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

Albert Astals Cid aacid at kde.org
Wed Jan 26 00:50:30 PST 2011


A Dimecres, 26 de gener de 2011, Carlos Garcia Campos va escriure:
> Excerpts from Albert Astals Cid's message of mar ene 25 21:05:46 +0100 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.
> 
> Ok, I'll push the patch and change axial and radial gradients to also
> return early when content is hidden. Ok?

Fine for me, if you are concerned about it creating regressions i can run the 
regtest in cairo and splash to make sure nothing is changed after you commit 
the patch.

Albert

> 
> > Albert


More information about the poppler mailing list