Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 Page* page = layer->renderer()->frame()->page(); | 152 Page* page = layer->renderer()->frame()->page(); |
| 153 if (!page) | 153 if (!page) |
| 154 return 0; | 154 return 0; |
| 155 | 155 |
| 156 return page->scrollingCoordinator(); | 156 return page->scrollingCoordinator(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 CompositedLayerMapping::CompositedLayerMapping(RenderLayer* layer) | 159 CompositedLayerMapping::CompositedLayerMapping(RenderLayer* layer) |
| 160 : m_owningLayer(layer) | 160 : m_owningLayer(layer) |
| 161 , m_animationProvider(adoptPtr(new WebAnimationProvider)) | 161 , m_animationProvider(adoptPtr(new WebAnimationProvider)) |
| 162 , m_nextSquashedLayerIndex(0x0fff0000) | |
| 162 , m_artificiallyInflatedBounds(false) | 163 , m_artificiallyInflatedBounds(false) |
| 163 , m_boundsConstrainedByClipping(false) | 164 , m_boundsConstrainedByClipping(false) |
| 164 , m_isMainFrameRenderViewLayer(false) | 165 , m_isMainFrameRenderViewLayer(false) |
| 165 , m_requiresOwnBackingStoreForIntrinsicReasons(true) | 166 , m_requiresOwnBackingStoreForIntrinsicReasons(true) |
| 166 , m_requiresOwnBackingStoreForAncestorReasons(true) | 167 , m_requiresOwnBackingStoreForAncestorReasons(true) |
| 167 , m_canCompositeFilters(false) | 168 , m_canCompositeFilters(false) |
| 168 , m_backgroundLayerPaintsFixedRootBackground(false) | 169 , m_backgroundLayerPaintsFixedRootBackground(false) |
| 169 { | 170 { |
| 170 if (layer->isRootLayer() && renderer()->frame()->isMainFrame()) | 171 if (layer->isRootLayer() && renderer()->frame()->isMainFrame()) |
| 171 m_isMainFrameRenderViewLayer = true; | 172 m_isMainFrameRenderViewLayer = true; |
| 172 | 173 |
| 173 createPrimaryGraphicsLayer(); | 174 createPrimaryGraphicsLayer(); |
| 174 } | 175 } |
| 175 | 176 |
| 176 CompositedLayerMapping::~CompositedLayerMapping() | 177 CompositedLayerMapping::~CompositedLayerMapping() |
| 177 { | 178 { |
| 179 // FIXME: this almost certainly needs to go somewhere more appropriate so it occurs | |
| 180 // when things change as well as things getting destroyed. | |
| 181 for (size_t i = 0; i < m_squashedLayers.size(); ++i) { | |
| 182 if (m_squashedLayers[i].renderLayer->compositingState() == PaintsIntoGro upedBacking) | |
| 183 m_squashedLayers[i].renderLayer->setGroupedMapping(0); | |
| 184 } | |
| 185 | |
| 178 updateClippingLayers(false, false); | 186 updateClippingLayers(false, false); |
| 179 updateOverflowControlsLayers(false, false, false); | 187 updateOverflowControlsLayers(false, false, false); |
| 180 updateForegroundLayer(false); | 188 updateForegroundLayer(false); |
| 181 updateBackgroundLayer(false); | 189 updateBackgroundLayer(false); |
| 182 updateMaskLayer(false); | 190 updateMaskLayer(false); |
| 183 updateClippingMaskLayers(false); | 191 updateClippingMaskLayers(false); |
| 184 updateScrollingLayers(false); | 192 updateScrollingLayers(false); |
| 193 updateSquashingLayers(false); | |
| 185 destroyGraphicsLayers(); | 194 destroyGraphicsLayers(); |
| 186 } | 195 } |
| 187 | 196 |
| 188 PassOwnPtr<GraphicsLayer> CompositedLayerMapping::createGraphicsLayer(Compositin gReasons reasons) | 197 PassOwnPtr<GraphicsLayer> CompositedLayerMapping::createGraphicsLayer(Compositin gReasons reasons) |
| 189 { | 198 { |
| 190 GraphicsLayerFactory* graphicsLayerFactory = 0; | 199 GraphicsLayerFactory* graphicsLayerFactory = 0; |
| 191 if (Page* page = renderer()->frame()->page()) | 200 if (Page* page = renderer()->frame()->page()) |
| 192 graphicsLayerFactory = page->chrome().client().graphicsLayerFactory(); | 201 graphicsLayerFactory = page->chrome().client().graphicsLayerFactory(); |
| 193 | 202 |
| 194 OwnPtr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFac tory, this); | 203 OwnPtr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFac tory, this); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 | 459 |
| 451 if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), require sVerticalScrollbarLayer(), requiresScrollCornerLayer())) | 460 if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), require sVerticalScrollbarLayer(), requiresScrollCornerLayer())) |
| 452 layerConfigChanged = true; | 461 layerConfigChanged = true; |
| 453 | 462 |
| 454 if (updateScrollingLayers(m_owningLayer->needsCompositedScrolling())) | 463 if (updateScrollingLayers(m_owningLayer->needsCompositedScrolling())) |
| 455 layerConfigChanged = true; | 464 layerConfigChanged = true; |
| 456 | 465 |
| 457 updateScrollParent(scrollParent); | 466 updateScrollParent(scrollParent); |
| 458 updateClipParent(m_owningLayer->clipParent()); | 467 updateClipParent(m_owningLayer->clipParent()); |
| 459 | 468 |
| 469 if (updateSquashingLayers(!m_squashedLayers.isEmpty())) | |
| 470 layerConfigChanged = true; | |
| 471 | |
| 460 if (layerConfigChanged) | 472 if (layerConfigChanged) |
| 461 updateInternalHierarchy(); | 473 updateInternalHierarchy(); |
| 462 | 474 |
| 463 if (updateMaskLayer(renderer->hasMask())) | 475 if (updateMaskLayer(renderer->hasMask())) |
| 464 m_graphicsLayer->setMaskLayer(m_maskLayer.get()); | 476 m_graphicsLayer->setMaskLayer(m_maskLayer.get()); |
| 465 | 477 |
| 466 bool hasChildClippingLayer = compositor->clipsCompositingDescendants(m_ownin gLayer) && (hasClippingLayer() || hasScrollingLayer()); | 478 bool hasChildClippingLayer = compositor->clipsCompositingDescendants(m_ownin gLayer) && (hasClippingLayer() || hasScrollingLayer()); |
| 467 bool needsChildClippingMask = (renderer->style()->clipPath() || renderer->st yle()->hasBorderRadius()) && (hasChildClippingLayer || isAcceleratedContents(ren derer)); | 479 bool needsChildClippingMask = (renderer->style()->clipPath() || renderer->st yle()->hasBorderRadius()) && (hasChildClippingLayer || isAcceleratedContents(ren derer)); |
| 468 if (updateClippingMaskLayers(needsChildClippingMask)) { | 480 if (updateClippingMaskLayers(needsChildClippingMask)) { |
| 469 if (hasClippingLayer()) | 481 if (hasClippingLayer()) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959 | 571 // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959 |
| 560 bool preserves3D = style->transformStyle3D() == TransformStyle3DPreserve3D & & !renderer()->hasReflection(); | 572 bool preserves3D = style->transformStyle3D() == TransformStyle3DPreserve3D & & !renderer()->hasReflection(); |
| 561 m_graphicsLayer->setPreserves3D(preserves3D); | 573 m_graphicsLayer->setPreserves3D(preserves3D); |
| 562 m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == Backfa ceVisibilityVisible); | 574 m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == Backfa ceVisibilityVisible); |
| 563 | 575 |
| 564 RenderLayer* compAncestor = m_owningLayer->ancestorCompositingLayer(); | 576 RenderLayer* compAncestor = m_owningLayer->ancestorCompositingLayer(); |
| 565 | 577 |
| 566 // We compute everything relative to the enclosing compositing layer. | 578 // We compute everything relative to the enclosing compositing layer. |
| 567 IntRect ancestorCompositingBounds; | 579 IntRect ancestorCompositingBounds; |
| 568 if (compAncestor) { | 580 if (compAncestor) { |
| 581 // FIXME: is it correct to fix the ASSERT by adding the squashing condit ion here, too? | |
| 569 ASSERT(compAncestor->hasCompositedLayerMapping()); | 582 ASSERT(compAncestor->hasCompositedLayerMapping()); |
| 570 ancestorCompositingBounds = pixelSnappedIntRect(compAncestor->composited LayerMapping()->compositedBounds()); | 583 ancestorCompositingBounds = pixelSnappedIntRect(compAncestor->composited LayerMapping()->compositedBounds()); |
| 571 } | 584 } |
| 572 | 585 |
| 573 IntRect localCompositingBounds = pixelSnappedIntRect(compositedBounds()); | 586 IntRect localCompositingBounds = pixelSnappedIntRect(compositedBounds()); |
| 574 | 587 |
| 575 IntRect relativeCompositingBounds(localCompositingBounds); | 588 IntRect relativeCompositingBounds(localCompositingBounds); |
| 576 IntPoint delta; | 589 IntPoint delta; |
| 577 m_owningLayer->convertToPixelSnappedLayerCoords(compAncestor, delta); | 590 m_owningLayer->convertToPixelSnappedLayerCoords(compAncestor, delta); |
| 578 relativeCompositingBounds.moveBy(delta); | 591 relativeCompositingBounds.moveBy(delta); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, GraphicsLayer::DontSetNeedsDisplay); | 786 m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, GraphicsLayer::DontSetNeedsDisplay); |
| 774 | 787 |
| 775 if (m_foregroundLayer) { | 788 if (m_foregroundLayer) { |
| 776 if (m_foregroundLayer->size() != m_scrollingContentsLayer->size()) | 789 if (m_foregroundLayer->size() != m_scrollingContentsLayer->size()) |
| 777 m_foregroundLayer->setSize(m_scrollingContentsLayer->size()); | 790 m_foregroundLayer->setSize(m_scrollingContentsLayer->size()); |
| 778 m_foregroundLayer->setNeedsDisplay(); | 791 m_foregroundLayer->setNeedsDisplay(); |
| 779 m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->o ffsetFromRenderer()); | 792 m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->o ffsetFromRenderer()); |
| 780 } | 793 } |
| 781 } | 794 } |
| 782 | 795 |
| 796 if (m_squashingLayer) { | |
| 797 ASSERT(compositor()->isLayerSquashingEnabled()); | |
| 798 | |
| 799 IntRect totalSquashBounds; | |
| 800 for (size_t i = 0; i < m_squashedLayers.size(); ++i) { | |
| 801 IntRect squashedBounds = compositor()->calculateCompositedBounds(m_s quashedLayers[i].renderLayer, m_squashedLayers[i].renderLayer); | |
| 802 | |
| 803 // Store the composited bounds before applying the offset. | |
| 804 // FIXME: do we need to? is it better for some reason? | |
| 805 m_squashedLayers[i].compositedBounds = squashedBounds; | |
| 806 | |
| 807 squashedBounds.move(m_squashedLayers[i].offsetFromBackingRoot); | |
| 808 totalSquashBounds.unite(squashedBounds); | |
| 809 } | |
| 810 | |
| 811 IntPoint squashLayerPosition; | |
| 812 if (m_ancestorClippingLayer) { | |
| 813 squashLayerPosition = IntPoint(m_ancestorClippingLayer->position().x () + totalSquashBounds.location().x(), | |
| 814 m_ancestorClippingLayer->position().y() + totalSquashBounds.loca tion().y()); | |
| 815 } else { | |
| 816 squashLayerPosition = IntPoint(m_graphicsLayer->position().x() + tot alSquashBounds.location().x(), | |
| 817 m_graphicsLayer->position().y() + totalSquashBounds.location().y ()); | |
| 818 } | |
| 819 | |
| 820 m_squashingLayer->setPosition(squashLayerPosition); | |
| 821 m_squashingLayer->setSize(totalSquashBounds.size()); | |
| 822 | |
| 823 // Now that the position of the squashing layer is known, update the off sets for each squashed RenderLayer. | |
| 824 // FIXME: find a cleaner way to compute renderer offsets, hopefully that supports transforms, too? | |
| 825 for (size_t i = 0; i < m_squashedLayers.size(); ++i) { | |
| 826 m_squashedLayers[i].offsetFromRenderer = IntSize(-m_squashedLayers[i ].offsetFromBackingRoot.width() - m_graphicsLayer->position().x() + m_squashingL ayer->position().x(), | |
| 827 -m_squashedLayers[i].offsetFromBackingRoot.height() - m_graphics Layer->position().y() + m_squashingLayer->position().y()); | |
| 828 | |
| 829 // FIXME: find a better design to avoid this redundant value | |
| 830 m_squashedLayers[i].renderLayer->setOffsetFromSquashingLayerOrigin(m _squashedLayers[i].offsetFromRenderer); | |
| 831 } | |
| 832 } | |
| 833 | |
| 783 if (m_owningLayer->scrollableArea()) | 834 if (m_owningLayer->scrollableArea()) |
| 784 m_owningLayer->scrollableArea()->positionOverflowControls(); | 835 m_owningLayer->scrollableArea()->positionOverflowControls(); |
| 785 | 836 |
| 786 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit edLayerMapping | 837 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit edLayerMapping |
| 787 // since it depends on whether compAncestor draws content, which gets update d later. | 838 // since it depends on whether compAncestor draws content, which gets update d later. |
| 788 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); | 839 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); |
| 789 | 840 |
| 790 updateContentsRect(isSimpleContainer); | 841 updateContentsRect(isSimpleContainer); |
| 791 updateBackgroundColor(isSimpleContainer); | 842 updateBackgroundColor(isSimpleContainer); |
| 792 updateDrawsContent(isSimpleContainer); | 843 updateDrawsContent(isSimpleContainer); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 846 m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get()); | 897 m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get()); |
| 847 } | 898 } |
| 848 if (m_layerForVerticalScrollbar) { | 899 if (m_layerForVerticalScrollbar) { |
| 849 m_layerForVerticalScrollbar->removeFromParent(); | 900 m_layerForVerticalScrollbar->removeFromParent(); |
| 850 m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get()); | 901 m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get()); |
| 851 } | 902 } |
| 852 if (m_layerForScrollCorner) { | 903 if (m_layerForScrollCorner) { |
| 853 m_layerForScrollCorner->removeFromParent(); | 904 m_layerForScrollCorner->removeFromParent(); |
| 854 m_graphicsLayer->addChild(m_layerForScrollCorner.get()); | 905 m_graphicsLayer->addChild(m_layerForScrollCorner.get()); |
| 855 } | 906 } |
| 907 | |
| 908 // The squashing containment layer, if it exists, becomes a no-op parent. | |
| 909 if (m_squashingLayer) { | |
| 910 ASSERT(compositor()->isLayerSquashingEnabled()); | |
| 911 ASSERT(m_squashingContainmentLayer); | |
| 912 | |
| 913 if (m_ancestorClippingLayer) | |
| 914 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get()) ; | |
| 915 else | |
| 916 m_squashingContainmentLayer->addChild(m_graphicsLayer.get()); | |
| 917 | |
| 918 m_squashingContainmentLayer->addChild(m_squashingLayer.get()); | |
| 919 } | |
| 856 } | 920 } |
| 857 | 921 |
| 858 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer) | 922 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer) |
| 859 { | 923 { |
| 860 IntRect contentsRect; | 924 IntRect contentsRect; |
| 861 if (isSimpleContainer && renderer()->hasBackground()) | 925 if (isSimpleContainer && renderer()->hasBackground()) |
| 862 contentsRect = backgroundBox(); | 926 contentsRect = backgroundBox(); |
| 863 else | 927 else |
| 864 contentsRect = contentsBox(); | 928 contentsRect = contentsBox(); |
| 865 | 929 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1172 m_graphicsLayer->setNeedsDisplay(); | 1236 m_graphicsLayer->setNeedsDisplay(); |
| 1173 if (renderer()->view()) | 1237 if (renderer()->view()) |
| 1174 compositor()->scrollingLayerDidChange(m_owningLayer); | 1238 compositor()->scrollingLayerDidChange(m_owningLayer); |
| 1175 } | 1239 } |
| 1176 | 1240 |
| 1177 return layerChanged; | 1241 return layerChanged; |
| 1178 } | 1242 } |
| 1179 | 1243 |
| 1180 void CompositedLayerMapping::updateScrollParent(RenderLayer* scrollParent) | 1244 void CompositedLayerMapping::updateScrollParent(RenderLayer* scrollParent) |
| 1181 { | 1245 { |
| 1246 // FIXME: Either the asserts or the code in his function are broken for squa shing. (I think it's the asserts?) | |
| 1247 | |
| 1182 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) { | 1248 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) { |
| 1183 if (m_ancestorClippingLayer) { | 1249 if (m_ancestorClippingLayer) { |
| 1184 ASSERT(childForSuperlayers() == m_ancestorClippingLayer.get()); | 1250 ASSERT(childForSuperlayers() == m_ancestorClippingLayer.get()); |
| 1185 // If we have an ancestor clipping layer, it is the scroll child. Th e other layer that may have | 1251 // If we have an ancestor clipping layer, it is the scroll child. Th e other layer that may have |
| 1186 // been the scroll child is the graphics layer. We will ensure that we clear its association | 1252 // been the scroll child is the graphics layer. We will ensure that we clear its association |
| 1187 // with a scroll parent if it had one. | 1253 // with a scroll parent if it had one. |
| 1188 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_ancestorC lippingLayer.get(), scrollParent); | 1254 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_ancestorC lippingLayer.get(), scrollParent); |
| 1189 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), 0); | 1255 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), 0); |
| 1190 } else { | 1256 } else { |
| 1191 ASSERT(childForSuperlayers() == m_graphicsLayer.get()); | 1257 ASSERT(childForSuperlayers() == m_graphicsLayer.get()); |
| 1192 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), scrollParent); | 1258 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), scrollParent); |
| 1193 } | 1259 } |
| 1194 } | 1260 } |
| 1195 } | 1261 } |
| 1196 | 1262 |
| 1197 void CompositedLayerMapping::updateClipParent(RenderLayer* clipParent) | 1263 void CompositedLayerMapping::updateClipParent(RenderLayer* clipParent) |
| 1198 { | 1264 { |
| 1199 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) | 1265 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) |
| 1200 scrollingCoordinator->updateClipParentForGraphicsLayer(m_graphicsLayer.g et(), clipParent); | 1266 scrollingCoordinator->updateClipParentForGraphicsLayer(m_graphicsLayer.g et(), clipParent); |
| 1201 } | 1267 } |
| 1202 | 1268 |
| 1269 bool CompositedLayerMapping::updateSquashingLayers(bool needsSquashingLayers) | |
| 1270 { | |
| 1271 bool layersChanged = false; | |
| 1272 | |
| 1273 if (needsSquashingLayers) { | |
| 1274 ASSERT(compositor()->isLayerSquashingEnabled()); | |
| 1275 | |
| 1276 if (!m_squashingLayer) { | |
| 1277 m_squashingLayer = createGraphicsLayer(CompositingReasonOverlap); | |
| 1278 m_squashingLayer->setDrawsContent(true); | |
| 1279 m_squashingLayer->setNeedsDisplay(); | |
| 1280 layersChanged = true; | |
| 1281 } | |
| 1282 | |
| 1283 if (!m_squashingContainmentLayer) { | |
| 1284 // FIXME: containment layer needs a new CompositingReason, Compositi ngReasonOverlap is not appropriate. | |
| 1285 m_squashingContainmentLayer = createGraphicsLayer(CompositingReasonO verlap); | |
| 1286 // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959 | |
| 1287 bool preserves3D = renderer()->style()->transformStyle3D() == Transf ormStyle3DPreserve3D && !renderer()->hasReflection(); | |
| 1288 m_squashingContainmentLayer->setPreserves3D(preserves3D); | |
| 1289 layersChanged = true; | |
| 1290 } | |
| 1291 | |
| 1292 ASSERT(m_squashingLayer && m_squashingContainmentLayer); | |
| 1293 } else { | |
| 1294 if (m_squashingLayer) { | |
| 1295 m_squashingLayer->removeFromParent(); | |
| 1296 m_squashingLayer = nullptr; | |
| 1297 layersChanged = true; | |
| 1298 // FIXME: do we need to invalidate something here? | |
| 1299 } | |
| 1300 | |
| 1301 if (m_squashingContainmentLayer) { | |
| 1302 m_squashingContainmentLayer->removeFromParent(); | |
| 1303 m_squashingContainmentLayer = nullptr; | |
| 1304 layersChanged = true; | |
| 1305 } | |
| 1306 | |
| 1307 ASSERT(!m_squashingLayer && !m_squashingContainmentLayer); | |
| 1308 } | |
| 1309 | |
| 1310 return layersChanged; | |
| 1311 } | |
| 1312 | |
| 1203 GraphicsLayerPaintingPhase CompositedLayerMapping::paintingPhaseForPrimaryLayer( ) const | 1313 GraphicsLayerPaintingPhase CompositedLayerMapping::paintingPhaseForPrimaryLayer( ) const |
| 1204 { | 1314 { |
| 1205 unsigned phase = 0; | 1315 unsigned phase = 0; |
| 1206 if (!m_backgroundLayer) | 1316 if (!m_backgroundLayer) |
| 1207 phase |= GraphicsLayerPaintBackground; | 1317 phase |= GraphicsLayerPaintBackground; |
| 1208 if (!m_foregroundLayer) | 1318 if (!m_foregroundLayer) |
| 1209 phase |= GraphicsLayerPaintForeground; | 1319 phase |= GraphicsLayerPaintForeground; |
| 1210 if (!m_maskLayer) | 1320 if (!m_maskLayer) |
| 1211 phase |= GraphicsLayerPaintMask; | 1321 phase |= GraphicsLayerPaintMask; |
| 1212 | 1322 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1534 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const | 1644 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const |
| 1535 { | 1645 { |
| 1536 if (m_scrollingContentsLayer) | 1646 if (m_scrollingContentsLayer) |
| 1537 return m_scrollingContentsLayer.get(); | 1647 return m_scrollingContentsLayer.get(); |
| 1538 | 1648 |
| 1539 return m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsL ayer.get(); | 1649 return m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsL ayer.get(); |
| 1540 } | 1650 } |
| 1541 | 1651 |
| 1542 GraphicsLayer* CompositedLayerMapping::childForSuperlayers() const | 1652 GraphicsLayer* CompositedLayerMapping::childForSuperlayers() const |
| 1543 { | 1653 { |
| 1654 if (m_squashingContainmentLayer) | |
| 1655 return m_squashingContainmentLayer.get(); | |
| 1656 | |
| 1544 if (m_ancestorClippingLayer) | 1657 if (m_ancestorClippingLayer) |
| 1545 return m_ancestorClippingLayer.get(); | 1658 return m_ancestorClippingLayer.get(); |
| 1546 | 1659 |
| 1547 return m_graphicsLayer.get(); | 1660 return m_graphicsLayer.get(); |
| 1548 } | 1661 } |
| 1549 | 1662 |
| 1550 bool CompositedLayerMapping::updateRequiresOwnBackingStoreForAncestorReasons(con st RenderLayer* compositingAncestorLayer) | 1663 bool CompositedLayerMapping::updateRequiresOwnBackingStoreForAncestorReasons(con st RenderLayer* compositingAncestorLayer) |
| 1551 { | 1664 { |
| 1552 bool previousRequiresOwnBackingStoreForAncestorReasons = m_requiresOwnBackin gStoreForAncestorReasons; | 1665 bool previousRequiresOwnBackingStoreForAncestorReasons = m_requiresOwnBackin gStoreForAncestorReasons; |
| 1553 bool previousPaintsIntoCompositedAncestor = paintsIntoCompositedAncestor(); | 1666 bool previousPaintsIntoCompositedAncestor = paintsIntoCompositedAncestor(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1701 | 1814 |
| 1702 // The dirtyRect is in the coords of the painting root. | 1815 // The dirtyRect is in the coords of the painting root. |
| 1703 IntRect dirtyRect = pixelSnappedIntRect(relativeClip); | 1816 IntRect dirtyRect = pixelSnappedIntRect(relativeClip); |
| 1704 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) | 1817 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) |
| 1705 dirtyRect.intersect(paintInfo.compositedBounds); | 1818 dirtyRect.intersect(paintInfo.compositedBounds); |
| 1706 | 1819 |
| 1707 #ifndef NDEBUG | 1820 #ifndef NDEBUG |
| 1708 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut(); | 1821 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut(); |
| 1709 #endif | 1822 #endif |
| 1710 | 1823 |
| 1711 // FIXME: GraphicsLayers need a way to split for RenderRegions. | 1824 if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) { |
| 1712 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehavi orNormal, LayoutSize()); | 1825 // FIXME: GraphicsLayers need a way to split for RenderRegions. |
| 1713 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFlags) ; | 1826 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, LayoutSize()); |
| 1827 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags); | |
| 1714 | 1828 |
| 1715 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRootBa ckgroundOnly); | 1829 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRo otBackgroundOnly); |
| 1716 | 1830 |
| 1717 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) | 1831 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) |
| 1718 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags | PaintLayerPaintingOverlayScrollbars); | 1832 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, pai ntFlags | PaintLayerPaintingOverlayScrollbars); |
| 1833 } else { | |
| 1834 ASSERT(compositor()->isLayerSquashingEnabled()); | |
| 1835 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, LayoutSize()); | |
| 1836 paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags); | |
| 1837 } | |
| 1719 | 1838 |
| 1720 ASSERT(!paintInfo.renderLayer->m_usedTransparency); | 1839 ASSERT(!paintInfo.renderLayer->m_usedTransparency); |
| 1721 | 1840 |
| 1722 // Manually restore the context to its original state by applying the opposi te translation. | 1841 // Manually restore the context to its original state by applying the opposi te translation. |
| 1723 context->translate(offset); | 1842 context->translate(offset); |
| 1724 } | 1843 } |
| 1725 | 1844 |
| 1726 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip) | 1845 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip) |
| 1727 { | 1846 { |
| 1728 if (!scrollbar) | 1847 if (!scrollbar) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1755 | 1874 |
| 1756 GraphicsLayerPaintInfo paintInfo; | 1875 GraphicsLayerPaintInfo paintInfo; |
| 1757 paintInfo.renderLayer = m_owningLayer; | 1876 paintInfo.renderLayer = m_owningLayer; |
| 1758 paintInfo.compositedBounds = compositedBounds(); | 1877 paintInfo.compositedBounds = compositedBounds(); |
| 1759 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); | 1878 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); |
| 1760 paintInfo.paintingPhase = paintingPhase; | 1879 paintInfo.paintingPhase = paintingPhase; |
| 1761 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); | 1880 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); |
| 1762 | 1881 |
| 1763 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. | 1882 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. |
| 1764 doPaintTask(paintInfo, &context, clip); | 1883 doPaintTask(paintInfo, &context, clip); |
| 1884 } else if (graphicsLayer == m_squashingLayer.get()) { | |
| 1885 ASSERT(compositor()->isLayerSquashingEnabled()); | |
| 1886 for (size_t i = 0; i < m_squashedLayers.size(); ++i) | |
| 1887 doPaintTask(m_squashedLayers[i], &context, clip); | |
| 1765 } else if (graphicsLayer == layerForHorizontalScrollbar()) { | 1888 } else if (graphicsLayer == layerForHorizontalScrollbar()) { |
| 1766 paintScrollbar(m_owningLayer->scrollableArea()->horizontalScrollbar(), c ontext, clip); | 1889 paintScrollbar(m_owningLayer->scrollableArea()->horizontalScrollbar(), c ontext, clip); |
| 1767 } else if (graphicsLayer == layerForVerticalScrollbar()) { | 1890 } else if (graphicsLayer == layerForVerticalScrollbar()) { |
| 1768 paintScrollbar(m_owningLayer->scrollableArea()->verticalScrollbar(), con text, clip); | 1891 paintScrollbar(m_owningLayer->scrollableArea()->verticalScrollbar(), con text, clip); |
| 1769 } else if (graphicsLayer == layerForScrollCorner()) { | 1892 } else if (graphicsLayer == layerForScrollCorner()) { |
| 1770 const IntRect& scrollCornerAndResizer = m_owningLayer->scrollableArea()- >scrollCornerAndResizerRect(); | 1893 const IntRect& scrollCornerAndResizer = m_owningLayer->scrollableArea()- >scrollCornerAndResizerRect(); |
| 1771 context.save(); | 1894 context.save(); |
| 1772 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y ()); | 1895 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y ()); |
| 1773 IntRect transformedClip = clip; | 1896 IntRect transformedClip = clip; |
| 1774 transformedClip.moveBy(scrollCornerAndResizer.location()); | 1897 transformedClip.moveBy(scrollCornerAndResizer.location()); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1950 IntRect CompositedLayerMapping::compositedBounds() const | 2073 IntRect CompositedLayerMapping::compositedBounds() const |
| 1951 { | 2074 { |
| 1952 return m_compositedBounds; | 2075 return m_compositedBounds; |
| 1953 } | 2076 } |
| 1954 | 2077 |
| 1955 void CompositedLayerMapping::setCompositedBounds(const IntRect& bounds) | 2078 void CompositedLayerMapping::setCompositedBounds(const IntRect& bounds) |
| 1956 { | 2079 { |
| 1957 m_compositedBounds = bounds; | 2080 m_compositedBounds = bounds; |
| 1958 } | 2081 } |
| 1959 | 2082 |
| 2083 void CompositedLayerMapping::addRenderLayerToSquashingGraphicsLayer(RenderLayer* layer, IntSize offsetFromTargetBacking) | |
| 2084 { | |
| 2085 ASSERT(compositor()->isLayerSquashingEnabled()); | |
| 2086 ASSERT(m_nextSquashedLayerIndex >= 0 && m_nextSquashedLayerIndex < 0x0fff000 0); | |
| 2087 | |
| 2088 // Temporary release mode sanity check | |
| 2089 if (m_nextSquashedLayerIndex == 0x0fff0000) { | |
|
enne (OOO)
2013/11/27 23:20:26
There's just something about temporary and "only v
shawnsingh
2013/12/02 01:55:03
Done - new patch is indeed much more elegant about
| |
| 2090 fprintf(stderr, "ERROR - trying to addRenderLayerToSquashingGraphicsLaye r() outside of begin/finish\n"); | |
| 2091 exit(1); | |
| 2092 } | |
| 2093 | |
| 2094 GraphicsLayerPaintInfo paintInfo; | |
| 2095 paintInfo.renderLayer = layer; | |
| 2096 // NOTE: composited bounds are updated elsewhere | |
| 2097 // NOTE: offsetFromRenderer is updated elsewhere | |
| 2098 paintInfo.offsetFromBackingRoot = offsetFromTargetBacking; | |
| 2099 paintInfo.paintingPhase = GraphicsLayerPaintAllWithOverflowClip; | |
| 2100 paintInfo.isBackgroundLayer = false; | |
| 2101 | |
| 2102 // Change tracking on squashing layers: at the first sign of something chang ed, just invalidate the layer. | |
| 2103 // FIXME: Perhaps we can find a tighter more clever mechanism later. | |
| 2104 if (m_nextSquashedLayerIndex < m_squashedLayers.size()) { | |
| 2105 if (m_squashedLayers[m_nextSquashedLayerIndex].renderLayer != layer) { | |
| 2106 m_squashedLayers[m_nextSquashedLayerIndex] = paintInfo; | |
| 2107 m_squashingLayer->setNeedsDisplay(); | |
| 2108 } | |
| 2109 } else { | |
| 2110 m_squashedLayers.append(paintInfo); | |
| 2111 if (m_squashingLayer) | |
| 2112 m_squashingLayer->setNeedsDisplay(); | |
| 2113 } | |
| 2114 m_nextSquashedLayerIndex++; | |
| 2115 | |
| 2116 layer->setGroupedMapping(this); | |
| 2117 } | |
| 2118 | |
| 2119 void CompositedLayerMapping::beginAccumulatingSquashingLayers() | |
| 2120 { | |
| 2121 ASSERT(compositor()->isLayerSquashingEnabled()); | |
| 2122 ASSERT(m_nextSquashedLayerIndex == 0x0fff0000); | |
| 2123 | |
| 2124 // temporary release mode sanity check | |
| 2125 if (m_nextSquashedLayerIndex != 0x0fff0000) { | |
| 2126 fprintf(stderr, "ERROR - DID NOT EXPECT 0x0fff000 here, got %lu instead\ n", m_nextSquashedLayerIndex); | |
| 2127 exit(1); | |
| 2128 } | |
| 2129 | |
| 2130 m_nextSquashedLayerIndex = 0; | |
| 2131 } | |
| 2132 | |
| 2133 void CompositedLayerMapping::finishAccumulatingSquashingLayers() | |
| 2134 { | |
| 2135 ASSERT(compositor()->isLayerSquashingEnabled()); | |
| 2136 | |
| 2137 // Any additional squashed RenderLayers in the array no longer exist, and re moving invalidates the squashingLayer contents. | |
| 2138 if (m_nextSquashedLayerIndex < m_squashedLayers.size()) { | |
| 2139 m_squashedLayers.remove(m_nextSquashedLayerIndex, m_squashedLayers.size( ) - m_nextSquashedLayerIndex); | |
| 2140 if (m_squashingLayer) | |
| 2141 m_squashingLayer->setNeedsDisplay(); | |
| 2142 } | |
| 2143 | |
| 2144 // FIXME: do something better than this encoded hack. This value is size_t a nd shouldn't be negative anyway. | |
| 2145 m_nextSquashedLayerIndex = 0x0fff0000; | |
| 2146 } | |
| 2147 | |
| 1960 CompositingLayerType CompositedLayerMapping::compositingLayerType() const | 2148 CompositingLayerType CompositedLayerMapping::compositingLayerType() const |
| 1961 { | 2149 { |
| 1962 if (m_graphicsLayer->hasContentsLayer()) | 2150 if (m_graphicsLayer->hasContentsLayer()) |
| 1963 return MediaCompositingLayer; | 2151 return MediaCompositingLayer; |
| 1964 | 2152 |
| 1965 if (m_graphicsLayer->drawsContent()) | 2153 if (m_graphicsLayer->drawsContent()) |
| 1966 return NormalCompositingLayer; | 2154 return NormalCompositingLayer; |
| 1967 | 2155 |
| 1968 return ContainerCompositingLayer; | 2156 return ContainerCompositingLayer; |
| 1969 } | 2157 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2026 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2214 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
| 2027 name = "Scrolling Contents Layer"; | 2215 name = "Scrolling Contents Layer"; |
| 2028 } else { | 2216 } else { |
| 2029 ASSERT_NOT_REACHED(); | 2217 ASSERT_NOT_REACHED(); |
| 2030 } | 2218 } |
| 2031 | 2219 |
| 2032 return name; | 2220 return name; |
| 2033 } | 2221 } |
| 2034 | 2222 |
| 2035 } // namespace WebCore | 2223 } // namespace WebCore |
| OLD | NEW |