Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef PaintArtifactCompositor_h | 5 #ifndef PaintArtifactCompositor_h |
| 6 #define PaintArtifactCompositor_h | 6 #define PaintArtifactCompositor_h |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "platform/PlatformExport.h" | 9 #include "platform/PlatformExport.h" |
| 10 #include "platform/RuntimeEnabledFeatures.h" | 10 #include "platform/RuntimeEnabledFeatures.h" |
| 11 #include "platform/graphics/GraphicsLayerClient.h" | 11 #include "platform/graphics/GraphicsLayerClient.h" |
| 12 #include "platform/graphics/paint/PaintController.h" | 12 #include "platform/graphics/paint/PaintController.h" |
| 13 #include "wtf/Noncopyable.h" | 13 #include "wtf/Noncopyable.h" |
| 14 #include "wtf/PtrUtil.h" | 14 #include "wtf/PtrUtil.h" |
| 15 #include "wtf/Vector.h" | 15 #include "wtf/Vector.h" |
| 16 #include <memory> | 16 #include <memory> |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 class DisplayItemList; | |
| 19 class Layer; | 20 class Layer; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace gfx { | 23 namespace gfx { |
| 23 class Vector2dF; | 24 class Vector2dF; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace blink { | 27 namespace blink { |
| 27 | 28 |
| 29 class GeometryMapper; | |
|
pdr.
2016/12/20 06:46:30
Can you writeup a high-level description of the ov
| |
| 28 class JSONObject; | 30 class JSONObject; |
| 29 class PaintArtifact; | 31 class PaintArtifact; |
| 30 class WebLayer; | 32 class WebLayer; |
| 31 struct PaintChunk; | 33 struct PaintChunk; |
| 32 | 34 |
| 33 // Responsible for managing compositing in terms of a PaintArtifact. | 35 // Responsible for managing compositing in terms of a PaintArtifact. |
| 34 // | 36 // |
| 35 // Owns a subtree of the compositor layer tree, and updates it in response to | 37 // Owns a subtree of the compositor layer tree, and updates it in response to |
| 36 // changes in the paint artifact. | 38 // changes in the paint artifact. |
| 37 // | 39 // |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 return m_extraDataForTesting.get(); | 73 return m_extraDataForTesting.get(); |
| 72 } | 74 } |
| 73 | 75 |
| 74 void setTracksRasterInvalidations(bool); | 76 void setTracksRasterInvalidations(bool); |
| 75 void resetTrackedRasterInvalidations(); | 77 void resetTrackedRasterInvalidations(); |
| 76 bool hasTrackedRasterInvalidations() const; | 78 bool hasTrackedRasterInvalidations() const; |
| 77 | 79 |
| 78 std::unique_ptr<JSONObject> layersAsJSON(LayerTreeFlags) const; | 80 std::unique_ptr<JSONObject> layersAsJSON(LayerTreeFlags) const; |
| 79 | 81 |
| 80 private: | 82 private: |
| 83 // A pending layer is a collection of paint chunks that will end up in | |
| 84 // the same cc::Layer. | |
| 85 struct PendingLayer { | |
| 86 PendingLayer(const PaintChunk& firstPaintChunk) | |
|
wkorman
2016/12/20 00:28:56
OK to put the impl for these methods in the .cpp f
chrishtr
2016/12/20 23:36:32
Done.
| |
| 87 : knownToBeOpaque(true), | |
| 88 backfaceHidden(firstPaintChunk.properties.backfaceHidden), | |
| 89 propertyTreeState(firstPaintChunk.properties.propertyTreeState) { | |
| 90 add(firstPaintChunk); | |
| 91 } | |
| 92 void add(const PaintChunk& paintChunk) { | |
| 93 DCHECK(paintChunk.properties.backfaceHidden == backfaceHidden); | |
| 94 paintChunks.append(&paintChunk); | |
| 95 bounds.unite(paintChunk.bounds); | |
| 96 knownToBeOpaque = knownToBeOpaque && paintChunk.knownToBeOpaque; | |
| 97 } | |
| 98 FloatRect bounds; | |
| 99 Vector<const PaintChunk*> paintChunks; | |
| 100 bool knownToBeOpaque; | |
| 101 bool backfaceHidden; | |
| 102 PropertyTreeState propertyTreeState; | |
| 103 }; | |
| 104 | |
| 81 PaintArtifactCompositor(); | 105 PaintArtifactCompositor(); |
| 82 | 106 |
| 83 class ContentLayerClientImpl; | 107 class ContentLayerClientImpl; |
| 84 | 108 |
| 109 void collectPendingLayers(const Vector<PaintChunk>& paintChunks, | |
|
pdr.
2016/12/20 06:46:30
Nit: Just return Vector<PendingLayer>:
Vector<Pend
chrishtr
2016/12/20 23:36:32
Returning a vector will cause a vector copy operat
| |
| 110 Vector<PendingLayer>& pendingLayers); | |
| 111 | |
| 85 // Builds a leaf layer that represents a single paint chunk. | 112 // Builds a leaf layer that represents a single paint chunk. |
| 86 // Note: cc::Layer API assumes the layer bounds start at (0, 0), but the | 113 // Note: cc::Layer API assumes the layer bounds start at (0, 0), but the |
| 87 // bounding box of a paint chunk does not necessarily start at (0, 0) (and | 114 // bounding box of a paint chunk does not necessarily start at (0, 0) (and |
| 88 // could even be negative). Internally the generated layer translates the | 115 // could even be negative). Internally the generated layer translates the |
| 89 // paint chunk to align the bounding box to (0, 0) and return the actual | 116 // paint chunk to align the bounding box to (0, 0) and return the actual |
| 90 // origin of the paint chunk in the |layerOffset| outparam. | 117 // origin of the paint chunk in the |layerOffset| outparam. |
| 91 scoped_refptr<cc::Layer> layerForPaintChunk( | 118 scoped_refptr<cc::Layer> compositedLayerForPendingLayer( |
| 92 const PaintArtifact&, | 119 const PaintArtifact&, |
| 93 const PaintChunk&, | 120 const PendingLayer&, |
| 94 gfx::Vector2dF& layerOffset, | 121 gfx::Vector2dF& layerOffset, |
| 95 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, | 122 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, |
| 96 RasterInvalidationTracking*); | 123 RasterInvalidationTrackingMap<const PaintChunk>*); |
| 97 | 124 |
| 98 // Finds a client among the current vector of clients that matches the paint | 125 // Finds a client among the current vector of clients that matches the paint |
| 99 // chunk's id, or otherwise allocates a new one. | 126 // chunk's id, or otherwise allocates a new one. |
| 100 std::unique_ptr<ContentLayerClientImpl> clientForPaintChunk( | 127 std::unique_ptr<ContentLayerClientImpl> clientForPaintChunk( |
| 101 const PaintChunk&, | 128 const PaintChunk&, |
| 102 const PaintArtifact&); | 129 const PaintArtifact&); |
| 103 | 130 |
| 131 static scoped_refptr<cc::DisplayItemList> recordPendingLayer( | |
| 132 const PaintArtifact&, | |
| 133 const PendingLayer& x, | |
|
wkorman
2016/12/20 00:28:56
Remove 'x', or use more meaningful name?
chrishtr
2016/12/20 23:36:32
Done.
| |
| 134 const gfx::Rect& combinedBounds); | |
| 135 | |
| 136 static bool canMergeInto(const PaintChunk& newChunk, | |
| 137 const PendingLayer& candidatePendingLayer); | |
| 138 | |
| 139 // Returns true if |newChunk| overlaps |candidatePendingLayer| in the | |
| 140 // root property tree space. | |
| 141 static bool overlaps(const PaintChunk& newChunk, | |
| 142 const PendingLayer& candidatePendingLayer, | |
| 143 GeometryMapper&); | |
| 144 | |
| 104 scoped_refptr<cc::Layer> m_rootLayer; | 145 scoped_refptr<cc::Layer> m_rootLayer; |
| 105 std::unique_ptr<WebLayer> m_webLayer; | 146 std::unique_ptr<WebLayer> m_webLayer; |
| 106 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; | 147 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; |
| 107 | 148 |
| 108 bool m_extraDataForTestingEnabled = false; | 149 bool m_extraDataForTestingEnabled = false; |
| 109 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; | 150 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; |
| 110 friend class StubChromeClientForSPv2; | 151 friend class StubChromeClientForSPv2; |
| 111 | 152 |
| 112 bool m_isTrackingRasterInvalidations; | 153 bool m_isTrackingRasterInvalidations; |
| 154 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, | |
|
wkorman
2016/12/20 00:28:56
I thought there was a way to have one line do this
chrishtr
2016/12/20 23:36:32
I don't know of one either.
| |
| 155 MergeSimpleChunks); | |
| 156 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, | |
| 157 Merge2DTransform); | |
| 158 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, | |
| 159 MergeClip); | |
| 160 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, | |
| 161 MergeOpacity); | |
| 162 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, | |
| 163 MergeNested); | |
| 164 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, | |
| 165 PendingLayer); | |
| 113 }; | 166 }; |
| 114 | 167 |
| 115 } // namespace blink | 168 } // namespace blink |
| 116 | 169 |
| 117 #endif // PaintArtifactCompositor_h | 170 #endif // PaintArtifactCompositor_h |
| OLD | NEW |