зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1052913 - Clean up some nsSVGClipPathFrame code and add some documentation to make it clearer. r=dholbert
This commit is contained in:
Родитель
7a07a4a8da
Коммит
9cf6a9f6a0
|
@ -28,9 +28,9 @@ NS_NewSVGClipPathFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|||
NS_IMPL_FRAMEARENA_HELPERS(nsSVGClipPathFrame)
|
||||
|
||||
nsresult
|
||||
nsSVGClipPathFrame::ClipPaint(nsRenderingContext* aContext,
|
||||
nsIFrame* aParent,
|
||||
const gfxMatrix &aMatrix)
|
||||
nsSVGClipPathFrame::ApplyClipOrPaintClipMask(nsRenderingContext* aContext,
|
||||
nsIFrame* aClippedFrame,
|
||||
const gfxMatrix& aMatrix)
|
||||
{
|
||||
// If the flag is set when we get here, it means this clipPath frame
|
||||
// has already been used painting the current clip, and the document
|
||||
|
@ -41,7 +41,7 @@ nsSVGClipPathFrame::ClipPaint(nsRenderingContext* aContext,
|
|||
}
|
||||
AutoClipPathReferencer clipRef(this);
|
||||
|
||||
mMatrixForChildren = GetClipPathTransform(aParent) * aMatrix;
|
||||
mMatrixForChildren = GetClipPathTransform(aClippedFrame) * aMatrix;
|
||||
|
||||
gfxContext *gfx = aContext->ThebesContext();
|
||||
|
||||
|
@ -78,7 +78,7 @@ nsSVGClipPathFrame::ClipPaint(nsRenderingContext* aContext,
|
|||
referencedClipIsTrivial = clipPathFrame->IsTrivial();
|
||||
gfx->Save();
|
||||
if (referencedClipIsTrivial) {
|
||||
clipPathFrame->ClipPaint(aContext, aParent, aMatrix);
|
||||
clipPathFrame->ApplyClipOrPaintClipMask(aContext, aClippedFrame, aMatrix);
|
||||
} else {
|
||||
gfx->PushGroup(gfxContentType::ALPHA);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ nsSVGClipPathFrame::ClipPaint(nsRenderingContext* aContext,
|
|||
isTrivial = clipPathFrame->IsTrivial();
|
||||
gfx->Save();
|
||||
if (isTrivial) {
|
||||
clipPathFrame->ClipPaint(aContext, aParent, aMatrix);
|
||||
clipPathFrame->ApplyClipOrPaintClipMask(aContext, aClippedFrame, aMatrix);
|
||||
} else {
|
||||
gfx->PushGroup(gfxContentType::ALPHA);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ nsSVGClipPathFrame::ClipPaint(nsRenderingContext* aContext,
|
|||
nsRefPtr<gfxPattern> clipMaskSurface;
|
||||
gfx->PushGroup(gfxContentType::ALPHA);
|
||||
|
||||
clipPathFrame->ClipPaint(aContext, aParent, aMatrix);
|
||||
clipPathFrame->ApplyClipOrPaintClipMask(aContext, aClippedFrame, aMatrix);
|
||||
clipMaskSurface = gfx->PopGroup();
|
||||
|
||||
if (clipMaskSurface) {
|
||||
|
@ -138,7 +138,7 @@ nsSVGClipPathFrame::ClipPaint(nsRenderingContext* aContext,
|
|||
nsRefPtr<gfxPattern> clipMaskSurface;
|
||||
gfx->PushGroup(gfxContentType::ALPHA);
|
||||
|
||||
clipPathFrame->ClipPaint(aContext, aParent, aMatrix);
|
||||
clipPathFrame->ApplyClipOrPaintClipMask(aContext, aClippedFrame, aMatrix);
|
||||
clipMaskSurface = gfx->PopGroup();
|
||||
|
||||
if (clipMaskSurface) {
|
||||
|
|
|
@ -37,9 +37,21 @@ public:
|
|||
const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
|
||||
|
||||
// nsSVGClipPathFrame methods:
|
||||
nsresult ClipPaint(nsRenderingContext* aContext,
|
||||
nsIFrame* aParent,
|
||||
const gfxMatrix &aMatrix);
|
||||
|
||||
/**
|
||||
* If the SVG clipPath is simple (as determined by the IsTrivial() method),
|
||||
* calling this method simply pushes a clip path onto the DrawTarget. If the
|
||||
* SVG clipPath is not simple then calling this method will paint the
|
||||
* clipPath's contents (geometry being filled only, with opaque black) to the
|
||||
* DrawTarget. In this latter case callers are expected to first push a
|
||||
* group before calling this method, then pop the group after calling and use
|
||||
* it as a mask to mask the clipped frame.
|
||||
*
|
||||
* XXXjwatt Maybe split this into two methods.
|
||||
*/
|
||||
nsresult ApplyClipOrPaintClipMask(nsRenderingContext* aContext,
|
||||
nsIFrame* aClippedFrame,
|
||||
const gfxMatrix &aMatrix);
|
||||
|
||||
/**
|
||||
* aPoint is expected to be in aClippedFrame's SVG user space.
|
||||
|
|
|
@ -515,7 +515,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsRenderingContext* aCtx,
|
|||
*/
|
||||
if (clipPathFrame && isTrivialClip) {
|
||||
gfx->Save();
|
||||
clipPathFrame->ClipPaint(aCtx, aFrame, cssPxToDevPxMatrix);
|
||||
clipPathFrame->ApplyClipOrPaintClipMask(aCtx, aFrame, cssPxToDevPxMatrix);
|
||||
}
|
||||
|
||||
/* Paint the child */
|
||||
|
@ -552,7 +552,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsRenderingContext* aCtx,
|
|||
if (clipPathFrame && !isTrivialClip) {
|
||||
gfx->PushGroup(gfxContentType::COLOR_ALPHA);
|
||||
|
||||
nsresult rv = clipPathFrame->ClipPaint(aCtx, aFrame, cssPxToDevPxMatrix);
|
||||
nsresult rv = clipPathFrame->ApplyClipOrPaintClipMask(aCtx, aFrame, cssPxToDevPxMatrix);
|
||||
clipMaskSurface = gfx->PopGroup();
|
||||
|
||||
if (NS_SUCCEEDED(rv) && clipMaskSurface) {
|
||||
|
|
|
@ -609,7 +609,7 @@ nsSVGUtils::PaintFrameWithEffects(nsRenderingContext *aContext,
|
|||
*/
|
||||
if (clipPathFrame && isTrivialClip) {
|
||||
gfx->Save();
|
||||
clipPathFrame->ClipPaint(aContext, aFrame, matrix);
|
||||
clipPathFrame->ApplyClipOrPaintClipMask(aContext, aFrame, matrix);
|
||||
}
|
||||
|
||||
/* Paint the child */
|
||||
|
@ -661,7 +661,7 @@ nsSVGUtils::PaintFrameWithEffects(nsRenderingContext *aContext,
|
|||
if (clipPathFrame && !isTrivialClip) {
|
||||
gfx->PushGroup(gfxContentType::COLOR_ALPHA);
|
||||
|
||||
nsresult rv = clipPathFrame->ClipPaint(aContext, aFrame, matrix);
|
||||
nsresult rv = clipPathFrame->ApplyClipOrPaintClipMask(aContext, aFrame, matrix);
|
||||
clipMaskSurface = gfx->PopGroup();
|
||||
|
||||
if (NS_SUCCEEDED(rv) && clipMaskSurface) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче