mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1276824 (part 1) - Rename gfxContext::ForDrawTarget{,WithTransform}(). r=milan.
The new names Create{,PreservingTransform}OrNull() better communicate that these functions (a) do object creation, and (b) are fallible. --HG-- extra : rebase_source : a36bd9a2bcdfae281868959403f811f2bc690ad4
This commit is contained in:
parent
6e099bf9a4
commit
a02611e830
@ -3605,7 +3605,7 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
|
||||
if (mOp == CanvasRenderingContext2D::TextDrawOperation::FILL &&
|
||||
mState->StyleIsColor(CanvasRenderingContext2D::Style::FILL)) {
|
||||
RefPtr<gfxContext> thebes =
|
||||
gfxContext::ForDrawTargetWithTransform(mCtx->mTarget);
|
||||
gfxContext::CreatePreservingTransformOrNull(mCtx->mTarget);
|
||||
nscolor fill = mState->colorStyles[CanvasRenderingContext2D::Style::FILL];
|
||||
thebes->SetColor(Color::FromABGR(fill));
|
||||
gfxTextRun::DrawParams params(thebes);
|
||||
@ -4788,7 +4788,7 @@ CanvasRenderingContext2D::DrawDirectlyToCanvas(
|
||||
// the matrix even though this is a temp gfxContext.
|
||||
AutoRestoreTransform autoRestoreTransform(mTarget);
|
||||
|
||||
RefPtr<gfxContext> context = gfxContext::ForDrawTarget(tempTarget);
|
||||
RefPtr<gfxContext> context = gfxContext::CreateOrNull(tempTarget);
|
||||
if (!context) {
|
||||
gfxDevCrash(LogReason::InvalidContext) << "Canvas context problem";
|
||||
return;
|
||||
@ -4991,7 +4991,7 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& aWindow, double aX,
|
||||
GlobalAlpha() == 1.0f &&
|
||||
UsedOperation() == CompositionOp::OP_OVER)
|
||||
{
|
||||
thebes = gfxContext::ForDrawTarget(mTarget);
|
||||
thebes = gfxContext::CreateOrNull(mTarget);
|
||||
MOZ_ASSERT(thebes); // alrady checked the draw target above
|
||||
thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
|
||||
matrix._22, matrix._31, matrix._32));
|
||||
@ -5004,7 +5004,7 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& aWindow, double aX,
|
||||
return;
|
||||
}
|
||||
|
||||
thebes = gfxContext::ForDrawTarget(drawDT);
|
||||
thebes = gfxContext::CreateOrNull(drawDT);
|
||||
MOZ_ASSERT(thebes); // alrady checked the draw target above
|
||||
thebes->SetMatrix(gfxMatrix::Scaling(matrix._11, matrix._22));
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ DocumentRendererChild::RenderDocument(nsPIDOMWindowOuter* window,
|
||||
gfxWarning() << "DocumentRendererChild::RenderDocument failed to Factory::CreateDrawTargetForData";
|
||||
return false;
|
||||
}
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
ctx->SetMatrix(mozilla::gfx::ThebesMatrix(transform));
|
||||
|
||||
|
@ -299,7 +299,7 @@ MediaEngineTabVideoSource::Draw() {
|
||||
if (!dt || !dt->IsValid()) {
|
||||
return;
|
||||
}
|
||||
RefPtr<gfxContext> context = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context); // already checked the draw target above
|
||||
context->SetMatrix(context->CurrentMatrix().Scale((((float) size.width)/mViewportWidth),
|
||||
(((float) size.height)/mViewportHeight)));
|
||||
|
@ -110,7 +110,8 @@ BasicLayerManager::PushGroupForLayer(gfxContext* aContext, Layer* aLayer, const
|
||||
if (!surfRect.IsEmpty()) {
|
||||
RefPtr<DrawTarget> dt = aContext->GetDrawTarget()->CreateSimilarDrawTarget(surfRect.Size(), SurfaceFormat::B8G8R8A8);
|
||||
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(dt, ToRect(rect).TopLeft());
|
||||
RefPtr<gfxContext> ctx =
|
||||
gfxContext::CreateOrNull(dt, ToRect(rect).TopLeft());
|
||||
if (!ctx) {
|
||||
gfxDevCrash(LogReason::InvalidContext) << "BasicLayerManager context problem " << gfx::hexa(dt);
|
||||
return group;
|
||||
@ -923,8 +924,8 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<gfxContext> groupTarget = gfxContext::ForDrawTarget(untransformedDT,
|
||||
Point(bounds.x, bounds.y));
|
||||
RefPtr<gfxContext> groupTarget = gfxContext::CreateOrNull(untransformedDT,
|
||||
Point(bounds.x, bounds.y));
|
||||
MOZ_ASSERT(groupTarget); // already checked the target above
|
||||
|
||||
PaintSelfOrChildren(paintLayerContext, groupTarget);
|
||||
@ -939,8 +940,8 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
|
||||
(aLayer->GetDebugColorIndex() & 2) ? 1.f : 0.f,
|
||||
(aLayer->GetDebugColorIndex() & 4) ? 1.f : 0.f);
|
||||
|
||||
RefPtr<gfxContext> temp = gfxContext::ForDrawTarget(untransformedDT,
|
||||
Point(bounds.x, bounds.y));
|
||||
RefPtr<gfxContext> temp =
|
||||
gfxContext::CreateOrNull(untransformedDT, Point(bounds.x, bounds.y));
|
||||
MOZ_ASSERT(temp); // already checked for target above
|
||||
temp->SetColor(color);
|
||||
temp->Paint();
|
||||
|
@ -174,7 +174,7 @@ BasicPaintedLayer::Validate(LayerManager::DrawPaintedLayerCallback aCallback,
|
||||
|
||||
RenderTraceInvalidateStart(this, "FFFF00", state.mRegionToDraw.GetBounds());
|
||||
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTargetWithTransform(target);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreatePreservingTransformOrNull(target);
|
||||
MOZ_ASSERT(ctx); // already checked the target above
|
||||
|
||||
PaintBuffer(ctx,
|
||||
|
@ -89,7 +89,7 @@ ClientPaintedLayer::PaintThebes()
|
||||
|
||||
SetAntialiasingFlags(this, target);
|
||||
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTargetWithTransform(target);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreatePreservingTransformOrNull(target);
|
||||
MOZ_ASSERT(ctx); // already checked the target above
|
||||
|
||||
ClientManager()->GetPaintedLayerCallback()(this,
|
||||
|
@ -178,7 +178,7 @@ ClientSingleTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion,
|
||||
}
|
||||
|
||||
{
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
if (!ctx) {
|
||||
gfxDevCrash(gfx::LogReason::InvalidContext) << "SingleTiledContextClient context problem " << gfx::hexa(dt);
|
||||
return;
|
||||
|
@ -811,7 +811,7 @@ ClientMultiTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion,
|
||||
return;
|
||||
}
|
||||
|
||||
ctxt = gfxContext::ForDrawTarget(mSinglePaintDrawTarget);
|
||||
ctxt = gfxContext::CreateOrNull(mSinglePaintDrawTarget);
|
||||
MOZ_ASSERT(ctxt); // already checked draw target above
|
||||
|
||||
mSinglePaintBufferOffset = nsIntPoint(bounds.x, bounds.y);
|
||||
@ -1039,7 +1039,7 @@ void ClientMultiTiledLayerBuffer::Update(const nsIntRegion& newValidRegion,
|
||||
}
|
||||
drawTarget->SetTransform(Matrix());
|
||||
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(drawTarget);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(drawTarget);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
ctx->SetMatrix(
|
||||
ctx->CurrentMatrix().Scale(mResolution, mResolution).Translate(ThebesPoint(-mTilingOrigin)));
|
||||
|
@ -368,7 +368,7 @@ nsDeviceContext::CreateRenderingContext()
|
||||
#endif
|
||||
dt->AddUserData(&sDisablePixelSnapping, (void*)0x1, nullptr);
|
||||
|
||||
RefPtr<gfxContext> pContext = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> pContext = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(pContext); // already checked draw target above
|
||||
|
||||
gfxMatrix transform;
|
||||
|
@ -192,7 +192,7 @@ MakeContext ()
|
||||
RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
|
||||
CreateOffscreenContentDrawTarget(IntSize(size, size),
|
||||
SurfaceFormat::B8G8R8X8);
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(drawTarget);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(drawTarget);
|
||||
|
||||
return ctx.forget();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ MakeContext ()
|
||||
RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
|
||||
CreateOffscreenContentDrawTarget(IntSize(size, size),
|
||||
SurfaceFormat::B8G8R8X8);
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(drawTarget);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(drawTarget);
|
||||
|
||||
return ctx.forget();
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect,
|
||||
IntRect irect = mBlur->GetRect();
|
||||
gfxPoint topleft(irect.TopLeft().x, irect.TopLeft().y);
|
||||
|
||||
mContext = gfxContext::ForDrawTarget(dt);
|
||||
mContext = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(mContext); // already checked for target above
|
||||
mContext->SetMatrix(gfxMatrix::Translation(-topleft));
|
||||
|
||||
|
@ -85,11 +85,11 @@ gfxContext::gfxContext(DrawTarget *aTarget, const Point& aDeviceOffset)
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<gfxContext>
|
||||
gfxContext::ForDrawTarget(DrawTarget* aTarget,
|
||||
const mozilla::gfx::Point& aDeviceOffset)
|
||||
gfxContext::CreateOrNull(DrawTarget* aTarget,
|
||||
const mozilla::gfx::Point& aDeviceOffset)
|
||||
{
|
||||
if (!aTarget || !aTarget->IsValid()) {
|
||||
gfxCriticalNote << "Invalid target in gfxContext::ForDrawTarget " << hexa(aTarget);
|
||||
gfxCriticalNote << "Invalid target in gfxContext::CreateOrNull " << hexa(aTarget);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -98,10 +98,10 @@ gfxContext::ForDrawTarget(DrawTarget* aTarget,
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<gfxContext>
|
||||
gfxContext::ForDrawTargetWithTransform(DrawTarget* aTarget)
|
||||
gfxContext::CreatePreservingTransformOrNull(DrawTarget* aTarget)
|
||||
{
|
||||
if (!aTarget || !aTarget->IsValid()) {
|
||||
gfxCriticalNote << "Invalid target in gfxContext::ForDrawTargetWithTransform " << hexa(aTarget);
|
||||
gfxCriticalNote << "Invalid target in gfxContext::CreatePreservingTransformOrNull " << hexa(aTarget);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -65,9 +65,9 @@ public:
|
||||
* is responsible for handling this scenario as appropriate.
|
||||
*/
|
||||
static already_AddRefed<gfxContext>
|
||||
ForDrawTarget(mozilla::gfx::DrawTarget* aTarget,
|
||||
const mozilla::gfx::Point& aDeviceOffset = mozilla::gfx::Point());
|
||||
|
||||
CreateOrNull(mozilla::gfx::DrawTarget* aTarget,
|
||||
const mozilla::gfx::Point& aDeviceOffset = mozilla::gfx::Point());
|
||||
|
||||
/**
|
||||
* Create a new gfxContext wrapping aTarget and preserving aTarget's
|
||||
* transform. Note that the transform is moved from aTarget to the resulting
|
||||
@ -76,7 +76,7 @@ public:
|
||||
* is responsible for handling this scenario as appropriate.
|
||||
*/
|
||||
static already_AddRefed<gfxContext>
|
||||
ForDrawTargetWithTransform(mozilla::gfx::DrawTarget* aTarget);
|
||||
CreatePreservingTransformOrNull(mozilla::gfx::DrawTarget* aTarget);
|
||||
|
||||
mozilla::gfx::DrawTarget *GetDrawTarget() { return mDT; }
|
||||
|
||||
|
@ -125,7 +125,7 @@ gfxCallbackDrawable::MakeSurfaceDrawable(const SamplingFilter aSamplingFilter)
|
||||
if (!dt || !dt->IsValid())
|
||||
return nullptr;
|
||||
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(ctx); // already checked for target above
|
||||
Draw(ctx, gfxRect(0, 0, mSize.width, mSize.height), ExtendMode::CLAMP,
|
||||
aSamplingFilter);
|
||||
|
@ -449,7 +449,7 @@ CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<gfxContext> tmpCtx = gfxContext::ForDrawTarget(target);
|
||||
RefPtr<gfxContext> tmpCtx = gfxContext::CreateOrNull(target);
|
||||
MOZ_ASSERT(tmpCtx); // already checked the target above
|
||||
|
||||
tmpCtx->SetOp(OptimalFillOp());
|
||||
@ -599,7 +599,7 @@ PrescaleAndTileDrawable(gfxDrawable* aDrawable,
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<gfxContext> tmpCtx = gfxContext::ForDrawTarget(scaledDT);
|
||||
RefPtr<gfxContext> tmpCtx = gfxContext::CreateOrNull(scaledDT);
|
||||
MOZ_ASSERT(tmpCtx); // already checked the target above
|
||||
|
||||
scaledDT->SetTransform(ToMatrix(scaleMatrix));
|
||||
@ -1214,7 +1214,7 @@ gfxUtils::WriteAsPNG(nsIPresShell* aShell, const char* aFile)
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
NS_ENSURE_TRUE(dt && dt->IsValid(), /*void*/);
|
||||
|
||||
RefPtr<gfxContext> context = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context); // already checked the draw target above
|
||||
aShell->RenderDocument(r, 0, NS_RGB(255, 255, 0), context);
|
||||
WriteAsPNG(dt.get(), aFile);
|
||||
|
@ -295,7 +295,7 @@ ClippedImage::GetFrameInternal(const nsIntSize& aSize,
|
||||
return MakePair(DrawResult::TEMPORARY_ERROR, RefPtr<SourceSurface>());
|
||||
}
|
||||
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(target);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
|
||||
// Create our callback.
|
||||
|
@ -185,7 +185,7 @@ DynamicImage::GetFrameAtSize(const IntSize& aSize,
|
||||
"DynamicImage::GetFrame failed in CreateOffscreenContentDrawTarget";
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<gfxContext> context = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context); // already checked the draw target above
|
||||
|
||||
auto result = Draw(context, aSize, ImageRegion::Create(aSize),
|
||||
|
@ -113,7 +113,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
|
||||
new gfxSurfaceDrawable(innerSurface, size);
|
||||
|
||||
// Draw.
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(target);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
ctx->Multiply(OrientationMatrix(size));
|
||||
gfxUtils::DrawPixelSnapped(ctx, drawable, size, ImageRegion::Create(size),
|
||||
|
@ -735,7 +735,7 @@ VectorImage::GetFrameAtSize(const IntSize& aSize,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<gfxContext> context = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context); // already checked the draw target above
|
||||
|
||||
auto result = Draw(context, aSize, ImageRegion::Create(aSize),
|
||||
|
@ -301,7 +301,7 @@ imgFrame::InitWithDrawable(gfxDrawable* aDrawable,
|
||||
}
|
||||
|
||||
// Draw using the drawable the caller provided.
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(target);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
|
||||
MOZ_ASSERT(ctx); // Already checked the draw target above.
|
||||
gfxUtils::DrawPixelSnapped(ctx, aDrawable, mFrameRect.Size(),
|
||||
ImageRegion::Create(ThebesRect(mFrameRect)),
|
||||
|
@ -3543,7 +3543,7 @@ PaintInactiveLayer(nsDisplayListBuilder* aBuilder,
|
||||
itemVisibleRect.Size(),
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
if (tempDT) {
|
||||
context = gfxContext::ForDrawTarget(tempDT);
|
||||
context = gfxContext::CreateOrNull(tempDT);
|
||||
if (!context) {
|
||||
// Leave this as crash, it's in the debugging code, we want to know
|
||||
gfxDevCrash(LogReason::InvalidContext) << "PaintInactive context problem " << gfx::hexa(tempDT);
|
||||
@ -5518,7 +5518,7 @@ static void DebugPaintItem(DrawTarget& aDrawTarget,
|
||||
RefPtr<DrawTarget> tempDT =
|
||||
aDrawTarget.CreateSimilarDrawTarget(IntSize(bounds.width, bounds.height),
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
RefPtr<gfxContext> context = gfxContext::ForDrawTarget(tempDT);
|
||||
RefPtr<gfxContext> context = gfxContext::CreateOrNull(tempDT);
|
||||
if (!context) {
|
||||
// Leave this as crash, it's in the debugging code, we want to know
|
||||
gfxDevCrash(LogReason::InvalidContext) << "DebugPaintItem context problem " << gfx::hexa(tempDT);
|
||||
@ -6066,7 +6066,7 @@ ContainerState::CreateMaskLayer(Layer *aLayer,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<gfxContext> context = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context); // already checked the draw target above
|
||||
context->Multiply(ThebesMatrix(imageTransform));
|
||||
|
||||
|
@ -5260,7 +5260,7 @@ nsImageRenderer::Draw(nsPresContext* aPresContext,
|
||||
gfxRect clipRect = ctx->GetClipExtents();
|
||||
tmpDTRect = RoundedOut(ToRect(clipRect));
|
||||
RefPtr<DrawTarget> tempDT = ctx->GetDrawTarget()->CreateSimilarDrawTarget(tmpDTRect.Size(), SurfaceFormat::B8G8R8A8);
|
||||
ctx = gfxContext::ForDrawTarget(tempDT, tmpDTRect.TopLeft());
|
||||
ctx = gfxContext::CreateOrNull(tempDT, tmpDTRect.TopLeft());
|
||||
if (!ctx) {
|
||||
gfxDevCrash(LogReason::InvalidContext) << "ImageRenderer::Draw problem " << gfx::hexa(tempDT);
|
||||
return DrawResult::TEMPORARY_ERROR;
|
||||
|
@ -568,7 +568,7 @@ GenerateAndPushTextMask(nsIFrame* aFrame, nsRenderingContext* aContext,
|
||||
if (!maskDT) {
|
||||
NS_ABORT_OOM(drawRect.width * drawRect.height);
|
||||
}
|
||||
RefPtr<gfxContext> maskCtx = gfxContext::ForDrawTargetWithTransform(maskDT);
|
||||
RefPtr<gfxContext> maskCtx = gfxContext::CreatePreservingTransformOrNull(maskDT);
|
||||
gfxMatrix currentMatrix = sourceCtx->CurrentMatrix();
|
||||
maskCtx->SetMatrix(gfxMatrix::Translation(bounds.TopLeft()) *
|
||||
currentMatrix *
|
||||
|
@ -6739,7 +6739,7 @@ DrawImageInternal(gfxContext& aContext,
|
||||
imageRect.ToIntRect(&tmpDTRect);
|
||||
|
||||
RefPtr<DrawTarget> tempDT = destCtx->GetDrawTarget()->CreateSimilarDrawTarget(tmpDTRect.Size(), SurfaceFormat::B8G8R8A8);
|
||||
destCtx = gfxContext::ForDrawTarget(tempDT, imageRect.TopLeft());
|
||||
destCtx = gfxContext::CreateOrNull(tempDT, imageRect.TopLeft());
|
||||
if (!destCtx) {
|
||||
gfxDevCrash(LogReason::InvalidContext) << "NonOP_OVER context problem " << gfx::hexa(tempDT);
|
||||
return result;
|
||||
|
@ -2922,21 +2922,15 @@ PresShell::CreateReferenceRenderingContext()
|
||||
nsDeviceContext* devCtx = mPresContext->DeviceContext();
|
||||
RefPtr<gfxContext> rc;
|
||||
if (mPresContext->IsScreen()) {
|
||||
rc = gfxContext::ForDrawTarget(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
|
||||
if (!rc) {
|
||||
return nullptr;
|
||||
}
|
||||
rc = gfxContext::CreateOrNull(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
|
||||
} 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->CreateRenderingContext();
|
||||
if (!rc) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return rc.forget();
|
||||
return rc ? rc.forget() : nullptr;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -5194,7 +5188,7 @@ PresShell::PaintRangePaintInfo(const nsTArray<UniquePtr<RangePaintInfo>>& aItems
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
|
||||
if (aRegion) {
|
||||
|
@ -311,7 +311,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
|
||||
ceil(destRect.height)),
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
if (dt && dt->IsValid()) {
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(ctx); // already checked draw target above
|
||||
ctx->SetMatrix(ctx->CurrentMatrix().Translate(-destRect.x, -destRect.y));
|
||||
nsRenderingContext context(ctx);
|
||||
|
@ -364,7 +364,7 @@ nsFilterInstance::BuildSourcePaint(SourceInfo *aSource,
|
||||
}
|
||||
|
||||
if (!mPaintTransform.IsSingular()) {
|
||||
RefPtr<gfxContext> gfx = gfxContext::ForDrawTarget(offscreenDT);
|
||||
RefPtr<gfxContext> gfx = gfxContext::CreateOrNull(offscreenDT);
|
||||
MOZ_ASSERT(gfx); // already checked the draw target above
|
||||
gfx->Save();
|
||||
gfx->Multiply(mPaintTransform *
|
||||
@ -444,7 +444,7 @@ nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT)
|
||||
if (!deviceToFilterSpace.Invert()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(offscreenDT);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(offscreenDT);
|
||||
MOZ_ASSERT(ctx); // already checked the draw target above
|
||||
ctx->SetMatrix(
|
||||
ctx->CurrentMatrix().Translate(-neededRect.TopLeft()).
|
||||
|
@ -132,7 +132,7 @@ nsSVGClipPathFrame::GetClipMask(gfxContext& aReferenceContext,
|
||||
|
||||
// Paint this clipPath's contents into maskDT:
|
||||
{
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(maskDT);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(maskDT);
|
||||
if (!ctx) {
|
||||
gfxCriticalError() << "SVGClipPath context problem " << gfx::hexa(maskDT);
|
||||
return nullptr;
|
||||
|
@ -456,7 +456,7 @@ GenerateMaskSurface(const nsSVGIntegrationUtils::PaintFramesParams& aParams,
|
||||
: ctx.GetDrawTarget()->CreateSimilarDrawTarget(maskSurfaceRect.Size(),
|
||||
SurfaceFormat::A8);
|
||||
|
||||
RefPtr<gfxContext> maskContext = gfxContext::ForDrawTarget(maskDT);
|
||||
RefPtr<gfxContext> maskContext = gfxContext::CreateOrNull(maskDT);
|
||||
|
||||
// Set ctx's matrix on maskContext, offset by the maskSurfaceRect's position.
|
||||
// This makes sure that we combine the masks in device space.
|
||||
@ -681,7 +681,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(const PaintFramesParams& aParams)
|
||||
context.Restore();
|
||||
return;
|
||||
}
|
||||
target = gfxContext::ForDrawTarget(targetDT);
|
||||
target = gfxContext::CreateOrNull(targetDT);
|
||||
MOZ_ASSERT(target); // already checked the draw target above
|
||||
target->SetMatrix(context.CurrentMatrix() * gfxMatrix::Translation(-drawRect.TopLeft()));
|
||||
targetOffset = drawRect.TopLeft();
|
||||
|
@ -260,7 +260,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
|
||||
gfxMatrix maskSurfaceMatrix =
|
||||
aContext->CurrentMatrix() * gfxMatrix::Translation(-maskSurfaceRect.TopLeft());
|
||||
|
||||
RefPtr<gfxContext> tmpCtx = gfxContext::ForDrawTarget(maskDT);
|
||||
RefPtr<gfxContext> tmpCtx = gfxContext::CreateOrNull(maskDT);
|
||||
MOZ_ASSERT(tmpCtx); // already checked the draw target above
|
||||
tmpCtx->SetMatrix(maskSurfaceMatrix);
|
||||
|
||||
|
@ -377,7 +377,7 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
|
||||
}
|
||||
dt->ClearRect(Rect(0, 0, surfaceSize.width, surfaceSize.height));
|
||||
|
||||
RefPtr<gfxContext> gfx = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> gfx = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(gfx); // already checked the draw target above
|
||||
|
||||
if (aGraphicOpacity != 1.0f) {
|
||||
|
@ -639,7 +639,7 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
|
||||
IntRect drawRect = RoundedOut(ToRect(clipRect));
|
||||
|
||||
RefPtr<DrawTarget> targetDT = aContext.GetDrawTarget()->CreateSimilarDrawTarget(drawRect.Size(), SurfaceFormat::B8G8R8A8);
|
||||
target = gfxContext::ForDrawTarget(targetDT);
|
||||
target = gfxContext::CreateOrNull(targetDT);
|
||||
if (!target) {
|
||||
gfxDevCrash(LogReason::InvalidContext) << "SVGPaintWithEffects context problem " << gfx::hexa(targetDT);
|
||||
return;
|
||||
|
@ -1070,7 +1070,7 @@ PuppetWidget::Paint()
|
||||
mTabChild->NotifyPainted();
|
||||
}
|
||||
} else {
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(mDrawTarget);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(mDrawTarget);
|
||||
if (!ctx) {
|
||||
gfxDevCrash(LogReason::InvalidContext) << "PuppetWidget context problem " << gfx::hexa(mDrawTarget);
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1903,7 +1903,7 @@ AndroidBridge::CaptureZoomedView(mozIDOMWindowProxy *window, nsIntRect zoomedVie
|
||||
ALOG_BRIDGE("Error creating DrawTarget");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
RefPtr<gfxContext> context = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context); // already checked the draw target above
|
||||
context->SetMatrix(context->CurrentMatrix().Scale(zoomFactor, zoomFactor));
|
||||
|
||||
@ -2009,7 +2009,7 @@ nsresult AndroidBridge::CaptureThumbnail(mozIDOMWindowProxy *window, int32_t buf
|
||||
ALOG_BRIDGE("Error creating DrawTarget");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
RefPtr<gfxContext> context = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(context); // checked the draw target above
|
||||
|
||||
context->SetMatrix(
|
||||
|
@ -1546,7 +1546,7 @@ nsChildView::PaintWindowInContext(CGContextRef aContext, const LayoutDeviceIntRe
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<gfxContext> targetContext = gfxContext::ForDrawTarget(mBackingSurface);
|
||||
RefPtr<gfxContext> targetContext = gfxContext::CreateOrNull(mBackingSurface);
|
||||
MOZ_ASSERT(targetContext); // already checked the draw target above
|
||||
|
||||
// Set up the clip region and clear existing contents in the backing surface.
|
||||
|
@ -486,7 +486,7 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(imgIContainer *aImage, ui
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
RefPtr<gfxContext> context = gfxContext::ForDrawTarget(drawTarget);
|
||||
RefPtr<gfxContext> context = gfxContext::CreateOrNull(drawTarget);
|
||||
if (!context) {
|
||||
NS_ERROR("Failed to create gfxContext");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -2276,11 +2276,11 @@ nsWindow::OnExposeEvent(cairo_t *cr)
|
||||
if (!destDT || !destDT->IsValid()) {
|
||||
return FALSE;
|
||||
}
|
||||
ctx = gfxContext::ForDrawTarget(destDT, boundsRect.TopLeft());
|
||||
ctx = gfxContext::CreateOrNull(destDT, boundsRect.TopLeft());
|
||||
} else {
|
||||
gfxUtils::ClipToRegion(dt, region.ToUnknownRegion());
|
||||
|
||||
ctx = gfxContext::ForDrawTarget(dt, offset);
|
||||
ctx = gfxContext::CreateOrNull(dt, offset);
|
||||
}
|
||||
MOZ_ASSERT(ctx); // checked both dt and destDT valid draw target above
|
||||
|
||||
|
@ -725,7 +725,7 @@ nsBaseDragService::DrawDragForImage(nsIImageLoadingContent* aImageLoader,
|
||||
if (!dt || !dt->IsValid())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
RefPtr<gfxContext> ctx = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
|
||||
if (!ctx)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -362,7 +362,7 @@ private:
|
||||
return;
|
||||
}
|
||||
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
|
||||
targetContext = gfxContext::ForDrawTarget(dt);
|
||||
targetContext = gfxContext::CreateOrNull(dt);
|
||||
} else if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BackendType::CAIRO)) {
|
||||
// This is dead code unless you mess with prefs, but keep it around for
|
||||
// debugging.
|
||||
@ -376,7 +376,7 @@ private:
|
||||
return;
|
||||
}
|
||||
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
|
||||
targetContext = gfxContext::ForDrawTarget(dt);
|
||||
targetContext = gfxContext::CreateOrNull(dt);
|
||||
} else {
|
||||
MOZ_ASSERT_UNREACHABLE("COREGRAPHICS is the only supported backend");
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel)
|
||||
doubleBuffering = mozilla::layers::BufferMode::BUFFERED;
|
||||
#endif
|
||||
|
||||
RefPtr<gfxContext> thebesContext = gfxContext::ForDrawTarget(dt);
|
||||
RefPtr<gfxContext> thebesContext = gfxContext::CreateOrNull(dt);
|
||||
MOZ_ASSERT(thebesContext); // already checked draw target above
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user