Re: gl: fix gradient color generation where two stops have same offset
"Henry (Yu) Song - SISA" <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <3955FA337689574EB32F94B12A7E6E9E16364AF1@sisaex01sj> |
Hi, Chris I think we still need to offset. You can experiment linear-gradient-large by commenting out offseting code, but leave dx = 0.01 in - this will use max texture width of 1024. Try that. I think the image does not come out right. This because at the end of stops stop[0] and stop[1] both have offset at 0, pixman picks stop[1] color which is black for the first pixel. Thanks Henry ________________________________________ From: Chris Wilson [[email protected]] Sent: Thursday, July 26, 2012 10:14 AM To: Henry (Yu) Song - SISA; [email protected] Subject: Re: [cairo] gl: fix gradient color generation where two stops have same offset On Thu, 26 Jul 2012 17:02:16 +0000, "Henry (Yu) Song - SISA" <[email protected]> wrote: > Hi, Chris > > Based on your comments, I am re-working the patch. The first patch is about fixing gradient color generation when multiple stops have a same offset but different color. This patch brings test case linear-gradient-large closer to reference image > > Thanks > > Henry > > From 29f4412c0a2454c36828b4dce826d9f29e6b0739 Mon Sep 17 00:00:00 2001 > From: Henry Song <[email protected]> > Date: Wed, 25 Jul 2012 15:34:52 -0700 > Subject: [PATCH] gl: fix gradient color generation for GL in cases where > there are stops that have same offset but different color. > > bring test case: linear-gradient-large closer to reference image > --- > src/cairo-gl-gradient.c | 51 ++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 48 insertions(+), 3 deletions(-) > > diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c > index ffb5468..a66f26d 100644 > --- a/src/cairo-gl-gradient.c > +++ b/src/cairo-gl-gradient.c > @@ -44,6 +44,7 @@ > #include "cairo-gl-gradient-private.h" > #include "cairo-gl-private.h" > > +#define OFFSET_TOLERANCE 0.00001 > > static int > _cairo_gl_gradient_sample_width (unsigned int n_stops, > @@ -57,9 +58,10 @@ _cairo_gl_gradient_sample_width (unsigned int n_stops, > double dx = stops[n].offset - stops[n-1].offset; > double delta, max; > int ramp; > - > + > + /* in case two stops offsets are same, and colors for different. */ > if (dx == 0) > - continue; > + dx = 0.01; I had forgotten about that issue. The solution I choose was to use a maximum texture size ramp in such (frequent) cases. If we do that do we still need to fudge the offsets? As the transistion will be as sharp as the sampler allows, and the only other solution would be to do the gradient interpolation within the shader. -Chris -- Chris Wilson, Intel Open Source Technology Centre -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo