Title: [103309] trunk/Source/WebCore
Revision
103309
Author
al...@chromium.org
Date
2011-12-20 00:39:07 -0800 (Tue, 20 Dec 2011)

Log Message

[chromium] compositing/shadows tests fail with accelerated painting
https://bugs.webkit.org/show_bug.cgi?id=74871

Reviewed by James Robinson.

Switched over to new API for creating accelerated canvas GrContext::createPlatformTexture.
It correctly binds the stencil buffer to the FBO.

Test: compositing/shadows/shadow-drawing.html (existing)

* platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp:
(WebCore::createAcceleratedCanvas):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):
* platform/graphics/chromium/ManagedTexture.cpp:
(WebCore::ManagedTexture::allocate):
(WebCore::ManagedTexture::bindTexture):
(WebCore::ManagedTexture::framebufferTexture2D):
* platform/graphics/chromium/ManagedTexture.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (103308 => 103309)


--- trunk/Source/WebCore/ChangeLog	2011-12-20 08:00:53 UTC (rev 103308)
+++ trunk/Source/WebCore/ChangeLog	2011-12-20 08:39:07 UTC (rev 103309)
@@ -1,3 +1,24 @@
+2011-12-20  Alok Priyadarshi  <al...@chromium.org>
+
+        [chromium] compositing/shadows tests fail with accelerated painting
+        https://bugs.webkit.org/show_bug.cgi?id=74871
+
+        Reviewed by James Robinson.
+        
+        Switched over to new API for creating accelerated canvas GrContext::createPlatformTexture.
+        It correctly binds the stencil buffer to the FBO.
+
+        Test: compositing/shadows/shadow-drawing.html (existing)
+
+        * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp:
+        (WebCore::createAcceleratedCanvas):
+        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):
+        * platform/graphics/chromium/ManagedTexture.cpp:
+        (WebCore::ManagedTexture::allocate):
+        (WebCore::ManagedTexture::bindTexture):
+        (WebCore::ManagedTexture::framebufferTexture2D):
+        * platform/graphics/chromium/ManagedTexture.h:
+
 2011-12-20  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r103291.

Modified: trunk/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp (103308 => 103309)


--- trunk/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp	2011-12-20 08:00:53 UTC (rev 103308)
+++ trunk/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp	2011-12-20 08:39:07 UTC (rev 103309)
@@ -37,64 +37,26 @@
 
 namespace WebCore {
 
-namespace {
-
-class FrameBuffer {
-public:
-    FrameBuffer();
-    ~FrameBuffer();
-
-    SkCanvas* initialize(GraphicsContext3D*, TextureAllocator*, ManagedTexture*);
-
-private:
-    GraphicsContext3D* m_context;
-    Platform3DObject m_fbo;
-    OwnPtr<SkCanvas> m_canvas;
-};
-
-FrameBuffer::FrameBuffer()
-    : m_context(0)
-    , m_fbo(0)
+static PassOwnPtr<SkCanvas> createAcceleratedCanvas(GraphicsContext3D* context,
+                                                    TextureAllocator* allocator,
+                                                    ManagedTexture* texture)
 {
-}
+    // Allocate so that we have a valid texture id.
+    texture->allocate(allocator);
 
-FrameBuffer::~FrameBuffer()
-{
-    m_canvas.clear();
-
-    if (m_fbo)
-        m_context->deleteFramebuffer(m_fbo);
-}
-
-SkCanvas* FrameBuffer::initialize(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture)
-{
-    m_context = context;
-    m_fbo = m_context->createFramebuffer();
-    m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
-    texture->framebufferTexture2D(m_context, allocator);
-
-    // Create a skia gpu canvas.
-    GrContext* grContext = m_context->grContext();
+    GrContext* grContext = context->grContext();
     IntSize canvasSize = texture->size();
-    GrPlatformSurfaceDesc targetDesc;
-    targetDesc.reset();
-    targetDesc.fSurfaceType = kTextureRenderTarget_GrPlatformSurfaceType;
-    targetDesc.fRenderTargetFlags = kNone_GrPlatformRenderTargetFlagBit;
-    targetDesc.fWidth = canvasSize.width();
-    targetDesc.fHeight = canvasSize.height();
-    targetDesc.fConfig = kRGBA_8888_GrPixelConfig;
-    targetDesc.fStencilBits = 8;
-    targetDesc.fPlatformTexture = texture->textureId();
-    targetDesc.fPlatformRenderTarget = m_fbo;
-    SkAutoTUnref<GrTexture> target(static_cast<GrTexture*>(grContext->createPlatformSurface(targetDesc)));
+    GrPlatformTextureDesc textureDesc;
+    textureDesc.fFlags = kRenderTarget_GrPlatformTextureFlag;
+    textureDesc.fWidth = canvasSize.width();
+    textureDesc.fHeight = canvasSize.height();
+    textureDesc.fConfig = kRGBA_8888_GrPixelConfig;
+    textureDesc.fTextureHandle = texture->textureId();
+    SkAutoTUnref<GrTexture> target(grContext->createPlatformTexture(textureDesc));
     SkAutoTUnref<SkDevice> device(new SkGpuDevice(grContext, target.get()));
-    m_canvas = adoptPtr(new SkCanvas(device.get()));
-
-    return m_canvas.get();
+    return adoptPtr(new SkCanvas(device.get()));
 }
 
-} // namespace
-
 FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::Texture(FrameBufferSkPictureCanvasLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture)
     : LayerTextureUpdater::Texture(texture)
     , m_textureUpdater(textureUpdater)
@@ -143,8 +105,7 @@
     context->grContext()->resetContext();
 
     // Create an accelerated canvas to draw on.
-    FrameBuffer buffer;
-    SkCanvas* canvas = buffer.initialize(context, allocator, texture);
+    OwnPtr<SkCanvas> canvas = createAcceleratedCanvas(context, allocator, texture);
 
     canvas->clipRect(SkRect(destRect));
     // The compositor expects the textures to be upside-down so it can flip
@@ -156,7 +117,7 @@
     // Note that destRect is defined relative to sourceRect.
     canvas->translate(contentRect().x() - sourceRect.x() + destRect.x(),
                       contentRect().y() - sourceRect.y() + destRect.y());
-    drawPicture(canvas);
+    drawPicture(canvas.get());
 
     // Flush SKIA context so that all the rendered stuff appears on the texture.
     context->grContext()->flush();

Modified: trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp (103308 => 103309)


--- trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp	2011-12-20 08:00:53 UTC (rev 103308)
+++ trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp	2011-12-20 08:39:07 UTC (rev 103309)
@@ -80,19 +80,22 @@
     m_textureManager->unprotectTexture(m_token);
 }
 
-void ManagedTexture::bindTexture(GraphicsContext3D* context, TextureAllocator* allocator)
+void ManagedTexture::allocate(TextureAllocator* allocator)
 {
     ASSERT(m_textureManager->hasTexture(m_token));
     if (!m_textureId)
         m_textureId = m_textureManager->allocateTexture(allocator, m_token);
+}
+
+void ManagedTexture::bindTexture(GraphicsContext3D* context, TextureAllocator* allocator)
+{
+    allocate(allocator);
     context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId);
 }
 
 void ManagedTexture::framebufferTexture2D(GraphicsContext3D* context, TextureAllocator* allocator)
 {
-    ASSERT(m_textureManager->hasTexture(m_token));
-    if (!m_textureId)
-        m_textureId = m_textureManager->allocateTexture(allocator, m_token);
+    allocate(allocator);
     context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_textureId, 0);
 }
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.h (103308 => 103309)


--- trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.h	2011-12-20 08:00:53 UTC (rev 103308)
+++ trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.h	2011-12-20 08:39:07 UTC (rev 103309)
@@ -55,6 +55,7 @@
         return m_textureManager->isProtected(m_token);
     }
 
+    void allocate(TextureAllocator*);
     void bindTexture(GraphicsContext3D*, TextureAllocator*);
     void framebufferTexture2D(GraphicsContext3D*, TextureAllocator*);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to