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

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 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 // Do not leave the destroyed pointer dangling on any RenderLayers that pain ted to this mapping's squashing layer.
179 for (size_t i = 0; i < m_squashedLayers.size(); ++i) {
180 if (m_squashedLayers[i].renderLayer->groupedMapping() == this)
181 m_squashedLayers[i].renderLayer->setGroupedMapping(0);
182 }
183
178 updateClippingLayers(false, false); 184 updateClippingLayers(false, false);
179 updateOverflowControlsLayers(false, false, false); 185 updateOverflowControlsLayers(false, false, false);
180 updateForegroundLayer(false); 186 updateForegroundLayer(false);
181 updateBackgroundLayer(false); 187 updateBackgroundLayer(false);
182 updateMaskLayer(false); 188 updateMaskLayer(false);
183 updateClippingMaskLayers(false); 189 updateClippingMaskLayers(false);
184 updateScrollingLayers(false); 190 updateScrollingLayers(false);
191 updateSquashingLayers(false);
185 destroyGraphicsLayers(); 192 destroyGraphicsLayers();
186 } 193 }
187 194
188 PassOwnPtr<GraphicsLayer> CompositedLayerMapping::createGraphicsLayer(Compositin gReasons reasons) 195 PassOwnPtr<GraphicsLayer> CompositedLayerMapping::createGraphicsLayer(Compositin gReasons reasons)
189 { 196 {
190 GraphicsLayerFactory* graphicsLayerFactory = 0; 197 GraphicsLayerFactory* graphicsLayerFactory = 0;
191 if (Page* page = renderer()->frame()->page()) 198 if (Page* page = renderer()->frame()->page())
192 graphicsLayerFactory = page->chrome().client().graphicsLayerFactory(); 199 graphicsLayerFactory = page->chrome().client().graphicsLayerFactory();
193 200
194 OwnPtr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFac tory, this); 201 OwnPtr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFac tory, this);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 470
464 if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), require sVerticalScrollbarLayer(), requiresScrollCornerLayer())) 471 if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), require sVerticalScrollbarLayer(), requiresScrollCornerLayer()))
465 layerConfigChanged = true; 472 layerConfigChanged = true;
466 473
467 if (updateScrollingLayers(m_owningLayer->needsCompositedScrolling())) 474 if (updateScrollingLayers(m_owningLayer->needsCompositedScrolling()))
468 layerConfigChanged = true; 475 layerConfigChanged = true;
469 476
470 updateScrollParent(scrollParent); 477 updateScrollParent(scrollParent);
471 updateClipParent(m_owningLayer->clipParent()); 478 updateClipParent(m_owningLayer->clipParent());
472 479
480 if (updateSquashingLayers(!m_squashedLayers.isEmpty()))
481 layerConfigChanged = true;
482
473 if (layerConfigChanged) 483 if (layerConfigChanged)
474 updateInternalHierarchy(); 484 updateInternalHierarchy();
475 485
476 if (updateMaskLayer(renderer->hasMask())) 486 if (updateMaskLayer(renderer->hasMask()))
477 m_graphicsLayer->setMaskLayer(m_maskLayer.get()); 487 m_graphicsLayer->setMaskLayer(m_maskLayer.get());
478 488
479 bool hasChildClippingLayer = compositor->clipsCompositingDescendants(m_ownin gLayer) && (hasClippingLayer() || hasScrollingLayer()); 489 bool hasChildClippingLayer = compositor->clipsCompositingDescendants(m_ownin gLayer) && (hasClippingLayer() || hasScrollingLayer());
480 bool needsChildClippingMask = (renderer->style()->clipPath() || renderer->st yle()->hasBorderRadius()) && (hasChildClippingLayer || isAcceleratedContents(ren derer)); 490 bool needsChildClippingMask = (renderer->style()->clipPath() || renderer->st yle()->hasBorderRadius()) && (hasChildClippingLayer || isAcceleratedContents(ren derer));
481 if (updateClippingMaskLayers(needsChildClippingMask)) { 491 if (updateClippingMaskLayers(needsChildClippingMask)) {
482 if (hasClippingLayer()) 492 if (hasClippingLayer())
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, GraphicsLayer::DontSetNeedsDisplay); 793 m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, GraphicsLayer::DontSetNeedsDisplay);
784 794
785 if (m_foregroundLayer) { 795 if (m_foregroundLayer) {
786 if (m_foregroundLayer->size() != m_scrollingContentsLayer->size()) 796 if (m_foregroundLayer->size() != m_scrollingContentsLayer->size())
787 m_foregroundLayer->setSize(m_scrollingContentsLayer->size()); 797 m_foregroundLayer->setSize(m_scrollingContentsLayer->size());
788 m_foregroundLayer->setNeedsDisplay(); 798 m_foregroundLayer->setNeedsDisplay();
789 m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->o ffsetFromRenderer()); 799 m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->o ffsetFromRenderer());
790 } 800 }
791 } 801 }
792 802
803 if (m_squashingLayer) {
804 ASSERT(compositor()->isLayerSquashingEnabled());
805
806 IntRect totalSquashBounds;
807 for (size_t i = 0; i < m_squashedLayers.size(); ++i) {
808 IntRect squashedBounds = compositor()->calculateCompositedBounds(m_s quashedLayers[i].renderLayer, m_squashedLayers[i].renderLayer);
809
810 // Store the composited bounds before applying the offset.
811 // FIXME: consider whether it is more efficient or clarifies the mat h to store the compositedBounds after applying the offset.
812 m_squashedLayers[i].compositedBounds = squashedBounds;
813
814 squashedBounds.move(m_squashedLayers[i].offsetFromBackingRoot);
815 totalSquashBounds.unite(squashedBounds);
816 }
817
818 IntPoint squashLayerPosition;
819 // FIXME: this logic needs to update depending on what "containment" lay ers are added to CompositedLayerMapping due to other changes
820 if (m_ancestorClippingLayer) {
821 squashLayerPosition = IntPoint(m_ancestorClippingLayer->position().x () + totalSquashBounds.location().x(),
822 m_ancestorClippingLayer->position().y() + totalSquashBounds.loca tion().y());
823 } else {
824 squashLayerPosition = IntPoint(m_graphicsLayer->position().x() + tot alSquashBounds.location().x(),
825 m_graphicsLayer->position().y() + totalSquashBounds.location().y ());
826 }
827
828 m_squashingLayer->setPosition(squashLayerPosition);
829 m_squashingLayer->setSize(totalSquashBounds.size());
830
831 // Now that the position of the squashing layer is known, update the off sets for each squashed RenderLayer.
832 for (size_t i = 0; i < m_squashedLayers.size(); ++i) {
833 m_squashedLayers[i].offsetFromRenderer = IntSize(-m_squashedLayers[i ].offsetFromBackingRoot.width() - m_graphicsLayer->position().x() + m_squashingL ayer->position().x(),
834 -m_squashedLayers[i].offsetFromBackingRoot.height() - m_graphics Layer->position().y() + m_squashingLayer->position().y());
835
836 // FIXME: find a better design to avoid this redundant value - most likely it will make
837 // sense to move the paint task info into RenderLayer's m_compositin gProperties.
838 m_squashedLayers[i].renderLayer->setOffsetFromSquashingLayerOrigin(m _squashedLayers[i].offsetFromRenderer);
839 }
840 }
841
793 if (m_owningLayer->scrollableArea()) 842 if (m_owningLayer->scrollableArea())
794 m_owningLayer->scrollableArea()->positionOverflowControls(); 843 m_owningLayer->scrollableArea()->positionOverflowControls();
795 844
796 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit edLayerMapping 845 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit edLayerMapping
797 // since it depends on whether compAncestor draws content, which gets update d later. 846 // since it depends on whether compAncestor draws content, which gets update d later.
798 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); 847 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor);
799 848
800 if (RuntimeEnabledFeatures::cssCompositingEnabled()) { 849 if (RuntimeEnabledFeatures::cssCompositingEnabled()) {
801 updateLayerBlendMode(style); 850 updateLayerBlendMode(style);
802 updateIsRootForIsolatedGroup(); 851 updateIsRootForIsolatedGroup();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get()); 910 m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get());
862 } 911 }
863 if (m_layerForVerticalScrollbar) { 912 if (m_layerForVerticalScrollbar) {
864 m_layerForVerticalScrollbar->removeFromParent(); 913 m_layerForVerticalScrollbar->removeFromParent();
865 m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get()); 914 m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get());
866 } 915 }
867 if (m_layerForScrollCorner) { 916 if (m_layerForScrollCorner) {
868 m_layerForScrollCorner->removeFromParent(); 917 m_layerForScrollCorner->removeFromParent();
869 m_graphicsLayer->addChild(m_layerForScrollCorner.get()); 918 m_graphicsLayer->addChild(m_layerForScrollCorner.get());
870 } 919 }
920
921 // The squashing containment layer, if it exists, becomes a no-op parent.
922 if (m_squashingLayer) {
923 ASSERT(compositor()->isLayerSquashingEnabled());
924 ASSERT(m_squashingContainmentLayer);
925
926 m_squashingContainmentLayer->removeAllChildren();
927
928 if (m_ancestorClippingLayer)
929 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get()) ;
930 else
931 m_squashingContainmentLayer->addChild(m_graphicsLayer.get());
932
933 m_squashingContainmentLayer->addChild(m_squashingLayer.get());
934 }
871 } 935 }
872 936
873 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer) 937 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer)
874 { 938 {
875 IntRect contentsRect; 939 IntRect contentsRect;
876 if (isSimpleContainer && renderer()->hasBackground()) 940 if (isSimpleContainer && renderer()->hasBackground())
877 contentsRect = backgroundBox(); 941 contentsRect = backgroundBox();
878 else 942 else
879 contentsRect = contentsBox(); 943 contentsRect = contentsBox();
880 944
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 m_graphicsLayer->setNeedsDisplay(); 1251 m_graphicsLayer->setNeedsDisplay();
1188 if (renderer()->view()) 1252 if (renderer()->view())
1189 compositor()->scrollingLayerDidChange(m_owningLayer); 1253 compositor()->scrollingLayerDidChange(m_owningLayer);
1190 } 1254 }
1191 1255
1192 return layerChanged; 1256 return layerChanged;
1193 } 1257 }
1194 1258
1195 void CompositedLayerMapping::updateScrollParent(RenderLayer* scrollParent) 1259 void CompositedLayerMapping::updateScrollParent(RenderLayer* scrollParent)
1196 { 1260 {
1261
1197 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) { 1262 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) {
1198 if (m_ancestorClippingLayer) { 1263 // FIXME: not 100% certain if this scrollParent code adjustment for squa shing is correct?.
Ian Vollick 2013/12/06 21:11:30 Looks correct, but would you mind doing a minor cl
Ian Vollick 2013/12/07 02:44:42 On second thought, I'm pretty confident this is co
shawnsingh 2013/12/11 18:50:34 Your cleanup landed anyway, and the latest patch i
1264 if (m_squashingContainmentLayer) {
1265 ASSERT(childForSuperlayers() == m_squashingContainmentLayer.get());
1266 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_squashing ContainmentLayer.get(), scrollParent);
1267 if (m_ancestorClippingLayer)
1268 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_ances torClippingLayer.get(), 0);
1269 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), 0);
1270 } else if (m_ancestorClippingLayer) {
1199 ASSERT(childForSuperlayers() == m_ancestorClippingLayer.get()); 1271 ASSERT(childForSuperlayers() == m_ancestorClippingLayer.get());
1200 // If we have an ancestor clipping layer, it is the scroll child. Th e other layer that may have 1272 // If we have an ancestor clipping layer, it is the scroll child. Th e other layer that may have
1201 // been the scroll child is the graphics layer. We will ensure that we clear its association 1273 // been the scroll child is the graphics layer. We will ensure that we clear its association
1202 // with a scroll parent if it had one. 1274 // with a scroll parent if it had one.
1203 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_ancestorC lippingLayer.get(), scrollParent); 1275 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_ancestorC lippingLayer.get(), scrollParent);
1204 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), 0); 1276 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), 0);
1205 } else { 1277 } else {
1206 ASSERT(childForSuperlayers() == m_graphicsLayer.get()); 1278 ASSERT(childForSuperlayers() == m_graphicsLayer.get());
1207 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), scrollParent); 1279 scrollingCoordinator->updateScrollParentForGraphicsLayer(m_graphicsL ayer.get(), scrollParent);
1208 } 1280 }
1209 } 1281 }
1210 } 1282 }
1211 1283
1212 void CompositedLayerMapping::updateClipParent(RenderLayer* clipParent) 1284 void CompositedLayerMapping::updateClipParent(RenderLayer* clipParent)
1213 { 1285 {
1214 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) 1286 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer))
1215 scrollingCoordinator->updateClipParentForGraphicsLayer(m_graphicsLayer.g et(), clipParent); 1287 scrollingCoordinator->updateClipParentForGraphicsLayer(m_graphicsLayer.g et(), clipParent);
1216 } 1288 }
1217 1289
1290 bool CompositedLayerMapping::updateSquashingLayers(bool needsSquashingLayers)
1291 {
1292 bool layersChanged = false;
1293
1294 if (needsSquashingLayers) {
1295 ASSERT(compositor()->isLayerSquashingEnabled());
1296
1297 if (!m_squashingLayer) {
1298 ASSERT(!m_squashingContainmentLayer);
1299
1300 m_squashingLayer = createGraphicsLayer(CompositingReasonOverlap);
1301 m_squashingLayer->setDrawsContent(true);
1302 m_squashingLayer->setNeedsDisplay();
1303 layersChanged = true;
1304
1305 // FIXME: containment layer needs a new CompositingReason, Compositi ngReasonOverlap is not appropriate.
1306 m_squashingContainmentLayer = createGraphicsLayer(CompositingReasonO verlap);
1307 // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959
1308 bool preserves3D = renderer()->style()->transformStyle3D() == Transf ormStyle3DPreserve3D && !renderer()->hasReflection();
1309 m_squashingContainmentLayer->setPreserves3D(preserves3D);
1310 layersChanged = true;
1311 }
1312
1313 ASSERT(m_squashingLayer && m_squashingContainmentLayer);
1314 } else {
1315 if (m_squashingLayer) {
1316 m_squashingLayer->removeFromParent();
1317 m_squashingLayer = nullptr;
1318 layersChanged = true;
1319 // FIXME: do we need to invalidate something here?
1320
1321 ASSERT(m_squashingContainmentLayer);
1322 m_squashingContainmentLayer->removeFromParent();
1323 m_squashingContainmentLayer = nullptr;
1324 layersChanged = true;
1325 }
1326
1327 ASSERT(!m_squashingLayer && !m_squashingContainmentLayer);
1328 }
1329
1330 return layersChanged;
1331 }
1332
1218 GraphicsLayerPaintingPhase CompositedLayerMapping::paintingPhaseForPrimaryLayer( ) const 1333 GraphicsLayerPaintingPhase CompositedLayerMapping::paintingPhaseForPrimaryLayer( ) const
1219 { 1334 {
1220 unsigned phase = 0; 1335 unsigned phase = 0;
1221 if (!m_backgroundLayer) 1336 if (!m_backgroundLayer)
1222 phase |= GraphicsLayerPaintBackground; 1337 phase |= GraphicsLayerPaintBackground;
1223 if (!m_foregroundLayer) 1338 if (!m_foregroundLayer)
1224 phase |= GraphicsLayerPaintForeground; 1339 phase |= GraphicsLayerPaintForeground;
1225 if (!m_maskLayer) 1340 if (!m_maskLayer)
1226 phase |= GraphicsLayerPaintMask; 1341 phase |= GraphicsLayerPaintMask;
1227 1342
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const 1664 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const
1550 { 1665 {
1551 if (m_scrollingContentsLayer) 1666 if (m_scrollingContentsLayer)
1552 return m_scrollingContentsLayer.get(); 1667 return m_scrollingContentsLayer.get();
1553 1668
1554 return m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsL ayer.get(); 1669 return m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsL ayer.get();
1555 } 1670 }
1556 1671
1557 GraphicsLayer* CompositedLayerMapping::childForSuperlayers() const 1672 GraphicsLayer* CompositedLayerMapping::childForSuperlayers() const
1558 { 1673 {
1674 if (m_squashingContainmentLayer)
1675 return m_squashingContainmentLayer.get();
1676
1559 if (m_ancestorClippingLayer) 1677 if (m_ancestorClippingLayer)
1560 return m_ancestorClippingLayer.get(); 1678 return m_ancestorClippingLayer.get();
1561 1679
1562 return m_graphicsLayer.get(); 1680 return m_graphicsLayer.get();
1563 } 1681 }
1564 1682
1565 bool CompositedLayerMapping::updateRequiresOwnBackingStoreForAncestorReasons(con st RenderLayer* compositingAncestorLayer) 1683 bool CompositedLayerMapping::updateRequiresOwnBackingStoreForAncestorReasons(con st RenderLayer* compositingAncestorLayer)
1566 { 1684 {
1567 bool previousRequiresOwnBackingStoreForAncestorReasons = m_requiresOwnBackin gStoreForAncestorReasons; 1685 bool previousRequiresOwnBackingStoreForAncestorReasons = m_requiresOwnBackin gStoreForAncestorReasons;
1568 bool previousPaintsIntoCompositedAncestor = paintsIntoCompositedAncestor(); 1686 bool previousPaintsIntoCompositedAncestor = paintsIntoCompositedAncestor();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 1841
1724 // The dirtyRect is in the coords of the painting root. 1842 // The dirtyRect is in the coords of the painting root.
1725 IntRect dirtyRect = pixelSnappedIntRect(relativeClip); 1843 IntRect dirtyRect = pixelSnappedIntRect(relativeClip);
1726 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) 1844 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents))
1727 dirtyRect.intersect(paintInfo.compositedBounds); 1845 dirtyRect.intersect(paintInfo.compositedBounds);
1728 1846
1729 #ifndef NDEBUG 1847 #ifndef NDEBUG
1730 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut(); 1848 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut();
1731 #endif 1849 #endif
1732 1850
1733 // FIXME: GraphicsLayers need a way to split for RenderRegions. 1851 if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) {
1734 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehavi orNormal, LayoutSize()); 1852 // FIXME: GraphicsLayers need a way to split for RenderRegions.
1735 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFlags) ; 1853 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, LayoutSize());
1854 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags);
1736 1855
1737 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRootBa ckgroundOnly); 1856 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRo otBackgroundOnly);
1738 1857
1739 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) 1858 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars())
1740 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags | PaintLayerPaintingOverlayScrollbars); 1859 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, pai ntFlags | PaintLayerPaintingOverlayScrollbars);
1860 } else {
1861 ASSERT(compositor()->isLayerSquashingEnabled());
1862 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, LayoutSize());
1863 paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags);
1864 }
1741 1865
1742 ASSERT(!paintInfo.renderLayer->m_usedTransparency); 1866 ASSERT(!paintInfo.renderLayer->m_usedTransparency);
1743 1867
1744 // Manually restore the context to its original state by applying the opposi te translation. 1868 // Manually restore the context to its original state by applying the opposi te translation.
1745 context->translate(offset); 1869 context->translate(offset);
1746 } 1870 }
1747 1871
1748 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip) 1872 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip)
1749 { 1873 {
1750 if (!scrollbar) 1874 if (!scrollbar)
(...skipping 26 matching lines...) Expand all
1777 1901
1778 GraphicsLayerPaintInfo paintInfo; 1902 GraphicsLayerPaintInfo paintInfo;
1779 paintInfo.renderLayer = m_owningLayer; 1903 paintInfo.renderLayer = m_owningLayer;
1780 paintInfo.compositedBounds = compositedBounds(); 1904 paintInfo.compositedBounds = compositedBounds();
1781 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); 1905 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer();
1782 paintInfo.paintingPhase = paintingPhase; 1906 paintInfo.paintingPhase = paintingPhase;
1783 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); 1907 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer);
1784 1908
1785 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 1909 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
1786 doPaintTask(paintInfo, &context, clip); 1910 doPaintTask(paintInfo, &context, clip);
1911 } else if (graphicsLayer == m_squashingLayer.get()) {
1912 ASSERT(compositor()->isLayerSquashingEnabled());
1913 for (size_t i = 0; i < m_squashedLayers.size(); ++i)
1914 doPaintTask(m_squashedLayers[i], &context, clip);
1787 } else if (graphicsLayer == layerForHorizontalScrollbar()) { 1915 } else if (graphicsLayer == layerForHorizontalScrollbar()) {
1788 paintScrollbar(m_owningLayer->scrollableArea()->horizontalScrollbar(), c ontext, clip); 1916 paintScrollbar(m_owningLayer->scrollableArea()->horizontalScrollbar(), c ontext, clip);
1789 } else if (graphicsLayer == layerForVerticalScrollbar()) { 1917 } else if (graphicsLayer == layerForVerticalScrollbar()) {
1790 paintScrollbar(m_owningLayer->scrollableArea()->verticalScrollbar(), con text, clip); 1918 paintScrollbar(m_owningLayer->scrollableArea()->verticalScrollbar(), con text, clip);
1791 } else if (graphicsLayer == layerForScrollCorner()) { 1919 } else if (graphicsLayer == layerForScrollCorner()) {
1792 const IntRect& scrollCornerAndResizer = m_owningLayer->scrollableArea()- >scrollCornerAndResizerRect(); 1920 const IntRect& scrollCornerAndResizer = m_owningLayer->scrollableArea()- >scrollCornerAndResizerRect();
1793 context.save(); 1921 context.save();
1794 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y ()); 1922 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y ());
1795 IntRect transformedClip = clip; 1923 IntRect transformedClip = clip;
1796 transformedClip.moveBy(scrollCornerAndResizer.location()); 1924 transformedClip.moveBy(scrollCornerAndResizer.location());
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 IntRect CompositedLayerMapping::compositedBounds() const 2100 IntRect CompositedLayerMapping::compositedBounds() const
1973 { 2101 {
1974 return m_compositedBounds; 2102 return m_compositedBounds;
1975 } 2103 }
1976 2104
1977 void CompositedLayerMapping::setCompositedBounds(const IntRect& bounds) 2105 void CompositedLayerMapping::setCompositedBounds(const IntRect& bounds)
1978 { 2106 {
1979 m_compositedBounds = bounds; 2107 m_compositedBounds = bounds;
1980 } 2108 }
1981 2109
2110 void CompositedLayerMapping::addRenderLayerToSquashingGraphicsLayer(RenderLayer* layer, IntSize offsetFromTargetBacking, size_t nextSquashedLayerIndex)
2111 {
2112 ASSERT(compositor()->isLayerSquashingEnabled());
2113
2114 GraphicsLayerPaintInfo paintInfo;
2115 paintInfo.renderLayer = layer;
2116 // NOTE: composited bounds are updated elsewhere
2117 // NOTE: offsetFromRenderer is updated elsewhere
2118 paintInfo.offsetFromBackingRoot = offsetFromTargetBacking;
2119 paintInfo.paintingPhase = GraphicsLayerPaintAllWithOverflowClip;
2120 paintInfo.isBackgroundLayer = false;
2121
2122 // Change tracking on squashing layers: at the first sign of something chang ed, just invalidate the layer.
2123 // FIXME: Perhaps we can find a tighter more clever mechanism later.
2124 if (nextSquashedLayerIndex < m_squashedLayers.size()) {
2125 if (m_squashedLayers[nextSquashedLayerIndex].renderLayer != layer) {
2126 m_squashedLayers[nextSquashedLayerIndex] = paintInfo;
2127 if (m_squashingLayer)
2128 m_squashingLayer->setNeedsDisplay();
2129 }
2130 } else {
2131 m_squashedLayers.append(paintInfo);
2132 if (m_squashingLayer)
2133 m_squashingLayer->setNeedsDisplay();
2134 }
2135 layer->setGroupedMapping(this);
2136 }
2137
2138 void CompositedLayerMapping::finishAccumulatingSquashingLayers(size_t nextSquash edLayerIndex)
2139 {
2140 ASSERT(compositor()->isLayerSquashingEnabled());
2141
2142 // Any additional squashed RenderLayers in the array no longer exist, and re moving invalidates the squashingLayer contents.
2143 if (nextSquashedLayerIndex < m_squashedLayers.size()) {
2144 m_squashedLayers.remove(nextSquashedLayerIndex, m_squashedLayers.size() - nextSquashedLayerIndex);
2145 if (m_squashingLayer)
2146 m_squashingLayer->setNeedsDisplay();
2147 }
2148 }
2149
1982 CompositingLayerType CompositedLayerMapping::compositingLayerType() const 2150 CompositingLayerType CompositedLayerMapping::compositingLayerType() const
1983 { 2151 {
1984 if (m_graphicsLayer->hasContentsLayer()) 2152 if (m_graphicsLayer->hasContentsLayer())
1985 return MediaCompositingLayer; 2153 return MediaCompositingLayer;
1986 2154
1987 if (m_graphicsLayer->drawsContent()) 2155 if (m_graphicsLayer->drawsContent())
1988 return NormalCompositingLayer; 2156 return NormalCompositingLayer;
1989 2157
1990 return ContainerCompositingLayer; 2158 return ContainerCompositingLayer;
1991 } 2159 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2216 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2049 name = "Scrolling Contents Layer"; 2217 name = "Scrolling Contents Layer";
2050 } else { 2218 } else {
2051 ASSERT_NOT_REACHED(); 2219 ASSERT_NOT_REACHED();
2052 } 2220 }
2053 2221
2054 return name; 2222 return name;
2055 } 2223 }
2056 2224
2057 } // namespace WebCore 2225 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698