Bug 1231303 - Moz2Dify nsFilterInstance. r=roc.

This commit is contained in:
Nicholas Nethercote 2015-12-13 14:02:34 -08:00
parent d3527e598c
commit 8da5bffaea
4 changed files with 20 additions and 18 deletions

View File

@ -58,7 +58,7 @@ UserSpaceMetricsForFrame(nsIFrame* aFrame)
nsresult
nsFilterInstance::PaintFilteredFrame(nsIFrame *aFilteredFrame,
gfxContext& aContext,
DrawTarget* aDrawTarget,
const gfxMatrix& aTransform,
nsSVGFilterPaintCallback *aPaintCallback,
const nsRegion *aDirtyArea)
@ -71,7 +71,7 @@ nsFilterInstance::PaintFilteredFrame(nsIFrame *aFilteredFrame,
if (!instance.IsInitialized()) {
return NS_OK;
}
return instance.Render(&aContext);
return instance.Render(aDrawTarget);
}
nsRegion
@ -457,34 +457,34 @@ nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT)
}
nsresult
nsFilterInstance::Render(gfxContext* aContext)
nsFilterInstance::Render(DrawTarget* aDrawTarget)
{
MOZ_ASSERT(mTargetFrame, "Need a frame for rendering");
nsIntRect filterRect = mPostFilterDirtyRegion.GetBounds().Intersect(OutputFilterSpaceBounds());
nsIntRect filterRect =
mPostFilterDirtyRegion.GetBounds().Intersect(OutputFilterSpaceBounds());
gfxMatrix ctm = GetFilterSpaceToDeviceSpaceTransform();
if (filterRect.IsEmpty() || ctm.IsSingular()) {
return NS_OK;
}
RefPtr<DrawTarget> dt = aContext->GetDrawTarget();
AutoRestoreTransform autoRestoreTransform(dt);
Matrix newTM = ToMatrix(ctm).PreTranslate(filterRect.x, filterRect.y) * dt->GetTransform();
dt->SetTransform(newTM);
AutoRestoreTransform autoRestoreTransform(aDrawTarget);
Matrix newTM = ToMatrix(ctm).PreTranslate(filterRect.x, filterRect.y) *
aDrawTarget->GetTransform();
aDrawTarget->SetTransform(newTM);
ComputeNeededBoxes();
nsresult rv = BuildSourceImage(dt);
nsresult rv = BuildSourceImage(aDrawTarget);
if (NS_FAILED(rv))
return rv;
rv = BuildSourcePaints(dt);
rv = BuildSourcePaints(aDrawTarget);
if (NS_FAILED(rv))
return rv;
FilterSupport::RenderFilterDescription(
dt, mFilterDescription, IntRectToRect(filterRect),
aDrawTarget, mFilterDescription, IntRectToRect(filterRect),
mSourceGraphic.mSourceSurface, mSourceGraphic.mSurfaceRect,
mFillPaint.mSourceSurface, mFillPaint.mSurfaceRect,
mStrokePaint.mSourceSurface, mStrokePaint.mSurfaceRect,

View File

@ -77,7 +77,7 @@ public:
* border box).
*/
static nsresult PaintFilteredFrame(nsIFrame *aFilteredFrame,
gfxContext& aContext,
DrawTarget* aDrawTarget,
const gfxMatrix& aTransform,
nsSVGFilterPaintCallback *aPaintCallback,
const nsRegion* aDirtyArea);
@ -150,12 +150,12 @@ public:
bool IsInitialized() const { return mInitialized; }
/**
* Draws the filter output into aContext. The area that
* Draws the filter output into aDrawTarget. The area that
* needs to be painted must have been specified before calling this method
* by passing it as the aPostFilterDirtyRegion argument to the
* nsFilterInstance constructor.
*/
nsresult Render(gfxContext* aContext);
nsresult Render(DrawTarget* aDrawTarget);
const FilterDescription& ExtractDescriptionAndAdditionalImages(nsTArray<RefPtr<SourceSurface>>& aOutAdditionalImages)
{

View File

@ -590,7 +590,8 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(gfxContext& aContext,
nsRegion dirtyRegion = aDirtyRect - offsetToBoundingBox;
gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(aFrame);
nsFilterInstance::PaintFilteredFrame(aFrame, *target, tm, &callback, &dirtyRegion);
nsFilterInstance::PaintFilteredFrame(aFrame, target->GetDrawTarget(),
tm, &callback, &dirtyRegion);
} else {
target->SetMatrix(matrixAutoSaveRestore.Matrix());
BasicLayerManager* basic = static_cast<BasicLayerManager*>(aLayerManager);

View File

@ -690,8 +690,9 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
dirtyRegion = &tmpDirtyRegion;
}
SVGPaintCallback paintCallback;
nsFilterInstance::PaintFilteredFrame(aFrame, *target, aTransform,
&paintCallback, dirtyRegion);
nsFilterInstance::PaintFilteredFrame(aFrame, target->GetDrawTarget(),
aTransform, &paintCallback,
dirtyRegion);
} else {
svgChildFrame->PaintSVG(*target, aTransform, aDirtyRect);
}