Bug 1276824 (part 2) - Fix up checks for calls to gfxContext::Create{,PreservingTransform}OrNull(). r=milan.

--HG--
extra : rebase_source : 80644c1a6658da553c13ae1ab3b8d03e916ee6e7
This commit is contained in:
Nicholas Nethercote 2016-06-07 11:17:48 +10:00
Родитель a02611e830
Коммит 4e8f3b6d6e
8 изменённых файлов: 21 добавлений и 12 удалений

Просмотреть файл

@ -3604,6 +3604,8 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
// not render well via the code below.
if (mOp == CanvasRenderingContext2D::TextDrawOperation::FILL &&
mState->StyleIsColor(CanvasRenderingContext2D::Style::FILL)) {
// TODO: determine if mCtx->mTarget is guaranteed to be non-null and valid
// here. If it's not, thebes will be null and we'll crash.
RefPtr<gfxContext> thebes =
gfxContext::CreatePreservingTransformOrNull(mCtx->mTarget);
nscolor fill = mState->colorStyles[CanvasRenderingContext2D::Style::FILL];
@ -4992,7 +4994,8 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& aWindow, double aX,
UsedOperation() == CompositionOp::OP_OVER)
{
thebes = gfxContext::CreateOrNull(mTarget);
MOZ_ASSERT(thebes); // alrady checked the draw target above
MOZ_ASSERT(thebes); // already checked the draw target above
// (in SupportsAzureContentForDrawTarget)
thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
matrix._22, matrix._31, matrix._32));
} else {

Просмотреть файл

@ -932,8 +932,6 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
// Temporary fast fix for bug 725886
// Revert these changes when 725886 is ready
MOZ_ASSERT(untransformedDT && untransformedDT->IsValid(),
"We should always allocate an untransformed surface with 3d transforms!");
#ifdef DEBUG
if (aLayer->GetDebugColorIndex() != 0) {
Color color((aLayer->GetDebugColorIndex() & 1) ? 1.f : 0.f,

Просмотреть файл

@ -193,6 +193,9 @@ MakeContext ()
CreateOffscreenContentDrawTarget(IntSize(size, size),
SurfaceFormat::B8G8R8X8);
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(drawTarget);
if (!ctx) {
MOZ_CRASH("gfxContext creation failed");
}
return ctx.forget();
}

Просмотреть файл

@ -44,6 +44,9 @@ MakeContext ()
CreateOffscreenContentDrawTarget(IntSize(size, size),
SurfaceFormat::B8G8R8X8);
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(drawTarget);
if (!ctx) {
MOZ_CRASH("gfxContext creation failed");
}
return ctx.forget();
}

Просмотреть файл

@ -1238,7 +1238,7 @@ gfxPlatform::PopulateScreenInfo()
bool
gfxPlatform::SupportsAzureContentForDrawTarget(DrawTarget* aTarget)
{
if (!aTarget) {
if (!aTarget || !aTarget->IsValid()) {
return false;
}

Просмотреть файл

@ -565,10 +565,11 @@ GenerateAndPushTextMask(nsIFrame* aFrame, nsRenderingContext* aContext,
RefPtr<DrawTarget> maskDT =
sourceTarget->CreateSimilarDrawTarget(drawRect.Size(),
SurfaceFormat::A8);
if (!maskDT) {
NS_ABORT_OOM(drawRect.width * drawRect.height);
if (!maskDT || !maskDT->IsValid()) {
return false;
}
RefPtr<gfxContext> maskCtx = gfxContext::CreatePreservingTransformOrNull(maskDT);
MOZ_ASSERT(maskCtx);
gfxMatrix currentMatrix = sourceCtx->CurrentMatrix();
maskCtx->SetMatrix(gfxMatrix::Translation(bounds.TopLeft()) *
currentMatrix *

Просмотреть файл

@ -455,8 +455,12 @@ GenerateMaskSurface(const nsSVGIntegrationUtils::PaintFramesParams& aParams,
SurfaceFormat::A8)
: ctx.GetDrawTarget()->CreateSimilarDrawTarget(maskSurfaceRect.Size(),
SurfaceFormat::A8);
if (!maskDT || !maskDT->IsValid()) {
return;
}
RefPtr<gfxContext> maskContext = gfxContext::CreateOrNull(maskDT);
MOZ_ASSERT(maskContext);
// Set ctx's matrix on maskContext, offset by the maskSurfaceRect's position.
// This makes sure that we combine the masks in device space.

Просмотреть файл

@ -481,16 +481,13 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(imgIContainer *aImage, ui
RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(scaledSize, SurfaceFormat::B8G8R8A8);
if (!drawTarget) {
NS_ERROR("Failed to create DrawTarget");
if (!drawTarget || !drawTarget->IsValid()) {
NS_ERROR("Failed to create valid DrawTarget");
return NS_ERROR_FAILURE;
}
RefPtr<gfxContext> context = gfxContext::CreateOrNull(drawTarget);
if (!context) {
NS_ERROR("Failed to create gfxContext");
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(context);
mozilla::image::DrawResult res =
aImage->Draw(context, scaledSize, ImageRegion::Create(scaledSize),