From 79ce683b4e6d34fe327b00f1e427e476016cfab0 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 4 Apr 2010 12:41:19 +0000 Subject: Most of a stop implementation. Remaining work: 1) Clone content_html_data 2) Cloning content_css_data requires the charset of the old content 3) Calling hlcache_handle_abort() before a content has been created must clean up the retrieval context. svn path=/trunk/netsurf/; revision=10236 --- image/bmp.c | 17 +++++++++++++++++ image/bmp.h | 1 + image/gif.c | 16 ++++++++++++++++ image/gif.h | 1 + image/ico.c | 15 +++++++++++++++ image/ico.h | 1 + image/jpeg.c | 13 +++++++++++++ image/jpeg.h | 1 + image/mng.c | 25 +++++++++++++++++++++++++ image/mng.h | 1 + image/nssprite.c | 13 +++++++++++++ image/nssprite.h | 1 + image/png.c | 24 ++++++++++++++++++++++++ image/png.h | 2 ++ image/rsvg.c | 24 ++++++++++++++++++++++++ image/rsvg.h | 1 + image/svg.c | 16 ++++++++++++++++ image/svg.h | 1 + 18 files changed, 173 insertions(+) (limited to 'image') diff --git a/image/bmp.c b/image/bmp.c index 23ea740e9..ac7bc300e 100644 --- a/image/bmp.c +++ b/image/bmp.c @@ -162,6 +162,23 @@ void nsbmp_destroy(struct content *c) } + +bool nsbmp_clone(const struct content *old, struct content *new_content) +{ + /* We "clone" the old content by replaying creation and conversion */ + if (nsbmp_create(new_content, NULL) == false) + return false; + + if (old->status == CONTENT_STATUS_READY || + old->status == CONTENT_STATUS_DONE) { + if (nsbmp_convert(new_content) == false) + return false; + } + + return true; +} + + /** * Callback for libnsbmp; forwards the call to bitmap_create() * diff --git a/image/bmp.h b/image/bmp.h index 0ef5ba602..e78d52f6f 100644 --- a/image/bmp.h +++ b/image/bmp.h @@ -53,6 +53,7 @@ bool nsbmp_redraw_tiled(struct content *c, int x, int y, int clip_x0, int clip_y0, int clip_x1, int clip_y1, float scale, colour background_colour, bool repeat_x, bool repeat_y); +bool nsbmp_clone(const struct content *old, struct content *new_content); void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state); #endif /* WITH_BMP */ diff --git a/image/gif.c b/image/gif.c index 01ea57420..7d5a2dc30 100644 --- a/image/gif.c +++ b/image/gif.c @@ -197,6 +197,22 @@ void nsgif_destroy(struct content *c) } +bool nsgif_clone(const struct content *old, struct content *new_content) +{ + /* Simply replay creation and conversion of content */ + if (nsgif_create(new_content, NULL) == false) + return false; + + if (old->status == CONTENT_STATUS_READY || + old->status == CONTENT_STATUS_DONE) { + if (nsgif_convert(new_content) == false) + return false; + } + + return true; +} + + /** * Updates the GIF bitmap to display the current frame * diff --git a/image/gif.h b/image/gif.h index 9a39ecf55..9b2eb9fd6 100644 --- a/image/gif.h +++ b/image/gif.h @@ -50,6 +50,7 @@ bool nsgif_redraw_tiled(struct content *c, int x, int y, int clip_x0, int clip_y0, int clip_x1, int clip_y1, float scale, colour background_colour, bool repeat_x, bool repeat_y); +bool nsgif_clone(const struct content *old, struct content *new_content); void *nsgif_bitmap_create(int width, int height); #endif /* WITH_GIF */ diff --git a/image/ico.c b/image/ico.c index 3335a6a58..190da86d2 100644 --- a/image/ico.c +++ b/image/ico.c @@ -169,4 +169,19 @@ void nsico_destroy(struct content *c) free(c->data.ico.ico); } +bool nsico_clone(const struct content *old, struct content *new_content) +{ + /* Simply replay creation and conversion */ + if (nsico_create(new_content, NULL) == false) + return false; + + if (old->status == CONTENT_STATUS_READY || + old->status == CONTENT_STATUS_DONE) { + if (nsico_convert(new_content) == false) + return false; + } + + return true; +} + #endif diff --git a/image/ico.h b/image/ico.h index 75f79a92e..6ed8b59d2 100644 --- a/image/ico.h +++ b/image/ico.h @@ -49,6 +49,7 @@ bool nsico_redraw_tiled(struct content *c, int x, int y, int clip_x0, int clip_y0, int clip_x1, int clip_y1, float scale, colour background_colour, bool repeat_x, bool repeat_y); +bool nsico_clone(const struct content *old, struct content *new_content); bool nsico_set_bitmap_from_size(struct hlcache_handle *h, int width, int height); diff --git a/image/jpeg.c b/image/jpeg.c index af28fe6fa..6e5e446dd 100644 --- a/image/jpeg.c +++ b/image/jpeg.c @@ -286,4 +286,17 @@ void nsjpeg_destroy(struct content *c) bitmap_destroy(c->bitmap); } + +bool nsjpeg_clone(const struct content *old, struct content *new_content) +{ + /* Simply replay conversion */ + if (old->status == CONTENT_STATUS_READY || + old->status == CONTENT_STATUS_DONE) { + if (nsjpeg_convert(new_content) == false) + return false; + } + + return true; +} + #endif /* WITH_JPEG */ diff --git a/image/jpeg.h b/image/jpeg.h index 1c01929b8..5f142546a 100644 --- a/image/jpeg.h +++ b/image/jpeg.h @@ -46,6 +46,7 @@ bool nsjpeg_redraw_tiled(struct content *c, int x, int y, int clip_x0, int clip_y0, int clip_x1, int clip_y1, float scale, colour background_colour, bool repeat_x, bool repeat_y); +bool nsjpeg_clone(const struct content *old, struct content *new_content); #endif /* WITH_JPEG */ diff --git a/image/mng.c b/image/mng.c index 5498d0528..7d288a3d3 100644 --- a/image/mng.c +++ b/image/mng.c @@ -585,6 +585,31 @@ bool nsmng_redraw_tiled(struct content *c, int x, int y, return ret; } + +bool nsmng_clone(const struct content *old, struct content *new_content) +{ + const char *data; + unsigned long size; + + /* Simply replay create/process/convert */ + if (nsmng_create(new_content, NULL) == false) + return false; + + data = content__get_source_data(new_content, &size); + if (size > 0) { + if (nsmng_process_data(new_content, data, size) == false) + return false; + } + + if (old->status == CONTENT_STATUS_READY || + old->status == CONTENT_STATUS_DONE) { + if (nsmng_convert(new_content) == false) + return false; + } + + return true; +} + /** * Animates to the next frame */ diff --git a/image/mng.h b/image/mng.h index 319d42059..9b45852a0 100644 --- a/image/mng.h +++ b/image/mng.h @@ -54,6 +54,7 @@ bool nsmng_redraw_tiled(struct content *c, int x, int y, int clip_x0, int clip_y0, int clip_x1, int clip_y1, float scale, colour background_colour, bool repeat_x, bool repeat_y); +bool nsmng_clone(const struct content *old, struct content *new_content); #endif /* WITH_MNG */ diff --git a/image/nssprite.c b/image/nssprite.c index 06e5696a0..6e2778960 100644 --- a/image/nssprite.c +++ b/image/nssprite.c @@ -144,4 +144,17 @@ bool nssprite_redraw(struct content *c, int x, int y, c->bitmap, background_colour, BITMAPF_NONE); } + +bool nssprite_clone(const struct content *old, struct content *new_content) +{ + /* Simply replay convert */ + if (old->status == CONTENT_STATUS_READY || + old->status == CONTENT_STATUS_DONE) { + if (nssprite_convert(new_content) == false) + return false; + } + + return true; +} + #endif diff --git a/image/nssprite.h b/image/nssprite.h index cc366efc7..7149b1fa0 100644 --- a/image/nssprite.h +++ b/image/nssprite.h @@ -40,6 +40,7 @@ bool nssprite_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, colour background_colour); +bool nssprite_clone(const struct content *old, struct content *new_content); #endif /* WITH_NSSPRITE */ diff --git a/image/png.c b/image/png.c index f68c07cda..5f01b2387 100644 --- a/image/png.c +++ b/image/png.c @@ -326,4 +326,28 @@ bool nspng_redraw_tiled(struct content *c, int x, int y, int width, int height, background_colour, flags); } +bool nspng_clone(const struct content *old, struct content *new_content) +{ + const char *data; + unsigned long size; + + /* Simply replay create/process/convert */ + if (nspng_create(new_content, NULL) == false) + return false; + + data = content__get_source_data(new_content, &size); + if (size > 0) { + if (nspng_process_data(new_content, data, size) == false) + return false; + } + + if (old->status == CONTENT_STATUS_READY || + old->status == CONTENT_STATUS_DONE) { + if (nspng_convert(new_content) == false) + return false; + } + + return true; +} + #endif diff --git a/image/png.h b/image/png.h index 253e685ad..9f673d9fe 100644 --- a/image/png.h +++ b/image/png.h @@ -54,6 +54,8 @@ bool nspng_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, colour background_colour, bool repeat_x, bool repeat_y); +bool nspng_clone(const struct content *old, struct content *new_content); + #endif #endif diff --git a/image/rsvg.c b/image/rsvg.c index c47e9a078..02455733e 100644 --- a/image/rsvg.c +++ b/image/rsvg.c @@ -207,4 +207,28 @@ void rsvg_destroy(struct content *c) return; } +bool rsvg_clone(const struct content *old, struct content *new_content) +{ + const char *data; + unsigned long size; + + /* Simply replay create/process/convert */ + if (rsvg_create(new_content, NULL) == false) + return false; + + data = content__get_source_data(new_content, &size); + if (size > 0) { + if (rsvg_process_data(new_content, data, size) == false) + return false; + } + + if (old->status == CONTENT_STATUS_READY || + old->status == CONTENT_STATUS_DONE) { + if (rsvg_convert(new_content) == false) + return false; + } + + return true; +} + #endif /* WITH_RSVG */ diff --git a/image/rsvg.h b/image/rsvg.h index 0eeb3c9eb..e85115dcf 100644 --- a/image/rsvg.h +++ b/image/rsvg.h @@ -55,6 +55,7 @@ bool rsvg_redraw_tiled(struct content *c, int x, int y, int clip_x0, int clip_y0, int clip_x1, int clip_y1, float scale, colour background_colour, bool repeat_x, bool repeat_y); +bool rsvg_clone(const struct content *old, struct content *new_content); #endif /* WITH_RSVG */ diff --git a/image/svg.c b/image/svg.c index fce246588..44f893afe 100644 --- a/image/svg.c +++ b/image/svg.c @@ -177,4 +177,20 @@ void svg_destroy(struct content *c) } +bool svg_clone(const struct content *old, struct content *new_content) +{ + /* Simply replay create/convert */ + if (svg_create(new_content, NULL) == false) + return false; + + if (old->status == CONTENT_STATUS_READY || + old->status == CONTENT_STATUS_DONE) { + if (svg_convert(new_content) == false) + return false; + } + + return true; +} + + #endif /* WITH_NS_SVG */ diff --git a/image/svg.h b/image/svg.h index e6cffea39..9720a3772 100644 --- a/image/svg.h +++ b/image/svg.h @@ -42,5 +42,6 @@ bool svg_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, colour background_colour); +bool svg_clone(const struct content *old, struct content *new_content); #endif -- cgit v1.2.3