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

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: removed bogus asserts 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 17 matching lines...) Expand all
820 return; 869 return;
821 870
822 compositor()->updateViewportConstraintStatus(m_owningLayer); 871 compositor()->updateViewportConstraintStatus(m_owningLayer);
823 872
824 scrollingCoordinator->updateLayerPositionConstraint(m_owningLayer); 873 scrollingCoordinator->updateLayerPositionConstraint(m_owningLayer);
825 874
826 // Page scale is applied as a transform on the root render view layer. Becau se the scroll 875 // Page scale is applied as a transform on the root render view layer. Becau se the scroll
827 // layer is further up in the hierarchy, we need to avoid marking the root r ender view 876 // layer is further up in the hierarchy, we need to avoid marking the root r ender view
828 // layer as a container. 877 // layer as a container.
829 bool isContainer = m_owningLayer->hasTransform() && !m_owningLayer->isRootLa yer(); 878 bool isContainer = m_owningLayer->hasTransform() && !m_owningLayer->isRootLa yer();
879 // FIXME: we should make certain that childForSuperLayers will never be the m_squashingContainmentLayer here
830 scrollingCoordinator->setLayerIsContainerForFixedPositionLayers(childForSupe rlayers(), isContainer); 880 scrollingCoordinator->setLayerIsContainerForFixedPositionLayers(childForSupe rlayers(), isContainer);
831 } 881 }
832 882
833 void CompositedLayerMapping::updateInternalHierarchy() 883 void CompositedLayerMapping::updateInternalHierarchy()
834 { 884 {
835 // m_foregroundLayer has to be inserted in the correct order with child laye rs, 885 // m_foregroundLayer has to be inserted in the correct order with child laye rs,
836 // so it's not inserted here. 886 // so it's not inserted here.
837 if (m_ancestorClippingLayer) 887 if (m_ancestorClippingLayer)
838 m_ancestorClippingLayer->removeAllChildren(); 888 m_ancestorClippingLayer->removeAllChildren();
839 889
(...skipping 21 matching lines...) Expand all
861 m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get()); 911 m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get());
862 } 912 }
863 if (m_layerForVerticalScrollbar) { 913 if (m_layerForVerticalScrollbar) {
864 m_layerForVerticalScrollbar->removeFromParent(); 914 m_layerForVerticalScrollbar->removeFromParent();
865 m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get()); 915 m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get());
866 } 916 }
867 if (m_layerForScrollCorner) { 917 if (m_layerForScrollCorner) {
868 m_layerForScrollCorner->removeFromParent(); 918 m_layerForScrollCorner->removeFromParent();
869 m_graphicsLayer->addChild(m_layerForScrollCorner.get()); 919 m_graphicsLayer->addChild(m_layerForScrollCorner.get());
870 } 920 }
921
922 // The squashing containment layer, if it exists, becomes a no-op parent.
923 if (m_squashingLayer) {
924 ASSERT(compositor()->isLayerSquashingEnabled());
925 ASSERT(m_squashingContainmentLayer);
926
927 m_squashingContainmentLayer->removeAllChildren();
928
929 if (m_ancestorClippingLayer)
930 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get()) ;
931 else
932 m_squashingContainmentLayer->addChild(m_graphicsLayer.get());
933
934 m_squashingContainmentLayer->addChild(m_squashingLayer.get());
935 }
871 } 936 }
872 937
873 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer) 938 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer)
874 { 939 {
875 IntRect contentsRect; 940 IntRect contentsRect;
876 if (isSimpleContainer && renderer()->hasBackground()) 941 if (isSimpleContainer && renderer()->hasBackground())
877 contentsRect = backgroundBox(); 942 contentsRect = backgroundBox();
878 else 943 else
879 contentsRect = contentsBox(); 944 contentsRect = contentsBox();
880 945
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 1264
1200 // Only the topmost layer has a scroll parent. All other layers have a null scroll parent. 1265 // Only the topmost layer has a scroll parent. All other layers have a null scroll parent.
1201 if (layer != topmostLayer) 1266 if (layer != topmostLayer)
1202 scrollParent = 0; 1267 scrollParent = 0;
1203 1268
1204 scrollingCoordinator->updateScrollParentForGraphicsLayer(layer, scrollParent ); 1269 scrollingCoordinator->updateScrollParentForGraphicsLayer(layer, scrollParent );
1205 } 1270 }
1206 1271
1207 void CompositedLayerMapping::updateScrollParent(RenderLayer* scrollParent) 1272 void CompositedLayerMapping::updateScrollParent(RenderLayer* scrollParent)
1208 { 1273 {
1274
1209 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) { 1275 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) {
1210 GraphicsLayer* topmostLayer = childForSuperlayers(); 1276 GraphicsLayer* topmostLayer = childForSuperlayers();
1277 updateScrollParentForGraphicsLayer(m_squashingContainmentLayer.get(), to pmostLayer, scrollParent, scrollingCoordinator);
1211 updateScrollParentForGraphicsLayer(m_ancestorClippingLayer.get(), topmos tLayer, scrollParent, scrollingCoordinator); 1278 updateScrollParentForGraphicsLayer(m_ancestorClippingLayer.get(), topmos tLayer, scrollParent, scrollingCoordinator);
1212 updateScrollParentForGraphicsLayer(m_graphicsLayer.get(), topmostLayer, scrollParent, scrollingCoordinator); 1279 updateScrollParentForGraphicsLayer(m_graphicsLayer.get(), topmostLayer, scrollParent, scrollingCoordinator);
1213 } 1280 }
1214 } 1281 }
1215 1282
1216 void CompositedLayerMapping::updateClipParent(RenderLayer* clipParent) 1283 void CompositedLayerMapping::updateClipParent(RenderLayer* clipParent)
1217 { 1284 {
1218 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer)) 1285 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay er(m_owningLayer))
1219 scrollingCoordinator->updateClipParentForGraphicsLayer(m_graphicsLayer.g et(), clipParent); 1286 scrollingCoordinator->updateClipParentForGraphicsLayer(m_graphicsLayer.g et(), clipParent);
1220 } 1287 }
1221 1288
1289 bool CompositedLayerMapping::updateSquashingLayers(bool needsSquashingLayers)
1290 {
1291 bool layersChanged = false;
1292
1293 if (needsSquashingLayers) {
1294 ASSERT(compositor()->isLayerSquashingEnabled());
1295
1296 if (!m_squashingLayer) {
1297 ASSERT(!m_squashingContainmentLayer);
1298
1299 m_squashingLayer = createGraphicsLayer(CompositingReasonOverlap);
1300 m_squashingLayer->setDrawsContent(true);
1301 m_squashingLayer->setNeedsDisplay();
1302 layersChanged = true;
1303
1304 // FIXME: containment layer needs a new CompositingReason, Compositi ngReasonOverlap is not appropriate.
1305 m_squashingContainmentLayer = createGraphicsLayer(CompositingReasonO verlap);
1306 // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959
1307 bool preserves3D = renderer()->style()->transformStyle3D() == Transf ormStyle3DPreserve3D && !renderer()->hasReflection();
1308 m_squashingContainmentLayer->setPreserves3D(preserves3D);
1309 layersChanged = true;
1310 }
1311
1312 ASSERT(m_squashingLayer && m_squashingContainmentLayer);
1313 } else {
1314 if (m_squashingLayer) {
1315 m_squashingLayer->removeFromParent();
1316 m_squashingLayer = nullptr;
1317 layersChanged = true;
1318 // FIXME: do we need to invalidate something here?
1319
1320 ASSERT(m_squashingContainmentLayer);
1321 m_squashingContainmentLayer->removeFromParent();
1322 m_squashingContainmentLayer = nullptr;
1323 layersChanged = true;
1324 }
1325
1326 ASSERT(!m_squashingLayer && !m_squashingContainmentLayer);
1327 }
1328
1329 return layersChanged;
1330 }
1331
1222 GraphicsLayerPaintingPhase CompositedLayerMapping::paintingPhaseForPrimaryLayer( ) const 1332 GraphicsLayerPaintingPhase CompositedLayerMapping::paintingPhaseForPrimaryLayer( ) const
1223 { 1333 {
1224 unsigned phase = 0; 1334 unsigned phase = 0;
1225 if (!m_backgroundLayer) 1335 if (!m_backgroundLayer)
1226 phase |= GraphicsLayerPaintBackground; 1336 phase |= GraphicsLayerPaintBackground;
1227 if (!m_foregroundLayer) 1337 if (!m_foregroundLayer)
1228 phase |= GraphicsLayerPaintForeground; 1338 phase |= GraphicsLayerPaintForeground;
1229 if (!m_maskLayer) 1339 if (!m_maskLayer)
1230 phase |= GraphicsLayerPaintMask; 1340 phase |= GraphicsLayerPaintMask;
1231 1341
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const 1663 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const
1554 { 1664 {
1555 if (m_scrollingContentsLayer) 1665 if (m_scrollingContentsLayer)
1556 return m_scrollingContentsLayer.get(); 1666 return m_scrollingContentsLayer.get();
1557 1667
1558 return m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsL ayer.get(); 1668 return m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsL ayer.get();
1559 } 1669 }
1560 1670
1561 GraphicsLayer* CompositedLayerMapping::childForSuperlayers() const 1671 GraphicsLayer* CompositedLayerMapping::childForSuperlayers() const
1562 { 1672 {
1673 if (m_squashingContainmentLayer)
1674 return m_squashingContainmentLayer.get();
1675
1563 if (m_ancestorClippingLayer) 1676 if (m_ancestorClippingLayer)
1564 return m_ancestorClippingLayer.get(); 1677 return m_ancestorClippingLayer.get();
1565 1678
1566 return m_graphicsLayer.get(); 1679 return m_graphicsLayer.get();
1567 } 1680 }
1568 1681
1569 bool CompositedLayerMapping::updateRequiresOwnBackingStoreForAncestorReasons(con st RenderLayer* compositingAncestorLayer) 1682 bool CompositedLayerMapping::updateRequiresOwnBackingStoreForAncestorReasons(con st RenderLayer* compositingAncestorLayer)
1570 { 1683 {
1571 bool previousRequiresOwnBackingStoreForAncestorReasons = m_requiresOwnBackin gStoreForAncestorReasons; 1684 bool previousRequiresOwnBackingStoreForAncestorReasons = m_requiresOwnBackin gStoreForAncestorReasons;
1572 bool previousPaintsIntoCompositedAncestor = paintsIntoCompositedAncestor(); 1685 bool previousPaintsIntoCompositedAncestor = paintsIntoCompositedAncestor();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 // it changes we have to clear clip rects on descendants. 1717 // it changes we have to clear clip rects on descendants.
1605 m_owningLayer->clipper().clearClipRectsIncludingDescendants(PaintingClipRect s); 1718 m_owningLayer->clipper().clearClipRectsIncludingDescendants(PaintingClipRect s);
1606 m_owningLayer->repainter().computeRepaintRectsIncludingDescendants(); 1719 m_owningLayer->repainter().computeRepaintRectsIncludingDescendants();
1607 1720
1608 compositor()->repaintInCompositedAncestor(m_owningLayer, compositedBounds()) ; 1721 compositor()->repaintInCompositedAncestor(m_owningLayer, compositedBounds()) ;
1609 } 1722 }
1610 1723
1611 void CompositedLayerMapping::setBlendMode(blink::WebBlendMode blendMode) 1724 void CompositedLayerMapping::setBlendMode(blink::WebBlendMode blendMode)
1612 { 1725 {
1613 if (m_ancestorClippingLayer) { 1726 if (m_ancestorClippingLayer) {
1614 ASSERT(childForSuperlayers() == m_ancestorClippingLayer.get()); 1727 m_ancestorClippingLayer->setBlendMode(blendMode);
1615 m_graphicsLayer->setBlendMode(blink::WebBlendModeNormal); 1728 m_graphicsLayer->setBlendMode(blink::WebBlendModeNormal);
1616 } else { 1729 } else {
1617 ASSERT(childForSuperlayers() == m_graphicsLayer.get()); 1730 m_graphicsLayer->setBlendMode(blendMode);
1618 } 1731 }
1619 childForSuperlayers()->setBlendMode(blendMode);
1620 } 1732 }
1621 1733
1622 void CompositedLayerMapping::setContentsNeedDisplay() 1734 void CompositedLayerMapping::setContentsNeedDisplay()
1623 { 1735 {
1624 ASSERT(!paintsIntoCompositedAncestor()); 1736 ASSERT(!paintsIntoCompositedAncestor());
1625 1737
1626 if (m_graphicsLayer && m_graphicsLayer->drawsContent()) 1738 if (m_graphicsLayer && m_graphicsLayer->drawsContent())
1627 m_graphicsLayer->setNeedsDisplay(); 1739 m_graphicsLayer->setNeedsDisplay();
1628 1740
1629 if (m_foregroundLayer && m_foregroundLayer->drawsContent()) 1741 if (m_foregroundLayer && m_foregroundLayer->drawsContent())
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 1839
1728 // The dirtyRect is in the coords of the painting root. 1840 // The dirtyRect is in the coords of the painting root.
1729 IntRect dirtyRect = pixelSnappedIntRect(relativeClip); 1841 IntRect dirtyRect = pixelSnappedIntRect(relativeClip);
1730 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) 1842 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents))
1731 dirtyRect.intersect(paintInfo.compositedBounds); 1843 dirtyRect.intersect(paintInfo.compositedBounds);
1732 1844
1733 #ifndef NDEBUG 1845 #ifndef NDEBUG
1734 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut(); 1846 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut();
1735 #endif 1847 #endif
1736 1848
1737 // FIXME: GraphicsLayers need a way to split for RenderRegions. 1849 if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) {
1738 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehavi orNormal, LayoutSize()); 1850 // FIXME: GraphicsLayers need a way to split for RenderRegions.
1739 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFlags) ; 1851 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, LayoutSize());
1852 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags);
1740 1853
1741 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRootBa ckgroundOnly); 1854 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRo otBackgroundOnly);
1742 1855
1743 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) 1856 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars())
1744 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags | PaintLayerPaintingOverlayScrollbars); 1857 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, pai ntFlags | PaintLayerPaintingOverlayScrollbars);
1858 } else {
1859 ASSERT(compositor()->isLayerSquashingEnabled());
1860 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, LayoutSize());
1861 paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags);
1862 }
1745 1863
1746 ASSERT(!paintInfo.renderLayer->m_usedTransparency); 1864 ASSERT(!paintInfo.renderLayer->m_usedTransparency);
1747 1865
1748 // Manually restore the context to its original state by applying the opposi te translation. 1866 // Manually restore the context to its original state by applying the opposi te translation.
1749 context->translate(offset); 1867 context->translate(offset);
1750 } 1868 }
1751 1869
1752 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip) 1870 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip)
1753 { 1871 {
1754 if (!scrollbar) 1872 if (!scrollbar)
(...skipping 26 matching lines...) Expand all
1781 1899
1782 GraphicsLayerPaintInfo paintInfo; 1900 GraphicsLayerPaintInfo paintInfo;
1783 paintInfo.renderLayer = m_owningLayer; 1901 paintInfo.renderLayer = m_owningLayer;
1784 paintInfo.compositedBounds = compositedBounds(); 1902 paintInfo.compositedBounds = compositedBounds();
1785 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); 1903 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer();
1786 paintInfo.paintingPhase = paintingPhase; 1904 paintInfo.paintingPhase = paintingPhase;
1787 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); 1905 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer);
1788 1906
1789 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 1907 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
1790 doPaintTask(paintInfo, &context, clip); 1908 doPaintTask(paintInfo, &context, clip);
1909 } else if (graphicsLayer == m_squashingLayer.get()) {
1910 ASSERT(compositor()->isLayerSquashingEnabled());
1911 for (size_t i = 0; i < m_squashedLayers.size(); ++i)
1912 doPaintTask(m_squashedLayers[i], &context, clip);
1791 } else if (graphicsLayer == layerForHorizontalScrollbar()) { 1913 } else if (graphicsLayer == layerForHorizontalScrollbar()) {
1792 paintScrollbar(m_owningLayer->scrollableArea()->horizontalScrollbar(), c ontext, clip); 1914 paintScrollbar(m_owningLayer->scrollableArea()->horizontalScrollbar(), c ontext, clip);
1793 } else if (graphicsLayer == layerForVerticalScrollbar()) { 1915 } else if (graphicsLayer == layerForVerticalScrollbar()) {
1794 paintScrollbar(m_owningLayer->scrollableArea()->verticalScrollbar(), con text, clip); 1916 paintScrollbar(m_owningLayer->scrollableArea()->verticalScrollbar(), con text, clip);
1795 } else if (graphicsLayer == layerForScrollCorner()) { 1917 } else if (graphicsLayer == layerForScrollCorner()) {
1796 const IntRect& scrollCornerAndResizer = m_owningLayer->scrollableArea()- >scrollCornerAndResizerRect(); 1918 const IntRect& scrollCornerAndResizer = m_owningLayer->scrollableArea()- >scrollCornerAndResizerRect();
1797 context.save(); 1919 context.save();
1798 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y ()); 1920 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y ());
1799 IntRect transformedClip = clip; 1921 IntRect transformedClip = clip;
1800 transformedClip.moveBy(scrollCornerAndResizer.location()); 1922 transformedClip.moveBy(scrollCornerAndResizer.location());
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 IntRect CompositedLayerMapping::compositedBounds() const 2098 IntRect CompositedLayerMapping::compositedBounds() const
1977 { 2099 {
1978 return m_compositedBounds; 2100 return m_compositedBounds;
1979 } 2101 }
1980 2102
1981 void CompositedLayerMapping::setCompositedBounds(const IntRect& bounds) 2103 void CompositedLayerMapping::setCompositedBounds(const IntRect& bounds)
1982 { 2104 {
1983 m_compositedBounds = bounds; 2105 m_compositedBounds = bounds;
1984 } 2106 }
1985 2107
2108 void CompositedLayerMapping::addRenderLayerToSquashingGraphicsLayer(RenderLayer* layer, IntSize offsetFromTargetBacking, size_t nextSquashedLayerIndex)
2109 {
2110 ASSERT(compositor()->isLayerSquashingEnabled());
2111
2112 GraphicsLayerPaintInfo paintInfo;
2113 paintInfo.renderLayer = layer;
2114 // NOTE: composited bounds are updated elsewhere
2115 // NOTE: offsetFromRenderer is updated elsewhere
2116 paintInfo.offsetFromBackingRoot = offsetFromTargetBacking;
2117 paintInfo.paintingPhase = GraphicsLayerPaintAllWithOverflowClip;
2118 paintInfo.isBackgroundLayer = false;
2119
2120 // Change tracking on squashing layers: at the first sign of something chang ed, just invalidate the layer.
2121 // FIXME: Perhaps we can find a tighter more clever mechanism later.
2122 if (nextSquashedLayerIndex < m_squashedLayers.size()) {
2123 if (m_squashedLayers[nextSquashedLayerIndex].renderLayer != layer) {
2124 m_squashedLayers[nextSquashedLayerIndex] = paintInfo;
2125 if (m_squashingLayer)
2126 m_squashingLayer->setNeedsDisplay();
2127 }
2128 } else {
2129 m_squashedLayers.append(paintInfo);
2130 if (m_squashingLayer)
2131 m_squashingLayer->setNeedsDisplay();
2132 }
2133 layer->setGroupedMapping(this);
2134 }
2135
2136 void CompositedLayerMapping::finishAccumulatingSquashingLayers(size_t nextSquash edLayerIndex)
2137 {
2138 ASSERT(compositor()->isLayerSquashingEnabled());
2139
2140 // Any additional squashed RenderLayers in the array no longer exist, and re moving invalidates the squashingLayer contents.
2141 if (nextSquashedLayerIndex < m_squashedLayers.size()) {
2142 m_squashedLayers.remove(nextSquashedLayerIndex, m_squashedLayers.size() - nextSquashedLayerIndex);
2143 if (m_squashingLayer)
2144 m_squashingLayer->setNeedsDisplay();
2145 }
2146 }
2147
1986 CompositingLayerType CompositedLayerMapping::compositingLayerType() const 2148 CompositingLayerType CompositedLayerMapping::compositingLayerType() const
1987 { 2149 {
1988 if (m_graphicsLayer->hasContentsLayer()) 2150 if (m_graphicsLayer->hasContentsLayer())
1989 return MediaCompositingLayer; 2151 return MediaCompositingLayer;
1990 2152
1991 if (m_graphicsLayer->drawsContent()) 2153 if (m_graphicsLayer->drawsContent())
1992 return NormalCompositingLayer; 2154 return NormalCompositingLayer;
1993 2155
1994 return ContainerCompositingLayer; 2156 return ContainerCompositingLayer;
1995 } 2157 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2214 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2053 name = "Scrolling Contents Layer"; 2215 name = "Scrolling Contents Layer";
2054 } else { 2216 } else {
2055 ASSERT_NOT_REACHED(); 2217 ASSERT_NOT_REACHED();
2056 } 2218 }
2057 2219
2058 return name; 2220 return name;
2059 } 2221 }
2060 2222
2061 } // namespace WebCore 2223 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/CompositedLayerMapping.h ('k') | Source/core/rendering/CompositingReasons.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698