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

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: Remove comment about moving bits 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..fb737d2d430c3eb226df769601073e5f033d0183 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp
@@ -7,23 +7,36 @@
#include "platform/TraceEvent.h"
#include "platform/geometry/IntRect.h"
#include "platform/graphics/paint/DrawingDisplayItem.h"
+#include "third_party/skia/include/core/SkRegion.h"
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;
+ SkRegion knownToBeOpaqueRegion;
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 (const SkPicture* picture = drawing.picture()) {
+ const SkRect& pictureRect = picture->cullRect();
+ bounds.unite(pictureRect);
+ if (drawing.knownToBeOpaque()) {
+ // TODO(pdr): This may be too conservative and fail due to
+ // floating point precision issues.
+ SkIRect conservativelyRoundedPictureRect;
+ pictureRect.roundIn(&conservativelyRoundedPictureRect);
+ knownToBeOpaqueRegion.op(conservativelyRoundedPictureRect, SkRegion::kUnion_Op);
+ }
+ }
}
chunk.bounds = bounds;
+ if (knownToBeOpaqueRegion.contains(enclosingIntRect(bounds)))
+ chunk.knownToBeOpaque = true;
}
}
@@ -38,7 +51,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