зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1073964 - Pass a const DrawTarget* through to nsSVGPaintServerFrame::GetPaintServerPattern so that it can create a pattern of the appropriate type. r=Bas
This commit is contained in:
Родитель
27111a9c27
Коммит
a6a8b844ba
|
@ -1548,6 +1548,7 @@ private:
|
|||
nsRefPtr<gfxPattern> fillPattern;
|
||||
if (!mFontParams.contextPaint ||
|
||||
!(fillPattern = mFontParams.contextPaint->GetFillPattern(
|
||||
mRunParams.context->GetDrawTarget(),
|
||||
mRunParams.context->CurrentMatrix()))) {
|
||||
if (state.pattern) {
|
||||
pat = state.pattern->GetPattern(mRunParams.dt,
|
||||
|
@ -1630,6 +1631,7 @@ private:
|
|||
if (mFontParams.contextPaint) {
|
||||
nsRefPtr<gfxPattern> strokePattern =
|
||||
mFontParams.contextPaint->GetStrokePattern(
|
||||
mRunParams.context->GetDrawTarget(),
|
||||
mRunParams.context->CurrentMatrix());
|
||||
if (strokePattern) {
|
||||
mRunParams.dt->Stroke(path,
|
||||
|
|
|
@ -178,7 +178,7 @@ class GradientCache MOZ_FINAL : public nsExpirationTracker<GradientCacheData,4>
|
|||
static GradientCache* gGradientCache = nullptr;
|
||||
|
||||
GradientStops *
|
||||
gfxGradientCache::GetGradientStops(DrawTarget *aDT, nsTArray<GradientStop>& aStops, ExtendMode aExtend)
|
||||
gfxGradientCache::GetGradientStops(const DrawTarget *aDT, nsTArray<GradientStop>& aStops, ExtendMode aExtend)
|
||||
{
|
||||
if (!gGradientCache) {
|
||||
gGradientCache = new GradientCache();
|
||||
|
@ -189,7 +189,7 @@ gfxGradientCache::GetGradientStops(DrawTarget *aDT, nsTArray<GradientStop>& aSto
|
|||
}
|
||||
|
||||
GradientStops *
|
||||
gfxGradientCache::GetOrCreateGradientStops(DrawTarget *aDT, nsTArray<GradientStop>& aStops, ExtendMode aExtend)
|
||||
gfxGradientCache::GetOrCreateGradientStops(const DrawTarget *aDT, nsTArray<GradientStop>& aStops, ExtendMode aExtend)
|
||||
{
|
||||
RefPtr<GradientStops> gs = GetGradientStops(aDT, aStops, aExtend);
|
||||
if (!gs) {
|
||||
|
|
|
@ -17,12 +17,12 @@ namespace gfx {
|
|||
class gfxGradientCache {
|
||||
public:
|
||||
static gfx::GradientStops*
|
||||
GetGradientStops(gfx::DrawTarget *aDT,
|
||||
GetGradientStops(const gfx::DrawTarget *aDT,
|
||||
nsTArray<gfx::GradientStop>& aStops,
|
||||
gfx::ExtendMode aExtend);
|
||||
|
||||
static gfx::GradientStops*
|
||||
GetOrCreateGradientStops(gfx::DrawTarget *aDT,
|
||||
GetOrCreateGradientStops(const gfx::DrawTarget *aDT,
|
||||
nsTArray<gfx::GradientStop>& aStops,
|
||||
gfx::ExtendMode aExtend);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ gfxPattern::SetColorStops(GradientStops* aStops)
|
|||
}
|
||||
|
||||
void
|
||||
gfxPattern::CacheColorStops(DrawTarget *aDT)
|
||||
gfxPattern::CacheColorStops(const DrawTarget *aDT)
|
||||
{
|
||||
mStops = gfxGradientCache::GetOrCreateGradientStops(aDT, mStopsList,
|
||||
ToExtendMode(mExtend));
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
// This should only be called on a cairo pattern that we want to use with
|
||||
// Azure. We will read back the color stops from cairo and try to look
|
||||
// them up in the cache.
|
||||
void CacheColorStops(mozilla::gfx::DrawTarget *aDT);
|
||||
void CacheColorStops(const mozilla::gfx::DrawTarget *aDT);
|
||||
|
||||
void SetMatrix(const gfxMatrix& matrix);
|
||||
gfxMatrix GetMatrix() const;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define GFX_SVG_GLYPHS_WRAPPER_H
|
||||
|
||||
#include "gfxFontUtils.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsClassHashtable.h"
|
||||
|
@ -166,6 +167,8 @@ private:
|
|||
class gfxTextContextPaint
|
||||
{
|
||||
protected:
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
|
||||
gfxTextContextPaint() { }
|
||||
|
||||
public:
|
||||
|
@ -176,9 +179,11 @@ public:
|
|||
* This lets us inherit paints and paint opacities (i.e. fill/stroke and
|
||||
* fill-opacity/stroke-opacity) separately.
|
||||
*/
|
||||
virtual already_AddRefed<gfxPattern> GetFillPattern(float aOpacity,
|
||||
virtual already_AddRefed<gfxPattern> GetFillPattern(const DrawTarget* aDrawTarget,
|
||||
float aOpacity,
|
||||
const gfxMatrix& aCTM) = 0;
|
||||
virtual already_AddRefed<gfxPattern> GetStrokePattern(float aOpacity,
|
||||
virtual already_AddRefed<gfxPattern> GetStrokePattern(const DrawTarget* aDrawTarget,
|
||||
float aOpacity,
|
||||
const gfxMatrix& aCTM) = 0;
|
||||
|
||||
virtual float GetFillOpacity() { return 1.0f; }
|
||||
|
@ -199,12 +204,14 @@ public:
|
|||
return mStrokeWidth;
|
||||
}
|
||||
|
||||
already_AddRefed<gfxPattern> GetFillPattern(const gfxMatrix& aCTM) {
|
||||
return GetFillPattern(GetFillOpacity(), aCTM);
|
||||
already_AddRefed<gfxPattern> GetFillPattern(const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aCTM) {
|
||||
return GetFillPattern(aDrawTarget, GetFillOpacity(), aCTM);
|
||||
}
|
||||
|
||||
already_AddRefed<gfxPattern> GetStrokePattern(const gfxMatrix& aCTM) {
|
||||
return GetStrokePattern(GetStrokeOpacity(), aCTM);
|
||||
already_AddRefed<gfxPattern> GetStrokePattern(const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aCTM) {
|
||||
return GetStrokePattern(aDrawTarget, GetStrokeOpacity(), aCTM);
|
||||
}
|
||||
|
||||
virtual ~gfxTextContextPaint() { }
|
||||
|
@ -247,7 +254,8 @@ public:
|
|||
mStrokeMatrix = SetupDeviceToPatternMatrix(aStrokePattern, aCTM);
|
||||
}
|
||||
|
||||
already_AddRefed<gfxPattern> GetFillPattern(float aOpacity,
|
||||
already_AddRefed<gfxPattern> GetFillPattern(const DrawTarget* aDrawTarget,
|
||||
float aOpacity,
|
||||
const gfxMatrix& aCTM) {
|
||||
if (mFillPattern) {
|
||||
mFillPattern->SetMatrix(aCTM * mFillMatrix);
|
||||
|
@ -256,7 +264,8 @@ public:
|
|||
return fillPattern.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxPattern> GetStrokePattern(float aOpacity,
|
||||
already_AddRefed<gfxPattern> GetStrokePattern(const DrawTarget* aDrawTarget,
|
||||
float aOpacity,
|
||||
const gfxMatrix& aCTM) {
|
||||
if (mStrokePattern) {
|
||||
mStrokePattern->SetMatrix(aCTM * mStrokeMatrix);
|
||||
|
|
|
@ -4699,6 +4699,7 @@ nsImageRenderer::DrawableForElement(const nsRect& aImageRect,
|
|||
nsRefPtr<gfxDrawable> drawable =
|
||||
nsSVGIntegrationUtils::DrawableFromPaintServer(
|
||||
mPaintServerFrame, mForFrame, mSize, imageSize,
|
||||
aRenderingContext.GetDrawTarget(),
|
||||
aRenderingContext.ThebesContext()->CurrentMatrix(),
|
||||
mFlags & FLAG_SYNC_DECODE_IMAGES
|
||||
? nsSVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES
|
||||
|
|
|
@ -2993,21 +2993,24 @@ SVGTextDrawPathCallbacks::StrokeGeometry()
|
|||
// SVGTextContextPaint methods:
|
||||
|
||||
already_AddRefed<gfxPattern>
|
||||
SVGTextContextPaint::GetFillPattern(float aOpacity,
|
||||
SVGTextContextPaint::GetFillPattern(const DrawTarget* aDrawTarget,
|
||||
float aOpacity,
|
||||
const gfxMatrix& aCTM)
|
||||
{
|
||||
return mFillPaint.GetPattern(aOpacity, &nsStyleSVG::mFill, aCTM);
|
||||
return mFillPaint.GetPattern(aDrawTarget, aOpacity, &nsStyleSVG::mFill, aCTM);
|
||||
}
|
||||
|
||||
already_AddRefed<gfxPattern>
|
||||
SVGTextContextPaint::GetStrokePattern(float aOpacity,
|
||||
SVGTextContextPaint::GetStrokePattern(const DrawTarget* aDrawTarget,
|
||||
float aOpacity,
|
||||
const gfxMatrix& aCTM)
|
||||
{
|
||||
return mStrokePaint.GetPattern(aOpacity, &nsStyleSVG::mStroke, aCTM);
|
||||
return mStrokePaint.GetPattern(aDrawTarget, aOpacity, &nsStyleSVG::mStroke, aCTM);
|
||||
}
|
||||
|
||||
already_AddRefed<gfxPattern>
|
||||
SVGTextContextPaint::Paint::GetPattern(float aOpacity,
|
||||
SVGTextContextPaint::Paint::GetPattern(const DrawTarget* aDrawTarget,
|
||||
float aOpacity,
|
||||
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
||||
const gfxMatrix& aCTM)
|
||||
{
|
||||
|
@ -3034,6 +3037,7 @@ SVGTextContextPaint::Paint::GetPattern(float aOpacity,
|
|||
break;
|
||||
case eStyleSVGPaintType_Server:
|
||||
pattern = mPaintDefinition.mPaintServerFrame->GetPaintServerPattern(mFrame,
|
||||
aDrawTarget,
|
||||
mContextMatrix,
|
||||
aFillOrStroke,
|
||||
aOpacity);
|
||||
|
@ -3050,12 +3054,14 @@ SVGTextContextPaint::Paint::GetPattern(float aOpacity,
|
|||
pattern->SetMatrix(aCTM * mPatternMatrix);
|
||||
break;
|
||||
case eStyleSVGPaintType_ContextFill:
|
||||
pattern = mPaintDefinition.mContextPaint->GetFillPattern(aOpacity, aCTM);
|
||||
pattern = mPaintDefinition.mContextPaint->GetFillPattern(aDrawTarget,
|
||||
aOpacity, aCTM);
|
||||
// Don't cache this. mContextPaint will have cached it anyway. If we
|
||||
// cache it, we'll have to compute mPatternMatrix, which is annoying.
|
||||
return pattern.forget();
|
||||
case eStyleSVGPaintType_ContextStroke:
|
||||
pattern = mPaintDefinition.mContextPaint->GetStrokePattern(aOpacity, aCTM);
|
||||
pattern = mPaintDefinition.mContextPaint->GetStrokePattern(aDrawTarget,
|
||||
aOpacity, aCTM);
|
||||
// Don't cache this. mContextPaint will have cached it anyway. If we
|
||||
// cache it, we'll have to compute mPatternMatrix, which is annoying.
|
||||
return pattern.forget();
|
||||
|
@ -3677,8 +3683,8 @@ SVGTextFrame::PaintSVG(nsRenderingContext* aContext,
|
|||
|
||||
SVGTextContextPaint contextPaint;
|
||||
DrawMode drawMode =
|
||||
SetupContextPaint(gfx->CurrentMatrix(), frame, outerContextPaint,
|
||||
&contextPaint);
|
||||
SetupContextPaint(gfx->GetDrawTarget(), gfx->CurrentMatrix(),
|
||||
frame, outerContextPaint, &contextPaint);
|
||||
|
||||
if (int(drawMode) & int(DrawMode::GLYPH_STROKE)) {
|
||||
// This may change the gfxContext's transform (for non-scaling stroke),
|
||||
|
@ -5587,7 +5593,8 @@ SVGTextFrame::TransformFrameRectFromTextChild(const nsRect& aRect,
|
|||
* server frame
|
||||
*/
|
||||
static void
|
||||
SetupInheritablePaint(const gfxMatrix& aContextMatrix,
|
||||
SetupInheritablePaint(const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
nsIFrame* aFrame,
|
||||
float& aOpacity,
|
||||
gfxTextContextPaint* aOuterContextPaint,
|
||||
|
@ -5601,7 +5608,8 @@ SetupInheritablePaint(const gfxMatrix& aContextMatrix,
|
|||
|
||||
if (ps) {
|
||||
nsRefPtr<gfxPattern> pattern =
|
||||
ps->GetPaintServerPattern(aFrame, aContextMatrix, aFillOrStroke, aOpacity);
|
||||
ps->GetPaintServerPattern(aFrame, aDrawTarget, aContextMatrix,
|
||||
aFillOrStroke, aOpacity);
|
||||
if (pattern) {
|
||||
aTargetPaint.SetPaintServer(aFrame, aContextMatrix, ps);
|
||||
return;
|
||||
|
@ -5611,10 +5619,12 @@ SetupInheritablePaint(const gfxMatrix& aContextMatrix,
|
|||
nsRefPtr<gfxPattern> pattern;
|
||||
switch ((style->*aFillOrStroke).mType) {
|
||||
case eStyleSVGPaintType_ContextFill:
|
||||
pattern = aOuterContextPaint->GetFillPattern(aOpacity, aContextMatrix);
|
||||
pattern = aOuterContextPaint->GetFillPattern(aDrawTarget, aOpacity,
|
||||
aContextMatrix);
|
||||
break;
|
||||
case eStyleSVGPaintType_ContextStroke:
|
||||
pattern = aOuterContextPaint->GetStrokePattern(aOpacity, aContextMatrix);
|
||||
pattern = aOuterContextPaint->GetStrokePattern(aDrawTarget, aOpacity,
|
||||
aContextMatrix);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
|
@ -5630,7 +5640,8 @@ SetupInheritablePaint(const gfxMatrix& aContextMatrix,
|
|||
}
|
||||
|
||||
DrawMode
|
||||
SVGTextFrame::SetupContextPaint(const gfxMatrix& aContextMatrix,
|
||||
SVGTextFrame::SetupContextPaint(const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
nsIFrame* aFrame,
|
||||
gfxTextContextPaint* aOuterContextPaint,
|
||||
SVGTextContextPaint* aThisContextPaint)
|
||||
|
@ -5647,7 +5658,8 @@ SVGTextFrame::SetupContextPaint(const gfxMatrix& aContextMatrix,
|
|||
style->mFillOpacity,
|
||||
aOuterContextPaint);
|
||||
|
||||
SetupInheritablePaint(aContextMatrix, aFrame, opacity, aOuterContextPaint,
|
||||
SetupInheritablePaint(aDrawTarget, aContextMatrix, aFrame,
|
||||
opacity, aOuterContextPaint,
|
||||
aThisContextPaint->mFillPaint, &nsStyleSVG::mFill,
|
||||
nsSVGEffects::FillProperty());
|
||||
|
||||
|
@ -5664,7 +5676,8 @@ SVGTextFrame::SetupContextPaint(const gfxMatrix& aContextMatrix,
|
|||
style->mStrokeOpacity,
|
||||
aOuterContextPaint);
|
||||
|
||||
SetupInheritablePaint(aContextMatrix, aFrame, opacity, aOuterContextPaint,
|
||||
SetupInheritablePaint(aDrawTarget, aContextMatrix, aFrame,
|
||||
opacity, aOuterContextPaint,
|
||||
aThisContextPaint->mStrokePaint, &nsStyleSVG::mStroke,
|
||||
nsSVGEffects::StrokeProperty());
|
||||
|
||||
|
|
|
@ -139,9 +139,14 @@ private:
|
|||
|
||||
// Slightly horrible callback for deferring application of opacity
|
||||
struct SVGTextContextPaint : public gfxTextContextPaint {
|
||||
already_AddRefed<gfxPattern> GetFillPattern(float aOpacity,
|
||||
protected:
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
public:
|
||||
already_AddRefed<gfxPattern> GetFillPattern(const DrawTarget* aDrawTarget,
|
||||
float aOpacity,
|
||||
const gfxMatrix& aCTM) MOZ_OVERRIDE;
|
||||
already_AddRefed<gfxPattern> GetStrokePattern(float aOpacity,
|
||||
already_AddRefed<gfxPattern> GetStrokePattern(const DrawTarget* aDrawTarget,
|
||||
float aOpacity,
|
||||
const gfxMatrix& aCTM) MOZ_OVERRIDE;
|
||||
|
||||
void SetFillOpacity(float aOpacity) { mFillOpacity = aOpacity; }
|
||||
|
@ -190,7 +195,8 @@ struct SVGTextContextPaint : public gfxTextContextPaint {
|
|||
gfxMatrix mPatternMatrix;
|
||||
nsRefPtrHashtable<nsFloatHashKey, gfxPattern> mPatternCache;
|
||||
|
||||
already_AddRefed<gfxPattern> GetPattern(float aOpacity,
|
||||
already_AddRefed<gfxPattern> GetPattern(const DrawTarget* aDrawTarget,
|
||||
float aOpacity,
|
||||
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
||||
const gfxMatrix& aCTM);
|
||||
};
|
||||
|
@ -252,6 +258,7 @@ class SVGTextFrame MOZ_FINAL : public SVGTextFrameBase
|
|||
friend class MutationObserver;
|
||||
friend class nsDisplaySVGText;
|
||||
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
typedef mozilla::gfx::Path Path;
|
||||
typedef mozilla::gfx::Point Point;
|
||||
typedef mozilla::SVGTextContextPaint SVGTextContextPaint;
|
||||
|
@ -594,7 +601,8 @@ private:
|
|||
gfxFloat GetOffsetScale(nsIFrame* aTextPathFrame);
|
||||
gfxFloat GetStartOffset(nsIFrame* aTextPathFrame);
|
||||
|
||||
DrawMode SetupContextPaint(const gfxMatrix& aContextMatrix,
|
||||
DrawMode SetupContextPaint(const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
nsIFrame* aFrame,
|
||||
gfxTextContextPaint* aOuterContextPaint,
|
||||
SVGTextContextPaint* aThisContextPaint);
|
||||
|
|
|
@ -209,11 +209,12 @@ static void GetStopInformation(nsIFrame* aStopFrame,
|
|||
}
|
||||
|
||||
already_AddRefed<gfxPattern>
|
||||
nsSVGGradientFrame::GetPaintServerPattern(nsIFrame *aSource,
|
||||
nsSVGGradientFrame::GetPaintServerPattern(nsIFrame* aSource,
|
||||
const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
||||
float aGraphicOpacity,
|
||||
const gfxRect *aOverrideBounds)
|
||||
const gfxRect* aOverrideBounds)
|
||||
{
|
||||
uint16_t gradientUnits = GetGradientUnits();
|
||||
MOZ_ASSERT(gradientUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX ||
|
||||
|
|
|
@ -47,11 +47,12 @@ public:
|
|||
|
||||
// nsSVGPaintServerFrame methods:
|
||||
virtual already_AddRefed<gfxPattern>
|
||||
GetPaintServerPattern(nsIFrame *aSource,
|
||||
GetPaintServerPattern(nsIFrame* aSource,
|
||||
const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
||||
float aGraphicOpacity,
|
||||
const gfxRect *aOverrideBounds) MOZ_OVERRIDE;
|
||||
const gfxRect* aOverrideBounds) MOZ_OVERRIDE;
|
||||
|
||||
// nsIFrame interface:
|
||||
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
||||
|
|
|
@ -695,6 +695,7 @@ nsSVGIntegrationUtils::DrawableFromPaintServer(nsIFrame* aFrame,
|
|||
nsIFrame* aTarget,
|
||||
const nsSize& aPaintServerSize,
|
||||
const gfxIntSize& aRenderSize,
|
||||
const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
|
@ -715,8 +716,9 @@ nsSVGIntegrationUtils::DrawableFromPaintServer(nsIFrame* aFrame,
|
|||
aPaintServerSize.width, aPaintServerSize.height);
|
||||
overrideBounds.ScaleInverse(aFrame->PresContext()->AppUnitsPerDevPixel());
|
||||
nsRefPtr<gfxPattern> pattern =
|
||||
server->GetPaintServerPattern(aTarget, aContextMatrix,
|
||||
&nsStyleSVG::mFill, 1.0, &overrideBounds);
|
||||
server->GetPaintServerPattern(aTarget, aDrawTarget,
|
||||
aContextMatrix, &nsStyleSVG::mFill, 1.0,
|
||||
&overrideBounds);
|
||||
|
||||
if (!pattern)
|
||||
return nullptr;
|
||||
|
|
|
@ -22,6 +22,9 @@ struct nsRect;
|
|||
struct nsIntRect;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class DrawTarget;
|
||||
}
|
||||
namespace layers {
|
||||
class LayerManager;
|
||||
}
|
||||
|
@ -36,6 +39,8 @@ struct nsSize;
|
|||
*/
|
||||
class nsSVGIntegrationUtils MOZ_FINAL
|
||||
{
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Returns true if SVG effects are currently applied to this frame.
|
||||
|
@ -166,6 +171,7 @@ public:
|
|||
nsIFrame* aTarget,
|
||||
const nsSize& aPaintServerSize,
|
||||
const gfxIntSize& aRenderSize,
|
||||
const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
uint32_t aFlags);
|
||||
};
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
#include "nsSVGContainerFrame.h"
|
||||
#include "nsSVGUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class DrawTarget;
|
||||
}
|
||||
}
|
||||
|
||||
class gfxContext;
|
||||
class gfxPattern;
|
||||
class nsStyleContext;
|
||||
|
@ -25,6 +31,8 @@ typedef nsSVGContainerFrame nsSVGPaintServerFrameBase;
|
|||
class nsSVGPaintServerFrame : public nsSVGPaintServerFrameBase
|
||||
{
|
||||
protected:
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
|
||||
explicit nsSVGPaintServerFrame(nsStyleContext* aContext)
|
||||
: nsSVGPaintServerFrameBase(aContext)
|
||||
{
|
||||
|
@ -44,6 +52,7 @@ public:
|
|||
*/
|
||||
virtual already_AddRefed<gfxPattern>
|
||||
GetPaintServerPattern(nsIFrame *aSource,
|
||||
const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
||||
float aOpacity,
|
||||
|
|
|
@ -231,7 +231,8 @@ GetTargetGeometry(gfxRect *aBBox,
|
|||
}
|
||||
|
||||
TemporaryRef<SourceSurface>
|
||||
nsSVGPatternFrame::PaintPattern(Matrix* patternMatrix,
|
||||
nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
|
||||
Matrix* patternMatrix,
|
||||
const Matrix &aContextMatrix,
|
||||
nsIFrame *aSource,
|
||||
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
||||
|
@ -373,8 +374,7 @@ nsSVGPatternFrame::PaintPattern(Matrix* patternMatrix,
|
|||
}
|
||||
|
||||
RefPtr<DrawTarget> dt =
|
||||
gfxPlatform::GetPlatform()->
|
||||
CreateOffscreenContentDrawTarget(surfaceSize, SurfaceFormat::B8G8R8A8);
|
||||
aDrawTarget->CreateSimilarDrawTarget(surfaceSize, SurfaceFormat::B8G8R8A8);
|
||||
if (!dt) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -707,6 +707,7 @@ nsSVGPatternFrame::ConstructCTM(const nsSVGViewBox& aViewBox,
|
|||
|
||||
already_AddRefed<gfxPattern>
|
||||
nsSVGPatternFrame::GetPaintServerPattern(nsIFrame *aSource,
|
||||
const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
||||
float aGraphicOpacity,
|
||||
|
@ -720,8 +721,8 @@ nsSVGPatternFrame::GetPaintServerPattern(nsIFrame *aSource,
|
|||
// Paint it!
|
||||
Matrix pMatrix;
|
||||
RefPtr<SourceSurface> surface =
|
||||
PaintPattern(&pMatrix, ToMatrix(aContextMatrix), aSource, aFillOrStroke,
|
||||
aGraphicOpacity, aOverrideBounds);
|
||||
PaintPattern(aDrawTarget, &pMatrix, ToMatrix(aContextMatrix), aSource,
|
||||
aFillOrStroke, aGraphicOpacity, aOverrideBounds);
|
||||
|
||||
if (!surface) {
|
||||
return nullptr;
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
// nsSVGPaintServerFrame methods:
|
||||
virtual already_AddRefed<gfxPattern>
|
||||
GetPaintServerPattern(nsIFrame *aSource,
|
||||
const DrawTarget* aDrawTarget,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
||||
float aOpacity,
|
||||
|
@ -112,7 +113,8 @@ protected:
|
|||
}
|
||||
|
||||
mozilla::TemporaryRef<SourceSurface>
|
||||
PaintPattern(Matrix *patternMatrix,
|
||||
PaintPattern(const DrawTarget* aDrawTarget,
|
||||
Matrix *patternMatrix,
|
||||
const Matrix &aContextMatrix,
|
||||
nsIFrame *aSource,
|
||||
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
||||
|
|
|
@ -1257,16 +1257,18 @@ nsSVGUtils::MakeFillPatternFor(nsIFrame *aFrame,
|
|||
GetOpacity(style->mFillOpacitySource,
|
||||
style->mFillOpacity,
|
||||
aContextPaint));
|
||||
const DrawTarget* dt = aContext->GetDrawTarget();
|
||||
|
||||
nsRefPtr<gfxPattern> pattern;
|
||||
|
||||
nsSVGPaintServerFrame *ps =
|
||||
nsSVGEffects::GetPaintServer(aFrame, &style->mFill,
|
||||
nsSVGEffects::FillProperty());
|
||||
if (ps) {
|
||||
pattern = ps->GetPaintServerPattern(aFrame, aContext->CurrentMatrix(),
|
||||
pattern = ps->GetPaintServerPattern(aFrame, dt, aContext->CurrentMatrix(),
|
||||
&nsStyleSVG::mFill, opacity);
|
||||
if (pattern) {
|
||||
pattern->CacheColorStops(aContext->GetDrawTarget());
|
||||
pattern->CacheColorStops(dt);
|
||||
return pattern.forget();
|
||||
}
|
||||
}
|
||||
|
@ -1274,10 +1276,12 @@ nsSVGUtils::MakeFillPatternFor(nsIFrame *aFrame,
|
|||
if (aContextPaint) {
|
||||
switch (style->mFill.mType) {
|
||||
case eStyleSVGPaintType_ContextFill:
|
||||
pattern = aContextPaint->GetFillPattern(opacity, aContext->CurrentMatrix());
|
||||
pattern = aContextPaint->GetFillPattern(dt, opacity,
|
||||
aContext->CurrentMatrix());
|
||||
break;
|
||||
case eStyleSVGPaintType_ContextStroke:
|
||||
pattern = aContextPaint->GetStrokePattern(opacity, aContext->CurrentMatrix());
|
||||
pattern = aContextPaint->GetStrokePattern(dt, opacity,
|
||||
aContext->CurrentMatrix());
|
||||
break;
|
||||
default:
|
||||
;
|
||||
|
@ -1313,16 +1317,19 @@ nsSVGUtils::MakeStrokePatternFor(nsIFrame *aFrame,
|
|||
GetOpacity(style->mStrokeOpacitySource,
|
||||
style->mStrokeOpacity,
|
||||
aContextPaint));
|
||||
|
||||
const DrawTarget* dt = aContext->GetDrawTarget();
|
||||
|
||||
nsRefPtr<gfxPattern> pattern;
|
||||
|
||||
nsSVGPaintServerFrame *ps =
|
||||
nsSVGEffects::GetPaintServer(aFrame, &style->mStroke,
|
||||
nsSVGEffects::StrokeProperty());
|
||||
if (ps) {
|
||||
pattern = ps->GetPaintServerPattern(aFrame, aContext->CurrentMatrix(),
|
||||
pattern = ps->GetPaintServerPattern(aFrame, dt, aContext->CurrentMatrix(),
|
||||
&nsStyleSVG::mStroke, opacity);
|
||||
if (pattern) {
|
||||
pattern->CacheColorStops(aContext->GetDrawTarget());
|
||||
pattern->CacheColorStops(dt);
|
||||
return pattern.forget();
|
||||
}
|
||||
}
|
||||
|
@ -1330,10 +1337,12 @@ nsSVGUtils::MakeStrokePatternFor(nsIFrame *aFrame,
|
|||
if (aContextPaint) {
|
||||
switch (style->mStroke.mType) {
|
||||
case eStyleSVGPaintType_ContextFill:
|
||||
pattern = aContextPaint->GetFillPattern(opacity, aContext->CurrentMatrix());
|
||||
pattern = aContextPaint->GetFillPattern(dt, opacity,
|
||||
aContext->CurrentMatrix());
|
||||
break;
|
||||
case eStyleSVGPaintType_ContextStroke:
|
||||
pattern = aContextPaint->GetStrokePattern(opacity, aContext->CurrentMatrix());
|
||||
pattern = aContextPaint->GetStrokePattern(dt, opacity,
|
||||
aContext->CurrentMatrix());
|
||||
break;
|
||||
default:
|
||||
;
|
||||
|
|
Загрузка…
Ссылка в новой задаче