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

Side by Side Diff: Source/core/rendering/compositing/CompositedLayerMapping.cpp

Issue 399733002: Make sure we set "should flatten transform" correctly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove redundant call to updateShouldFlattenTransform Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/platform/linux/virtual/softwarecompositing/update-paint-phases-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1089
1090 if (m_backgroundLayer) 1090 if (m_backgroundLayer)
1091 m_backgroundLayer->setDrawsContent(hasPaintedContent); 1091 m_backgroundLayer->setDrawsContent(hasPaintedContent);
1092 } 1092 }
1093 1093
1094 void CompositedLayerMapping::updateChildrenTransform() 1094 void CompositedLayerMapping::updateChildrenTransform()
1095 { 1095 {
1096 if (GraphicsLayer* childTransformLayer = layerForChildrenTransform()) { 1096 if (GraphicsLayer* childTransformLayer = layerForChildrenTransform()) {
1097 childTransformLayer->setTransform(owningLayer().perspectiveTransform()); 1097 childTransformLayer->setTransform(owningLayer().perspectiveTransform());
1098 childTransformLayer->setTransformOrigin(FloatPoint3D(childTransformLayer ->size().width() * 0.5f, childTransformLayer->size().height() * 0.5f, 0.f)); 1098 childTransformLayer->setTransformOrigin(FloatPoint3D(childTransformLayer ->size().width() * 0.5f, childTransformLayer->size().height() * 0.5f, 0.f));
1099 bool hasPerspective = false; 1099 }
1100 if (RenderStyle* style = m_owningLayer.renderer()->style())
1101 hasPerspective = style->hasPerspective();
1102 if (hasPerspective)
1103 childTransformLayer->setShouldFlattenTransform(false);
1104 1100
1105 // Note, if the target is the scrolling layer, we need to ensure that th e 1101 updateShouldFlattenTransform();
1106 // scrolling content layer doesn't flatten the transform. (It would be n ice
1107 // if we could apply transform to the scrolling content layer, but that' s
1108 // too late, we need the children transform to be applied _before_ the
1109 // scrolling offset.)
1110 if (childTransformLayer == m_scrollingLayer.get())
1111 m_scrollingContentsLayer->setShouldFlattenTransform(false);
1112 }
1113 } 1102 }
1114 1103
1115 // Return true if the layers changed. 1104 // Return true if the layers changed.
1116 bool CompositedLayerMapping::updateClippingLayers(bool needsAncestorClip, bool n eedsDescendantClip) 1105 bool CompositedLayerMapping::updateClippingLayers(bool needsAncestorClip, bool n eedsDescendantClip)
1117 { 1106 {
1118 bool layersChanged = false; 1107 bool layersChanged = false;
1119 1108
1120 if (needsAncestorClip) { 1109 if (needsAncestorClip) {
1121 if (!m_ancestorClippingLayer) { 1110 if (!m_ancestorClippingLayer) {
1122 m_ancestorClippingLayer = createGraphicsLayer(CompositingReasonLayer ForAncestorClip); 1111 m_ancestorClippingLayer = createGraphicsLayer(CompositingReasonLayer ForAncestorClip);
(...skipping 24 matching lines...) Expand all
1147 } 1136 }
1148 1137
1149 bool CompositedLayerMapping::updateChildTransformLayer(bool needsChildTransformL ayer) 1138 bool CompositedLayerMapping::updateChildTransformLayer(bool needsChildTransformL ayer)
1150 { 1139 {
1151 bool layersChanged = false; 1140 bool layersChanged = false;
1152 1141
1153 if (needsChildTransformLayer) { 1142 if (needsChildTransformLayer) {
1154 if (!m_childTransformLayer) { 1143 if (!m_childTransformLayer) {
1155 m_childTransformLayer = createGraphicsLayer(CompositingReasonLayerFo rPerspective); 1144 m_childTransformLayer = createGraphicsLayer(CompositingReasonLayerFo rPerspective);
1156 m_childTransformLayer->setDrawsContent(false); 1145 m_childTransformLayer->setDrawsContent(false);
1157 m_childTransformLayer->setShouldFlattenTransform(false);
1158 layersChanged = true; 1146 layersChanged = true;
1159 } 1147 }
1160 } else if (m_childTransformLayer) { 1148 } else if (m_childTransformLayer) {
1161 m_childTransformLayer->removeFromParent(); 1149 m_childTransformLayer->removeFromParent();
1162 m_childTransformLayer = nullptr; 1150 m_childTransformLayer = nullptr;
1163 layersChanged = true; 1151 layersChanged = true;
1164 } 1152 }
1165 1153
1166 return layersChanged; 1154 return layersChanged;
1167 } 1155 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 if ((mode & ApplyToCoreLayers) && mapping->childTransformLayer()) 1261 if ((mode & ApplyToCoreLayers) && mapping->childTransformLayer())
1274 f(mapping->childTransformLayer()); 1262 f(mapping->childTransformLayer());
1275 if ((mode & ApplyToCoreLayers) && mapping->ancestorClippingLayer()) 1263 if ((mode & ApplyToCoreLayers) && mapping->ancestorClippingLayer())
1276 f(mapping->ancestorClippingLayer()); 1264 f(mapping->ancestorClippingLayer());
1277 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping ->mainGraphicsLayer()) 1265 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping ->mainGraphicsLayer())
1278 f(mapping->mainGraphicsLayer()); 1266 f(mapping->mainGraphicsLayer());
1279 if ((mode & ApplyToCoreLayers) && mapping->clippingLayer()) 1267 if ((mode & ApplyToCoreLayers) && mapping->clippingLayer())
1280 f(mapping->clippingLayer()); 1268 f(mapping->clippingLayer());
1281 if ((mode & ApplyToCoreLayers) && mapping->scrollingLayer()) 1269 if ((mode & ApplyToCoreLayers) && mapping->scrollingLayer())
1282 f(mapping->scrollingLayer()); 1270 f(mapping->scrollingLayer());
1271 if ((mode & ApplyToCoreLayers) && mapping->scrollingBlockSelectionLayer())
1272 f(mapping->scrollingBlockSelectionLayer());
1283 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping ->scrollingContentsLayer()) 1273 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping ->scrollingContentsLayer())
1284 f(mapping->scrollingContentsLayer()); 1274 f(mapping->scrollingContentsLayer());
1285 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping ->foregroundLayer()) 1275 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping ->foregroundLayer())
1286 f(mapping->foregroundLayer()); 1276 f(mapping->foregroundLayer());
1287 1277
1288 if ((mode & ApplyToSquashingLayer) && mapping->squashingLayer()) 1278 if ((mode & ApplyToSquashingLayer) && mapping->squashingLayer())
1289 f(mapping->squashingLayer()); 1279 f(mapping->squashingLayer());
1290 1280
1291 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers)) && mapping ->maskLayer()) 1281 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers)) && mapping ->maskLayer())
1292 f(mapping->maskLayer()); 1282 f(mapping->maskLayer());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 bool shouldFlatten; 1328 bool shouldFlatten;
1339 }; 1329 };
1340 1330
1341 void CompositedLayerMapping::updateShouldFlattenTransform() 1331 void CompositedLayerMapping::updateShouldFlattenTransform()
1342 { 1332 {
1343 // All CLM-managed layers that could affect a descendant layer should update their 1333 // All CLM-managed layers that could affect a descendant layer should update their
1344 // should-flatten-transform value (the other layers' transforms don't matter here). 1334 // should-flatten-transform value (the other layers' transforms don't matter here).
1345 UpdateShouldFlattenTransformFunctor functor = { !m_owningLayer.shouldPreserv e3D() }; 1335 UpdateShouldFlattenTransformFunctor functor = { !m_owningLayer.shouldPreserv e3D() };
1346 ApplyToGraphicsLayersMode mode = ApplyToCoreLayers; 1336 ApplyToGraphicsLayersMode mode = ApplyToCoreLayers;
1347 ApplyToGraphicsLayers(this, functor, mode); 1337 ApplyToGraphicsLayers(this, functor, mode);
1338
1339 // Note, if we apply perspective, we have to set should flatten differently
1340 // so that the transform propagates to child layers correctly.
1341 if (GraphicsLayer* childTransformLayer = layerForChildrenTransform()) {
1342 bool hasPerspective = false;
1343 if (RenderStyle* style = m_owningLayer.renderer()->style())
1344 hasPerspective = style->hasPerspective();
1345 if (hasPerspective)
1346 childTransformLayer->setShouldFlattenTransform(false);
1347
1348 // Note, if the target is the scrolling layer, we need to ensure that th e
1349 // scrolling content layer doesn't flatten the transform. (It would be n ice
1350 // if we could apply transform to the scrolling content layer, but that' s
1351 // too late, we need the children transform to be applied _before_ the
1352 // scrolling offset.)
1353 if (childTransformLayer == m_scrollingLayer.get()) {
1354 m_scrollingContentsLayer->setShouldFlattenTransform(false);
1355 m_scrollingBlockSelectionLayer->setShouldFlattenTransform(false);
1356 }
1357 }
1348 } 1358 }
1349 1359
1350 bool CompositedLayerMapping::updateForegroundLayer(bool needsForegroundLayer) 1360 bool CompositedLayerMapping::updateForegroundLayer(bool needsForegroundLayer)
1351 { 1361 {
1352 bool layerChanged = false; 1362 bool layerChanged = false;
1353 if (needsForegroundLayer) { 1363 if (needsForegroundLayer) {
1354 if (!m_foregroundLayer) { 1364 if (!m_foregroundLayer) {
1355 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor eground); 1365 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor eground);
1356 m_foregroundLayer->setDrawsContent(true); 1366 m_foregroundLayer->setDrawsContent(true);
1357 m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground); 1367 m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground);
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { 2251 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2242 name = "Scrolling Block Selection Layer"; 2252 name = "Scrolling Block Selection Layer";
2243 } else { 2253 } else {
2244 ASSERT_NOT_REACHED(); 2254 ASSERT_NOT_REACHED();
2245 } 2255 }
2246 2256
2247 return name; 2257 return name;
2248 } 2258 }
2249 2259
2250 } // namespace WebCore 2260 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/platform/linux/virtual/softwarecompositing/update-paint-phases-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698