Title: [94329] trunk/Source/WebCore
Revision
94329
Author
[email protected]
Date
2011-09-01 12:28:50 -0700 (Thu, 01 Sep 2011)

Log Message

[Chromium/Skia] Use GraphicsContext3D::grContext() to create GrContext for accelerated drawing
https://bugs.webkit.org/show_bug.cgi?id=67419

Patch by Brian Salomon <[email protected]> on 2011-09-01
Reviewed by James Robinson.

Accelerated drawing is not enabled in layout tests. However, once it is this change will be tested by every test.

* platform/graphics/chromium/ContentLayerChromium.cpp:
(WebCore::ContentLayerChromium::createTextureUpdater):
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::contextSupportsAcceleratedPainting):
(WebCore::LayerRendererChromium::initialize):
* platform/graphics/chromium/LayerRendererChromium.h:
* platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
(WebCore::LayerTextureUpdaterSkPicture::create):
(WebCore::LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture):
(WebCore::LayerTextureUpdaterSkPicture::updateTextureRect):
(WebCore::LayerTextureUpdaterSkPicture::createFrameBuffer):
* platform/graphics/chromium/LayerTextureUpdaterCanvas.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (94328 => 94329)


--- trunk/Source/WebCore/ChangeLog	2011-09-01 19:27:03 UTC (rev 94328)
+++ trunk/Source/WebCore/ChangeLog	2011-09-01 19:28:50 UTC (rev 94329)
@@ -1,3 +1,25 @@
+2011-09-01  Brian Salomon  <[email protected]>
+
+        [Chromium/Skia] Use GraphicsContext3D::grContext() to create GrContext for accelerated drawing
+        https://bugs.webkit.org/show_bug.cgi?id=67419
+
+        Reviewed by James Robinson.
+
+        Accelerated drawing is not enabled in layout tests. However, once it is this change will be tested by every test.
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::createTextureUpdater):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::contextSupportsAcceleratedPainting):
+        (WebCore::LayerRendererChromium::initialize):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
+        (WebCore::LayerTextureUpdaterSkPicture::create):
+        (WebCore::LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture):
+        (WebCore::LayerTextureUpdaterSkPicture::updateTextureRect):
+        (WebCore::LayerTextureUpdaterSkPicture::createFrameBuffer):
+        * platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
+
 2011-09-01  Dominik Röttsches  <[email protected]>
 
         Rename GraphicsContext3DInternal to GraphicsContext3DPrivate and add a dummy version of this class for Mac

Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp (94328 => 94329)


--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2011-09-01 19:27:03 UTC (rev 94328)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2011-09-01 19:28:50 UTC (rev 94329)
@@ -123,7 +123,7 @@
 #if !USE(THREADED_COMPOSITING)
 #if USE(SKIA)
     if (host->settings().acceleratePainting) {
-        m_textureUpdater = LayerTextureUpdaterSkPicture::create(ContentLayerPainter::create(m_owner), host->layerRenderer()->skiaContext());
+        m_textureUpdater = LayerTextureUpdaterSkPicture::create(ContentLayerPainter::create(m_owner));
         return;
     }
 #endif // SKIA

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (94328 => 94329)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-09-01 19:27:03 UTC (rev 94328)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-09-01 19:28:50 UTC (rev 94329)
@@ -444,6 +444,9 @@
     else
         return false;
 
+    if (!context->grContext())
+        return false;
+
     return true;
 }
 #endif
@@ -474,16 +477,6 @@
 bool LayerRendererChromium::initialize()
 {
     m_context->makeContextCurrent();
-#if USE(SKIA)
-    if (settings().acceleratePainting) {
-        m_skiaContext = adoptPtr(GrContext::CreateGLShaderContext());
-        // Limit the number of textures we hold in the bitmap->texture cache.
-        static const int maxTextureCacheCount = 512;
-        // Limit the bytes allocated toward textures in the bitmap->texture cache.
-        static const size_t maxTextureCacheBytes = 50 * 1024 * 1024;
-        m_skiaContext->setTextureCacheLimits(maxTextureCacheCount, maxTextureCacheBytes);
-    }
-#endif
 
     WebCore::Extensions3D* extensions = m_context->getExtensions();
     m_contextSupportsMapSub = extensions->supports("GL_CHROMIUM_map_sub");

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h (94328 => 94329)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h	2011-09-01 19:27:03 UTC (rev 94328)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h	2011-09-01 19:28:50 UTC (rev 94329)
@@ -87,10 +87,6 @@
     GraphicsContext3D* context();
     bool contextSupportsMapSub() const { return m_contextSupportsMapSub; }
 
-#if USE(SKIA)
-    GrContext* skiaContext() { return m_skiaContext.get(); }
-#endif
-
     const IntSize& viewportSize() { return m_owner->viewportSize(); }
     int viewportWidth() { return viewportSize().width(); }
     int viewportHeight() { return viewportSize().height(); }
@@ -230,9 +226,6 @@
     OwnPtr<CCHeadsUpDisplay> m_headsUpDisplay;
 
     RefPtr<GraphicsContext3D> m_context;
-#if USE(SKIA)
-    OwnPtr<GrContext> m_skiaContext;
-#endif
 
     bool m_contextSupportsMapSub;
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp (94328 => 94329)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp	2011-09-01 19:27:03 UTC (rev 94328)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp	2011-09-01 19:28:50 UTC (rev 94329)
@@ -103,14 +103,13 @@
 
 #if !USE(THREADED_COMPOSITING)
 #if USE(SKIA)
-PassOwnPtr<LayerTextureUpdaterSkPicture> LayerTextureUpdaterSkPicture::create(PassOwnPtr<LayerPainterChromium> painter, GrContext* skiaContext)
+PassOwnPtr<LayerTextureUpdaterSkPicture> LayerTextureUpdaterSkPicture::create(PassOwnPtr<LayerPainterChromium> painter)
 {
-    return adoptPtr(new LayerTextureUpdaterSkPicture(painter, skiaContext));
+    return adoptPtr(new LayerTextureUpdaterSkPicture(painter));
 }
 
-LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium> painter, GrContext* skiaContext)
+LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium> painter)
     : LayerTextureUpdaterCanvas(painter)
-    , m_skiaContext(skiaContext)
     , m_context(0)
     , m_createFrameBuffer(false)
     , m_fbo(0)
@@ -167,8 +166,9 @@
     // Make sure SKIA uses the correct GL context.
     context()->makeContextCurrent();
 
+    GrContext* skiaContext = m_context->grContext();
     // Notify SKIA to sync its internal GL state.
-    m_skiaContext->resetContext();
+    skiaContext->resetContext();
     m_canvas->save();
     m_canvas->clipRect(SkRect(destRect));
     // Translate the origin of contentRect to that of destRect.
@@ -178,7 +178,7 @@
     m_canvas->drawPicture(m_picture);
     m_canvas->restore();
     // Flush SKIA context so that all the rendered stuff appears on the texture.
-    m_skiaContext->flush();
+    skiaContext->flush();
 
     // Unbind texture.
     context()->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, 0, 0);
@@ -237,6 +237,7 @@
     context()->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer);
 
     // Create a skia gpu canvas.
+    GrContext* skiaContext = m_context->grContext();
     GrPlatformSurfaceDesc targetDesc;
     targetDesc.reset();
     targetDesc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
@@ -246,8 +247,8 @@
     targetDesc.fConfig = kRGBA_8888_GrPixelConfig;
     targetDesc.fStencilBits = 8;
     targetDesc.fPlatformRenderTarget = m_fbo;
-    SkAutoTUnref<GrRenderTarget> target(static_cast<GrRenderTarget*>(m_skiaContext->createPlatformSurface(targetDesc)));
-    SkAutoTUnref<SkDevice> device(new SkGpuDevice(m_skiaContext, target.get()));
+    SkAutoTUnref<GrRenderTarget> target(static_cast<GrRenderTarget*>(skiaContext->createPlatformSurface(targetDesc)));
+    SkAutoTUnref<SkDevice> device(new SkGpuDevice(skiaContext, target.get()));
     m_canvas = adoptPtr(new SkCanvas(device.get()));
 
     context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0);

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h (94328 => 94329)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h	2011-09-01 19:27:03 UTC (rev 94328)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h	2011-09-01 19:28:50 UTC (rev 94329)
@@ -85,7 +85,7 @@
 class LayerTextureUpdaterSkPicture : public LayerTextureUpdaterCanvas {
     WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterSkPicture);
 public:
-    static PassOwnPtr<LayerTextureUpdaterSkPicture> create(PassOwnPtr<LayerPainterChromium>, GrContext*);
+    static PassOwnPtr<LayerTextureUpdaterSkPicture> create(PassOwnPtr<LayerPainterChromium>);
     virtual ~LayerTextureUpdaterSkPicture();
 
     virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; }
@@ -94,12 +94,11 @@
     virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
 
 private:
-    LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium>, GrContext*);
+    explicit LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium>);
     void deleteFrameBuffer();
     bool createFrameBuffer();
     GraphicsContext3D* context() { return m_context; }
 
-    GrContext* m_skiaContext; // SKIA graphics context.
     GraphicsContext3D* m_context;
 
     bool m_createFrameBuffer; // Need to create FBO if true.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to