summaryrefslogtreecommitdiff
path: root/image
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-05-09 13:02:22 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-05-09 13:02:22 +0000
commit0929aa897b73bb5a028c732a0867a7f093f92629 (patch)
treecf44221a33416b14a433aa1438747b07d3ef1e0e /image
parentcbc2a9470f04fab9bf9379fcc428fd7ba799c5cf (diff)
downloadnetsurf-0929aa897b73bb5a028c732a0867a7f093f92629.tar.gz
netsurf-0929aa897b73bb5a028c732a0867a7f093f92629.tar.bz2
Fix tiled redraw of SVGs.
svn path=/trunk/netsurf/; revision=12340
Diffstat (limited to 'image')
-rw-r--r--image/svg.c61
1 files changed, 58 insertions, 3 deletions
diff --git a/image/svg.c b/image/svg.c
index 281b7d74c..5f093b8e8 100644
--- a/image/svg.c
+++ b/image/svg.c
@@ -224,10 +224,9 @@ void svg_reformat(struct content *c, int width, int height)
* Redraw a CONTENT_SVG.
*/
-bool svg_redraw(struct content *c, int x, int y,
+static bool svg_redraw_internal(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)
+ float scale, colour background_colour)
{
svg_content *svg = (svg_content *) c;
float transform[6];
@@ -290,6 +289,62 @@ bool svg_redraw(struct content *c, int x, int y,
/**
+ * Redraw a CONTENT_SVG.
+ */
+
+bool svg_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)
+{
+ if ((width <= 0) && (height <= 0)) {
+ /* No point trying to plot SVG if it does not occupy a valid
+ * area */
+ return true;
+ }
+
+ if ((repeat_x == false) && (repeat_y == false)) {
+ /* Simple case: SVG is not tiled */
+ return svg_redraw_internal(c, x, y, width, height,
+ clip, scale, background_colour);
+ } else {
+ /* Tiled redraw required. SVG repeats to extents of clip
+ * rectangle, in x, y or both directions */
+ int x0, y0, x1, y1;
+
+ /* 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 the SVG across the area */
+ for (y = y0; y < y1; y += height) {
+ for (x = x0; x < x1; x += width) {
+ if (!svg_redraw_internal(c, x, y,
+ width, height, clip, scale,
+ background_colour)) {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+
+/**
* Destroy a CONTENT_SVG and free all resources it owns.
*/