Title: [110118] trunk/Source/WebCore
Revision
110118
Author
commit-qu...@webkit.org
Date
2012-03-07 15:55:39 -0800 (Wed, 07 Mar 2012)

Log Message

[chromium] Support printing WebGL content in threaded compositor
https://bugs.webkit.org/show_bug.cgi?id=80464

Patch by James Robinson <jam...@chromium.org> on 2012-03-07
Reviewed by Kenneth Russell.

Do the readback on the WebGL context instead of the compositor's context since we cannot use the latter from the
main thread. Since we're on the WebGL context, we have to be careful to restore any state we change.

Tested printing manually with threaded compositing enabled.

* platform/graphics/chromium/WebGLLayerChromium.cpp:
(WebCore::WebGLLayerChromium::paintRenderedResultsToCanvas):
* platform/graphics/chromium/WebGLLayerChromium.h:
(WebGLLayerChromium):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110117 => 110118)


--- trunk/Source/WebCore/ChangeLog	2012-03-07 23:34:28 UTC (rev 110117)
+++ trunk/Source/WebCore/ChangeLog	2012-03-07 23:55:39 UTC (rev 110118)
@@ -1,3 +1,20 @@
+2012-03-07  James Robinson  <jam...@chromium.org>
+
+        [chromium] Support printing WebGL content in threaded compositor
+        https://bugs.webkit.org/show_bug.cgi?id=80464
+
+        Reviewed by Kenneth Russell.
+
+        Do the readback on the WebGL context instead of the compositor's context since we cannot use the latter from the
+        main thread. Since we're on the WebGL context, we have to be careful to restore any state we change.
+
+        Tested printing manually with threaded compositing enabled.
+
+        * platform/graphics/chromium/WebGLLayerChromium.cpp:
+        (WebCore::WebGLLayerChromium::paintRenderedResultsToCanvas):
+        * platform/graphics/chromium/WebGLLayerChromium.h:
+        (WebGLLayerChromium):
+
 2012-03-07  Adam Barth  <aba...@webkit.org>
 
         Remove #define private public from WebCache.cpp

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


--- trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp	2012-03-07 23:34:28 UTC (rev 110117)
+++ trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp	2012-03-07 23:55:39 UTC (rev 110118)
@@ -108,20 +108,26 @@
 
 bool WebGLLayerChromium::paintRenderedResultsToCanvas(ImageBuffer* imageBuffer)
 {
-    if (m_textureUpdated || !layerRendererContext() || !drawsContent())
+    if (m_textureUpdated || !m_drawingBuffer || !drawsContent())
         return false;
 
     IntSize framebufferSize = context()->getInternalFramebufferSize();
-    ASSERT(layerRendererContext());
 
-    // This would ideally be done in the webgl context, but that isn't possible yet.
-    Platform3DObject framebuffer = layerRendererContext()->createFramebuffer();
-    layerRendererContext()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, framebuffer);
-    layerRendererContext()->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_textureId, 0);
+    // 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);
 
-    Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(layerRendererContext()->getExtensions());
+    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);
-    layerRendererContext()->deleteFramebuffer(framebuffer);
+    context()->deleteFramebuffer(framebuffer);
+
+    context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, previousFramebuffer);
     return true;
 }
 
@@ -173,15 +179,6 @@
     return 0;
 }
 
-GraphicsContext3D* WebGLLayerChromium::layerRendererContext()
-{
-    // FIXME: In the threaded case, paintRenderedResultsToCanvas must be
-    // refactored to be asynchronous. Currently this is unimplemented.
-    if (!layerTreeHost() || CCProxy::hasImplThread())
-        return 0;
-    return layerTreeHost()->context();
 }
 
-}
-
 #endif // USE(ACCELERATED_COMPOSITING)

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


--- trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h	2012-03-07 23:34:28 UTC (rev 110117)
+++ trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h	2012-03-07 23:55:39 UTC (rev 110118)
@@ -67,8 +67,6 @@
     WebGLLayerChromium();
     friend class WebGLLayerChromiumRateLimitTask;
 
-    GraphicsContext3D* layerRendererContext();
-
     bool m_hasAlpha;
     bool m_premultipliedAlpha;
     unsigned m_textureId;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to