Move code that calls setAcceleratesDrawing() on GraphicsLayers into RenderLayerBacking
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2012 21:40:21 +0000 (21:40 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2012 21:40:21 +0000 (21:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82092

Reviewed by Dean Jackson.

A RenderLayerBacking manages several GraphicsLayers, but RenderLayerCompositor
was only calling setAcceleratesDrawing() on the one it knows about. Fix by moving
this setting code down into RenderLayerBacking.

RenderLayerCompositor now caches the setAcceleratesDrawing setting, as it does
for other compositing-related settings, so that RenderLayerBacking doesn't have
to grovel for Settings every time.

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::createGraphicsLayer):
(WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::RenderLayerCompositor):
(WebCore::RenderLayerCompositor::cacheAcceleratedCompositingFlags):
(WebCore::RenderLayerCompositor::updateBacking):
* rendering/RenderLayerCompositor.h:
(WebCore::RenderLayerCompositor::acceleratedDrawingEnabled):
(RenderLayerCompositor):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111908 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h

index aa1a8f50718b2f4fd9d33b0a3d1da8e8b142a9f5..4acd3fc0d18cd3fa9b4ae11f3f71b61e643bfd8e 100644 (file)
@@ -1,3 +1,29 @@
+2012-03-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Move code that calls setAcceleratesDrawing() on GraphicsLayers into RenderLayerBacking
+        https://bugs.webkit.org/show_bug.cgi?id=82092
+
+        Reviewed by Dean Jackson.
+
+        A RenderLayerBacking manages several GraphicsLayers, but RenderLayerCompositor
+        was only calling setAcceleratesDrawing() on the one it knows about. Fix by moving
+        this setting code down into RenderLayerBacking.
+        
+        RenderLayerCompositor now caches the setAcceleratesDrawing setting, as it does
+        for other compositing-related settings, so that RenderLayerBacking doesn't have
+        to grovel for Settings every time.
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::createGraphicsLayer):
+        (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::RenderLayerCompositor):
+        (WebCore::RenderLayerCompositor::cacheAcceleratedCompositingFlags):
+        (WebCore::RenderLayerCompositor::updateBacking):
+        * rendering/RenderLayerCompositor.h:
+        (WebCore::RenderLayerCompositor::acceleratedDrawingEnabled):
+        (RenderLayerCompositor):
+
 2012-03-23  Beth Dakin  <bdakin@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=82083
index 9228f8bb983c96ccb78f86c9c702f49bc0ef564d..26ea017c59fb68e01a5f2b4d40964b657c6eb990 100644 (file)
@@ -138,6 +138,11 @@ PassOwnPtr<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(const String&
     UNUSED_PARAM(name);
 #endif
     graphicsLayer->setMaintainsPixelAlignment(compositor()->keepLayersPixelAligned());
+
+#if PLATFORM(MAC) && USE(CA)
+    graphicsLayer->setAcceleratesDrawing(compositor()->acceleratedDrawingEnabled());
+#endif    
+    
     return graphicsLayer.release();
 }
 
@@ -158,6 +163,14 @@ void RenderLayerBacking::createPrimaryGraphicsLayer()
         m_graphicsLayer->setContentsOpaque(true);
         m_graphicsLayer->setAppliesPageScale();
     }
+
+#if PLATFORM(MAC) && USE(CA)
+    if (!compositor()->acceleratedDrawingEnabled() && renderer()->isCanvas()) {
+        HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer()->node());
+        if (canvas->shouldAccelerate(canvas->size()))
+            m_graphicsLayer->setAcceleratesDrawing(true);
+    }
+#endif    
     
     updateLayerOpacity(renderer()->style());
     updateLayerTransform(renderer()->style());
index 0446b2093bdaf19724464b3ce163ed79026bc426..8b9c0634a4eec5aae1624f9f92939655b7666c12 100644 (file)
@@ -153,6 +153,7 @@ RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView)
     , m_compositedLayerCount(0)
     , m_showDebugBorders(false)
     , m_showRepaintCounter(false)
+    , m_acceleratedDrawingEnabled(false)
     , m_compositingConsultsOverlap(true)
     , m_compositingDependsOnGeometry(false)
     , m_compositingNeedsUpdate(false)
@@ -191,6 +192,7 @@ void RenderLayerCompositor::cacheAcceleratedCompositingFlags()
     bool showDebugBorders = false;
     bool showRepaintCounter = false;
     bool forceCompositingMode = false;
+    bool acceleratedDrawingEnabled = false;
 
     if (Settings* settings = m_renderView->document()->settings()) {
         hasAcceleratedCompositing = settings->acceleratedCompositingEnabled();
@@ -213,8 +215,9 @@ void RenderLayerCompositor::cacheAcceleratedCompositingFlags()
 
         if (forceCompositingMode && m_renderView->document()->ownerElement())
             forceCompositingMode = settings->acceleratedCompositingForScrollableFramesEnabled() && requiresCompositingForScrollableFrame();
-    }
 
+        acceleratedDrawingEnabled = settings->acceleratedDrawingEnabled();
+    }
 
     if (hasAcceleratedCompositing != m_hasAcceleratedCompositing || showDebugBorders != m_showDebugBorders || showRepaintCounter != m_showRepaintCounter || forceCompositingMode != m_forceCompositingMode)
         setCompositingLayersNeedRebuild();
@@ -223,6 +226,7 @@ void RenderLayerCompositor::cacheAcceleratedCompositingFlags()
     m_showDebugBorders = showDebugBorders;
     m_showRepaintCounter = showRepaintCounter;
     m_forceCompositingMode = forceCompositingMode;
+    m_acceleratedDrawingEnabled = acceleratedDrawingEnabled;
 }
 
 bool RenderLayerCompositor::canRender3DTransforms() const
@@ -424,16 +428,6 @@ bool RenderLayerCompositor::updateBacking(RenderLayer* layer, CompositingChangeR
             if (layer->parent())
                 layer->computeRepaintRects();
 
-#if PLATFORM(MAC) && USE(CA)
-            Settings* settings = m_renderView->document()->settings();
-            if (settings && settings->acceleratedDrawingEnabled())
-                layer->backing()->graphicsLayer()->setAcceleratesDrawing(true);
-            else if (layer->renderer()->isCanvas()) {
-                HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(layer->renderer()->node());
-                if (canvas->shouldAccelerate(canvas->size()))
-                    layer->backing()->graphicsLayer()->setAcceleratesDrawing(true);
-            }
-#endif
             layerChanged = true;
         }
     } else {
index 98a2a9f95ecf15b37c03cf361a8de98b94dbf57b..3fc7ea9e1373a7f457a8da4c5d2d9a9d153dbfcf 100644 (file)
@@ -197,6 +197,7 @@ public:
     virtual void didCommitChangesForLayer(const GraphicsLayer*) const;
     
     bool keepLayersPixelAligned() const;
+    bool acceleratedDrawingEnabled() const { return m_acceleratedDrawingEnabled; }
 
     void deviceOrPageScaleFactorChanged();
 
@@ -306,6 +307,7 @@ private:
     int m_compositedLayerCount;
     bool m_showDebugBorders;
     bool m_showRepaintCounter;
+    bool m_acceleratedDrawingEnabled;
     bool m_compositingConsultsOverlap;
 
     // When true, we have to wait until layout has happened before we can decide whether to enter compositing mode,