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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 return false; | 218 return false; |
| 219 #endif | 219 #endif |
| 220 } | 220 } |
| 221 | 221 |
| 222 RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView) | 222 RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView) |
| 223 : m_renderView(renderView) | 223 : m_renderView(renderView) |
| 224 , m_hasAcceleratedCompositing(true) | 224 , m_hasAcceleratedCompositing(true) |
| 225 , m_compositingTriggers(static_cast<ChromeClient::CompositingTriggerFlags>(C hromeClient::AllTriggers)) | 225 , m_compositingTriggers(static_cast<ChromeClient::CompositingTriggerFlags>(C hromeClient::AllTriggers)) |
| 226 , m_compositedLayerCount(0) | 226 , m_compositedLayerCount(0) |
| 227 , m_showRepaintCounter(false) | 227 , m_showRepaintCounter(false) |
| 228 , m_reevaluateCompositingAfterLayout(false) | 228 , m_needsToRecomputeCompositingRequirements(false) |
| 229 , m_needsToUpdateLayerTreeGeometry(false) | |
| 229 , m_compositing(false) | 230 , m_compositing(false) |
| 230 , m_compositingLayersNeedRebuild(false) | 231 , m_compositingLayersNeedRebuild(false) |
| 231 , m_forceCompositingMode(false) | 232 , m_forceCompositingMode(false) |
| 232 , m_inPostLayoutUpdate(false) | 233 , m_inPostLayoutUpdate(false) |
| 233 , m_needsUpdateCompositingRequirementsState(false) | 234 , m_needsUpdateCompositingRequirementsState(false) |
| 234 , m_isTrackingRepaints(false) | 235 , m_isTrackingRepaints(false) |
| 235 , m_rootLayerAttachment(RootLayerUnattached) | 236 , m_rootLayerAttachment(RootLayerUnattached) |
| 236 #if !LOG_DISABLED | 237 #if !LOG_DISABLED |
| 237 , m_rootLayerUpdateCount(0) | 238 , m_rootLayerUpdateCount(0) |
| 238 , m_obligateCompositedLayerCount(0) | 239 , m_obligateCompositedLayerCount(0) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 | 374 |
| 374 void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update Type, RenderLayer* updateRoot) | 375 void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update Type, RenderLayer* updateRoot) |
| 375 { | 376 { |
| 376 // Avoid updating the layers with old values. Compositing layers will be upd ated after the layout is finished. | 377 // Avoid updating the layers with old values. Compositing layers will be upd ated after the layout is finished. |
| 377 if (m_renderView->needsLayout()) | 378 if (m_renderView->needsLayout()) |
| 378 return; | 379 return; |
| 379 | 380 |
| 380 if (m_forceCompositingMode && !m_compositing) | 381 if (m_forceCompositingMode && !m_compositing) |
| 381 enableCompositingMode(true); | 382 enableCompositingMode(true); |
| 382 | 383 |
| 383 if (!m_reevaluateCompositingAfterLayout && !m_compositing) | 384 if (!m_needsToRecomputeCompositingRequirements && !m_compositing) |
| 384 return; | 385 return; |
| 385 | 386 |
| 386 AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame() .animation()); | 387 AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame() .animation()); |
| 387 | 388 |
| 388 TemporaryChange<bool> postLayoutChange(m_inPostLayoutUpdate, true); | 389 TemporaryChange<bool> postLayoutChange(m_inPostLayoutUpdate, true); |
| 389 | 390 |
| 390 bool checkForHierarchyUpdate = m_reevaluateCompositingAfterLayout; | 391 bool checkForHierarchyUpdate = false; |
| 391 bool needGeometryUpdate = false; | 392 bool needGeometryUpdate = false; |
| 392 | 393 |
| 394 // CompositingUpdateOnBeginDrawingFrame is the only updateType that will act ually do any work in this function. | |
| 395 // All other updateTypes will simply mark that something needed updating, an d defer the actual update. | |
| 396 // This way we only need to compute all compositing state once for every fra me drawn (if needed). | |
|
Ian Vollick
2013/10/08 18:32:21
I love this. :)
| |
| 393 switch (updateType) { | 397 switch (updateType) { |
| 394 case CompositingUpdateAfterStyleChange: | 398 case CompositingUpdateAfterStyleChange: |
| 395 case CompositingUpdateAfterLayout: | 399 case CompositingUpdateAfterLayout: |
| 396 checkForHierarchyUpdate = true; | 400 m_needsToRecomputeCompositingRequirements = true; |
| 397 break; | 401 break; |
| 398 case CompositingUpdateOnScroll: | 402 case CompositingUpdateOnScroll: |
| 399 checkForHierarchyUpdate = true; // Overlap can change with scrolling, so need to check for hierarchy updates. | 403 m_needsToRecomputeCompositingRequirements = true; // Overlap can change with scrolling, so need to check for hierarchy updates. |
| 400 needGeometryUpdate = true; | 404 m_needsToUpdateLayerTreeGeometry = true; |
| 401 break; | 405 break; |
| 402 case CompositingUpdateOnCompositedScroll: | 406 case CompositingUpdateOnCompositedScroll: |
| 403 needGeometryUpdate = true; | 407 m_needsToUpdateLayerTreeGeometry = true; |
| 408 break; | |
| 409 case CompositingUpdateOnBeginDrawingFrame: | |
| 410 checkForHierarchyUpdate = m_needsToRecomputeCompositingRequirements; | |
| 411 needGeometryUpdate = m_needsToUpdateLayerTreeGeometry; | |
| 404 break; | 412 break; |
| 405 } | 413 } |
| 406 | 414 |
| 415 // FIXME: why isn't needHierarchyUpdate part of this? | |
|
Ian Vollick
2013/10/08 18:32:21
Whoa. No good reason I can see. If we need to rebu
| |
| 407 if (!checkForHierarchyUpdate && !needGeometryUpdate) | 416 if (!checkForHierarchyUpdate && !needGeometryUpdate) |
| 408 return; | 417 return; |
| 409 | 418 |
| 410 bool needHierarchyUpdate = m_compositingLayersNeedRebuild; | 419 bool needHierarchyUpdate = m_compositingLayersNeedRebuild; |
| 411 bool isFullUpdate = !updateRoot; | 420 bool isFullUpdate = !updateRoot; |
| 412 | 421 |
| 413 // Only clear the flag if we're updating the entire hierarchy. | 422 // Only clear the flags if we're updating the entire hierarchy. |
| 414 m_compositingLayersNeedRebuild = false; | 423 m_compositingLayersNeedRebuild = false; |
| 424 m_needsToUpdateLayerTreeGeometry = false; | |
| 415 updateRoot = rootRenderLayer(); | 425 updateRoot = rootRenderLayer(); |
| 416 | 426 |
| 417 if (isFullUpdate && updateType == CompositingUpdateAfterLayout) | 427 // FIXME, I think we can remove this if-condition? |
|
Ian Vollick
2013/10/08 18:32:21
I don't think so. If the update root is non-NULL,
| |
| 418 m_reevaluateCompositingAfterLayout = false; | 428 if (isFullUpdate) |
| 429 m_needsToRecomputeCompositingRequirements = false; | |
| 419 | 430 |
| 420 #if !LOG_DISABLED | 431 #if !LOG_DISABLED |
| 421 double startTime = 0; | 432 double startTime = 0; |
| 422 if (compositingLogEnabled()) { | 433 if (compositingLogEnabled()) { |
| 423 ++m_rootLayerUpdateCount; | 434 ++m_rootLayerUpdateCount; |
| 424 startTime = currentTime(); | 435 startTime = currentTime(); |
| 425 } | 436 } |
| 426 #endif | 437 #endif |
| 427 | 438 |
| 428 if (checkForHierarchyUpdate) { | 439 if (checkForHierarchyUpdate) { |
| (...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1925 | 1936 |
| 1926 bool RenderLayerCompositor::requiresCompositingForPlugin(RenderObject* renderer) const | 1937 bool RenderLayerCompositor::requiresCompositingForPlugin(RenderObject* renderer) const |
| 1927 { | 1938 { |
| 1928 if (!(m_compositingTriggers & ChromeClient::PluginTrigger)) | 1939 if (!(m_compositingTriggers & ChromeClient::PluginTrigger)) |
| 1929 return false; | 1940 return false; |
| 1930 | 1941 |
| 1931 bool composite = renderer->isEmbeddedObject() && toRenderEmbeddedObject(rend erer)->allowsAcceleratedCompositing(); | 1942 bool composite = renderer->isEmbeddedObject() && toRenderEmbeddedObject(rend erer)->allowsAcceleratedCompositing(); |
| 1932 if (!composite) | 1943 if (!composite) |
| 1933 return false; | 1944 return false; |
| 1934 | 1945 |
| 1935 m_reevaluateCompositingAfterLayout = true; | 1946 // FIXME: this seems bogus. If we don't know the layout position/size of the plugin yet, would't that be handled elsewhere? |
|
Ian Vollick
2013/10/08 18:32:21
Totally fishy. Doesn't this mean that if we have a
Vangelis Kokkevis
2013/10/08 23:22:33
I think the reason this code existed is that there
| |
| 1947 m_needsToRecomputeCompositingRequirements = true; | |
| 1936 | 1948 |
| 1937 RenderWidget* pluginRenderer = toRenderWidget(renderer); | 1949 RenderWidget* pluginRenderer = toRenderWidget(renderer); |
| 1938 // If we can't reliably know the size of the plugin yet, don't change compos iting state. | 1950 // If we can't reliably know the size of the plugin yet, don't change compos iting state. |
| 1939 if (pluginRenderer->needsLayout()) | 1951 if (pluginRenderer->needsLayout()) |
| 1940 return pluginRenderer->hasLayer() && pluginRenderer->layer()->composited LayerMapping(); | 1952 return pluginRenderer->hasLayer() && pluginRenderer->layer()->composited LayerMapping(); |
| 1941 | 1953 |
| 1942 // Don't go into compositing mode if height or width are zero, or size is 1x 1. | 1954 // Don't go into compositing mode if height or width are zero, or size is 1x 1. |
| 1943 IntRect contentBox = pixelSnappedIntRect(pluginRenderer->contentBoxRect()); | 1955 IntRect contentBox = pixelSnappedIntRect(pluginRenderer->contentBoxRect()); |
| 1944 return contentBox.height() * contentBox.width() > 1; | 1956 return contentBox.height() * contentBox.width() > 1; |
| 1945 } | 1957 } |
| 1946 | 1958 |
| 1947 bool RenderLayerCompositor::requiresCompositingForFrame(RenderObject* renderer) const | 1959 bool RenderLayerCompositor::requiresCompositingForFrame(RenderObject* renderer) const |
| 1948 { | 1960 { |
| 1949 if (!renderer->isRenderPart()) | 1961 if (!renderer->isRenderPart()) |
| 1950 return false; | 1962 return false; |
| 1951 | 1963 |
| 1952 RenderPart* frameRenderer = toRenderPart(renderer); | 1964 RenderPart* frameRenderer = toRenderPart(renderer); |
| 1953 | 1965 |
| 1954 if (!frameRenderer->requiresAcceleratedCompositing()) | 1966 if (!frameRenderer->requiresAcceleratedCompositing()) |
| 1955 return false; | 1967 return false; |
| 1956 | 1968 |
| 1957 m_reevaluateCompositingAfterLayout = true; | 1969 // FIXME: this seems bogus. If we don't know the layout position/size of the frame yet, wouldn't that be handled elsehwere? |
|
Ian Vollick
2013/10/08 18:32:21
Ditto.
| |
| 1970 m_needsToRecomputeCompositingRequirements = true; | |
| 1958 | 1971 |
| 1959 RenderLayerCompositor* innerCompositor = frameContentsCompositor(frameRender er); | 1972 RenderLayerCompositor* innerCompositor = frameContentsCompositor(frameRender er); |
| 1960 if (!innerCompositor) | 1973 if (!innerCompositor) |
| 1961 return false; | 1974 return false; |
| 1962 | 1975 |
| 1963 // If we can't reliably know the size of the iframe yet, don't change compos iting state. | 1976 // If we can't reliably know the size of the iframe yet, don't change compos iting state. |
| 1964 if (renderer->needsLayout()) | 1977 if (renderer->needsLayout()) |
| 1965 return frameRenderer->hasLayer() && frameRenderer->layer()->compositedLa yerMapping(); | 1978 return frameRenderer->hasLayer() && frameRenderer->layer()->compositedLa yerMapping(); |
| 1966 | 1979 |
| 1967 // Don't go into compositing mode if height or width are zero. | 1980 // Don't go into compositing mode if height or width are zero. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2084 if (!settings->acceleratedCompositingForFixedPositionEnabled()) | 2097 if (!settings->acceleratedCompositingForFixedPositionEnabled()) |
| 2085 return false; | 2098 return false; |
| 2086 } | 2099 } |
| 2087 | 2100 |
| 2088 if (isSticky) | 2101 if (isSticky) |
| 2089 return true; | 2102 return true; |
| 2090 | 2103 |
| 2091 RenderObject* container = renderer->container(); | 2104 RenderObject* container = renderer->container(); |
| 2092 // If the renderer is not hooked up yet then we have to wait until it is. | 2105 // If the renderer is not hooked up yet then we have to wait until it is. |
| 2093 if (!container) { | 2106 if (!container) { |
| 2094 m_reevaluateCompositingAfterLayout = true; | 2107 m_needsToRecomputeCompositingRequirements = true; |
| 2095 return false; | 2108 return false; |
| 2096 } | 2109 } |
| 2097 | 2110 |
| 2098 // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements. | 2111 // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements. |
| 2099 // They will stay fixed wrt the container rather than the enclosing frame. | 2112 // They will stay fixed wrt the container rather than the enclosing frame. |
| 2100 if (container != m_renderView) { | 2113 if (container != m_renderView) { |
| 2101 if (viewportConstrainedNotCompositedReason) | 2114 if (viewportConstrainedNotCompositedReason) |
| 2102 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForNonViewContainer; | 2115 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForNonViewContainer; |
| 2103 return false; | 2116 return false; |
| 2104 } | 2117 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 2124 } | 2137 } |
| 2125 | 2138 |
| 2126 if (!hasScrollableAncestor) { | 2139 if (!hasScrollableAncestor) { |
| 2127 if (viewportConstrainedNotCompositedReason) | 2140 if (viewportConstrainedNotCompositedReason) |
| 2128 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForUnscrollableAncestors; | 2141 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForUnscrollableAncestors; |
| 2129 return false; | 2142 return false; |
| 2130 } | 2143 } |
| 2131 | 2144 |
| 2132 // Subsequent tests depend on layout. If we can't tell now, just keep things the way they are until layout is done. | 2145 // Subsequent tests depend on layout. If we can't tell now, just keep things the way they are until layout is done. |
| 2133 if (!m_inPostLayoutUpdate) { | 2146 if (!m_inPostLayoutUpdate) { |
| 2134 m_reevaluateCompositingAfterLayout = true; | 2147 m_needsToRecomputeCompositingRequirements = true; |
| 2135 return layer->compositedLayerMapping(); | 2148 return layer->compositedLayerMapping(); |
| 2136 } | 2149 } |
| 2137 | 2150 |
| 2138 bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescend ant(); | 2151 bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescend ant(); |
| 2139 if (!paintsContent) { | 2152 if (!paintsContent) { |
| 2140 if (viewportConstrainedNotCompositedReason) | 2153 if (viewportConstrainedNotCompositedReason) |
| 2141 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForNoVisibleContent; | 2154 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForNoVisibleContent; |
| 2142 return false; | 2155 return false; |
| 2143 } | 2156 } |
| 2144 | 2157 |
| 2145 // Fixed position elements that are invisible in the current view don't get their own layer. | 2158 // Fixed position elements that are invisible in the current view don't get their own layer. |
| 2146 if (FrameView* frameView = m_renderView->frameView()) { | 2159 if (FrameView* frameView = m_renderView->frameView()) { |
| 2147 LayoutRect viewBounds = frameView->viewportConstrainedVisibleContentRect (); | 2160 LayoutRect viewBounds = frameView->viewportConstrainedVisibleContentRect (); |
| 2148 LayoutRect layerBounds = layer->calculateLayerBounds(rootRenderLayer(), 0, RenderLayer::DefaultCalculateLayerBoundsFlags | 2161 LayoutRect layerBounds = layer->calculateLayerBounds(rootRenderLayer(), 0, RenderLayer::DefaultCalculateLayerBoundsFlags |
| 2149 | RenderLayer::ExcludeHiddenDescendants | RenderLayer::DontConstrain ForMask | RenderLayer::IncludeCompositedDescendants); | 2162 | RenderLayer::ExcludeHiddenDescendants | RenderLayer::DontConstrain ForMask | RenderLayer::IncludeCompositedDescendants); |
| 2150 if (!viewBounds.intersects(enclosingIntRect(layerBounds))) { | 2163 if (!viewBounds.intersects(enclosingIntRect(layerBounds))) { |
| 2151 if (viewportConstrainedNotCompositedReason) { | 2164 if (viewportConstrainedNotCompositedReason) { |
| 2152 *viewportConstrainedNotCompositedReason = RenderLayer::NotCompos itedForBoundsOutOfView; | 2165 *viewportConstrainedNotCompositedReason = RenderLayer::NotCompos itedForBoundsOutOfView; |
| 2153 m_reevaluateCompositingAfterLayout = true; | 2166 m_needsToRecomputeCompositingRequirements = true; |
| 2154 } | 2167 } |
| 2155 return false; | 2168 return false; |
| 2156 } | 2169 } |
| 2157 } | 2170 } |
| 2158 | 2171 |
| 2159 return true; | 2172 return true; |
| 2160 } | 2173 } |
| 2161 | 2174 |
| 2162 bool RenderLayerCompositor::requiresCompositingForOverflowScrolling(const Render Layer* layer) const | 2175 bool RenderLayerCompositor::requiresCompositingForOverflowScrolling(const Render Layer* layer) const |
| 2163 { | 2176 { |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2787 } else if (graphicsLayer == m_scrollLayer.get()) { | 2800 } else if (graphicsLayer == m_scrollLayer.get()) { |
| 2788 name = "Frame Scrolling Layer"; | 2801 name = "Frame Scrolling Layer"; |
| 2789 } else { | 2802 } else { |
| 2790 ASSERT_NOT_REACHED(); | 2803 ASSERT_NOT_REACHED(); |
| 2791 } | 2804 } |
| 2792 | 2805 |
| 2793 return name; | 2806 return name; |
| 2794 } | 2807 } |
| 2795 | 2808 |
| 2796 } // namespace WebCore | 2809 } // namespace WebCore |
| OLD | NEW |