Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/9f3d0126503d0f22ffa6c...
...commit
http://git.netsurf-browser.org/netsurf.git/commit/9f3d0126503d0f22ffa6cd3...
...tree
http://git.netsurf-browser.org/netsurf.git/tree/9f3d0126503d0f22ffa6cd3d0...
The branch, master has been updated
via 9f3d0126503d0f22ffa6cd3d0d9d907d8d400595 (commit)
via 287e5e89b56c688bfc67bd742b386c68506c6e40 (commit)
via d58f893c57711fd353f33404418f54a824b1c304 (commit)
via e177254db462891236454a262afc8f1f7a31eaf8 (commit)
via 4b15a49bde7343c707263c7ee1d73be07a0bf060 (commit)
via b65abe987c4611bbd514c921a90f1800abb1c4b0 (commit)
from fa64d91d12c94c9aa230cd231b1d2e16054b41f2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=9f3d0126503d0f22ffa...
commit 9f3d0126503d0f22ffa6cd3d0d9d907d8d400595
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: Image: Tinct workaround: Use OS alpha sprite rendering.
If NetSurf is configured to use OS for image rendering, and the
OS supports Alpha sprites, avoid going via Tinct completely.
Going via Tinct loses the alpha channel. However, with this
workaround, we lose Tinct's pretiling optimisation for tiling
tiny sprites.
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index 83653ba..0bad948 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -168,6 +168,27 @@ static bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
}
/**
+ * Override a sprite's mode.
+ *
+ * Only replaces mode if existing mode matches \ref old.
+ *
+ * \param[in] area The sprite area containing the sprite.
+ * \param[in] old Existing sprite mode to check for.
+ * \param[in] new Sprite mode to set if existing mode is expected.
+ */
+static inline void image__override_sprite_mode(
+ osspriteop_area *area,
+ os_mode old,
+ os_mode new)
+{
+ osspriteop_header *sprite = (osspriteop_header *)(area + 1);
+
+ if (sprite->mode == old) {
+ sprite->mode = new;
+ }
+}
+
+/**
* Plot an image at the given coordinates using the method specified
*
* \param area The sprite area containing the sprite
@@ -190,6 +211,8 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
bool repeatx, bool repeaty, bool background, image_type type)
{
unsigned int tinct_options;
+ bool tinct_avoid = false;
+ bool res = false;
/* failed decompression/loading can result in no image being present */
if (!area)
@@ -203,28 +226,57 @@ bool image_redraw(osspriteop_area *area, int x, int y, int
req_width,
height *= 2;
tinct_options = background ? nsoption_int(plot_bg_quality) :
nsoption_int(plot_fg_quality);
+
+ if (os_alpha_sprite_supported) {
+ /* Ideally Tinct would be updated to understand that modern OS
+ * versions can cope with alpha channels, and we could continue
+ * to pass to Tinct. The main drawback of fully avoiding Tinct
+ * is that we lose the optimisation for tiling tiny bitmaps.
+ */
+ if (tinct_options & tinct_USE_OS_SPRITE_OP) {
+ type = IMAGE_PLOT_OS;
+ tinct_avoid = true;
+ }
+ }
+
switch (type) {
case IMAGE_PLOT_TINCT_ALPHA:
- return image_redraw_tinct(header, x, y,
+ res = image_redraw_tinct(header, x, y,
req_width, req_height,
width, height,
background_colour,
repeatx, repeaty, true,
tinct_options);
+ break;
+
case IMAGE_PLOT_TINCT_OPAQUE:
- return image_redraw_tinct(header, x, y,
+ res = image_redraw_tinct(header, x, y,
req_width, req_height,
width, height,
background_colour,
repeatx, repeaty, false,
tinct_options);
+ break;
+
case IMAGE_PLOT_OS:
- return image_redraw_os(header, x, y, req_width,
+ if (tinct_avoid) {
+ image__override_sprite_mode(area,
+ tinct_SPRITE_MODE,
+ alpha_SPRITE_MODE);
+ }
+ res = image_redraw_os(header, x, y, req_width,
req_height, width, height,
repeatx | repeaty);
+ if (tinct_avoid) {
+ image__override_sprite_mode(area,
+ alpha_SPRITE_MODE,
+ tinct_SPRITE_MODE);
+ }
+ break;
+
default:
break;
}
- return false;
+ return res;
}
diff --git a/frontends/riscos/tinct.h b/frontends/riscos/tinct.h
index e02dcde..2931372 100644
--- a/frontends/riscos/tinct.h
+++ b/frontends/riscos/tinct.h
@@ -148,7 +148,16 @@
*/
#define tinct_BACKGROUND_SHIFT 0x08
-/* Sprite mode
-*/
+/* Sprite mode tinct
+ *
+ * Mode is: 32bpp 8:8:8:8 XXBBGGRR mode (a RISC OS 3.5+ type)
+ * We put alpha in the unused XX channel and Tinct treats it as alpha.
+ */
#define tinct_SPRITE_MODE (os_mode)0x301680b5
+
+/* Sprite mode alpha
+ *
+ * Mode is: 32bpp 8:8:8:8 AABBGGRR mode (a RISC OS 5 type)
+ */
+#define alpha_SPRITE_MODE (os_mode)0x78608051
#endif
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=287e5e89b56c688bfc6...
commit 287e5e89b56c688bfc67bd742b386c68506c6e40
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: GUI: Add check for sprite alpha channel OS support.
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index cc12eac..3f2a212 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -94,6 +94,7 @@ bool riscos_done = false;
extern bool ro_plot_patterned_lines;
int os_version = 0;
+bool os_alpha_sprite_supported = false;
const char * const __dynamic_da_name = "NetSurf"; /**< For UnixLib. */
int __dynamic_da_max_size = 128 * 1024 * 1024; /**< For UnixLib. */
@@ -1110,6 +1111,33 @@ static void ro_gui_check_resolvers(void)
}
}
+/**
+ * Set global variable for whether the OS version supports alpha channels.
+ */
+static void ro_gui__check_os_alpha_sprites(void)
+{
+ os_error *error;
+ int var_val;
+ bits psr;
+
+ psr = 0;
+ error = xos_read_mode_variable(alpha_SPRITE_MODE,
+ os_MODEVAR_MODE_FLAGS, &var_val, &psr);
+ if (error) {
+ NSLOG(netsurf, ERROR, "xos_read_mode_variable: 0x%x: %s",
+ error->errnum, error->errmess);
+ return;
+ }
+
+ if (var_val == (1 << 15)) {
+ os_alpha_sprite_supported = true;
+ } else {
+ os_alpha_sprite_supported = false;
+ }
+
+ NSLOG(netsurf, INFO, "OS supports alpha sprites: %s (%i)",
+ os_alpha_sprite_supported ? "yes" : "no", var_val);
+}
/**
* Initialise the RISC OS specific GUI.
@@ -1151,6 +1179,7 @@ static nserror gui_init(int argc, char** argv)
* (remember that it's preferable to check for specific features
* being present) */
xos_byte(osbyte_IN_KEY, 0, 0xff, &os_version, NULL);
+ ro_gui__check_os_alpha_sprites();
/* the first release version of the A9home OS is incapable of
plotting patterned lines (presumably a fault in the hw acceleration) */
diff --git a/frontends/riscos/gui.h b/frontends/riscos/gui.h
index 5ff17e9..03989ae 100644
--- a/frontends/riscos/gui.h
+++ b/frontends/riscos/gui.h
@@ -34,6 +34,8 @@
extern int os_version;
+extern bool os_alpha_sprite_supported;
+
extern const char * NETSURF_DIR;
struct toolbar;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=d58f893c57711fd353f...
commit d58f893c57711fd353f33404418f54a824b1c304
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: Image: Add support for tiled plots with OS renderer.
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index 885364e..83653ba 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -92,10 +92,11 @@ static bool image_redraw_tinct(osspriteop_id header, int x, int y,
* \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 tile Whether to tile the sprite
* \return true on success, false otherwise
*/
static bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
- int req_height, int width, int height)
+ int req_height, int width, int height, bool tile)
{
int size;
os_factors f;
@@ -141,10 +142,17 @@ static bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
f.xdiv = width;
f.ydiv = height;
- error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
- osspriteop_UNSPECIFIED, header,
- x, (int)(y - req_height),
- osspriteop_USE_MASK, &f, table);
+ if (tile) {
+ error = xosspriteop_plot_tiled_sprite(osspriteop_PTR,
+ osspriteop_UNSPECIFIED, header,
+ x, (int)(y - req_height),
+ osspriteop_USE_MASK, &f, table);
+ } else {
+ error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
+ osspriteop_UNSPECIFIED, header,
+ x, (int)(y - req_height),
+ osspriteop_USE_MASK, &f, table);
+ }
if (error) {
NSLOG(netsurf, INFO,
"xosspriteop_put_sprite_scaled: 0x%x: %s",
@@ -212,7 +220,8 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
tinct_options);
case IMAGE_PLOT_OS:
return image_redraw_os(header, x, y, req_width,
- req_height, width, height);
+ req_height, width, height,
+ repeatx | repeaty);
default:
break;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=e177254db4628912364...
commit e177254db462891236454a262afc8f1f7a31eaf8
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: Image: Remove forward declaration.
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index 4cf2869..885364e 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -29,74 +29,6 @@
#include "riscos/gui.h"
#include "riscos/tinct.h"
-static bool image_redraw_tinct(osspriteop_id header, int x, int y,
- int req_width, int req_height, int width, int height,
- colour background_colour, bool repeatx, bool repeaty,
- bool alpha, unsigned int tinct_options);
-static bool image_redraw_os(osspriteop_id header, int x, int y,
- 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
- * \param background Use background image settings (otherwise foreground)
- * \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,
- colour background_colour,
- bool repeatx, bool repeaty, bool background, image_type type)
-{
- unsigned int tinct_options;
-
- /* failed decompression/loading can result in no image being present */
- if (!area)
- return false;
-
- osspriteop_id header = (osspriteop_id)
- ((char*) area + area->first);
- req_width *= 2;
- req_height *= 2;
- width *= 2;
- height *= 2;
- tinct_options = background ? nsoption_int(plot_bg_quality) :
- nsoption_int(plot_fg_quality);
- switch (type) {
- case IMAGE_PLOT_TINCT_ALPHA:
- return image_redraw_tinct(header, x, y,
- req_width, req_height,
- width, height,
- background_colour,
- repeatx, repeaty, true,
- tinct_options);
- case IMAGE_PLOT_TINCT_OPAQUE:
- return image_redraw_tinct(header, x, y,
- req_width, req_height,
- width, height,
- background_colour,
- repeatx, repeaty, false,
- tinct_options);
- case IMAGE_PLOT_OS:
- return image_redraw_os(header, x, y, req_width,
- req_height, width, height);
- default:
- break;
- }
-
- return false;
-}
-
/**
* Plot an image at the given coordinates using tinct
*
@@ -114,7 +46,7 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
* \param tinct_options The base option set to use
* \return true on success, false otherwise
*/
-bool image_redraw_tinct(osspriteop_id header, int x, int y,
+static bool image_redraw_tinct(osspriteop_id header, int x, int y,
int req_width, int req_height, int width, int height,
colour background_colour, bool repeatx, bool repeaty,
bool alpha, unsigned int tinct_options)
@@ -150,7 +82,6 @@ bool image_redraw_tinct(osspriteop_id header, int x, int y,
return true;
}
-
/**
* Plot an image at the given coordinates using os_spriteop
*
@@ -163,7 +94,7 @@ bool image_redraw_tinct(osspriteop_id header, int x, int y,
* \param height The actual height of the sprite
* \return true on success, false otherwise
*/
-bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
+static bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
int req_height, int width, int height)
{
int size;
@@ -227,3 +158,64 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
return true;
}
+
+/**
+ * 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
+ * \param background Use background image settings (otherwise foreground)
+ * \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,
+ colour background_colour,
+ bool repeatx, bool repeaty, bool background, image_type type)
+{
+ unsigned int tinct_options;
+
+ /* failed decompression/loading can result in no image being present */
+ if (!area)
+ return false;
+
+ osspriteop_id header = (osspriteop_id)
+ ((char*) area + area->first);
+ req_width *= 2;
+ req_height *= 2;
+ width *= 2;
+ height *= 2;
+ tinct_options = background ? nsoption_int(plot_bg_quality) :
+ nsoption_int(plot_fg_quality);
+ switch (type) {
+ case IMAGE_PLOT_TINCT_ALPHA:
+ return image_redraw_tinct(header, x, y,
+ req_width, req_height,
+ width, height,
+ background_colour,
+ repeatx, repeaty, true,
+ tinct_options);
+ case IMAGE_PLOT_TINCT_OPAQUE:
+ return image_redraw_tinct(header, x, y,
+ req_width, req_height,
+ width, height,
+ background_colour,
+ repeatx, repeaty, false,
+ tinct_options);
+ case IMAGE_PLOT_OS:
+ return image_redraw_os(header, x, y, req_width,
+ req_height, width, height);
+ default:
+ break;
+ }
+
+ return false;
+}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=4b15a49bde7343c7072...
commit 4b15a49bde7343c707263c7ee1d73be07a0bf060
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: Image: Use #define to enable use of mask.
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index e6e0f7f..4cf2869 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -213,7 +213,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
osspriteop_UNSPECIFIED, header,
x, (int)(y - req_height),
- 8, &f, table);
+ osspriteop_USE_MASK, &f, table);
if (error) {
NSLOG(netsurf, INFO,
"xosspriteop_put_sprite_scaled: 0x%x: %s",
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=b65abe987c4611bbd51...
commit b65abe987c4611bbd514c921a90f1800abb1c4b0
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: Image: Use #define for unspecified sprite area.
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index 30cb300..e6e0f7f 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -172,7 +172,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
os_error *error;
error = xcolourtrans_generate_table_for_sprite(
- (osspriteop_area *)0x100, header,
+ osspriteop_UNSPECIFIED, header,
os_CURRENT_MODE,
colourtrans_CURRENT_PALETTE,
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
@@ -192,7 +192,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
}
error = xcolourtrans_generate_table_for_sprite(
- (osspriteop_area *)0x100, header,
+ osspriteop_UNSPECIFIED, header,
os_CURRENT_MODE,
colourtrans_CURRENT_PALETTE,
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
@@ -211,7 +211,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
f.ydiv = height;
error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
- (osspriteop_area *)0x100, header,
+ osspriteop_UNSPECIFIED, header,
x, (int)(y - req_height),
8, &f, table);
if (error) {
-----------------------------------------------------------------------
Summary of changes:
frontends/riscos/gui.c | 29 +++++++
frontends/riscos/gui.h | 2 +
frontends/riscos/image.c | 209 +++++++++++++++++++++++++++++-----------------
frontends/riscos/tinct.h | 13 ++-
4 files changed, 173 insertions(+), 80 deletions(-)
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index cc12eac..3f2a212 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -94,6 +94,7 @@ bool riscos_done = false;
extern bool ro_plot_patterned_lines;
int os_version = 0;
+bool os_alpha_sprite_supported = false;
const char * const __dynamic_da_name = "NetSurf"; /**< For UnixLib. */
int __dynamic_da_max_size = 128 * 1024 * 1024; /**< For UnixLib. */
@@ -1110,6 +1111,33 @@ static void ro_gui_check_resolvers(void)
}
}
+/**
+ * Set global variable for whether the OS version supports alpha channels.
+ */
+static void ro_gui__check_os_alpha_sprites(void)
+{
+ os_error *error;
+ int var_val;
+ bits psr;
+
+ psr = 0;
+ error = xos_read_mode_variable(alpha_SPRITE_MODE,
+ os_MODEVAR_MODE_FLAGS, &var_val, &psr);
+ if (error) {
+ NSLOG(netsurf, ERROR, "xos_read_mode_variable: 0x%x: %s",
+ error->errnum, error->errmess);
+ return;
+ }
+
+ if (var_val == (1 << 15)) {
+ os_alpha_sprite_supported = true;
+ } else {
+ os_alpha_sprite_supported = false;
+ }
+
+ NSLOG(netsurf, INFO, "OS supports alpha sprites: %s (%i)",
+ os_alpha_sprite_supported ? "yes" : "no", var_val);
+}
/**
* Initialise the RISC OS specific GUI.
@@ -1151,6 +1179,7 @@ static nserror gui_init(int argc, char** argv)
* (remember that it's preferable to check for specific features
* being present) */
xos_byte(osbyte_IN_KEY, 0, 0xff, &os_version, NULL);
+ ro_gui__check_os_alpha_sprites();
/* the first release version of the A9home OS is incapable of
plotting patterned lines (presumably a fault in the hw acceleration) */
diff --git a/frontends/riscos/gui.h b/frontends/riscos/gui.h
index 5ff17e9..03989ae 100644
--- a/frontends/riscos/gui.h
+++ b/frontends/riscos/gui.h
@@ -34,6 +34,8 @@
extern int os_version;
+extern bool os_alpha_sprite_supported;
+
extern const char * NETSURF_DIR;
struct toolbar;
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index 30cb300..0bad948 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -29,74 +29,6 @@
#include "riscos/gui.h"
#include "riscos/tinct.h"
-static bool image_redraw_tinct(osspriteop_id header, int x, int y,
- int req_width, int req_height, int width, int height,
- colour background_colour, bool repeatx, bool repeaty,
- bool alpha, unsigned int tinct_options);
-static bool image_redraw_os(osspriteop_id header, int x, int y,
- 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
- * \param background Use background image settings (otherwise foreground)
- * \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,
- colour background_colour,
- bool repeatx, bool repeaty, bool background, image_type type)
-{
- unsigned int tinct_options;
-
- /* failed decompression/loading can result in no image being present */
- if (!area)
- return false;
-
- osspriteop_id header = (osspriteop_id)
- ((char*) area + area->first);
- req_width *= 2;
- req_height *= 2;
- width *= 2;
- height *= 2;
- tinct_options = background ? nsoption_int(plot_bg_quality) :
- nsoption_int(plot_fg_quality);
- switch (type) {
- case IMAGE_PLOT_TINCT_ALPHA:
- return image_redraw_tinct(header, x, y,
- req_width, req_height,
- width, height,
- background_colour,
- repeatx, repeaty, true,
- tinct_options);
- case IMAGE_PLOT_TINCT_OPAQUE:
- return image_redraw_tinct(header, x, y,
- req_width, req_height,
- width, height,
- background_colour,
- repeatx, repeaty, false,
- tinct_options);
- case IMAGE_PLOT_OS:
- return image_redraw_os(header, x, y, req_width,
- req_height, width, height);
- default:
- break;
- }
-
- return false;
-}
-
/**
* Plot an image at the given coordinates using tinct
*
@@ -114,7 +46,7 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
* \param tinct_options The base option set to use
* \return true on success, false otherwise
*/
-bool image_redraw_tinct(osspriteop_id header, int x, int y,
+static bool image_redraw_tinct(osspriteop_id header, int x, int y,
int req_width, int req_height, int width, int height,
colour background_colour, bool repeatx, bool repeaty,
bool alpha, unsigned int tinct_options)
@@ -150,7 +82,6 @@ bool image_redraw_tinct(osspriteop_id header, int x, int y,
return true;
}
-
/**
* Plot an image at the given coordinates using os_spriteop
*
@@ -161,10 +92,11 @@ bool image_redraw_tinct(osspriteop_id header, int x, int y,
* \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 tile Whether to tile the sprite
* \return true on success, false otherwise
*/
-bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
- int req_height, int width, int height)
+static bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
+ int req_height, int width, int height, bool tile)
{
int size;
os_factors f;
@@ -172,7 +104,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
os_error *error;
error = xcolourtrans_generate_table_for_sprite(
- (osspriteop_area *)0x100, header,
+ osspriteop_UNSPECIFIED, header,
os_CURRENT_MODE,
colourtrans_CURRENT_PALETTE,
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
@@ -192,7 +124,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
}
error = xcolourtrans_generate_table_for_sprite(
- (osspriteop_area *)0x100, header,
+ osspriteop_UNSPECIFIED, header,
os_CURRENT_MODE,
colourtrans_CURRENT_PALETTE,
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
@@ -210,10 +142,17 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
f.xdiv = width;
f.ydiv = height;
- error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
- (osspriteop_area *)0x100, header,
- x, (int)(y - req_height),
- 8, &f, table);
+ if (tile) {
+ error = xosspriteop_plot_tiled_sprite(osspriteop_PTR,
+ osspriteop_UNSPECIFIED, header,
+ x, (int)(y - req_height),
+ osspriteop_USE_MASK, &f, table);
+ } else {
+ error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
+ osspriteop_UNSPECIFIED, header,
+ x, (int)(y - req_height),
+ osspriteop_USE_MASK, &f, table);
+ }
if (error) {
NSLOG(netsurf, INFO,
"xosspriteop_put_sprite_scaled: 0x%x: %s",
@@ -227,3 +166,117 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int
req_width,
return true;
}
+
+/**
+ * Override a sprite's mode.
+ *
+ * Only replaces mode if existing mode matches \ref old.
+ *
+ * \param[in] area The sprite area containing the sprite.
+ * \param[in] old Existing sprite mode to check for.
+ * \param[in] new Sprite mode to set if existing mode is expected.
+ */
+static inline void image__override_sprite_mode(
+ osspriteop_area *area,
+ os_mode old,
+ os_mode new)
+{
+ osspriteop_header *sprite = (osspriteop_header *)(area + 1);
+
+ if (sprite->mode == old) {
+ sprite->mode = new;
+ }
+}
+
+/**
+ * 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
+ * \param background Use background image settings (otherwise foreground)
+ * \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,
+ colour background_colour,
+ bool repeatx, bool repeaty, bool background, image_type type)
+{
+ unsigned int tinct_options;
+ bool tinct_avoid = false;
+ bool res = false;
+
+ /* failed decompression/loading can result in no image being present */
+ if (!area)
+ return false;
+
+ osspriteop_id header = (osspriteop_id)
+ ((char*) area + area->first);
+ req_width *= 2;
+ req_height *= 2;
+ width *= 2;
+ height *= 2;
+ tinct_options = background ? nsoption_int(plot_bg_quality) :
+ nsoption_int(plot_fg_quality);
+
+ if (os_alpha_sprite_supported) {
+ /* Ideally Tinct would be updated to understand that modern OS
+ * versions can cope with alpha channels, and we could continue
+ * to pass to Tinct. The main drawback of fully avoiding Tinct
+ * is that we lose the optimisation for tiling tiny bitmaps.
+ */
+ if (tinct_options & tinct_USE_OS_SPRITE_OP) {
+ type = IMAGE_PLOT_OS;
+ tinct_avoid = true;
+ }
+ }
+
+ switch (type) {
+ case IMAGE_PLOT_TINCT_ALPHA:
+ res = image_redraw_tinct(header, x, y,
+ req_width, req_height,
+ width, height,
+ background_colour,
+ repeatx, repeaty, true,
+ tinct_options);
+ break;
+
+ case IMAGE_PLOT_TINCT_OPAQUE:
+ res = image_redraw_tinct(header, x, y,
+ req_width, req_height,
+ width, height,
+ background_colour,
+ repeatx, repeaty, false,
+ tinct_options);
+ break;
+
+ case IMAGE_PLOT_OS:
+ if (tinct_avoid) {
+ image__override_sprite_mode(area,
+ tinct_SPRITE_MODE,
+ alpha_SPRITE_MODE);
+ }
+ res = image_redraw_os(header, x, y, req_width,
+ req_height, width, height,
+ repeatx | repeaty);
+ if (tinct_avoid) {
+ image__override_sprite_mode(area,
+ alpha_SPRITE_MODE,
+ tinct_SPRITE_MODE);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return res;
+}
diff --git a/frontends/riscos/tinct.h b/frontends/riscos/tinct.h
index e02dcde..2931372 100644
--- a/frontends/riscos/tinct.h
+++ b/frontends/riscos/tinct.h
@@ -148,7 +148,16 @@
*/
#define tinct_BACKGROUND_SHIFT 0x08
-/* Sprite mode
-*/
+/* Sprite mode tinct
+ *
+ * Mode is: 32bpp 8:8:8:8 XXBBGGRR mode (a RISC OS 3.5+ type)
+ * We put alpha in the unused XX channel and Tinct treats it as alpha.
+ */
#define tinct_SPRITE_MODE (os_mode)0x301680b5
+
+/* Sprite mode alpha
+ *
+ * Mode is: 32bpp 8:8:8:8 AABBGGRR mode (a RISC OS 5 type)
+ */
+#define alpha_SPRITE_MODE (os_mode)0x78608051
#endif
--
NetSurf Browser