Title: [93988] trunk/Source/WebCore
Revision
93988
Author
[email protected]
Date
2011-08-29 11:16:32 -0700 (Mon, 29 Aug 2011)

Log Message

Skia's accelerated canvas 2D implementation should use GrTexture, not DrawingBuffer
https://bugs.webkit.org/show_bug.cgi?id=67050

Reviewed by Kenneth Russell.

Covered by existing tests.

* platform/graphics/chromium/Canvas2DLayerChromium.cpp:
(WebCore::Canvas2DLayerChromium::create):
(WebCore::Canvas2DLayerChromium::Canvas2DLayerChromium):
(WebCore::Canvas2DLayerChromium::drawsContent):
Construct Canvas2DLayerChromium with a GraphicsContext3D, not a
DrawingBuffer.
(WebCore::Canvas2DLayerChromium::updateCompositorResources):
Flush the GrContext and GraphicsContext3D on compositor update.
* platform/graphics/chromium/Canvas2DLayerChromium.h:
* platform/graphics/chromium/CanvasLayerChromium.cpp:
(WebCore::CanvasLayerChromium::CanvasLayerChromium):
* platform/graphics/chromium/CanvasLayerChromium.h:
Put textureId() back on the base class (CanvasLayerChromium) and
de-virtualize it.
(WebCore::CanvasLayerChromium::textureId):
(WebCore::CanvasLayerChromium::setTextureId):
Move m_textureId from WebGLLayerChromium, since canvas2D now uses
it too.  Provide getters and setters.
* platform/graphics/chromium/DrawingBufferChromium.cpp:
(WebCore::DrawingBuffer::DrawingBuffer):
(WebCore::DrawingBuffer::~DrawingBuffer):
Remove all Canvas2D-related calls from DrawingBuffer.
(WebCore::DrawingBuffer::publishToPlatformLayer):
Remove GrContext::flush call, since it's now handled by the platform layer.
(WebCore::DrawingBuffer::platformLayer):
Return NULL for now (WebGL may rescussitate this later).
* platform/graphics/chromium/GraphicsLayerChromium.cpp:
Remove a useless #include.
* platform/graphics/chromium/ImageBufferDataSkia.h:
Add ownership of the Canvas2DLayerChromium.
* platform/graphics/chromium/WebGLLayerChromium.cpp:
(WebCore::WebGLLayerChromium::WebGLLayerChromium):
* platform/graphics/chromium/WebGLLayerChromium.h:
Remove all texture ID stuff (now on base class).
* platform/graphics/gpu/DrawingBuffer.h:
Remove Canvas2DLayerChromium and all Ganesh datatypes from
DrawingBuffer, since it's no longer used by canvas2D.
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::ImageBuffer::ImageBuffer):
On accelerated ImageBuffer creation, create a GrTexture instead of a
DrawingBuffer.  If all is cool, create and set the SkGpuDevice here,
and create a Canvas2DLayerChromium platform layer.
(WebCore::ImageBuffer::platformLayer):
* platform/graphics/skia/PlatformContextSkia.cpp:
(WebCore::PlatformContextSkia::setGraphicsContext3D):
* platform/graphics/skia/PlatformContextSkia.h:
Remove all GrContext creation and DrawingBuffer "scraping" from 
PlatformContextSkia::setGraphicsContext3D().  This is handled in
the ImageBuffer constructor instead.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (93987 => 93988)


--- trunk/Source/WebCore/ChangeLog	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/ChangeLog	2011-08-29 18:16:32 UTC (rev 93988)
@@ -1,3 +1,62 @@
+2011-08-29  Stephen White  <[email protected]>
+
+        Skia's accelerated canvas 2D implementation should use GrTexture, not DrawingBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=67050
+
+        Reviewed by Kenneth Russell.
+
+        Covered by existing tests.
+
+        * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
+        (WebCore::Canvas2DLayerChromium::create):
+        (WebCore::Canvas2DLayerChromium::Canvas2DLayerChromium):
+        (WebCore::Canvas2DLayerChromium::drawsContent):
+        Construct Canvas2DLayerChromium with a GraphicsContext3D, not a
+        DrawingBuffer.
+        (WebCore::Canvas2DLayerChromium::updateCompositorResources):
+        Flush the GrContext and GraphicsContext3D on compositor update.
+        * platform/graphics/chromium/Canvas2DLayerChromium.h:
+        * platform/graphics/chromium/CanvasLayerChromium.cpp:
+        (WebCore::CanvasLayerChromium::CanvasLayerChromium):
+        * platform/graphics/chromium/CanvasLayerChromium.h:
+        Put textureId() back on the base class (CanvasLayerChromium) and
+        de-virtualize it.
+        (WebCore::CanvasLayerChromium::textureId):
+        (WebCore::CanvasLayerChromium::setTextureId):
+        Move m_textureId from WebGLLayerChromium, since canvas2D now uses
+        it too.  Provide getters and setters.
+        * platform/graphics/chromium/DrawingBufferChromium.cpp:
+        (WebCore::DrawingBuffer::DrawingBuffer):
+        (WebCore::DrawingBuffer::~DrawingBuffer):
+        Remove all Canvas2D-related calls from DrawingBuffer.
+        (WebCore::DrawingBuffer::publishToPlatformLayer):
+        Remove GrContext::flush call, since it's now handled by the platform layer.
+        (WebCore::DrawingBuffer::platformLayer):
+        Return NULL for now (WebGL may rescussitate this later).
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        Remove a useless #include.
+        * platform/graphics/chromium/ImageBufferDataSkia.h:
+        Add ownership of the Canvas2DLayerChromium.
+        * platform/graphics/chromium/WebGLLayerChromium.cpp:
+        (WebCore::WebGLLayerChromium::WebGLLayerChromium):
+        * platform/graphics/chromium/WebGLLayerChromium.h:
+        Remove all texture ID stuff (now on base class).
+        * platform/graphics/gpu/DrawingBuffer.h:
+        Remove Canvas2DLayerChromium and all Ganesh datatypes from
+        DrawingBuffer, since it's no longer used by canvas2D.
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        On accelerated ImageBuffer creation, create a GrTexture instead of a
+        DrawingBuffer.  If all is cool, create and set the SkGpuDevice here,
+        and create a Canvas2DLayerChromium platform layer.
+        (WebCore::ImageBuffer::platformLayer):
+        * platform/graphics/skia/PlatformContextSkia.cpp:
+        (WebCore::PlatformContextSkia::setGraphicsContext3D):
+        * platform/graphics/skia/PlatformContextSkia.h:
+        Remove all GrContext creation and DrawingBuffer "scraping" from 
+        PlatformContextSkia::setGraphicsContext3D().  This is handled in
+        the ImageBuffer constructor instead.
+
 2011-08-26  Alexey Proskuryakov  <[email protected]>
 
         DumpRenderTree should begin each test with an empty cookie store

Modified: trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp	2011-08-29 18:16:32 UTC (rev 93988)
@@ -34,21 +34,23 @@
 
 #include "Canvas2DLayerChromium.h"
 
-#include "DrawingBuffer.h"
 #include "Extensions3DChromium.h"
 #include "GraphicsContext3D.h"
-#include "LayerRendererChromium.h"
 
+#if USE(SKIA)
+#include "GrContext.h"
+#endif
+
 namespace WebCore {
 
-PassRefPtr<Canvas2DLayerChromium> Canvas2DLayerChromium::create(DrawingBuffer* drawingBuffer, GraphicsLayerChromium* owner)
+PassRefPtr<Canvas2DLayerChromium> Canvas2DLayerChromium::create(GraphicsContext3D* context)
 {
-    return adoptRef(new Canvas2DLayerChromium(drawingBuffer, owner));
+    return adoptRef(new Canvas2DLayerChromium(context));
 }
 
-Canvas2DLayerChromium::Canvas2DLayerChromium(DrawingBuffer* drawingBuffer, GraphicsLayerChromium* owner)
-    : CanvasLayerChromium(owner)
-    , m_drawingBuffer(drawingBuffer)
+Canvas2DLayerChromium::Canvas2DLayerChromium(GraphicsContext3D* context)
+    : CanvasLayerChromium(0)
+    , m_context(context)
 {
 }
 
@@ -58,32 +60,29 @@
 
 bool Canvas2DLayerChromium::drawsContent() const
 {
-    GraphicsContext3D* context;
-    return (m_drawingBuffer
-            && (context = m_drawingBuffer->graphicsContext3D().get())
-            && (context->getExtensions()->getGraphicsResetStatusARB() == GraphicsContext3D::NO_ERROR));
+    return (m_context
+            && (m_context->getExtensions()->getGraphicsResetStatusARB() == GraphicsContext3D::NO_ERROR));
 }
 
 void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*)
 {
     if (!m_contentsDirty || !drawsContent())
         return;
-    // Update the contents of the texture used by the compositor.
+
     if (m_contentsDirty) {
-        m_drawingBuffer->publishToPlatformLayer();
+        if (m_context) {
+#if USE(SKIA)
+            GrContext* grContext = m_context->grContext();
+            if (grContext) {
+                m_context->makeContextCurrent();
+                grContext->flush();
+            }
+#endif
+            m_context->flush();
+        }
         m_contentsDirty = false;
     }
 }
 
-unsigned Canvas2DLayerChromium::textureId() const
-{
-    return m_drawingBuffer ? m_drawingBuffer->platformColorBuffer() : 0;
 }
-
-void Canvas2DLayerChromium::setDrawingBuffer(DrawingBuffer* drawingBuffer)
-{
-    m_drawingBuffer = drawingBuffer;
-}
-
-}
 #endif // USE(ACCELERATED_COMPOSITING)

Modified: trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h	2011-08-29 18:16:32 UTC (rev 93988)
@@ -38,23 +38,21 @@
 
 namespace WebCore {
 
-class DrawingBuffer;
+class GraphicsContext3D;
 
 // A layer containing an accelerated 2d canvas
 class Canvas2DLayerChromium : public CanvasLayerChromium {
 public:
-    static PassRefPtr<Canvas2DLayerChromium> create(DrawingBuffer*, GraphicsLayerChromium* owner);
+    static PassRefPtr<Canvas2DLayerChromium> create(GraphicsContext3D*);
     virtual ~Canvas2DLayerChromium();
     virtual bool drawsContent() const;
     virtual void updateCompositorResources(GraphicsContext3D*);
 
     void setTextureChanged();
-    virtual unsigned textureId() const;
-    void setDrawingBuffer(DrawingBuffer*);
 
 private:
-    explicit Canvas2DLayerChromium(DrawingBuffer*, GraphicsLayerChromium* owner);
-    DrawingBuffer* m_drawingBuffer;
+    explicit Canvas2DLayerChromium(GraphicsContext3D*);
+    GraphicsContext3D* m_context;
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp	2011-08-29 18:16:32 UTC (rev 93988)
@@ -44,6 +44,7 @@
     : LayerChromium(owner)
     , m_hasAlpha(true)
     , m_premultipliedAlpha(true)
+    , m_textureId(0)
 {
 }
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.h (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.h	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.h	2011-08-29 18:16:32 UTC (rev 93988)
@@ -46,15 +46,17 @@
     virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
 
     virtual void pushPropertiesTo(CCLayerImpl*);
+    unsigned textureId() const { return m_textureId; }
+    void setTextureId(unsigned textureId) { m_textureId = textureId; }
 
 protected:
     explicit CanvasLayerChromium(GraphicsLayerChromium* owner);
 
-    virtual unsigned textureId() const = 0;
     virtual const char* layerTypeAsString() const { return "CanvasLayer"; }
 
     bool m_hasAlpha;
     bool m_premultipliedAlpha;
+    unsigned m_textureId;
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp	2011-08-29 18:16:32 UTC (rev 93988)
@@ -33,14 +33,7 @@
 #include "DrawingBuffer.h"
 
 #include "GraphicsContext3D.h"
-#if USE(SKIA)
-#include "GrContext.h"
-#endif
 
-#if USE(ACCELERATED_COMPOSITING)
-#include "Canvas2DLayerChromium.h"
-#endif
-
 namespace WebCore {
 
 static unsigned generateColorTexture(GraphicsContext3D* context, const IntSize& size)
@@ -75,9 +68,6 @@
     , m_stencilBuffer(0)
     , m_multisampleFBO(0)
     , m_multisampleColorBuffer(0)
-#if USE(SKIA)
-    , m_grContext(0)
-#endif
 {
     m_fbo = context->createFramebuffer();
     context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
@@ -91,11 +81,6 @@
 
 DrawingBuffer::~DrawingBuffer()
 {
-#if USE(ACCELERATED_COMPOSITING)
-    if (m_platformLayer)
-        m_platformLayer->setDrawingBuffer(0);
-#endif
-
     if (!m_context)
         return;
 
@@ -111,10 +96,6 @@
     if (multisample())
         commit();
     m_context->makeContextCurrent();
-#if USE(SKIA)
-    if (m_grContext)
-        m_grContext->flush(0);
-#endif
     m_context->flush();
 }
 #endif
@@ -122,9 +103,7 @@
 #if USE(ACCELERATED_COMPOSITING)
 PlatformLayer* DrawingBuffer::platformLayer()
 {
-    if (!m_platformLayer)
-        m_platformLayer = Canvas2DLayerChromium::create(this, 0);
-    return m_platformLayer.get();
+    return 0;
 }
 #endif
 
@@ -133,36 +112,4 @@
     return m_colorBuffer;
 }
 
-#if USE(SKIA)
-void DrawingBuffer::setGrContext(GrContext* context)
-{
-    // We just take a ptr without referencing it, as we require that we never outlive
-    // the GraphicsContext3D object that is giving us the context.
-    m_grContext = context;
 }
-
-void DrawingBuffer::getGrPlatformSurfaceDesc(GrPlatformSurfaceDesc* desc)
-{
-    desc->fSurfaceType = kTextureRenderTarget_GrPlatformSurfaceType;
-
-    desc->fPlatformTexture = m_colorBuffer;
-    if (multisample()) {
-        desc->fRenderTargetFlags = kIsMultisampled_GrPlatformRenderTargetFlagBit | kGrCanResolve_GrPlatformRenderTargetFlagBit;
-        desc->fPlatformRenderTarget = m_multisampleFBO;
-        desc->fPlatformResolveDestination = m_fbo;
-    } else {
-        desc->fRenderTargetFlags = kNone_GrPlatformRenderTargetFlagBit;
-        desc->fPlatformRenderTarget = m_fbo;
-        desc->fPlatformResolveDestination = 0;
-    }
-
-    desc->fWidth = m_size.width();
-    desc->fHeight = m_size.height();
-    desc->fConfig = kRGBA_8888_GrPixelConfig;
-
-    desc->fStencilBits = (m_depthStencilBuffer || m_stencilBuffer) ? 8 : 0;
-}
-
-#endif
-
-}

Modified: trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2011-08-29 18:16:32 UTC (rev 93988)
@@ -47,7 +47,6 @@
 
 #include "Canvas2DLayerChromium.h"
 #include "ContentLayerChromium.h"
-#include "DrawingBuffer.h"
 #include "FloatConversion.h"
 #include "FloatRect.h"
 #include "Image.h"

Modified: trunk/Source/WebCore/platform/graphics/chromium/ImageBufferDataSkia.h (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/chromium/ImageBufferDataSkia.h	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/chromium/ImageBufferDataSkia.h	2011-08-29 18:16:32 UTC (rev 93988)
@@ -28,20 +28,25 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "DrawingBuffer.h"
 #include "PlatformContextSkia.h"
 
 #include "skia/ext/platform_canvas.h"
 
 namespace WebCore {
 
+#if USE(ACCELERATED_COMPOSITING)
+class Canvas2DLayerChromium;
+#endif
+
 class ImageBufferData {
 public:
     ImageBufferData(const IntSize&);
 
     OwnPtr<SkCanvas> m_canvas;
     PlatformContextSkia m_platformContext;
-    RefPtr<DrawingBuffer> m_drawingBuffer;
+#if USE(ACCELERATED_COMPOSITING)
+    RefPtr<Canvas2DLayerChromium> m_platformLayer;
+#endif
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp	2011-08-29 18:16:32 UTC (rev 93988)
@@ -49,7 +49,6 @@
 WebGLLayerChromium::WebGLLayerChromium(GraphicsLayerChromium* owner)
     : CanvasLayerChromium(owner)
     , m_context(0)
-    , m_textureId(0)
     , m_textureChanged(true)
     , m_contextSupportsRateLimitingExtension(false)
     , m_rateLimitingTimer(this, &WebGLLayerChromium::rateLimitContext)

Modified: trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h	2011-08-29 18:16:32 UTC (rev 93988)
@@ -64,14 +64,12 @@
     explicit WebGLLayerChromium(GraphicsLayerChromium* owner);
     friend class WebGLLayerChromiumRateLimitTask;
 
-    virtual unsigned textureId() const { return m_textureId; }
     void rateLimitContext(Timer<WebGLLayerChromium>*);
 
     // GraphicsContext3D::platformLayer has a side-effect of assigning itself
     // to the layer. Because of that GraphicsContext3D's destructor will reset
     // layer's context to 0.
     GraphicsContext3D* m_context;
-    unsigned m_textureId;
     bool m_textureChanged;
     bool m_contextSupportsRateLimitingExtension;
     Timer<WebGLLayerChromium> m_rateLimitingTimer;

Modified: trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h	2011-08-29 18:16:32 UTC (rev 93988)
@@ -42,11 +42,6 @@
 #include <wtf/RetainPtr.h>
 #endif
 
-#if USE(SKIA)
-class GrContext;
-struct GrPlatformSurfaceDesc;
-#endif
-
 namespace WebCore {
 
 #if PLATFORM(CHROMIUM) && USE(ACCELERATED_COMPOSITING)
@@ -90,11 +85,6 @@
     void publishToPlatformLayer();
 #endif
 
-#if USE(SKIA)
-    void setGrContext(GrContext* ctx);
-    void getGrPlatformSurfaceDesc(GrPlatformSurfaceDesc*);
-#endif
-
     PassRefPtr<GraphicsContext3D> graphicsContext3D() const { return m_context; }
 
 private:
@@ -120,19 +110,9 @@
     Platform3DObject m_multisampleFBO;
     Platform3DObject m_multisampleColorBuffer;
 
-#if PLATFORM(CHROMIUM)
-#if USE(ACCELERATED_COMPOSITING)
-    RefPtr<Canvas2DLayerChromium> m_platformLayer;
-#endif
-#endif
-
 #if PLATFORM(MAC)
     RetainPtr<WebGLLayer> m_platformLayer;
 #endif
-
-#if USE(SKIA)
-    GrContext* m_grContext;
-#endif
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2011-08-29 18:16:32 UTC (rev 93988)
@@ -36,7 +36,8 @@
 #include "Base64.h"
 #include "BitmapImage.h"
 #include "BitmapImageSingleFrameSkia.h"
-#include "DrawingBuffer.h"
+#include "Canvas2DLayerChromium.h"
+#include "GrContext.h"
 #include "GraphicsContext.h"
 #include "ImageData.h"
 #include "JPEGImageEncoder.h"
@@ -45,6 +46,7 @@
 #include "PlatformContextSkia.h"
 #include "SharedGraphicsContext3D.h"
 #include "SkColorPriv.h"
+#include "SkGpuDevice.h"
 #include "SkiaUtils.h"
 
 #include <wtf/text/WTFString.h>
@@ -83,12 +85,29 @@
     // color. Can we have another way to manage this?
     m_data.m_canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
     if (renderingMode == Accelerated) {
-        m_accelerateRendering = true;
         GraphicsContext3D* context3D = SharedGraphicsContext3D::create(0);
         if (context3D) {
-            m_data.m_drawingBuffer = context3D->createDrawingBuffer(size);
-            if (m_data.m_drawingBuffer)
-                m_data.m_platformContext.setGraphicsContext3D(context3D, m_data.m_drawingBuffer.get());
+            context3D->makeContextCurrent();
+            GrContext* gr = context3D->grContext();
+            if (gr) {
+                gr->resetContext();
+                GrTextureDesc desc;
+                desc.fFlags = kRenderTarget_GrTextureFlagBit;
+                desc.fAALevel = kNone_GrAALevel;
+                desc.fWidth = size.width();
+                desc.fHeight = size.height();
+                desc.fFormat = kRGBA_8888_GrPixelConfig;
+                SkAutoTUnref<GrTexture> texture(gr->createUncachedTexture(desc, 0, 0));
+                if (texture.get()) {
+                    m_data.m_canvas->setDevice(new SkGpuDevice(gr, texture.get()))->unref();
+                    m_context->platformContext()->setGraphicsContext3D(context3D);
+                    m_accelerateRendering = true;
+#if USE(ACCELERATED_COMPOSITING)
+                    m_data.m_platformLayer = Canvas2DLayerChromium::create(context3D);
+                    m_data.m_platformLayer->setTextureId(texture.get()->getTextureHandle());
+#endif
+                }
+            }
         }
     }
 
@@ -380,7 +399,7 @@
 
 PlatformLayer* ImageBuffer::platformLayer() const
 {
-    return m_data.m_drawingBuffer ? m_data.m_drawingBuffer->platformLayer() : 0;
+    return m_data.m_platformLayer.get();
 }
 
 String ImageDataToDataURL(const ImageData& source, const String& mimeType, const double* quality)

Modified: trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	2011-08-29 18:16:32 UTC (rev 93988)
@@ -33,7 +33,6 @@
 #include "PlatformContextSkia.h"
 
 #include "AffineTransform.h"
-#include "DrawingBuffer.h"
 #include "Extensions3D.h"
 #include "GraphicsContext.h"
 #include "GraphicsContext3D.h"
@@ -660,28 +659,9 @@
     m_canvas->restore();
 }
 
-void PlatformContextSkia::setGraphicsContext3D(GraphicsContext3D* context, DrawingBuffer* drawingBuffer)
+void PlatformContextSkia::setGraphicsContext3D(GraphicsContext3D* context)
 {
     m_gpuContext = context;
-#if ENABLE(ACCELERATED_2D_CANVAS)
-    if (context && drawingBuffer) {
-        // use skia gpu rendering if available
-        GrContext* gr = context->grContext();
-        if (gr) {
-            context->makeContextCurrent();
-            drawingBuffer->bind();
-
-            gr->resetContext();
-            drawingBuffer->setGrContext(gr);
-
-            GrPlatformSurfaceDesc drawBufDesc;
-            drawingBuffer->getGrPlatformSurfaceDesc(&drawBufDesc);
-            SkAutoTUnref<GrTexture> drawBufTex(static_cast<GrTexture*>(gr->createPlatformSurface(drawBufDesc)));
-            m_canvas->setDevice(new SkGpuDevice(gr, drawBufTex.get()))->unref();
-        } else
-            m_gpuContext = 0;
-    }
-#endif
 }
 
 void PlatformContextSkia::makeGrContextCurrent()

Modified: trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h (93987 => 93988)


--- trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h	2011-08-29 18:15:38 UTC (rev 93987)
+++ trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h	2011-08-29 18:16:32 UTC (rev 93988)
@@ -45,7 +45,6 @@
 namespace WebCore {
 
 enum CompositeOperator;
-class DrawingBuffer;
 class GraphicsContext3D;
 class Texture;
 
@@ -179,7 +178,7 @@
     bool hasImageResamplingHint() const;
 
     bool isAccelerated() const { return m_gpuContext; }
-    void setGraphicsContext3D(GraphicsContext3D*, DrawingBuffer*);
+    void setGraphicsContext3D(GraphicsContext3D*);
     void makeGrContextCurrent();
 
 private:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to