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

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

Issue 2833883003: Skip paint chunks with effectively invisible opacity. (Closed)
Patch Set: Sync to head. Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h"
6 6
7 #include "cc/layers/content_layer_client.h" 7 #include "cc/layers/content_layer_client.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/layers/picture_layer.h" 9 #include "cc/layers/picture_layer.h"
10 #include "cc/paint/display_item_list.h" 10 #include "cc/paint/display_item_list.h"
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 return false; 467 return false;
468 if (effect->HasDirectCompositingReasons()) 468 if (effect->HasDirectCompositingReasons())
469 return false; 469 return false;
470 if (!CanUpcastTo(layer.property_tree_state, 470 if (!CanUpcastTo(layer.property_tree_state,
471 PropertyTreeState(effect->LocalTransformSpace(), 471 PropertyTreeState(effect->LocalTransformSpace(),
472 effect->OutputClip(), effect))) 472 effect->OutputClip(), effect)))
473 return false; 473 return false;
474 return true; 474 return true;
475 } 475 }
476 476
477 static bool EffectGroupContainsChunk(
478 const EffectPaintPropertyNode& group_effect,
479 const PaintChunk& chunk) {
480 const EffectPaintPropertyNode* effect =
481 chunk.properties.property_tree_state.Effect();
482 return effect == &group_effect ||
483 StrictChildOfAlongPath(&group_effect, effect);
484 }
485
486 static bool SkipGroupIfEffectivelyInvisible(
487 const PaintArtifact& paint_artifact,
488 const EffectPaintPropertyNode& current_group,
489 Vector<PaintChunk>::const_iterator& chunk_it) {
490 // The lower bound of visibility is considered to be 0.0004f < 1/2048. With
491 // 10-bit color channels (only available on the newest Macs as of 2016;
492 // otherwise it's 8-bit), we see that an alpha of 1/2048 or less leads to a
493 // color output of less than 0.5 in all channels, hence not visible.
494 static const float kMinimumVisibleOpacity = 0.0004f;
495 if (current_group.Opacity() >= kMinimumVisibleOpacity ||
496 current_group.HasDirectCompositingReasons()) {
497 return false;
498 }
499
500 // Fast-forward to just past the end of the chunk sequence within this
501 // effect group.
502 DCHECK(EffectGroupContainsChunk(current_group, *chunk_it));
503 while (++chunk_it != paint_artifact.PaintChunks().end()) {
504 if (!EffectGroupContainsChunk(current_group, *chunk_it))
505 break;
506 }
507 return true;
508 }
509
477 void PaintArtifactCompositor::LayerizeGroup( 510 void PaintArtifactCompositor::LayerizeGroup(
478 const PaintArtifact& paint_artifact, 511 const PaintArtifact& paint_artifact,
479 Vector<PendingLayer>& pending_layers, 512 Vector<PendingLayer>& pending_layers,
480 const EffectPaintPropertyNode& current_group, 513 const EffectPaintPropertyNode& current_group,
481 Vector<PaintChunk>::const_iterator& chunk_it) { 514 Vector<PaintChunk>::const_iterator& chunk_it) {
515 // Skip paint chunks that are effectively invisible due to opacity and don't
516 // have a direct compositing reason.
517 if (SkipGroupIfEffectivelyInvisible(paint_artifact, current_group, chunk_it))
518 return;
519
482 size_t first_layer_in_current_group = pending_layers.size(); 520 size_t first_layer_in_current_group = pending_layers.size();
483 // The worst case time complexity of the algorithm is O(pqd), where 521 // The worst case time complexity of the algorithm is O(pqd), where
484 // p = the number of paint chunks. 522 // p = the number of paint chunks.
485 // q = average number of trials to find a squash layer or rejected 523 // q = average number of trials to find a squash layer or rejected
486 // for overlapping. 524 // for overlapping.
487 // d = (sum of) the depth of property trees. 525 // d = (sum of) the depth of property trees.
488 // The analysis as follows: 526 // The analysis as follows:
489 // Every paint chunk will be visited by the main loop below for exactly once, 527 // Every paint chunk will be visited by the main loop below for exactly once,
490 // except for chunks that enter or exit groups (case B & C below). 528 // except for chunks that enter or exit groups (case B & C below).
491 // For normal chunk visit (case A), the only cost is determining squash, 529 // For normal chunk visit (case A), the only cost is determining squash,
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 #ifndef NDEBUG 697 #ifndef NDEBUG
660 void PaintArtifactCompositor::ShowDebugData() { 698 void PaintArtifactCompositor::ShowDebugData() {
661 LOG(ERROR) << LayersAsJSON(kLayerTreeIncludesDebugInfo) 699 LOG(ERROR) << LayersAsJSON(kLayerTreeIncludesDebugInfo)
662 ->ToPrettyJSONString() 700 ->ToPrettyJSONString()
663 .Utf8() 701 .Utf8()
664 .data(); 702 .data();
665 } 703 }
666 #endif 704 #endif
667 705
668 } // namespace blink 706 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698