[chromium] Wrap shared context getters in WebKit API and avoid WebCore::GraphicsConte...
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Aug 2012 20:33:42 +0000 (20:33 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Aug 2012 20:33:42 +0000 (20:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=92917

Reviewed by Adrienne Walker.

Source/Platform:

This adds Platform API for creating and accessing shared GraphicsContext3D and Ganesh contexts from the main or
compositor threads. These can be used for evaluating filters or doing accelerated painting. These contexts are
generally leaked until lost or process exit, the details are documented in WebSharedGraphicsContext3D.h

* Platform.gypi:
* chromium/public/WebSharedGraphicsContext3D.h: Added.
(WebKit):
(WebSharedGraphicsContext3D):

Source/WebCore:

This uses Platform API wrappers to access the shared WebGraphicsContext3D / Ganesh contexts from the compositor
to evaluate accelerated filters or do accelerated painting.

Filters changes covered by css3/filters/*-hw.html layout tests.

* WebCore.gypi:
* platform/chromium/support/WebSharedGraphicsContext3D.cpp:
(WebKit):
(WebKit::WebSharedGraphicsContext3D::mainThreadContext):
(WebKit::WebSharedGraphicsContext3D::mainThreadGrContext):
(WebKit::WebSharedGraphicsContext3D::compositorThreadContext):
(WebKit::WebSharedGraphicsContext3D::compositorThreadGrContext):
(WebKit::WebSharedGraphicsContext3D::haveCompositorThreadContext):
(WebKit::WebSharedGraphicsContext3D::createCompositorThreadContext):
* platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp:
(WebCore::createAcceleratedCanvas):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):
* platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h:
(WebKit):
(FrameBufferSkPictureCanvasLayerTextureUpdater):
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::applyFilters):
* platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp:
(WebCore::CCRenderSurfaceFilters::apply):
* platform/graphics/chromium/cc/CCRenderSurfaceFilters.h:
(WebKit):
(CCRenderSurfaceFilters):

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

12 files changed:
Source/Platform/ChangeLog
Source/Platform/Platform.gypi
Source/Platform/chromium/public/WebSharedGraphicsContext3D.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/platform/chromium/support/WebSharedGraphicsContext3D.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp
Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp
Source/WebCore/platform/graphics/chromium/cc/CCRenderSurfaceFilters.h
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

index c9fa24f..8908f08 100644 (file)
@@ -1,3 +1,19 @@
+2012-08-01  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Wrap shared context getters in WebKit API and avoid WebCore::GraphicsContext3D use in compositor internals
+        https://bugs.webkit.org/show_bug.cgi?id=92917
+
+        Reviewed by Adrienne Walker.
+
+        This adds Platform API for creating and accessing shared GraphicsContext3D and Ganesh contexts from the main or
+        compositor threads. These can be used for evaluating filters or doing accelerated painting. These contexts are
+        generally leaked until lost or process exit, the details are documented in WebSharedGraphicsContext3D.h
+
+        * Platform.gypi:
+        * chromium/public/WebSharedGraphicsContext3D.h: Added.
+        (WebKit):
+        (WebSharedGraphicsContext3D):
+
 2012-08-02  Peter Beverloo  <peter@chromium.org>
 
         [Chromium] Add a stub for WebView::getTouchHighlightQuads()
index 9473809..c3af963 100644 (file)
             'chromium/public/WebScrollbarThemeGeometry.h',
             'chromium/public/WebScrollbarThemePainter.h',
             'chromium/public/WebSessionDescriptionDescriptor.h',
+            'chromium/public/WebSharedGraphicsContext3D.h',
             'chromium/public/WebSize.h',
             'chromium/public/WebSocketStreamError.h',
             'chromium/public/WebSocketStreamHandle.h',
diff --git a/Source/Platform/chromium/public/WebSharedGraphicsContext3D.h b/Source/Platform/chromium/public/WebSharedGraphicsContext3D.h
new file mode 100644 (file)
index 0000000..948e6ed
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSharedGraphicsContext3D_h
+#define WebSharedGraphicsContext3D_h
+
+#include "WebCommon.h"
+
+class GrContext;
+
+namespace WebKit {
+
+class WebGraphicsContext3D;
+
+class WebSharedGraphicsContext3D {
+public:
+    // Returns a context usable from the main thread. If the context is lost or has never been created, this will attempt to create a new context.
+    // The returned pointer is only valid until the next call to mainThreadContext().
+    WEBKIT_EXPORT static WebGraphicsContext3D* mainThreadContext();
+
+    // Returns a ganesh context associated with the main thread shared context. The ganesh context has the same lifetime as the main thread shared
+    // WebGraphicsContext3D.
+    WEBKIT_EXPORT static GrContext* mainThreadGrContext();
+
+    // Attempts to create a context usable from the compositor thread. Must be called from the main (WebKit) thread. Returns false
+    // if a context could not be created.
+    WEBKIT_EXPORT static bool createCompositorThreadContext();
+
+    // Can be called from any thread.
+    WEBKIT_EXPORT static bool haveCompositorThreadContext();
+
+    // Returns a context usable from the compositor thread, if there is one. The context must be used only from the compositor thread.
+    // The returned context is valid until the next call to createCompositorThreadContext().
+    // If this context becomes lost or unusable, the caller should call createCompositorThreadContext() on the main thread and
+    // then use the newly created context from the compositor thread.
+    WEBKIT_EXPORT static WebGraphicsContext3D* compositorThreadContext();
+
+    // Returns a ganesh context associated with the compositor thread shared context. The ganesh context has the same lifetime as the compositor thread
+    // shared WebGraphicsContext3D.
+    WEBKIT_EXPORT static GrContext* compositorThreadGrContext();
+};
+
+}
+
+#endif // WebSharedGraphicsContext3D_h
index 7cde910..d91ef76 100644 (file)
@@ -1,3 +1,39 @@
+2012-08-01  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Wrap shared context getters in WebKit API and avoid WebCore::GraphicsContext3D use in compositor internals
+        https://bugs.webkit.org/show_bug.cgi?id=92917
+
+        Reviewed by Adrienne Walker.
+
+        This uses Platform API wrappers to access the shared WebGraphicsContext3D / Ganesh contexts from the compositor
+        to evaluate accelerated filters or do accelerated painting.
+
+        Filters changes covered by css3/filters/*-hw.html layout tests.
+
+        * WebCore.gypi:
+        * platform/chromium/support/WebSharedGraphicsContext3D.cpp:
+        (WebKit):
+        (WebKit::WebSharedGraphicsContext3D::mainThreadContext):
+        (WebKit::WebSharedGraphicsContext3D::mainThreadGrContext):
+        (WebKit::WebSharedGraphicsContext3D::compositorThreadContext):
+        (WebKit::WebSharedGraphicsContext3D::compositorThreadGrContext):
+        (WebKit::WebSharedGraphicsContext3D::haveCompositorThreadContext):
+        (WebKit::WebSharedGraphicsContext3D::createCompositorThreadContext):
+        * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp:
+        (WebCore::createAcceleratedCanvas):
+        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect):
+        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):
+        * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h:
+        (WebKit):
+        (FrameBufferSkPictureCanvasLayerTextureUpdater):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::applyFilters):
+        * platform/graphics/chromium/cc/CCRenderSurfaceFilters.cpp:
+        (WebCore::CCRenderSurfaceFilters::apply):
+        * platform/graphics/chromium/cc/CCRenderSurfaceFilters.h:
+        (WebKit):
+        (CCRenderSurfaceFilters):
+
 2012-08-02  Beth Dakin  <bdakin@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=93020
index 0a0a493..859fe15 100644 (file)
             'platform/chromium/support/WebMediaStreamSourcesRequest.cpp',
             'platform/chromium/support/WebPrerender.cpp',
             'platform/chromium/support/WebRTCConfiguration.cpp',
+            'platform/chromium/support/WebSharedGraphicsContext3D.cpp',
             'platform/chromium/support/WebThreadSafeData.cpp',
-            'platform/chromium/support/WebTransformationMatrix.cpp',
             'platform/chromium/support/WebTransformOperations.cpp',
+            'platform/chromium/support/WebTransformationMatrix.cpp',
             'platform/chromium/support/WebURL.cpp',
             'platform/chromium/support/WebURLError.cpp',
             'platform/chromium/support/WebURLRequest.cpp',
diff --git a/Source/WebCore/platform/chromium/support/WebSharedGraphicsContext3D.cpp b/Source/WebCore/platform/chromium/support/WebSharedGraphicsContext3D.cpp
new file mode 100644 (file)
index 0000000..52d054d
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include <public/WebSharedGraphicsContext3D.h>
+
+#include "GraphicsContext3DPrivate.h"
+#include "SharedGraphicsContext3D.h"
+
+using WebCore::GraphicsContext3DPrivate;
+using WebCore::SharedGraphicsContext3D;
+
+namespace WebKit {
+
+WebGraphicsContext3D* WebSharedGraphicsContext3D::mainThreadContext()
+{
+    return GraphicsContext3DPrivate::extractWebGraphicsContext3D(SharedGraphicsContext3D::get().get());
+}
+
+GrContext* WebSharedGraphicsContext3D::mainThreadGrContext()
+{
+    return SharedGraphicsContext3D::get() ? SharedGraphicsContext3D::get()->grContext() : 0;
+}
+
+
+WebGraphicsContext3D* WebSharedGraphicsContext3D::compositorThreadContext()
+{
+    return GraphicsContext3DPrivate::extractWebGraphicsContext3D(SharedGraphicsContext3D::getForImplThread().get());
+}
+
+GrContext* WebSharedGraphicsContext3D::compositorThreadGrContext()
+{
+    return SharedGraphicsContext3D::getForImplThread() ? SharedGraphicsContext3D::getForImplThread()->grContext() : 0;
+}
+
+bool WebSharedGraphicsContext3D::haveCompositorThreadContext()
+{
+    return SharedGraphicsContext3D::haveForImplThread();
+}
+
+bool WebSharedGraphicsContext3D::createCompositorThreadContext()
+{
+    return SharedGraphicsContext3D::createForImplThread();
+}
+
+}
+
index 436f346..9cd1e75 100644 (file)
 #include "FrameBufferSkPictureCanvasLayerTextureUpdater.h"
 
 #include "LayerPainterChromium.h"
-#include "SharedGraphicsContext3D.h"
 #include "SkCanvas.h"
 #include "SkGpuDevice.h"
 #include "cc/CCProxy.h"
+#include <public/WebGraphicsContext3D.h>
+#include <public/WebSharedGraphicsContext3D.h>
+
+using WebKit::WebGraphicsContext3D;
+using WebKit::WebSharedGraphicsContext3D;
 
 namespace WebCore {
 
-static PassOwnPtr<SkCanvas> createAcceleratedCanvas(GraphicsContext3D* context,
+static PassOwnPtr<SkCanvas> createAcceleratedCanvas(GrContext* grContext,
                                                     IntSize canvasSize,
                                                     unsigned textureId)
 {
-    GrContext* grContext = context->grContext();
     GrPlatformTextureDesc textureDesc;
     textureDesc.fFlags = kRenderTarget_GrPlatformTextureFlag;
     textureDesc.fWidth = canvasSize.width();
@@ -66,10 +69,11 @@ FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::~Texture()
 
 void FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect(CCResourceProvider* resourceProvider, const IntRect& sourceRect, const IntRect& destRect)
 {
-    RefPtr<GraphicsContext3D> sharedContext = CCProxy::hasImplThread() ? SharedGraphicsContext3D::getForImplThread() : SharedGraphicsContext3D::get();
-    if (!sharedContext)
+    WebGraphicsContext3D* sharedContext = CCProxy::hasImplThread() ? WebSharedGraphicsContext3D::compositorThreadContext() : WebSharedGraphicsContext3D::mainThreadContext();
+    GrContext* sharedGrContext = CCProxy::hasImplThread() ? WebSharedGraphicsContext3D::compositorThreadGrContext() : WebSharedGraphicsContext3D::mainThreadGrContext();
+    if (!sharedContext || !sharedGrContext)
         return;
-    textureUpdater()->updateTextureRect(sharedContext.release(), resourceProvider, texture(), sourceRect, destRect);
+    textureUpdater()->updateTextureRect(sharedContext, sharedGrContext, resourceProvider, texture(), sourceRect, destRect);
 }
 
 PassRefPtr<FrameBufferSkPictureCanvasLayerTextureUpdater> FrameBufferSkPictureCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter)
@@ -97,17 +101,15 @@ LayerTextureUpdater::SampledTexelFormat FrameBufferSkPictureCanvasLayerTextureUp
     return LayerTextureUpdater::SampledTexelFormatRGBA;
 }
 
-void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(PassRefPtr<GraphicsContext3D> prpContext, CCResourceProvider* resourceProvider, CCPrioritizedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
+void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(WebGraphicsContext3D* context, GrContext* grContext, CCResourceProvider* resourceProvider, CCPrioritizedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
 {
-    RefPtr<GraphicsContext3D> context(prpContext);
-
     // Make sure ganesh uses the correct GL context.
     context->makeContextCurrent();
 
     texture->acquireBackingTexture(resourceProvider);
     CCScopedLockResourceForWrite lock(resourceProvider, texture->resourceId());
     // Create an accelerated canvas to draw on.
-    OwnPtr<SkCanvas> canvas = createAcceleratedCanvas(context.get(), texture->size(), lock.textureId());
+    OwnPtr<SkCanvas> canvas = createAcceleratedCanvas(grContext, texture->size(), lock.textureId());
 
     // The compositor expects the textures to be upside-down so it can flip
     // the final composited image. Ganesh renders the image upright so we
@@ -123,7 +125,7 @@ void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(PassRefPtr
     drawPicture(canvas.get());
 
     // Flush ganesh context so that all the rendered stuff appears on the texture.
-    context->grContext()->flush();
+    grContext->flush();
 
     // Flush the GL context so rendering results from this context are visible in the compositor's context.
     context->flush();
index 44649e4..64d5eec 100644 (file)
 
 #include "SkPictureCanvasLayerTextureUpdater.h"
 
+class GrContext;
+
+namespace WebKit {
+class WebGraphicsContext3D;
+class WebSharedGraphicsContext3D;
+}
+
 namespace WebCore {
 
 // This class records the contentRect into an SkPicture, then uses accelerated
@@ -56,7 +63,7 @@ public:
 
     virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(CCPrioritizedTextureManager*) OVERRIDE;
     virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) OVERRIDE;
-    void updateTextureRect(PassRefPtr<GraphicsContext3D>, CCResourceProvider*, CCPrioritizedTexture*, const IntRect& sourceRect, const IntRect& destRect);
+    void updateTextureRect(WebKit::WebGraphicsContext3D*, GrContext*, CCResourceProvider*, CCPrioritizedTexture*, const IntRect& sourceRect, const IntRect& destRect);
 
 private:
     explicit FrameBufferSkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>);
index 8f91d2f..88610a0 100644 (file)
@@ -40,7 +40,6 @@
 #include "GrTexture.h"
 #include "NotImplemented.h"
 #include "PlatformColor.h"
-#include "SharedGraphicsContext3D.h"
 #include "SkBitmap.h"
 #include "SkColor.h"
 #include "ThrottledTextureUploader.h"
@@ -56,6 +55,7 @@
 #include "cc/CCSingleThreadProxy.h"
 #include "cc/CCVideoLayerImpl.h"
 #include <public/WebGraphicsContext3D.h>
+#include <public/WebSharedGraphicsContext3D.h>
 #include <public/WebVideoFrame.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/MainThread.h>
@@ -64,6 +64,7 @@
 using namespace std;
 using WebKit::WebGraphicsContext3D;
 using WebKit::WebGraphicsMemoryAllocation;
+using WebKit::WebSharedGraphicsContext3D;
 using WebKit::WebTransformationMatrix;
 
 namespace WebCore {
@@ -529,14 +530,16 @@ static inline SkBitmap applyFilters(LayerRendererChromium* layerRenderer, const
     if (filters.isEmpty())
         return SkBitmap();
 
-    RefPtr<GraphicsContext3D> filterContext = CCProxy::hasImplThread() ? SharedGraphicsContext3D::getForImplThread() : SharedGraphicsContext3D::get();
-    if (!filterContext)
+    WebGraphicsContext3D* filterContext = CCProxy::hasImplThread() ? WebSharedGraphicsContext3D::compositorThreadContext() : WebSharedGraphicsContext3D::mainThreadContext();
+    GrContext* filterGrContext = CCProxy::hasImplThread() ? WebSharedGraphicsContext3D::compositorThreadGrContext() : WebSharedGraphicsContext3D::mainThreadGrContext();
+
+    if (!filterContext || !filterGrContext)
         return SkBitmap();
 
     layerRenderer->context()->flush();
 
     CCScopedLockResourceForWrite lock(layerRenderer->resourceProvider(), sourceTexture->id());
-    SkBitmap source = CCRenderSurfaceFilters::apply(filters, lock.textureId(), sourceTexture->size(), filterContext.get());
+    SkBitmap source = CCRenderSurfaceFilters::apply(filters, lock.textureId(), sourceTexture->size(), filterContext, filterGrContext);
     return source;
 }
 
index 4e8549d..a02fd5f 100644 (file)
@@ -30,7 +30,6 @@
 #include "cc/CCRenderSurfaceFilters.h"
 
 #include "FloatSize.h"
-#include "GraphicsContext3D.h"
 #include "SkBlurImageFilter.h"
 #include "SkCanvas.h"
 #include "SkColorMatrixFilter.h"
@@ -38,6 +37,7 @@
 #include "SkGrTexturePixelRef.h"
 #include <public/WebFilterOperation.h>
 #include <public/WebFilterOperations.h>
+#include <public/WebGraphicsContext3D.h>
 #include <wtf/MathExtras.h>
 
 namespace {
@@ -385,14 +385,11 @@ WebKit::WebFilterOperations CCRenderSurfaceFilters::optimize(const WebKit::WebFi
     return newList;
 }
 
-SkBitmap CCRenderSurfaceFilters::apply(const WebKit::WebFilterOperations& filters, unsigned textureId, const FloatSize& size, GraphicsContext3D* context3D)
+SkBitmap CCRenderSurfaceFilters::apply(const WebKit::WebFilterOperations& filters, unsigned textureId, const FloatSize& size, WebKit::WebGraphicsContext3D* context3D, GrContext* grContext)
 {
-    if (!context3D)
+    if (!context3D || !grContext)
         return SkBitmap();
 
-    GrContext* grContext = context3D->grContext();
-    if (!grContext)
-        return SkBitmap();
     WebKit::WebFilterOperations optimizedFilters = optimize(filters);
     FilterBufferState state(grContext, size, textureId);
     if (!state.init(optimizedFilters.size()))
index fb4d78f..4ae97a2 100644 (file)
 
 #if USE(ACCELERATED_COMPOSITING)
 
+class GrContext;
 class SkBitmap;
 
 namespace WebKit {
 class WebFilterOperations;
+class WebGraphicsContext3D;
 }
 
 namespace WebCore {
 class FloatSize;
-class GraphicsContext3D;
 
 class CCRenderSurfaceFilters {
 public:
-    static SkBitmap apply(const WebKit::WebFilterOperations& filters, unsigned textureId, const FloatSize&, GraphicsContext3D*);
+    static SkBitmap apply(const WebKit::WebFilterOperations& filters, unsigned textureId, const FloatSize&, WebKit::WebGraphicsContext3D*, GrContext*);
     static WebKit::WebFilterOperations optimize(const WebKit::WebFilterOperations& filters);
+
 private:
     CCRenderSurfaceFilters();
 };
index f85e602..4824ffb 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "cc/CCThreadProxy.h"
 
-#include "SharedGraphicsContext3D.h"
 #include "TraceEvent.h"
 #include "cc/CCDelayBasedTimeSource.h"
 #include "cc/CCDrawQuad.h"
 #include "cc/CCScopedThreadProxy.h"
 #include "cc/CCTextureUpdater.h"
 #include "cc/CCThreadTask.h"
+#include <public/WebSharedGraphicsContext3D.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/MainThread.h>
 
 using namespace WTF;
 
+using WebKit::WebSharedGraphicsContext3D;
 namespace {
 
 // Number of textures to update with each call to
@@ -241,7 +242,7 @@ bool CCThreadProxy::recreateContext()
     if (!context)
         return false;
     if (m_layerTreeHost->needsSharedContext() && !m_layerTreeHost->settings().forceSoftwareCompositing)
-        if (!SharedGraphicsContext3D::createForImplThread())
+        if (!WebSharedGraphicsContext3D::createCompositorThreadContext())
             return false;
 
     // Make a blocking call to recreateContextOnImplThread. The results of that
@@ -473,8 +474,8 @@ void CCThreadProxy::beginFrame()
         return;
     }
 
-    if (m_layerTreeHost->needsSharedContext() && !m_layerTreeHost->settings().forceSoftwareCompositing && !SharedGraphicsContext3D::haveForImplThread())
-        SharedGraphicsContext3D::createForImplThread();
+    if (m_layerTreeHost->needsSharedContext() && !m_layerTreeHost->settings().forceSoftwareCompositing && !WebSharedGraphicsContext3D::haveCompositorThreadContext())
+        WebSharedGraphicsContext3D::createCompositorThreadContext();
 
     OwnPtr<BeginFrameAndCommitState> request(m_pendingBeginFrameRequest.release());