Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 #include "core/rendering/RenderEmbeddedObject.h" | 52 #include "core/rendering/RenderEmbeddedObject.h" |
| 53 #include "core/rendering/RenderFullScreen.h" | 53 #include "core/rendering/RenderFullScreen.h" |
| 54 #include "core/rendering/RenderGeometryMap.h" | 54 #include "core/rendering/RenderGeometryMap.h" |
| 55 #include "core/rendering/RenderIFrame.h" | 55 #include "core/rendering/RenderIFrame.h" |
| 56 #include "core/rendering/RenderLayerStackingNode.h" | 56 #include "core/rendering/RenderLayerStackingNode.h" |
| 57 #include "core/rendering/RenderLayerStackingNodeIterator.h" | 57 #include "core/rendering/RenderLayerStackingNodeIterator.h" |
| 58 #include "core/rendering/RenderReplica.h" | 58 #include "core/rendering/RenderReplica.h" |
| 59 #include "core/rendering/RenderVideo.h" | 59 #include "core/rendering/RenderVideo.h" |
| 60 #include "core/rendering/RenderView.h" | 60 #include "core/rendering/RenderView.h" |
| 61 #include "core/rendering/compositing/CompositedLayerMapping.h" | 61 #include "core/rendering/compositing/CompositedLayerMapping.h" |
| 62 #include "core/rendering/compositing/GraphicsLayerUpdater.h" | |
| 62 #include "platform/OverscrollTheme.h" | 63 #include "platform/OverscrollTheme.h" |
| 63 #include "platform/TraceEvent.h" | 64 #include "platform/TraceEvent.h" |
| 64 #include "platform/geometry/TransformState.h" | 65 #include "platform/geometry/TransformState.h" |
| 65 #include "platform/graphics/GraphicsLayer.h" | 66 #include "platform/graphics/GraphicsLayer.h" |
| 66 #include "platform/scroll/ScrollbarTheme.h" | 67 #include "platform/scroll/ScrollbarTheme.h" |
| 67 #include "public/platform/Platform.h" | 68 #include "public/platform/Platform.h" |
| 68 #include "wtf/TemporaryChange.h" | 69 #include "wtf/TemporaryChange.h" |
| 69 | 70 |
| 70 #ifndef NDEBUG | 71 #ifndef NDEBUG |
| 71 #include "core/rendering/RenderTreeAsText.h" | 72 #include "core/rendering/RenderTreeAsText.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 | 466 |
| 466 { | 467 { |
| 467 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::updateHasVis ibleNonLayerContentLoop"); | 468 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::updateHasVis ibleNonLayerContentLoop"); |
| 468 const FrameView::ScrollableAreaSet* scrollableAreas = m_renderView-> frameView()->scrollableAreas(); | 469 const FrameView::ScrollableAreaSet* scrollableAreas = m_renderView-> frameView()->scrollableAreas(); |
| 469 if (scrollableAreas) { | 470 if (scrollableAreas) { |
| 470 for (FrameView::ScrollableAreaSet::iterator it = scrollableAreas ->begin(); it != scrollableAreas->end(); ++it) | 471 for (FrameView::ScrollableAreaSet::iterator it = scrollableAreas ->begin(); it != scrollableAreas->end(); ++it) |
| 471 (*it)->updateHasVisibleNonLayerContent(); | 472 (*it)->updateHasVisibleNonLayerContent(); |
| 472 } | 473 } |
| 473 } | 474 } |
| 474 | 475 |
| 475 needHierarchyAndGeometryUpdate |= layersChanged; | 476 if (layersChanged) |
| 477 needHierarchyAndGeometryUpdate = true; | |
| 476 } | 478 } |
| 477 | 479 |
| 478 if (needHierarchyAndGeometryUpdate) { | 480 if (needHierarchyAndGeometryUpdate) { |
| 479 // Update the hierarchy of the compositing layers. | 481 // Update the hierarchy of the compositing layers. |
| 480 Vector<GraphicsLayer*> childList; | 482 Vector<GraphicsLayer*> childList; |
| 481 { | 483 { |
| 482 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::rebuildCompo sitingLayerTree"); | 484 TRACE_EVENT0("blink_rendering", "GraphicsLayerUpdater::rebuildTree") ; |
| 483 rebuildCompositingLayerTree(updateRoot, childList, 0); | 485 GraphicsLayerUpdater updater(*m_renderView); |
| 486 updater.rebuildTree(updateRoot, childList, 0); | |
| 484 } | 487 } |
| 485 | 488 |
| 486 // Host the document layer in the RenderView's root layer. | 489 // Host the document layer in the RenderView's root layer. |
| 487 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isMainFra me()) { | 490 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isMainFra me()) { |
| 488 RenderVideo* video = findFullscreenVideoRenderer(m_renderView->docum ent()); | 491 RenderVideo* video = findFullscreenVideoRenderer(m_renderView->docum ent()); |
| 489 if (video && video->hasCompositedLayerMapping()) { | 492 if (video && video->hasCompositedLayerMapping()) { |
| 490 childList.clear(); | 493 childList.clear(); |
| 491 childList.append(video->compositedLayerMapping()->mainGraphicsLa yer()); | 494 childList.append(video->compositedLayerMapping()->mainGraphicsLa yer()); |
| 492 } | 495 } |
| 493 } | 496 } |
| 494 | 497 |
| 495 if (childList.isEmpty()) | 498 if (childList.isEmpty()) |
| 496 destroyRootLayer(); | 499 destroyRootLayer(); |
| 497 else | 500 else |
| 498 m_rootContentLayer->setChildren(childList); | 501 m_rootContentLayer->setChildren(childList); |
| 499 } else if (needGeometryUpdate) { | 502 } else if (needGeometryUpdate) { |
| 500 // We just need to do a geometry update. This is only used for position: fixed scrolling; | 503 // We just need to do a geometry update. This is only used for position: fixed scrolling; |
| 501 // most of the time, geometry is updated via RenderLayer::styleChanged() . | 504 // most of the time, geometry is updated via RenderLayer::styleChanged() . |
| 502 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::updateLayerTreeG eometry"); | 505 TRACE_EVENT0("blink_rendering", "GraphicsLayerUpdater::updateRecursive") ; |
| 503 updateLayerTreeGeometry(updateRoot); | 506 GraphicsLayerUpdater updater(*m_renderView); |
| 507 updater.updateRecursive(updateRoot); | |
|
esprehn
2014/03/01 09:37:07
We often just do
AlgorithmObject(...).updateRecur
abarth-chromium
2014/03/01 09:40:39
Will do
| |
| 504 } | 508 } |
| 505 | 509 |
| 506 ASSERT(updateRoot || !m_compositingLayersNeedRebuild); | 510 ASSERT(updateRoot || !m_compositingLayersNeedRebuild); |
| 507 | 511 |
| 508 if (!hasAcceleratedCompositing()) | 512 if (!hasAcceleratedCompositing()) |
| 509 enableCompositingMode(false); | 513 enableCompositingMode(false); |
| 510 | 514 |
| 511 // The scrolling coordinator may realize that it needs updating while compos iting was being updated in this function. | 515 // The scrolling coordinator may realize that it needs updating while compos iting was being updated in this function. |
| 512 needsToUpdateScrollingCoordinator |= scrollingCoordinator() ? scrollingCoord inator()->needsToUpdateAfterCompositingChange() : false; | 516 needsToUpdateScrollingCoordinator |= scrollingCoordinator() ? scrollingCoord inator()->needsToUpdateAfterCompositingChange() : false; |
| 513 if (needsToUpdateScrollingCoordinator && isMainFrame() && scrollingCoordinat or() && inCompositingMode()) | 517 if (needsToUpdateScrollingCoordinator && isMainFrame() && scrollingCoordinat or() && inCompositingMode()) |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1270 } | 1274 } |
| 1271 | 1275 |
| 1272 void RenderLayerCompositor::removeCompositedChildren(RenderLayer* layer) | 1276 void RenderLayerCompositor::removeCompositedChildren(RenderLayer* layer) |
| 1273 { | 1277 { |
| 1274 ASSERT(layer->hasCompositedLayerMapping()); | 1278 ASSERT(layer->hasCompositedLayerMapping()); |
| 1275 | 1279 |
| 1276 GraphicsLayer* hostingLayer = layer->compositedLayerMapping()->parentForSubl ayers(); | 1280 GraphicsLayer* hostingLayer = layer->compositedLayerMapping()->parentForSubl ayers(); |
| 1277 hostingLayer->removeAllChildren(); | 1281 hostingLayer->removeAllChildren(); |
| 1278 } | 1282 } |
| 1279 | 1283 |
| 1280 void RenderLayerCompositor::updateGraphicsLayersMappedToRenderLayer(RenderLayer* layer) | |
| 1281 { | |
| 1282 if (!layer->hasCompositedLayerMapping()) | |
| 1283 return; | |
| 1284 | |
| 1285 CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLayerMap ping(); | |
| 1286 | |
| 1287 // Note carefully: here we assume that the compositing state of all descenda nts have been updated already, | |
| 1288 // so it is legitimate to compute and cache the composited bounds for this l ayer. | |
| 1289 compositedLayerMapping->updateCompositedBounds(); | |
| 1290 | |
| 1291 if (layer->reflectionInfo()) { | |
| 1292 RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLayer( ); | |
| 1293 ASSERT(reflectionLayer); | |
| 1294 if (reflectionLayer->hasCompositedLayerMapping()) | |
| 1295 reflectionLayer->compositedLayerMapping()->updateCompositedBounds(); | |
| 1296 } | |
| 1297 | |
| 1298 compositedLayerMapping->updateGraphicsLayerConfiguration(); | |
| 1299 compositedLayerMapping->updateGraphicsLayerGeometry(); | |
| 1300 | |
| 1301 if (!layer->parent()) | |
| 1302 updateRootLayerPosition(); | |
| 1303 | |
| 1304 if (compositedLayerMapping->hasUnpositionedOverflowControlsLayers()) | |
| 1305 layer->scrollableArea()->positionOverflowControls(); | |
| 1306 } | |
| 1307 | |
| 1308 void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer* layer, Vect or<GraphicsLayer*>& childLayersOfEnclosingLayer, int depth) | |
| 1309 { | |
| 1310 // Make the layer compositing if necessary, and set up clipping and content layers. | |
| 1311 // Note that we can only do work here that is independent of whether the des cendant layers | |
| 1312 // have been processed. computeCompositingRequirements() will already have d one the repaint if necessary. | |
| 1313 | |
| 1314 layer->stackingNode()->updateLayerListsIfNeeded(); | |
| 1315 layer->update3dRenderingContext(); | |
| 1316 | |
| 1317 // Used for gathering UMA data about the effect on memory usage of promoting all layers | |
| 1318 // that have a webkit-transition on opacity or transform and intersect the v iewport. | |
| 1319 static double pixelsWithoutPromotingAllTransitions = 0.0; | |
| 1320 static double pixelsAddedByPromotingAllTransitions = 0.0; | |
| 1321 | |
| 1322 if (!depth) { | |
| 1323 pixelsWithoutPromotingAllTransitions = 0.0; | |
| 1324 pixelsAddedByPromotingAllTransitions = 0.0; | |
| 1325 } | |
| 1326 | |
| 1327 const bool hasCompositedLayerMapping = layer->hasCompositedLayerMapping(); | |
| 1328 CompositedLayerMappingPtr currentCompositedLayerMapping = layer->compositedL ayerMapping(); | |
| 1329 | |
| 1330 updateGraphicsLayersMappedToRenderLayer(layer); | |
| 1331 | |
| 1332 // Grab some stats for histograms. | |
| 1333 if (hasCompositedLayerMapping) { | |
| 1334 pixelsWithoutPromotingAllTransitions += layer->size().height() * layer-> size().width(); | |
| 1335 } else { | |
| 1336 if ((layer->renderer()->style()->transitionForProperty(CSSPropertyOpacit y) || | |
| 1337 layer->renderer()->style()->transitionForProperty(CSSPropertyWebkit Transform)) && | |
| 1338 m_renderView->viewRect().intersects(layer->absoluteBoundingBox())) | |
| 1339 pixelsAddedByPromotingAllTransitions += layer->size().height() * lay er->size().width(); | |
| 1340 } | |
| 1341 | |
| 1342 // If this layer has a compositedLayerMapping, then that is where we place s ubsequent children GraphicsLayers. | |
| 1343 // Otherwise children continue to append to the child list of the enclosing layer. | |
| 1344 Vector<GraphicsLayer*> layerChildren; | |
| 1345 Vector<GraphicsLayer*>& childList = hasCompositedLayerMapping ? layerChildre n : childLayersOfEnclosingLayer; | |
| 1346 | |
| 1347 #if !ASSERT_DISABLED | |
| 1348 LayerListMutationDetector mutationChecker(layer->stackingNode()); | |
| 1349 #endif | |
| 1350 | |
| 1351 if (layer->stackingNode()->isStackingContainer()) { | |
| 1352 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren); | |
| 1353 while (RenderLayerStackingNode* curNode = iterator.next()) | |
| 1354 rebuildCompositingLayerTree(curNode->layer(), childList, depth + 1); | |
| 1355 | |
| 1356 // If a negative z-order child is compositing, we get a foreground layer which needs to get parented. | |
| 1357 if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregrou ndLayer()) | |
| 1358 childList.append(currentCompositedLayerMapping->foregroundLayer()); | |
| 1359 } | |
| 1360 | |
| 1361 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren); | |
| 1362 while (RenderLayerStackingNode* curNode = iterator.next()) | |
| 1363 rebuildCompositingLayerTree(curNode->layer(), childList, depth + 1); | |
| 1364 | |
| 1365 if (hasCompositedLayerMapping) { | |
| 1366 bool parented = false; | |
| 1367 if (layer->renderer()->isRenderPart()) | |
| 1368 parented = parentFrameContentLayers(toRenderPart(layer->renderer())) ; | |
| 1369 | |
| 1370 if (!parented) | |
| 1371 currentCompositedLayerMapping->parentForSublayers()->setChildren(lay erChildren); | |
| 1372 | |
| 1373 // If the layer has a clipping layer the overflow controls layers will b e siblings of the clipping layer. | |
| 1374 // Otherwise, the overflow control layers are normal children. | |
| 1375 if (!currentCompositedLayerMapping->hasClippingLayer() && !currentCompos itedLayerMapping->hasScrollingLayer()) { | |
| 1376 if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapp ing->layerForHorizontalScrollbar()) { | |
| 1377 overflowControlLayer->removeFromParent(); | |
| 1378 currentCompositedLayerMapping->parentForSublayers()->addChild(ov erflowControlLayer); | |
| 1379 } | |
| 1380 | |
| 1381 if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapp ing->layerForVerticalScrollbar()) { | |
| 1382 overflowControlLayer->removeFromParent(); | |
| 1383 currentCompositedLayerMapping->parentForSublayers()->addChild(ov erflowControlLayer); | |
| 1384 } | |
| 1385 | |
| 1386 if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapp ing->layerForScrollCorner()) { | |
| 1387 overflowControlLayer->removeFromParent(); | |
| 1388 currentCompositedLayerMapping->parentForSublayers()->addChild(ov erflowControlLayer); | |
| 1389 } | |
| 1390 } | |
| 1391 | |
| 1392 childLayersOfEnclosingLayer.append(currentCompositedLayerMapping->childF orSuperlayers()); | |
| 1393 } | |
| 1394 | |
| 1395 if (!depth) { | |
| 1396 int percentageIncreaseInPixels = static_cast<int>(pixelsAddedByPromoting AllTransitions / pixelsWithoutPromotingAllTransitions * 100); | |
| 1397 blink::Platform::current()->histogramCustomCounts("Renderer.PixelIncreas eFromTransitions", percentageIncreaseInPixels, 0, 1000, 50); | |
| 1398 } | |
| 1399 } | |
| 1400 | |
| 1401 void RenderLayerCompositor::frameViewDidChangeLocation(const IntPoint& contentsO ffset) | 1284 void RenderLayerCompositor::frameViewDidChangeLocation(const IntPoint& contentsO ffset) |
| 1402 { | 1285 { |
| 1403 if (m_overflowControlsHostLayer) | 1286 if (m_overflowControlsHostLayer) |
| 1404 m_overflowControlsHostLayer->setPosition(contentsOffset); | 1287 m_overflowControlsHostLayer->setPosition(contentsOffset); |
| 1405 } | 1288 } |
| 1406 | 1289 |
| 1407 void RenderLayerCompositor::frameViewDidChangeSize() | 1290 void RenderLayerCompositor::frameViewDidChangeSize() |
| 1408 { | 1291 { |
| 1409 if (m_containerLayer) { | 1292 if (m_containerLayer) { |
| 1410 FrameView* frameView = m_renderView->frameView(); | 1293 FrameView* frameView = m_renderView->frameView(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1518 return 0; | 1401 return 0; |
| 1519 | 1402 |
| 1520 HTMLFrameOwnerElement* element = toHTMLFrameOwnerElement(renderer->node()); | 1403 HTMLFrameOwnerElement* element = toHTMLFrameOwnerElement(renderer->node()); |
| 1521 if (Document* contentDocument = element->contentDocument()) { | 1404 if (Document* contentDocument = element->contentDocument()) { |
| 1522 if (RenderView* view = contentDocument->renderView()) | 1405 if (RenderView* view = contentDocument->renderView()) |
| 1523 return view->compositor(); | 1406 return view->compositor(); |
| 1524 } | 1407 } |
| 1525 return 0; | 1408 return 0; |
| 1526 } | 1409 } |
| 1527 | 1410 |
| 1528 bool RenderLayerCompositor::parentFrameContentLayers(RenderPart* renderer) | |
| 1529 { | |
| 1530 RenderLayerCompositor* innerCompositor = frameContentsCompositor(renderer); | |
| 1531 if (!innerCompositor || !innerCompositor->inCompositingMode() || innerCompos itor->rootLayerAttachment() != RootLayerAttachedViaEnclosingFrame) | |
| 1532 return false; | |
| 1533 | |
| 1534 RenderLayer* layer = renderer->layer(); | |
| 1535 if (!layer->hasCompositedLayerMapping()) | |
| 1536 return false; | |
| 1537 | |
| 1538 CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLayerMap ping(); | |
| 1539 GraphicsLayer* hostingLayer = compositedLayerMapping->parentForSublayers(); | |
| 1540 GraphicsLayer* rootLayer = innerCompositor->rootGraphicsLayer(); | |
| 1541 if (hostingLayer->children().size() != 1 || hostingLayer->children()[0] != r ootLayer) { | |
| 1542 hostingLayer->removeAllChildren(); | |
| 1543 hostingLayer->addChild(rootLayer); | |
| 1544 } | |
| 1545 return true; | |
| 1546 } | |
| 1547 | |
| 1548 // This just updates layer geometry without changing the hierarchy. | |
| 1549 void RenderLayerCompositor::updateLayerTreeGeometry(RenderLayer* layer) | |
| 1550 { | |
| 1551 updateGraphicsLayersMappedToRenderLayer(layer); | |
| 1552 | |
| 1553 #if !ASSERT_DISABLED | |
| 1554 LayerListMutationDetector mutationChecker(layer->stackingNode()); | |
| 1555 #endif | |
| 1556 | |
| 1557 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), AllChildren ); | |
| 1558 while (RenderLayerStackingNode* curNode = iterator.next()) | |
| 1559 updateLayerTreeGeometry(curNode->layer()); | |
| 1560 } | |
| 1561 | |
| 1562 // Recurs down the RenderLayer tree until its finds the compositing descendants of compositingAncestor and updates their geometry. | 1411 // Recurs down the RenderLayer tree until its finds the compositing descendants of compositingAncestor and updates their geometry. |
| 1563 void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayerStack ingNode* compositingAncestor, RenderLayer* layer, bool compositedChildrenOnly) | 1412 void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayerStack ingNode* compositingAncestor, RenderLayer* layer, bool compositedChildrenOnly) |
| 1564 { | 1413 { |
| 1565 if (layer->stackingNode() != compositingAncestor) { | 1414 if (layer->stackingNode() != compositingAncestor) { |
| 1566 if (layer->hasCompositedLayerMapping()) { | 1415 if (layer->hasCompositedLayerMapping()) { |
| 1567 CompositedLayerMappingPtr compositedLayerMapping = layer->composited LayerMapping(); | 1416 CompositedLayerMappingPtr compositedLayerMapping = layer->composited LayerMapping(); |
| 1568 compositedLayerMapping->updateCompositedBounds(); | 1417 compositedLayerMapping->updateCompositedBounds(); |
| 1569 | 1418 |
| 1570 if (layer->reflectionInfo()) { | 1419 if (layer->reflectionInfo()) { |
| 1571 RenderLayer* reflectionLayer = layer->reflectionInfo()->reflecti onLayer(); | 1420 RenderLayer* reflectionLayer = layer->reflectionInfo()->reflecti onLayer(); |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2405 } else if (graphicsLayer == m_scrollLayer.get()) { | 2254 } else if (graphicsLayer == m_scrollLayer.get()) { |
| 2406 name = "LocalFrame Scrolling Layer"; | 2255 name = "LocalFrame Scrolling Layer"; |
| 2407 } else { | 2256 } else { |
| 2408 ASSERT_NOT_REACHED(); | 2257 ASSERT_NOT_REACHED(); |
| 2409 } | 2258 } |
| 2410 | 2259 |
| 2411 return name; | 2260 return name; |
| 2412 } | 2261 } |
| 2413 | 2262 |
| 2414 } // namespace WebCore | 2263 } // namespace WebCore |
| OLD | NEW |