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 #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/compositing_display_item.h" | 10 #include "cc/playback/compositing_display_item.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 static void applyClipsBetweenStates(const PropertyTreeState& localState, | 277 static void applyClipsBetweenStates(const PropertyTreeState& localState, |
278 const PropertyTreeState& ancestorState, | 278 const PropertyTreeState& ancestorState, |
279 cc::DisplayItemList& ccList, | 279 cc::DisplayItemList& ccList, |
280 Vector<EndDisplayItemType>& endDisplayItems, | 280 Vector<EndDisplayItemType>& endDisplayItems, |
281 GeometryMapper& geometryMapper) { | 281 GeometryMapper& geometryMapper) { |
282 DCHECK(localState.transform() == ancestorState.transform()); | 282 DCHECK(localState.transform() == ancestorState.transform()); |
283 #ifdef DCHECK_IS_ON | 283 #ifdef DCHECK_IS_ON |
284 const TransformPaintPropertyNode* transformNode = | 284 const TransformPaintPropertyNode* transformNode = |
285 localState.clip()->localTransformSpace(); | 285 localState.clip()->localTransformSpace(); |
286 if (transformNode != ancestorState.transform()) { | 286 if (transformNode != ancestorState.transform()) { |
287 bool success = false; | |
288 const TransformationMatrix& localToAncestorMatrix = | 287 const TransformationMatrix& localToAncestorMatrix = |
289 geometryMapper.localToAncestorMatrix( | 288 geometryMapper.localToAncestorMatrix(transformNode, |
290 transformNode, ancestorState.transform(), success); | 289 ancestorState.transform()); |
291 DCHECK(success); | |
292 // Clips are only in descendant spaces that are transformed by one | 290 // Clips are only in descendant spaces that are transformed by one |
293 // or more scrolls. | 291 // or more scrolls. |
294 DCHECK(localToAncestorMatrix.isIdentityOrTranslation()); | 292 DCHECK(localToAncestorMatrix.isIdentityOrTranslation()); |
295 } | 293 } |
296 #endif | 294 #endif |
297 | 295 |
298 FloatRect combinedClip; | 296 FloatRect combinedClip = |
299 bool success = false; | 297 geometryMapper.localToAncestorClipRect(localState, ancestorState); |
300 combinedClip = geometryMapper.localToAncestorClipRect(localState, | |
301 ancestorState, success); | |
302 DCHECK(success); | |
303 | 298 |
304 ccList.CreateAndAppendPairedBeginItem<cc::FloatClipDisplayItem>( | 299 ccList.CreateAndAppendPairedBeginItem<cc::FloatClipDisplayItem>( |
305 gfx::RectF(combinedClip)); | 300 gfx::RectF(combinedClip)); |
306 endDisplayItems.push_back(EndClip); | 301 endDisplayItems.push_back(EndClip); |
307 } | 302 } |
308 | 303 |
309 static void recordPairedBeginDisplayItems( | 304 static void recordPairedBeginDisplayItems( |
310 const Vector<PropertyTreeState>& pairedStates, | 305 const Vector<PropertyTreeState>& pairedStates, |
311 const PropertyTreeState& pendingLayerState, | 306 const PropertyTreeState& pendingLayerState, |
312 cc::DisplayItemList& ccList, | 307 cc::DisplayItemList& ccList, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 case PropertyTreeState::Effect: { | 357 case PropertyTreeState::Effect: { |
363 // TODO(chrishtr): skip effect and/or compositing display items if | 358 // TODO(chrishtr): skip effect and/or compositing display items if |
364 // not necessary. | 359 // not necessary. |
365 | 360 |
366 FloatRect clipRect = | 361 FloatRect clipRect = |
367 pairedState->effect()->outputClip()->clipRect().rect(); | 362 pairedState->effect()->outputClip()->clipRect().rect(); |
368 // TODO(chrishtr): specify origin of the filter. | 363 // TODO(chrishtr): specify origin of the filter. |
369 FloatPoint filterOrigin; | 364 FloatPoint filterOrigin; |
370 if (pairedState->effect()->localTransformSpace() != | 365 if (pairedState->effect()->localTransformSpace() != |
371 pairedState->transform()) { | 366 pairedState->transform()) { |
372 bool success = false; | |
373 const TransformPaintPropertyNode* transformNode = | 367 const TransformPaintPropertyNode* transformNode = |
374 pairedState->effect()->localTransformSpace(); | 368 pairedState->effect()->localTransformSpace(); |
375 const TransformationMatrix& localToAncestorMatrix = | 369 const TransformationMatrix& localToAncestorMatrix = |
376 geometryMapper.localToAncestorMatrix( | 370 geometryMapper.localToAncestorMatrix(transformNode, |
377 transformNode, pairedState->transform(), success); | 371 pairedState->transform()); |
378 DCHECK(success); | |
379 // Effects are only in descendant spaces that are transformed by one | 372 // Effects are only in descendant spaces that are transformed by one |
380 // or more scrolls. | 373 // or more scrolls. |
381 DCHECK(localToAncestorMatrix.isIdentityOrTranslation()); | 374 DCHECK(localToAncestorMatrix.isIdentityOrTranslation()); |
382 | 375 |
383 clipRect = localToAncestorMatrix.mapRect(clipRect); | 376 clipRect = localToAncestorMatrix.mapRect(clipRect); |
384 filterOrigin = localToAncestorMatrix.mapPoint(filterOrigin); | 377 filterOrigin = localToAncestorMatrix.mapPoint(filterOrigin); |
385 } | 378 } |
386 | 379 |
387 const bool kLcdTextRequiresOpaqueLayer = true; | 380 const bool kLcdTextRequiresOpaqueLayer = true; |
388 ccList.CreateAndAppendPairedBeginItem<cc::CompositingDisplayItem>( | 381 ccList.CreateAndAppendPairedBeginItem<cc::CompositingDisplayItem>( |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 } | 1068 } |
1076 | 1069 |
1077 bool PaintArtifactCompositor::mightOverlap( | 1070 bool PaintArtifactCompositor::mightOverlap( |
1078 const PaintChunk& paintChunk, | 1071 const PaintChunk& paintChunk, |
1079 const PendingLayer& candidatePendingLayer, | 1072 const PendingLayer& candidatePendingLayer, |
1080 GeometryMapper& geometryMapper) { | 1073 GeometryMapper& geometryMapper) { |
1081 PropertyTreeState rootPropertyTreeState( | 1074 PropertyTreeState rootPropertyTreeState( |
1082 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1075 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
1083 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); | 1076 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); |
1084 | 1077 |
1085 bool success = false; | |
1086 FloatRect paintChunkScreenVisualRect = | 1078 FloatRect paintChunkScreenVisualRect = |
1087 geometryMapper.localToAncestorVisualRect( | 1079 geometryMapper.localToAncestorVisualRect( |
1088 paintChunk.bounds, paintChunk.properties.propertyTreeState, | 1080 paintChunk.bounds, paintChunk.properties.propertyTreeState, |
1089 rootPropertyTreeState, success); | 1081 rootPropertyTreeState); |
1090 DCHECK(success); | |
1091 | 1082 |
1092 success = false; | |
1093 FloatRect pendingLayerScreenVisualRect = | 1083 FloatRect pendingLayerScreenVisualRect = |
1094 geometryMapper.localToAncestorVisualRect( | 1084 geometryMapper.localToAncestorVisualRect( |
1095 candidatePendingLayer.bounds, candidatePendingLayer.propertyTreeState, | 1085 candidatePendingLayer.bounds, candidatePendingLayer.propertyTreeState, |
1096 rootPropertyTreeState, success); | 1086 rootPropertyTreeState); |
1097 DCHECK(success); | |
1098 | 1087 |
1099 return paintChunkScreenVisualRect.intersects(pendingLayerScreenVisualRect); | 1088 return paintChunkScreenVisualRect.intersects(pendingLayerScreenVisualRect); |
1100 } | 1089 } |
1101 | 1090 |
1102 PaintArtifactCompositor::PendingLayer::PendingLayer( | 1091 PaintArtifactCompositor::PendingLayer::PendingLayer( |
1103 const PaintChunk& firstPaintChunk) | 1092 const PaintChunk& firstPaintChunk) |
1104 : bounds(firstPaintChunk.bounds), | 1093 : bounds(firstPaintChunk.bounds), |
1105 knownToBeOpaque(firstPaintChunk.knownToBeOpaque), | 1094 knownToBeOpaque(firstPaintChunk.knownToBeOpaque), |
1106 backfaceHidden(firstPaintChunk.properties.backfaceHidden), | 1095 backfaceHidden(firstPaintChunk.properties.backfaceHidden), |
1107 propertyTreeState(firstPaintChunk.properties.propertyTreeState) { | 1096 propertyTreeState(firstPaintChunk.properties.propertyTreeState) { |
1108 paintChunks.push_back(&firstPaintChunk); | 1097 paintChunks.push_back(&firstPaintChunk); |
1109 } | 1098 } |
1110 | 1099 |
1111 void PaintArtifactCompositor::PendingLayer::add( | 1100 void PaintArtifactCompositor::PendingLayer::add( |
1112 const PaintChunk& paintChunk, | 1101 const PaintChunk& paintChunk, |
1113 GeometryMapper* geometryMapper) { | 1102 GeometryMapper* geometryMapper) { |
1114 DCHECK(paintChunk.properties.backfaceHidden == backfaceHidden); | 1103 DCHECK(paintChunk.properties.backfaceHidden == backfaceHidden); |
1115 paintChunks.push_back(&paintChunk); | 1104 paintChunks.push_back(&paintChunk); |
1116 FloatRect mappedBounds = paintChunk.bounds; | 1105 FloatRect mappedBounds = paintChunk.bounds; |
1117 if (geometryMapper) { | 1106 if (geometryMapper) { |
1118 bool success = false; | |
1119 mappedBounds = geometryMapper->localToAncestorRect( | 1107 mappedBounds = geometryMapper->localToAncestorRect( |
1120 mappedBounds, paintChunk.properties.propertyTreeState.transform(), | 1108 mappedBounds, paintChunk.properties.propertyTreeState.transform(), |
1121 propertyTreeState.transform(), success); | 1109 propertyTreeState.transform()); |
1122 DCHECK(success); | |
1123 } | 1110 } |
1124 bounds.unite(mappedBounds); | 1111 bounds.unite(mappedBounds); |
1125 if (bounds.size() != paintChunks[0]->bounds.size()) { | 1112 if (bounds.size() != paintChunks[0]->bounds.size()) { |
1126 if (bounds.size() != paintChunk.bounds.size()) | 1113 if (bounds.size() != paintChunk.bounds.size()) |
1127 knownToBeOpaque = false; | 1114 knownToBeOpaque = false; |
1128 else | 1115 else |
1129 knownToBeOpaque = paintChunk.knownToBeOpaque; | 1116 knownToBeOpaque = paintChunk.knownToBeOpaque; |
1130 } | 1117 } |
1131 } | 1118 } |
1132 | 1119 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 #ifndef NDEBUG | 1218 #ifndef NDEBUG |
1232 void PaintArtifactCompositor::showDebugData() { | 1219 void PaintArtifactCompositor::showDebugData() { |
1233 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) | 1220 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) |
1234 ->toPrettyJSONString() | 1221 ->toPrettyJSONString() |
1235 .utf8() | 1222 .utf8() |
1236 .data(); | 1223 .data(); |
1237 } | 1224 } |
1238 #endif | 1225 #endif |
1239 | 1226 |
1240 } // namespace blink | 1227 } // namespace blink |
OLD | NEW |