diff --git a/gfx/layers/client/SingleTiledContentClient.cpp b/gfx/layers/client/SingleTiledContentClient.cpp index f8f493456fef..bc2cbdec04f6 100644 --- a/gfx/layers/client/SingleTiledContentClient.cpp +++ b/gfx/layers/client/SingleTiledContentClient.cpp @@ -186,24 +186,12 @@ ClientSingleTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion, dtOnWhite = backBufferOnWhite->BorrowDrawTarget(); } - if (mode != SurfaceMode::SURFACE_OPAQUE) { - auto clear = CapturedTiledPaintState::Clear{ - dt, - dtOnWhite, - tileDirtyRegion, - }; - - if (asyncPaint) { - paintClears.push_back(clear); - } else { - clear.ClearBuffer(); - } - } - // If the old frontbuffer was discarded then attempt to copy what we // can from it to the new backbuffer. + bool copiedFromDiscarded = false; + nsIntRegion copyableRegion; + if (discardedFrontBuffer) { - nsIntRegion copyableRegion; copyableRegion.And(aNewValidRegion, discardedValidRegion); copyableRegion.SubOut(aDirtyRegion); @@ -266,10 +254,31 @@ ClientSingleTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion, // We don't need to repaint valid content that was just copied. paintRegion.SubOut(copyableRegion); + copiedFromDiscarded = true; } } } + if (mode != SurfaceMode::SURFACE_OPAQUE) { + nsIntRegion regionToClear = tileDirtyRegion; + if (copiedFromDiscarded) { + copyableRegion.MoveBy(-mTilingOrigin); + regionToClear.SubOut(copyableRegion); + } + + auto clear = CapturedTiledPaintState::Clear{ + dt, + dtOnWhite, + regionToClear, + }; + + if (asyncPaint) { + paintClears.push_back(clear); + } else { + clear.ClearBuffer(); + } + } + if (dtOnWhite) { dt = gfx::Factory::CreateDualDrawTarget(dt, dtOnWhite); dtOnWhite = nullptr;