[chromium] Move paintRenderedResultsToCanvas code into DrawingBuffer
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Apr 2012 05:36:46 +0000 (05:36 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Apr 2012 05:36:46 +0000 (05:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84066

Patch by James Robinson <jamesr@chromium.org> on 2012-04-16
Reviewed by Adrienne Walker.

WebGLLayerChromium used to be responsible for the readback path for software painting WebGL canvases (for
printing, etc), but this path no longer has any compositor interaction. This moves the code into
DrawingBufferChromium which is responsible for managing the front / back buffers for WebGL.

* platform/graphics/chromium/DrawingBufferChromium.cpp:
(WebCore::DrawingBuffer::paintCompositedResultsToCanvas):
* platform/graphics/chromium/WebGLLayerChromium.cpp:
* platform/graphics/chromium/WebGLLayerChromium.h:
(WebGLLayerChromium):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp
Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h

index 314c2fd..c1d5dcf 100644 (file)
@@ -1,3 +1,20 @@
+2012-04-16  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Move paintRenderedResultsToCanvas code into DrawingBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=84066
+
+        Reviewed by Adrienne Walker.
+
+        WebGLLayerChromium used to be responsible for the readback path for software painting WebGL canvases (for
+        printing, etc), but this path no longer has any compositor interaction. This moves the code into
+        DrawingBufferChromium which is responsible for managing the front / back buffers for WebGL.
+
+        * platform/graphics/chromium/DrawingBufferChromium.cpp:
+        (WebCore::DrawingBuffer::paintCompositedResultsToCanvas):
+        * platform/graphics/chromium/WebGLLayerChromium.cpp:
+        * platform/graphics/chromium/WebGLLayerChromium.h:
+        (WebGLLayerChromium):
+
 2012-04-16  Dana Jansens  <danakj@chromium.org>
 
         [chromium] Expose compositor filters to Aura through WebLayer
index 61576fc..4cd8942 100644 (file)
@@ -169,8 +169,26 @@ Platform3DObject DrawingBuffer::framebuffer() const
 #if USE(ACCELERATED_COMPOSITING)
 void DrawingBuffer::paintCompositedResultsToCanvas(CanvasRenderingContext* context)
 {
-    if (m_platformLayer)
-        m_platformLayer->paintRenderedResultsToCanvas(context->canvas()->buffer());
+    if (!m_context->makeContextCurrent() || m_context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR)
+        return;
+
+    IntSize framebufferSize = m_context->getInternalFramebufferSize();
+
+    // Since we're using the same context as WebGL, we have to restore any state we change (in this case, just the framebuffer binding).
+    // FIXME: The WebGLRenderingContext tracks the current framebuffer binding, it would be slightly more efficient to use this value
+    // rather than querying it off of the context.
+    GC3Dint previousFramebuffer = 0;
+    m_context->getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &previousFramebuffer);
+
+    Platform3DObject framebuffer = m_context->createFramebuffer();
+    m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, framebuffer);
+    m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, frontColorBuffer(), 0);
+
+    Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
+    extensions->paintFramebufferToCanvas(framebuffer, framebufferSize.width(), framebufferSize.height(), !m_context->getContextAttributes().premultipliedAlpha, context->canvas()->buffer());
+    m_context->deleteFramebuffer(framebuffer);
+
+    m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, previousFramebuffer);
 }
 #endif
 
index 20ff5e1..2cf9e38 100644 (file)
@@ -98,31 +98,6 @@ void WebGLLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
     textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
 }
 
-bool WebGLLayerChromium::paintRenderedResultsToCanvas(ImageBuffer* imageBuffer)
-{
-    if (!m_drawingBuffer || !drawsContent())
-        return false;
-
-    IntSize framebufferSize = context()->getInternalFramebufferSize();
-
-    // Since we're using the same context as WebGL, we have to restore any state we change (in this case, just the framebuffer binding).
-    // FIXME: The WebGLRenderingContext tracks the current framebuffer binding, it would be slightly more efficient to use this value
-    // rather than querying it off of the context.
-    GC3Dint previousFramebuffer = 0;
-    context()->getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &previousFramebuffer);
-
-    Platform3DObject framebuffer = context()->createFramebuffer();
-    context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, framebuffer);
-    context()->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_textureId, 0);
-
-    Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context()->getExtensions());
-    extensions->paintFramebufferToCanvas(framebuffer, framebufferSize.width(), framebufferSize.height(), !context()->getContextAttributes().premultipliedAlpha, imageBuffer);
-    context()->deleteFramebuffer(framebuffer);
-
-    context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, previousFramebuffer);
-    return true;
-}
-
 void WebGLLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
 {
     LayerChromium::setNeedsDisplayRect(dirtyRect);
index f295fb8..b15f563 100644 (file)
@@ -53,7 +53,6 @@ public:
     virtual void update(CCTextureUpdater&, const CCOcclusionTracker*) OVERRIDE;
     virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE;
     virtual void setNeedsDisplayRect(const FloatRect&) OVERRIDE;
-    bool paintRenderedResultsToCanvas(ImageBuffer*);
 
     GraphicsContext3D* context() const;