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

Unified Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp

Issue 2833883003: Skip paint chunks with effectively invisible opacity. (Closed)
Patch Set: Remove TODO comment. Created 3 years, 8 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/compositing/PaintArtifactCompositor.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp
index 83cf5e45e90c8d5f3da455493a94a93311c6a8d0..29560ad32793a176ffcc736f27223a5f24415299 100644
--- a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp
+++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp
@@ -499,12 +499,28 @@ void PaintArtifactCompositor::LayerizeGroup(
// due to copying the chunk list. Subtotal: O((qd + p)d) = O(qd^2 + pd)
// Assuming p > d, the total complexity would be O(pqd + qd^2 + pd) = O(pqd)
while (chunk_it != paint_artifact.PaintChunks().end()) {
- // Look at the effect node of the next chunk. There are 3 possible cases:
+ // Look at the effect node of the next chunk. If the chunk has
+ // effectively-invisible opacity we skip it. Otherwise, there are 3 possible
+ // cases:
// A. The next chunk belongs to the current group but no subgroup.
// B. The next chunk does not belong to the current group.
// C. The next chunk belongs to some subgroup of the current group.
const EffectPaintPropertyNode* chunk_effect =
chunk_it->properties.property_tree_state.Effect();
+
+ // Skip paint chunks that are effectively invisible due to opacity as long
+ // as we don't have another explicit reason to give them a layer. The lower
+ // bound of visibility is considered to be 0.0004f < 1/2048. With 10-bit
+ // color channels (only available on the newest Macs as of 2016; otherwise
+ // it's 8-bit), we see that an alpha of 1/2048 or less leads to a color
+ // output of less than 0.5 in all channels, hence not visible.
+ static const float kMinimumVisibleOpacity = 0.0004f;
+ if (chunk_effect->Opacity() < kMinimumVisibleOpacity &&
+ !chunk_effect->HasDirectCompositingReasons()) {
+ chunk_it++;
+ continue;
+ }
+
if (chunk_effect == &current_group) {
// Case A: The next chunk belongs to the current group but no subgroup.
bool is_foreign =

Powered by Google App Engine
This is Rietveld 408576698