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

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: Tweak comment. 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // which costs O(qd), where d came from "canUpcastTo" and geometry mapping. 492 // which costs O(qd), where d came from "canUpcastTo" and geometry mapping.
493 // Subtotal: O(pqd) 493 // Subtotal: O(pqd)
494 // For group entering and exiting, it could cost O(d) for each group, for 494 // For group entering and exiting, it could cost O(d) for each group, for
495 // searching the shallowest subgroup (strictChildOfAlongPath), thus O(d^2) 495 // searching the shallowest subgroup (strictChildOfAlongPath), thus O(d^2)
496 // in total. 496 // in total.
497 // Also when exiting group, the group may be decomposited and squashed to a 497 // Also when exiting group, the group may be decomposited and squashed to a
498 // previous layer. Again finding the host costs O(qd). Merging would cost O(p) 498 // previous layer. Again finding the host costs O(qd). Merging would cost O(p)
499 // due to copying the chunk list. Subtotal: O((qd + p)d) = O(qd^2 + pd) 499 // due to copying the chunk list. Subtotal: O((qd + p)d) = O(qd^2 + pd)
500 // Assuming p > d, the total complexity would be O(pqd + qd^2 + pd) = O(pqd) 500 // Assuming p > d, the total complexity would be O(pqd + qd^2 + pd) = O(pqd)
501 while (chunk_it != paint_artifact.PaintChunks().end()) { 501 while (chunk_it != paint_artifact.PaintChunks().end()) {
502 // Look at the effect node of the next chunk. There are 3 possible cases: 502 // Look at the effect node of the next chunk. If the chunk has
503 // effectively-invisible opacity we skip it. Otherwise, there are 3 possible
504 // cases:
503 // A. The next chunk belongs to the current group but no subgroup. 505 // A. The next chunk belongs to the current group but no subgroup.
504 // B. The next chunk does not belong to the current group. 506 // B. The next chunk does not belong to the current group.
505 // C. The next chunk belongs to some subgroup of the current group. 507 // C. The next chunk belongs to some subgroup of the current group.
506 const EffectPaintPropertyNode* chunk_effect = 508 const EffectPaintPropertyNode* chunk_effect =
507 chunk_it->properties.property_tree_state.Effect(); 509 chunk_it->properties.property_tree_state.Effect();
510
511 // TODO(wkorman): Do we need to check blend mode, mask, or filter to skip
wkorman 2017/04/24 19:49:38 Seeking your thought on this comment as I haven't
512 // only when appropriate? See also PaintLayer::IsTransparent() which was
513 // previously incorporated via PaintLayer::PaintsWithTransparency().
514
515 // Skip paint chunks that are effectively invisible due to opacity. The
516 // lower bound of visibility is considered to be 0.0004f < 1/2048. With
517 // 10-bit color channels (only available on the newest Macs as of 2016;
518 // otherwise it's 8-bit), we see that an alpha of 1/2048 or less leads to a
519 // color output of less than 0.5 in all channels, hence not visible.
520 static const float kMinimumVisibleOpacity = 0.0004f;
521 if (chunk_effect->Opacity() < kMinimumVisibleOpacity) {
522 chunk_it++;
523 continue;
524 }
525
508 if (chunk_effect == &current_group) { 526 if (chunk_effect == &current_group) {
509 // Case A: The next chunk belongs to the current group but no subgroup. 527 // Case A: The next chunk belongs to the current group but no subgroup.
510 bool is_foreign = 528 bool is_foreign =
511 paint_artifact.GetDisplayItemList()[chunk_it->begin_index] 529 paint_artifact.GetDisplayItemList()[chunk_it->begin_index]
512 .IsForeignLayer(); 530 .IsForeignLayer();
513 pending_layers.push_back(PendingLayer(*chunk_it++, is_foreign)); 531 pending_layers.push_back(PendingLayer(*chunk_it++, is_foreign));
514 if (is_foreign) 532 if (is_foreign)
515 continue; 533 continue;
516 } else { 534 } else {
517 const EffectPaintPropertyNode* subgroup = 535 const EffectPaintPropertyNode* subgroup =
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 #ifndef NDEBUG 677 #ifndef NDEBUG
660 void PaintArtifactCompositor::ShowDebugData() { 678 void PaintArtifactCompositor::ShowDebugData() {
661 LOG(ERROR) << LayersAsJSON(kLayerTreeIncludesDebugInfo) 679 LOG(ERROR) << LayersAsJSON(kLayerTreeIncludesDebugInfo)
662 ->ToPrettyJSONString() 680 ->ToPrettyJSONString()
663 .Utf8() 681 .Utf8()
664 .data(); 682 .data();
665 } 683 }
666 #endif 684 #endif
667 685
668 } // namespace blink 686 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698