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

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

Issue 2564193002: [SPv2] Add CSS mix-blend-mode support (Closed)
Patch Set: fix msvc warning Created 4 years 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/playback/display_item_list.h" 10 #include "cc/playback/display_item_list.h"
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 buildEffectNodesRecursively(nextEffect->parent()); 711 buildEffectNodesRecursively(nextEffect->parent());
712 DCHECK_EQ(nextEffect->parent(), currentEffectNode()); 712 DCHECK_EQ(nextEffect->parent(), currentEffectNode());
713 713
714 #if DCHECK_IS_ON() 714 #if DCHECK_IS_ON()
715 DCHECK(!m_effectNodesConverted.contains(nextEffect)) 715 DCHECK(!m_effectNodesConverted.contains(nextEffect))
716 << "Malformed paint artifact. Paint chunks under the same effect should " 716 << "Malformed paint artifact. Paint chunks under the same effect should "
717 "be contiguous."; 717 "be contiguous.";
718 m_effectNodesConverted.add(nextEffect); 718 m_effectNodesConverted.add(nextEffect);
719 #endif 719 #endif
720 720
721 // An effect node can't omit render surface if it has child with exotic
722 // blending mode. See comments below for more detail.
723 // TODO(crbug.com/504464): Remove premature optimization here.
724 if (nextEffect->blendMode() != SkBlendMode::kSrcOver) {
725 effectTree().Node(compositorIdForCurrentEffectNode())->has_render_surface =
726 true;
727 }
728
721 // We currently create dummy layers to host effect nodes and corresponding 729 // We currently create dummy layers to host effect nodes and corresponding
722 // render surfaces. This should be removed once cc implements better support 730 // render surfaces. This should be removed once cc implements better support
723 // for freestanding property trees. 731 // for freestanding property trees.
724 scoped_refptr<cc::Layer> dummyLayer = nextEffect->ensureDummyLayer(); 732 scoped_refptr<cc::Layer> dummyLayer = nextEffect->ensureDummyLayer();
725 m_rootLayer->AddChild(dummyLayer); 733 m_rootLayer->AddChild(dummyLayer);
726 734
727 int outputClipId = compositorIdForClipNode(nextEffect->outputClip()); 735 int outputClipId = compositorIdForClipNode(nextEffect->outputClip());
728 736
729 cc::EffectNode& effectNode = *effectTree().Node(effectTree().Insert( 737 cc::EffectNode& effectNode = *effectTree().Node(effectTree().Insert(
730 cc::EffectNode(), compositorIdForCurrentEffectNode())); 738 cc::EffectNode(), compositorIdForCurrentEffectNode()));
731 effectNode.owner_id = dummyLayer->id(); 739 effectNode.owner_id = dummyLayer->id();
732 effectNode.clip_id = outputClipId; 740 effectNode.clip_id = outputClipId;
733 // Every effect is supposed to have render surface enabled for grouping, 741 // Every effect is supposed to have render surface enabled for grouping,
734 // but we can get away without one if the effect is opacity-only and has only 742 // but we can get away without one if the effect is opacity-only and has only
735 // one compositing child. This is both for optimization and not introducing 743 // one compositing child with kSrcOver blend mode. This is both for
736 // sub-pixel differences in layout tests. 744 // optimization and not introducing sub-pixel differences in layout tests.
737 // See PropertyTreeManager::switchToEffectNode() where we retrospectively 745 // See PropertyTreeManager::switchToEffectNode() and above where we
738 // enable render surface when more than one compositing child is detected. 746 // retrospectively enable render surface when more than one compositing child
747 // or a child with exotic blend mode is detected.
739 // TODO(crbug.com/504464): There is ongoing work in cc to delay render surface 748 // TODO(crbug.com/504464): There is ongoing work in cc to delay render surface
740 // decision until later phase of the pipeline. Remove premature optimization 749 // decision until later phase of the pipeline. Remove premature optimization
741 // here once the work is ready. 750 // here once the work is ready.
742 if (!nextEffect->filter().isEmpty()) 751 if (!nextEffect->filter().isEmpty() ||
752 nextEffect->blendMode() != SkBlendMode::kSrcOver)
743 effectNode.has_render_surface = true; 753 effectNode.has_render_surface = true;
744 effectNode.opacity = nextEffect->opacity(); 754 effectNode.opacity = nextEffect->opacity();
745 effectNode.filters = nextEffect->filter().asCcFilterOperations(); 755 effectNode.filters = nextEffect->filter().asCcFilterOperations();
756 effectNode.blend_mode = nextEffect->blendMode();
746 m_propertyTrees.effect_id_to_index_map[effectNode.owner_id] = effectNode.id; 757 m_propertyTrees.effect_id_to_index_map[effectNode.owner_id] = effectNode.id;
747 m_effectStack.append(BlinkEffectAndCcIdPair{nextEffect, effectNode.id}); 758 m_effectStack.append(BlinkEffectAndCcIdPair{nextEffect, effectNode.id});
748 759
749 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); 760 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber);
750 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId); 761 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId);
751 dummyLayer->SetClipTreeIndex(outputClipId); 762 dummyLayer->SetClipTreeIndex(outputClipId);
752 dummyLayer->SetEffectTreeIndex(effectNode.id); 763 dummyLayer->SetEffectTreeIndex(effectNode.id);
753 dummyLayer->SetScrollTreeIndex(kRealRootNodeId); 764 dummyLayer->SetScrollTreeIndex(kRealRootNodeId);
754 } 765 }
755 766
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 m_contentLayerClients.clear(); 831 m_contentLayerClients.clear();
821 m_contentLayerClients.swap(newContentLayerClients); 832 m_contentLayerClients.swap(newContentLayerClients);
822 833
823 // Mark the property trees as having been rebuilt. 834 // Mark the property trees as having been rebuilt.
824 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber; 835 layerTree->property_trees()->sequence_number = kPropertyTreeSequenceNumber;
825 layerTree->property_trees()->needs_rebuild = false; 836 layerTree->property_trees()->needs_rebuild = false;
826 layerTree->property_trees()->ResetCachedData(); 837 layerTree->property_trees()->ResetCachedData();
827 } 838 }
828 839
829 } // namespace blink 840 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698