OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 m_secondaryBackingStoreBytes = 0; | 432 m_secondaryBackingStoreBytes = 0; |
433 | 433 |
434 Frame& frame = m_renderView->frameView()->frame(); | 434 Frame& frame = m_renderView->frameView()->frame(); |
435 LOG(Compositing, "\nUpdate %d of %s.\n", m_rootLayerUpdateCount, isMainF
rame() ? "main frame" : frame.tree()->uniqueName().string().utf8().data()); | 435 LOG(Compositing, "\nUpdate %d of %s.\n", m_rootLayerUpdateCount, isMainF
rame() ? "main frame" : frame.tree()->uniqueName().string().utf8().data()); |
436 } | 436 } |
437 #endif | 437 #endif |
438 | 438 |
439 if (needHierarchyUpdate) { | 439 if (needHierarchyUpdate) { |
440 // Update the hierarchy of the compositing layers. | 440 // Update the hierarchy of the compositing layers. |
441 Vector<GraphicsLayer*> childList; | 441 Vector<GraphicsLayer*> childList; |
| 442 HashSet<RenderLayer*> visited; |
442 { | 443 { |
443 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::rebuildCompo
sitingLayerTree"); | 444 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::rebuildCompo
sitingLayerTree"); |
444 rebuildCompositingLayerTree(updateRoot, childList, 0); | 445 rebuildCompositingLayerTree(updateRoot, childList, visited, 0); |
445 } | 446 } |
446 | 447 |
447 // Host the document layer in the RenderView's root layer. | 448 // Host the document layer in the RenderView's root layer. |
448 if (isFullUpdate) { | 449 if (isFullUpdate) { |
449 // Even when childList is empty, don't drop out of compositing mode
if there are | 450 // Even when childList is empty, don't drop out of compositing mode
if there are |
450 // composited layers that we didn't hit in our traversal (e.g. becau
se of visibility:hidden). | 451 // composited layers that we didn't hit in our traversal (e.g. becau
se of visibility:hidden). |
451 if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(updateR
oot)) | 452 if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(updateR
oot)) |
452 destroyRootLayer(); | 453 destroyRootLayer(); |
453 else | 454 else |
454 m_rootContentLayer->setChildren(childList); | 455 m_rootContentLayer->setChildren(childList); |
455 } | 456 } |
456 } else if (needGeometryUpdate) { | 457 } else if (needGeometryUpdate) { |
457 // We just need to do a geometry update. This is only used for position:
fixed scrolling; | 458 // We just need to do a geometry update. This is only used for position:
fixed scrolling; |
458 // most of the time, geometry is updated via RenderLayer::styleChanged()
. | 459 // most of the time, geometry is updated via RenderLayer::styleChanged()
. |
459 updateLayerTreeGeometry(updateRoot, 0); | 460 HashSet<RenderLayer*> visited; |
| 461 updateLayerTreeGeometry(updateRoot, visited, 0); |
460 } | 462 } |
461 | 463 |
462 #if !LOG_DISABLED | 464 #if !LOG_DISABLED |
463 if (compositingLogEnabled() && isFullUpdate && (needHierarchyUpdate || needG
eometryUpdate)) { | 465 if (compositingLogEnabled() && isFullUpdate && (needHierarchyUpdate || needG
eometryUpdate)) { |
464 double endTime = currentTime(); | 466 double endTime = currentTime(); |
465 LOG(Compositing, "Total layers primary secondary obligatory backin
g (KB) secondary backing(KB) total backing (KB) update time (ms)\n"); | 467 LOG(Compositing, "Total layers primary secondary obligatory backin
g (KB) secondary backing(KB) total backing (KB) update time (ms)\n"); |
466 | 468 |
467 LOG(Compositing, "%8d %11d %9d %20.2f %22.2f %22.2f %18.2f\n", | 469 LOG(Compositing, "%8d %11d %9d %20.2f %22.2f %22.2f %18.2f\n", |
468 m_obligateCompositedLayerCount + m_secondaryCompositedLayerCount, m_
obligateCompositedLayerCount, | 470 m_obligateCompositedLayerCount + m_secondaryCompositedLayerCount, m_
obligateCompositedLayerCount, |
469 m_secondaryCompositedLayerCount, m_obligatoryBackingStoreBytes / 102
4, m_secondaryBackingStoreBytes / 1024, (m_obligatoryBackingStoreBytes + m_secon
daryBackingStoreBytes) / 1024, 1000.0 * (endTime - startTime)); | 471 m_secondaryCompositedLayerCount, m_obligatoryBackingStoreBytes / 102
4, m_secondaryBackingStoreBytes / 1024, (m_obligatoryBackingStoreBytes + m_secon
daryBackingStoreBytes) / 1024, 1000.0 * (endTime - startTime)); |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 } | 1040 } |
1039 | 1041 |
1040 bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideo* o) const | 1042 bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideo* o) const |
1041 { | 1043 { |
1042 if (!m_hasAcceleratedCompositing) | 1044 if (!m_hasAcceleratedCompositing) |
1043 return false; | 1045 return false; |
1044 | 1046 |
1045 return o->supportsAcceleratedRendering(); | 1047 return o->supportsAcceleratedRendering(); |
1046 } | 1048 } |
1047 | 1049 |
1048 void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect
or<GraphicsLayer*>& childLayersOfEnclosingLayer, int depth) | 1050 // The purpose of this function is to ensure that we call rebuildCompostingLayer
Tree on curLayer's |
| 1051 // scroll parent (if it has one) before we call it on curLayer. This is necessar
y because rebuilding the |
| 1052 // compositing layer tree for curLayer will use values we computed for the scrol
l parent. More specifically, |
| 1053 // rebuildCompositingLayreTree will call RenderLayerBacking::updateGraphicsLayer
Geometry, and it's this |
| 1054 // function that will pull values from a scroll parent's graphics layers. Unfort
unately, |
| 1055 // the childList needs to be populated as if we'd visited all the layers in pain
t order. To work around |
| 1056 // this, when we visit a scroll parent out of order, we'll set its additions to
childList aside (in |
| 1057 // scrollParentChildLists), and add them to the real childList when we visit the
scroll parent in paint |
| 1058 // order. |
| 1059 void RenderLayerCompositor::rebuildCompositingLayerTreeForLayerAndScrollParents(
RenderLayer* curLayer, Vector<GraphicsLayer*>& childList, HashSet<RenderLayer*>&
visited, HashMap<RenderLayer*, Vector<GraphicsLayer*> >& scrollParentChildLists
, int depth) |
| 1060 { |
| 1061 ASSERT(curLayer->zIndex() >= 0 || !visited.contains(curLayer)); |
| 1062 if (visited.contains(curLayer)) { |
| 1063 // We've already processed this layer, but since we processed it out of
order, its |
| 1064 // contribution to childList was not added. We must do that now. |
| 1065 HashMap<RenderLayer*, Vector<GraphicsLayer*> >::iterator it = scrollPare
ntChildLists.find(curLayer); |
| 1066 ASSERT(it != scrollParentChildLists.end()); |
| 1067 childList.append(it->value); |
| 1068 scrollParentChildLists.remove(it); |
| 1069 return; |
| 1070 } |
| 1071 |
| 1072 if (requiresCompositingForOverflowScrollingParent(curLayer)) { |
| 1073 RenderLayer* scrollParent = curLayer->ancestorScrollingLayer(); |
| 1074 if (!visited.contains(scrollParent)) { |
| 1075 ASSERT(!scrollParentChildLists.contains(scrollParent)); |
| 1076 // We will populate scrollParentChildList rather than childList, sin
ce we're visiting it |
| 1077 // out of order. |
| 1078 Vector<GraphicsLayer*> scrollParentChildList; |
| 1079 rebuildCompositingLayerTreeForLayerAndScrollParents(scrollParent, sc
rollParentChildList, visited, scrollParentChildLists, depth); |
| 1080 // We will set aside the scrollParentChildList in scrollParentChildL
ists so that we can |
| 1081 // add it to childList when we visit the scrollParent normally. |
| 1082 scrollParentChildLists.add(scrollParent, scrollParentChildList); |
| 1083 } |
| 1084 } |
| 1085 |
| 1086 rebuildCompositingLayerTree(curLayer, childList, visited, depth); |
| 1087 } |
| 1088 |
| 1089 void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect
or<GraphicsLayer*>& childLayersOfEnclosingLayer, HashSet<RenderLayer*>& visited,
int depth) |
1049 { | 1090 { |
1050 // Make the layer compositing if necessary, and set up clipping and content
layers. | 1091 // Make the layer compositing if necessary, and set up clipping and content
layers. |
1051 // Note that we can only do work here that is independent of whether the des
cendant layers | 1092 // Note that we can only do work here that is independent of whether the des
cendant layers |
1052 // have been processed. computeCompositingRequirements() will already have d
one the repaint if necessary. | 1093 // have been processed. computeCompositingRequirements() will already have d
one the repaint if necessary. |
1053 | 1094 |
1054 // Used for gathering UMA data about the effect on memory usage of promoting
all layers | 1095 // Used for gathering UMA data about the effect on memory usage of promoting
all layers |
1055 // that have a webkit-transition on opacity or transform and intersect the v
iewport. | 1096 // that have a webkit-transition on opacity or transform and intersect the v
iewport. |
1056 static double pixelsWithoutPromotingAllTransitions = 0.0; | 1097 static double pixelsWithoutPromotingAllTransitions = 0.0; |
1057 static double pixelsAddedByPromotingAllTransitions = 0.0; | 1098 static double pixelsAddedByPromotingAllTransitions = 0.0; |
1058 | 1099 |
1059 if (!depth) { | 1100 if (!depth) { |
1060 pixelsWithoutPromotingAllTransitions = 0.0; | 1101 pixelsWithoutPromotingAllTransitions = 0.0; |
1061 pixelsAddedByPromotingAllTransitions = 0.0; | 1102 pixelsAddedByPromotingAllTransitions = 0.0; |
1062 } | 1103 } |
1063 | 1104 |
| 1105 visited.add(layer); |
| 1106 |
1064 RenderLayerBacking* layerBacking = layer->backing(); | 1107 RenderLayerBacking* layerBacking = layer->backing(); |
1065 if (layerBacking) { | 1108 if (layerBacking) { |
1066 // The compositing state of all our children has been updated already, s
o now | 1109 // The compositing state of all our children has been updated already, s
o now |
1067 // we can compute and cache the composited bounds for this layer. | 1110 // we can compute and cache the composited bounds for this layer. |
1068 layerBacking->updateCompositedBounds(); | 1111 layerBacking->updateCompositedBounds(); |
1069 | 1112 |
1070 if (RenderLayer* reflection = layer->reflectionLayer()) { | 1113 if (RenderLayer* reflection = layer->reflectionLayer()) { |
1071 if (reflection->backing()) | 1114 if (reflection->backing()) |
1072 reflection->backing()->updateCompositedBounds(); | 1115 reflection->backing()->updateCompositedBounds(); |
1073 } | 1116 } |
(...skipping 22 matching lines...) Expand all Loading... |
1096 | 1139 |
1097 // If this layer has backing, then we are collecting its children, otherwise
appending | 1140 // If this layer has backing, then we are collecting its children, otherwise
appending |
1098 // to the compositing child list of an enclosing layer. | 1141 // to the compositing child list of an enclosing layer. |
1099 Vector<GraphicsLayer*> layerChildren; | 1142 Vector<GraphicsLayer*> layerChildren; |
1100 Vector<GraphicsLayer*>& childList = layerBacking ? layerChildren : childLaye
rsOfEnclosingLayer; | 1143 Vector<GraphicsLayer*>& childList = layerBacking ? layerChildren : childLaye
rsOfEnclosingLayer; |
1101 | 1144 |
1102 #if !ASSERT_DISABLED | 1145 #if !ASSERT_DISABLED |
1103 LayerListMutationDetector mutationChecker(layer); | 1146 LayerListMutationDetector mutationChecker(layer); |
1104 #endif | 1147 #endif |
1105 | 1148 |
| 1149 HashMap<RenderLayer*, Vector<GraphicsLayer*> > scrollParentChildLists; |
1106 if (layer->isStackingContainer()) { | 1150 if (layer->isStackingContainer()) { |
1107 if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) { | 1151 if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) { |
1108 size_t listSize = negZOrderList->size(); | 1152 size_t listSize = negZOrderList->size(); |
1109 for (size_t i = 0; i < listSize; ++i) { | 1153 for (size_t i = 0; i < listSize; ++i) { |
1110 RenderLayer* curLayer = negZOrderList->at(i); | 1154 RenderLayer* curLayer = negZOrderList->at(i); |
1111 rebuildCompositingLayerTree(curLayer, childList, depth + 1); | 1155 rebuildCompositingLayerTreeForLayerAndScrollParents(curLayer, ch
ildList, visited, scrollParentChildLists, depth + 1); |
1112 } | 1156 } |
1113 } | 1157 } |
1114 | 1158 |
1115 // If a negative z-order child is compositing, we get a foreground layer
which needs to get parented. | 1159 // If a negative z-order child is compositing, we get a foreground layer
which needs to get parented. |
1116 if (layerBacking && layerBacking->foregroundLayer()) | 1160 if (layerBacking && layerBacking->foregroundLayer()) |
1117 childList.append(layerBacking->foregroundLayer()); | 1161 childList.append(layerBacking->foregroundLayer()); |
1118 } | 1162 } |
1119 | 1163 |
1120 if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) { | 1164 if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) { |
1121 size_t listSize = normalFlowList->size(); | 1165 size_t listSize = normalFlowList->size(); |
1122 for (size_t i = 0; i < listSize; ++i) { | 1166 for (size_t i = 0; i < listSize; ++i) { |
1123 RenderLayer* curLayer = normalFlowList->at(i); | 1167 RenderLayer* curLayer = normalFlowList->at(i); |
1124 rebuildCompositingLayerTree(curLayer, childList, depth + 1); | 1168 rebuildCompositingLayerTreeForLayerAndScrollParents(curLayer, childL
ist, visited, scrollParentChildLists, depth + 1); |
1125 } | 1169 } |
1126 } | 1170 } |
1127 | 1171 |
1128 if (layer->isStackingContainer()) { | 1172 if (layer->isStackingContainer()) { |
1129 if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) { | 1173 if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) { |
1130 size_t listSize = posZOrderList->size(); | 1174 size_t listSize = posZOrderList->size(); |
1131 for (size_t i = 0; i < listSize; ++i) { | 1175 for (size_t i = 0; i < listSize; ++i) { |
1132 RenderLayer* curLayer = posZOrderList->at(i); | 1176 RenderLayer* curLayer = posZOrderList->at(i); |
1133 rebuildCompositingLayerTree(curLayer, childList, depth + 1); | 1177 rebuildCompositingLayerTreeForLayerAndScrollParents(curLayer, ch
ildList, visited, scrollParentChildLists, depth + 1); |
1134 } | 1178 } |
1135 } | 1179 } |
1136 } | 1180 } |
1137 | 1181 |
1138 if (layerBacking) { | 1182 if (layerBacking) { |
1139 bool parented = false; | 1183 bool parented = false; |
1140 if (layer->renderer()->isRenderPart()) | 1184 if (layer->renderer()->isRenderPart()) |
1141 parented = parentFrameContentLayers(toRenderPart(layer->renderer()))
; | 1185 parented = parentFrameContentLayers(toRenderPart(layer->renderer()))
; |
1142 | 1186 |
1143 if (!parented) | 1187 if (!parented) |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 RenderLayerBacking* backing = layer->backing(); | 1369 RenderLayerBacking* backing = layer->backing(); |
1326 GraphicsLayer* hostingLayer = backing->parentForSublayers(); | 1370 GraphicsLayer* hostingLayer = backing->parentForSublayers(); |
1327 GraphicsLayer* rootLayer = innerCompositor->rootGraphicsLayer(); | 1371 GraphicsLayer* rootLayer = innerCompositor->rootGraphicsLayer(); |
1328 if (hostingLayer->children().size() != 1 || hostingLayer->children()[0] != r
ootLayer) { | 1372 if (hostingLayer->children().size() != 1 || hostingLayer->children()[0] != r
ootLayer) { |
1329 hostingLayer->removeAllChildren(); | 1373 hostingLayer->removeAllChildren(); |
1330 hostingLayer->addChild(rootLayer); | 1374 hostingLayer->addChild(rootLayer); |
1331 } | 1375 } |
1332 return true; | 1376 return true; |
1333 } | 1377 } |
1334 | 1378 |
| 1379 // The purpose of this function is to ensure that we call updateLayerTreeGeometr
y on layer's |
| 1380 // scroll parent (if it has one) before we call it on layer. This is necessary b
ecause updating |
| 1381 // layer tree geometry for layer will use values we computed for its scroll pare
nt. |
| 1382 void RenderLayerCompositor::updateLayerTreeGeometryForLayerAndScrollParents(Rend
erLayer* layer, HashSet<RenderLayer*>& visited, int depth) |
| 1383 { |
| 1384 ASSERT(layer->zIndex() >= 0 || !visited.contains(layer)); |
| 1385 if (visited.contains(layer)) |
| 1386 return; |
| 1387 |
| 1388 if (requiresCompositingForOverflowScrollingParent(layer)) { |
| 1389 RenderLayer* scrollParent = layer->ancestorScrollingLayer(); |
| 1390 if (!visited.contains(scrollParent)) |
| 1391 updateLayerTreeGeometryForLayerAndScrollParents(scrollParent, visite
d, depth); |
| 1392 } |
| 1393 |
| 1394 updateLayerTreeGeometry(layer, visited, depth); |
| 1395 } |
| 1396 |
1335 // This just updates layer geometry without changing the hierarchy. | 1397 // This just updates layer geometry without changing the hierarchy. |
1336 void RenderLayerCompositor::updateLayerTreeGeometry(RenderLayer* layer, int dept
h) | 1398 void RenderLayerCompositor::updateLayerTreeGeometry(RenderLayer* layer, HashSet<
RenderLayer*>& visited, int depth) |
1337 { | 1399 { |
| 1400 visited.add(layer); |
| 1401 |
1338 if (RenderLayerBacking* layerBacking = layer->backing()) { | 1402 if (RenderLayerBacking* layerBacking = layer->backing()) { |
1339 // The compositing state of all our children has been updated already, s
o now | 1403 // The compositing state of all our children has been updated already, s
o now |
1340 // we can compute and cache the composited bounds for this layer. | 1404 // we can compute and cache the composited bounds for this layer. |
1341 layerBacking->updateCompositedBounds(); | 1405 layerBacking->updateCompositedBounds(); |
1342 | 1406 |
1343 if (RenderLayer* reflection = layer->reflectionLayer()) { | 1407 if (RenderLayer* reflection = layer->reflectionLayer()) { |
1344 if (reflection->backing()) | 1408 if (reflection->backing()) |
1345 reflection->backing()->updateCompositedBounds(); | 1409 reflection->backing()->updateCompositedBounds(); |
1346 } | 1410 } |
1347 | 1411 |
1348 layerBacking->updateGraphicsLayerConfiguration(); | 1412 layerBacking->updateGraphicsLayerConfiguration(); |
1349 layerBacking->updateGraphicsLayerGeometry(); | 1413 layerBacking->updateGraphicsLayerGeometry(); |
1350 | 1414 |
1351 if (!layer->parent()) | 1415 if (!layer->parent()) |
1352 updateRootLayerPosition(); | 1416 updateRootLayerPosition(); |
1353 | 1417 |
1354 #if !LOG_DISABLED | 1418 #if !LOG_DISABLED |
1355 logLayerInfo(layer, depth); | 1419 logLayerInfo(layer, depth); |
1356 #else | 1420 #else |
1357 UNUSED_PARAM(depth); | 1421 UNUSED_PARAM(depth); |
1358 #endif | 1422 #endif |
1359 } | 1423 } |
1360 | 1424 |
1361 #if !ASSERT_DISABLED | 1425 #if !ASSERT_DISABLED |
1362 LayerListMutationDetector mutationChecker(layer); | 1426 LayerListMutationDetector mutationChecker(layer); |
1363 #endif | 1427 #endif |
1364 | 1428 |
| 1429 if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) { |
| 1430 size_t listSize = normalFlowList->size(); |
| 1431 for (size_t i = 0; i < listSize; ++i) |
| 1432 updateLayerTreeGeometry(normalFlowList->at(i), visited, depth + 1); |
| 1433 } |
| 1434 |
1365 if (layer->isStackingContainer()) { | 1435 if (layer->isStackingContainer()) { |
1366 if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) { | 1436 if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) { |
1367 size_t listSize = negZOrderList->size(); | 1437 size_t listSize = negZOrderList->size(); |
1368 for (size_t i = 0; i < listSize; ++i) | 1438 for (size_t i = 0; i < listSize; ++i) |
1369 updateLayerTreeGeometry(negZOrderList->at(i), depth + 1); | 1439 updateLayerTreeGeometryForLayerAndScrollParents(negZOrderList->a
t(i), visited, depth + 1); |
1370 } | 1440 } |
1371 } | 1441 } |
1372 | 1442 |
1373 if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) { | |
1374 size_t listSize = normalFlowList->size(); | |
1375 for (size_t i = 0; i < listSize; ++i) | |
1376 updateLayerTreeGeometry(normalFlowList->at(i), depth + 1); | |
1377 } | |
1378 | |
1379 if (layer->isStackingContainer()) { | 1443 if (layer->isStackingContainer()) { |
1380 if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) { | 1444 if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) { |
1381 size_t listSize = posZOrderList->size(); | 1445 size_t listSize = posZOrderList->size(); |
1382 for (size_t i = 0; i < listSize; ++i) | 1446 for (size_t i = 0; i < listSize; ++i) |
1383 updateLayerTreeGeometry(posZOrderList->at(i), depth + 1); | 1447 updateLayerTreeGeometryForLayerAndScrollParents(posZOrderList->a
t(i), visited, depth + 1); |
1384 } | 1448 } |
1385 } | 1449 } |
1386 } | 1450 } |
1387 | 1451 |
| 1452 // The purpose of this function is to ensure that we call updateCompositingDesce
ndantGeometry on layer's |
| 1453 // scroll parent (if it has one) before we call it on layer. This is necessary b
ecause updating |
| 1454 // layer tree geometry for layer will use values we computed for its scroll pare
nt. |
| 1455 void RenderLayerCompositor::updateCompositingDescendantGeometryForLayerAndScroll
Parents(RenderLayer* compositingAncestor, RenderLayer* layer, HashSet<RenderLaye
r*>& visited, bool compositedChildrenOnly) |
| 1456 { |
| 1457 ASSERT(layer->zIndex() >= 0 || !visited.contains(layer)); |
| 1458 if (visited.contains(layer)) |
| 1459 return; |
| 1460 |
| 1461 if (requiresCompositingForOverflowScrollingParent(layer)) { |
| 1462 RenderLayer* scrollParent = layer->ancestorScrollingLayer(); |
| 1463 if (!visited.contains(scrollParent)) |
| 1464 updateCompositingDescendantGeometryForLayerAndScrollParents(composit
ingAncestor, scrollParent, visited, compositedChildrenOnly); |
| 1465 } |
| 1466 |
| 1467 updateCompositingDescendantGeometry(compositingAncestor, layer, visited, com
positedChildrenOnly); |
| 1468 } |
| 1469 |
1388 // Recurs down the RenderLayer tree until its finds the compositing descendants
of compositingAncestor and updates their geometry. | 1470 // Recurs down the RenderLayer tree until its finds the compositing descendants
of compositingAncestor and updates their geometry. |
1389 void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayer* com
positingAncestor, RenderLayer* layer, bool compositedChildrenOnly) | 1471 void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayer* com
positingAncestor, RenderLayer* layer, HashSet<RenderLayer*>& visited, bool compo
sitedChildrenOnly) |
1390 { | 1472 { |
| 1473 visited.add(layer); |
| 1474 |
1391 if (layer != compositingAncestor) { | 1475 if (layer != compositingAncestor) { |
1392 if (RenderLayerBacking* layerBacking = layer->backing()) { | 1476 if (RenderLayerBacking* layerBacking = layer->backing()) { |
1393 layerBacking->updateCompositedBounds(); | 1477 layerBacking->updateCompositedBounds(); |
1394 | 1478 |
1395 if (RenderLayer* reflection = layer->reflectionLayer()) { | 1479 if (RenderLayer* reflection = layer->reflectionLayer()) { |
1396 if (reflection->backing()) | 1480 if (reflection->backing()) |
1397 reflection->backing()->updateCompositedBounds(); | 1481 reflection->backing()->updateCompositedBounds(); |
1398 } | 1482 } |
1399 | 1483 |
1400 layerBacking->updateGraphicsLayerGeometry(); | 1484 layerBacking->updateGraphicsLayerGeometry(); |
1401 if (compositedChildrenOnly) | 1485 if (compositedChildrenOnly) |
1402 return; | 1486 return; |
1403 } | 1487 } |
1404 } | 1488 } |
1405 | 1489 |
1406 if (layer->reflectionLayer()) | 1490 if (layer->reflectionLayer()) |
1407 updateCompositingDescendantGeometry(compositingAncestor, layer->reflecti
onLayer(), compositedChildrenOnly); | 1491 updateCompositingDescendantGeometry(compositingAncestor, layer->reflecti
onLayer(), visited, compositedChildrenOnly); |
1408 | 1492 |
1409 if (!layer->hasCompositingDescendant()) | 1493 if (!layer->hasCompositingDescendant()) |
1410 return; | 1494 return; |
1411 | 1495 |
1412 #if !ASSERT_DISABLED | 1496 #if !ASSERT_DISABLED |
1413 LayerListMutationDetector mutationChecker(layer); | 1497 LayerListMutationDetector mutationChecker(layer); |
1414 #endif | 1498 #endif |
1415 | 1499 |
1416 if (layer->isStackingContainer()) { | 1500 if (layer->isStackingContainer()) { |
1417 if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) { | 1501 if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) { |
1418 size_t listSize = negZOrderList->size(); | 1502 size_t listSize = negZOrderList->size(); |
1419 for (size_t i = 0; i < listSize; ++i) | 1503 for (size_t i = 0; i < listSize; ++i) |
1420 updateCompositingDescendantGeometry(compositingAncestor, negZOrd
erList->at(i), compositedChildrenOnly); | 1504 updateCompositingDescendantGeometryForLayerAndScrollParents(comp
ositingAncestor, negZOrderList->at(i), visited, compositedChildrenOnly); |
1421 } | 1505 } |
1422 } | 1506 } |
1423 | 1507 |
1424 if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) { | 1508 if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) { |
1425 size_t listSize = normalFlowList->size(); | 1509 size_t listSize = normalFlowList->size(); |
1426 for (size_t i = 0; i < listSize; ++i) | 1510 for (size_t i = 0; i < listSize; ++i) |
1427 updateCompositingDescendantGeometry(compositingAncestor, normalFlowL
ist->at(i), compositedChildrenOnly); | 1511 updateCompositingDescendantGeometryForLayerAndScrollParents(composit
ingAncestor, normalFlowList->at(i), visited, compositedChildrenOnly); |
1428 } | 1512 } |
1429 | 1513 |
1430 if (layer->isStackingContainer()) { | 1514 if (layer->isStackingContainer()) { |
1431 if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) { | 1515 if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) { |
1432 size_t listSize = posZOrderList->size(); | 1516 size_t listSize = posZOrderList->size(); |
1433 for (size_t i = 0; i < listSize; ++i) | 1517 for (size_t i = 0; i < listSize; ++i) |
1434 updateCompositingDescendantGeometry(compositingAncestor, posZOrd
erList->at(i), compositedChildrenOnly); | 1518 updateCompositingDescendantGeometryForLayerAndScrollParents(comp
ositingAncestor, posZOrderList->at(i), visited, compositedChildrenOnly); |
1435 } | 1519 } |
1436 } | 1520 } |
1437 } | 1521 } |
1438 | 1522 |
1439 | 1523 |
1440 void RenderLayerCompositor::repaintCompositedLayers(const IntRect* absRect) | 1524 void RenderLayerCompositor::repaintCompositedLayers(const IntRect* absRect) |
1441 { | 1525 { |
1442 recursiveRepaintLayer(rootRenderLayer(), absRect); | 1526 recursiveRepaintLayer(rootRenderLayer(), absRect); |
1443 } | 1527 } |
1444 | 1528 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 | 1848 |
1765 return ""; | 1849 return ""; |
1766 } | 1850 } |
1767 #endif | 1851 #endif |
1768 | 1852 |
1769 // Return true if the given layer has some ancestor in the RenderLayer hierarchy
that clips, | 1853 // Return true if the given layer has some ancestor in the RenderLayer hierarchy
that clips, |
1770 // up to the enclosing compositing ancestor. This is required because compositin
g layers are parented | 1854 // up to the enclosing compositing ancestor. This is required because compositin
g layers are parented |
1771 // according to the z-order hierarchy, yet clipping goes down the renderer hiera
rchy. | 1855 // according to the z-order hierarchy, yet clipping goes down the renderer hiera
rchy. |
1772 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th
e renderer hierarchy, | 1856 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th
e renderer hierarchy, |
1773 // but a sibling in the z-order hierarchy. | 1857 // but a sibling in the z-order hierarchy. |
1774 bool RenderLayerCompositor::clippedByAncestor(RenderLayer* layer) const | 1858 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const |
1775 { | 1859 { |
1776 if (!layer->isComposited() || !layer->parent()) | 1860 if (!layer->isComposited() || !layer->parent()) |
1777 return false; | 1861 return false; |
1778 | 1862 |
1779 RenderLayer* compositingAncestor = layer->ancestorCompositingLayer(); | 1863 // Scroll children use their scrolling ancestor as their clip root. |
| 1864 RenderLayer* compositingAncestor = requiresCompositingForOverflowScrollingPa
rent(layer) |
| 1865 ? layer->ancestorScrollingLayer() |
| 1866 : layer->ancestorCompositingLayer(); |
| 1867 |
1780 if (!compositingAncestor) | 1868 if (!compositingAncestor) |
1781 return false; | 1869 return false; |
1782 | 1870 |
1783 // If the compositingAncestor clips, that will be taken care of by clipsComp
ositingDescendants(), | 1871 // If the compositingAncestor clips, that will be taken care of by clipsComp
ositingDescendants(), |
1784 // so we only care about clipping between its first child that is our ancest
or (the computeClipRoot), | 1872 // so we only care about clipping between its first child that is our ancest
or (the computeClipRoot), |
1785 // and layer. | 1873 // and layer. |
1786 RenderLayer* computeClipRoot = 0; | 1874 const RenderLayer* computeClipRoot = 0; |
1787 RenderLayer* curr = layer; | 1875 const RenderLayer* curr = layer; |
1788 while (curr) { | 1876 while (curr) { |
1789 RenderLayer* next = curr->parent(); | 1877 const RenderLayer* next = curr->parent(); |
1790 if (next == compositingAncestor) { | 1878 if (next == compositingAncestor) { |
1791 computeClipRoot = curr; | 1879 computeClipRoot = curr; |
1792 break; | 1880 break; |
1793 } | 1881 } |
1794 curr = next; | 1882 curr = next; |
1795 } | 1883 } |
1796 | 1884 |
1797 if (!computeClipRoot || computeClipRoot == layer) | 1885 if (!computeClipRoot || computeClipRoot == layer) |
1798 return false; | 1886 return false; |
1799 | 1887 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1991 return renderer->hasFilter(); | 2079 return renderer->hasFilter(); |
1992 } | 2080 } |
1993 | 2081 |
1994 bool RenderLayerCompositor::requiresCompositingForBlending(RenderObject* rendere
r) const | 2082 bool RenderLayerCompositor::requiresCompositingForBlending(RenderObject* rendere
r) const |
1995 { | 2083 { |
1996 return renderer->hasBlendMode(); | 2084 return renderer->hasBlendMode(); |
1997 } | 2085 } |
1998 | 2086 |
1999 bool RenderLayerCompositor::requiresCompositingForOverflowScrollingParent(const
RenderLayer* layer) const | 2087 bool RenderLayerCompositor::requiresCompositingForOverflowScrollingParent(const
RenderLayer* layer) const |
2000 { | 2088 { |
2001 if (!layer->compositorDrivenAcceleratedScrollingEnabled()) | 2089 return !!layer->scrollParent(); |
2002 return false; | |
2003 | |
2004 // A layer scrolls with its containing block. So to find the overflow scroll
ing layer | |
2005 // that we scroll with respect to, we must ascend the layer tree until we re
ach the | |
2006 // first overflow scrolling div at or above our containing block. I will ref
er to this | |
2007 // layer as our 'scrolling ancestor'. | |
2008 // | |
2009 // Now, if we reside in a normal flow list, then we will naturally scroll wi
th our scrolling | |
2010 // ancestor, and we need not be composited. If, on the other hand, we reside
in a z-order | |
2011 // list, and on our walk upwards to our scrolling ancestor we find no layer
that is a stacking | |
2012 // context, then we know that in the stacking tree, we will not be in the su
btree rooted at | |
2013 // our scrolling ancestor, and we will therefore not scroll with it. In this
case, we must | |
2014 // be a composited layer since the compositor will need to take special meas
ures to ensure | |
2015 // that we scroll with our scrolling ancestor and it cannot do this if we do
not promote. | |
2016 RenderLayer* scrollParent = layer->ancestorScrollingLayer(); | |
2017 | |
2018 if (!scrollParent || scrollParent->isStackingContext()) | |
2019 return false; | |
2020 | |
2021 // If we hit a stacking context on our way up to the ancestor scrolling laye
r, it will already | |
2022 // be composited due to an overflow scrolling parent, so we don't need to. | |
2023 for (RenderLayer* ancestor = layer->parent(); ancestor && ancestor != scroll
Parent; ancestor = ancestor->parent()) { | |
2024 if (ancestor->isStackingContext()) | |
2025 return false; | |
2026 } | |
2027 | |
2028 return true; | |
2029 } | 2090 } |
2030 | 2091 |
2031 bool RenderLayerCompositor::requiresCompositingForOutOfFlowClipping(const Render
Layer* layer) const | 2092 bool RenderLayerCompositor::requiresCompositingForOutOfFlowClipping(const Render
Layer* layer) const |
2032 { | 2093 { |
2033 return layer->compositorDrivenAcceleratedScrollingEnabled() && layer->isUncl
ippedDescendant(); | 2094 return layer->compositorDrivenAcceleratedScrollingEnabled() && layer->isUncl
ippedDescendant(); |
2034 } | 2095 } |
2035 | 2096 |
2036 bool RenderLayerCompositor::requiresCompositingForPosition(RenderObject* rendere
r, const RenderLayer* layer, RenderLayer::ViewportConstrainedNotCompositedReason
* viewportConstrainedNotCompositedReason) const | 2097 bool RenderLayerCompositor::requiresCompositingForPosition(RenderObject* rendere
r, const RenderLayer* layer, RenderLayer::ViewportConstrainedNotCompositedReason
* viewportConstrainedNotCompositedReason) const |
2037 { | 2098 { |
2038 // position:fixed elements that create their own stacking context (e.g. have
an explicit z-index, | 2099 // position:fixed elements that create their own stacking context (e.g. have
an explicit z-index, |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2755 } else if (graphicsLayer == m_scrollLayer.get()) { | 2816 } else if (graphicsLayer == m_scrollLayer.get()) { |
2756 name = "Frame Scrolling Layer"; | 2817 name = "Frame Scrolling Layer"; |
2757 } else { | 2818 } else { |
2758 ASSERT_NOT_REACHED(); | 2819 ASSERT_NOT_REACHED(); |
2759 } | 2820 } |
2760 | 2821 |
2761 return name; | 2822 return name; |
2762 } | 2823 } |
2763 | 2824 |
2764 } // namespace WebCore | 2825 } // namespace WebCore |
OLD | NEW |