2010-08-06 James Robinson <jamesr@chromium.org>
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Aug 2010 21:49:20 +0000 (21:49 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Aug 2010 21:49:20 +0000 (21:49 +0000)
        Reviewed by Simon Fraser.

        Composited canvas should be treated the same by the compositor and not be WebGL specific
        https://bugs.webkit.org/show_bug.cgi?id=43589

        Initializes the platformLayer as a CanvasLayerChromium, not a WebGLLayerChromium.
        The layer itself isn't WebGL-specific.

        * src/GraphicsContext3D.cpp:
        (WebCore::GraphicsContext3DInternal::initialize):
        (WebCore::GraphicsContext3DInternal::platformLayer):
        (WebCore::GraphicsContext3D::platformLayer):
2010-08-06  James Robinson  <jamesr@chromium.org>

        Reviewed by Simon Fraser.

        Composited canvas should be treated the same by the compositor and not be WebGL specific
        https://bugs.webkit.org/show_bug.cgi?id=43589

        This treats all GraphicsContext3D-backed layers the same instead of special casing WebGL.
        The cross-platform change is to rename GraphicsLayer::setContentsToWebGL() to
        GraphicsLayer::setContentsToCanvas() and to rename all implementations.

        This patch also renames the chromium class used for accelerating these layers.

        Cross platform changes:
        * WebCore.gypi:
        * platform/graphics/GraphicsLayer.h:
        (WebCore::GraphicsLayer::setContentsToCanvas):
            Rename the function on the base class. GraphicsLayerCA and GraphicsLayerChromium implement this.
        * rendering/RenderLayerBacking.cpp:
        (WebCore::isAcceleratedCanvas):
            Helper function to see if a renderer is associated with an accelerated compositing layer.
        (WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration):
        (WebCore::RenderLayerBacking::containsPaintedContent):
        (WebCore::RenderLayerBacking::rendererContentChanged):
       Chromium specific changes:
        * platform/graphics/chromium/CanvasLayerChromium.cpp: Added.
        (WebCore::CanvasLayerChromium::create):
        (WebCore::CanvasLayerChromium::CanvasLayerChromium):
        (WebCore::CanvasLayerChromium::textureId):
        (WebCore::CanvasLayerChromium::updateTextureContents):
        (WebCore::CanvasLayerChromium::setContext):
        * platform/graphics/chromium/CanvasLayerChromium.h: Added.
        (WebCore::CanvasLayerChromium::drawsContent):
        (WebCore::CanvasLayerChromium::ownsTexture):
        (WebCore::CanvasLayerChromium::shaderProgramId):
        (WebCore::CanvasLayerChromium::setShaderProgramId):
        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
        (WebCore::GraphicsLayerChromium::setContentsNeedsDisplay):
        (WebCore::GraphicsLayerChromium::setContentsToCanvas):
        * platform/graphics/chromium/GraphicsLayerChromium.h:
        (WebCore::GraphicsLayerChromium::):
        * platform/graphics/chromium/LayerRendererChromium.cpp:
        (WebCore::LayerRendererChromium::drawLayer):
        (WebCore::LayerRendererChromium::initializeSharedGLObjects):
        * platform/graphics/chromium/LayerRendererChromium.h:
        (WebCore::LayerRendererChromium::):
        * platform/graphics/chromium/WebGLLayerChromium.cpp: Removed.
        * platform/graphics/chromium/WebGLLayerChromium.h: Removed.
        Mac specific changes:
        * platform/graphics/mac/GraphicsLayerCA.h:
        (WebCore::GraphicsLayerCA::):
        * platform/graphics/mac/GraphicsLayerCA.mm:
        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
        (WebCore::GraphicsLayerCA::updateContentsCanvasLayer):
        (WebCore::GraphicsLayerCA::setContentsToCanvas):

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

14 files changed:
WebCore/ChangeLog
WebCore/WebCore.gypi
WebCore/platform/graphics/GraphicsLayer.h
WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp [moved from WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp with 85% similarity]
WebCore/platform/graphics/chromium/CanvasLayerChromium.h [moved from WebCore/platform/graphics/chromium/WebGLLayerChromium.h with 87% similarity]
WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
WebCore/platform/graphics/chromium/LayerRendererChromium.h
WebCore/platform/graphics/mac/GraphicsLayerCA.h
WebCore/platform/graphics/mac/GraphicsLayerCA.mm
WebCore/rendering/RenderLayerBacking.cpp
WebKit/chromium/ChangeLog
WebKit/chromium/src/GraphicsContext3D.cpp

index 742c60f..54c5e1f 100644 (file)
@@ -1,3 +1,59 @@
+2010-08-06  James Robinson  <jamesr@chromium.org>
+
+        Reviewed by Simon Fraser.
+
+        Composited canvas should be treated the same by the compositor and not be WebGL specific
+        https://bugs.webkit.org/show_bug.cgi?id=43589
+
+        This treats all GraphicsContext3D-backed layers the same instead of special casing WebGL.
+        The cross-platform change is to rename GraphicsLayer::setContentsToWebGL() to
+        GraphicsLayer::setContentsToCanvas() and to rename all implementations.
+
+        This patch also renames the chromium class used for accelerating these layers.
+
+        Cross platform changes:
+        * WebCore.gypi:
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::setContentsToCanvas):
+            Rename the function on the base class. GraphicsLayerCA and GraphicsLayerChromium implement this.
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::isAcceleratedCanvas):
+            Helper function to see if a renderer is associated with an accelerated compositing layer.
+        (WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration):
+        (WebCore::RenderLayerBacking::containsPaintedContent):
+        (WebCore::RenderLayerBacking::rendererContentChanged):
+       Chromium specific changes:
+        * platform/graphics/chromium/CanvasLayerChromium.cpp: Added.
+        (WebCore::CanvasLayerChromium::create):
+        (WebCore::CanvasLayerChromium::CanvasLayerChromium):
+        (WebCore::CanvasLayerChromium::textureId):
+        (WebCore::CanvasLayerChromium::updateTextureContents):
+        (WebCore::CanvasLayerChromium::setContext):
+        * platform/graphics/chromium/CanvasLayerChromium.h: Added.
+        (WebCore::CanvasLayerChromium::drawsContent):
+        (WebCore::CanvasLayerChromium::ownsTexture):
+        (WebCore::CanvasLayerChromium::shaderProgramId):
+        (WebCore::CanvasLayerChromium::setShaderProgramId):
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayerChromium::setContentsNeedsDisplay):
+        (WebCore::GraphicsLayerChromium::setContentsToCanvas):
+        * platform/graphics/chromium/GraphicsLayerChromium.h:
+        (WebCore::GraphicsLayerChromium::):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::drawLayer):
+        (WebCore::LayerRendererChromium::initializeSharedGLObjects):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (WebCore::LayerRendererChromium::):
+        * platform/graphics/chromium/WebGLLayerChromium.cpp: Removed.
+        * platform/graphics/chromium/WebGLLayerChromium.h: Removed.
+        Mac specific changes:
+        * platform/graphics/mac/GraphicsLayerCA.h:
+        (WebCore::GraphicsLayerCA::):
+        * platform/graphics/mac/GraphicsLayerCA.mm:
+        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
+        (WebCore::GraphicsLayerCA::updateContentsCanvasLayer):
+        (WebCore::GraphicsLayerCA::setContentsToCanvas):
+
 2010-08-06  Patrick Gansterer  <paroga@paroga.com>
 
         Reviewed by Eric Seidel.
index 9684c62..6ff4928 100644 (file)
             'platform/graphics/cg/PathCG.cpp',
             'platform/graphics/cg/PatternCG.cpp',
             'platform/graphics/cg/TransformationMatrixCG.cpp',
+            'platform/graphics/chromium/CanvasLayerChromium.cpp',
+            'platform/graphics/chromium/CanvasLayerChromium.h',
             'platform/graphics/chromium/FontCacheChromiumWin.cpp',
             'platform/graphics/chromium/FontCacheLinux.cpp',
             'platform/graphics/chromium/FontChromiumWin.cpp',
             'platform/graphics/chromium/UniscribeHelperTextRun.h',
             'platform/graphics/chromium/VideoLayerChromium.cpp',
             'platform/graphics/chromium/VideoLayerChromium.h',
-            'platform/graphics/chromium/WebGLLayerChromium.cpp',
-            'platform/graphics/chromium/WebGLLayerChromium.h',
             'platform/graphics/filters/FEBlend.cpp',
             'platform/graphics/filters/FEBlend.h',
             'platform/graphics/filters/FEColorMatrix.cpp',
index a5819f4..0f74cd5 100644 (file)
@@ -298,9 +298,7 @@ public:
     virtual void setContentsToImage(Image*) { }
     virtual void setContentsToMedia(PlatformLayer*) { } // video or plug-in
     virtual void setContentsBackgroundColor(const Color&) { }
-#if ENABLE(3D_CANVAS)
-    virtual void setContentsToWebGL(PlatformLayer*) { }
-#endif
+    virtual void setContentsToCanvas(PlatformLayer*) { }
     virtual bool hasContentsLayer() const { return false; }
 
     // Callback from the underlying graphics system to draw layer contents.
 
 #if USE(ACCELERATED_COMPOSITING)
 
-#include "WebGLLayerChromium.h"
+#include "CanvasLayerChromium.h"
 
 #include "GraphicsContext3D.h"
 #include <GLES2/gl2.h>
 
 namespace WebCore {
 
-unsigned WebGLLayerChromium::m_shaderProgramId = 0;
+unsigned CanvasLayerChromium::m_shaderProgramId = 0;
 
-PassRefPtr<WebGLLayerChromium> WebGLLayerChromium::create(GraphicsLayerChromium* owner)
+PassRefPtr<CanvasLayerChromium> CanvasLayerChromium::create(GraphicsLayerChromium* owner)
 {
-    return adoptRef(new WebGLLayerChromium(owner));
+    return adoptRef(new CanvasLayerChromium(owner));
 }
 
-WebGLLayerChromium::WebGLLayerChromium(GraphicsLayerChromium* owner)
+CanvasLayerChromium::CanvasLayerChromium(GraphicsLayerChromium* owner)
     : LayerChromium(owner)
     , m_context(0)
     , m_textureId(0)
@@ -54,12 +54,12 @@ WebGLLayerChromium::WebGLLayerChromium(GraphicsLayerChromium* owner)
 {
 }
 
-unsigned WebGLLayerChromium::textureId()
+unsigned CanvasLayerChromium::textureId()
 {
     return m_textureId;
 }
 
-void WebGLLayerChromium::updateTextureContents(unsigned textureId)
+void CanvasLayerChromium::updateTextureContents(unsigned textureId)
 {
     ASSERT(textureId == m_textureId);
     ASSERT(m_context);
@@ -80,7 +80,7 @@ void WebGLLayerChromium::updateTextureContents(unsigned textureId)
     }
 }
 
-void WebGLLayerChromium::setContext(const GraphicsContext3D* context)
+void CanvasLayerChromium::setContext(const GraphicsContext3D* context)
 {
     m_context = const_cast<GraphicsContext3D*>(context);
 
@@ -29,8 +29,8 @@
  */
 
 
-#ifndef WebGLLayerChromium_h
-#define WebGLLayerChromium_h
+#ifndef CanvasLayerChromium_h
+#define CanvasLayerChromium_h
 
 #if USE(ACCELERATED_COMPOSITING)
 
@@ -40,10 +40,10 @@ namespace WebCore {
 
 class GraphicsContext3D;
 
-// A Layer that contains a WebGL element.
-class WebGLLayerChromium : public LayerChromium {
+// A Layer containing a WebGL or accelerated 2d canvas
+class CanvasLayerChromium : public LayerChromium {
 public:
-    static PassRefPtr<WebGLLayerChromium> create(GraphicsLayerChromium* owner = 0);
+    static PassRefPtr<CanvasLayerChromium> create(GraphicsLayerChromium* owner = 0);
     virtual bool drawsContent() { return m_context; }
     virtual bool ownsTexture() { return true; }
     virtual void updateTextureContents(unsigned);
@@ -55,7 +55,7 @@ public:
     static void setShaderProgramId(unsigned shaderProgramId) { m_shaderProgramId = shaderProgramId; }
 
 private:
-    WebGLLayerChromium(GraphicsLayerChromium* owner);
+    explicit CanvasLayerChromium(GraphicsLayerChromium* owner);
     GraphicsContext3D* m_context;
     unsigned m_textureId;
     bool m_textureChanged;
index e895cee..1d67857 100644 (file)
@@ -53,7 +53,7 @@
 #include "PlatformString.h"
 #include "SystemTime.h"
 #include "TransformLayerChromium.h"
-#include "WebGLLayerChromium.h"
+
 #include <wtf/CurrentTime.h>
 #include <wtf/StringExtras.h>
 #include <wtf/text/CString.h>
@@ -285,6 +285,11 @@ void GraphicsLayerChromium::setOpacity(float opacity)
     primaryLayer()->setOpacity(opacity);
 }
 
+void GraphicsLayerChromium::setContentsNeedsDisplay()
+{
+    if (m_contentsLayer)
+        m_contentsLayer->setNeedsDisplay();
+}
 void GraphicsLayerChromium::setNeedsDisplay()
 {
     if (drawsContent())
@@ -334,19 +339,17 @@ void GraphicsLayerChromium::setContentsToImage(Image* image)
         updateSublayerList();
 }
 
-#if ENABLE(3D_CANVAS)
-void GraphicsLayerChromium::setContentsToWebGL(PlatformLayer* platformLayer)
+void GraphicsLayerChromium::setContentsToCanvas(PlatformLayer* platformLayer)
 {
     bool childrenChanged = false;
     if (platformLayer) {
-        if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForWebGL) {
-            WebGLLayerChromium* webGLLayer = static_cast<WebGLLayerChromium*>(platformLayer);
-            setupContentsLayer(webGLLayer);
-            m_contentsLayer = webGLLayer;
-            m_contentsLayerPurpose = ContentsLayerForWebGL;
+        platformLayer->setOwner(this);
+        if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForCanvas) {
+            setupContentsLayer(platformLayer);
+            m_contentsLayer = platformLayer;
+            m_contentsLayerPurpose = ContentsLayerForCanvas;
             childrenChanged = true;
         }
-        platformLayer->setOwner(this);
         platformLayer->setNeedsDisplay();
         updateContentsRect();
     } else {
@@ -361,7 +364,6 @@ void GraphicsLayerChromium::setContentsToWebGL(PlatformLayer* platformLayer)
     if (childrenChanged)
         updateSublayerList();
 }
-#endif
 
 void GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer)
 {
index cd5e479..9dff66a 100644 (file)
@@ -81,12 +81,13 @@ public:
 
     virtual void setNeedsDisplay();
     virtual void setNeedsDisplayInRect(const FloatRect&);
+    virtual void setContentsNeedsDisplay();
 
     virtual void setContentsRect(const IntRect&);
 
     virtual void setContentsToImage(Image*);
     virtual void setContentsToMedia(PlatformLayer*);
-    virtual void setContentsToWebGL(PlatformLayer*);
+    virtual void setContentsToCanvas(PlatformLayer*);
 
     virtual PlatformLayer* platformLayer() const;
 
@@ -137,7 +138,7 @@ private:
         NoContentsLayer = 0,
         ContentsLayerForImage,
         ContentsLayerForVideo,
-        ContentsLayerForWebGL
+        ContentsLayerForCanvas
     };
 
     ContentsLayerPurpose m_contentsLayerPurpose;
index e98a65a..89d8907 100644 (file)
 #if USE(ACCELERATED_COMPOSITING)
 #include "LayerRendererChromium.h"
 
+#include "CanvasLayerChromium.h"
 #include "GLES2Context.h"
 #include "LayerChromium.h"
 #include "NotImplemented.h"
 #include "TransformLayerChromium.h"
-#include "WebGLLayerChromium.h"
 #if PLATFORM(SKIA)
 #include "NativeImageSkia.h"
 #include "PlatformContextSkia.h"
@@ -691,6 +691,7 @@ void LayerRendererChromium::drawLayer(LayerChromium* layer)
         if (layer->contentsDirty()) {
             // Update the backing texture contents for any dirty portion of the layer.
             layer->updateTextureContents(textureId);
+            m_gles2Context->makeCurrent();
         }
 
         if (layer->doubleSided())
@@ -770,9 +771,9 @@ bool LayerRendererChromium::initializeSharedGLObjects()
         "  gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w); \n"
         "}                                                   \n";
 
-    // WebGL layers need to be flipped vertically and their colors shouldn't be
+    // Canvas layers need to be flipped vertically and their colors shouldn't be
     // swizzled.
-    char webGLFragmentShaderString[] =
+    char canvasFragmentShaderString[] =
         "precision mediump float;                            \n"
         "varying vec2 v_texCoord;                            \n"
         "uniform sampler2D s_texture;                        \n"
@@ -819,11 +820,11 @@ bool LayerRendererChromium::initializeSharedGLObjects()
     }
     LayerChromium::setShaderProgramId(ContentLayerProgram);
 
-    if (!createLayerShader(WebGLLayerProgram, vertexShaderString, webGLFragmentShaderString)) {
-        LOG_ERROR("Failed to create shader program for WebGL layers");
+    if (!createLayerShader(CanvasLayerProgram, vertexShaderString, canvasFragmentShaderString)) {
+        LOG_ERROR("Failed to create shader program for Canvas layers");
         return false;
     }
-    WebGLLayerChromium::setShaderProgramId(WebGLLayerProgram);
+    CanvasLayerChromium::setShaderProgramId(CanvasLayerProgram);
 
     if (!createLayerShader(ScrollLayerProgram, vertexShaderString, scrollFragmentShaderString)) {
         LOG_ERROR("Failed to create shader program for scrolling layer");
@@ -838,7 +839,7 @@ bool LayerRendererChromium::initializeSharedGLObjects()
     // Specify the attrib location for the position and texCoord and make it the same for all programs to
     // avoid binding re-binding the vertex attributes.
     bindCommonAttribLocations(ContentLayerProgram);
-    bindCommonAttribLocations(WebGLLayerProgram);
+    bindCommonAttribLocations(CanvasLayerProgram);
     bindCommonAttribLocations(DebugBorderProgram);
     bindCommonAttribLocations(ScrollLayerProgram);
 
index 17e7e57..e4474b5 100644 (file)
@@ -88,7 +88,7 @@ public:
     GraphicsContext* rootLayerGraphicsContext() const { return m_rootLayerGraphicsContext.get(); }
 
 private:
-    enum ShaderProgramType { DebugBorderProgram, ScrollLayerProgram, ContentLayerProgram, WebGLLayerProgram, NumShaderProgramTypes };
+    enum ShaderProgramType { DebugBorderProgram, ScrollLayerProgram, ContentLayerProgram, CanvasLayerProgram, NumShaderProgramTypes };
 
     void updateLayersRecursive(LayerChromium* layer, const TransformationMatrix& parentMatrix, float opacity, const IntRect& visibleRect);
 
index 80c822c..ee70338 100644 (file)
@@ -103,9 +103,8 @@ public:
     
     virtual void setContentsToImage(Image*);
     virtual void setContentsToMedia(PlatformLayer*);
-#if ENABLE(3D_CANVAS)
-    virtual void setContentsToWebGL(PlatformLayer*);
-#endif
+    virtual void setContentsToCanvas(PlatformLayer*);
+
     virtual bool hasContentsLayer() const { return m_contentsLayer; }
     
     virtual PlatformLayer* platformLayer() const;
@@ -258,9 +257,7 @@ private:
 
     void updateContentsImage();
     void updateContentsMediaLayer();
-#if ENABLE(3D_CANVAS)
-    void updateContentsWebGLLayer();
-#endif
+    void updateContentsCanvasLayer();
     void updateContentsRect();
     void updateGeometryOrientation();
     void updateMaskLayer();
@@ -305,9 +302,7 @@ private:
         DirtyRectsChanged = 1 << 16,
         ContentsImageChanged = 1 << 17,
         ContentsMediaLayerChanged = 1 << 18,
-#if ENABLE(3D_CANVAS)
-        ContentsWebGLLayerChanged = 1 << 19,
-#endif
+        ContentsCanvasLayerChanged = 1 << 19,
         ContentsRectChanged = 1 << 20,
         GeometryOrientationChanged = 1 << 21,
         MaskLayerChanged = 1 << 22,
@@ -332,10 +327,8 @@ private:
     enum ContentsLayerPurpose {
         NoContentsLayer = 0,
         ContentsLayerForImage,
-        ContentsLayerForMedia
-#if ENABLE(3D_CANVAS)
-        , ContentsLayerForWebGL
-#endif
+        ContentsLayerForMedia,
+        ContentsLayerForCanvas
     };
     
     ContentsLayerPurpose m_contentsLayerPurpose;
index 9f1ac83..cb4ca58 100644 (file)
@@ -917,10 +917,8 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers()
     if (m_uncommittedChanges & ContentsMediaLayerChanged) // Needs to happen before ChildrenChanged
         updateContentsMediaLayer();
     
-#if ENABLE(3D_CANVAS)
-    if (m_uncommittedChanges & ContentsWebGLLayerChanged) // Needs to happen before ChildrenChanged
-        updateContentsWebGLLayer();
-#endif
+    if (m_uncommittedChanges & ContentsCanvasLayerChanged) // Needs to happen before ChildrenChanged
+        updateContentsCanvasLayer();
     
     if (m_uncommittedChanges & BackgroundColorChanged)  // Needs to happen before ChildrenChanged, and after updating image or video
         updateLayerBackgroundColor();
@@ -1396,18 +1394,16 @@ void GraphicsLayerCA::updateContentsMediaLayer()
     }
 }
 
-#if ENABLE(3D_CANVAS)
-void GraphicsLayerCA::updateContentsWebGLLayer()
+void GraphicsLayerCA::updateContentsCanvasLayer()
 {
-    // WebGLLayer was set as m_contentsLayer, and will get parented in updateSublayerList().
+    // CanvasLayer was set as m_contentsLayer, and will get parented in updateSublayerList().
     if (m_contentsLayer) {
         setupContentsLayer(m_contentsLayer.get());
         [m_contentsLayer.get() setNeedsDisplay];
         updateContentsRect();
     }
 }
-#endif
-    
+
 void GraphicsLayerCA::updateContentsRect()
 {
     if (!m_contentsLayer)
@@ -1722,22 +1718,20 @@ void GraphicsLayerCA::pauseAnimationOnLayer(AnimatedPropertyID property, const S
     }
 }
 
-#if ENABLE(3D_CANVAS)
-void GraphicsLayerCA::setContentsToWebGL(PlatformLayer* webglLayer)
+void GraphicsLayerCA::setContentsToCanvas(PlatformLayer* canvasLayer)
 {
-    if (webglLayer == m_contentsLayer)
+    if (canvasLayer == m_contentsLayer)
         return;
         
-    m_contentsLayer = webglLayer;
+    m_contentsLayer = canvasLayer;
     if (m_contentsLayer && [m_contentsLayer.get() respondsToSelector:@selector(setLayerOwner:)])
         [(id)m_contentsLayer.get() setLayerOwner:this];
     
-    m_contentsLayerPurpose = webglLayer ? ContentsLayerForWebGL : NoContentsLayer;
+    m_contentsLayerPurpose = canvasLayer ? ContentsLayerForCanvas : NoContentsLayer;
 
     noteSublayersChanged();
-    noteLayerPropertyChanged(ContentsWebGLLayerChanged);
+    noteLayerPropertyChanged(ContentsCanvasLayerChanged);
 }
-#endif
     
 void GraphicsLayerCA::repaintLayerDirtyRects()
 {
index 0e5933e..b3a7917 100644 (file)
 #if USE(ACCELERATED_COMPOSITING)
 
 #include "AnimationController.h"
-#if ENABLE(3D_CANVAS)    
-#include "WebGLRenderingContext.h"
-#endif
+#include "CanvasRenderingContext.h"
 #include "CSSPropertyNames.h"
 #include "CSSStyleSelector.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
+#include "GraphicsContext3D.h"
 #include "GraphicsLayer.h"
 #include "HTMLCanvasElement.h"
 #include "HTMLElement.h"
@@ -66,11 +65,14 @@ static bool hasBoxDecorationsOrBackground(const RenderObject*);
 static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle*);
 static IntRect clipBox(RenderBox* renderer);
 
-static inline bool is3DCanvas(RenderObject* renderer)
+static inline bool isAcceleratedCanvas(RenderObject* renderer)
 {
-#if ENABLE(3D_CANVAS)    
-    if (renderer->isCanvas())
-        return static_cast<HTMLCanvasElement*>(renderer->node())->is3D();
+#if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS)
+    if (renderer->isCanvas()) {
+        HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer->node());
+        if (CanvasRenderingContext* context = canvas->renderingContext())
+            return context->isAccelerated();
+    }
 #else
     UNUSED_PARAM(renderer);
 #endif
@@ -252,12 +254,13 @@ bool RenderLayerBacking::updateGraphicsLayerConfiguration()
         m_graphicsLayer->setContentsToMedia(mediaElement->platformLayer());
     }
 #endif
-#if ENABLE(3D_CANVAS)    
-    else if (is3DCanvas(renderer())) {
+#if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS)
+    else if (isAcceleratedCanvas(renderer())) {
         HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer()->node());
-        WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(canvas->renderingContext());
-        if (context->graphicsContext3D()->platformLayer())
-            m_graphicsLayer->setContentsToWebGL(context->graphicsContext3D()->platformLayer());
+        if (CanvasRenderingContext* context = canvas->renderingContext())
+            if (context->graphicsContext3D())
+                if (PlatformLayer* pl = context->graphicsContext3D()->platformLayer())
+                    m_graphicsLayer->setContentsToCanvas(pl);
     }
 #endif
 
@@ -756,8 +759,12 @@ bool RenderLayerBacking::containsPaintedContent() const
 
     // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely,
     // and set background color on the layer in that case, instead of allocating backing store and painting.
-    if (renderer()->isVideo() || is3DCanvas(renderer()))
+    if (renderer()->isVideo())
         return hasBoxDecorationsOrBackground(renderer());
+#if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS)
+    if (isAcceleratedCanvas(renderer()))
+        return hasBoxDecorationsOrBackground(renderer());
+#endif
 
     return true;
 }
@@ -777,8 +784,8 @@ void RenderLayerBacking::rendererContentChanged()
         return;
     }
 
-#if ENABLE(3D_CANVAS)    
-    if (is3DCanvas(renderer())) {
+#if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS)
+    if (isAcceleratedCanvas(renderer())) {
         m_graphicsLayer->setContentsNeedsDisplay();
         return;
     }
index b4102bf..4c68dd7 100644 (file)
@@ -1,3 +1,18 @@
+2010-08-06  James Robinson  <jamesr@chromium.org>
+
+        Reviewed by Simon Fraser.
+
+        Composited canvas should be treated the same by the compositor and not be WebGL specific
+        https://bugs.webkit.org/show_bug.cgi?id=43589
+
+        Initializes the platformLayer as a CanvasLayerChromium, not a WebGLLayerChromium.
+        The layer itself isn't WebGL-specific.
+
+        * src/GraphicsContext3D.cpp:
+        (WebCore::GraphicsContext3DInternal::initialize):
+        (WebCore::GraphicsContext3DInternal::platformLayer):
+        (WebCore::GraphicsContext3D::platformLayer):
+
 2010-08-06  Jessie Berlin  <jberlin@apple.com>
 
         Roll out http://trac.webkit.org/changeset/64801, which broke the Safari Windows Build.
index d6ad1a3..a02872d 100644 (file)
@@ -35,6 +35,7 @@
 #include "GraphicsContext3D.h"
 
 #include "CachedImage.h"
+#include "CanvasLayerChromium.h"
 #include "CanvasRenderingContext.h"
 #include "Chrome.h"
 #include "ChromeClientImpl.h"
@@ -46,7 +47,6 @@
 #include "Int32Array.h"
 #include "Int8Array.h"
 #include "Uint8Array.h"
-#include "WebGLLayerChromium.h"
 #include "WebGraphicsContext3D.h"
 #include "WebGraphicsContext3DDefaultImpl.h"
 #include "WebKit.h"
@@ -111,7 +111,7 @@ public:
     void prepareTexture();
 
 #if USE(ACCELERATED_COMPOSITING)
-    WebGLLayerChromium* platformLayer() const;
+    CanvasLayerChromium* platformLayer() const;
 #endif
     bool isGLES2Compliant() const;
 
@@ -304,7 +304,7 @@ public:
 private:
     OwnPtr<WebKit::WebGraphicsContext3D> m_impl;
 #if USE(ACCELERATED_COMPOSITING)
-    RefPtr<WebGLLayerChromium> m_compositingLayer;
+    RefPtr<CanvasLayerChromium> m_compositingLayer;
 #endif
 #if PLATFORM(SKIA)
     // If the width and height of the Canvas's backing store don't
@@ -365,7 +365,7 @@ bool GraphicsContext3DInternal::initialize(GraphicsContext3D::Attributes attrs,
     m_impl.set(webContext);
 
 #if USE(ACCELERATED_COMPOSITING)
-    m_compositingLayer = WebGLLayerChromium::create(0);
+    m_compositingLayer = CanvasLayerChromium::create(0);
 #endif
     return true;
 }
@@ -386,7 +386,7 @@ void GraphicsContext3DInternal::prepareTexture()
 }
 
 #if USE(ACCELERATED_COMPOSITING)
-WebGLLayerChromium* GraphicsContext3DInternal::platformLayer() const
+CanvasLayerChromium* GraphicsContext3DInternal::platformLayer() const
 {
     return m_compositingLayer.get();
 }
@@ -1046,9 +1046,9 @@ void GraphicsContext3D::prepareTexture()
 #if USE(ACCELERATED_COMPOSITING)
 PlatformLayer* GraphicsContext3D::platformLayer() const
 {
-    WebGLLayerChromium* webGLLayer = m_internal->platformLayer();
-    webGLLayer->setContext(this);
-    return webGLLayer;
+    CanvasLayerChromium* canvasLayer = m_internal->platformLayer();
+    canvasLayer->setContext(this);
+    return canvasLayer;
 }
 #endif