Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp

Issue 1632263002: Calculate and track display item opaqueness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698