[poppler] Implement Type 4, 5, 6, 7 shadings using cairo mesh gradients

Adrian Johnson ajohnson at redneon.com
Tue Jan 25 00:43:23 PST 2011


On 25/01/11 00:56, Thomas Freitag wrote:
> I had a quick look at what Adrian has done in Gfc.cc, and think, that is
> a little bit misusing of out->gouraudTriangleShadedFill( state, shading)
> and out->patchMeshShadedFill( state, shading):
> 
> When these functions returns gTrue, this indicates that all work has
> already be done in the output device. How Adrian implements it is very
> special to Cairo. But it is quite ease to change it:
> Just move the lines
> 
> + double xMin, yMin, xMax, yMax;
> +
> + // get the clip region bbox
> + state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax);
> + state->moveTo(xMin, yMin);
> + state->lineTo(xMin, yMax);
> + state->lineTo(xMax, yMax);
> + state->lineTo(xMax, yMin);
> + state->closePath();
> + if (!contentIsHidden())
> + out->fill(state);
> + state->clearPath();
> 
> to CairoOutputDev::gouraudTriangleShadedFill respectively to
> CairoOutputDev::patchMeshShadedFill, i.e. if the actual implementation
> of gouraudTriangleShadedFill in CairoUtputDev would be renamed to
> formerGouraudTriangleShadedFill then do it like
> 
> GBool CairoOutputDev::gouraudTriangleShadedFill(GfxState *state,
> GfxGouraudTriangleShading *shading) {
>         if (formerGouraudTriangleShadedFill(state, shading)) {
>             double xMin, yMin, xMax, yMax;
> 
>              // get the clip region bbox
>              state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax);
>              state->moveTo(xMin, yMin);
>              state->lineTo(xMin, yMax);
>              state->lineTo(xMax, yMax);
>              state->lineTo(xMax, yMin);
>              state->closePath();
>              fill(state);
>              state->clearPath();
>              return gTrue;
>         } else
>             return gFalse;
> }
> 
> patchMeshShadedFill simular. Then You don't need to change Gfx, and it
> fits to the other shading routines.

I'm attaching a new patch that moves the fill into the cairo backend.


More information about the poppler mailing list