mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1034528
, part 3 - Remove the Thebes backed gfxContext propagating code from nsFilterInstance. r=Bas
This commit is contained in:
parent
19e2f4f417
commit
52f08fab55
@ -298,30 +298,18 @@ nsFilterInstance::ComputeNeededBoxes()
|
||||
|
||||
nsresult
|
||||
nsFilterInstance::BuildSourcePaint(SourceInfo *aSource,
|
||||
gfxASurface* aTargetSurface,
|
||||
DrawTarget* aTargetDT)
|
||||
{
|
||||
nsIntRect neededRect = aSource->mNeededBounds;
|
||||
|
||||
RefPtr<DrawTarget> offscreenDT;
|
||||
nsRefPtr<gfxASurface> offscreenSurface;
|
||||
nsRefPtr<gfxContext> ctx;
|
||||
if (aTargetSurface) {
|
||||
offscreenSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(
|
||||
neededRect.Size().ToIntSize(), gfxContentType::COLOR_ALPHA);
|
||||
if (!offscreenSurface || offscreenSurface->CairoStatus()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
ctx = new gfxContext(offscreenSurface);
|
||||
} else {
|
||||
offscreenDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
|
||||
RefPtr<DrawTarget> offscreenDT =
|
||||
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
|
||||
ToIntSize(neededRect.Size()), SurfaceFormat::B8G8R8A8);
|
||||
if (!offscreenDT) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
ctx = new gfxContext(offscreenDT);
|
||||
if (!offscreenDT) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(offscreenDT);
|
||||
ctx->Translate(-neededRect.TopLeft());
|
||||
|
||||
nsRefPtr<nsRenderingContext> tmpCtx(new nsRenderingContext());
|
||||
@ -348,63 +336,46 @@ nsFilterInstance::BuildSourcePaint(SourceInfo *aSource,
|
||||
}
|
||||
gfx->Restore();
|
||||
|
||||
if (offscreenSurface) {
|
||||
aSource->mSourceSurface =
|
||||
gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(aTargetDT, offscreenSurface);
|
||||
} else {
|
||||
aSource->mSourceSurface = offscreenDT->Snapshot();
|
||||
}
|
||||
|
||||
aSource->mSourceSurface = offscreenDT->Snapshot();
|
||||
aSource->mSurfaceRect = ToIntRect(neededRect);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFilterInstance::BuildSourcePaints(gfxASurface* aTargetSurface,
|
||||
DrawTarget* aTargetDT)
|
||||
nsFilterInstance::BuildSourcePaints(DrawTarget* aTargetDT)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mFillPaint.mNeededBounds.IsEmpty()) {
|
||||
rv = BuildSourcePaint(&mFillPaint, aTargetSurface, aTargetDT);
|
||||
rv = BuildSourcePaint(&mFillPaint, aTargetDT);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!mStrokePaint.mNeededBounds.IsEmpty()) {
|
||||
rv = BuildSourcePaint(&mStrokePaint, aTargetSurface, aTargetDT);
|
||||
rv = BuildSourcePaint(&mStrokePaint, aTargetDT);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFilterInstance::BuildSourceImage(gfxASurface* aTargetSurface,
|
||||
DrawTarget* aTargetDT)
|
||||
nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT)
|
||||
{
|
||||
nsIntRect neededRect = mSourceGraphic.mNeededBounds;
|
||||
if (neededRect.IsEmpty()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> offscreenDT;
|
||||
nsRefPtr<gfxASurface> offscreenSurface;
|
||||
nsRefPtr<gfxContext> ctx;
|
||||
if (aTargetSurface) {
|
||||
offscreenSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(
|
||||
neededRect.Size().ToIntSize(), gfxContentType::COLOR_ALPHA);
|
||||
if (!offscreenSurface || offscreenSurface->CairoStatus()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
ctx = new gfxContext(offscreenSurface);
|
||||
} else {
|
||||
offscreenDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
|
||||
RefPtr<DrawTarget> offscreenDT =
|
||||
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
|
||||
ToIntSize(neededRect.Size()), SurfaceFormat::B8G8R8A8);
|
||||
if (!offscreenDT) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
ctx = new gfxContext(offscreenDT);
|
||||
if (!offscreenDT) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(offscreenDT);
|
||||
ctx->Translate(-neededRect.TopLeft());
|
||||
|
||||
nsRefPtr<nsRenderingContext> tmpCtx(new nsRenderingContext());
|
||||
@ -431,16 +402,7 @@ nsFilterInstance::BuildSourceImage(gfxASurface* aTargetSurface,
|
||||
tmpCtx->ThebesContext()->Multiply(deviceToFilterSpace);
|
||||
mPaintCallback->Paint(tmpCtx, mTargetFrame, &dirty, mTransformRoot);
|
||||
|
||||
RefPtr<SourceSurface> sourceGraphicSource;
|
||||
|
||||
if (offscreenSurface) {
|
||||
sourceGraphicSource =
|
||||
gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(aTargetDT, offscreenSurface);
|
||||
} else {
|
||||
sourceGraphicSource = offscreenDT->Snapshot();
|
||||
}
|
||||
|
||||
mSourceGraphic.mSourceSurface = sourceGraphicSource;
|
||||
mSourceGraphic.mSourceSurface = offscreenDT->Snapshot();
|
||||
mSourceGraphic.mSurfaceRect = ToIntRect(neededRect);
|
||||
|
||||
return NS_OK;
|
||||
@ -457,34 +419,18 @@ nsFilterInstance::Render(gfxContext* aContext)
|
||||
}
|
||||
|
||||
Matrix oldDTMatrix;
|
||||
nsRefPtr<gfxASurface> resultImage;
|
||||
RefPtr<DrawTarget> dt;
|
||||
if (aContext->IsCairo()) {
|
||||
resultImage =
|
||||
gfxPlatform::GetPlatform()->CreateOffscreenSurface(filterRect.Size().ToIntSize(),
|
||||
gfxContentType::COLOR_ALPHA);
|
||||
if (!resultImage || resultImage->CairoStatus())
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// Create a Cairo DrawTarget around resultImage.
|
||||
dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(
|
||||
resultImage, ToIntSize(filterRect.Size()));
|
||||
} else {
|
||||
// When we have a DrawTarget-backed context, we can call DrawFilter
|
||||
// directly on the target DrawTarget and don't need a temporary DT.
|
||||
dt = aContext->GetDrawTarget();
|
||||
oldDTMatrix = dt->GetTransform();
|
||||
Matrix matrix = ToMatrix(ctm);
|
||||
matrix.Translate(filterRect.x, filterRect.y);
|
||||
dt->SetTransform(matrix * oldDTMatrix);
|
||||
}
|
||||
RefPtr<DrawTarget> dt = aContext->GetDrawTarget();
|
||||
oldDTMatrix = dt->GetTransform();
|
||||
Matrix matrix = ToMatrix(ctm);
|
||||
matrix.Translate(filterRect.x, filterRect.y);
|
||||
dt->SetTransform(matrix * oldDTMatrix);
|
||||
|
||||
ComputeNeededBoxes();
|
||||
|
||||
nsresult rv = BuildSourceImage(resultImage, dt);
|
||||
nsresult rv = BuildSourceImage(dt);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = BuildSourcePaints(resultImage, dt);
|
||||
rv = BuildSourcePaints(dt);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -498,16 +444,7 @@ nsFilterInstance::Render(gfxContext* aContext)
|
||||
mStrokePaint.mSourceSurface, mStrokePaint.mSurfaceRect,
|
||||
mInputImages);
|
||||
|
||||
if (resultImage) {
|
||||
aContext->Save();
|
||||
aContext->Multiply(ctm);
|
||||
aContext->Translate(filterRect.TopLeft());
|
||||
aContext->SetSource(resultImage);
|
||||
aContext->Paint();
|
||||
aContext->Restore();
|
||||
} else {
|
||||
dt->SetTransform(oldDTMatrix);
|
||||
}
|
||||
dt->SetTransform(oldDTMatrix);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -183,7 +183,6 @@ private:
|
||||
* nodes
|
||||
*/
|
||||
nsresult BuildSourcePaint(SourceInfo *aPrimitive,
|
||||
gfxASurface* aTargetSurface,
|
||||
DrawTarget* aTargetDT);
|
||||
|
||||
/**
|
||||
@ -191,15 +190,13 @@ private:
|
||||
* nodes, fills its contents and assigns it to mFillPaint.mSourceSurface and
|
||||
* mStrokePaint.mSourceSurface respectively.
|
||||
*/
|
||||
nsresult BuildSourcePaints(gfxASurface* aTargetSurface,
|
||||
DrawTarget* aTargetDT);
|
||||
nsresult BuildSourcePaints(DrawTarget* aTargetDT);
|
||||
|
||||
/**
|
||||
* Creates the SourceSurface for the SourceGraphic graph node, paints its
|
||||
* contents, and assigns it to mSourceGraphic.mSourceSurface.
|
||||
*/
|
||||
nsresult BuildSourceImage(gfxASurface* aTargetSurface,
|
||||
DrawTarget* aTargetDT);
|
||||
nsresult BuildSourceImage(DrawTarget* aTargetDT);
|
||||
|
||||
/**
|
||||
* Build the list of FilterPrimitiveDescriptions that describes the filter's
|
||||
|
Loading…
Reference in New Issue
Block a user