summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/content.c105
-rw-r--r--content/content.h3
-rw-r--r--content/content_protected.h3
-rw-r--r--css/css.c1
-rw-r--r--desktop/browser.c2
-rw-r--r--desktop/print.c2
-rw-r--r--desktop/thumbnail.c2
-rw-r--r--desktop/tree.c2
-rw-r--r--gtk/Makefile.target6
-rw-r--r--image/bmp.c227
-rw-r--r--image/gif.c448
-rw-r--r--image/ico.c173
-rw-r--r--image/jpeg.c15
-rw-r--r--image/png.c15
-rw-r--r--image/rsvg.c184
-rw-r--r--render/html.c1
-rw-r--r--render/html_internal.h3
-rw-r--r--render/html_redraw.c10
-rw-r--r--render/textplain.c7
19 files changed, 500 insertions, 709 deletions
diff --git a/content/content.c b/content/content.c
index 0a47cfd65..cb8ecd4b3 100644
--- a/content/content.c
+++ b/content/content.c
@@ -464,119 +464,34 @@ void content_request_redraw(struct hlcache_handle *h,
}
/**
- * Display content on screen.
- *
- * Calls the redraw function for the content, if it exists.
- *
- * \param h content
- * \param x coordinate for top-left of redraw
- * \param y coordinate for top-left of redraw
- * \param width render width (not used for HTML redraw)
- * \param height render height (not used for HTML redraw)
- * \param clip clip rectangle
- * \param scale scale for redraw
- * \param background_colour the background colour
- * \return true if successful, false otherwise
- *
- * x, y and clip are coordinates from the top left of the canvas area.
- *
- * The top left corner of the clip rectangle is (x0, y0) and
- * the bottom right corner of the clip rectangle is (x1, y1).
- * Units for x, y and clip are pixels.
- *
- * Content scaling is handled differently for contents with and without
- * intrinsic dimensions.
- *
- * Content without intrinsic dimensions, e.g. HTML:
- * The scale value is applied (the content having been reformatted
- * appropriately beforehand). The width and height are not used.
+ * Display content on screen with optional tiling.
*
- * Content with intrinsic dimensions, e.g. images:
- * The scale value is not used. The content is scaled from its own
- * intrinsic dimensions to the passed render width and height.
+ * Calls the redraw_tile function for the content, or emulates it with the
+ * redraw function if it doesn't exist.
*/
bool content_redraw(hlcache_handle *h, int x, int y,
int width, int height, const struct rect *clip,
- float scale, colour background_colour)
+ float scale, colour background_colour,
+ bool repeat_x, bool repeat_y)
{
struct content *c = hlcache_handle_get_content(h);
- assert(c != 0);
+
+ assert(c != NULL);
if (c->locked) {
/* not safe to attempt redraw */
return true;
}
+ /* ensure we have a redrawable content */
if (c->handler->redraw == NULL) {
return true;
}
return c->handler->redraw(c, x, y, width, height,
- clip, scale, background_colour);
-}
-
-
-/**
- * Display content on screen with optional tiling.
- *
- * Calls the redraw_tile function for the content, or emulates it with the
- * redraw function if it doesn't exist.
- */
-
-bool content_redraw_tiled(hlcache_handle *h, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour,
- bool repeat_x, bool repeat_y)
-{
- struct content *c = hlcache_handle_get_content(h);
- int x0, y0, x1, y1;
-
- assert(c != 0);
-
-// LOG(("%p %s", c, c->url));
-
- if (c->locked)
- /* not safe to attempt redraw */
- return true;
-
- if (c->handler->redraw_tiled != NULL) {
- return c->handler->redraw_tiled(c, x, y, width, height,
- clip, scale, background_colour,
- repeat_x, repeat_y);
- } else {
- /* ensure we have a redrawable content */
- if ((c->handler->redraw == NULL) || (width == 0) ||
- (height == 0))
- return true;
- /* simple optimisation for no repeat (common for backgrounds) */
- if ((!repeat_x) && (!repeat_y))
- return c->handler->redraw(c, x, y, width,
- height, clip, scale, background_colour);
- /* find the redraw boundaries to loop within*/
- x0 = x;
- if (repeat_x) {
- for (; x0 > clip->x0; x0 -= width);
- x1 = clip->x1;
- } else {
- x1 = x + 1;
- }
- y0 = y;
- if (repeat_y) {
- for (; y0 > clip->y0; y0 -= height);
- y1 = clip->y1;
- } else {
- y1 = y + 1;
- }
- /* repeatedly plot our content */
- for (y = y0; y < y1; y += height)
- for (x = x0; x < x1; x += width)
- if (!c->handler->redraw(c, x, y,
- width, height, clip,
- scale, background_colour))
- return false;
- }
- return true;
+ clip, scale, background_colour,
+ repeat_x, repeat_y);
}
diff --git a/content/content.h b/content/content.h
index b3e0b1ce2..0efdf443f 100644
--- a/content/content.h
+++ b/content/content.h
@@ -126,9 +126,6 @@ void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
bool content_redraw(struct hlcache_handle *h, int x, int y,
int width, int height, const struct rect *clip,
- float scale, colour background_colour);
-bool content_redraw_tiled(struct hlcache_handle *h, int x, int y,
- int width, int height, const struct rect *clip,
float scale, colour background_colour,
bool repeat_x, bool repeat_y);
void content_open(struct hlcache_handle *h, struct browser_window *bw,
diff --git a/content/content_protected.h b/content/content_protected.h
index 1d88de972..6659e2cd8 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -56,9 +56,6 @@ struct content_handler {
browser_mouse_state mouse, int x, int y);
bool (*redraw)(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
- float scale, colour background_colour);
- bool (*redraw_tiled)(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
float scale, colour background_colour,
bool repeat_x, bool repeat_y);
void (*open)(struct content *c, struct browser_window *bw,
diff --git a/css/css.c b/css/css.c
index b27debd5a..a70ae8037 100644
--- a/css/css.c
+++ b/css/css.c
@@ -90,7 +90,6 @@ static const content_handler css_content_handler = {
NULL,
NULL,
NULL,
- NULL,
nscss_clone,
nscss_matches_quirks,
nscss_content_type,
diff --git a/desktop/browser.c b/desktop/browser.c
index 1fb4de5f5..e538e87f3 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -131,7 +131,7 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y,
/* Render the content */
plot_ok &= content_redraw(bw->current_content, x, y, width, height,
- clip, bw->scale, 0xFFFFFF);
+ clip, bw->scale, 0xFFFFFF, false, false);
if (plot.option_knockout)
knockout_plot_end();
diff --git a/desktop/print.c b/desktop/print.c
index ab36f24f1..13f26e5d5 100644
--- a/desktop/print.c
+++ b/desktop/print.c
@@ -137,7 +137,7 @@ bool print_draw_next_page(const struct printer *printer,
printer->print_next_page();
if (!content_redraw(printed_content, 0, -done_height,
0, 0,
- &clip, settings->scale, 0xffffff))
+ &clip, settings->scale, 0xffffff, false, false))
return false;
done_height += page_content_height -
diff --git a/desktop/thumbnail.c b/desktop/thumbnail.c
index c8aa9de76..bf1db7ca1 100644
--- a/desktop/thumbnail.c
+++ b/desktop/thumbnail.c
@@ -88,7 +88,7 @@ bool thumbnail_redraw(struct hlcache_handle *content,
/* Render the content */
plot_ok &= content_redraw(content, 0, 0, width, height, &clip, scale,
- 0xFFFFFF);
+ 0xFFFFFF, false, false);
if (plot.option_knockout)
knockout_plot_end();
diff --git a/desktop/tree.c b/desktop/tree.c
index 674bc1612..36b61bab9 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -1623,7 +1623,7 @@ static void tree_draw_node_element(struct tree *tree,
plot.clip(&c);
content_redraw(icon , x, y + icon_inset,
TREE_ICON_SIZE, TREE_ICON_SIZE,
- &c, 1, 0);
+ &c, 1, 0, false, false);
/* Restore previous clipping area */
plot.clip(clip);
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index 17dc8619e..d08359085 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -39,6 +39,12 @@
$(shell $(PKG_CONFIG) --cflags openssl) \
$(shell xml2-config --cflags)
+ # The GTK build can also enable the following deprication flags
+ # -DG_DISABLE_SINGLE_INCLUDES -DG_DISABLE_DEPRECATED
+ # -DGTK_DISABLE_SINGLE_INCLUDES -DPANGO_DISABLE_DEPRECATED
+ # -DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED
+ # -DGTK_DISABLE_DEPRECATED -DGTK_MULTIHEAD_SAFE
+
GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs libglade-2.0 gtk+-2.0 gthread-2.0 gmodule-2.0 lcms)
CFLAGS += $(GTKCFLAGS)
diff --git a/image/bmp.c b/image/bmp.c
index dbb4d9796..9e1326e62 100644
--- a/image/bmp.c
+++ b/image/bmp.c
@@ -46,54 +46,8 @@ typedef struct nsbmp_content {
bmp_image *bmp; /** BMP image data */
} nsbmp_content;
-static nserror nsbmp_create(const content_handler *handler,
- lwc_string *imime_type, const struct http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
- bool quirks, struct content **c);
-static nserror nsbmp_create_bmp_data(nsbmp_content *bmp);
-static bool nsbmp_convert(struct content *c);
-static void nsbmp_destroy(struct content *c);
-static bool nsbmp_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour);
-static bool nsbmp_redraw_tiled(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour,
- bool repeat_x, bool repeat_y);
-static nserror nsbmp_clone(const struct content *old, struct content **newc);
-static content_type nsbmp_content_type(lwc_string *mime_type);
-static void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state);
-/* The Bitmap callbacks function table;
- * necessary for interaction with nsbmplib.
- */
-bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
- .bitmap_create = nsbmp_bitmap_create,
- .bitmap_destroy = bitmap_destroy,
- .bitmap_set_suspendable = bitmap_set_suspendable,
- .bitmap_get_buffer = bitmap_get_buffer,
- .bitmap_get_bpp = bitmap_get_bpp
-};
-
-static const content_handler nsbmp_content_handler = {
- nsbmp_create,
- NULL,
- nsbmp_convert,
- NULL,
- nsbmp_destroy,
- NULL,
- NULL,
- NULL,
- nsbmp_redraw,
- nsbmp_redraw_tiled,
- NULL,
- NULL,
- nsbmp_clone,
- NULL,
- nsbmp_content_type,
- false
-};
static const char *nsbmp_types[] = {
"application/bmp",
@@ -112,46 +66,24 @@ static const char *nsbmp_types[] = {
static lwc_string *nsbmp_mime_types[NOF_ELEMENTS(nsbmp_types)];
-nserror nsbmp_init(void)
-{
- uint32_t i;
- lwc_error lerror;
- nserror error;
-
- for (i = 0; i < NOF_ELEMENTS(nsbmp_mime_types); i++) {
- lerror = lwc_intern_string(nsbmp_types[i],
- strlen(nsbmp_types[i]),
- &nsbmp_mime_types[i]);
- if (lerror != lwc_error_ok) {
- error = NSERROR_NOMEM;
- goto error;
- }
+static nserror nsbmp_create_bmp_data(nsbmp_content *bmp)
+{
+ union content_msg_data msg_data;
- error = content_factory_register_handler(nsbmp_mime_types[i],
- &nsbmp_content_handler);
- if (error != NSERROR_OK)
- goto error;
+ bmp->bmp = calloc(sizeof(struct bmp_image), 1);
+ if (bmp->bmp == NULL) {
+ msg_data.error = messages_get("NoMemory");
+ content_broadcast(&bmp->base, CONTENT_MSG_ERROR, msg_data);
+ return NSERROR_NOMEM;
}
- return NSERROR_OK;
-
-error:
- nsbmp_fini();
+ bmp_create(bmp->bmp, &bmp_bitmap_callbacks);
- return error;
+ return NSERROR_OK;
}
-void nsbmp_fini(void)
-{
- uint32_t i;
- for (i = 0; i < NOF_ELEMENTS(nsbmp_mime_types); i++) {
- if (nsbmp_mime_types[i] != NULL)
- lwc_string_unref(nsbmp_mime_types[i]);
- }
-}
-
-nserror nsbmp_create(const content_handler *handler,
+static nserror nsbmp_create(const content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c)
@@ -181,23 +113,39 @@ nserror nsbmp_create(const content_handler *handler,
return NSERROR_OK;
}
-nserror nsbmp_create_bmp_data(nsbmp_content *bmp)
-{
- union content_msg_data msg_data;
-
- bmp->bmp = calloc(sizeof(struct bmp_image), 1);
- if (bmp->bmp == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&bmp->base, CONTENT_MSG_ERROR, msg_data);
- return NSERROR_NOMEM;
- }
+/**
+ * Callback for libnsbmp; forwards the call to bitmap_create()
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+static void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state)
+{
+ unsigned int bitmap_state = BITMAP_NEW;
- bmp_create(bmp->bmp, &bmp_bitmap_callbacks);
+ /* set bitmap state based on bmp state */
+ bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
+ bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ?
+ BITMAP_CLEAR_MEMORY : 0;
- return NSERROR_OK;
+ /* return the created bitmap */
+ return bitmap_create(width, height, bitmap_state);
}
-bool nsbmp_convert(struct content *c)
+/* The Bitmap callbacks function table;
+ * necessary for interaction with nsbmplib.
+ */
+bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
+ .bitmap_create = nsbmp_bitmap_create,
+ .bitmap_destroy = bitmap_destroy,
+ .bitmap_set_suspendable = bitmap_set_suspendable,
+ .bitmap_get_buffer = bitmap_get_buffer,
+ .bitmap_get_bpp = bitmap_get_bpp
+};
+
+static bool nsbmp_convert(struct content *c)
{
nsbmp_content *bmp = (nsbmp_content *) c;
bmp_result res;
@@ -249,25 +197,7 @@ bool nsbmp_convert(struct content *c)
return true;
}
-
-bool nsbmp_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour)
-{
- nsbmp_content *bmp = (nsbmp_content *) c;
-
- if (bmp->bmp->decoded == false)
- if (bmp_decode(bmp->bmp) != BMP_OK)
- return false;
-
- c->bitmap = bmp->bmp->bitmap;
-
- return plot.bitmap(x, y, width, height, c->bitmap,
- background_colour, BITMAPF_NONE);
-}
-
-
-bool nsbmp_redraw_tiled(struct content *c, int x, int y,
+static bool nsbmp_redraw(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
float scale, colour background_colour,
bool repeat_x, bool repeat_y)
@@ -291,7 +221,7 @@ bool nsbmp_redraw_tiled(struct content *c, int x, int y,
}
-void nsbmp_destroy(struct content *c)
+static void nsbmp_destroy(struct content *c)
{
nsbmp_content *bmp = (nsbmp_content *) c;
@@ -300,7 +230,7 @@ void nsbmp_destroy(struct content *c)
}
-nserror nsbmp_clone(const struct content *old, struct content **newc)
+static nserror nsbmp_clone(const struct content *old, struct content **newc)
{
nsbmp_content *new_bmp;
nserror error;
@@ -335,30 +265,67 @@ nserror nsbmp_clone(const struct content *old, struct content **newc)
return NSERROR_OK;
}
-content_type nsbmp_content_type(lwc_string *mime_type)
+static content_type nsbmp_content_type(lwc_string *mime_type)
{
return CONTENT_IMAGE;
}
-/**
- * Callback for libnsbmp; forwards the call to bitmap_create()
- *
- * \param width width of image in pixels
- * \param height width of image in pixels
- * \param state a flag word indicating the initial state
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
-void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state)
+
+static const content_handler nsbmp_content_handler = {
+ nsbmp_create,
+ NULL,
+ nsbmp_convert,
+ NULL,
+ nsbmp_destroy,
+ NULL,
+ NULL,
+ NULL,
+ nsbmp_redraw,
+ NULL,
+ NULL,
+ nsbmp_clone,
+ NULL,
+ nsbmp_content_type,
+ false
+};
+
+nserror nsbmp_init(void)
{
- unsigned int bitmap_state = BITMAP_NEW;
+ uint32_t i;
+ lwc_error lerror;
+ nserror error;
- /* set bitmap state based on bmp state */
- bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
- bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ?
- BITMAP_CLEAR_MEMORY : 0;
+ for (i = 0; i < NOF_ELEMENTS(nsbmp_mime_types); i++) {
+ lerror = lwc_intern_string(nsbmp_types[i],
+ strlen(nsbmp_types[i]),
+ &nsbmp_mime_types[i]);
+ if (lerror != lwc_error_ok) {
+ error = NSERROR_NOMEM;
+ goto error;
+ }
- /* return the created bitmap */
- return bitmap_create(width, height, bitmap_state);
+ error = content_factory_register_handler(nsbmp_mime_types[i],
+ &nsbmp_content_handler);
+ if (error != NSERROR_OK)
+ goto error;
+ }
+
+ return NSERROR_OK;
+
+error:
+ nsbmp_fini();
+
+ return error;
+}
+
+void nsbmp_fini(void)
+{
+ uint32_t i;
+
+ for (i = 0; i < NOF_ELEMENTS(nsbmp_mime_types); i++) {
+ if (nsbmp_mime_types[i] != NULL)
+ lwc_string_unref(nsbmp_mime_types[i]);
+ }
}
#endif
diff --git a/image/gif.c b/image/gif.c
index 20a67424e..798097bf5 100644
--- a/image/gif.c
+++ b/image/gif.c
@@ -56,32 +56,28 @@ typedef struct nsgif_content {
int current_frame; /**< current frame to display [0...(max-1)] */
} nsgif_content;
-static nserror nsgif_create(const content_handler *handler,
- lwc_string *imime_type, const struct http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
- bool quirks, struct content **c);
-static nserror nsgif_create_gif_data(nsgif_content *c);
-static bool nsgif_convert(struct content *c);
-static void nsgif_destroy(struct content *c);
-static bool nsgif_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour);
-static bool nsgif_redraw_tiled(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour,
- bool repeat_x, bool repeat_y);
-static nserror nsgif_clone(const struct content *old, struct content **newc);
-static content_type nsgif_content_type(lwc_string *mime_type);
+static const char *nsgif_types[] = {
+ "image/gif"
+};
-static void *nsgif_bitmap_create(int width, int height);
-static void nsgif_invalidate(void *bitmap, void *private_word);
-static void nsgif_animate(void *p);
-static gif_result nsgif_get_frame(struct content *c);
+static lwc_string *nsgif_mime_types[NOF_ELEMENTS(nsgif_types)];
+
+/**
+ * Callback for libnsgif; forwards the call to bitmap_create()
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+static void *nsgif_bitmap_create(int width, int height)
+{
+ return bitmap_create(width, height, BITMAP_NEW);
+}
/* The Bitmap callbacks function table;
* necessary for interaction with nsgiflib.
*/
-gif_bitmap_callback_vt gif_bitmap_callbacks = {
+static gif_bitmap_callback_vt gif_bitmap_callbacks = {
.bitmap_create = nsgif_bitmap_create,
.bitmap_destroy = bitmap_destroy,
.bitmap_get_buffer = bitmap_get_buffer,
@@ -90,71 +86,24 @@ gif_bitmap_callback_vt gif_bitmap_callbacks = {
.bitmap_modified = bitmap_modified
};
-static const content_handler nsgif_content_handler = {
- nsgif_create,
- NULL,
- nsgif_convert,
- NULL,
- nsgif_destroy,
- NULL,
- NULL,
- NULL,
- nsgif_redraw,
- nsgif_redraw_tiled,
- NULL,
- NULL,
- nsgif_clone,
- NULL,
- nsgif_content_type,
- false
-};
-
-static const char *nsgif_types[] = {
- "image/gif"
-};
-
-static lwc_string *nsgif_mime_types[NOF_ELEMENTS(nsgif_types)];
-
-nserror nsgif_init(void)
+static nserror nsgif_create_gif_data(nsgif_content *c)
{
- uint32_t i;
- lwc_error lerror;
- nserror error;
-
- for (i = 0; i < NOF_ELEMENTS(nsgif_mime_types); i++) {
- lerror = lwc_intern_string(nsgif_types[i],
- strlen(nsgif_types[i]),
- &nsgif_mime_types[i]);
- if (lerror != lwc_error_ok) {
- error = NSERROR_NOMEM;
- goto error;
- }
+ union content_msg_data msg_data;
- error = content_factory_register_handler(nsgif_mime_types[i],
- &nsgif_content_handler);
- if (error != NSERROR_OK)
- goto error;
+ /* Initialise our data structure */
+ c->gif = calloc(sizeof(gif_animation), 1);
+ if (c->gif == NULL) {
+ msg_data.error = messages_get("NoMemory");
+ content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ return NSERROR_NOMEM;
}
-
+ gif_create(c->gif, &gif_bitmap_callbacks);
return NSERROR_OK;
-
-error:
- nsgif_fini();
-
- return error;
}
-void nsgif_fini(void)
-{
- uint32_t i;
- for (i = 0; i < NOF_ELEMENTS(nsgif_mime_types); i++) {
- if (nsgif_mime_types[i] != NULL)
- lwc_string_unref(nsgif_mime_types[i]);
- }
-}
-nserror nsgif_create(const content_handler *handler,
+static nserror nsgif_create(const content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c)
@@ -184,23 +133,122 @@ nserror nsgif_create(const content_handler *handler,
return NSERROR_OK;
}
-nserror nsgif_create_gif_data(nsgif_content *c)
+/**
+ * Performs any necessary animation.
+ *
+ * \param p The content to animate
+*/
+static void nsgif_animate(void *p)
{
- union content_msg_data msg_data;
+ nsgif_content *gif = p;
+ union content_msg_data data;
+ int delay;
+ int f;
- /* Initialise our data structure */
- c->gif = calloc(sizeof(gif_animation), 1);
- if (c->gif == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
- return NSERROR_NOMEM;
+ /* Advance by a frame, updating the loop count accordingly */
+ gif->current_frame++;
+ if (gif->current_frame == (int)gif->gif->frame_count_partial) {
+ gif->current_frame = 0;
+
+ /* A loop count of 0 has a special meaning of infinite */
+ if (gif->gif->loop_count != 0) {
+ gif->gif->loop_count--;
+ if (gif->gif->loop_count == 0) {
+ gif->current_frame =
+ gif->gif->frame_count_partial - 1;
+ gif->gif->loop_count = -1;
+ }
+ }
}
- gif_create(c->gif, &gif_bitmap_callbacks);
- return NSERROR_OK;
+
+ /* Continue animating if we should */
+ if (gif->gif->loop_count >= 0) {
+ delay = gif->gif->frames[gif->current_frame].frame_delay;
+ if (delay < option_minimum_gif_delay)
+ delay = option_minimum_gif_delay;
+ schedule(delay, nsgif_animate, gif);
+ }
+
+ if ((!option_animate_images) ||
+ (!gif->gif->frames[gif->current_frame].display))
+ return;
+
+ /* area within gif to redraw */
+ f = gif->current_frame;
+ data.redraw.x = gif->gif->frames[f].redraw_x;
+ data.redraw.y = gif->gif->frames[f].redraw_y;
+ data.redraw.width = gif->gif->frames[f].redraw_width;
+ data.redraw.height = gif->gif->frames[f].redraw_height;
+
+ /* redraw background (true) or plot on top (false) */
+ if (gif->current_frame > 0) {
+ data.redraw.full_redraw =
+ gif->gif->frames[f - 1].redraw_required;
+ /* previous frame needed clearing: expand the redraw area to
+ * cover it */
+ if (data.redraw.full_redraw) {
+ if (data.redraw.x >
+ (int)(gif->gif->frames[f - 1].redraw_x)) {
+ data.redraw.width += data.redraw.x -
+ gif->gif->frames[f - 1].redraw_x;
+ data.redraw.x =
+ gif->gif->frames[f - 1].redraw_x;
+ }
+ if (data.redraw.y >
+ (int)(gif->gif->frames[f - 1].redraw_y)) {
+ data.redraw.height += (data.redraw.y -
+ gif->gif->frames[f - 1].redraw_y);
+ data.redraw.y =
+ gif->gif->frames[f - 1].redraw_y;
+ }
+ if ((int)(gif->gif->frames[f - 1].redraw_x +
+ gif->gif->frames[f - 1].redraw_width) >
+ (data.redraw.x + data.redraw.width))
+ data.redraw.width =
+ gif->gif->frames[f - 1].redraw_x -
+ data.redraw.x +
+ gif->gif->frames[f - 1].redraw_width;
+ if ((int)(gif->gif->frames[f - 1].redraw_y +
+ gif->gif->frames[f - 1].redraw_height) >
+ (data.redraw.y + data.redraw.height))
+ data.redraw.height =
+ gif->gif->frames[f - 1].redraw_y -
+ data.redraw.y +
+ gif->gif->frames[f - 1].redraw_height;
+ }
+ } else {
+ /* do advanced check */
+ if ((data.redraw.x == 0) && (data.redraw.y == 0) &&
+ (data.redraw.width == (int)(gif->gif->width)) &&
+ (data.redraw.height == (int)(gif->gif->height))) {
+ data.redraw.full_redraw = !gif->gif->frames[f].opaque;
+ } else {
+ data.redraw.full_redraw = true;
+ data.redraw.x = 0;
+ data.redraw.y = 0;
+ data.redraw.width = gif->gif->width;
+ data.redraw.height = gif->gif->height;
+ }
+ }
+
+ /* other data */
+ data.redraw.object = (struct content *) gif;
+ data.redraw.object_x = 0;
+ data.redraw.object_y = 0;
+ data.redraw.object_width = gif->base.width;
+ data.redraw.object_height = gif->base.height;
+
+ content_broadcast(&gif->base, CONTENT_MSG_REDRAW, data);
}
+static void nsgif_invalidate(void *bitmap, void *private_word)
+{
+ struct gif_animation *gif = (struct gif_animation *)private_word;
+
+ gif->decoded_frame = -1;
+}
-bool nsgif_convert(struct content *c)
+static bool nsgif_convert(struct content *c)
{
nsgif_content *gif = (nsgif_content *) c;
int res;
@@ -265,31 +313,32 @@ bool nsgif_convert(struct content *c)
return true;
}
-void nsgif_invalidate(void *bitmap, void *private_word)
-{
- struct gif_animation *gif = (struct gif_animation *)private_word;
-
- gif->decoded_frame = -1;
-}
-bool nsgif_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour)
+/**
+ * Updates the GIF bitmap to display the current frame
+ *
+ * \param c the content to update
+ */
+static gif_result nsgif_get_frame(struct content *c)
{
nsgif_content *gif = (nsgif_content *) c;
+ int previous_frame, current_frame, frame;
+ gif_result res = GIF_OK;
- if (gif->current_frame != gif->gif->decoded_frame)
- if (nsgif_get_frame(c) != GIF_OK)
- return false;
- c->bitmap = gif->gif->frame_image;
- if ((width == -1) && (height == -1))
- return true;
- return plot.bitmap(x, y, width, height, c->bitmap,
- background_colour, BITMAPF_NONE);
-}
+ current_frame = gif->current_frame;
+ if (!option_animate_images)
+ current_frame = 0;
+ if (current_frame < gif->gif->decoded_frame)
+ previous_frame = 0;
+ else
+ previous_frame = gif->gif->decoded_frame + 1;
+ for (frame = previous_frame; frame <= current_frame; frame++)
+ res = gif_decode_frame(gif->gif, frame);
+ return res;
+}
-bool nsgif_redraw_tiled(struct content *c, int x, int y,
+static bool nsgif_redraw(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
float scale, colour background_colour,
bool repeat_x, bool repeat_y)
@@ -302,6 +351,9 @@ bool nsgif_redraw_tiled(struct content *c, int x, int y,
return false;
c->bitmap = gif->gif->frame_image;
+
+ if ((width == -1) && (height == -1))
+ return true;
if (repeat_x)
flags |= BITMAPF_REPEAT_X;
@@ -312,7 +364,7 @@ bool nsgif_redraw_tiled(struct content *c, int x, int y,
}
-void nsgif_destroy(struct content *c)
+static void nsgif_destroy(struct content *c)
{
nsgif_content *gif = (nsgif_content *) c;
@@ -323,7 +375,7 @@ void nsgif_destroy(struct content *c)
}
-nserror nsgif_clone(const struct content *old, struct content **newc)
+static nserror nsgif_clone(const struct content *old, struct content **newc)
{
nsgif_content *gif;
nserror error;
@@ -358,155 +410,67 @@ nserror nsgif_clone(const struct content *old, struct content **newc)
return NSERROR_OK;
}
-content_type nsgif_content_type(lwc_string *mime_type)
+static content_type nsgif_content_type(lwc_string *mime_type)
{
return CONTENT_IMAGE;
}
-/**
- * Updates the GIF bitmap to display the current frame
- *
- * \param c the content to update
- */
-gif_result nsgif_get_frame(struct content *c)
-{
- nsgif_content *gif = (nsgif_content *) c;
- int previous_frame, current_frame, frame;
- gif_result res = GIF_OK;
-
- current_frame = gif->current_frame;
- if (!option_animate_images)
- current_frame = 0;
- if (current_frame < gif->gif->decoded_frame)
- previous_frame = 0;
- else
- previous_frame = gif->gif->decoded_frame + 1;
- for (frame = previous_frame; frame <= current_frame; frame++)
- res = gif_decode_frame(gif->gif, frame);
-
- return res;
-}
+static const content_handler nsgif_content_handler = {
+ nsgif_create,
+ NULL,
+ nsgif_convert,
+ NULL,
+ nsgif_destroy,
+ NULL,
+ NULL,
+ NULL,
+ nsgif_redraw,
+ NULL,
+ NULL,
+ nsgif_clone,
+ NULL,
+ nsgif_content_type,
+ false
+};
-/**
- * Performs any necessary animation.
- *
- * \param p The content to animate
-*/
-void nsgif_animate(void *p)
+nserror nsgif_init(void)
{
- nsgif_content *gif = p;
- union content_msg_data data;
- int delay;
- int f;
-
- /* Advance by a frame, updating the loop count accordingly */
- gif->current_frame++;
- if (gif->current_frame == (int)gif->gif->frame_count_partial) {
- gif->current_frame = 0;
+ uint32_t i;
+ lwc_error lerror;
+ nserror error;
- /* A loop count of 0 has a special meaning of infinite */
- if (gif->gif->loop_count != 0) {
- gif->gif->loop_count--;
- if (gif->gif->loop_count == 0) {
- gif->current_frame =
- gif->gif->frame_count_partial - 1;
- gif->gif->loop_count = -1;
- }
+ for (i = 0; i < NOF_ELEMENTS(nsgif_mime_types); i++) {
+ lerror = lwc_intern_string(nsgif_types[i],
+ strlen(nsgif_types[i]),
+ &nsgif_mime_types[i]);
+ if (lerror != lwc_error_ok) {
+ error = NSERROR_NOMEM;
+ goto error;
}
- }
- /* Continue animating if we should */
- if (gif->gif->loop_count >= 0) {
- delay = gif->gif->frames[gif->current_frame].frame_delay;
- if (delay < option_minimum_gif_delay)
- delay = option_minimum_gif_delay;
- schedule(delay, nsgif_animate, gif);
+ error = content_factory_register_handler(nsgif_mime_types[i],
+ &nsgif_content_handler);
+ if (error != NSERROR_OK)
+ goto error;
}
- if ((!option_animate_images) ||
- (!gif->gif->frames[gif->current_frame].display))
- return;
-
- /* area within gif to redraw */
- f = gif->current_frame;
- data.redraw.x = gif->gif->frames[f].redraw_x;
- data.redraw.y = gif->gif->frames[f].redraw_y;
- data.redraw.width = gif->gif->frames[f].redraw_width;
- data.redraw.height = gif->gif->frames[f].redraw_height;
-
- /* redraw background (true) or plot on top (false) */
- if (gif->current_frame > 0) {
- data.redraw.full_redraw =
- gif->gif->frames[f - 1].redraw_required;
- /* previous frame needed clearing: expand the redraw area to
- * cover it */
- if (data.redraw.full_redraw) {
- if (data.redraw.x >
- (int)(gif->gif->frames[f - 1].redraw_x)) {
- data.redraw.width += data.redraw.x -
- gif->gif->frames[f - 1].redraw_x;
- data.redraw.x =
- gif->gif->frames[f - 1].redraw_x;
- }
- if (data.redraw.y >
- (int)(gif->gif->frames[f - 1].redraw_y)) {
- data.redraw.height += (data.redraw.y -
- gif->gif->frames[f - 1].redraw_y);
- data.redraw.y =
- gif->gif->frames[f - 1].redraw_y;
- }
- if ((int)(gif->gif->frames[f - 1].redraw_x +
- gif->gif->frames[f - 1].redraw_width) >
- (data.redraw.x + data.redraw.width))
- data.redraw.width =
- gif->gif->frames[f - 1].redraw_x -
- data.redraw.x +
- gif->gif->frames[f - 1].redraw_width;
- if ((int)(gif->gif->frames[f - 1].redraw_y +
- gif->gif->frames[f - 1].redraw_height) >
- (data.redraw.y + data.redraw.height))
- data.redraw.height =
- gif->gif->frames[f - 1].redraw_y -
- data.redraw.y +
- gif->gif->frames[f - 1].redraw_height;
- }
- } else {
- /* do advanced check */
- if ((data.redraw.x == 0) && (data.redraw.y == 0) &&
- (data.redraw.width == (int)(gif->gif->width)) &&
- (data.redraw.height == (int)(gif->gif->height))) {
- data.redraw.full_redraw = !gif->gif->frames[f].opaque;
- } else {
- data.redraw.full_redraw = true;
- data.redraw.x = 0;
- data.redraw.y = 0;
- data.redraw.width = gif->gif->width;
- data.redraw.height = gif->gif->height;
- }
- }
+ return NSERROR_OK;
- /* other data */
- data.redraw.object = (struct content *) gif;
- data.redraw.object_x = 0;
- data.redraw.object_y = 0;
- data.redraw.object_width = gif->base.width;
- data.redraw.object_height = gif->base.height;
+error:
+ nsgif_fini();
- content_broadcast(&gif->base, CONTENT_MSG_REDRAW, data);
+ return error;
}
-
-/**
- * Callback for libnsgif; forwards the call to bitmap_create()
- *
- * \param width width of image in pixels
- * \param height width of image in pixels
- * \return an opaque struct bitmap, or NULL on memory exhaustion
- */
-void *nsgif_bitmap_create(int width, int height)
+void nsgif_fini(void)
{
- return bitmap_create(width, height, BITMAP_NEW);
+ uint32_t i;
+
+ for (i = 0; i < NOF_ELEMENTS(nsgif_mime_types); i++) {
+ if (nsgif_mime_types[i] != NULL)
+ lwc_string_unref(nsgif_mime_types[i]);
+ }
}
#endif
diff --git a/image/ico.c b/image/ico.c
index 0397c5c7f..2f546b6e8 100644
--- a/image/ico.c
+++ b/image/ico.c
@@ -46,42 +46,6 @@ typedef struct nsico_content {
struct ico_collection *ico; /** ICO collection data */
} nsico_content;
-static nserror nsico_create(const content_handler *handler,
- lwc_string *imime_type, const struct http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
- bool quirks, struct content **c);
-static nserror nsico_create_ico_data(nsico_content *c);
-static bool nsico_convert(struct content *c);
-static void nsico_destroy(struct content *c);
-static bool nsico_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour);
-static bool nsico_redraw_tiled(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour,
- bool repeat_x, bool repeat_y);
-static nserror nsico_clone(const struct content *old, struct content **newc);
-static content_type nsico_content_type(lwc_string *mime_type);
-
-static const content_handler nsico_content_handler = {
- nsico_create,
- NULL,
- nsico_convert,
- NULL,
- nsico_destroy,
- NULL,
- NULL,
- NULL,
- nsico_redraw,
- nsico_redraw_tiled,
- NULL,
- NULL,
- nsico_clone,
- NULL,
- nsico_content_type,
- false
-};
-
static const char *nsico_types[] = {
"application/ico",
"application/x-ico",
@@ -92,46 +56,23 @@ static const char *nsico_types[] = {
static lwc_string *nsico_mime_types[NOF_ELEMENTS(nsico_types)];
-nserror nsico_init(void)
-{
- uint32_t i;
- lwc_error lerror;
- nserror error;
- for (i = 0; i < NOF_ELEMENTS(nsico_mime_types); i++) {
- lerror = lwc_intern_string(nsico_types[i],
- strlen(nsico_types[i]),
- &nsico_mime_types[i]);
- if (lerror != lwc_error_ok) {
- error = NSERROR_NOMEM;
- goto error;
- }
+static nserror nsico_create_ico_data(nsico_content *c)
+{
+ union content_msg_data msg_data;
- error = content_factory_register_handler(nsico_mime_types[i],
- &nsico_content_handler);
- if (error != NSERROR_OK)
- goto error;
+ c->ico = calloc(sizeof(ico_collection), 1);
+ if (c->ico == NULL) {
+ msg_data.error = messages_get("NoMemory");
+ content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ return NSERROR_NOMEM;
}
-
+ ico_collection_create(c->ico, &bmp_bitmap_callbacks);
return NSERROR_OK;
-
-error:
- nsico_fini();
-
- return error;
}
-void nsico_fini(void)
-{
- uint32_t i;
-
- for (i = 0; i < NOF_ELEMENTS(nsico_mime_types); i++) {
- if (nsico_mime_types[i] != NULL)
- lwc_string_unref(nsico_mime_types[i]);
- }
-}
-nserror nsico_create(const content_handler *handler,
+static nserror nsico_create(const content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c)
@@ -161,22 +102,9 @@ nserror nsico_create(const content_handler *handler,
return NSERROR_OK;
}
-nserror nsico_create_ico_data(nsico_content *c)
-{
- union content_msg_data msg_data;
-
- c->ico = calloc(sizeof(ico_collection), 1);
- if (c->ico == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
- return NSERROR_NOMEM;
- }
- ico_collection_create(c->ico, &bmp_bitmap_callbacks);
- return NSERROR_OK;
-}
-bool nsico_convert(struct content *c)
+static bool nsico_convert(struct content *c)
{
nsico_content *ico = (nsico_content *) c;
struct bmp_image *bmp;
@@ -228,21 +156,8 @@ bool nsico_convert(struct content *c)
return true;
}
-bool nsico_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour)
-{
- nsico_content *ico = (nsico_content *) c;
- struct bmp_image *bmp = ico_find(ico->ico, width, height);
- if (!bmp->decoded)
- if (bmp_decode(bmp) != BMP_OK)
- return false;
- c->bitmap = bmp->bitmap;
- return plot.bitmap(x, y, width, height, c->bitmap,
- background_colour, BITMAPF_NONE);
-}
-bool nsico_redraw_tiled(struct content *c, int x, int y,
+static bool nsico_redraw(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
float scale, colour background_colour,
bool repeat_x, bool repeat_y)
@@ -266,7 +181,7 @@ bool nsico_redraw_tiled(struct content *c, int x, int y,
}
-void nsico_destroy(struct content *c)
+static void nsico_destroy(struct content *c)
{
nsico_content *ico = (nsico_content *) c;
@@ -274,7 +189,7 @@ void nsico_destroy(struct content *c)
free(ico->ico);
}
-nserror nsico_clone(const struct content *old, struct content **newc)
+static nserror nsico_clone(const struct content *old, struct content **newc)
{
nsico_content *ico;
nserror error;
@@ -309,9 +224,67 @@ nserror nsico_clone(const struct content *old, struct content **newc)
return NSERROR_OK;
}
-content_type nsico_content_type(lwc_string *mime_type)
+static content_type nsico_content_type(lwc_string *mime_type)
{
return CONTENT_IMAGE;
}
+static const content_handler nsico_content_handler = {
+ nsico_create,
+ NULL,
+ nsico_convert,
+ NULL,
+ nsico_destroy,
+ NULL,
+ NULL,
+ NULL,
+ nsico_redraw,
+ NULL,
+ NULL,
+ nsico_clone,
+ NULL,
+ nsico_content_type,
+ false
+};
+
+
+nserror nsico_init(void)
+{
+ uint32_t i;
+ lwc_error lerror;
+ nserror error;
+
+ for (i = 0; i < NOF_ELEMENTS(nsico_mime_types); i++) {
+ lerror = lwc_intern_string(nsico_types[i],
+ strlen(nsico_types[i]),
+ &nsico_mime_types[i]);
+ if (lerror != lwc_error_ok) {
+ error = NSERROR_NOMEM;
+ goto error;
+ }
+
+ error = content_factory_register_handler(nsico_mime_types[i],
+ &nsico_content_handler);
+ if (error != NSERROR_OK)
+ goto error;
+ }
+
+ return NSERROR_OK;
+
+error:
+ nsico_fini();
+
+ return error;
+}
+
+void nsico_fini(void)
+{
+ uint32_t i;
+
+ for (i = 0; i < NOF_ELEMENTS(nsico_mime_types); i++) {
+ if (nsico_mime_types[i] != NULL)
+ lwc_string_unref(nsico_mime_types[i]);
+ }
+}
+
#endif
diff --git a/image/jpeg.c b/image/jpeg.c
index 9709bc0f7..1d0e16edd 100644
--- a/image/jpeg.c
+++ b/image/jpeg.c
@@ -275,21 +275,9 @@ static void nsjpeg_destroy(struct content *c)
/**
- * Redraw a CONTENT_JPEG.
- */
-static bool nsjpeg_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour)
-{
- return plot.bitmap(x, y, width, height,
- c->bitmap, background_colour, BITMAPF_NONE);
-}
-
-
-/**
* Redraw a CONTENT_JPEG with appropriate tiling.
*/
-static bool nsjpeg_redraw_tiled(struct content *c, int x, int y,
+static bool nsjpeg_redraw(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
float scale, colour background_colour,
bool repeat_x, bool repeat_y)
@@ -356,7 +344,6 @@ static const content_handler nsjpeg_content_handler = {
NULL,
NULL,
nsjpeg_redraw,
- nsjpeg_redraw_tiled,
NULL,
NULL,
nsjpeg_clone,
diff --git a/image/png.c b/image/png.c
index 69ea92312..f3fbf35ea 100644
--- a/image/png.c
+++ b/image/png.c
@@ -344,24 +344,12 @@ static void nspng_destroy(struct content *c)
static bool nspng_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour)
-{
- nspng_content *png_c = (nspng_content *) c;
-
- assert(png_c->bitmap != NULL);
-
- return plot.bitmap(x, y, width, height, png_c->bitmap,
- background_colour, BITMAPF_NONE);
-}
-
-static bool nspng_redraw_tiled(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
float scale, colour background_colour,
bool repeat_x, bool repeat_y)
{
nspng_content *png_c = (nspng_content *) c;
- bitmap_flags_t flags = 0;
+ bitmap_flags_t flags = BITMAPF_NONE;
assert(png_c->bitmap != NULL);
@@ -434,7 +422,6 @@ static const content_handler nspng_content_handler = {
NULL,
NULL,
nspng_redraw,
- nspng_redraw_tiled,
NULL,
NULL,
nspng_clone,
diff --git a/image/rsvg.c b/image/rsvg.c
index 26370de57..80c5368a4 100644
--- a/image/rsvg.c
+++ b/image/rsvg.c
@@ -56,42 +56,7 @@ typedef struct rsvg_content {
struct bitmap *bitmap; /**< Created NetSurf bitmap */
} rsvg_content;
-static nserror rsvg_create(const content_handler *handler,
- lwc_string *imime_type, const http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
- bool quirks, struct content **c);
-static nserror rsvg_create_svg_data(rsvg_content *c);
-static bool rsvg_process_data(struct content *c, const char *data,
- unsigned int size);
-static bool rsvg_convert(struct content *c);
-static void rsvg_destroy(struct content *c);
-static bool rsvg_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour);
-static nserror rsvg_clone(const struct content *old, struct content **newc);
-static content_type rsvg_content_type(lwc_string *mime_type);
-static inline void rsvg_argb_to_abgr(uint8_t *pixels,
- int width, int height, size_t rowstride);
-
-static const content_handler rsvg_content_handler = {
- rsvg_create,
- rsvg_process_data,
- rsvg_convert,
- NULL,
- rsvg_destroy,
- NULL,
- NULL,
- NULL,
- rsvg_redraw,
- NULL,
- NULL,
- NULL,
- rsvg_clone,
- NULL,
- rsvg_content_type,
- false
-};
static const char *rsvg_types[] = {
"image/svg",
@@ -100,46 +65,28 @@ static const char *rsvg_types[] = {
static lwc_string *rsvg_mime_types[NOF_ELEMENTS(rsvg_types)];
-nserror nsrsvg_init(void)
+
+static nserror rsvg_create_svg_data(rsvg_content *c)
{
- uint32_t i;
- lwc_error lerror;
- nserror error;
+ union content_msg_data msg_data;
- for (i = 0; i < NOF_ELEMENTS(rsvg_mime_types); i++) {
- lerror = lwc_intern_string(rsvg_types[i],
- strlen(rsvg_types[i]),
- &rsvg_mime_types[i]);
- if (lerror != lwc_error_ok) {
- error = NSERROR_NOMEM;
- goto error;
- }
+ c->rsvgh = NULL;
+ c->cs = NULL;
+ c->ct = NULL;
+ c->bitmap = NULL;
- error = content_factory_register_handler(rsvg_mime_types[i],
- &rsvg_content_handler);
- if (error != NSERROR_OK)
- goto error;
+ if ((c->rsvgh = rsvg_handle_new()) == NULL) {
+ LOG(("rsvg_handle_new() returned NULL."));
+ msg_data.error = messages_get("NoMemory");
+ content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ return NSERROR_NOMEM;
}
return NSERROR_OK;
-
-error:
- nsrsvg_fini();
-
- return error;
}
-void nsrsvg_fini(void)
-{
- uint32_t i;
-
- for (i = 0; i < NOF_ELEMENTS(rsvg_mime_types); i++) {
- if (rsvg_mime_types[i] != NULL)
- lwc_string_unref(rsvg_mime_types[i]);
- }
-}
-nserror rsvg_create(const content_handler *handler,
+static nserror rsvg_create(const content_handler *handler,
lwc_string *imime_type, const http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c)
@@ -169,26 +116,8 @@ nserror rsvg_create(const content_handler *handler,
return NSERROR_OK;
}
-nserror rsvg_create_svg_data(rsvg_content *c)
-{
- union content_msg_data msg_data;
-
- c->rsvgh = NULL;
- c->cs = NULL;
- c->ct = NULL;
- c->bitmap = NULL;
- if ((c->rsvgh = rsvg_handle_new()) == NULL) {
- LOG(("rsvg_handle_new() returned NULL."));
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
- return NSERROR_NOMEM;
- }
-
- return NSERROR_OK;
-}
-
-bool rsvg_process_data(struct content *c, const char *data,
+static bool rsvg_process_data(struct content *c, const char *data,
unsigned int size)
{
rsvg_content *d = (rsvg_content *) c;
@@ -235,7 +164,7 @@ static inline void rsvg_argb_to_abgr(uint8_t *pixels,
}
}
-bool rsvg_convert(struct content *c)
+static bool rsvg_convert(struct content *c)
{
rsvg_content *d = (rsvg_content *) c;
union content_msg_data msg_data;
@@ -300,15 +229,25 @@ bool rsvg_convert(struct content *c)
return true;
}
-bool rsvg_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour)
+static bool rsvg_redraw(struct content *c, int x, int y,
+ int width, int height, const struct rect *clip,
+ float scale, colour background_colour,
+ bool repeat_x, bool repeat_y)
{
- plot.bitmap(x, y, width, height, c->bitmap, background_colour, BITMAPF_NONE);
- return true;
+ bitmap_flags_t flags = BITMAPF_NONE;
+
+ assert(c->bitmap != NULL);
+
+ if (repeat_x)
+ flags |= BITMAPF_REPEAT_X;
+ if (repeat_y)
+ flags |= BITMAPF_REPEAT_Y;
+
+ return plot.bitmap(x, y, width, height,
+ c->bitmap, background_colour, flags);
}
-void rsvg_destroy(struct content *c)
+static void rsvg_destroy(struct content *c)
{
rsvg_content *d = (rsvg_content *) c;
@@ -320,7 +259,7 @@ void rsvg_destroy(struct content *c)
return;
}
-nserror rsvg_clone(const struct content *old, struct content **newc)
+static nserror rsvg_clone(const struct content *old, struct content **newc)
{
rsvg_content *svg;
nserror error;
@@ -365,9 +304,66 @@ nserror rsvg_clone(const struct content *old, struct content **newc)
return NSERROR_OK;
}
-content_type rsvg_content_type(lwc_string *mime_type)
+static content_type rsvg_content_type(lwc_string *mime_type)
{
return CONTENT_IMAGE;
}
+static const content_handler rsvg_content_handler = {
+ rsvg_create,
+ rsvg_process_data,
+ rsvg_convert,
+ NULL,
+ rsvg_destroy,
+ NULL,
+ NULL,
+ NULL,
+ rsvg_redraw,
+ NULL,
+ NULL,
+ rsvg_clone,
+ NULL,
+ rsvg_content_type,
+ false
+};
+
+nserror nsrsvg_init(void)
+{
+ uint32_t i;
+ lwc_error lerror;
+ nserror error;
+
+ for (i = 0; i < NOF_ELEMENTS(rsvg_mime_types); i++) {
+ lerror = lwc_intern_string(rsvg_types[i],
+ strlen(rsvg_types[i]),
+ &rsvg_mime_types[i]);
+ if (lerror != lwc_error_ok) {
+ error = NSERROR_NOMEM;
+ goto error;
+ }
+
+ error = content_factory_register_handler(rsvg_mime_types[i],
+ &rsvg_content_handler);
+ if (error != NSERROR_OK)
+ goto error;
+ }
+
+ return NSERROR_OK;
+
+error:
+ nsrsvg_fini();
+
+ return error;
+}
+
+void nsrsvg_fini(void)
+{
+ uint32_t i;
+
+ for (i = 0; i < NOF_ELEMENTS(rsvg_mime_types); i++) {
+ if (rsvg_mime_types[i] != NULL)
+ lwc_string_unref(rsvg_mime_types[i]);
+ }
+}
+
#endif /* WITH_RSVG */
diff --git a/render/html.c b/render/html.c
index 20ff41f5e..dd29d2c54 100644
--- a/render/html.c
+++ b/render/html.c
@@ -111,7 +111,6 @@ static const content_handler html_content_handler = {
html_mouse_track,
html_mouse_action,
html_redraw,
- NULL,
html_open,
html_close,
html_clone,
diff --git a/render/html_internal.h b/render/html_internal.h
index ae1851e1e..dd04edb77 100644
--- a/render/html_internal.h
+++ b/render/html_internal.h
@@ -97,7 +97,8 @@ void html_set_status(html_content *c, const char *extra);
/* in render/html_redraw.c */
bool html_redraw(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
- float scale, colour background_colour);
+ float scale, colour background_colour,
+ bool repeat_x, bool repeat_y);
/* in render/html_interaction.c */
void html_mouse_track(struct content *c, struct browser_window *bw,
diff --git a/render/html_redraw.c b/render/html_redraw.c
index fbe09f744..2d1a78559 100644
--- a/render/html_redraw.c
+++ b/render/html_redraw.c
@@ -113,7 +113,8 @@ bool html_redraw_debug = false;
bool html_redraw(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
- float scale, colour background_colour)
+ float scale, colour background_colour,
+ bool repeat_x, bool repeat_y)
{
html_content *html = (html_content *) c;
struct box *box;
@@ -655,7 +656,8 @@ bool html_redraw_box(struct box *box, int x_parent, int y_parent,
x_scrolled + padding_left,
y_scrolled + padding_top,
width, height, &r, scale,
- current_background_color))
+ current_background_color,
+ false, false))
return false;
} else if (box->gadget && box->gadget->type == GADGET_CHECKBOX) {
@@ -2169,7 +2171,7 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
if ((r.x0 < r.x1) && (r.y0 < r.y1)) {
if (!plot.clip(&r))
return false;
- if (!content_redraw_tiled(
+ if (!content_redraw(
background->background, x, y,
ceilf(width * scale),
ceilf(height * scale), &r,
@@ -2310,7 +2312,7 @@ bool html_redraw_inline_background(int x, int y, struct box *box, float scale,
if ((r.x0 < r.x1) && (r.y0 < r.y1)) {
if (!plot.clip(&r))
return false;
- if (!content_redraw_tiled(box->background, x, y,
+ if (!content_redraw(box->background, x, y,
ceilf(width * scale),
ceilf(height * scale), &r,
scale, *background_colour,
diff --git a/render/textplain.c b/render/textplain.c
index a394b8251..6ec2f2521 100644
--- a/render/textplain.c
+++ b/render/textplain.c
@@ -104,7 +104,8 @@ static void textplain_reformat(struct content *c, int width, int height);
static void textplain_destroy(struct content *c);
static bool textplain_redraw(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
- float scale, colour background_colour);
+ float scale, colour background_colour,
+ bool redraw_x, bool redraw_y);
static nserror textplain_clone(const struct content *old,
struct content **newc);
static content_type textplain_content_type(lwc_string *mime_type);
@@ -131,7 +132,6 @@ static const content_handler textplain_content_handler = {
textplain_redraw,
NULL,
NULL,
- NULL,
textplain_clone,
NULL,
textplain_content_type,
@@ -687,7 +687,8 @@ void textplain_mouse_action(struct content *c, struct browser_window *bw,
bool textplain_redraw(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
- float scale, colour background_colour)
+ float scale, colour background_colour,
+ bool repeat_x, bool repeat_y)
{
textplain_content *text = (textplain_content *) c;
struct browser_window *bw = current_redraw_browser;