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

Albert Astals Cid aacid at kde.org
Tue Jan 25 12:05:46 PST 2011


A Dimarts, 25 de gener de 2011, Adrian Johnson va escriure:
> 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.

Pending the discussion if we really need to do anything or not if content is 
hidden (i'd vote for no but not really strong) this patch looks good to me.

Albert


More information about the poppler mailing list