diff --git a/gfx/layers/wr/WebRenderCommandBuilder.cpp b/gfx/layers/wr/WebRenderCommandBuilder.cpp index 7e7c5094a2e5..037e1f6c6105 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.cpp +++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp @@ -2047,6 +2047,7 @@ static bool PaintByLayer(nsDisplayItem* aItem, static bool PaintItemByDrawTarget(nsDisplayItem* aItem, gfx::DrawTarget* aDT, const LayoutDevicePoint& aOffset, + const IntRect& visibleRect, nsDisplayListBuilder* aDisplayListBuilder, const RefPtr& aManager, const gfx::Size& aScale, @@ -2055,7 +2056,7 @@ static bool PaintItemByDrawTarget(nsDisplayItem* aItem, gfx::DrawTarget* aDT, bool isInvalidated = false; // XXX Why is this ClearRect() needed? - aDT->ClearRect(Rect(aDT->GetRect())); + aDT->ClearRect(Rect(visibleRect)); RefPtr context = gfxContext::CreateOrNull(aDT); MOZ_ASSERT(context); @@ -2100,15 +2101,14 @@ static bool PaintItemByDrawTarget(nsDisplayItem* aItem, gfx::DrawTarget* aDT, // which isn't very useful. if (aHighlight) { aDT->SetTransform(gfx::Matrix()); - aDT->FillRect(Rect(aDT->GetRect()), - gfx::ColorPattern(aHighlight.value())); + aDT->FillRect(Rect(visibleRect), gfx::ColorPattern(aHighlight.value())); } if (aItem->Frame()->PresContext()->GetPaintFlashing() && isInvalidated) { aDT->SetTransform(gfx::Matrix()); float r = float(rand()) / float(RAND_MAX); float g = float(rand()) / float(RAND_MAX); float b = float(rand()) / float(RAND_MAX); - aDT->FillRect(Rect(aDT->GetRect()), + aDT->FillRect(Rect(visibleRect), gfx::ColorPattern(gfx::Color(r, g, b, 0.5))); } } @@ -2195,7 +2195,7 @@ WebRenderCommandBuilder::GenerateFallbackData( if (dtSize.IsEmpty()) { return nullptr; } - + // Display item bounds should be unscaled aImageRect = dtRect / layerScale; nsDisplayItemGeometry* geometry = fallbackData->mGeometry; @@ -2276,8 +2276,11 @@ WebRenderCommandBuilder::GenerateFallbackData( fallbackData->mBasicLayerManager = new BasicLayerManager(BasicLayerManager::BLM_INACTIVE); } + // aOffset is (0, 0) because blobs don't want to normalize their + // coordinates bool isInvalidated = PaintItemByDrawTarget( - aItem, dt, LayoutDevicePoint(0, 0), aDisplayListBuilder, + aItem, dt, LayoutDevicePoint(0, 0), + /*aVisibleRect: */ dtRect.ToUnknownRect(), aDisplayListBuilder, fallbackData->mBasicLayerManager, scale, highlight); if (!isInvalidated) { if (!aItem->GetBuildingRect().IsEqualInterior( @@ -2346,8 +2349,12 @@ WebRenderCommandBuilder::GenerateFallbackData( fallbackData->mBasicLayerManager = new BasicLayerManager(mManager->GetWidget()); } + // aOffset is applied because this case is a "real" image and not a + // blob isInvalidated = PaintItemByDrawTarget( - aItem, dt, aImageRect.TopLeft(), aDisplayListBuilder, + aItem, dt, + /*aOffset: */ aImageRect.TopLeft(), + /*aVisibleRect: */ dt->GetRect(), aDisplayListBuilder, fallbackData->mBasicLayerManager, scale, highlight); }