Bug 1385164 - Using gfxContextAutoSaveRestore to prevent unpaired gfxContext::Save/Restore.
MozReview-Commit-ID: 8JtqftYQTHN
--- a/gfx/layers/basic/BasicLayerManager.cpp
+++ b/gfx/layers/basic/BasicLayerManager.cpp
@@ -87,17 +87,17 @@ BasicLayerManager::PushGroupForLayer(gfx
// If we need to call PushGroup, we should clip to the smallest possible
// area first to minimize the size of the temporary surface.
bool didCompleteClip = ClipToContain(aContext, aRegion.GetBounds());
bool canPushGroup = aGroupResult.mOperator == CompositionOp::OP_OVER ||
(aGroupResult.mOperator == CompositionOp::OP_SOURCE && (aLayer->CanUseOpaqueSurface() || aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA));
if (!canPushGroup) {
- aContext->Save();
+ gfxContextAutoSaveRestore autoSR(aContext);
gfxUtils::ClipToRegion(aGroupResult.mFinalTarget, aGroupResult.mVisibleRegion);
// PushGroup/PopGroup do not support non operator over.
gfxMatrix oldMat = aContext->CurrentMatrix();
aContext->SetMatrix(gfxMatrix());
gfxRect rect = aContext->GetClipExtents();
aContext->SetMatrix(oldMat);
rect.RoundOut();
@@ -116,17 +116,16 @@ BasicLayerManager::PushGroupForLayer(gfx
ctx->SetMatrix(oldMat);
aGroupResult.mGroupOffset = surfRect.TopLeft();
aGroupResult.mGroupTarget = ctx;
aGroupResult.mMaskSurface = GetMaskForLayer(aLayer, &aGroupResult.mMaskTransform);
return true;
}
- aContext->Restore();
}
Matrix maskTransform;
RefPtr<SourceSurface> maskSurf = GetMaskForLayer(aLayer, &maskTransform);
if (maskSurf) {
// The returned transform will transform the mask to device space on the
// destination. Since the User->Device space transform will be applied