[cairo] Another Gradient rendering speedup patch
David Turner
david at freetype.org
Fri Feb 2 01:32:30 PST 2007
Hi Carl,
sorry, this bug report escaped me. Here's a patch that fixes the
problem and includes the test case provided in the original bug
report.
Thanks,
- David
On Thu, 01 Feb 2007 16:55:44 -0800, "Carl Worth" <cworth at cworth.org> said:
> On Thu, 01 Feb 2007 11:18:52 +0100, "David Turner" wrote:
> > And here's a second one, which depends on the first, that will
> > speedup radial gradient fills (on my machine, up to 1.35 speedup
> > from the previous patch, and 1.44 from origin)
>
> Thanks David,
>
> It's always nice to find nice performance improvements in my inbox.
>
> But, did you see the earlier not from Tim Rowley about the bug that
> was introduced by the last round of linear gradient optimizations:
>
> http://lists.freedesktop.org/archives/cairo/2007-January/009041.html
>
> Apparently, our test suite is not exercising gradients as well as it
> should be, (and in particular, the various extend modes).
>
> Tim's message above provides a new test case showing the problem in
> the previous optimization with EXTEND_PAD and linear gradients.
> Could you take a look at that and see if it's something easy to fix?
>
> In the meantime, I'll write some tests that better exercise the
> various gradients and extend modes, and give these new patches a
> run-through with those before I push them out.
>
> Thanks,
>
> -Carl
-------------- next part --------------
From a152420e029909e0148c9957b1b4b829bfab8ea6 Mon Sep 17 00:00:00 2001
From: David Turner <digit at mounini.par.corp.google.com>
Date: Fri, 2 Feb 2007 10:30:24 +0100
Subject: [PATCH] fixing gradient repeat mode computations + adding new test case to check it
---
pixman/src/fbcompose.c | 6 +++-
test/Makefile.am | 2 +
test/linear-gradient-reflect-ref.png | Bin
test/linear-gradient-reflect.c | 48 ++++++++++++++++++++++++++++++++++
4 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/pixman/src/fbcompose.c b/pixman/src/fbcompose.c
index d698eb4..7d7ac00 100644
--- a/pixman/src/fbcompose.c
+++ b/pixman/src/fbcompose.c
@@ -2852,13 +2852,15 @@ _gradient_walker_reset (GradientWalker
pixman_color_t *tmp_c;
int32_t tmp_x;
- tmp_x = 0x20000 - right_x;
- right_x = 0x20000 - left_x;
+ tmp_x = 0x10000 - right_x;
+ right_x = 0x10000 - left_x;
left_x = tmp_x;
tmp_c = right_c;
right_c = left_c;
left_c = tmp_c;
+
+ x = 0x10000 - x;
}
left_x += (pos - x);
right_x += (pos - x);
diff --git a/test/Makefile.am b/test/Makefile.am
index 8d31419..63286ee 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -53,6 +53,7 @@ leaky-polygon \
line-width \
line-width-scale \
linear-gradient \
+linear-gradient-reflect \
long-lines \
mask \
mask-ctm \
@@ -250,6 +251,7 @@ infinite-join-ref.png \
leaky-dash-ref.png \
leaky-polygon-ref.png \
linear-gradient-ref.png \
+linear-gradient-reflect-ref.png \
linear-gradient-svg-ref.png \
line-width-ref.png \
line-width-scale-ref.png \
diff --git a/test/linear-gradient-reflect-ref.png b/test/linear-gradient-reflect-ref.png
new file mode 100644
index 0000000..e4f9db8
Binary files /dev/null and b/test/linear-gradient-reflect-ref.png differ
diff --git a/test/linear-gradient-reflect.c b/test/linear-gradient-reflect.c
new file mode 100644
index 0000000..89c48bc
--- /dev/null
+++ b/test/linear-gradient-reflect.c
@@ -0,0 +1,48 @@
+#include "cairo-test.h"
+#include "stdio.h"
+
+#define WIDTH 50
+#define HEIGHT 50
+
+static cairo_test_draw_function_t draw;
+
+cairo_test_t test = {
+ "linear-gradient-reflect",
+ "Tests the drawing of linear gradient with reflect",
+ WIDTH, HEIGHT,
+ draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+
+ cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
+ cairo_paint (cr);
+
+ cairo_save (cr);
+
+ pattern = cairo_pattern_create_linear (0, 0, 10.0, 0);
+
+ cairo_pattern_add_color_stop_rgb (pattern, 0.0,
+ 0.0, 0.0, 1.0);
+ cairo_pattern_add_color_stop_rgb (pattern, 1.0,
+ 1.0, 0.0, 0.0);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REFLECT);
+
+ cairo_set_source (cr, pattern);
+ cairo_pattern_destroy (pattern);
+ cairo_rectangle (cr, 0.0, 0.0, WIDTH, HEIGHT);
+ cairo_fill (cr);
+
+ cairo_restore (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}
--
1.4.1
More information about the cairo
mailing list