2004-08-15 23:06:24 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2004 John M Bell <jmb202@ecs.soton.ac.uk>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-08-15 23:06:24 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2014-06-05 18:14:49 +04:00
|
|
|
#include <swis.h>
|
2016-04-22 00:36:21 +03:00
|
|
|
#include <stdlib.h>
|
2014-06-05 18:14:49 +04:00
|
|
|
#include <oslib/colourtrans.h>
|
|
|
|
#include <oslib/osspriteop.h>
|
|
|
|
|
2013-05-26 01:46:27 +04:00
|
|
|
#include "utils/nsoption.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/log.h"
|
2004-08-15 23:06:24 +04:00
|
|
|
|
2014-06-05 18:14:49 +04:00
|
|
|
#include "riscos/image.h"
|
|
|
|
#include "riscos/gui.h"
|
|
|
|
#include "riscos/tinct.h"
|
2004-08-15 23:06:24 +04:00
|
|
|
|
2005-04-11 03:26:34 +04:00
|
|
|
static bool image_redraw_tinct(osspriteop_id header, int x, int y,
|
2004-08-15 23:06:24 +04:00
|
|
|
int req_width, int req_height, int width, int height,
|
2008-09-29 02:37:13 +04:00
|
|
|
colour background_colour, bool repeatx, bool repeaty,
|
2004-11-03 02:23:07 +03:00
|
|
|
bool alpha, unsigned int tinct_options);
|
2005-04-11 03:26:34 +04:00
|
|
|
static bool image_redraw_os(osspriteop_id header, int x, int y,
|
2004-08-15 23:06:24 +04:00
|
|
|
int req_width, int req_height, int width, int height);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plot an image at the given coordinates using the method specified
|
|
|
|
*
|
|
|
|
* \param area The sprite area containing the sprite
|
|
|
|
* \param x Left edge of sprite
|
|
|
|
* \param y Top edge of sprite
|
|
|
|
* \param req_width The requested width of the sprite
|
|
|
|
* \param req_height The requested height of the sprite
|
|
|
|
* \param width The actual width of the sprite
|
|
|
|
* \param height The actual height of the sprite
|
|
|
|
* \param background_colour The background colour to blend to
|
|
|
|
* \param repeatx Repeat the image in the x direction
|
|
|
|
* \param repeaty Repeat the image in the y direction
|
2004-11-03 02:23:07 +03:00
|
|
|
* \param background Use background image settings (otherwise foreground)
|
2004-08-15 23:06:24 +04:00
|
|
|
* \param type The plot method to use
|
|
|
|
* \return true on success, false otherwise
|
|
|
|
*/
|
|
|
|
bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
|
|
|
|
int req_height, int width, int height,
|
2008-09-29 02:37:13 +04:00
|
|
|
colour background_colour,
|
2004-11-03 02:23:07 +03:00
|
|
|
bool repeatx, bool repeaty, bool background, image_type type)
|
2004-08-15 23:06:24 +04:00
|
|
|
{
|
2004-11-03 02:23:07 +03:00
|
|
|
unsigned int tinct_options;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-01-25 02:02:44 +03:00
|
|
|
/* failed decompression/loading can result in no image being present */
|
|
|
|
if (!area)
|
|
|
|
return false;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2005-04-11 03:26:34 +04:00
|
|
|
osspriteop_id header = (osspriteop_id)
|
|
|
|
((char*) area + area->first);
|
2004-10-18 01:16:00 +04:00
|
|
|
req_width *= 2;
|
|
|
|
req_height *= 2;
|
|
|
|
width *= 2;
|
|
|
|
height *= 2;
|
2013-05-28 19:44:46 +04:00
|
|
|
tinct_options = background ? nsoption_int(plot_bg_quality) :
|
|
|
|
nsoption_int(plot_fg_quality);
|
2004-08-15 23:06:24 +04:00
|
|
|
switch (type) {
|
|
|
|
case IMAGE_PLOT_TINCT_ALPHA:
|
2005-04-11 03:26:34 +04:00
|
|
|
return image_redraw_tinct(header, x, y,
|
2004-08-15 23:06:24 +04:00
|
|
|
req_width, req_height,
|
|
|
|
width, height,
|
|
|
|
background_colour,
|
2004-11-03 02:23:07 +03:00
|
|
|
repeatx, repeaty, true,
|
|
|
|
tinct_options);
|
2004-08-15 23:06:24 +04:00
|
|
|
case IMAGE_PLOT_TINCT_OPAQUE:
|
2005-04-11 03:26:34 +04:00
|
|
|
return image_redraw_tinct(header, x, y,
|
2004-08-15 23:06:24 +04:00
|
|
|
req_width, req_height,
|
|
|
|
width, height,
|
|
|
|
background_colour,
|
2004-11-03 02:23:07 +03:00
|
|
|
repeatx, repeaty, false,
|
|
|
|
tinct_options);
|
2004-08-15 23:06:24 +04:00
|
|
|
case IMAGE_PLOT_OS:
|
2005-04-11 03:26:34 +04:00
|
|
|
return image_redraw_os(header, x, y, req_width,
|
2004-08-15 23:06:24 +04:00
|
|
|
req_height, width, height);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-08-16 02:36:13 +04:00
|
|
|
* Plot an image at the given coordinates using tinct
|
2004-08-15 23:06:24 +04:00
|
|
|
*
|
2014-11-13 01:36:11 +03:00
|
|
|
* \param header The sprite header
|
2004-08-15 23:06:24 +04:00
|
|
|
* \param x Left edge of sprite
|
|
|
|
* \param y Top edge of sprite
|
|
|
|
* \param req_width The requested width of the sprite
|
|
|
|
* \param req_height The requested height of the sprite
|
|
|
|
* \param width The actual width of the sprite
|
|
|
|
* \param height The actual height of the sprite
|
|
|
|
* \param background_colour The background colour to blend to
|
2004-08-16 02:36:13 +04:00
|
|
|
* \param repeatx Repeat the image in the x direction
|
|
|
|
* \param repeaty Repeat the image in the y direction
|
|
|
|
* \param alpha Use the alpha channel
|
2004-11-03 02:23:07 +03:00
|
|
|
* \param tinct_options The base option set to use
|
2004-08-15 23:06:24 +04:00
|
|
|
* \return true on success, false otherwise
|
|
|
|
*/
|
2005-04-11 03:26:34 +04:00
|
|
|
bool image_redraw_tinct(osspriteop_id header, int x, int y,
|
2004-08-15 23:06:24 +04:00
|
|
|
int req_width, int req_height, int width, int height,
|
2008-09-29 02:37:13 +04:00
|
|
|
colour background_colour, bool repeatx, bool repeaty,
|
2004-11-03 02:23:07 +03:00
|
|
|
bool alpha, unsigned int tinct_options)
|
2004-08-15 23:06:24 +04:00
|
|
|
{
|
|
|
|
_kernel_oserror *error;
|
|
|
|
|
2004-11-03 02:23:07 +03:00
|
|
|
/* Set up our flagword
|
|
|
|
*/
|
|
|
|
tinct_options |= background_colour << tinct_BACKGROUND_SHIFT;
|
2006-11-27 18:35:18 +03:00
|
|
|
if (print_active)
|
2004-11-03 02:23:07 +03:00
|
|
|
tinct_options |= tinct_USE_OS_SPRITE_OP;
|
2004-08-15 23:06:24 +04:00
|
|
|
if (repeatx)
|
|
|
|
tinct_options |= tinct_FILL_HORIZONTALLY;
|
|
|
|
if (repeaty)
|
|
|
|
tinct_options |= tinct_FILL_VERTICALLY;
|
|
|
|
|
2004-08-16 02:36:13 +04:00
|
|
|
if (alpha) {
|
|
|
|
error = _swix(Tinct_PlotScaledAlpha, _INR(2,7),
|
2005-04-11 03:26:34 +04:00
|
|
|
header, x, y - req_height,
|
2004-08-16 02:36:13 +04:00
|
|
|
req_width, req_height, tinct_options);
|
2004-08-15 23:06:24 +04:00
|
|
|
} else {
|
2004-08-16 02:36:13 +04:00
|
|
|
error = _swix(Tinct_PlotScaled, _INR(2,7),
|
2005-04-11 03:26:34 +04:00
|
|
|
header, x, y - req_height,
|
2004-08-16 02:36:13 +04:00
|
|
|
req_width, req_height, tinct_options);
|
2004-10-18 01:16:00 +04:00
|
|
|
}
|
2004-08-15 23:06:24 +04:00
|
|
|
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xtinct_plotscaled%s: 0x%x: %s",
|
|
|
|
(alpha ? "alpha" : ""), error->errnum, error->errmess);
|
2004-08-15 23:06:24 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-08-16 02:36:13 +04:00
|
|
|
|
2004-08-15 23:06:24 +04:00
|
|
|
/**
|
|
|
|
* Plot an image at the given coordinates using os_spriteop
|
|
|
|
*
|
2014-11-13 01:36:11 +03:00
|
|
|
* \param header The sprite header
|
2004-08-15 23:06:24 +04:00
|
|
|
* \param x Left edge of sprite
|
|
|
|
* \param y Top edge of sprite
|
|
|
|
* \param req_width The requested width of the sprite
|
|
|
|
* \param req_height The requested height of the sprite
|
|
|
|
* \param width The actual width of the sprite
|
|
|
|
* \param height The actual height of the sprite
|
|
|
|
* \return true on success, false otherwise
|
|
|
|
*/
|
2005-04-11 03:26:34 +04:00
|
|
|
bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
|
2004-08-15 23:06:24 +04:00
|
|
|
int req_height, int width, int height)
|
|
|
|
{
|
2009-03-27 05:15:24 +03:00
|
|
|
int size;
|
2004-08-15 23:06:24 +04:00
|
|
|
os_factors f;
|
|
|
|
osspriteop_trans_tab *table;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xcolourtrans_generate_table_for_sprite(
|
2005-04-11 03:26:34 +04:00
|
|
|
(osspriteop_area *)0x100, header,
|
2009-12-02 19:30:44 +03:00
|
|
|
os_CURRENT_MODE,
|
2004-08-15 23:06:24 +04:00
|
|
|
colourtrans_CURRENT_PALETTE,
|
|
|
|
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xcolourtrans_generate_table_for_sprite: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2004-08-15 23:06:24 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
table = calloc(size, sizeof(char));
|
|
|
|
if (!table) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "malloc failed");
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("NoMemory", 0);
|
2004-08-15 23:06:24 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xcolourtrans_generate_table_for_sprite(
|
2005-04-11 03:26:34 +04:00
|
|
|
(osspriteop_area *)0x100, header,
|
2009-12-02 19:30:44 +03:00
|
|
|
os_CURRENT_MODE,
|
2004-08-15 23:06:24 +04:00
|
|
|
colourtrans_CURRENT_PALETTE,
|
|
|
|
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xcolourtrans_generate_table_for_sprite: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2004-08-15 23:06:24 +04:00
|
|
|
free(table);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
f.xmul = req_width;
|
|
|
|
f.ymul = req_height;
|
2004-08-16 02:36:13 +04:00
|
|
|
f.xdiv = width;
|
|
|
|
f.ydiv = height;
|
2004-08-15 23:06:24 +04:00
|
|
|
|
|
|
|
error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
|
2005-04-11 03:26:34 +04:00
|
|
|
(osspriteop_area *)0x100, header,
|
2004-08-15 23:06:24 +04:00
|
|
|
x, (int)(y - req_height),
|
2004-08-16 02:36:13 +04:00
|
|
|
8, &f, table);
|
2004-08-15 23:06:24 +04:00
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xosspriteop_put_sprite_scaled: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2004-08-15 23:06:24 +04:00
|
|
|
free(table);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(table);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|