Index: third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp |
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp |
index 174649d4c63e92e8888ca1d9d7cb439ef407e908..13c947e5646e391514f22f0865e6acc87c08a193 100644 |
--- a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp |
@@ -12,18 +12,40 @@ namespace blink { |
namespace { |
-void computeChunkBounds(const DisplayItemList& displayItems, Vector<PaintChunk>& paintChunks) |
+void computeChunkBoundsAndOpaqueness(const DisplayItemList& displayItems, Vector<PaintChunk>& paintChunks) |
{ |
for (PaintChunk& chunk : paintChunks) { |
FloatRect bounds; |
+ bool knownToBeOpaqueItems = false; |
for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) { |
if (!item.isDrawing()) |
continue; |
const auto& drawing = static_cast<const DrawingDisplayItem&>(item); |
if (const SkPicture* picture = drawing.picture()) |
bounds.unite(picture->cullRect()); |
+ if (drawing.knownToBeOpaque()) |
+ knownToBeOpaqueItems = true; |
} |
chunk.bounds = bounds; |
+ |
+ // TODO(pdr): This should be optimized to not require a second walk of |
+ // the items. It's not yet clear what the best approach is (regions, |
+ // largest rects, first-N-rects, etc). |
+ if (!knownToBeOpaqueItems) |
jbroman
2016/01/26 17:50:14
I'd think SkRegion is both simple and reasonably e
pdr.
2016/01/26 23:38:08
Heck yeah, done.
|
+ return; |
+ for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) { |
+ if (!item.isDrawing()) |
+ continue; |
+ const auto& drawing = static_cast<const DrawingDisplayItem&>(item); |
+ if (!drawing.knownToBeOpaque()) |
+ continue; |
+ if (const SkPicture* picture = drawing.picture()) { |
+ if (bounds.contains(picture->cullRect())) { |
+ chunk.knownToBeOpaque = true; |
+ break; |
+ } |
+ } |
+ } |
} |
} |
@@ -38,7 +60,7 @@ PaintArtifact::PaintArtifact(DisplayItemList displayItems, Vector<PaintChunk> pa |
: m_displayItemList(std::move(displayItems)) |
, m_paintChunks(std::move(paintChunks)) |
{ |
- computeChunkBounds(m_displayItemList, m_paintChunks); |
+ computeChunkBoundsAndOpaqueness(m_displayItemList, m_paintChunks); |
} |
PaintArtifact::PaintArtifact(PaintArtifact&& source) |