Bug 1815404 - Remove refcounting from gfxContext. r=gfx-reviewers,lsalzman

Depends on D170367

Differential Revision: https://phabricator.services.mozilla.com/D170369
This commit is contained in:
Jonathan Kew 2023-02-21 07:28:24 +00:00
parent 64fac83d98
commit 1b3e69f8aa
57 changed files with 188 additions and 188 deletions

View File

@ -3857,14 +3857,14 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor final
return;
}
RefPtr<gfxContext> thebes =
UniquePtr<gfxContext> thebes =
gfxContext::CreatePreservingTransformOrNull(target);
if (!thebes) {
// If CreatePreservingTransformOrNull returns null, it will also have
// issued a gfxCriticalNote already, so here we'll just bail out.
return;
}
gfxTextRun::DrawParams params(thebes);
gfxTextRun::DrawParams params(thebes.get());
params.allowGDI = false;
@ -5027,7 +5027,7 @@ void CanvasRenderingContext2D::DrawDirectlyToCanvas(
// the matrix even though this is a temp gfxContext.
AutoRestoreTransform autoRestoreTransform(mTarget);
RefPtr<gfxContext> context = gfxContext::CreateOrNull(tempTarget);
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(tempTarget);
if (!context) {
gfxDevCrash(LogReason::InvalidContext) << "Canvas context problem";
return;
@ -5047,7 +5047,7 @@ void CanvasRenderingContext2D::DrawDirectlyToCanvas(
SVGImageContext svgContext(Some(sz));
auto result = aImage.mImgContainer->Draw(
context, scaledImageSize,
context.get(), scaledImageSize,
ImageRegion::Create(gfxRect(aSrc.x, aSrc.y, aSrc.width, aSrc.height)),
aImage.mWhichFrame, SamplingFilter::GOOD, svgContext, modifiedFlags,
CurrentState().globalAlpha);
@ -5225,7 +5225,7 @@ void CanvasRenderingContext2D::DrawWindow(nsGlobalWindowInner& aWindow,
return;
}
RefPtr<gfxContext> thebes;
UniquePtr<gfxContext> thebes;
RefPtr<DrawTarget> drawDT;
// Rendering directly is faster and can be done if mTarget supports Azure
// and does not need alpha blending.
@ -5275,7 +5275,7 @@ void CanvasRenderingContext2D::DrawWindow(nsGlobalWindowInner& aWindow,
RefPtr<PresShell> presShell = presContext->PresShell();
Unused << presShell->RenderDocument(r, renderDocFlags, backgroundColor,
thebes);
thebes.get());
// 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);

View File

@ -140,12 +140,12 @@ PaintFragment PaintFragment::Record(dom::BrowsingContext* aBc,
dt->AddUserData(&sDisablePixelSnapping, (void*)0x1, nullptr);
}
RefPtr<gfxContext> thebes = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> thebes = gfxContext::CreateOrNull(dt);
thebes->SetMatrix(Matrix::Scaling(aScale, aScale));
thebes->SetCrossProcessPaintScale(aScale);
RefPtr<PresShell> presShell = presContext->PresShell();
Unused << presShell->RenderDocument(r, renderDocFlags, aBackgroundColor,
thebes);
thebes.get());
}
if (!recorder->mOutputStream.mValid) {

View File

@ -657,7 +657,7 @@ struct DIGroup {
RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateRecordingDrawTarget(
recorder, dummyDt, mLayerBounds.ToUnknownRect());
// Setup the gfxContext
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(dt);
context->SetMatrix(Matrix::Scaling(mScale).PostTranslate(
mResidualOffset.x, mResidualOffset.y));
@ -673,7 +673,7 @@ struct DIGroup {
return;
}
PaintItemRange(aGrouper, aStartItem, aEndItem, context, recorder,
PaintItemRange(aGrouper, aStartItem, aEndItem, context.get(), recorder,
rootManager, aResources);
// XXX: set this correctly perhaps using
@ -2295,7 +2295,7 @@ static void PaintItemByDrawTarget(nsDisplayItem* aItem, gfx::DrawTarget* aDT,
// XXX Why is this ClearRect() needed?
aDT->ClearRect(Rect(visibleRect));
RefPtr<gfxContext> context = gfxContext::CreateOrNull(aDT);
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(aDT);
MOZ_ASSERT(context);
switch (aItem->GetType()) {
@ -2315,7 +2315,7 @@ static void PaintItemByDrawTarget(nsDisplayItem* aItem, gfx::DrawTarget* aDT,
if (aDisplayListBuilder->IsPaintingToWindow()) {
aItem->Frame()->AddStateBits(NS_FRAME_PAINTED_THEBES);
}
aItem->AsPaintedDisplayItem()->Paint(aDisplayListBuilder, context);
aItem->AsPaintedDisplayItem()->Paint(aDisplayListBuilder, context.get());
break;
}
@ -2782,7 +2782,7 @@ Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
RefPtr<DrawTarget> dt = Factory::CreateRecordingDrawTarget(
recorder, dummyDt, IntRect(IntPoint(0, 0), size));
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(context);
context->SetMatrix(context->CurrentMatrix()
@ -2791,7 +2791,7 @@ Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
bool maskPainted = false;
bool maskIsComplete = aMaskItem->PaintMask(
aDisplayListBuilder, context, shouldHandleOpacity, &maskPainted);
aDisplayListBuilder, context.get(), shouldHandleOpacity, &maskPainted);
if (!maskPainted) {
return Nothing();
}

View File

@ -254,7 +254,7 @@ class WebRenderLayerManager final : public WindowRenderer {
// we send a message to our remote side to capture the actual pixels
// being drawn to the default target, and then copy those pixels
// back to mTarget.
RefPtr<gfxContext> mTarget;
gfxContext* mTarget;
// See equivalent field in ClientLayerManager
uint32_t mPaintSequenceNumber;

View File

@ -116,16 +116,15 @@ void nsDeviceContext::Init(nsIWidget* aWidget) {
}
// XXX This is only for printing. We should make that obvious in the name.
already_AddRefed<gfxContext> nsDeviceContext::CreateRenderingContext() {
UniquePtr<gfxContext> nsDeviceContext::CreateRenderingContext() {
return CreateRenderingContextCommon(/* not a reference context */ false);
}
already_AddRefed<gfxContext>
nsDeviceContext::CreateReferenceRenderingContext() {
UniquePtr<gfxContext> nsDeviceContext::CreateReferenceRenderingContext() {
return CreateRenderingContextCommon(/* a reference context */ true);
}
already_AddRefed<gfxContext> nsDeviceContext::CreateRenderingContextCommon(
UniquePtr<gfxContext> nsDeviceContext::CreateRenderingContextCommon(
bool aWantReferenceContext) {
MOZ_ASSERT(IsPrinterContext());
MOZ_ASSERT(mWidth > 0 && mHeight > 0);
@ -154,14 +153,14 @@ already_AddRefed<gfxContext> nsDeviceContext::CreateRenderingContextCommon(
dt->AddUserData(&sDisablePixelSnapping, (void*)0x1, nullptr);
RefPtr<gfxContext> pContext = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> pContext = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(pContext); // already checked draw target above
gfxMatrix transform;
transform.PreTranslate(mPrintingTranslate);
transform.PreScale(mPrintingScale, mPrintingScale);
pContext->SetMatrixDouble(transform);
return pContext.forget();
return pContext;
}
uint32_t nsDeviceContext::GetDepth() {

View File

@ -73,7 +73,7 @@ class nsDeviceContext final {
*
* @return the new rendering context (guaranteed to be non-null)
*/
already_AddRefed<gfxContext> CreateRenderingContext();
mozilla::UniquePtr<gfxContext> CreateRenderingContext();
/**
* Create a reference rendering context and initialize it. Only call this
@ -81,7 +81,7 @@ class nsDeviceContext final {
*
* @return the new rendering context.
*/
already_AddRefed<gfxContext> CreateReferenceRenderingContext();
mozilla::UniquePtr<gfxContext> CreateReferenceRenderingContext();
/**
* Gets the number of app units in one device pixel; this number
@ -270,7 +270,7 @@ class nsDeviceContext final {
* Implementation shared by CreateRenderingContext and
* CreateReferenceRenderingContext.
*/
already_AddRefed<gfxContext> CreateRenderingContextCommon(
mozilla::UniquePtr<gfxContext> CreateRenderingContextCommon(
bool aWantReferenceContext);
void SetDPI();

View File

@ -23,13 +23,13 @@ using namespace mozilla::gfx;
gfxAlphaBoxBlur::~gfxAlphaBoxBlur() = default;
already_AddRefed<gfxContext> gfxAlphaBoxBlur::Init(gfxContext* aDestinationCtx,
const gfxRect& aRect,
const IntSize& aSpreadRadius,
const IntSize& aBlurRadius,
const gfxRect* aDirtyRect,
const gfxRect* aSkipRect,
bool aUseHardwareAccel) {
UniquePtr<gfxContext> gfxAlphaBoxBlur::Init(gfxContext* aDestinationCtx,
const gfxRect& aRect,
const IntSize& aSpreadRadius,
const IntSize& aBlurRadius,
const gfxRect* aDirtyRect,
const gfxRect* aSkipRect,
bool aUseHardwareAccel) {
DrawTarget* refDT = aDestinationCtx->GetDrawTarget();
Maybe<Rect> dirtyRect = aDirtyRect ? Some(ToRect(*aDirtyRect)) : Nothing();
Maybe<Rect> skipRect = aSkipRect ? Some(ToRect(*aSkipRect)) : Nothing();
@ -40,10 +40,10 @@ already_AddRefed<gfxContext> gfxAlphaBoxBlur::Init(gfxContext* aDestinationCtx,
return nullptr;
}
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(context); // already checked for target above
context->SetMatrix(Matrix::Translation(-mBlur.GetRect().TopLeft()));
return context.forget();
return context;
}
already_AddRefed<DrawTarget> gfxAlphaBoxBlur::InitDrawTarget(

View File

@ -77,13 +77,11 @@ class gfxAlphaBoxBlur final {
* @param aUseHardwareAccel Flag to state whether or not we can use hardware
* acceleration to speed up this blur.
*/
already_AddRefed<gfxContext> Init(gfxContext* aDestinationCtx,
const gfxRect& aRect,
const mozilla::gfx::IntSize& aSpreadRadius,
const mozilla::gfx::IntSize& aBlurRadius,
const gfxRect* aDirtyRect,
const gfxRect* aSkipRect,
bool aUseHardwareAccel = true);
mozilla::UniquePtr<gfxContext> Init(
gfxContext* aDestinationCtx, const gfxRect& aRect,
const mozilla::gfx::IntSize& aSpreadRadius,
const mozilla::gfx::IntSize& aBlurRadius, const gfxRect* aDirtyRect,
const gfxRect* aSkipRect, bool aUseHardwareAccel = true);
already_AddRefed<DrawTarget> InitDrawTarget(
const mozilla::gfx::DrawTarget* aReferenceDT,

View File

@ -62,7 +62,7 @@ gfxContext::gfxContext(DrawTarget* aTarget, const Point& aDeviceOffset)
}
/* static */
already_AddRefed<gfxContext> gfxContext::CreateOrNull(
UniquePtr<gfxContext> gfxContext::CreateOrNull(
DrawTarget* aTarget, const mozilla::gfx::Point& aDeviceOffset) {
if (!aTarget || !aTarget->IsValid()) {
gfxCriticalNote << "Invalid target in gfxContext::CreateOrNull "
@ -70,12 +70,11 @@ already_AddRefed<gfxContext> gfxContext::CreateOrNull(
return nullptr;
}
RefPtr<gfxContext> result = new gfxContext(aTarget, aDeviceOffset);
return result.forget();
return MakeUnique<gfxContext>(aTarget, aDeviceOffset);
}
/* static */
already_AddRefed<gfxContext> gfxContext::CreatePreservingTransformOrNull(
UniquePtr<gfxContext> gfxContext::CreatePreservingTransformOrNull(
DrawTarget* aTarget) {
if (!aTarget || !aTarget->IsValid()) {
gfxCriticalNote
@ -84,10 +83,11 @@ already_AddRefed<gfxContext> gfxContext::CreatePreservingTransformOrNull(
return nullptr;
}
Matrix transform = aTarget->GetTransform();
RefPtr<gfxContext> result = new gfxContext(aTarget);
auto transform = aTarget->GetTransform();
auto result = MakeUnique<gfxContext>(aTarget);
result->SetMatrix(transform);
return result.forget();
return result;
}
gfxContext::~gfxContext() {

View File

@ -57,9 +57,20 @@ class gfxContext final {
typedef mozilla::gfx::RectCornerRadii RectCornerRadii;
typedef mozilla::gfx::Size Size;
NS_INLINE_DECL_REFCOUNTING(gfxContext)
public:
/**
* Initialize this context from a DrawTarget.
* Strips any transform from aTarget.
* aTarget will be flushed in the gfxContext's destructor. Use the static
* ContextForDrawTargetNoTransform() when you want this behavior, as that
* version deals with null DrawTarget better.
*/
explicit gfxContext(
mozilla::gfx::DrawTarget* aTarget,
const mozilla::gfx::Point& aDeviceOffset = mozilla::gfx::Point());
~gfxContext();
/**
* Initialize this context from a DrawTarget.
* Strips any transform from aTarget.
@ -67,7 +78,7 @@ class gfxContext final {
* If aTarget is null or invalid, nullptr is returned. The caller
* is responsible for handling this scenario as appropriate.
*/
static already_AddRefed<gfxContext> CreateOrNull(
static mozilla::UniquePtr<gfxContext> CreateOrNull(
mozilla::gfx::DrawTarget* aTarget,
const mozilla::gfx::Point& aDeviceOffset = mozilla::gfx::Point());
@ -78,7 +89,7 @@ class gfxContext final {
* If aTarget is null or invalid, nullptr is returned. The caller
* is responsible for handling this scenario as appropriate.
*/
static already_AddRefed<gfxContext> CreatePreservingTransformOrNull(
static mozilla::UniquePtr<gfxContext> CreatePreservingTransformOrNull(
mozilla::gfx::DrawTarget* aTarget);
mozilla::gfx::DrawTarget* GetDrawTarget() { return mDT; }
@ -438,18 +449,6 @@ class gfxContext final {
#endif
private:
/**
* Initialize this context from a DrawTarget.
* Strips any transform from aTarget.
* aTarget will be flushed in the gfxContext's destructor. Use the static
* ContextForDrawTargetNoTransform() when you want this behavior, as that
* version deals with null DrawTarget better.
*/
explicit gfxContext(
mozilla::gfx::DrawTarget* aTarget,
const mozilla::gfx::Point& aDeviceOffset = mozilla::gfx::Point());
~gfxContext();
friend class PatternFromState;
friend class GlyphBufferAzure;
@ -543,7 +542,7 @@ class gfxContextAutoSaveRestore {
~gfxContextAutoSaveRestore() { Restore(); }
void SetContext(gfxContext* aContext) {
NS_ASSERTION(!mContext, "Not going to call Restore() on some context!!!");
MOZ_ASSERT(!mContext, "no context?");
mContext = aContext;
mContext->Save();
}

View File

@ -105,9 +105,9 @@ already_AddRefed<gfxSurfaceDrawable> gfxCallbackDrawable::MakeSurfaceDrawable(
if (!dt || !dt->IsValid()) return nullptr;
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(ctx); // already checked for target above
Draw(ctx, gfxRect(0, 0, mSize.width, mSize.height), ExtendMode::CLAMP,
Draw(ctx.get(), gfxRect(0, 0, mSize.width, mSize.height), ExtendMode::CLAMP,
aSamplingFilter);
RefPtr<SourceSurface> surface = dt->Snapshot();

View File

@ -321,13 +321,13 @@ static already_AddRefed<gfxDrawable> CreateSamplingRestrictedDrawable(
return nullptr;
}
RefPtr<gfxContext> tmpCtx = gfxContext::CreateOrNull(target);
UniquePtr<gfxContext> tmpCtx = gfxContext::CreateOrNull(target);
MOZ_ASSERT(tmpCtx); // already checked the target above
if (aUseOptimalFillOp) {
tmpCtx->SetOp(OptimalFillOp());
}
aDrawable->Draw(tmpCtx, needed - needed.TopLeft(), ExtendMode::REPEAT,
aDrawable->Draw(tmpCtx.get(), needed - needed.TopLeft(), ExtendMode::REPEAT,
SamplingFilter::LINEAR, 1.0,
gfxMatrix::Translation(needed.TopLeft()));
RefPtr<SourceSurface> surface = target->Snapshot();
@ -474,7 +474,7 @@ static bool PrescaleAndTileDrawable(gfxDrawable* aDrawable,
return false;
}
RefPtr<gfxContext> tmpCtx = gfxContext::CreateOrNull(scaledDT);
UniquePtr<gfxContext> tmpCtx = gfxContext::CreateOrNull(scaledDT);
MOZ_ASSERT(tmpCtx); // already checked the target above
scaledDT->SetTransform(scaleMatrix);
@ -482,8 +482,8 @@ static bool PrescaleAndTileDrawable(gfxDrawable* aDrawable,
aImageRect.height);
// Since this is just the scaled image, we don't want to repeat anything yet.
aDrawable->Draw(tmpCtx, gfxImageRect, ExtendMode::CLAMP, aSamplingFilter, 1.0,
gfxMatrix());
aDrawable->Draw(tmpCtx.get(), gfxImageRect, ExtendMode::CLAMP,
aSamplingFilter, 1.0, gfxMatrix());
RefPtr<SourceSurface> scaledImage = scaledDT->Snapshot();

View File

@ -11,7 +11,7 @@
#include "gfxContext.h"
#include "gfxWindowsSurface.h"
class gfxWindowsNativeDrawing {
class MOZ_STACK_CLASS gfxWindowsNativeDrawing {
public:
/* Flags for notifying this class what kind of operations the native
* drawing supports
@ -79,7 +79,7 @@ class gfxWindowsNativeDrawing {
void PaintToContext();
private:
RefPtr<gfxContext> mContext;
gfxContext* mContext;
gfxRect mNativeRect;
uint32_t mNativeDrawFlags;

View File

@ -1643,7 +1643,7 @@ DisplayListBuilder::FixedPosScrollTargetTracker::GetSideBitsForASR(
return aAsr == mAsr ? Some(mSideBits) : Nothing();
}
already_AddRefed<gfxContext> DisplayListBuilder::GetTextContext(
gfxContext* DisplayListBuilder::GetTextContext(
wr::IpcResourceUpdateQueue& aResources,
const layers::StackingContextHelper& aSc,
layers::RenderRootStateManager* aManager, nsDisplayItem* aItem,
@ -1658,8 +1658,7 @@ already_AddRefed<gfxContext> DisplayListBuilder::GetTextContext(
mCachedContext->SetMatrix(gfx::Matrix());
}
RefPtr<gfxContext> tmp = mCachedContext;
return tmp.forget();
return mCachedContext.get();
}
void DisplayListBuilder::PushInheritedClipChain(

View File

@ -684,11 +684,11 @@ class DisplayListBuilder final {
Maybe<SideBits> GetContainingFixedPosSideBits(const ActiveScrolledRoot* aAsr);
already_AddRefed<gfxContext> GetTextContext(
wr::IpcResourceUpdateQueue& aResources,
const layers::StackingContextHelper& aSc,
layers::RenderRootStateManager* aManager, nsDisplayItem* aItem,
nsRect& aBounds, const gfx::Point& aDeviceOffset);
gfxContext* GetTextContext(wr::IpcResourceUpdateQueue& aResources,
const layers::StackingContextHelper& aSc,
layers::RenderRootStateManager* aManager,
nsDisplayItem* aItem, nsRect& aBounds,
const gfx::Point& aDeviceOffset);
// Try to avoid using this when possible.
wr::WrState* Raw() { return mWrState; }
@ -771,7 +771,7 @@ class DisplayListBuilder final {
Maybe<wr::LayoutRect> mSuspendedClipChainLeaf;
RefPtr<layout::TextDrawTarget> mCachedTextDT;
RefPtr<gfxContext> mCachedContext;
mozilla::UniquePtr<gfxContext> mCachedContext;
FixedPosScrollTargetTracker* mActiveFixedPosTracker;

View File

@ -226,7 +226,7 @@ Maybe<BlobImageKeyData> BlobSurfaceProvider::RecordDrawing(
mSVGDocumentWrapper->UpdateViewportBounds(viewportSize);
mSVGDocumentWrapper->FlushImageTransformInvalidation();
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(ctx); // Already checked the draw target above.
nsRect svgRect;
@ -261,7 +261,7 @@ Maybe<BlobImageKeyData> BlobSurfaceProvider::RecordDrawing(
presShell->RenderDocument(svgRect, renderDocFlags,
NS_RGBA(0, 0, 0, 0), // transparent
ctx);
ctx.get());
}
recorder->FlushItem(imageRectOrigin);

View File

@ -255,7 +255,7 @@ std::pair<ImgDrawResult, RefPtr<SourceSurface>> ClippedImage::GetFrameInternal(
RefPtr<SourceSurface>());
}
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
MOZ_ASSERT(ctx); // already checked the draw target above
// Create our callback.
@ -266,7 +266,7 @@ std::pair<ImgDrawResult, RefPtr<SourceSurface>> ClippedImage::GetFrameInternal(
new gfxCallbackDrawable(drawTileCallback, aSize);
// Actually draw. The callback will end up invoking DrawSingleTile.
gfxUtils::DrawPixelSnapped(ctx, drawable, SizeDouble(aSize),
gfxUtils::DrawPixelSnapped(ctx.get(), drawable, SizeDouble(aSize),
ImageRegion::Create(aSize),
SurfaceFormat::OS_RGBA, SamplingFilter::LINEAR,
imgIContainer::FLAG_CLAMP);

View File

@ -150,11 +150,12 @@ DynamicImage::GetFrameAtSize(const IntSize& aSize, uint32_t aWhichFrame,
<< "DynamicImage::GetFrame failed in CreateOffscreenContentDrawTarget";
return nullptr;
}
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(context); // already checked the draw target above
auto result = Draw(context, aSize, ImageRegion::Create(aSize), aWhichFrame,
SamplingFilter::POINT, SVGImageContext(), aFlags, 1.0);
auto result =
Draw(context.get(), aSize, ImageRegion::Create(aSize), aWhichFrame,
SamplingFilter::POINT, SVGImageContext(), aFlags, 1.0);
return result == ImgDrawResult::SUCCESS ? dt->Snapshot() : nullptr;
}

View File

@ -108,10 +108,10 @@ already_AddRefed<SourceSurface> OrientedImage::OrientSurface(
}
// Draw.
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
MOZ_ASSERT(ctx); // already checked the draw target above
ctx->Multiply(OrientationMatrix(aOrientation, originalSize));
gfxUtils::DrawPixelSnapped(ctx, drawable, SizeDouble(originalSize),
gfxUtils::DrawPixelSnapped(ctx.get(), drawable, SizeDouble(originalSize),
ImageRegion::Create(originalSize), surfaceFormat,
SamplingFilter::LINEAR);

View File

@ -359,9 +359,9 @@ nsresult imgFrame::InitWithDrawable(gfxDrawable* aDrawable,
}
// Draw using the drawable the caller provided.
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
MOZ_ASSERT(ctx); // Already checked the draw target above.
gfxUtils::DrawPixelSnapped(ctx, aDrawable, SizeDouble(mImageSize),
gfxUtils::DrawPixelSnapped(ctx.get(), aDrawable, SizeDouble(mImageSize),
ImageRegion::Create(ThebesRect(GetRect())),
mFormat, aSamplingFilter, aImageFlags);

View File

@ -3080,9 +3080,9 @@ void PresShell::ClearFrameRefs(nsIFrame* aFrame) {
}
}
already_AddRefed<gfxContext> PresShell::CreateReferenceRenderingContext() {
UniquePtr<gfxContext> PresShell::CreateReferenceRenderingContext() {
nsDeviceContext* devCtx = mPresContext->DeviceContext();
RefPtr<gfxContext> rc;
UniquePtr<gfxContext> rc;
if (mPresContext->IsScreen()) {
rc = gfxContext::CreateOrNull(
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget().get());
@ -3093,7 +3093,7 @@ already_AddRefed<gfxContext> PresShell::CreateReferenceRenderingContext() {
rc = devCtx->CreateReferenceRenderingContext();
}
return rc ? rc.forget() : nullptr;
return rc;
}
// https://html.spec.whatwg.org/#scroll-to-the-fragment-identifier
@ -5121,7 +5121,7 @@ already_AddRefed<SourceSurface> PresShell::PaintRangePaintInfo(
return nullptr;
}
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(ctx); // already checked the draw target above
if (aRegion) {
@ -5176,7 +5176,7 @@ already_AddRefed<SourceSurface> PresShell::PaintRangePaintInfo(
ctx->SetMatrixDouble(initialTM.PreTranslate(rootOffset));
aArea.MoveBy(-rangeInfo->mRootOffset.x, -rangeInfo->mRootOffset.y);
nsRegion visible(aArea);
rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, ctx,
rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, ctx.get(),
nsDisplayList::PAINT_DEFAULT, Nothing());
aArea.MoveBy(rangeInfo->mRootOffset.x, rangeInfo->mRootOffset.y);
}
@ -9536,7 +9536,7 @@ bool PresShell::DoReflow(nsIFrame* target, bool aInterruptible,
"non-root frames");
// CreateReferenceRenderingContext can return nullptr
RefPtr<gfxContext> rcx(CreateReferenceRenderingContext());
UniquePtr<gfxContext> rcx(CreateReferenceRenderingContext());
#ifdef DEBUG
mCurrentReflowRoot = target;
@ -9564,7 +9564,7 @@ bool PresShell::DoReflow(nsIFrame* target, bool aInterruptible,
// Don't pass size directly to the reflow input, since a
// constrained height implies page/column breaking.
LogicalSize reflowSize(wm, size.ISize(wm), NS_UNCONSTRAINEDSIZE);
ReflowInput reflowInput(mPresContext, target, rcx, reflowSize,
ReflowInput reflowInput(mPresContext, target, rcx.get(), reflowSize,
ReflowInput::InitFlag::CallerWillInit);
reflowInput.mOrthogonalLimit = size.BSize(wm);
@ -11507,11 +11507,11 @@ PresShell::WindowSizeConstraints PresShell::GetWindowSizeConstraints() {
return {minSize, maxSize};
}
if (rootFrame->IsXULBoxFrame()) {
RefPtr<gfxContext> rcx(CreateReferenceRenderingContext());
UniquePtr<gfxContext> rcx(CreateReferenceRenderingContext());
if (!rcx) {
return {minSize, maxSize};
}
nsBoxLayoutState state(mPresContext, rcx);
nsBoxLayoutState state(mPresContext, rcx.get());
minSize = rootFrame->GetXULMinSize(state);
maxSize = rootFrame->GetXULMaxSize(state);
} else {

View File

@ -590,7 +590,7 @@ class PresShell final : public nsStubDocumentObserver,
* be rendered to, but is suitable for measuring text and performing
* other non-rendering operations. Guaranteed to return non-null.
*/
already_AddRefed<gfxContext> CreateReferenceRenderingContext();
mozilla::UniquePtr<gfxContext> CreateReferenceRenderingContext();
/**
* Scrolls the view of the document so that the given area of a frame

View File

@ -823,7 +823,7 @@ static bool RecomputePosition(nsIFrame* aFrame) {
// the frame, and then get the offsets and size from it. If the frame's size
// doesn't need to change, we can simply update the frame position. Otherwise
// we fall back to a reflow.
RefPtr<gfxContext> rc =
UniquePtr<gfxContext> rc =
aFrame->PresShell()->CreateReferenceRenderingContext();
// Construct a bogus parent reflow input so that there's a usable reflow input
@ -834,7 +834,7 @@ static bool RecomputePosition(nsIFrame* aFrame) {
LogicalSize parentSize = parentFrame->GetLogicalSize();
nsFrameState savedState = parentFrame->GetStateBits();
ReflowInput parentReflowInput(aFrame->PresContext(), parentFrame, rc,
ReflowInput parentReflowInput(aFrame->PresContext(), parentFrame, rc.get(),
parentSize);
parentFrame->RemoveStateBits(~nsFrameState(0));
parentFrame->AddStateBits(savedState);
@ -849,7 +849,7 @@ static bool RecomputePosition(nsIFrame* aFrame) {
parentFrame->IsTableFrame())) {
const auto cbWM = cbFrame->GetWritingMode();
LogicalSize cbSize = cbFrame->GetLogicalSize();
cbReflowInput.emplace(cbFrame->PresContext(), cbFrame, rc, cbSize);
cbReflowInput.emplace(cbFrame->PresContext(), cbFrame, rc.get(), cbSize);
cbReflowInput->SetComputedLogicalMargin(
cbWM, cbFrame->GetLogicalUsedMargin(cbWM));
cbReflowInput->SetComputedLogicalPadding(

View File

@ -2645,14 +2645,14 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsDocumentViewer::GetContentSize(
aMaxHeight = std::min(aMaxHeight, constraints.mMaxSize.height);
aMaxWidth = std::min(aMaxWidth, constraints.mMaxSize.width);
RefPtr<gfxContext> rcx(presShell->CreateReferenceRenderingContext());
UniquePtr<gfxContext> rcx(presShell->CreateReferenceRenderingContext());
const nscoord minISize = wm.IsVertical() ? constraints.mMinSize.height
: constraints.mMinSize.width;
const nscoord maxISize = wm.IsVertical() ? aMaxHeight : aMaxWidth;
if (aPrefWidth) {
prefISize = std::max(root->GetMinISize(rcx), aPrefWidth);
prefISize = std::max(root->GetMinISize(rcx.get()), aPrefWidth);
} else {
prefISize = root->GetPrefISize(rcx);
prefISize = root->GetPrefISize(rcx.get());
}
prefISize = std::max(minISize, std::min(prefISize, maxISize));
}

View File

@ -7156,7 +7156,7 @@ static RefPtr<SourceSurface> ScaleSourceSurface(SourceSurface& aSurface,
return nullptr;
}
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(context);
dt->DrawSurface(&aSurface, Rect(Point(), Size(aTargetSize)),

View File

@ -40,7 +40,7 @@ class LazyReferenceRenderingDrawTargetGetterFromFrame final
explicit LazyReferenceRenderingDrawTargetGetterFromFrame(nsIFrame* aFrame)
: mFrame(aFrame) {}
virtual already_AddRefed<DrawTarget> GetRefDrawTarget() override {
RefPtr<gfxContext> ctx =
UniquePtr<gfxContext> ctx =
mFrame->PresShell()->CreateReferenceRenderingContext();
RefPtr<DrawTarget> dt = ctx->GetDrawTarget();
return dt.forget();
@ -270,8 +270,8 @@ bool nsDisplayTextOverflowMarker::CreateWebRenderCommands(
// Run the rendering algorithm to capture the glyphs and shadows
RefPtr<TextDrawTarget> textDrawer =
new TextDrawTarget(aBuilder, aResources, aSc, aManager, this, bounds);
RefPtr<gfxContext> captureCtx = gfxContext::CreateOrNull(textDrawer);
Paint(aDisplayListBuilder, captureCtx);
UniquePtr<gfxContext> captureCtx = gfxContext::CreateOrNull(textDrawer);
Paint(aDisplayListBuilder, captureCtx.get());
textDrawer->TerminateShadows();
return textDrawer->Finish();
@ -916,7 +916,7 @@ void TextOverflow::Marker::SetupString(nsIFrame* aFrame) {
mISize = 0;
}
} else {
RefPtr<gfxContext> rc =
UniquePtr<gfxContext> rc =
aFrame->PresShell()->CreateReferenceRenderingContext();
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame);

View File

@ -73,13 +73,13 @@ bool nsDisplayColumnRule::CreateWebRenderCommands(
const StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) {
RefPtr<gfxContext> screenRefCtx = gfxContext::CreateOrNull(
UniquePtr<gfxContext> screenRefCtx = gfxContext::CreateOrNull(
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget().get());
bool dummy;
static_cast<nsColumnSetFrame*>(mFrame)->CreateBorderRenderers(
mBorderRenderers, screenRefCtx, GetBounds(aDisplayListBuilder, &dummy),
ToReferenceFrame());
mBorderRenderers, screenRefCtx.get(),
GetBounds(aDisplayListBuilder, &dummy), ToReferenceFrame());
if (mBorderRenderers.IsEmpty()) {
return true;

View File

@ -2703,7 +2703,7 @@ nsFloatManager::ShapeInfo::CreateImageShape(const StyleImage& aShapeImage,
return nullptr;
}
RefPtr<gfxContext> context = gfxContext::CreateOrNull(drawTarget);
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(drawTarget);
MOZ_ASSERT(context); // already checked the target above
ImgDrawResult result =

View File

@ -2048,7 +2048,7 @@ ImgDrawResult nsImageFrame::DisplayAltFeedbackWithoutLayer(
RefPtr<TextDrawTarget> textDrawer =
new TextDrawTarget(aBuilder, aResources, aSc, aManager, aItem, inner,
/* aCallerDoesSaveRestore = */ true);
RefPtr<gfxContext> captureCtx = gfxContext::CreateOrNull(textDrawer);
UniquePtr<gfxContext> captureCtx = gfxContext::CreateOrNull(textDrawer);
nsAutoString altText;
nsCSSFrameConstructor::GetAlternateTextFor(*mContent->AsElement(), altText);

View File

@ -589,7 +589,7 @@ nsresult nsPageSequenceFrame::PrePrintNextSheet(nsITimerCallback* aCallback,
mCalledBeginPage = true;
RefPtr<gfxContext> renderingContext = dc->CreateRenderingContext();
UniquePtr<gfxContext> renderingContext = dc->CreateRenderingContext();
NS_ENSURE_TRUE(renderingContext, NS_ERROR_OUT_OF_MEMORY);
DrawTarget* drawTarget = renderingContext->GetDrawTarget();
@ -684,12 +684,12 @@ nsresult nsPageSequenceFrame::PrintNextSheet() {
mCurrentSheetIdx));
// CreateRenderingContext can fail
RefPtr<gfxContext> gCtx = dc->CreateRenderingContext();
UniquePtr<gfxContext> gCtx = dc->CreateRenderingContext();
NS_ENSURE_TRUE(gCtx, NS_ERROR_OUT_OF_MEMORY);
nsRect drawingRect(nsPoint(0, 0), currentSheetFrame->GetSize());
nsRegion drawingRegion(drawingRect);
nsLayoutUtils::PaintFrame(gCtx, currentSheetFrame, drawingRegion,
nsLayoutUtils::PaintFrame(gCtx.get(), currentSheetFrame, drawingRegion,
NS_RGBA(0, 0, 0, 0),
nsDisplayListBuilderMode::PaintForPrinting,
nsLayoutUtils::PaintFrameFlags::SyncDecodeImages);

View File

@ -2258,7 +2258,7 @@ static gfxFontGroup* GetInflatedFontGroupForFrame(nsTextFrame* aFrame) {
static already_AddRefed<DrawTarget> CreateReferenceDrawTarget(
const nsTextFrame* aTextFrame) {
RefPtr<gfxContext> ctx =
UniquePtr<gfxContext> ctx =
aTextFrame->PresShell()->CreateReferenceRenderingContext();
RefPtr<DrawTarget> dt = ctx->GetDrawTarget();
return dt.forget();

View File

@ -208,14 +208,14 @@ void FallbackRenderer::EndTransactionWithList(nsDisplayListBuilder* aBuilder,
RefPtr<DrawTarget> dest =
gfxPlatform::GetPlatform()->CreateDrawTargetForBackend(
backend, dt->GetSize(), dt->GetFormat());
RefPtr<gfxContext> ctx = gfxContext::CreatePreservingTransformOrNull(dest);
UniquePtr<gfxContext> ctx = gfxContext::CreatePreservingTransformOrNull(dest);
nsRegion opaque = aList->GetOpaqueRegion(aBuilder);
if (opaque.Contains(aList->GetComponentAlphaBounds(aBuilder))) {
dest->SetPermitSubpixelAA(true);
}
aList->Paint(aBuilder, ctx, aAppUnitsPerDevPixel);
aList->Paint(aBuilder, ctx.get(), aAppUnitsPerDevPixel);
RefPtr<SourceSurface> snapshot = dest->Snapshot();
dt->DrawSurface(snapshot, Rect(dest->GetRect()), Rect(dest->GetRect()),

View File

@ -275,7 +275,7 @@ class FallbackRenderer : public WindowRenderer {
int32_t aAppUnitsPerDevPixel,
EndTransactionFlags aFlags);
RefPtr<gfxContext> mTarget;
gfxContext* mTarget;
layers::BufferMode mBufferMode;
};

View File

@ -4687,14 +4687,15 @@ gfxContext* nsContextBoxBlur::Init(const nsRect& aRect, nscoord aSpreadRadius,
bool useHardwareAccel = !(aFlags & DISABLE_HARDWARE_ACCELERATION_BLUR);
if (aSkipRect) {
gfxRect skipRect = transform.TransformBounds(*aSkipRect);
mContext =
mOwnedContext =
mAlphaBoxBlur.Init(aDestinationCtx, rect, spreadRadius, blurRadius,
&dirtyRect, &skipRect, useHardwareAccel);
} else {
mContext =
mOwnedContext =
mAlphaBoxBlur.Init(aDestinationCtx, rect, spreadRadius, blurRadius,
&dirtyRect, nullptr, useHardwareAccel);
}
mContext = mOwnedContext.get();
if (mContext) {
// we don't need to blur if skipRect is equal to rect

View File

@ -942,7 +942,8 @@ class nsContextBoxBlur {
bool aConstrainSpreadRadius = true);
gfxAlphaBoxBlur mAlphaBoxBlur;
RefPtr<gfxContext> mContext;
mozilla::UniquePtr<gfxContext> mOwnedContext;
gfxContext* mContext; // may be either mOwnedContext or mDestinationContext
gfxContext* mDestinationCtx;
/* This is true if the blur already has it's content transformed

View File

@ -1155,7 +1155,7 @@ bool nsCSSGradientRenderer::TryPaintTilesWithExtendMode(
return false;
}
RefPtr<gfxContext> tileContext = gfxContext::CreateOrNull(tileTarget);
UniquePtr<gfxContext> tileContext = gfxContext::CreateOrNull(tileTarget);
tileContext->SetPattern(aGradientPattern);
tileContext->Paint();

View File

@ -315,14 +315,14 @@ static bool GenerateAndPushTextMask(nsIFrame* aFrame, gfxContext* aContext,
if (!maskDT || !maskDT->IsValid()) {
return false;
}
RefPtr<gfxContext> maskCtx =
UniquePtr<gfxContext> maskCtx =
gfxContext::CreatePreservingTransformOrNull(maskDT);
MOZ_ASSERT(maskCtx);
maskCtx->Multiply(Matrix::Translation(bounds.TopLeft().ToUnknownPoint()));
// Shade text shape into mask A8 surface.
nsLayoutUtils::PaintFrame(
maskCtx, aFrame, nsRect(nsPoint(0, 0), aFrame->GetSize()),
maskCtx.get(), aFrame, nsRect(nsPoint(0, 0), aFrame->GetSize()),
NS_RGB(255, 255, 255), nsDisplayListBuilderMode::GenerateGlyph);
// Push the generated mask into aContext, so that the caller can pop and
@ -5066,9 +5066,9 @@ void nsDisplayBlendMode::Paint(nsDisplayListBuilder* aBuilder,
return;
}
RefPtr<gfxContext> ctx = gfxContext::CreatePreservingTransformOrNull(temp);
UniquePtr<gfxContext> ctx = gfxContext::CreatePreservingTransformOrNull(temp);
GetChildren()->Paint(aBuilder, ctx,
GetChildren()->Paint(aBuilder, ctx.get(),
mFrame->PresContext()->AppUnitsPerDevPixel());
// Draw the temporary DT to the real destination, applying the blend mode, but
@ -6869,7 +6869,7 @@ void nsDisplayTransform::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
untransformedDT->SetTransform(
Matrix::Translation(-Point(pixelBounds.X(), pixelBounds.Y())));
RefPtr<gfxContext> groupTarget =
UniquePtr<gfxContext> groupTarget =
gfxContext::CreatePreservingTransformOrNull(untransformedDT);
if (aPolygon) {
@ -6878,7 +6878,7 @@ void nsDisplayTransform::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
aCtx->GetDrawTarget()->PushClip(path);
}
GetChildren()->Paint(aBuilder, groupTarget,
GetChildren()->Paint(aBuilder, groupTarget.get(),
mFrame->PresContext()->AppUnitsPerDevPixel());
if (aPolygon) {
@ -7543,8 +7543,8 @@ bool nsDisplayText::CreateWebRenderCommands(
bounds = bounds.Intersect(visible);
}
RefPtr<gfxContext> textDrawer = aBuilder.GetTextContext(
aResources, aSc, aManager, this, bounds, deviceOffset);
gfxContext* textDrawer = aBuilder.GetTextContext(aResources, aSc, aManager,
this, bounds, deviceOffset);
aBuilder.StartGroup(this);

View File

@ -474,7 +474,8 @@ ImgDrawResult nsImageRenderer::Draw(nsPresContext* aPresContext,
SamplingFilter samplingFilter =
nsLayoutUtils::GetSamplingFilterForFrame(mForFrame);
ImgDrawResult result = ImgDrawResult::SUCCESS;
RefPtr<gfxContext> ctx = &aRenderingContext;
gfxContext* ctx = &aRenderingContext;
UniquePtr<gfxContext> tempCtx;
IntRect tmpDTRect;
if (ctx->CurrentOp() != CompositionOp::OP_OVER ||
@ -493,7 +494,8 @@ ImgDrawResult nsImageRenderer::Draw(nsPresContext* aPresContext,
}
tempDT->SetTransform(ctx->GetDrawTarget()->GetTransform() *
Matrix::Translation(-tmpDTRect.TopLeft()));
ctx = gfxContext::CreatePreservingTransformOrNull(tempDT);
tempCtx = gfxContext::CreatePreservingTransformOrNull(tempDT);
ctx = tempCtx.get();
if (!ctx) {
gfxDevCrash(LogReason::InvalidContext)
<< "ImageRenderer::Draw problem " << gfx::hexa(tempDT);

View File

@ -20,7 +20,7 @@ namespace layout {
PrintTranslator::PrintTranslator(nsDeviceContext* aDeviceContext)
: mDeviceContext(aDeviceContext) {
RefPtr<gfxContext> context =
UniquePtr<gfxContext> context =
mDeviceContext->CreateReferenceRenderingContext();
mBaseDT = context->GetDrawTarget();
}
@ -71,7 +71,7 @@ bool PrintTranslator::TranslateRecording(PRFileDescStream& aRecording) {
already_AddRefed<DrawTarget> PrintTranslator::CreateDrawTarget(
ReferencePtr aRefPtr, const gfx::IntSize& aSize,
gfx::SurfaceFormat aFormat) {
RefPtr<gfxContext> context = mDeviceContext->CreateRenderingContext();
UniquePtr<gfxContext> context = mDeviceContext->CreateRenderingContext();
if (!context) {
NS_WARNING("Failed to create rendering context for print.");
return nullptr;

View File

@ -636,17 +636,18 @@ void FilterInstance::BuildSourcePaint(SourceInfo* aSource,
return;
}
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(offscreenDT);
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(offscreenDT);
MOZ_ASSERT(ctx); // already checked the draw target above
gfxContextAutoSaveRestore saver(ctx);
gfxContextAutoSaveRestore saver(ctx.get());
ctx->SetMatrixDouble(mPaintTransform *
gfxMatrix::Translation(-neededRect.TopLeft()));
GeneralPattern pattern;
if (aSource == &mFillPaint) {
SVGUtils::MakeFillPatternFor(mTargetFrame, ctx, &pattern, aImgParams);
SVGUtils::MakeFillPatternFor(mTargetFrame, ctx.get(), &pattern, aImgParams);
} else if (aSource == &mStrokePaint) {
SVGUtils::MakeStrokePatternFor(mTargetFrame, ctx, &pattern, aImgParams);
SVGUtils::MakeStrokePatternFor(mTargetFrame, ctx.get(), &pattern,
aImgParams);
}
if (pattern.GetPattern()) {
@ -707,7 +708,7 @@ 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.)
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(offscreenDT);
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(offscreenDT);
MOZ_ASSERT(ctx); // already checked the draw target above
gfxMatrix devPxToCssPxTM = SVGUtils::GetCSSPxToDevPxMatrix(mTargetFrame);
DebugOnly<bool> invertible = devPxToCssPxTM.Invert();

View File

@ -232,7 +232,7 @@ already_AddRefed<SourceSurface> SVGClipPathFrame::GetClipMask(
return nullptr;
}
RefPtr<gfxContext> maskContext =
UniquePtr<gfxContext> maskContext =
gfxContext::CreatePreservingTransformOrNull(maskDT);
if (!maskContext) {
gfxCriticalError() << "SVGClipPath context problem " << gfx::hexa(maskDT);

View File

@ -464,13 +464,13 @@ void SVGForeignObjectFrame::DoReflow() {
}
// initiate a synchronous reflow here and now:
RefPtr<gfxContext> renderingContext =
UniquePtr<gfxContext> renderingContext =
presContext->PresShell()->CreateReferenceRenderingContext();
mInReflow = true;
WritingMode wm = kid->GetWritingMode();
ReflowInput reflowInput(presContext, kid, renderingContext,
ReflowInput reflowInput(presContext, kid, renderingContext.get(),
LogicalSize(wm, ISize(wm), NS_UNCONSTRAINEDSIZE));
ReflowOutput desiredSize(reflowInput);
nsReflowStatus status;

View File

@ -466,7 +466,7 @@ static bool PaintMaskSurface(const PaintFramesParams& aParams,
gfxPoint devPixelOffsetToUserSpace = nsLayoutUtils::PointToGfxPoint(
aOffsetToUserSpace, presContext->AppUnitsPerDevPixel());
RefPtr<gfxContext> maskContext =
UniquePtr<gfxContext> maskContext =
gfxContext::CreatePreservingTransformOrNull(aMaskDT);
MOZ_ASSERT(maskContext);
@ -498,7 +498,7 @@ static bool PaintMaskSurface(const PaintFramesParams& aParams,
aMaskDT->SetTransform(tmp);
}
} else if (svgReset->mMask.mLayers[i].mImage.IsResolved()) {
gfxContextMatrixAutoSaveRestore matRestore(maskContext);
gfxContextMatrixAutoSaveRestore matRestore(maskContext.get());
maskContext->Multiply(gfxMatrix::Translation(-devPixelOffsetToUserSpace));
nsCSSRendering::PaintBGParams params =

View File

@ -78,7 +78,7 @@ already_AddRefed<SourceSurface> SVGMaskFrame::GetMaskForMaskedFrame(
return nullptr;
}
RefPtr<gfxContext> tmpCtx =
UniquePtr<gfxContext> tmpCtx =
gfxContext::CreatePreservingTransformOrNull(maskDT);
MOZ_ASSERT(tmpCtx); // already checked the draw target above

View File

@ -338,7 +338,7 @@ already_AddRefed<SourceSurface> SVGPatternFrame::PaintPattern(
}
dt->ClearRect(Rect(0, 0, surfaceSize.width, surfaceSize.height));
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(ctx); // already checked the draw target above
if (aGraphicOpacity != 1.0f) {

View File

@ -5124,7 +5124,7 @@ void SVGTextFrame::DoReflow() {
return;
}
RefPtr<gfxContext> renderingContext =
UniquePtr<gfxContext> renderingContext =
presContext->PresShell()->CreateReferenceRenderingContext();
if (UpdateFontSizeScaleFactor()) {
@ -5133,9 +5133,9 @@ void SVGTextFrame::DoReflow() {
kid->MarkIntrinsicISizesDirty();
}
nscoord inlineSize = kid->GetPrefISize(renderingContext);
nscoord inlineSize = kid->GetPrefISize(renderingContext.get());
WritingMode wm = kid->GetWritingMode();
ReflowInput reflowInput(presContext, kid, renderingContext,
ReflowInput reflowInput(presContext, kid, renderingContext.get(),
LogicalSize(wm, inlineSize, NS_UNCONSTRAINEDSIZE));
ReflowOutput desiredSize(reflowInput);
nsReflowStatus status;

View File

@ -508,7 +508,7 @@ class MixModeBlender {
mTargetOffset = drawRect.TopLeft();
return mTargetCtx;
return mTargetCtx.get();
}
void BlendToTarget() {
@ -564,7 +564,7 @@ class MixModeBlender {
nsIFrame* mFrame;
gfxContext* mSourceCtx;
RefPtr<gfxContext> mTargetCtx;
UniquePtr<gfxContext> mTargetCtx;
IntPoint mTargetOffset;
};

View File

@ -546,9 +546,9 @@ nsresult nsSplitterFrameInner::MouseDown(Event* aMouseEvent) {
// get our index
nsPresContext* outerPresContext = mOuter->PresContext();
RefPtr<gfxContext> rc =
UniquePtr<gfxContext> rc =
outerPresContext->PresShell()->CreateReferenceRenderingContext();
nsBoxLayoutState state(outerPresContext, rc);
nsBoxLayoutState state(outerPresContext, rc.get());
mDidDrag = false;

View File

@ -302,10 +302,10 @@ bool nsDisplayXULTextBox::CreateWebRenderCommands(
RefPtr<mozilla::layout::TextDrawTarget> textDrawer =
new mozilla::layout::TextDrawTarget(aBuilder, aResources, aSc, aManager,
this, bounds);
RefPtr<gfxContext> captureCtx =
UniquePtr<gfxContext> captureCtx =
gfxContext::CreateOrNull(textDrawer, deviceOffset);
Paint(aDisplayListBuilder, captureCtx);
Paint(aDisplayListBuilder, captureCtx.get());
textDrawer->TerminateShadows();
return textDrawer->Finish();
@ -469,7 +469,7 @@ void nsTextBoxFrame::DrawText(gfxContext& aRenderingContext,
}
}
RefPtr<gfxContext> refContext =
UniquePtr<gfxContext> refContext =
PresShell()->CreateReferenceRenderingContext();
DrawTarget* refDrawTarget = refContext->GetDrawTarget();

View File

@ -213,14 +213,15 @@ nscoord nsTreeBodyFrame::CalcMaxRowWidth() {
nscoord rowWidth;
nsTreeColumn* col;
RefPtr<gfxContext> rc = PresShell()->CreateReferenceRenderingContext();
UniquePtr<gfxContext> rc = PresShell()->CreateReferenceRenderingContext();
for (int32_t row = 0; row < mRowCount; ++row) {
rowWidth = 0;
for (col = mColumns->GetFirstColumn(); col; col = col->GetNext()) {
nscoord desiredWidth, currentWidth;
nsresult rv = GetCellWidth(row, col, rc, desiredWidth, currentWidth);
nsresult rv =
GetCellWidth(row, col, rc.get(), desiredWidth, currentWidth);
if (NS_FAILED(rv)) {
MOZ_ASSERT_UNREACHABLE("invalid column");
continue;
@ -1004,7 +1005,7 @@ nsresult nsTreeBodyFrame::GetCoordsForCellItem(int32_t aRow, nsTreeColumn* aCol,
// interfere with our computations.
AdjustForBorderPadding(cellContext, cellRect);
RefPtr<gfxContext> rc =
UniquePtr<gfxContext> rc =
presContext->PresShell()->CreateReferenceRenderingContext();
// Now we'll start making our way across the cell, starting at the edge of
@ -1263,7 +1264,7 @@ nsCSSAnonBoxPseudoStaticAtom* nsTreeBodyFrame::GetItemWithinCellAt(
bool isRTL = StyleVisibility()->mDirection == StyleDirection::Rtl;
nsPresContext* presContext = PresContext();
RefPtr<gfxContext> rc =
UniquePtr<gfxContext> rc =
presContext->PresShell()->CreateReferenceRenderingContext();
if (aColumn->IsPrimary()) {
@ -1504,9 +1505,9 @@ nsresult nsTreeBodyFrame::IsCellCropped(int32_t aRow, nsTreeColumn* aCol,
if (!aCol) return NS_ERROR_INVALID_ARG;
RefPtr<gfxContext> rc = PresShell()->CreateReferenceRenderingContext();
UniquePtr<gfxContext> rc = PresShell()->CreateReferenceRenderingContext();
rv = GetCellWidth(aRow, aCol, rc, desiredSize, currentSize);
rv = GetCellWidth(aRow, aCol, rc.get(), desiredSize, currentSize);
NS_ENSURE_SUCCESS(rv, rv);
*_retval = desiredSize > currentSize;

View File

@ -1316,7 +1316,7 @@ bool nsChildView::PaintWindow(LayoutDeviceIntRegion aRegion) {
bool nsChildView::PaintWindowInDrawTarget(gfx::DrawTarget* aDT,
const LayoutDeviceIntRegion& aRegion,
const gfx::IntSize& aSurfaceSize) {
RefPtr<gfxContext> targetContext = gfxContext::CreateOrNull(aDT);
UniquePtr<gfxContext> targetContext = gfxContext::CreateOrNull(aDT);
MOZ_ASSERT(targetContext);
// Set up the clip region and clear existing contents in the backing surface.
@ -1330,7 +1330,7 @@ bool nsChildView::PaintWindowInDrawTarget(gfx::DrawTarget* aDT,
nsAutoRetainCocoaObject kungFuDeathGrip(mView);
if (GetWindowRenderer()->GetBackendType() == LayersBackend::LAYERS_NONE) {
nsBaseWidget::AutoLayerManagerSetup setupLayerManager(this, targetContext,
nsBaseWidget::AutoLayerManagerSetup setupLayerManager(this, targetContext.get(),
BufferMode::BUFFER_NONE);
return PaintWindow(aRegion);
}

View File

@ -494,7 +494,7 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(imgIContainer* aImage, ui
return NS_ERROR_FAILURE;
}
RefPtr<gfxContext> context = gfxContext::CreateOrNull(drawTarget);
UniquePtr<gfxContext> context = gfxContext::CreateOrNull(drawTarget);
MOZ_ASSERT(context);
SVGImageContext svgContext;
@ -502,7 +502,7 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(imgIContainer* aImage, ui
SVGImageContext::MaybeStoreContextPaint(svgContext, *aPresContext, *aComputedStyle, aImage);
}
mozilla::image::ImgDrawResult res =
aImage->Draw(context, scaledSize, ImageRegion::Create(scaledSize), aWhichFrame,
aImage->Draw(context.get(), scaledSize, ImageRegion::Create(scaledSize), aWhichFrame,
SamplingFilter::POINT, svgContext, imgIContainer::FLAG_SYNC_DECODE, 1.0);
if (res != mozilla::image::ImgDrawResult::SUCCESS) {

View File

@ -3852,7 +3852,7 @@ gboolean nsWindow::OnExposeEvent(cairo_t* cr) {
if (!dt || !dt->IsValid()) {
return FALSE;
}
RefPtr<gfxContext> ctx;
UniquePtr<gfxContext> ctx;
IntRect boundsRect = region.GetBounds().ToUnknownRect();
IntPoint offset(0, 0);
if (dt->GetSize() == boundsRect.Size()) {
@ -3908,7 +3908,7 @@ gboolean nsWindow::OnExposeEvent(cairo_t* cr) {
// reused SHM image. See bug 1258086.
dt->ClearRect(Rect(boundsRect));
}
AutoLayerManagerSetup setupLayerManager(this, ctx, layerBuffering);
AutoLayerManagerSetup setupLayerManager(this, ctx.get(), layerBuffering);
painted = listener->PaintWindow(this, region);
// Re-get the listener since the will paint notification might have

View File

@ -940,11 +940,11 @@ nsresult nsBaseDragService::DrawDragForImage(
destSize, SurfaceFormat::B8G8R8A8);
if (!dt || !dt->IsValid()) return NS_ERROR_FAILURE;
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
if (!ctx) return NS_ERROR_FAILURE;
ImgDrawResult res = imgContainer->Draw(
ctx, destSize, ImageRegion::Create(destSize),
ctx.get(), 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 ||

View File

@ -317,7 +317,7 @@ class nsAutoRetainUIKitObject {
// Create Cairo objects.
RefPtr<gfxQuartzSurface> targetSurface;
RefPtr<gfxContext> targetContext;
UniquePtrPtr<gfxContext> targetContext;
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BackendType::CAIRO)) {
// This is dead code unless you mess with prefs, but keep it around for
// debugging.

View File

@ -1427,12 +1427,12 @@ nsNativeThemeWin::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
return NS_OK;
}
RefPtr<gfxContext> ctx = aContext;
gfxContextMatrixAutoSaveRestore save(ctx);
gfxContextMatrixAutoSaveRestore save(aContext);
double themeScale = GetThemeDpiScaleFactor(aFrame);
if (themeScale != 1.0) {
ctx->SetMatrix(ctx->CurrentMatrix().PreScale(themeScale, themeScale));
aContext->SetMatrix(
aContext->CurrentMatrix().PreScale(themeScale, themeScale));
}
gfxFloat p2a = gfxFloat(aFrame->PresContext()->AppUnitsPerDevPixel());
@ -1446,7 +1446,7 @@ nsNativeThemeWin::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
dr.Scale(1.0 / (p2a * themeScale));
gfxWindowsNativeDrawing nativeDrawing(
ctx, dr, GetWidgetNativeDrawingFlags(aAppearance));
aContext, dr, GetWidgetNativeDrawingFlags(aAppearance));
RENDER_AGAIN:
@ -3109,10 +3109,8 @@ nsresult nsNativeThemeWin::ClassicDrawWidgetBackground(
tr.Scale(1.0 / p2a);
dr.Scale(1.0 / p2a);
RefPtr<gfxContext> ctx = aContext;
gfxWindowsNativeDrawing nativeDrawing(
ctx, dr, GetWidgetNativeDrawingFlags(aAppearance));
aContext, dr, GetWidgetNativeDrawingFlags(aAppearance));
RENDER_AGAIN:

View File

@ -307,11 +307,11 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel) {
break;
}
RefPtr<gfxContext> thebesContext = gfxContext::CreateOrNull(dt);
UniquePtr<gfxContext> thebesContext = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(thebesContext); // already checked draw target above
{
AutoLayerManagerSetup setupLayerManager(this, thebesContext,
AutoLayerManagerSetup setupLayerManager(this, thebesContext.get(),
doubleBuffering);
result = listener->PaintWindow(this, region);
}