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

Side by Side Diff: Source/WebCore/rendering/RenderLayerBacking.cpp

Issue 13462003: Add support for accelerated fixed root background (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@background-attachment-fixed2
Patch Set: Adding a FIXME for a bit that'll need fixing. Created 7 years, 8 months 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
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 , m_usingTiledCacheLayer(false) 114 , m_usingTiledCacheLayer(false)
115 , m_requiresOwnBackingStore(true) 115 , m_requiresOwnBackingStore(true)
116 #if ENABLE(CSS_FILTERS) 116 #if ENABLE(CSS_FILTERS)
117 , m_canCompositeFilters(false) 117 , m_canCompositeFilters(false)
118 #endif 118 #endif
119 , m_backgroundLayerPaintsFixedRootBackground(false) 119 , m_backgroundLayerPaintsFixedRootBackground(false)
120 { 120 {
121 if (layer->isRootLayer()) { 121 if (layer->isRootLayer()) {
122 Frame* frame = toRenderView(renderer())->frameView()->frame(); 122 Frame* frame = toRenderView(renderer())->frameView()->frame();
123 Page* page = frame ? frame->page() : 0; 123 Page* page = frame ? frame->page() : 0;
124 if (page && frame && page->mainFrame() == frame) { 124 if (page && frame && page->mainFrame() == frame)
125 m_isMainFrameRenderViewLayer = true; 125 m_isMainFrameRenderViewLayer = true;
126 }
126 127
127 #if PLATFORM(MAC)
128 // FIXME: It's a little weird that we base this decision on whether there's a scrolling coordinator or not.
129 if (page->scrollingCoordinator())
130 m_usingTiledCacheLayer = true;
131 #endif
132 }
133 }
134
135 createPrimaryGraphicsLayer(); 128 createPrimaryGraphicsLayer();
136 129
137 if (m_usingTiledCacheLayer) { 130 if (m_usingTiledCacheLayer) {
138 TiledBacking* tiledBacking = this->tiledBacking(); 131 TiledBacking* tiledBacking = this->tiledBacking();
139 if (Page* page = renderer()->frame()->page()) { 132 if (Page* page = renderer()->frame()->page()) {
140 Frame* frame = renderer()->frame(); 133 Frame* frame = renderer()->frame();
141 tiledBacking->setIsInWindow(page->isInWindow()); 134 tiledBacking->setIsInWindow(page->isInWindow());
142 135
143 if (m_isMainFrameRenderViewLayer) 136 if (m_isMainFrameRenderViewLayer)
144 tiledBacking->setUnparentsOffscreenTiles(true); 137 tiledBacking->setUnparentsOffscreenTiles(true);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 273
281 // The call to createGraphicsLayer ends calling back into here as 274 // The call to createGraphicsLayer ends calling back into here as
282 // a GraphicsLayerClient to ask if it shouldUseTiledBacking(). We only want 275 // a GraphicsLayerClient to ask if it shouldUseTiledBacking(). We only want
283 // the tile cache on our main layer. This is pretty ugly, but saves us from 276 // the tile cache on our main layer. This is pretty ugly, but saves us from
284 // exposing the API to all clients. 277 // exposing the API to all clients.
285 278
286 m_creatingPrimaryGraphicsLayer = true; 279 m_creatingPrimaryGraphicsLayer = true;
287 m_graphicsLayer = createGraphicsLayer(layerName); 280 m_graphicsLayer = createGraphicsLayer(layerName);
288 m_creatingPrimaryGraphicsLayer = false; 281 m_creatingPrimaryGraphicsLayer = false;
289 282
290 if (m_usingTiledCacheLayer)
291 m_childContainmentLayer = createGraphicsLayer("TiledBacking Flattening L ayer");
292
293 if (m_isMainFrameRenderViewLayer) { 283 if (m_isMainFrameRenderViewLayer) {
294 m_graphicsLayer->setContentsOpaque(true); 284 m_graphicsLayer->setContentsOpaque(true);
295 m_graphicsLayer->setAppliesPageScale(); 285 m_graphicsLayer->setAppliesPageScale();
296 } 286 }
297 287
298 #if PLATFORM(MAC) && USE(CA) 288 #if PLATFORM(MAC) && USE(CA)
299 if (!compositor()->acceleratedDrawingEnabled() && renderer()->isCanvas()) { 289 if (!compositor()->acceleratedDrawingEnabled() && renderer()->isCanvas()) {
300 HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer()-> node()); 290 HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer()-> node());
301 if (canvas->shouldAccelerate(canvas->size())) 291 if (canvas->shouldAccelerate(canvas->size()))
302 m_graphicsLayer->setAcceleratesDrawing(true); 292 m_graphicsLayer->setAcceleratesDrawing(true);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 387
398 return false; 388 return false;
399 } 389 }
400 390
401 bool RenderLayerBacking::shouldClipCompositedBounds() const 391 bool RenderLayerBacking::shouldClipCompositedBounds() const
402 { 392 {
403 // Scrollbar layers use this layer for relative positioning, so don't clip. 393 // Scrollbar layers use this layer for relative positioning, so don't clip.
404 if (layerForHorizontalScrollbar() || layerForVerticalScrollbar()) 394 if (layerForHorizontalScrollbar() || layerForVerticalScrollbar())
405 return false; 395 return false;
406 396
407 if (m_usingTiledCacheLayer) 397 if (m_usingTiledCacheLayer || m_backgroundLayerPaintsFixedRootBackground)
408 return false; 398 return false;
409 399
410 if (!compositor()->compositingConsultsOverlap()) 400 if (!compositor()->compositingConsultsOverlap())
411 return false; 401 return false;
412 402
413 if (layerOrAncestorIsTransformedOrUsingCompositedScrolling(m_owningLayer)) 403 if (layerOrAncestorIsTransformedOrUsingCompositedScrolling(m_owningLayer))
414 return false; 404 return false;
415 405
416 return true; 406 return true;
417 } 407 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 if (foregroundSize != m_foregroundLayer->size()) { 765 if (foregroundSize != m_foregroundLayer->size()) {
776 m_foregroundLayer->setSize(foregroundSize); 766 m_foregroundLayer->setSize(foregroundSize);
777 m_foregroundLayer->setNeedsDisplay(); 767 m_foregroundLayer->setNeedsDisplay();
778 } 768 }
779 m_foregroundLayer->setOffsetFromRenderer(foregroundOffset); 769 m_foregroundLayer->setOffsetFromRenderer(foregroundOffset);
780 } 770 }
781 771
782 if (m_backgroundLayer) { 772 if (m_backgroundLayer) {
783 FloatPoint backgroundPosition; 773 FloatPoint backgroundPosition;
784 FloatSize backgroundSize = contentsSize; 774 FloatSize backgroundSize = contentsSize;
785 if (backgroundLayerPaintsFixedRootBackground()) {
786 FrameView* frameView = toRenderView(renderer())->frameView();
787 backgroundPosition = IntPoint(frameView->scrollOffsetForFixedPositio n());
788 backgroundSize = frameView->visibleContentRect().size();
789 }
790 m_backgroundLayer->setPosition(backgroundPosition); 775 m_backgroundLayer->setPosition(backgroundPosition);
791 if (backgroundSize != m_backgroundLayer->size()) { 776 if (backgroundSize != m_backgroundLayer->size()) {
792 m_backgroundLayer->setSize(backgroundSize); 777 m_backgroundLayer->setSize(backgroundSize);
793 m_backgroundLayer->setNeedsDisplay(); 778 m_backgroundLayer->setNeedsDisplay();
794 } 779 }
795 m_backgroundLayer->setOffsetFromRenderer(m_graphicsLayer->offsetFromRend erer());
796 } 780 }
797 781
798 if (m_owningLayer->reflectionLayer() && m_owningLayer->reflectionLayer()->is Composited()) { 782 if (m_owningLayer->reflectionLayer() && m_owningLayer->reflectionLayer()->is Composited()) {
799 RenderLayerBacking* reflectionBacking = m_owningLayer->reflectionLayer() ->backing(); 783 RenderLayerBacking* reflectionBacking = m_owningLayer->reflectionLayer() ->backing();
800 reflectionBacking->updateGraphicsLayerGeometry(); 784 reflectionBacking->updateGraphicsLayerGeometry();
801 785
802 // The reflection layer has the bounds of m_owningLayer->reflectionLayer (), 786 // The reflection layer has the bounds of m_owningLayer->reflectionLayer (),
803 // but the reflected layer is the bounds of this layer, so we need to po sition it appropriately. 787 // but the reflected layer is the bounds of this layer, so we need to po sition it appropriately.
804 FloatRect layerBounds = compositedBounds(); 788 FloatRect layerBounds = compositedBounds();
805 FloatRect reflectionLayerBounds = reflectionBacking->compositedBounds(); 789 FloatRect reflectionLayerBounds = reflectionBacking->compositedBounds();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 // m_foregroundLayer has to be inserted in the correct order with child laye rs, 862 // m_foregroundLayer has to be inserted in the correct order with child laye rs,
879 // so it's not inserted here. 863 // so it's not inserted here.
880 if (m_ancestorClippingLayer) 864 if (m_ancestorClippingLayer)
881 m_ancestorClippingLayer->removeAllChildren(); 865 m_ancestorClippingLayer->removeAllChildren();
882 866
883 if (m_contentsContainmentLayer) { 867 if (m_contentsContainmentLayer) {
884 m_contentsContainmentLayer->removeAllChildren(); 868 m_contentsContainmentLayer->removeAllChildren();
885 if (m_ancestorClippingLayer) 869 if (m_ancestorClippingLayer)
886 m_ancestorClippingLayer->addChild(m_contentsContainmentLayer.get()); 870 m_ancestorClippingLayer->addChild(m_contentsContainmentLayer.get());
887 } 871 }
888
889 if (m_backgroundLayer)
890 m_contentsContainmentLayer->addChild(m_backgroundLayer.get());
891 872
892 m_graphicsLayer->removeFromParent(); 873 m_graphicsLayer->removeFromParent();
893 if (m_contentsContainmentLayer) 874 if (m_contentsContainmentLayer)
894 m_contentsContainmentLayer->addChild(m_graphicsLayer.get()); 875 m_contentsContainmentLayer->addChild(m_graphicsLayer.get());
895 else if (m_ancestorClippingLayer) 876 else if (m_ancestorClippingLayer)
896 m_ancestorClippingLayer->addChild(m_graphicsLayer.get()); 877 m_ancestorClippingLayer->addChild(m_graphicsLayer.get());
897 878
898 if (m_childContainmentLayer) { 879 if (m_childContainmentLayer) {
899 m_childContainmentLayer->removeFromParent(); 880 m_childContainmentLayer->removeFromParent();
900 m_graphicsLayer->addChild(m_childContainmentLayer.get()); 881 m_graphicsLayer->addChild(m_childContainmentLayer.get());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 layersChanged = true; 958 layersChanged = true;
978 } 959 }
979 } else if (m_ancestorClippingLayer) { 960 } else if (m_ancestorClippingLayer) {
980 willDestroyLayer(m_ancestorClippingLayer.get()); 961 willDestroyLayer(m_ancestorClippingLayer.get());
981 m_ancestorClippingLayer->removeFromParent(); 962 m_ancestorClippingLayer->removeFromParent();
982 m_ancestorClippingLayer = nullptr; 963 m_ancestorClippingLayer = nullptr;
983 layersChanged = true; 964 layersChanged = true;
984 } 965 }
985 966
986 if (needsDescendantClip) { 967 if (needsDescendantClip) {
987 if (!m_childContainmentLayer && !m_usingTiledCacheLayer) { 968 if (!m_childContainmentLayer && !m_usingTiledCacheLayer && !m_background LayerPaintsFixedRootBackground) {
988 m_childContainmentLayer = createGraphicsLayer("Child clipping Layer" ); 969 m_childContainmentLayer = createGraphicsLayer("Child clipping Layer" );
989 m_childContainmentLayer->setMasksToBounds(true); 970 m_childContainmentLayer->setMasksToBounds(true);
990 layersChanged = true; 971 layersChanged = true;
991 } 972 }
992 } else if (hasClippingLayer()) { 973 } else if (hasClippingLayer()) {
993 willDestroyLayer(m_childContainmentLayer.get()); 974 willDestroyLayer(m_childContainmentLayer.get());
994 m_childContainmentLayer->removeFromParent(); 975 m_childContainmentLayer->removeFromParent();
995 m_childContainmentLayer = nullptr; 976 m_childContainmentLayer = nullptr;
996 layersChanged = true; 977 layersChanged = true;
997 } 978 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 String layerName; 1145 String layerName;
1165 #ifndef NDEBUG 1146 #ifndef NDEBUG
1166 layerName = m_owningLayer->name() + " (background)"; 1147 layerName = m_owningLayer->name() + " (background)";
1167 #endif 1148 #endif
1168 m_backgroundLayer = createGraphicsLayer(layerName); 1149 m_backgroundLayer = createGraphicsLayer(layerName);
1169 m_backgroundLayer->setDrawsContent(true); 1150 m_backgroundLayer->setDrawsContent(true);
1170 m_backgroundLayer->setAnchorPoint(FloatPoint3D()); 1151 m_backgroundLayer->setAnchorPoint(FloatPoint3D());
1171 m_backgroundLayer->setPaintingPhase(GraphicsLayerPaintBackground); 1152 m_backgroundLayer->setPaintingPhase(GraphicsLayerPaintBackground);
1172 layerChanged = true; 1153 layerChanged = true;
1173 } 1154 }
1174
1175 if (!m_contentsContainmentLayer) {
1176 String layerName;
1177 #ifndef NDEBUG
1178 layerName = m_owningLayer->name() + " (contents containment)";
1179 #endif
1180 m_contentsContainmentLayer = createGraphicsLayer(layerName);
1181 m_contentsContainmentLayer->setAppliesPageScale(true);
1182 m_graphicsLayer->setAppliesPageScale(false);
1183 layerChanged = true;
1184 }
1185 } else { 1155 } else {
1186 if (m_backgroundLayer) { 1156 if (m_backgroundLayer) {
1187 willDestroyLayer(m_backgroundLayer.get()); 1157 willDestroyLayer(m_backgroundLayer.get());
1188 m_backgroundLayer->removeFromParent(); 1158 m_backgroundLayer->removeFromParent();
1189 m_backgroundLayer = nullptr; 1159 m_backgroundLayer = nullptr;
1190 layerChanged = true; 1160 layerChanged = true;
1191 } 1161 }
1192 if (m_contentsContainmentLayer) { 1162 }
1193 willDestroyLayer(m_contentsContainmentLayer.get()); 1163
1194 m_contentsContainmentLayer->removeFromParent(); 1164 if (layerChanged) {
1195 m_contentsContainmentLayer = nullptr; 1165 // This assumes that the background layer is only used for fixed backgro unds, which is currently a correct assumption.
1196 layerChanged = true; 1166 if (renderer()->view())
1197 m_graphicsLayer->setAppliesPageScale(true); 1167 compositor()->fixedRootBackgroundLayerChanged();
1198 }
1199 } 1168 }
1200 1169
1201 return layerChanged; 1170 return layerChanged;
1202 } 1171 }
1203 1172
1204 bool RenderLayerBacking::updateMaskLayer(bool needsMaskLayer) 1173 bool RenderLayerBacking::updateMaskLayer(bool needsMaskLayer)
1205 { 1174 {
1206 bool layerChanged = false; 1175 bool layerChanged = false;
1207 if (needsMaskLayer) { 1176 if (needsMaskLayer) {
1208 if (!m_maskLayer) { 1177 if (!m_maskLayer) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 Color backgroundColor; 1301 Color backgroundColor;
1333 if (isSimpleContainer) 1302 if (isSimpleContainer)
1334 backgroundColor = rendererBackgroundColor(); 1303 backgroundColor = rendererBackgroundColor();
1335 1304
1336 // An unset (invalid) color will remove the solid color. 1305 // An unset (invalid) color will remove the solid color.
1337 m_graphicsLayer->setContentsToSolidColor(backgroundColor); 1306 m_graphicsLayer->setContentsToSolidColor(backgroundColor);
1338 } 1307 }
1339 1308
1340 void RenderLayerBacking::updateRootLayerConfiguration() 1309 void RenderLayerBacking::updateRootLayerConfiguration()
1341 { 1310 {
1342 if (!m_usingTiledCacheLayer) 1311 if (!m_usingTiledCacheLayer && !m_backgroundLayerPaintsFixedRootBackground)
1343 return; 1312 return;
1344 1313
1345 Color backgroundColor; 1314 Color backgroundColor;
1346 bool viewIsTransparent = compositor()->viewHasTransparentBackground(&backgro undColor); 1315 bool viewIsTransparent = compositor()->viewHasTransparentBackground(&backgro undColor);
1347 1316
1348 if (m_backgroundLayerPaintsFixedRootBackground && m_backgroundLayer) { 1317 if (m_backgroundLayerPaintsFixedRootBackground && m_backgroundLayer) {
1349 m_backgroundLayer->setBackgroundColor(backgroundColor); 1318 m_backgroundLayer->setBackgroundColor(backgroundColor);
1350 m_backgroundLayer->setContentsOpaque(!viewIsTransparent); 1319 m_backgroundLayer->setContentsOpaque(!viewIsTransparent);
1351 1320
1352 m_graphicsLayer->setBackgroundColor(Color()); 1321 m_graphicsLayer->setBackgroundColor(Color());
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 return m_ancestorClippingLayer.get(); 1662 return m_ancestorClippingLayer.get();
1694 1663
1695 if (m_contentsContainmentLayer) 1664 if (m_contentsContainmentLayer)
1696 return m_contentsContainmentLayer.get(); 1665 return m_contentsContainmentLayer.get();
1697 1666
1698 return m_graphicsLayer.get(); 1667 return m_graphicsLayer.get();
1699 } 1668 }
1700 1669
1701 bool RenderLayerBacking::paintsIntoWindow() const 1670 bool RenderLayerBacking::paintsIntoWindow() const
1702 { 1671 {
1703 if (m_usingTiledCacheLayer) 1672 if (m_usingTiledCacheLayer || m_backgroundLayerPaintsFixedRootBackground)
1704 return false; 1673 return false;
1705 1674
1706 if (m_owningLayer->isRootLayer()) { 1675 if (m_owningLayer->isRootLayer()) {
1707 #if PLATFORM(BLACKBERRY) 1676 #if PLATFORM(BLACKBERRY)
1708 if (compositor()->inForcedCompositingMode()) 1677 if (compositor()->inForcedCompositingMode())
1709 return false; 1678 return false;
1710 #endif 1679 #endif
1711 1680
1712 return compositor()->rootLayerAttachment() != RenderLayerCompositor::Roo tLayerAttachedViaEnclosingFrame; 1681 return compositor()->rootLayerAttachment() != RenderLayerCompositor::Roo tLayerAttachedViaEnclosingFrame;
1713 } 1682 }
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 info.addMember(m_layerForHorizontalScrollbar, "layerForHorizontalScrollbar") ; 2205 info.addMember(m_layerForHorizontalScrollbar, "layerForHorizontalScrollbar") ;
2237 info.addMember(m_layerForVerticalScrollbar, "layerForVerticalScrollbar"); 2206 info.addMember(m_layerForVerticalScrollbar, "layerForVerticalScrollbar");
2238 info.addMember(m_layerForScrollCorner, "layerForScrollCorner"); 2207 info.addMember(m_layerForScrollCorner, "layerForScrollCorner");
2239 info.addMember(m_scrollingLayer, "scrollingLayer"); 2208 info.addMember(m_scrollingLayer, "scrollingLayer");
2240 info.addMember(m_scrollingContentsLayer, "scrollingContentsLayer"); 2209 info.addMember(m_scrollingContentsLayer, "scrollingContentsLayer");
2241 } 2210 }
2242 2211
2243 } // namespace WebCore 2212 } // namespace WebCore
2244 2213
2245 #endif // USE(ACCELERATED_COMPOSITING) 2214 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698