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

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: Remove TODO 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 // Skip paint chunks that are effectively invisible due to opacity as long
512 // as we don't have another explicit reason to give them a layer. The lower
513 // bound of visibility is considered to be 0.0004f < 1/2048. With 10-bit
514 // color channels (only available on the newest Macs as of 2016; otherwise
515 // it's 8-bit), we see that an alpha of 1/2048 or less leads to a color
516 // output of less than 0.5 in all channels, hence not visible.
517 static const float kMinimumVisibleOpacity = 0.0004f;
518 if (chunk_effect->Opacity() < kMinimumVisibleOpacity &&
519 !chunk_effect->HasDirectCompositingReasons()) {
520 chunk_it++;
521 continue;
522 }
523
508 if (chunk_effect == &current_group) { 524 if (chunk_effect == &current_group) {
509 // Case A: The next chunk belongs to the current group but no subgroup. 525 // Case A: The next chunk belongs to the current group but no subgroup.
510 bool is_foreign = 526 bool is_foreign =
511 paint_artifact.GetDisplayItemList()[chunk_it->begin_index] 527 paint_artifact.GetDisplayItemList()[chunk_it->begin_index]
512 .IsForeignLayer(); 528 .IsForeignLayer();
513 pending_layers.push_back(PendingLayer(*chunk_it++, is_foreign)); 529 pending_layers.push_back(PendingLayer(*chunk_it++, is_foreign));
514 if (is_foreign) 530 if (is_foreign)
515 continue; 531 continue;
516 } else { 532 } else {
517 const EffectPaintPropertyNode* subgroup = 533 const EffectPaintPropertyNode* subgroup =
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 #ifndef NDEBUG 675 #ifndef NDEBUG
660 void PaintArtifactCompositor::ShowDebugData() { 676 void PaintArtifactCompositor::ShowDebugData() {
661 LOG(ERROR) << LayersAsJSON(kLayerTreeIncludesDebugInfo) 677 LOG(ERROR) << LayersAsJSON(kLayerTreeIncludesDebugInfo)
662 ->ToPrettyJSONString() 678 ->ToPrettyJSONString()
663 .Utf8() 679 .Utf8()
664 .data(); 680 .data();
665 } 681 }
666 #endif 682 #endif
667 683
668 } // namespace blink 684 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698