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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 #ifndef NDEBUG | 88 #ifndef NDEBUG |
89 int m_depth; | 89 int m_depth; |
90 #endif | 90 #endif |
91 }; | 91 }; |
92 | 92 |
93 RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView) | 93 RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView) |
94 : m_renderView(renderView) | 94 : m_renderView(renderView) |
95 , m_updateCompositingLayersTimer(this, &RenderLayerCompositor::updateComposi
tingLayersTimerFired) | 95 , m_updateCompositingLayersTimer(this, &RenderLayerCompositor::updateComposi
tingLayersTimerFired) |
96 , m_hasAcceleratedCompositing(true) | 96 , m_hasAcceleratedCompositing(true) |
97 , m_compositingTriggers(static_cast<ChromeClient::CompositingTriggerFlags>(C
hromeClient::AllTriggers)) | 97 , m_compositingTriggers(static_cast<ChromeClient::CompositingTriggerFlags>(C
hromeClient::AllTriggers)) |
| 98 , m_compositedLayerCount(0) |
98 , m_showDebugBorders(false) | 99 , m_showDebugBorders(false) |
99 , m_showRepaintCounter(false) | 100 , m_showRepaintCounter(false) |
100 , m_compositingConsultsOverlap(true) | 101 , m_compositingConsultsOverlap(true) |
101 , m_compositingDependsOnGeometry(false) | 102 , m_compositingDependsOnGeometry(false) |
102 , m_compositing(false) | 103 , m_compositing(false) |
103 , m_compositingLayersNeedRebuild(false) | 104 , m_compositingLayersNeedRebuild(false) |
104 , m_flushingLayers(false) | 105 , m_flushingLayers(false) |
105 , m_forceCompositingMode(false) | 106 , m_forceCompositingMode(false) |
106 , m_rootLayerAttachment(RootLayerUnattached) | 107 , m_rootLayerAttachment(RootLayerUnattached) |
107 #if PROFILE_LAYER_REBUILD | 108 #if PROFILE_LAYER_REBUILD |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 { | 235 { |
235 if (!m_updateCompositingLayersTimer.isActive()) | 236 if (!m_updateCompositingLayersTimer.isActive()) |
236 m_updateCompositingLayersTimer.startOneShot(0); | 237 m_updateCompositingLayersTimer.startOneShot(0); |
237 } | 238 } |
238 | 239 |
239 void RenderLayerCompositor::updateCompositingLayersTimerFired(Timer<RenderLayerC
ompositor>*) | 240 void RenderLayerCompositor::updateCompositingLayersTimerFired(Timer<RenderLayerC
ompositor>*) |
240 { | 241 { |
241 updateCompositingLayers(); | 242 updateCompositingLayers(); |
242 } | 243 } |
243 | 244 |
| 245 bool RenderLayerCompositor::hasAnyAdditionalCompositedLayers(const RenderLayer*
rootLayer) const |
| 246 { |
| 247 return m_compositedLayerCount > rootLayer->isComposited(); |
| 248 } |
| 249 |
244 void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
Type, RenderLayer* updateRoot) | 250 void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
Type, RenderLayer* updateRoot) |
245 { | 251 { |
246 m_updateCompositingLayersTimer.stop(); | 252 m_updateCompositingLayersTimer.stop(); |
247 | 253 |
248 // Compositing layers will be updated in Document::implicitClose() if suppre
ssed here. | 254 // Compositing layers will be updated in Document::implicitClose() if suppre
ssed here. |
249 if (!m_renderView->document()->visualUpdatesAllowed()) | 255 if (!m_renderView->document()->visualUpdatesAllowed()) |
250 return; | 256 return; |
251 | 257 |
252 if (m_forceCompositingMode && !m_compositing) | 258 if (m_forceCompositingMode && !m_compositing) |
253 enableCompositingMode(true); | 259 enableCompositingMode(true); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 308 } |
303 | 309 |
304 if (needHierarchyUpdate) { | 310 if (needHierarchyUpdate) { |
305 // Update the hierarchy of the compositing layers. | 311 // Update the hierarchy of the compositing layers. |
306 CompositingState compState(updateRoot); | 312 CompositingState compState(updateRoot); |
307 Vector<GraphicsLayer*> childList; | 313 Vector<GraphicsLayer*> childList; |
308 rebuildCompositingLayerTree(updateRoot, compState, childList); | 314 rebuildCompositingLayerTree(updateRoot, compState, childList); |
309 | 315 |
310 // Host the document layer in the RenderView's root layer. | 316 // Host the document layer in the RenderView's root layer. |
311 if (updateRoot == rootRenderLayer()) { | 317 if (updateRoot == rootRenderLayer()) { |
312 if (childList.isEmpty()) | 318 // Even when childList is empty, don't drop out of compositing mode
if there are |
| 319 // composited layers that we didn't hit in our traversal (e.g. becau
se of visibility:hidden). |
| 320 if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(updateR
oot)) |
313 destroyRootLayer(); | 321 destroyRootLayer(); |
314 else | 322 else |
315 m_rootContentLayer->setChildren(childList); | 323 m_rootContentLayer->setChildren(childList); |
316 } | 324 } |
317 } else if (needGeometryUpdate) { | 325 } else if (needGeometryUpdate) { |
318 // We just need to do a geometry update. This is only used for position:
fixed scrolling; | 326 // We just need to do a geometry update. This is only used for position:
fixed scrolling; |
319 // most of the time, geometry is updated via RenderLayer::styleChanged()
. | 327 // most of the time, geometry is updated via RenderLayer::styleChanged()
. |
320 updateLayerTreeGeometry(updateRoot); | 328 updateLayerTreeGeometry(updateRoot); |
321 } | 329 } |
322 | 330 |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 | 775 |
768 // setHasCompositingDescendant() may have changed the answer to needsToBeCom
posited() when clipping, | 776 // setHasCompositingDescendant() may have changed the answer to needsToBeCom
posited() when clipping, |
769 // so test that again. | 777 // so test that again. |
770 if (!willBeComposited && canBeComposited(layer) && clipsCompositingDescendan
ts(layer)) { | 778 if (!willBeComposited && canBeComposited(layer) && clipsCompositingDescendan
ts(layer)) { |
771 if (overlapMap) | 779 if (overlapMap) |
772 addToOverlapMapRecursive(*overlapMap, layer); | 780 addToOverlapMapRecursive(*overlapMap, layer); |
773 willBeComposited = true; | 781 willBeComposited = true; |
774 } | 782 } |
775 | 783 |
776 // If we're back at the root, and no other layers need to be composited, and
the root layer itself doesn't need | 784 // If we're back at the root, and no other layers need to be composited, and
the root layer itself doesn't need |
777 // to be composited, then we can drop out of compositing mode altogether. | 785 // to be composited, then we can drop out of compositing mode altogether. Ho
wever, don't drop out of compositing mode |
778 if (layer->isRootLayer() && !childState.m_subtreeIsCompositing && !requiresC
ompositingLayer(layer) && !m_forceCompositingMode) { | 786 // if there are composited layers that we didn't hit in our traversal (e.g.
because of visibility:hidden). |
| 787 if (layer->isRootLayer() && !childState.m_subtreeIsCompositing && !requiresC
ompositingLayer(layer) && !m_forceCompositingMode && !hasAnyAdditionalComposited
Layers(layer)) { |
779 enableCompositingMode(false); | 788 enableCompositingMode(false); |
780 willBeComposited = false; | 789 willBeComposited = false; |
781 } | 790 } |
782 | 791 |
783 // If the layer is going into compositing mode, repaint its old location. | 792 // If the layer is going into compositing mode, repaint its old location. |
784 ASSERT(willBeComposited == needsToBeComposited(layer)); | 793 ASSERT(willBeComposited == needsToBeComposited(layer)); |
785 if (!layer->isComposited() && willBeComposited) | 794 if (!layer->isComposited() && willBeComposited) |
786 repaintOnCompositingChange(layer); | 795 repaintOnCompositingChange(layer); |
787 | 796 |
788 // Update backing now, so that we can use isComposited() reliably during tre
e traversal in rebuildCompositingLayerTree(). | 797 // Update backing now, so that we can use isComposited() reliably during tre
e traversal in rebuildCompositingLayerTree(). |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 if (!viewLayer->isComposited()) | 1958 if (!viewLayer->isComposited()) |
1950 return; | 1959 return; |
1951 | 1960 |
1952 if (GraphicsLayer* rootLayer = viewLayer->backing()->graphicsLayer()) | 1961 if (GraphicsLayer* rootLayer = viewLayer->backing()->graphicsLayer()) |
1953 rootLayer->noteDeviceOrPageScaleFactorChangedIncludingDescendants(); | 1962 rootLayer->noteDeviceOrPageScaleFactorChangedIncludingDescendants(); |
1954 } | 1963 } |
1955 | 1964 |
1956 } // namespace WebCore | 1965 } // namespace WebCore |
1957 | 1966 |
1958 #endif // USE(ACCELERATED_COMPOSITING) | 1967 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |