forked from mirrors/gecko-dev
Bug 1815404 - Replace most uses of gfxContext::CreateOrNull with stack-allocated contexts. r=gfx-reviewers,lsalzman
Depends on D170370 Differential Revision: https://phabricator.services.mozilla.com/D170371
This commit is contained in:
parent
5b9588f1aa
commit
4594ae314a
27 changed files with 150 additions and 151 deletions
|
|
@ -4995,7 +4995,7 @@ void CanvasRenderingContext2D::DrawDirectlyToCanvas(
|
|||
"Need positive source width and height");
|
||||
|
||||
AdjustedTarget tempTarget(this, aBounds->IsEmpty() ? nullptr : aBounds);
|
||||
if (!tempTarget) {
|
||||
if (!tempTarget || !tempTarget->IsValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -5021,17 +5021,13 @@ void CanvasRenderingContext2D::DrawDirectlyToCanvas(
|
|||
// the matrix even though this is a temp gfxContext.
|
||||
AutoRestoreTransform autoRestoreTransform(mTarget);
|
||||
|
||||
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(tempTarget);
|
||||
if (!context) {
|
||||
gfxDevCrash(LogReason::InvalidContext) << "Canvas context problem";
|
||||
return;
|
||||
}
|
||||
context->SetMatrixDouble(
|
||||
gfxContext context(tempTarget);
|
||||
context.SetMatrixDouble(
|
||||
contextMatrix
|
||||
.PreScale(1.0 / contextScale.xScale, 1.0 / contextScale.yScale)
|
||||
.PreTranslate(aDest.x - aSrc.x, aDest.y - aSrc.y));
|
||||
|
||||
context->SetOp(tempTarget.UsedOperation());
|
||||
context.SetOp(tempTarget.UsedOperation());
|
||||
|
||||
// FLAG_CLAMP is added for increased performance, since we never tile here.
|
||||
uint32_t modifiedFlags = aImage.mDrawingFlags | imgIContainer::FLAG_CLAMP;
|
||||
|
|
@ -5041,7 +5037,7 @@ void CanvasRenderingContext2D::DrawDirectlyToCanvas(
|
|||
SVGImageContext svgContext(Some(sz));
|
||||
|
||||
auto result = aImage.mImgContainer->Draw(
|
||||
context.get(), scaledImageSize,
|
||||
&context, scaledImageSize,
|
||||
ImageRegion::Create(gfxRect(aSrc.x, aSrc.y, aSrc.width, aSrc.height)),
|
||||
aImage.mWhichFrame, SamplingFilter::GOOD, svgContext, modifiedFlags,
|
||||
CurrentState().globalAlpha);
|
||||
|
|
@ -5219,7 +5215,7 @@ void CanvasRenderingContext2D::DrawWindow(nsGlobalWindowInner& aWindow,
|
|||
return;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> thebes;
|
||||
Maybe<gfxContext> thebes;
|
||||
RefPtr<DrawTarget> drawDT;
|
||||
// Rendering directly is faster and can be done if mTarget supports Azure
|
||||
// and does not need alpha blending.
|
||||
|
|
@ -5237,10 +5233,8 @@ void CanvasRenderingContext2D::DrawWindow(nsGlobalWindowInner& aWindow,
|
|||
}
|
||||
if (op == CompositionOp::OP_OVER &&
|
||||
(!mBufferProvider || !mBufferProvider->IsShared())) {
|
||||
thebes = gfxContext::CreateOrNull(mTarget);
|
||||
MOZ_ASSERT(thebes); // already checked the draw target above
|
||||
// (in SupportsAzureContentForDrawTarget)
|
||||
thebes->SetMatrix(matrix);
|
||||
thebes.emplace(mTarget);
|
||||
thebes.ref().SetMatrix(matrix);
|
||||
} else {
|
||||
IntSize dtSize = IntSize::Ceil(sw, sh);
|
||||
if (!Factory::AllowedSurfaceSize(dtSize)) {
|
||||
|
|
@ -5261,15 +5255,15 @@ void CanvasRenderingContext2D::DrawWindow(nsGlobalWindowInner& aWindow,
|
|||
return;
|
||||
}
|
||||
|
||||
thebes = gfxContext::CreateOrNull(drawDT);
|
||||
MOZ_ASSERT(thebes); // alrady checked the draw target above
|
||||
thebes->SetMatrix(Matrix::Scaling(matrix._11, matrix._22));
|
||||
thebes.emplace(drawDT);
|
||||
thebes.ref().SetMatrix(Matrix::Scaling(matrix._11, matrix._22));
|
||||
}
|
||||
MOZ_ASSERT(thebes.isSome());
|
||||
|
||||
RefPtr<PresShell> presShell = presContext->PresShell();
|
||||
|
||||
Unused << presShell->RenderDocument(r, renderDocFlags, backgroundColor,
|
||||
thebes.get());
|
||||
&thebes.ref());
|
||||
// If this canvas was contained in the drawn window, the pre-transaction
|
||||
// callback may have returned its DT. If so, we must reacquire it here.
|
||||
EnsureTarget(discardContent ? &drawRect : nullptr);
|
||||
|
|
|
|||
|
|
@ -118,6 +118,10 @@ PaintFragment PaintFragment::Record(dom::BrowsingContext* aBc,
|
|||
RefPtr<DrawTarget> dt = Factory::CreateRecordingDrawTarget(
|
||||
recorder, referenceDt,
|
||||
IntRect(IntPoint(0, 0), surfaceSize.ToUnknownSize()));
|
||||
if (!dt || !dt->IsValid()) {
|
||||
PF_LOG("Failed to create drawTarget.\n");
|
||||
return PaintFragment{};
|
||||
}
|
||||
|
||||
RenderDocumentFlags renderDocFlags = RenderDocumentFlags::None;
|
||||
if (!(aFlags & CrossProcessPaintFlags::DrawView)) {
|
||||
|
|
@ -140,12 +144,12 @@ PaintFragment PaintFragment::Record(dom::BrowsingContext* aBc,
|
|||
dt->AddUserData(&sDisablePixelSnapping, (void*)0x1, nullptr);
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> thebes = gfxContext::CreateOrNull(dt);
|
||||
thebes->SetMatrix(Matrix::Scaling(aScale, aScale));
|
||||
thebes->SetCrossProcessPaintScale(aScale);
|
||||
gfxContext thebes(dt);
|
||||
thebes.SetMatrix(Matrix::Scaling(aScale, aScale));
|
||||
thebes.SetCrossProcessPaintScale(aScale);
|
||||
RefPtr<PresShell> presShell = presContext->PresShell();
|
||||
Unused << presShell->RenderDocument(r, renderDocFlags, aBackgroundColor,
|
||||
thebes.get());
|
||||
&thebes);
|
||||
}
|
||||
|
||||
if (!recorder->mOutputStream.mValid) {
|
||||
|
|
|
|||
|
|
@ -656,10 +656,14 @@ struct DIGroup {
|
|||
|
||||
RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateRecordingDrawTarget(
|
||||
recorder, dummyDt, mLayerBounds.ToUnknownRect());
|
||||
// Setup the gfxContext
|
||||
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
context->SetMatrix(Matrix::Scaling(mScale).PostTranslate(
|
||||
mResidualOffset.x, mResidualOffset.y));
|
||||
if (!dt || !dt->IsValid()) {
|
||||
gfxCriticalNote << "Failed to create drawTarget for blob image";
|
||||
return;
|
||||
}
|
||||
|
||||
gfxContext context(dt);
|
||||
context.SetMatrix(Matrix::Scaling(mScale).PostTranslate(mResidualOffset.x,
|
||||
mResidualOffset.y));
|
||||
|
||||
GP("mInvalidRect: %d %d %d %d\n", mInvalidRect.x, mInvalidRect.y,
|
||||
mInvalidRect.width, mInvalidRect.height);
|
||||
|
|
@ -673,7 +677,7 @@ struct DIGroup {
|
|||
return;
|
||||
}
|
||||
|
||||
PaintItemRange(aGrouper, aStartItem, aEndItem, context.get(), recorder,
|
||||
PaintItemRange(aGrouper, aStartItem, aEndItem, &context, recorder,
|
||||
rootManager, aResources);
|
||||
|
||||
// XXX: set this correctly perhaps using
|
||||
|
|
@ -2291,12 +2295,11 @@ static void PaintItemByDrawTarget(nsDisplayItem* aItem, gfx::DrawTarget* aDT,
|
|||
nsDisplayListBuilder* aDisplayListBuilder,
|
||||
const gfx::MatrixScales& aScale,
|
||||
Maybe<gfx::DeviceColor>& aHighlight) {
|
||||
MOZ_ASSERT(aDT);
|
||||
MOZ_ASSERT(aDT && aDT->IsValid());
|
||||
|
||||
// XXX Why is this ClearRect() needed?
|
||||
aDT->ClearRect(Rect(visibleRect));
|
||||
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(aDT);
|
||||
MOZ_ASSERT(context);
|
||||
gfxContext context(aDT);
|
||||
|
||||
switch (aItem->GetType()) {
|
||||
case DisplayItemType::TYPE_SVG_WRAPPER:
|
||||
|
|
@ -2310,12 +2313,12 @@ static void PaintItemByDrawTarget(nsDisplayItem* aItem, gfx::DrawTarget* aDT,
|
|||
break;
|
||||
}
|
||||
|
||||
context->SetMatrix(context->CurrentMatrix().PreScale(aScale).PreTranslate(
|
||||
context.SetMatrix(context.CurrentMatrix().PreScale(aScale).PreTranslate(
|
||||
-aOffset.x, -aOffset.y));
|
||||
if (aDisplayListBuilder->IsPaintingToWindow()) {
|
||||
aItem->Frame()->AddStateBits(NS_FRAME_PAINTED_THEBES);
|
||||
}
|
||||
aItem->AsPaintedDisplayItem()->Paint(aDisplayListBuilder, context.get());
|
||||
aItem->AsPaintedDisplayItem()->Paint(aDisplayListBuilder, &context);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2781,17 +2784,19 @@ Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
|
|||
BackendType::SKIA, IntSize(1, 1), SurfaceFormat::A8);
|
||||
RefPtr<DrawTarget> dt = Factory::CreateRecordingDrawTarget(
|
||||
recorder, dummyDt, IntRect(IntPoint(0, 0), size));
|
||||
if (!dt || !dt->IsValid()) {
|
||||
gfxCriticalNote << "Failed to create drawTarget for blob mask image";
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context);
|
||||
|
||||
context->SetMatrix(context->CurrentMatrix()
|
||||
.PreTranslate(-itemRect.x, -itemRect.y)
|
||||
.PreScale(scale));
|
||||
gfxContext context(dt);
|
||||
context.SetMatrix(context.CurrentMatrix()
|
||||
.PreTranslate(-itemRect.x, -itemRect.y)
|
||||
.PreScale(scale));
|
||||
|
||||
bool maskPainted = false;
|
||||
bool maskIsComplete = aMaskItem->PaintMask(
|
||||
aDisplayListBuilder, context.get(), shouldHandleOpacity, &maskPainted);
|
||||
aDisplayListBuilder, &context, shouldHandleOpacity, &maskPainted);
|
||||
if (!maskPainted) {
|
||||
return Nothing();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,8 +153,7 @@ UniquePtr<gfxContext> nsDeviceContext::CreateRenderingContextCommon(
|
|||
|
||||
dt->AddUserData(&sDisablePixelSnapping, (void*)0x1, nullptr);
|
||||
|
||||
UniquePtr<gfxContext> pContext = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(pContext); // already checked draw target above
|
||||
auto pContext = MakeUnique<gfxContext>(dt);
|
||||
|
||||
gfxMatrix transform;
|
||||
transform.PreTranslate(mPrintingTranslate);
|
||||
|
|
|
|||
|
|
@ -36,12 +36,11 @@ UniquePtr<gfxContext> gfxAlphaBoxBlur::Init(gfxContext* aDestinationCtx,
|
|||
RefPtr<DrawTarget> dt = InitDrawTarget(
|
||||
refDT, ToRect(aRect), aSpreadRadius, aBlurRadius,
|
||||
dirtyRect.ptrOr(nullptr), skipRect.ptrOr(nullptr), aUseHardwareAccel);
|
||||
if (!dt) {
|
||||
if (!dt || !dt->IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context); // already checked for target above
|
||||
auto context = MakeUnique<gfxContext>(dt);
|
||||
context->SetMatrix(Matrix::Translation(-mBlur.GetRect().TopLeft()));
|
||||
return context;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,11 +103,12 @@ already_AddRefed<gfxSurfaceDrawable> gfxCallbackDrawable::MakeSurfaceDrawable(
|
|||
RefPtr<DrawTarget> dt =
|
||||
aContext->GetDrawTarget()->CreateSimilarDrawTarget(mSize, format);
|
||||
|
||||
if (!dt || !dt->IsValid()) return nullptr;
|
||||
if (!dt || !dt->IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(ctx); // already checked for target above
|
||||
Draw(ctx.get(), gfxRect(0, 0, mSize.width, mSize.height), ExtendMode::CLAMP,
|
||||
gfxContext ctx(dt);
|
||||
Draw(&ctx, gfxRect(0, 0, mSize.width, mSize.height), ExtendMode::CLAMP,
|
||||
aSamplingFilter);
|
||||
|
||||
RefPtr<SourceSurface> surface = dt->Snapshot();
|
||||
|
|
|
|||
|
|
@ -321,13 +321,12 @@ static already_AddRefed<gfxDrawable> CreateSamplingRestrictedDrawable(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> tmpCtx = gfxContext::CreateOrNull(target);
|
||||
MOZ_ASSERT(tmpCtx); // already checked the target above
|
||||
gfxContext tmpCtx(target);
|
||||
|
||||
if (aUseOptimalFillOp) {
|
||||
tmpCtx->SetOp(OptimalFillOp());
|
||||
tmpCtx.SetOp(OptimalFillOp());
|
||||
}
|
||||
aDrawable->Draw(tmpCtx.get(), needed - needed.TopLeft(), ExtendMode::REPEAT,
|
||||
aDrawable->Draw(&tmpCtx, needed - needed.TopLeft(), ExtendMode::REPEAT,
|
||||
SamplingFilter::LINEAR, 1.0,
|
||||
gfxMatrix::Translation(needed.TopLeft()));
|
||||
RefPtr<SourceSurface> surface = target->Snapshot();
|
||||
|
|
@ -474,16 +473,15 @@ static bool PrescaleAndTileDrawable(gfxDrawable* aDrawable,
|
|||
return false;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> tmpCtx = gfxContext::CreateOrNull(scaledDT);
|
||||
MOZ_ASSERT(tmpCtx); // already checked the target above
|
||||
gfxContext tmpCtx(scaledDT);
|
||||
|
||||
scaledDT->SetTransform(scaleMatrix);
|
||||
gfxRect gfxImageRect(aImageRect.x, aImageRect.y, aImageRect.width,
|
||||
aImageRect.height);
|
||||
|
||||
// Since this is just the scaled image, we don't want to repeat anything yet.
|
||||
aDrawable->Draw(tmpCtx.get(), gfxImageRect, ExtendMode::CLAMP,
|
||||
aSamplingFilter, 1.0, gfxMatrix());
|
||||
aDrawable->Draw(&tmpCtx, gfxImageRect, ExtendMode::CLAMP, aSamplingFilter,
|
||||
1.0, gfxMatrix());
|
||||
|
||||
RefPtr<SourceSurface> scaledImage = scaledDT->Snapshot();
|
||||
|
||||
|
|
|
|||
|
|
@ -1651,7 +1651,9 @@ gfxContext* DisplayListBuilder::GetTextContext(
|
|||
if (!mCachedTextDT) {
|
||||
mCachedTextDT = new layout::TextDrawTarget(*this, aResources, aSc, aManager,
|
||||
aItem, aBounds);
|
||||
mCachedContext = gfxContext::CreateOrNull(mCachedTextDT, aDeviceOffset);
|
||||
if (mCachedTextDT->IsValid()) {
|
||||
mCachedContext = MakeUnique<gfxContext>(mCachedTextDT, aDeviceOffset);
|
||||
}
|
||||
} else {
|
||||
mCachedTextDT->Reinitialize(aResources, aSc, aManager, aItem, aBounds);
|
||||
mCachedContext->SetDeviceOffset(aDeviceOffset);
|
||||
|
|
|
|||
|
|
@ -226,15 +226,14 @@ Maybe<BlobImageKeyData> BlobSurfaceProvider::RecordDrawing(
|
|||
mSVGDocumentWrapper->UpdateViewportBounds(viewportSize);
|
||||
mSVGDocumentWrapper->FlushImageTransformInvalidation();
|
||||
|
||||
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(ctx); // Already checked the draw target above.
|
||||
gfxContext ctx(dt);
|
||||
|
||||
nsRect svgRect;
|
||||
auto auPerDevPixel = presContext->AppUnitsPerDevPixel();
|
||||
if (size != viewportSize) {
|
||||
auto scaleX = double(size.width) / viewportSize.width;
|
||||
auto scaleY = double(size.height) / viewportSize.height;
|
||||
ctx->SetMatrix(Matrix::Scaling(float(scaleX), float(scaleY)));
|
||||
ctx.SetMatrix(Matrix::Scaling(float(scaleX), float(scaleY)));
|
||||
|
||||
auto scaledVisibleRect = IntRectToRect(imageRect);
|
||||
scaledVisibleRect.Scale(float(auPerDevPixel / scaleX),
|
||||
|
|
@ -261,7 +260,7 @@ Maybe<BlobImageKeyData> BlobSurfaceProvider::RecordDrawing(
|
|||
|
||||
presShell->RenderDocument(svgRect, renderDocFlags,
|
||||
NS_RGBA(0, 0, 0, 0), // transparent
|
||||
ctx.get());
|
||||
&ctx);
|
||||
}
|
||||
|
||||
recorder->FlushItem(imageRectOrigin);
|
||||
|
|
|
|||
|
|
@ -255,8 +255,7 @@ std::pair<ImgDrawResult, RefPtr<SourceSurface>> ClippedImage::GetFrameInternal(
|
|||
RefPtr<SourceSurface>());
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
gfxContext ctx(target);
|
||||
|
||||
// Create our callback.
|
||||
RefPtr<DrawSingleTileCallback> drawTileCallback =
|
||||
|
|
@ -266,7 +265,7 @@ std::pair<ImgDrawResult, RefPtr<SourceSurface>> ClippedImage::GetFrameInternal(
|
|||
new gfxCallbackDrawable(drawTileCallback, aSize);
|
||||
|
||||
// Actually draw. The callback will end up invoking DrawSingleTile.
|
||||
gfxUtils::DrawPixelSnapped(ctx.get(), drawable, SizeDouble(aSize),
|
||||
gfxUtils::DrawPixelSnapped(&ctx, drawable, SizeDouble(aSize),
|
||||
ImageRegion::Create(aSize),
|
||||
SurfaceFormat::OS_RGBA, SamplingFilter::LINEAR,
|
||||
imgIContainer::FLAG_CLAMP);
|
||||
|
|
|
|||
|
|
@ -150,12 +150,10 @@ DynamicImage::GetFrameAtSize(const IntSize& aSize, uint32_t aWhichFrame,
|
|||
<< "DynamicImage::GetFrame failed in CreateOffscreenContentDrawTarget";
|
||||
return nullptr;
|
||||
}
|
||||
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context); // already checked the draw target above
|
||||
gfxContext context(dt);
|
||||
|
||||
auto result =
|
||||
Draw(context.get(), aSize, ImageRegion::Create(aSize), aWhichFrame,
|
||||
SamplingFilter::POINT, SVGImageContext(), aFlags, 1.0);
|
||||
auto result = Draw(&context, aSize, ImageRegion::Create(aSize), aWhichFrame,
|
||||
SamplingFilter::POINT, SVGImageContext(), aFlags, 1.0);
|
||||
|
||||
return result == ImgDrawResult::SUCCESS ? dt->Snapshot() : nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,10 +108,10 @@ already_AddRefed<SourceSurface> OrientedImage::OrientSurface(
|
|||
}
|
||||
|
||||
// Draw.
|
||||
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
ctx->Multiply(OrientationMatrix(aOrientation, originalSize));
|
||||
gfxUtils::DrawPixelSnapped(ctx.get(), drawable, SizeDouble(originalSize),
|
||||
gfxContext ctx(target);
|
||||
|
||||
ctx.Multiply(OrientationMatrix(aOrientation, originalSize));
|
||||
gfxUtils::DrawPixelSnapped(&ctx, drawable, SizeDouble(originalSize),
|
||||
ImageRegion::Create(originalSize), surfaceFormat,
|
||||
SamplingFilter::LINEAR);
|
||||
|
||||
|
|
|
|||
|
|
@ -359,9 +359,9 @@ nsresult imgFrame::InitWithDrawable(gfxDrawable* aDrawable,
|
|||
}
|
||||
|
||||
// Draw using the drawable the caller provided.
|
||||
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
|
||||
MOZ_ASSERT(ctx); // Already checked the draw target above.
|
||||
gfxUtils::DrawPixelSnapped(ctx.get(), aDrawable, SizeDouble(mImageSize),
|
||||
gfxContext ctx(target);
|
||||
|
||||
gfxUtils::DrawPixelSnapped(&ctx, aDrawable, SizeDouble(mImageSize),
|
||||
ImageRegion::Create(ThebesRect(GetRect())),
|
||||
mFormat, aSamplingFilter, aImageFlags);
|
||||
|
||||
|
|
|
|||
|
|
@ -3081,19 +3081,16 @@ void PresShell::ClearFrameRefs(nsIFrame* aFrame) {
|
|||
}
|
||||
|
||||
UniquePtr<gfxContext> PresShell::CreateReferenceRenderingContext() {
|
||||
nsDeviceContext* devCtx = mPresContext->DeviceContext();
|
||||
UniquePtr<gfxContext> rc;
|
||||
if (mPresContext->IsScreen()) {
|
||||
rc = gfxContext::CreateOrNull(
|
||||
return gfxContext::CreateOrNull(
|
||||
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget().get());
|
||||
} else {
|
||||
// We assume the devCtx has positive width and height for this call.
|
||||
// However, width and height, may be outside of the reasonable range
|
||||
// so rc may still be null.
|
||||
rc = devCtx->CreateReferenceRenderingContext();
|
||||
}
|
||||
|
||||
return rc;
|
||||
// We assume the devCtx has positive width and height for this call.
|
||||
// However, width and height, may be outside of the reasonable range
|
||||
// so rc may still be null.
|
||||
nsDeviceContext* devCtx = mPresContext->DeviceContext();
|
||||
return devCtx->CreateReferenceRenderingContext();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#scroll-to-the-fragment-identifier
|
||||
|
|
@ -5121,8 +5118,7 @@ already_AddRefed<SourceSurface> PresShell::PaintRangePaintInfo(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
gfxContext ctx(dt);
|
||||
|
||||
if (aRegion) {
|
||||
RefPtr<PathBuilder> builder = dt->CreatePathBuilder(FillRule::FILL_WINDING);
|
||||
|
|
@ -5141,10 +5137,10 @@ already_AddRefed<SourceSurface> PresShell::PaintRangePaintInfo(
|
|||
}
|
||||
|
||||
RefPtr<Path> path = builder->Finish();
|
||||
ctx->Clip(path);
|
||||
ctx.Clip(path);
|
||||
}
|
||||
|
||||
gfxMatrix initialTM = ctx->CurrentMatrixDouble();
|
||||
gfxMatrix initialTM = ctx.CurrentMatrixDouble();
|
||||
|
||||
if (resize) {
|
||||
initialTM.PreScale(scale, scale);
|
||||
|
|
@ -5173,10 +5169,10 @@ already_AddRefed<SourceSurface> PresShell::PaintRangePaintInfo(
|
|||
// frame, so account for that translation too:
|
||||
gfxPoint rootOffset = nsLayoutUtils::PointToGfxPoint(
|
||||
rangeInfo->mRootOffset, pc->AppUnitsPerDevPixel());
|
||||
ctx->SetMatrixDouble(initialTM.PreTranslate(rootOffset));
|
||||
ctx.SetMatrixDouble(initialTM.PreTranslate(rootOffset));
|
||||
aArea.MoveBy(-rangeInfo->mRootOffset.x, -rangeInfo->mRootOffset.y);
|
||||
nsRegion visible(aArea);
|
||||
rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, ctx.get(),
|
||||
rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, &ctx,
|
||||
nsDisplayList::PAINT_DEFAULT, Nothing());
|
||||
aArea.MoveBy(rangeInfo->mRootOffset.x, rangeInfo->mRootOffset.y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7156,9 +7156,6 @@ static RefPtr<SourceSurface> ScaleSourceSurface(SourceSurface& aSurface,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context);
|
||||
|
||||
dt->DrawSurface(&aSurface, Rect(Point(), Size(aTargetSize)),
|
||||
Rect(Point(), Size(surfaceSize)));
|
||||
return dt->GetBackingSurface();
|
||||
|
|
|
|||
|
|
@ -270,8 +270,12 @@ bool nsDisplayTextOverflowMarker::CreateWebRenderCommands(
|
|||
// Run the rendering algorithm to capture the glyphs and shadows
|
||||
RefPtr<TextDrawTarget> textDrawer =
|
||||
new TextDrawTarget(aBuilder, aResources, aSc, aManager, this, bounds);
|
||||
UniquePtr<gfxContext> captureCtx = gfxContext::CreateOrNull(textDrawer);
|
||||
Paint(aDisplayListBuilder, captureCtx.get());
|
||||
MOZ_ASSERT(textDrawer->IsValid());
|
||||
if (!textDrawer->IsValid()) {
|
||||
return false;
|
||||
}
|
||||
gfxContext captureCtx(textDrawer);
|
||||
Paint(aDisplayListBuilder, &captureCtx);
|
||||
textDrawer->TerminateShadows();
|
||||
|
||||
return textDrawer->Finish();
|
||||
|
|
|
|||
|
|
@ -73,13 +73,16 @@ bool nsDisplayColumnRule::CreateWebRenderCommands(
|
|||
const StackingContextHelper& aSc,
|
||||
mozilla::layers::RenderRootStateManager* aManager,
|
||||
nsDisplayListBuilder* aDisplayListBuilder) {
|
||||
UniquePtr<gfxContext> screenRefCtx = gfxContext::CreateOrNull(
|
||||
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget().get());
|
||||
RefPtr dt = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
|
||||
if (!dt || !dt->IsValid()) {
|
||||
return false;
|
||||
}
|
||||
gfxContext screenRefCtx(dt);
|
||||
|
||||
bool dummy;
|
||||
static_cast<nsColumnSetFrame*>(mFrame)->CreateBorderRenderers(
|
||||
mBorderRenderers, screenRefCtx.get(),
|
||||
GetBounds(aDisplayListBuilder, &dummy), ToReferenceFrame());
|
||||
mBorderRenderers, &screenRefCtx, GetBounds(aDisplayListBuilder, &dummy),
|
||||
ToReferenceFrame());
|
||||
|
||||
if (mBorderRenderers.IsEmpty()) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -2703,11 +2703,10 @@ nsFloatManager::ShapeInfo::CreateImageShape(const StyleImage& aShapeImage,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(drawTarget);
|
||||
MOZ_ASSERT(context); // already checked the target above
|
||||
gfxContext context(drawTarget);
|
||||
|
||||
ImgDrawResult result =
|
||||
imageRenderer.DrawShapeImage(aFrame->PresContext(), *context);
|
||||
imageRenderer.DrawShapeImage(aFrame->PresContext(), context);
|
||||
|
||||
if (result != ImgDrawResult::SUCCESS) {
|
||||
return nullptr;
|
||||
|
|
|
|||
|
|
@ -2048,14 +2048,18 @@ ImgDrawResult nsImageFrame::DisplayAltFeedbackWithoutLayer(
|
|||
RefPtr<TextDrawTarget> textDrawer =
|
||||
new TextDrawTarget(aBuilder, aResources, aSc, aManager, aItem, inner,
|
||||
/* aCallerDoesSaveRestore = */ true);
|
||||
UniquePtr<gfxContext> captureCtx = gfxContext::CreateOrNull(textDrawer);
|
||||
MOZ_ASSERT(textDrawer->IsValid());
|
||||
if (textDrawer->IsValid()) {
|
||||
gfxContext captureCtx(textDrawer);
|
||||
|
||||
nsAutoString altText;
|
||||
nsCSSFrameConstructor::GetAlternateTextFor(*mContent->AsElement(), altText);
|
||||
DisplayAltText(PresContext(), *captureCtx.get(), altText, inner);
|
||||
nsAutoString altText;
|
||||
nsCSSFrameConstructor::GetAlternateTextFor(*mContent->AsElement(),
|
||||
altText);
|
||||
DisplayAltText(PresContext(), captureCtx, altText, inner);
|
||||
|
||||
textDrawer->TerminateShadows();
|
||||
textDrawResult = !textDrawer->CheckHasUnsupportedFeatures();
|
||||
textDrawer->TerminateShadows();
|
||||
textDrawResult = !textDrawer->CheckHasUnsupportedFeatures();
|
||||
}
|
||||
}
|
||||
|
||||
// Purposely ignore local DrawResult because we handled it not being success
|
||||
|
|
|
|||
|
|
@ -1155,12 +1155,13 @@ bool nsCSSGradientRenderer::TryPaintTilesWithExtendMode(
|
|||
return false;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> tileContext = gfxContext::CreateOrNull(tileTarget);
|
||||
{
|
||||
gfxContext tileContext(tileTarget);
|
||||
|
||||
tileContext->SetPattern(aGradientPattern);
|
||||
tileContext->Paint();
|
||||
tileContext.SetPattern(aGradientPattern);
|
||||
tileContext.Paint();
|
||||
}
|
||||
|
||||
tileContext = nullptr;
|
||||
tileSurface = tileTarget->Snapshot();
|
||||
tileTarget = nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -636,18 +636,16 @@ void FilterInstance::BuildSourcePaint(SourceInfo* aSource,
|
|||
return;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(offscreenDT);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
gfxContextAutoSaveRestore saver(ctx.get());
|
||||
gfxContext ctx(offscreenDT);
|
||||
gfxContextAutoSaveRestore saver(&ctx);
|
||||
|
||||
ctx->SetMatrixDouble(mPaintTransform *
|
||||
gfxMatrix::Translation(-neededRect.TopLeft()));
|
||||
ctx.SetMatrixDouble(mPaintTransform *
|
||||
gfxMatrix::Translation(-neededRect.TopLeft()));
|
||||
GeneralPattern pattern;
|
||||
if (aSource == &mFillPaint) {
|
||||
SVGUtils::MakeFillPatternFor(mTargetFrame, ctx.get(), &pattern, aImgParams);
|
||||
SVGUtils::MakeFillPatternFor(mTargetFrame, &ctx, &pattern, aImgParams);
|
||||
} else if (aSource == &mStrokePaint) {
|
||||
SVGUtils::MakeStrokePatternFor(mTargetFrame, ctx.get(), &pattern,
|
||||
aImgParams);
|
||||
SVGUtils::MakeStrokePatternFor(mTargetFrame, &ctx, &pattern, aImgParams);
|
||||
}
|
||||
|
||||
if (pattern.GetPattern()) {
|
||||
|
|
@ -708,13 +706,12 @@ void FilterInstance::BuildSourceImage(DrawTarget* aDest,
|
|||
// space to device space and back again). However, that would make the
|
||||
// code more complex while being hard to get right without introducing
|
||||
// subtle bugs, and in practice it probably makes no real difference.)
|
||||
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(offscreenDT);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
gfxContext ctx(offscreenDT);
|
||||
gfxMatrix devPxToCssPxTM = SVGUtils::GetCSSPxToDevPxMatrix(mTargetFrame);
|
||||
DebugOnly<bool> invertible = devPxToCssPxTM.Invert();
|
||||
MOZ_ASSERT(invertible);
|
||||
ctx->SetMatrixDouble(devPxToCssPxTM * mPaintTransform *
|
||||
gfxMatrix::Translation(-neededRect.TopLeft()));
|
||||
ctx.SetMatrixDouble(devPxToCssPxTM * mPaintTransform *
|
||||
gfxMatrix::Translation(-neededRect.TopLeft()));
|
||||
|
||||
auto imageFlags = aImgParams.imageFlags;
|
||||
if (mTargetFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) {
|
||||
|
|
@ -725,7 +722,7 @@ void FilterInstance::BuildSourceImage(DrawTarget* aDest,
|
|||
imageFlags &= ~imgIContainer::FLAG_HIGH_QUALITY_SCALING;
|
||||
}
|
||||
imgDrawingParams imgParams(imageFlags);
|
||||
mPaintCallback(*ctx, imgParams, &mPaintTransform, &dirty);
|
||||
mPaintCallback(ctx, imgParams, &mPaintTransform, &dirty);
|
||||
aImgParams.result = imgParams.result;
|
||||
|
||||
mSourceGraphic.mSourceSurface = offscreenDT->Snapshot();
|
||||
|
|
|
|||
|
|
@ -338,12 +338,11 @@ already_AddRefed<SourceSurface> SVGPatternFrame::PaintPattern(
|
|||
}
|
||||
dt->ClearRect(Rect(0, 0, surfaceSize.width, surfaceSize.height));
|
||||
|
||||
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
gfxContext ctx(dt);
|
||||
|
||||
if (aGraphicOpacity != 1.0f) {
|
||||
ctx->Save();
|
||||
ctx->PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, aGraphicOpacity);
|
||||
ctx.Save();
|
||||
ctx.PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, aGraphicOpacity);
|
||||
}
|
||||
|
||||
// OK, now render -- note that we use "firstKid", which
|
||||
|
|
@ -369,15 +368,15 @@ already_AddRefed<SourceSurface> SVGPatternFrame::PaintPattern(
|
|||
tm = SVGUtils::GetTransformMatrixInUserSpace(kid) * tm;
|
||||
}
|
||||
|
||||
SVGUtils::PaintFrameWithEffects(kid, *ctx, tm, aImgParams);
|
||||
SVGUtils::PaintFrameWithEffects(kid, ctx, tm, aImgParams);
|
||||
}
|
||||
}
|
||||
|
||||
patternWithChildren->mSource = nullptr;
|
||||
|
||||
if (aGraphicOpacity != 1.0f) {
|
||||
ctx->PopGroupAndBlend();
|
||||
ctx->Restore();
|
||||
ctx.PopGroupAndBlend();
|
||||
ctx.Restore();
|
||||
}
|
||||
|
||||
// caller now owns the surface
|
||||
|
|
|
|||
|
|
@ -302,10 +302,12 @@ bool nsDisplayXULTextBox::CreateWebRenderCommands(
|
|||
RefPtr<mozilla::layout::TextDrawTarget> textDrawer =
|
||||
new mozilla::layout::TextDrawTarget(aBuilder, aResources, aSc, aManager,
|
||||
this, bounds);
|
||||
UniquePtr<gfxContext> captureCtx =
|
||||
gfxContext::CreateOrNull(textDrawer, deviceOffset);
|
||||
if (!textDrawer->IsValid()) {
|
||||
return false;
|
||||
}
|
||||
gfxContext captureCtx(textDrawer, deviceOffset);
|
||||
|
||||
Paint(aDisplayListBuilder, captureCtx.get());
|
||||
Paint(aDisplayListBuilder, &captureCtx);
|
||||
textDrawer->TerminateShadows();
|
||||
|
||||
return textDrawer->Finish();
|
||||
|
|
|
|||
|
|
@ -1316,21 +1316,23 @@ bool nsChildView::PaintWindow(LayoutDeviceIntRegion aRegion) {
|
|||
bool nsChildView::PaintWindowInDrawTarget(gfx::DrawTarget* aDT,
|
||||
const LayoutDeviceIntRegion& aRegion,
|
||||
const gfx::IntSize& aSurfaceSize) {
|
||||
UniquePtr<gfxContext> targetContext = gfxContext::CreateOrNull(aDT);
|
||||
MOZ_ASSERT(targetContext);
|
||||
if (!aDT || !aDT->IsValid()) {
|
||||
return false;
|
||||
}
|
||||
gfxContext targetContext(aDT);
|
||||
|
||||
// Set up the clip region and clear existing contents in the backing surface.
|
||||
targetContext->NewPath();
|
||||
targetContext.NewPath();
|
||||
for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
|
||||
const LayoutDeviceIntRect& r = iter.Get();
|
||||
targetContext->Rectangle(gfxRect(r.x, r.y, r.width, r.height));
|
||||
targetContext.Rectangle(gfxRect(r.x, r.y, r.width, r.height));
|
||||
aDT->ClearRect(gfx::Rect(r.ToUnknownRect()));
|
||||
}
|
||||
targetContext->Clip();
|
||||
targetContext.Clip();
|
||||
|
||||
nsAutoRetainCocoaObject kungFuDeathGrip(mView);
|
||||
if (GetWindowRenderer()->GetBackendType() == LayersBackend::LAYERS_NONE) {
|
||||
nsBaseWidget::AutoLayerManagerSetup setupLayerManager(this, targetContext.get(),
|
||||
nsBaseWidget::AutoLayerManagerSetup setupLayerManager(this, &targetContext,
|
||||
BufferMode::BUFFER_NONE);
|
||||
return PaintWindow(aRegion);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -494,15 +494,14 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(imgIContainer* aImage, ui
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(drawTarget);
|
||||
MOZ_ASSERT(context);
|
||||
gfxContext context(drawTarget);
|
||||
|
||||
SVGImageContext svgContext;
|
||||
if (aPresContext && aComputedStyle) {
|
||||
SVGImageContext::MaybeStoreContextPaint(svgContext, *aPresContext, *aComputedStyle, aImage);
|
||||
}
|
||||
mozilla::image::ImgDrawResult res =
|
||||
aImage->Draw(context.get(), scaledSize, ImageRegion::Create(scaledSize), aWhichFrame,
|
||||
aImage->Draw(&context, scaledSize, ImageRegion::Create(scaledSize), aWhichFrame,
|
||||
SamplingFilter::POINT, svgContext, imgIContainer::FLAG_SYNC_DECODE, 1.0);
|
||||
|
||||
if (res != mozilla::image::ImgDrawResult::SUCCESS) {
|
||||
|
|
|
|||
|
|
@ -940,11 +940,10 @@ nsresult nsBaseDragService::DrawDragForImage(
|
|||
destSize, SurfaceFormat::B8G8R8A8);
|
||||
if (!dt || !dt->IsValid()) return NS_ERROR_FAILURE;
|
||||
|
||||
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
if (!ctx) return NS_ERROR_FAILURE;
|
||||
gfxContext ctx(dt);
|
||||
|
||||
ImgDrawResult res = imgContainer->Draw(
|
||||
ctx.get(), destSize, ImageRegion::Create(destSize),
|
||||
&ctx, destSize, ImageRegion::Create(destSize),
|
||||
imgIContainer::FRAME_CURRENT, SamplingFilter::GOOD, SVGImageContext(),
|
||||
imgIContainer::FLAG_SYNC_DECODE, 1.0);
|
||||
if (res == ImgDrawResult::BAD_IMAGE || res == ImgDrawResult::BAD_ARGS ||
|
||||
|
|
|
|||
|
|
@ -307,11 +307,10 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel) {
|
|||
break;
|
||||
}
|
||||
|
||||
UniquePtr<gfxContext> thebesContext = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(thebesContext); // already checked draw target above
|
||||
gfxContext thebesContext(dt);
|
||||
|
||||
{
|
||||
AutoLayerManagerSetup setupLayerManager(this, thebesContext.get(),
|
||||
AutoLayerManagerSetup setupLayerManager(this, &thebesContext,
|
||||
doubleBuffering);
|
||||
result = listener->PaintWindow(this, region);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue