Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: Source/core/rendering/CompositedLayerMapping.cpp

Issue 88863002: Land layer squashing behind a flag (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed reviewer feedback Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 , m_backgroundLayerPaintsFixedRootBackground(false) 168 , m_backgroundLayerPaintsFixedRootBackground(false)
169 { 169 {
170 if (layer->isRootLayer() && renderer()->frame()->isMainFrame()) 170 if (layer->isRootLayer() && renderer()->frame()->isMainFrame())
171 m_isMainFrameRenderViewLayer = true; 171 m_isMainFrameRenderViewLayer = true;
172 172
173 createPrimaryGraphicsLayer(); 173 createPrimaryGraphicsLayer();
174 } 174 }
175 175
176 CompositedLayerMapping::~CompositedLayerMapping() 176 CompositedLayerMapping::~CompositedLayerMapping()
177 { 177 {
178 // FIXME: this almost certainly needs to go somewhere more appropriate so it occurs
179 // when things change as well as things getting destroyed.
Ian Vollick 2013/12/02 21:17:05 I wonder if it can be driven from RLC::rebuildComp
shawnsingh 2013/12/05 17:55:24 This FIXME should be removed. I've convinced myse
180 for (size_t i = 0; i < m_squashedLayers.size(); ++i) {
181 if (m_squashedLayers[i].renderLayer->compositingState() == PaintsIntoGro upedBacking)
182 m_squashedLayers[i].renderLayer->setGroupedMapping(0);
183 }
184
178 updateClippingLayers(false, false); 185 updateClippingLayers(false, false);
179 updateOverflowControlsLayers(false, false, false); 186 updateOverflowControlsLayers(false, false, false);
180 updateForegroundLayer(false); 187 updateForegroundLayer(false);
181 updateBackgroundLayer(false); 188 updateBackgroundLayer(false);
182 updateMaskLayer(false); 189 updateMaskLayer(false);
183 updateClippingMaskLayers(false); 190 updateClippingMaskLayers(false);
184 updateScrollingLayers(false); 191 updateScrollingLayers(false);
192 updateSquashingLayers(false);
185 destroyGraphicsLayers(); 193 destroyGraphicsLayers();
186 } 194 }
187 195
188 PassOwnPtr<GraphicsLayer> CompositedLayerMapping::createGraphicsLayer(Compositin gReasons reasons) 196 PassOwnPtr<GraphicsLayer> CompositedLayerMapping::createGraphicsLayer(Compositin gReasons reasons)
189 { 197 {
190 GraphicsLayerFactory* graphicsLayerFactory = 0; 198 GraphicsLayerFactory* graphicsLayerFactory = 0;
191 if (Page* page = renderer()->frame()->page()) 199 if (Page* page = renderer()->frame()->page())
192 graphicsLayerFactory = page->chrome().client().graphicsLayerFactory(); 200 graphicsLayerFactory = page->chrome().client().graphicsLayerFactory();
193 201
194 OwnPtr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFac tory, this); 202 OwnPtr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFac tory, this);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 458
451 if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), require sVerticalScrollbarLayer(), requiresScrollCornerLayer())) 459 if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), require sVerticalScrollbarLayer(), requiresScrollCornerLayer()))
452 layerConfigChanged = true; 460 layerConfigChanged = true;
453 461
454 if (updateScrollingLayers(m_owningLayer->needsCompositedScrolling())) 462 if (updateScrollingLayers(m_owningLayer->needsCompositedScrolling()))
455 layerConfigChanged = true; 463 layerConfigChanged = true;
456 464
457 updateScrollParent(scrollParent); 465 updateScrollParent(scrollParent);
458 updateClipParent(m_owningLayer->clipParent()); 466 updateClipParent(m_owningLayer->clipParent());
459 467
468 if (updateSquashingLayers(!m_squashedLayers.isEmpty()))
469 layerConfigChanged = true;
470
460 if (layerConfigChanged) 471 if (layerConfigChanged)
461 updateInternalHierarchy(); 472 updateInternalHierarchy();
462 473
463 if (updateMaskLayer(renderer->hasMask())) 474 if (updateMaskLayer(renderer->hasMask()))
464 m_graphicsLayer->setMaskLayer(m_maskLayer.get()); 475 m_graphicsLayer->setMaskLayer(m_maskLayer.get());
465 476
466 bool hasChildClippingLayer = compositor->clipsCompositingDescendants(m_ownin gLayer) && (hasClippingLayer() || hasScrollingLayer()); 477 bool hasChildClippingLayer = compositor->clipsCompositingDescendants(m_ownin gLayer) && (hasClippingLayer() || hasScrollingLayer());
467 bool needsChildClippingMask = (renderer->style()->clipPath() || renderer->st yle()->hasBorderRadius()) && (hasChildClippingLayer || isAcceleratedContents(ren derer)); 478 bool needsChildClippingMask = (renderer->style()->clipPath() || renderer->st yle()->hasBorderRadius()) && (hasChildClippingLayer || isAcceleratedContents(ren derer));
468 if (updateClippingMaskLayers(needsChildClippingMask)) { 479 if (updateClippingMaskLayers(needsChildClippingMask)) {
469 if (hasClippingLayer()) 480 if (hasClippingLayer())
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959 570 // 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(); 571 bool preserves3D = style->transformStyle3D() == TransformStyle3DPreserve3D & & !renderer()->hasReflection();
561 m_graphicsLayer->setPreserves3D(preserves3D); 572 m_graphicsLayer->setPreserves3D(preserves3D);
562 m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == Backfa ceVisibilityVisible); 573 m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == Backfa ceVisibilityVisible);
563 574
564 RenderLayer* compAncestor = m_owningLayer->ancestorCompositingLayer(); 575 RenderLayer* compAncestor = m_owningLayer->ancestorCompositingLayer();
565 576
566 // We compute everything relative to the enclosing compositing layer. 577 // We compute everything relative to the enclosing compositing layer.
567 IntRect ancestorCompositingBounds; 578 IntRect ancestorCompositingBounds;
568 if (compAncestor) { 579 if (compAncestor) {
580 // FIXME: is it correct to fix the ASSERT by adding the squashing condit ion here, too?
Ian Vollick 2013/12/02 21:17:05 Yeah, I think so. It should be valid for compAnces
shawnsingh 2013/12/05 17:55:24 Actually I've convinced myself this FIXME is bogus
569 ASSERT(compAncestor->hasCompositedLayerMapping()); 581 ASSERT(compAncestor->hasCompositedLayerMapping());
570 ancestorCompositingBounds = pixelSnappedIntRect(compAncestor->composited LayerMapping()->compositedBounds()); 582 ancestorCompositingBounds = pixelSnappedIntRect(compAncestor->composited LayerMapping()->compositedBounds());
571 } 583 }
572 584
573 IntRect localCompositingBounds = pixelSnappedIntRect(compositedBounds()); 585 IntRect localCompositingBounds = pixelSnappedIntRect(compositedBounds());
574 586
575 IntRect relativeCompositingBounds(localCompositingBounds); 587 IntRect relativeCompositingBounds(localCompositingBounds);
576 IntPoint delta; 588 IntPoint delta;
577 m_owningLayer->convertToPixelSnappedLayerCoords(compAncestor, delta); 589 m_owningLayer->convertToPixelSnappedLayerCoords(compAncestor, delta);
578 relativeCompositingBounds.moveBy(delta); 590 relativeCompositingBounds.moveBy(delta);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, GraphicsLayer::DontSetNeedsDisplay); 785 m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, GraphicsLayer::DontSetNeedsDisplay);
774 786
775 if (m_foregroundLayer) { 787 if (m_foregroundLayer) {
776 if (m_foregroundLayer->size() != m_scrollingContentsLayer->size()) 788 if (m_foregroundLayer->size() != m_scrollingContentsLayer->size())
777 m_foregroundLayer->setSize(m_scrollingContentsLayer->size()); 789 m_foregroundLayer->setSize(m_scrollingContentsLayer->size());
778 m_foregroundLayer->setNeedsDisplay(); 790 m_foregroundLayer->setNeedsDisplay();
779 m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->o ffsetFromRenderer()); 791 m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->o ffsetFromRenderer());
780 } 792 }
781 } 793 }
782 794
795 if (m_squashingLayer) {
Ian Vollick 2013/12/02 21:17:05 IIUC, we ultimately want to postpone geometry comp
shawnsingh 2013/12/05 17:55:24 Can you please elaborate what geometry stuff is un
Ian Vollick 2013/12/06 21:11:30 I was incorrectly worried that calculateComposited
796 ASSERT(compositor()->isLayerSquashingEnabled());
797
798 IntRect totalSquashBounds;
799 for (size_t i = 0; i < m_squashedLayers.size(); ++i) {
800 IntRect squashedBounds = compositor()->calculateCompositedBounds(m_s quashedLayers[i].renderLayer, m_squashedLayers[i].renderLayer);
801
802 // Store the composited bounds before applying the offset.
803 // FIXME: do we need to? is it better for some reason?
Ian Vollick 2013/12/02 21:17:05 We'll always be able to move it back, if necessary
804 m_squashedLayers[i].compositedBounds = squashedBounds;
805
806 squashedBounds.move(m_squashedLayers[i].offsetFromBackingRoot);
807 totalSquashBounds.unite(squashedBounds);
808 }
809
810 IntPoint squashLayerPosition;
811 if (m_ancestorClippingLayer) {
Ian Vollick 2013/12/02 21:17:05 Ancestor transform layer's gonna have to be dealt
812 squashLayerPosition = IntPoint(m_ancestorClippingLayer->position().x () + totalSquashBounds.location().x(),
813 m_ancestorClippingLayer->position().y() + totalSquashBounds.loca tion().y());
814 } else {
815 squashLayerPosition = IntPoint(m_graphicsLayer->position().x() + tot alSquashBounds.location().x(),
816 m_graphicsLayer->position().y() + totalSquashBounds.location().y ());
817 }
818
819 m_squashingLayer->setPosition(squashLayerPosition);
820 m_squashingLayer->setSize(totalSquashBounds.size());
Ian Vollick 2013/12/02 21:17:05 It occurs to me that perspective depends on layer
shawnsingh 2013/12/05 17:55:24 Yeah, I am planning to add a canBeSquashed() funct
821
822 // Now that the position of the squashing layer is known, update the off sets for each squashed RenderLayer.
823 // FIXME: find a cleaner way to compute renderer offsets, hopefully that supports transforms, too?
Ian Vollick 2013/12/02 21:17:05 I kinda think we should punt on squashing layers w
shawnsingh 2013/12/05 17:55:24 3d transforms would always be composited... ? This
Ian Vollick 2013/12/06 21:11:30 (facepalm). Of course. Sorry, carry on..
824 for (size_t i = 0; i < m_squashedLayers.size(); ++i) {
825 m_squashedLayers[i].offsetFromRenderer = IntSize(-m_squashedLayers[i ].offsetFromBackingRoot.width() - m_graphicsLayer->position().x() + m_squashingL ayer->position().x(),
826 -m_squashedLayers[i].offsetFromBackingRoot.height() - m_graphics Layer->position().y() + m_squashingLayer->position().y());
827
828 // FIXME: find a better design to avoid this redundant value
829 m_squashedLayers[i].renderLayer->setOffsetFromSquashingLayerOrigin(m _squashedLayers[i].offsetFromRenderer);
830 }
831 }
832
783 if (m_owningLayer->scrollableArea()) 833 if (m_owningLayer->scrollableArea())
784 m_owningLayer->scrollableArea()->positionOverflowControls(); 834 m_owningLayer->scrollableArea()->positionOverflowControls();
785 835
786 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit edLayerMapping 836 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit edLayerMapping
787 // since it depends on whether compAncestor draws content, which gets update d later. 837 // since it depends on whether compAncestor draws content, which gets update d later.
788 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); 838 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor);
789 839
790 updateContentsRect(isSimpleContainer); 840 updateContentsRect(isSimpleContainer);
791 updateBackgroundColor(isSimpleContainer); 841 updateBackgroundColor(isSimpleContainer);
792 updateDrawsContent(isSimpleContainer); 842 updateDrawsContent(isSimpleContainer);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get()); 896 m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get());
847 } 897 }
848 if (m_layerForVerticalScrollbar) { 898 if (m_layerForVerticalScrollbar) {
849 m_layerForVerticalScrollbar->removeFromParent(); 899 m_layerForVerticalScrollbar->removeFromParent();
850 m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get()); 900 m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get());
851 } 901 }
852 if (m_layerForScrollCorner) { 902 if (m_layerForScrollCorner) {
853 m_layerForScrollCorner->removeFromParent(); 903 m_layerForScrollCorner->removeFromParent();
854 m_graphicsLayer->addChild(m_layerForScrollCorner.get()); 904 m_graphicsLayer->addChild(m_layerForScrollCorner.get());
855 } 905 }
906
907 // The squashing containment layer, if it exists, becomes a no-op parent.
908 if (m_squashingLayer) {
Ian Vollick 2013/12/02 21:17:05 Usually there's a bit here where we remove all chi
shawnsingh 2013/12/05 17:55:24 I think I just missed it. Added to new patch, tha
909 ASSERT(compositor()->isLayerSquashingEnabled());
910 ASSERT(m_squashingContainmentLayer);
911
912 if (m_ancestorClippingLayer)
913 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get()) ;
914 else
915 m_squashingContainmentLayer->addChild(m_graphicsLayer.get());
916
917 m_squashingContainmentLayer->addChild(m_squashingLayer.get());
918 }
856 } 919 }
857 920
858 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer) 921 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer)
859 { 922 {
860 IntRect contentsRect; 923 IntRect contentsRect;
861 if (isSimpleContainer && renderer()->hasBackground()) 924 if (isSimpleContainer && renderer()->hasBackground())
862 contentsRect = backgroundBox(); 925 contentsRect = backgroundBox();
863 else 926 else
864 contentsRect = contentsBox(); 927 contentsRect = contentsBox();
865 928
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 m_graphicsLayer->setNeedsDisplay(); 1235 m_graphicsLayer->setNeedsDisplay();
1173 if (renderer()->view()) 1236 if (renderer()->view())
1174 compositor()->scrollingLayerDidChange(m_owningLayer); 1237 compositor()->scrollingLayerDidChange(m_owningLayer);
1175 } 1238 }
1176 1239
1177 return layerChanged; 1240 return layerChanged;
1178 } 1241 }
1179 1242
1180 void CompositedLayerMapping::updateScrollParent(RenderLayer* scrollParent) 1243 void CompositedLayerMapping::updateScrollParent(RenderLayer* scrollParent)
1181 { 1244 {
1245 // FIXME: Either the asserts or the code in his function are broken for squa shing. (I think it's the asserts?)
Ian Vollick 2013/12/02 21:17:05 It's broken. There are three layers that might be
shawnsingh 2013/12/05 17:55:24 Please let me know if new patch does it properly =
1246
1182 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) { 1247 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) {
1183 if (m_ancestorClippingLayer) { 1248 if (m_ancestorClippingLayer) {
1184 ASSERT(childForSuperlayers() == m_ancestorClippingLayer.get()); 1249 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 1250 // 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 1251 // 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. 1252 // with a scroll parent if it had one.
1188 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_ancestorC lippingLayer.get(), scrollParent); 1253 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_ancestorC lippingLayer.get(), scrollParent);
1189 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), 0); 1254 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), 0);
1190 } else { 1255 } else {
1191 ASSERT(childForSuperlayers() == m_graphicsLayer.get()); 1256 ASSERT(childForSuperlayers() == m_graphicsLayer.get());
1192 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), scrollParent); 1257 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), scrollParent);
1193 } 1258 }
1194 } 1259 }
1195 } 1260 }
1196 1261
1197 void CompositedLayerMapping::updateClipParent(RenderLayer* clipParent) 1262 void CompositedLayerMapping::updateClipParent(RenderLayer* clipParent)
1198 { 1263 {
1199 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) 1264 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer))
1200 scrollingCoordinator->updateClipParentForGraphicsLayer(m_graphicsLayer.g et(), clipParent); 1265 scrollingCoordinator->updateClipParentForGraphicsLayer(m_graphicsLayer.g et(), clipParent);
1201 } 1266 }
1202 1267
1268 bool CompositedLayerMapping::updateSquashingLayers(bool needsSquashingLayers)
1269 {
1270 bool layersChanged = false;
1271
1272 if (needsSquashingLayers) {
1273 ASSERT(compositor()->isLayerSquashingEnabled());
1274
1275 if (!m_squashingLayer) {
1276 m_squashingLayer = createGraphicsLayer(CompositingReasonOverlap);
1277 m_squashingLayer->setDrawsContent(true);
1278 m_squashingLayer->setNeedsDisplay();
1279 layersChanged = true;
1280 }
1281
1282 if (!m_squashingContainmentLayer) {
trchen 2013/12/02 22:56:55 This can merge with the if-block above, with ASSER
1283 // FIXME: containment layer needs a new CompositingReason, Compositi ngReasonOverlap is not appropriate.
1284 m_squashingContainmentLayer = createGraphicsLayer(CompositingReasonO verlap);
1285 // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959
1286 bool preserves3D = renderer()->style()->transformStyle3D() == Transf ormStyle3DPreserve3D && !renderer()->hasReflection();
Ian Vollick 2013/12/02 21:17:05 Can we write a CLM::preserves3D() helper fn? I fin
trchen 2013/12/02 22:56:55 Couldn't we setPreserves3D(true) always? Squashing
shawnsingh 2013/12/05 17:55:24 I would prefer to call it CLM::owningLayerPreserve
1287 m_squashingContainmentLayer->setPreserves3D(preserves3D);
1288 layersChanged = true;
1289 }
1290
1291 ASSERT(m_squashingLayer && m_squashingContainmentLayer);
1292 } else {
1293 if (m_squashingLayer) {
1294 m_squashingLayer->removeFromParent();
trchen 2013/12/02 22:56:55 No need to explicitly removeFromParent. The destru
shawnsingh 2013/12/05 17:55:24 The style in the rest of this file does explicitly
1295 m_squashingLayer = nullptr;
1296 layersChanged = true;
1297 // FIXME: do we need to invalidate something here?
1298 }
1299
1300 if (m_squashingContainmentLayer) {
1301 m_squashingContainmentLayer->removeFromParent();
trchen 2013/12/02 22:56:55 Ditto
1302 m_squashingContainmentLayer = nullptr;
1303 layersChanged = true;
1304 }
1305
1306 ASSERT(!m_squashingLayer && !m_squashingContainmentLayer);
1307 }
1308
1309 return layersChanged;
1310 }
1311
1203 GraphicsLayerPaintingPhase CompositedLayerMapping::paintingPhaseForPrimaryLayer( ) const 1312 GraphicsLayerPaintingPhase CompositedLayerMapping::paintingPhaseForPrimaryLayer( ) const
1204 { 1313 {
1205 unsigned phase = 0; 1314 unsigned phase = 0;
1206 if (!m_backgroundLayer) 1315 if (!m_backgroundLayer)
1207 phase |= GraphicsLayerPaintBackground; 1316 phase |= GraphicsLayerPaintBackground;
1208 if (!m_foregroundLayer) 1317 if (!m_foregroundLayer)
1209 phase |= GraphicsLayerPaintForeground; 1318 phase |= GraphicsLayerPaintForeground;
1210 if (!m_maskLayer) 1319 if (!m_maskLayer)
1211 phase |= GraphicsLayerPaintMask; 1320 phase |= GraphicsLayerPaintMask;
1212 1321
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const 1643 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const
1535 { 1644 {
1536 if (m_scrollingContentsLayer) 1645 if (m_scrollingContentsLayer)
1537 return m_scrollingContentsLayer.get(); 1646 return m_scrollingContentsLayer.get();
1538 1647
1539 return m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsL ayer.get(); 1648 return m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsL ayer.get();
1540 } 1649 }
1541 1650
1542 GraphicsLayer* CompositedLayerMapping::childForSuperlayers() const 1651 GraphicsLayer* CompositedLayerMapping::childForSuperlayers() const
1543 { 1652 {
1653 if (m_squashingContainmentLayer)
1654 return m_squashingContainmentLayer.get();
1655
1544 if (m_ancestorClippingLayer) 1656 if (m_ancestorClippingLayer)
1545 return m_ancestorClippingLayer.get(); 1657 return m_ancestorClippingLayer.get();
1546 1658
1547 return m_graphicsLayer.get(); 1659 return m_graphicsLayer.get();
1548 } 1660 }
1549 1661
1550 bool CompositedLayerMapping::updateRequiresOwnBackingStoreForAncestorReasons(con st RenderLayer* compositingAncestorLayer) 1662 bool CompositedLayerMapping::updateRequiresOwnBackingStoreForAncestorReasons(con st RenderLayer* compositingAncestorLayer)
1551 { 1663 {
1552 bool previousRequiresOwnBackingStoreForAncestorReasons = m_requiresOwnBackin gStoreForAncestorReasons; 1664 bool previousRequiresOwnBackingStoreForAncestorReasons = m_requiresOwnBackin gStoreForAncestorReasons;
1553 bool previousPaintsIntoCompositedAncestor = paintsIntoCompositedAncestor(); 1665 bool previousPaintsIntoCompositedAncestor = paintsIntoCompositedAncestor();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 1813
1702 // The dirtyRect is in the coords of the painting root. 1814 // The dirtyRect is in the coords of the painting root.
1703 IntRect dirtyRect = pixelSnappedIntRect(relativeClip); 1815 IntRect dirtyRect = pixelSnappedIntRect(relativeClip);
1704 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) 1816 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents))
1705 dirtyRect.intersect(paintInfo.compositedBounds); 1817 dirtyRect.intersect(paintInfo.compositedBounds);
1706 1818
1707 #ifndef NDEBUG 1819 #ifndef NDEBUG
1708 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut(); 1820 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut();
1709 #endif 1821 #endif
1710 1822
1711 // FIXME: GraphicsLayers need a way to split for RenderRegions. 1823 if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) {
1712 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehavi orNormal, LayoutSize()); 1824 // FIXME: GraphicsLayers need a way to split for RenderRegions.
1713 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFlags) ; 1825 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, LayoutSize());
1826 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags);
1714 1827
1715 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRootBa ckgroundOnly); 1828 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRo otBackgroundOnly);
1716 1829
1717 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) 1830 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars())
1718 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags | PaintLayerPaintingOverlayScrollbars); 1831 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, pai ntFlags | PaintLayerPaintingOverlayScrollbars);
1832 } else {
1833 ASSERT(compositor()->isLayerSquashingEnabled());
1834 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, LayoutSize());
1835 paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags);
1836 }
1719 1837
1720 ASSERT(!paintInfo.renderLayer->m_usedTransparency); 1838 ASSERT(!paintInfo.renderLayer->m_usedTransparency);
1721 1839
1722 // Manually restore the context to its original state by applying the opposi te translation. 1840 // Manually restore the context to its original state by applying the opposi te translation.
1723 context->translate(offset); 1841 context->translate(offset);
1724 } 1842 }
1725 1843
1726 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip) 1844 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip)
1727 { 1845 {
1728 if (!scrollbar) 1846 if (!scrollbar)
(...skipping 25 matching lines...) Expand all
1754 || graphicsLayer == m_scrollingContentsLayer.get()) { 1872 || graphicsLayer == m_scrollingContentsLayer.get()) {
1755 1873
1756 GraphicsLayerPaintInfo paintInfo; 1874 GraphicsLayerPaintInfo paintInfo;
1757 paintInfo.renderLayer = m_owningLayer; 1875 paintInfo.renderLayer = m_owningLayer;
1758 paintInfo.compositedBounds = compositedBounds(); 1876 paintInfo.compositedBounds = compositedBounds();
1759 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); 1877 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer();
1760 paintInfo.paintingPhase = paintingPhase; 1878 paintInfo.paintingPhase = paintingPhase;
1761 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); 1879 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer);
1762 1880
1763 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 1881 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
1764 doPaintTask(paintInfo, &context, clip); 1882 doPaintTask(paintInfo, &context, clip);
trchen 2013/12/02 22:56:55 Do we have to skip painting here if we're squashed
shawnsingh 2013/12/05 17:55:24 We will guarantee not to reach this code when the
1883 } else if (graphicsLayer == m_squashingLayer.get()) {
1884 ASSERT(compositor()->isLayerSquashingEnabled());
1885 for (size_t i = 0; i < m_squashedLayers.size(); ++i)
1886 doPaintTask(m_squashedLayers[i], &context, clip);
Ian Vollick 2013/12/02 21:17:05 Cool.
1765 } else if (graphicsLayer == layerForHorizontalScrollbar()) { 1887 } else if (graphicsLayer == layerForHorizontalScrollbar()) {
1766 paintScrollbar(m_owningLayer->scrollableArea()->horizontalScrollbar(), c ontext, clip); 1888 paintScrollbar(m_owningLayer->scrollableArea()->horizontalScrollbar(), c ontext, clip);
1767 } else if (graphicsLayer == layerForVerticalScrollbar()) { 1889 } else if (graphicsLayer == layerForVerticalScrollbar()) {
1768 paintScrollbar(m_owningLayer->scrollableArea()->verticalScrollbar(), con text, clip); 1890 paintScrollbar(m_owningLayer->scrollableArea()->verticalScrollbar(), con text, clip);
1769 } else if (graphicsLayer == layerForScrollCorner()) { 1891 } else if (graphicsLayer == layerForScrollCorner()) {
1770 const IntRect& scrollCornerAndResizer = m_owningLayer->scrollableArea()- >scrollCornerAndResizerRect(); 1892 const IntRect& scrollCornerAndResizer = m_owningLayer->scrollableArea()- >scrollCornerAndResizerRect();
1771 context.save(); 1893 context.save();
1772 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y ()); 1894 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y ());
1773 IntRect transformedClip = clip; 1895 IntRect transformedClip = clip;
1774 transformedClip.moveBy(scrollCornerAndResizer.location()); 1896 transformedClip.moveBy(scrollCornerAndResizer.location());
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 IntRect CompositedLayerMapping::compositedBounds() const 2072 IntRect CompositedLayerMapping::compositedBounds() const
1951 { 2073 {
1952 return m_compositedBounds; 2074 return m_compositedBounds;
1953 } 2075 }
1954 2076
1955 void CompositedLayerMapping::setCompositedBounds(const IntRect& bounds) 2077 void CompositedLayerMapping::setCompositedBounds(const IntRect& bounds)
1956 { 2078 {
1957 m_compositedBounds = bounds; 2079 m_compositedBounds = bounds;
1958 } 2080 }
1959 2081
2082 void CompositedLayerMapping::addRenderLayerToSquashingGraphicsLayer(RenderLayer* layer, IntSize offsetFromTargetBacking, size_t nextSquashedLayerIndex)
2083 {
2084 ASSERT(compositor()->isLayerSquashingEnabled());
2085
2086 GraphicsLayerPaintInfo paintInfo;
2087 paintInfo.renderLayer = layer;
2088 // NOTE: composited bounds are updated elsewhere
2089 // NOTE: offsetFromRenderer is updated elsewhere
2090 paintInfo.offsetFromBackingRoot = offsetFromTargetBacking;
2091 paintInfo.paintingPhase = GraphicsLayerPaintAllWithOverflowClip;
2092 paintInfo.isBackgroundLayer = false;
2093
2094 // Change tracking on squashing layers: at the first sign of something chang ed, just invalidate the layer.
2095 // FIXME: Perhaps we can find a tighter more clever mechanism later.
Ian Vollick 2013/12/02 21:17:05 Makes sense, but for now, this seems ok to me, too
2096 if (nextSquashedLayerIndex < m_squashedLayers.size()) {
2097 if (m_squashedLayers[nextSquashedLayerIndex].renderLayer != layer) {
2098 m_squashedLayers[nextSquashedLayerIndex] = paintInfo;
2099 m_squashingLayer->setNeedsDisplay();
trchen 2013/12/02 22:56:55 Why null checking is needed below but not here?
shawnsingh 2013/12/05 17:55:24 Thanks for catching this - null check is needed in
2100 }
2101 } else {
2102 m_squashedLayers.append(paintInfo);
2103 if (m_squashingLayer)
2104 m_squashingLayer->setNeedsDisplay();
2105 }
2106 layer->setGroupedMapping(this);
2107 }
2108
2109 void CompositedLayerMapping::finishAccumulatingSquashingLayers(size_t nextSquash edLayerIndex)
2110 {
2111 ASSERT(compositor()->isLayerSquashingEnabled());
2112
2113 // Any additional squashed RenderLayers in the array no longer exist, and re moving invalidates the squashingLayer contents.
2114 if (nextSquashedLayerIndex < m_squashedLayers.size()) {
2115 m_squashedLayers.remove(nextSquashedLayerIndex, m_squashedLayers.size() - nextSquashedLayerIndex);
2116 if (m_squashingLayer)
2117 m_squashingLayer->setNeedsDisplay();
2118 }
2119 }
2120
1960 CompositingLayerType CompositedLayerMapping::compositingLayerType() const 2121 CompositingLayerType CompositedLayerMapping::compositingLayerType() const
1961 { 2122 {
1962 if (m_graphicsLayer->hasContentsLayer()) 2123 if (m_graphicsLayer->hasContentsLayer())
1963 return MediaCompositingLayer; 2124 return MediaCompositingLayer;
1964 2125
1965 if (m_graphicsLayer->drawsContent()) 2126 if (m_graphicsLayer->drawsContent())
1966 return NormalCompositingLayer; 2127 return NormalCompositingLayer;
1967 2128
1968 return ContainerCompositingLayer; 2129 return ContainerCompositingLayer;
1969 } 2130 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2187 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2027 name = "Scrolling Contents Layer"; 2188 name = "Scrolling Contents Layer";
2028 } else { 2189 } else {
2029 ASSERT_NOT_REACHED(); 2190 ASSERT_NOT_REACHED();
2030 } 2191 }
2031 2192
2032 return name; 2193 return name;
2033 } 2194 }
2034 2195
2035 } // namespace WebCore 2196 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698