Bug 1345853 - Part 4. Pass sync decode flag down to nsSVGPatternFrame::PaintPattern. r=tnikkel

MozReview-Commit-ID: 1bHMINhs121

--HG--
extra : rebase_source : 8da9c0d77dd9a32be392f43d3be266d365894b3a
This commit is contained in:
cku 2017-03-25 03:19:18 +08:00
parent ff10c4ce7b
commit a55d02afd1
12 changed files with 96 additions and 54 deletions

View File

@ -205,7 +205,8 @@ public:
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
GetFillPattern(const DrawTarget* aDrawTarget,
float aOpacity,
const gfxMatrix& aCTM) {
const gfxMatrix& aCTM,
uint32_t aFlags) {
if (mFillPattern) {
mFillPattern->SetMatrix(aCTM * mFillMatrix);
}
@ -216,7 +217,8 @@ public:
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
GetStrokePattern(const DrawTarget* aDrawTarget,
float aOpacity,
const gfxMatrix& aCTM) {
const gfxMatrix& aCTM,
uint32_t aFlags) {
if (mStrokePattern) {
mStrokePattern->SetMatrix(aCTM * mStrokeMatrix);
}

View File

@ -172,24 +172,29 @@ SVGContextPaint::GetContextPaint(nsIContent* aContent)
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
SVGContextPaintImpl::GetFillPattern(const DrawTarget* aDrawTarget,
float aOpacity,
const gfxMatrix& aCTM)
const gfxMatrix& aCTM,
uint32_t aFlags)
{
return mFillPaint.GetPattern(aDrawTarget, aOpacity, &nsStyleSVG::mFill, aCTM);
return mFillPaint.GetPattern(aDrawTarget, aOpacity, &nsStyleSVG::mFill, aCTM,
aFlags);
}
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
SVGContextPaintImpl::GetStrokePattern(const DrawTarget* aDrawTarget,
float aOpacity,
const gfxMatrix& aCTM)
const gfxMatrix& aCTM,
uint32_t aFlags)
{
return mStrokePaint.GetPattern(aDrawTarget, aOpacity, &nsStyleSVG::mStroke, aCTM);
return mStrokePaint.GetPattern(aDrawTarget, aOpacity, &nsStyleSVG::mStroke,
aCTM, aFlags);
}
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
SVGContextPaintImpl::Paint::GetPattern(const DrawTarget* aDrawTarget,
float aOpacity,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const gfxMatrix& aCTM)
const gfxMatrix& aCTM,
uint32_t aFlags)
{
RefPtr<gfxPattern> pattern;
if (mPatternCache.Get(aOpacity, getter_AddRefs(pattern))) {
@ -219,7 +224,9 @@ SVGContextPaintImpl::Paint::GetPattern(const DrawTarget* aDrawTarget,
aDrawTarget,
mContextMatrix,
aFillOrStroke,
aOpacity);
aOpacity,
nullptr,
aFlags);
{
// m maps original-user-space to pattern space
gfxMatrix m = pattern->GetMatrix();
@ -235,14 +242,14 @@ SVGContextPaintImpl::Paint::GetPattern(const DrawTarget* aDrawTarget,
case eStyleSVGPaintType_ContextFill:
Tie(result, pattern) =
mPaintDefinition.mContextPaint->GetFillPattern(aDrawTarget,
aOpacity, aCTM);
aOpacity, aCTM, aFlags);
// Don't cache this. mContextPaint will have cached it anyway. If we
// cache it, we'll have to compute mPatternMatrix, which is annoying.
return MakePair(result, Move(pattern));
case eStyleSVGPaintType_ContextStroke:
Tie(result, pattern) =
mPaintDefinition.mContextPaint->GetStrokePattern(aDrawTarget,
aOpacity, aCTM);
aOpacity, aCTM, aFlags);
// Don't cache this. mContextPaint will have cached it anyway. If we
// cache it, we'll have to compute mPatternMatrix, which is annoying.
return MakePair(result, Move(pattern));
@ -297,7 +304,8 @@ AutoSetRestoreSVGContextPaint::~AutoSetRestoreSVGContextPaint()
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
SVGEmbeddingContextPaint::GetFillPattern(const DrawTarget* aDrawTarget,
float aFillOpacity,
const gfxMatrix& aCTM)
const gfxMatrix& aCTM,
uint32_t aFlags)
{
if (!mFill) {
return MakePair(DrawResult::SUCCESS, RefPtr<gfxPattern>());
@ -314,7 +322,8 @@ SVGEmbeddingContextPaint::GetFillPattern(const DrawTarget* aDrawTarget,
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
SVGEmbeddingContextPaint::GetStrokePattern(const DrawTarget* aDrawTarget,
float aStrokeOpacity,
const gfxMatrix& aCTM)
const gfxMatrix& aCTM,
uint32_t aFlags)
{
if (!mStroke) {
return MakePair(DrawResult::SUCCESS, RefPtr<gfxPattern>());

View File

@ -63,22 +63,26 @@ public:
virtual mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
GetFillPattern(const DrawTarget* aDrawTarget,
float aOpacity,
const gfxMatrix& aCTM) = 0;
const gfxMatrix& aCTM,
uint32_t aFlags = 0) = 0;
virtual mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
GetStrokePattern(const DrawTarget* aDrawTarget,
float aOpacity,
const gfxMatrix& aCTM) = 0;
const gfxMatrix& aCTM,
uint32_t aFlags = 0) = 0;
virtual float GetFillOpacity() const = 0;
virtual float GetStrokeOpacity() const = 0;
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
GetFillPattern(const DrawTarget* aDrawTarget, const gfxMatrix& aCTM) {
return GetFillPattern(aDrawTarget, GetFillOpacity(), aCTM);
GetFillPattern(const DrawTarget* aDrawTarget, const gfxMatrix& aCTM,
uint32_t aFlags = 0) {
return GetFillPattern(aDrawTarget, GetFillOpacity(), aCTM, aFlags);
}
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
GetStrokePattern(const DrawTarget* aDrawTarget, const gfxMatrix& aCTM) {
return GetStrokePattern(aDrawTarget, GetStrokeOpacity(), aCTM);
GetStrokePattern(const DrawTarget* aDrawTarget, const gfxMatrix& aCTM,
uint32_t aFlags) {
return GetStrokePattern(aDrawTarget, GetStrokeOpacity(), aCTM, aFlags);
}
static SVGContextPaint* GetContextPaint(nsIContent* aContent);
@ -156,11 +160,13 @@ public:
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
GetFillPattern(const DrawTarget* aDrawTarget,
float aOpacity,
const gfxMatrix& aCTM) override;
const gfxMatrix& aCTM,
uint32_t aFlags) override;
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
GetStrokePattern(const DrawTarget* aDrawTarget,
float aOpacity,
const gfxMatrix& aCTM) override;
const gfxMatrix& aCTM,
uint32_t aFlags) override;
void SetFillOpacity(float aOpacity) { mFillOpacity = aOpacity; }
float GetFillOpacity() const override { return mFillOpacity; }
@ -214,7 +220,8 @@ public:
GetPattern(const DrawTarget* aDrawTarget,
float aOpacity,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const gfxMatrix& aCTM);
const gfxMatrix& aCTM,
uint32_t aFlags);
};
Paint mFillPaint;
@ -250,14 +257,14 @@ public:
*/
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
GetFillPattern(const DrawTarget* aDrawTarget, float aFillOpacity,
const gfxMatrix& aCTM) override;
const gfxMatrix& aCTM, uint32_t aFlags = 0) override;
/**
* Returns a pattern of type PatternType::COLOR, or else nullptr.
*/
mozilla::Pair<DrawResult, RefPtr<gfxPattern>>
GetStrokePattern(const DrawTarget* aDrawTarget, float aStrokeOpacity,
const gfxMatrix& aCTM) override;
const gfxMatrix& aCTM, uint32_t aFlags = 0) override;
float GetFillOpacity() const override {
// Always 1.0f since we don't currently allow 'context-fill-opacity'

View File

@ -303,7 +303,7 @@ SVGGeometryFrame::PaintSVG(gfxContext& aContext,
DrawResult result = DrawResult::SUCCESS;
if (paintOrder == NS_STYLE_PAINT_ORDER_NORMAL) {
result = Render(&aContext, eRenderFill | eRenderStroke, newMatrix);
result = Render(&aContext, eRenderFill | eRenderStroke, newMatrix, aFlags);
PaintMarkers(aContext, aTransform);
} else {
while (paintOrder) {
@ -311,10 +311,10 @@ SVGGeometryFrame::PaintSVG(gfxContext& aContext,
paintOrder & ((1 << NS_STYLE_PAINT_ORDER_BITWIDTH) - 1);
switch (component) {
case NS_STYLE_PAINT_ORDER_FILL:
result &= Render(&aContext, eRenderFill, newMatrix);
result &= Render(&aContext, eRenderFill, newMatrix, aFlags);
break;
case NS_STYLE_PAINT_ORDER_STROKE:
result &= Render(&aContext, eRenderStroke, newMatrix);
result &= Render(&aContext, eRenderStroke, newMatrix, aFlags);
break;
case NS_STYLE_PAINT_ORDER_MARKERS:
PaintMarkers(aContext, aTransform);
@ -761,7 +761,8 @@ SVGGeometryFrame::MarkerProperties::GetMarkerEndFrame()
DrawResult
SVGGeometryFrame::Render(gfxContext* aContext,
uint32_t aRenderComponents,
const gfxMatrix& aNewTransform)
const gfxMatrix& aNewTransform,
uint32_t aFlags)
{
MOZ_ASSERT(!aNewTransform.IsSingular());
@ -814,7 +815,7 @@ SVGGeometryFrame::Render(gfxContext* aContext,
if (aRenderComponents & eRenderFill) {
GeneralPattern fillPattern;
result = nsSVGUtils::MakeFillPatternFor(this, aContext, &fillPattern,
contextPaint);
contextPaint, aFlags);
if (fillPattern.GetPattern()) {
DrawOptions drawOptions(1.0f, CompositionOp::OP_OVER, aaMode);
@ -853,7 +854,7 @@ SVGGeometryFrame::Render(gfxContext* aContext,
GeneralPattern strokePattern;
result &=
nsSVGUtils::MakeStrokePatternFor(this, aContext, &strokePattern,
contextPaint);
contextPaint, aFlags);
if (strokePattern.GetPattern()) {
SVGContentUtils::AutoStrokeOptions strokeOptions;

View File

@ -122,7 +122,7 @@ protected:
private:
enum { eRenderFill = 1, eRenderStroke = 2 };
DrawResult Render(gfxContext* aContext, uint32_t aRenderComponents,
const gfxMatrix& aTransform);
const gfxMatrix& aTransform, uint32_t aFlags);
/**
* @param aMatrix The transform that must be multiplied onto aContext to

View File

@ -229,7 +229,8 @@ nsSVGGradientFrame::GetPaintServerPattern(nsIFrame* aSource,
const gfxMatrix& aContextMatrix,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float aGraphicOpacity,
const gfxRect* aOverrideBounds)
const gfxRect* aOverrideBounds,
uint32_t aFlags)
{
uint16_t gradientUnits = GetGradientUnits();
MOZ_ASSERT(gradientUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX ||

View File

@ -52,7 +52,8 @@ public:
const gfxMatrix& aContextMatrix,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float aGraphicOpacity,
const gfxRect* aOverrideBounds) override;
const gfxRect* aOverrideBounds,
uint32_t aFlags) override;
// nsIFrame interface:
virtual nsresult AttributeChanged(int32_t aNameSpaceID,

View File

@ -81,7 +81,8 @@ public:
const gfxMatrix& aContextMatrix,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float aOpacity,
const gfxRect *aOverrideBounds = nullptr) = 0;
const gfxRect *aOverrideBounds = nullptr,
uint32_t aFlags = 0) = 0;
// nsIFrame methods:
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,

View File

@ -218,7 +218,8 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
nsIFrame *aSource,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float aGraphicOpacity,
const gfxRect *aOverrideBounds)
const gfxRect *aOverrideBounds,
uint32_t aFlags)
{
/*
* General approach:
@ -396,7 +397,8 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
PrependLocalTransformsTo(tm, eUserSpaceToParent);
}
result &= nsSVGUtils::PaintFrameWithEffects(kid, *ctx, tm);
result &= nsSVGUtils::PaintFrameWithEffects(kid, *ctx, tm, nullptr,
aFlags);
}
}
@ -728,7 +730,8 @@ nsSVGPatternFrame::GetPaintServerPattern(nsIFrame *aSource,
const gfxMatrix& aContextMatrix,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float aGraphicOpacity,
const gfxRect *aOverrideBounds)
const gfxRect *aOverrideBounds,
uint32_t aFlags)
{
if (aGraphicOpacity == 0.0f) {
RefPtr<gfxPattern> pattern = new gfxPattern(Color());
@ -741,7 +744,7 @@ nsSVGPatternFrame::GetPaintServerPattern(nsIFrame *aSource,
DrawResult result = DrawResult::SUCCESS;
Tie(result, surface) =
PaintPattern(aDrawTarget, &pMatrix, ToMatrix(aContextMatrix), aSource,
aFillOrStroke, aGraphicOpacity, aOverrideBounds);
aFillOrStroke, aGraphicOpacity, aOverrideBounds, aFlags);
if (!surface) {
return MakePair(result, RefPtr<gfxPattern>());

View File

@ -46,7 +46,8 @@ public:
const gfxMatrix& aContextMatrix,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float aOpacity,
const gfxRect *aOverrideBounds) override;
const gfxRect *aOverrideBounds,
uint32_t aFlags) override;
public:
typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
@ -113,7 +114,8 @@ protected:
nsIFrame *aSource,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float aGraphicOpacity,
const gfxRect *aOverrideBounds);
const gfxRect *aOverrideBounds,
uint32_t aFlags);
/**
* A <pattern> element may reference another <pattern> element using

View File

@ -471,6 +471,10 @@ nsSVGUtils::NotifyChildrenOfSVGChange(nsIFrame *aFrame, uint32_t aFlags)
class SVGPaintCallback : public nsSVGFilterPaintCallback
{
public:
explicit SVGPaintCallback(uint32_t aFlags)
: mFlags(aFlags)
{ }
virtual DrawResult Paint(gfxContext& aContext, nsIFrame *aTarget,
const gfxMatrix& aTransform,
const nsIntRect* aDirtyRect) override
@ -498,8 +502,11 @@ public:
return svgFrame->PaintSVG(aContext,
nsSVGUtils::GetCSSPxToDevPxMatrix(aTarget),
dirtyRect);
dirtyRect, mFlags);
}
private:
uint32_t mFlags;
};
float
@ -677,7 +684,8 @@ DrawResult
nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
gfxContext& aContext,
const gfxMatrix& aTransform,
const nsIntRect *aDirtyRect)
const nsIntRect *aDirtyRect,
uint32_t aFlags)
{
NS_ASSERTION(!NS_SVGDisplayListPaintingEnabled() ||
(aFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY) ||
@ -881,13 +889,13 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
MOZ_ASSERT(invertible);
target->SetMatrix(aTransform * devPxToCssPxTM);
SVGPaintCallback paintCallback;
SVGPaintCallback paintCallback(aFlags);
result =
nsFilterInstance::PaintFilteredFrame(aFrame, target->GetDrawTarget(),
aTransform, &paintCallback,
dirtyRegion);
} else {
result = svgFrame->PaintSVG(*target, aTransform, aDirtyRect);
result = svgFrame->PaintSVG(*target, aTransform, aDirtyRect, aFlags);
}
if (maskUsage.shouldApplyClipPath || maskUsage.shouldApplyBasicShape) {
@ -1483,7 +1491,8 @@ nsSVGUtils::GetFallbackOrPaintColor(nsStyleContext *aStyleContext,
nsSVGUtils::MakeFillPatternFor(nsIFrame* aFrame,
gfxContext* aContext,
GeneralPattern* aOutPattern,
SVGContextPaint* aContextPaint)
SVGContextPaint* aContextPaint,
uint32_t aFlags)
{
const nsStyleSVG* style = aFrame->StyleSVG();
if (style->mFill.Type() == eStyleSVGPaintType_None) {
@ -1512,7 +1521,8 @@ nsSVGUtils::MakeFillPatternFor(nsIFrame* aFrame,
RefPtr<gfxPattern> pattern;
Tie(result, pattern) =
ps->GetPaintServerPattern(aFrame, dt, aContext->CurrentMatrix(),
&nsStyleSVG::mFill, fillOpacity);
&nsStyleSVG::mFill, fillOpacity, nullptr,
aFlags);
if (pattern) {
pattern->CacheColorStops(dt);
aOutPattern->Init(*pattern->GetPattern(dt));
@ -1526,12 +1536,12 @@ nsSVGUtils::MakeFillPatternFor(nsIFrame* aFrame,
case eStyleSVGPaintType_ContextFill:
Tie(result, pattern) =
aContextPaint->GetFillPattern(dt, fillOpacity,
aContext->CurrentMatrix());
aContext->CurrentMatrix(), aFlags);
break;
case eStyleSVGPaintType_ContextStroke:
Tie(result, pattern) =
aContextPaint->GetStrokePattern(dt, fillOpacity,
aContext->CurrentMatrix());
aContext->CurrentMatrix(), aFlags);
break;
default:
;
@ -1557,7 +1567,8 @@ nsSVGUtils::MakeFillPatternFor(nsIFrame* aFrame,
nsSVGUtils::MakeStrokePatternFor(nsIFrame* aFrame,
gfxContext* aContext,
GeneralPattern* aOutPattern,
SVGContextPaint* aContextPaint)
SVGContextPaint* aContextPaint,
uint32_t aFlags)
{
const nsStyleSVG* style = aFrame->StyleSVG();
if (style->mStroke.Type() == eStyleSVGPaintType_None) {
@ -1586,7 +1597,8 @@ nsSVGUtils::MakeStrokePatternFor(nsIFrame* aFrame,
RefPtr<gfxPattern> pattern;
Tie(result, pattern) =
ps->GetPaintServerPattern(aFrame, dt, aContext->CurrentMatrix(),
&nsStyleSVG::mStroke, strokeOpacity);
&nsStyleSVG::mStroke, strokeOpacity, nullptr,
aFlags);
if (pattern) {
pattern->CacheColorStops(dt);
aOutPattern->Init(*pattern->GetPattern(dt));
@ -1600,12 +1612,12 @@ nsSVGUtils::MakeStrokePatternFor(nsIFrame* aFrame,
case eStyleSVGPaintType_ContextFill:
Tie(result, pattern) =
aContextPaint->GetFillPattern(dt, strokeOpacity,
aContext->CurrentMatrix());
aContext->CurrentMatrix(), aFlags);
break;
case eStyleSVGPaintType_ContextStroke:
Tie(result, pattern) =
aContextPaint->GetStrokePattern(dt, strokeOpacity,
aContext->CurrentMatrix());
aContext->CurrentMatrix(), aFlags);
break;
default:
;

View File

@ -293,7 +293,8 @@ public:
static DrawResult PaintFrameWithEffects(nsIFrame *aFrame,
gfxContext& aContext,
const gfxMatrix& aTransform,
const nsIntRect *aDirtyRect = nullptr);
const nsIntRect *aDirtyRect = nullptr,
uint32_t aFlags = 0);
/* Hit testing - check if point hits the clipPath of indicated
* frame. Returns true if no clipPath set. */
@ -512,13 +513,15 @@ public:
static DrawResult MakeFillPatternFor(nsIFrame *aFrame,
gfxContext* aContext,
GeneralPattern* aOutPattern,
SVGContextPaint* aContextPaint = nullptr);
SVGContextPaint* aContextPaint = nullptr,
uint32_t aFlags = 0);
static DrawResult
MakeStrokePatternFor(nsIFrame* aFrame,
gfxContext* aContext,
GeneralPattern* aOutPattern,
SVGContextPaint* aContextPaint = nullptr);
SVGContextPaint* aContextPaint = nullptr,
uint32_t aFlags = 0);
static float GetOpacity(nsStyleSVGOpacitySource aOpacityType,
const float& aOpacity,