summaryrefslogtreecommitdiff
path: root/image
diff options
context:
space:
mode:
Diffstat (limited to 'image')
-rw-r--r--image/bitmap.h8
-rw-r--r--image/gif.c14
-rw-r--r--image/gif.h5
-rw-r--r--image/gifread.c7
-rw-r--r--image/jpeg.c18
-rw-r--r--image/jpeg.h7
-rw-r--r--image/mng.c25
-rw-r--r--image/mng.h5
8 files changed, 76 insertions, 13 deletions
diff --git a/image/bitmap.h b/image/bitmap.h
index 8c33b8100..c187b3ecb 100644
--- a/image/bitmap.h
+++ b/image/bitmap.h
@@ -20,12 +20,18 @@
#include <stdbool.h>
#include <stdlib.h>
+typedef enum {
+ BITMAP_READY, /** Bitmap buffer is ready */
+ BITMAP_ALLOCATE_MEMORY, /** Allocate memory */
+ BITMAP_CLEAR_MEMORY, /** Clear the memory */
+} bitmap_state;
+
struct content;
/** An opaque image. */
struct bitmap;
-struct bitmap *bitmap_create(int width, int height, bool clear);
+struct bitmap *bitmap_create(int width, int height, bitmap_state state);
void bitmap_set_opaque(struct bitmap *bitmap, bool opaque);
bool bitmap_test_opaque(struct bitmap *bitmap);
bool bitmap_get_opaque(struct bitmap *bitmap);
diff --git a/image/gif.c b/image/gif.c
index 8ec0a6ef4..312139173 100644
--- a/image/gif.c
+++ b/image/gif.c
@@ -126,6 +126,20 @@ bool nsgif_redraw(struct content *c, int x, int y,
}
+bool nsgif_redraw_tiled(struct content *c, int x, int y,
+ int width, int height,
+ int clip_x0, int clip_y0, int clip_x1, int clip_y1,
+ float scale, unsigned long background_colour,
+ bool repeat_x, bool repeat_y) {
+
+ if (c->data.gif.current_frame != c->data.gif.gif->decoded_frame)
+ nsgif_get_frame(c);
+ c->bitmap = c->data.gif.gif->frame_image;
+ return plot.bitmap_tile(x, y, width, height, c->bitmap, background_colour,
+ repeat_x, repeat_y);
+}
+
+
void nsgif_destroy(struct content *c)
{
/* Free all the associated memory buffers
diff --git a/image/gif.h b/image/gif.h
index e280cefbd..88b50e947 100644
--- a/image/gif.h
+++ b/image/gif.h
@@ -25,5 +25,10 @@ bool nsgif_redraw(struct content *c, int x, int y,
int width, int height,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, unsigned long background_colour);
+bool nsgif_redraw_tiled(struct content *c, int x, int y,
+ int width, int height,
+ int clip_x0, int clip_y0, int clip_x1, int clip_y1,
+ float scale, unsigned long background_colour,
+ bool repeat_x, bool repeat_y);
#endif
diff --git a/image/gifread.c b/image/gifread.c
index 76a067c68..ba26452d8 100644
--- a/image/gifread.c
+++ b/image/gifread.c
@@ -204,7 +204,7 @@ int gif_initialise(struct gif_animation *gif) {
/* Initialise the sprite header
*/
- if ((gif->frame_image = bitmap_create(gif->width, gif->height, false)) == NULL) {
+ if ((gif->frame_image = bitmap_create(gif->width, gif->height, BITMAP_ALLOCATE_MEMORY)) == NULL) {
gif_finalise(gif);
return GIF_INSUFFICIENT_MEMORY;
}
@@ -273,7 +273,8 @@ static int gif_initialise_sprite(struct gif_animation *gif, unsigned int width,
/* Check if we've changed
*/
- if ((width <= gif->width) && (height <= gif->height)) return 0;
+ if ((width <= gif->width) && (height <= gif->height))
+ return 0;
/* Get our maximum values
*/
@@ -282,7 +283,7 @@ static int gif_initialise_sprite(struct gif_animation *gif, unsigned int width,
/* Allocate some more memory
*/
- if ((buffer = bitmap_create(max_width, max_height, false)) == NULL)
+ if ((buffer = bitmap_create(max_width, max_height, BITMAP_ALLOCATE_MEMORY)) == NULL)
return GIF_INSUFFICIENT_MEMORY;
bitmap_destroy(gif->frame_image);
gif->frame_image = buffer;
diff --git a/image/jpeg.c b/image/jpeg.c
index 86f205964..3efe698df 100644
--- a/image/jpeg.c
+++ b/image/jpeg.c
@@ -94,7 +94,7 @@ bool nsjpeg_convert(struct content *c, int w, int h)
width = cinfo.output_width;
height = cinfo.output_height;
- bitmap = bitmap_create(width, height, false);
+ bitmap = bitmap_create(width, height, BITMAP_ALLOCATE_MEMORY);
if (bitmap)
pixels = bitmap_get_buffer(bitmap);
if ((!bitmap) || (!pixels)) {
@@ -227,6 +227,22 @@ bool nsjpeg_redraw(struct content *c, int x, int y,
/**
+ * Redraw a CONTENT_JPEG with appropriate tiling.
+ */
+
+bool nsjpeg_redraw_tiled(struct content *c, int x, int y,
+ int width, int height,
+ int clip_x0, int clip_y0, int clip_x1, int clip_y1,
+ float scale, unsigned long background_colour,
+ bool repeat_x, bool repeat_y)
+{
+ return plot.bitmap_tile(x, y, width, height,
+ c->bitmap, background_colour,
+ repeat_x, repeat_y);
+}
+
+
+/**
* Destroy a CONTENT_JPEG and free all resources it owns.
*/
diff --git a/image/jpeg.h b/image/jpeg.h
index 61f6b4d67..9375a10b6 100644
--- a/image/jpeg.h
+++ b/image/jpeg.h
@@ -22,10 +22,15 @@ struct content_jpeg_data {
};
bool nsjpeg_convert(struct content *c, int width, int height);
+void nsjpeg_destroy(struct content *c);
bool nsjpeg_redraw(struct content *c, int x, int y,
int width, int height,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, unsigned long background_colour);
-void nsjpeg_destroy(struct content *c);
+bool nsjpeg_redraw_tiled(struct content *c, int x, int y,
+ int width, int height,
+ int clip_x0, int clip_y0, int clip_x1, int clip_y1,
+ float scale, unsigned long background_colour,
+ bool repeat_x, bool repeat_y);
#endif
diff --git a/image/mng.c b/image/mng.c
index 219de6d08..838595960 100644
--- a/image/mng.c
+++ b/image/mng.c
@@ -190,7 +190,7 @@ mng_bool nsmng_processheader(mng_handle mng, mng_uint32 width, mng_uint32 height
LOG(("processing header (%p) %d, %d", c, width, height));
- c->bitmap = bitmap_create(width, height, false);
+ c->bitmap = bitmap_create(width, height, BITMAP_ALLOCATE_MEMORY);
if (!c->bitmap) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
@@ -450,21 +450,32 @@ bool nsmng_redraw(struct content *c, int x, int y,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, unsigned long background_colour)
{
+ return nsmng_redraw_tiled(c, x, y, width, height,
+ clip_x0, clip_y0, clip_x1, clip_y1,
+ scale, background_colour,
+ false, false);
+}
+
+
+bool nsmng_redraw_tiled(struct content *c, int x, int y,
+ int width, int height,
+ int clip_x0, int clip_y0, int clip_x1, int clip_y1,
+ float scale, unsigned long background_colour,
+ bool repeat_x, bool repeat_y)
+{
bool ret;
/* mark image as having been requested to display */
- if (!c->data.mng.displayed)
- c->data.mng.displayed = true;
+ c->data.mng.displayed = true;
if ((c->bitmap) && (c->data.mng.opaque_test_pending)) {
bitmap_set_opaque(c->bitmap, bitmap_test_opaque(c->bitmap));
c->data.mng.opaque_test_pending = false;
}
- assert(c != NULL);
-
- ret = plot.bitmap(x, y, width, height,
- c->bitmap, background_colour);
+ ret = plot.bitmap_tile(x, y, width, height,
+ c->bitmap, background_colour,
+ repeat_x, repeat_y);
/* Check if we need to restart the animation
*/
diff --git a/image/mng.h b/image/mng.h
index 8f2ca8e76..1dbcb849c 100644
--- a/image/mng.h
+++ b/image/mng.h
@@ -35,4 +35,9 @@ bool nsmng_redraw(struct content *c, int x, int y,
int width, int height,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, unsigned long background_colour);
+bool nsmng_redraw_tiled(struct content *c, int x, int y,
+ int width, int height,
+ int clip_x0, int clip_y0, int clip_x1, int clip_y1,
+ float scale, unsigned long background_colour,
+ bool repeat_x, bool repeat_y);
#endif