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

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

Issue 2798513002: Revert of Make GeometryMapper fully static (Closed)
Patch Set: Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/PaintChunksToCcLayer.h" 5 #include "platform/graphics/compositing/PaintChunksToCcLayer.h"
6 6
7 #include "cc/paint/compositing_display_item.h" 7 #include "cc/paint/compositing_display_item.h"
8 #include "cc/paint/display_item_list.h" 8 #include "cc/paint/display_item_list.h"
9 #include "cc/paint/drawing_display_item.h" 9 #include "cc/paint/drawing_display_item.h"
10 #include "cc/paint/filter_display_item.h" 10 #include "cc/paint/filter_display_item.h"
11 #include "cc/paint/float_clip_display_item.h" 11 #include "cc/paint/float_clip_display_item.h"
12 #include "cc/paint/transform_display_item.h" 12 #include "cc/paint/transform_display_item.h"
13 #include "platform/graphics/GraphicsContext.h" 13 #include "platform/graphics/GraphicsContext.h"
14 #include "platform/graphics/paint/DisplayItemList.h" 14 #include "platform/graphics/paint/DisplayItemList.h"
15 #include "platform/graphics/paint/DrawingDisplayItem.h" 15 #include "platform/graphics/paint/DrawingDisplayItem.h"
16 #include "platform/graphics/paint/GeometryMapper.h" 16 #include "platform/graphics/paint/GeometryMapper.h"
17 #include "platform/graphics/paint/PaintChunk.h" 17 #include "platform/graphics/paint/PaintChunk.h"
18 #include "platform/graphics/paint/PropertyTreeState.h" 18 #include "platform/graphics/paint/PropertyTreeState.h"
19 19
20 namespace blink { 20 namespace blink {
21 21
22 namespace { 22 namespace {
23 23
24 enum EndDisplayItemType { EndTransform, EndClip, EndEffect }; 24 enum EndDisplayItemType { EndTransform, EndClip, EndEffect };
25 25
26 // Applies the clips between |localState| and |ancestorState| into a single 26 // Applies the clips between |localState| and |ancestorState| into a single
27 // combined cc::FloatClipDisplayItem on |ccList|. 27 // combined cc::FloatClipDisplayItem on |ccList|.
28 static void applyClipsBetweenStates( 28 static void applyClipsBetweenStates(const PropertyTreeState& localState,
29 const PropertyTreeState& localState, 29 const PropertyTreeState& ancestorState,
30 const PropertyTreeState& ancestorState, 30 cc::DisplayItemList& ccList,
31 cc::DisplayItemList& ccList, 31 Vector<EndDisplayItemType>& endDisplayItems,
32 Vector<EndDisplayItemType>& endDisplayItems) { 32 GeometryMapper& geometryMapper) {
33 DCHECK(localState.transform() == ancestorState.transform()); 33 DCHECK(localState.transform() == ancestorState.transform());
34 #if DCHECK_IS_ON() 34 #if DCHECK_IS_ON()
35 const TransformPaintPropertyNode* transformNode = 35 const TransformPaintPropertyNode* transformNode =
36 localState.clip()->localTransformSpace(); 36 localState.clip()->localTransformSpace();
37 if (transformNode != ancestorState.transform()) { 37 if (transformNode != ancestorState.transform()) {
38 const TransformationMatrix& localToAncestorMatrix = 38 const TransformationMatrix& localToAncestorMatrix =
39 GeometryMapper::localToAncestorMatrix(transformNode, 39 geometryMapper.localToAncestorMatrix(transformNode,
40 ancestorState.transform()); 40 ancestorState.transform());
41 // Clips are only in descendant spaces that are transformed by one 41 // Clips are only in descendant spaces that are transformed by one
42 // or more scrolls. 42 // or more scrolls.
43 DCHECK(localToAncestorMatrix.isIdentityOrTranslation()); 43 DCHECK(localToAncestorMatrix.isIdentityOrTranslation());
44 } 44 }
45 #endif 45 #endif
46 46
47 const FloatClipRect& combinedClip = 47 const FloatClipRect& combinedClip =
48 GeometryMapper::localToAncestorClipRect(localState, ancestorState); 48 geometryMapper.localToAncestorClipRect(localState, ancestorState);
49 49
50 ccList.CreateAndAppendPairedBeginItem<cc::FloatClipDisplayItem>( 50 ccList.CreateAndAppendPairedBeginItem<cc::FloatClipDisplayItem>(
51 gfx::RectF(combinedClip.rect())); 51 gfx::RectF(combinedClip.rect()));
52 endDisplayItems.push_back(EndClip); 52 endDisplayItems.push_back(EndClip);
53 } 53 }
54 54
55 static void recordPairedBeginDisplayItems( 55 static void recordPairedBeginDisplayItems(
56 const Vector<PropertyTreeState>& pairedStates, 56 const Vector<PropertyTreeState>& pairedStates,
57 const PropertyTreeState& pendingLayerState, 57 const PropertyTreeState& pendingLayerState,
58 cc::DisplayItemList& ccList, 58 cc::DisplayItemList& ccList,
59 Vector<EndDisplayItemType>& endDisplayItems) { 59 Vector<EndDisplayItemType>& endDisplayItems,
60 GeometryMapper& geometryMapper) {
60 PropertyTreeState mappedClipDestinationSpace = pendingLayerState; 61 PropertyTreeState mappedClipDestinationSpace = pendingLayerState;
61 PropertyTreeState clipSpace = pendingLayerState; 62 PropertyTreeState clipSpace = pendingLayerState;
62 bool hasClip = false; 63 bool hasClip = false;
63 64
64 for (Vector<PropertyTreeState>::const_reverse_iterator pairedState = 65 for (Vector<PropertyTreeState>::const_reverse_iterator pairedState =
65 pairedStates.rbegin(); 66 pairedStates.rbegin();
66 pairedState != pairedStates.rend(); ++pairedState) { 67 pairedState != pairedStates.rend(); ++pairedState) {
67 switch (pairedState->innermostNode()) { 68 switch (pairedState->innermostNode()) {
68 case PropertyTreeState::Transform: { 69 case PropertyTreeState::Transform: {
69 if (hasClip) { 70 if (hasClip) {
70 applyClipsBetweenStates(clipSpace, mappedClipDestinationSpace, ccList, 71 applyClipsBetweenStates(clipSpace, mappedClipDestinationSpace, ccList,
71 endDisplayItems); 72 endDisplayItems, geometryMapper);
72 hasClip = false; 73 hasClip = false;
73 } 74 }
74 mappedClipDestinationSpace = *pairedState; 75 mappedClipDestinationSpace = *pairedState;
75 clipSpace = *pairedState; 76 clipSpace = *pairedState;
76 77
77 TransformationMatrix matrix = pairedState->transform()->matrix(); 78 TransformationMatrix matrix = pairedState->transform()->matrix();
78 matrix.applyTransformOrigin(pairedState->transform()->origin()); 79 matrix.applyTransformOrigin(pairedState->transform()->origin());
79 80
80 gfx::Transform transform(gfx::Transform::kSkipInitialization); 81 gfx::Transform transform(gfx::Transform::kSkipInitialization);
81 transform.matrix() = TransformationMatrix::toSkMatrix44(matrix); 82 transform.matrix() = TransformationMatrix::toSkMatrix44(matrix);
(...skipping 28 matching lines...) Expand all
110 111
111 FloatRect clipRect = 112 FloatRect clipRect =
112 pairedState->effect()->outputClip()->clipRect().rect(); 113 pairedState->effect()->outputClip()->clipRect().rect();
113 // TODO(chrishtr): specify origin of the filter. 114 // TODO(chrishtr): specify origin of the filter.
114 FloatPoint filterOrigin; 115 FloatPoint filterOrigin;
115 if (pairedState->effect()->localTransformSpace() != 116 if (pairedState->effect()->localTransformSpace() !=
116 pairedState->transform()) { 117 pairedState->transform()) {
117 const TransformPaintPropertyNode* transformNode = 118 const TransformPaintPropertyNode* transformNode =
118 pairedState->effect()->localTransformSpace(); 119 pairedState->effect()->localTransformSpace();
119 const TransformationMatrix& localToAncestorMatrix = 120 const TransformationMatrix& localToAncestorMatrix =
120 GeometryMapper::localToAncestorMatrix(transformNode, 121 geometryMapper.localToAncestorMatrix(transformNode,
121 pairedState->transform()); 122 pairedState->transform());
122 // Effects are only in descendant spaces that are transformed by one 123 // Effects are only in descendant spaces that are transformed by one
123 // or more scrolls. 124 // or more scrolls.
124 DCHECK(localToAncestorMatrix.isIdentityOrTranslation()); 125 DCHECK(localToAncestorMatrix.isIdentityOrTranslation());
125 126
126 clipRect = localToAncestorMatrix.mapRect(clipRect); 127 clipRect = localToAncestorMatrix.mapRect(clipRect);
127 filterOrigin = localToAncestorMatrix.mapPoint(filterOrigin); 128 filterOrigin = localToAncestorMatrix.mapPoint(filterOrigin);
128 } 129 }
129 130
130 const bool kLcdTextRequiresOpaqueLayer = true; 131 const bool kLcdTextRequiresOpaqueLayer = true;
131 ccList.CreateAndAppendPairedBeginItem<cc::CompositingDisplayItem>( 132 ccList.CreateAndAppendPairedBeginItem<cc::CompositingDisplayItem>(
(...skipping 13 matching lines...) Expand all
145 endDisplayItems.push_back(EndEffect); 146 endDisplayItems.push_back(EndEffect);
146 break; 147 break;
147 } 148 }
148 case PropertyTreeState::None: 149 case PropertyTreeState::None:
149 break; 150 break;
150 } 151 }
151 } 152 }
152 153
153 if (hasClip) { 154 if (hasClip) {
154 applyClipsBetweenStates(clipSpace, mappedClipDestinationSpace, ccList, 155 applyClipsBetweenStates(clipSpace, mappedClipDestinationSpace, ccList,
155 endDisplayItems); 156 endDisplayItems, geometryMapper);
156 } 157 }
157 } 158 }
158 159
159 static void recordPairedEndDisplayItems( 160 static void recordPairedEndDisplayItems(
160 const Vector<EndDisplayItemType>& endDisplayItemTypes, 161 const Vector<EndDisplayItemType>& endDisplayItemTypes,
161 cc::DisplayItemList* ccList) { 162 cc::DisplayItemList* ccList) {
162 for (Vector<EndDisplayItemType>::const_reverse_iterator endType = 163 for (Vector<EndDisplayItemType>::const_reverse_iterator endType =
163 endDisplayItemTypes.rbegin(); 164 endDisplayItemTypes.rbegin();
164 endType != endDisplayItemTypes.rend(); ++endType) { 165 endType != endDisplayItemTypes.rend(); ++endType) {
165 switch (*endType) { 166 switch (*endType) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 std::move(record)); 199 std::move(record));
199 } 200 }
200 } 201 }
201 202
202 } // unnamed namespace 203 } // unnamed namespace
203 204
204 scoped_refptr<cc::DisplayItemList> PaintChunksToCcLayer::convert( 205 scoped_refptr<cc::DisplayItemList> PaintChunksToCcLayer::convert(
205 const Vector<const PaintChunk*>& paintChunks, 206 const Vector<const PaintChunk*>& paintChunks,
206 const PropertyTreeState& layerState, 207 const PropertyTreeState& layerState,
207 const gfx::Vector2dF& layerOffset, 208 const gfx::Vector2dF& layerOffset,
208 const DisplayItemList& displayItems) { 209 const DisplayItemList& displayItems,
210 GeometryMapper& geometryMapper) {
209 auto ccList = make_scoped_refptr(new cc::DisplayItemList); 211 auto ccList = make_scoped_refptr(new cc::DisplayItemList);
210 212
211 gfx::Transform counterOffset; 213 gfx::Transform counterOffset;
212 counterOffset.Translate(-layerOffset.x(), -layerOffset.y()); 214 counterOffset.Translate(-layerOffset.x(), -layerOffset.y());
213 ccList->CreateAndAppendPairedBeginItem<cc::TransformDisplayItem>( 215 ccList->CreateAndAppendPairedBeginItem<cc::TransformDisplayItem>(
214 counterOffset); 216 counterOffset);
215 217
216 for (const auto* paintChunk : paintChunks) { 218 for (const auto* paintChunk : paintChunks) {
217 const PropertyTreeState* state = &paintChunk->properties.propertyTreeState; 219 const PropertyTreeState* state = &paintChunk->properties.propertyTreeState;
218 PropertyTreeStateIterator iterator(*state); 220 PropertyTreeStateIterator iterator(*state);
219 Vector<PropertyTreeState> pairedStates; 221 Vector<PropertyTreeState> pairedStates;
220 for (; state && *state != layerState; state = iterator.next()) { 222 for (; state && *state != layerState; state = iterator.next()) {
221 if (state->innermostNode() != PropertyTreeState::None) 223 if (state->innermostNode() != PropertyTreeState::None)
222 pairedStates.push_back(*state); 224 pairedStates.push_back(*state);
223 } 225 }
224 226
225 // TODO(chrishtr): we can avoid some extra paired display items if 227 // TODO(chrishtr): we can avoid some extra paired display items if
226 // multiple PaintChunks share them. We can also collapse clips between 228 // multiple PaintChunks share them. We can also collapse clips between
227 // transforms into single clips in the same way that PaintLayerClipper does. 229 // transforms into single clips in the same way that PaintLayerClipper does.
228 Vector<EndDisplayItemType> endDisplayItems; 230 Vector<EndDisplayItemType> endDisplayItems;
229 231
230 recordPairedBeginDisplayItems(pairedStates, layerState, *ccList.get(), 232 recordPairedBeginDisplayItems(pairedStates, layerState, *ccList.get(),
231 endDisplayItems); 233 endDisplayItems, geometryMapper);
232 234
233 for (const auto& displayItem : displayItems.itemsInPaintChunk(*paintChunk)) 235 for (const auto& displayItem : displayItems.itemsInPaintChunk(*paintChunk))
234 appendDisplayItemToCcDisplayItemList(displayItem, ccList.get()); 236 appendDisplayItemToCcDisplayItemList(displayItem, ccList.get());
235 237
236 recordPairedEndDisplayItems(endDisplayItems, ccList.get()); 238 recordPairedEndDisplayItems(endDisplayItems, ccList.get());
237 } 239 }
238 240
239 ccList->CreateAndAppendPairedEndItem<cc::EndTransformDisplayItem>(); 241 ccList->CreateAndAppendPairedEndItem<cc::EndTransformDisplayItem>();
240 242
241 ccList->Finalize(); 243 ccList->Finalize();
242 return ccList; 244 return ccList;
243 } 245 }
244 246
245 } // namespace blink 247 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698