From e29700e3664bec78589158ebd6d97d5ae46615c9 Mon Sep 17 00:00:00 2001 From: Morris Tseng Date: Tue, 16 Jan 2018 17:33:12 +0800 Subject: [PATCH] Bug 1424177 - Slightly enlarge drawtarget size when fallback. r=kats MozReview-Commit-ID: Dam5l91Y93Y --- gfx/layers/wr/WebRenderCommandBuilder.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/gfx/layers/wr/WebRenderCommandBuilder.cpp b/gfx/layers/wr/WebRenderCommandBuilder.cpp index 999020b45d77..cbc88b9f32e9 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.cpp +++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp @@ -527,9 +527,15 @@ WebRenderCommandBuilder::GenerateFallbackData(nsDisplayItem* aItem, return nullptr; } + // Some display item may draw exceed the paintSize, we need prepare a larger + // draw target to contain the result. + auto scaledBounds = bounds * LayoutDeviceToLayerScale(1); + scaledBounds.Scale(scale.width, scale.height); + LayerIntSize dtSize = RoundedToInt(scaledBounds).Size(); + bool needPaint = true; LayoutDeviceIntPoint offset = RoundedToInt(bounds.TopLeft()); - aImageRect = LayoutDeviceRect(offset, LayoutDeviceSize(RoundedToInt(bounds.Size()))); + aImageRect = LayoutDeviceRect(offset, LayoutDeviceSize(RoundedToInt(bounds).Size())); LayerRect paintRect = LayerRect(LayerPoint(0, 0), LayerSize(paintSize)); nsDisplayItemGeometry* geometry = fallbackData->GetGeometry(); @@ -581,7 +587,7 @@ WebRenderCommandBuilder::GenerateFallbackData(nsDisplayItem* aItem, }); RefPtr dummyDt = gfx::Factory::CreateDrawTarget(gfx::BackendType::SKIA, gfx::IntSize(1, 1), format); - RefPtr dt = gfx::Factory::CreateRecordingDrawTarget(recorder, dummyDt, paintSize.ToUnknownSize()); + RefPtr dt = gfx::Factory::CreateRecordingDrawTarget(recorder, dummyDt, dtSize.ToUnknownSize()); if (!fallbackData->mBasicLayerManager) { fallbackData->mBasicLayerManager = new BasicLayerManager(BasicLayerManager::BLM_INACTIVE); } @@ -593,7 +599,7 @@ WebRenderCommandBuilder::GenerateFallbackData(nsDisplayItem* aItem, if (isInvalidated) { Range bytes((uint8_t *)recorder->mOutputStream.mData, recorder->mOutputStream.mLength); wr::ImageKey key = mManager->WrBridge()->GetNextImageKey(); - wr::ImageDescriptor descriptor(paintSize.ToUnknownSize(), 0, dt->GetFormat(), isOpaque); + wr::ImageDescriptor descriptor(dtSize.ToUnknownSize(), 0, dt->GetFormat(), isOpaque); if (!aResources.AddBlobImage(key, descriptor, bytes)) { return nullptr; } @@ -612,7 +618,7 @@ WebRenderCommandBuilder::GenerateFallbackData(nsDisplayItem* aItem, bool isInvalidated = false; { - UpdateImageHelper helper(imageContainer, imageClient, paintSize.ToUnknownSize(), format); + UpdateImageHelper helper(imageContainer, imageClient, dtSize.ToUnknownSize(), format); { RefPtr dt = helper.GetDrawTarget(); if (!dt) { @@ -622,9 +628,9 @@ WebRenderCommandBuilder::GenerateFallbackData(nsDisplayItem* aItem, fallbackData->mBasicLayerManager = new BasicLayerManager(mManager->GetWidget()); } isInvalidated = PaintItemByDrawTarget(aItem, dt, paintRect, offset, - aDisplayListBuilder, - fallbackData->mBasicLayerManager, scale, - highlight); + aDisplayListBuilder, + fallbackData->mBasicLayerManager, scale, + highlight); } if (isInvalidated) {