[chromium] Provide compositor offscreen context through the WebLayerTreeViewClient...
authordanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Feb 2013 23:42:19 +0000 (23:42 +0000)
committerdanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Feb 2013 23:42:19 +0000 (23:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107776

Source/Platform:

Make "createGrGLInterface" the preferred virtual method for
WebGraphicsContext3D implementations to override. For now it
just calls the old method in its default implementation.

Reviewed by James Robinson.

* chromium/public/WebGraphicsContext3D.h:
(WebGraphicsContext3D):
(WebKit::WebGraphicsContext3D::createGrGLInterface):

Source/WebCore:

Reviewed by James Robinson.

Allow the compositor thread's context to be retrieved on either thread,
so the main thread can create and pass the context to the impl thread
via its own mechanisms.

Move the code to bind the GrGLInterface to a WebGraphicsContext3D into
chromium's GraphicsContext3DPrivate. The chromium-side code will need
to implement this code itself.

* platform/chromium/support/GraphicsContext3DPrivate.cpp:
(WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
(WebCore):
(WebCore::GraphicsContext3DPrivate::grContext):
* platform/chromium/support/GraphicsContext3DPrivate.h:
* platform/graphics/gpu/SharedGraphicsContext3D.cpp:
(WebCore::SharedGraphicsContext3D::getForImplThread):

Source/WebKit/chromium:

Reviewed by James Robinson.

* WebKit.gyp:
* src/WebGraphicsContext3D.cpp: Removed.

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

Source/Platform/ChangeLog
Source/Platform/chromium/public/WebGraphicsContext3D.h
Source/WebCore/ChangeLog
Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp
Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.h
Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp
Source/WebKit/chromium/src/WebGraphicsContext3D.cpp [deleted file]

index 36266ea..197ff7b 100644 (file)
@@ -1,3 +1,18 @@
+2013-02-05  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Provide compositor offscreen context through the WebLayerTreeViewClient interface
+        https://bugs.webkit.org/show_bug.cgi?id=107776
+
+        Make "createGrGLInterface" the preferred virtual method for
+        WebGraphicsContext3D implementations to override. For now it
+        just calls the old method in its default implementation.
+
+        Reviewed by James Robinson.
+
+        * chromium/public/WebGraphicsContext3D.h:
+        (WebGraphicsContext3D):
+        (WebKit::WebGraphicsContext3D::createGrGLInterface):
+
 2013-02-05  James Robinson  <jamesr@chromium.org>
 
         [chromium] Remove optionalness of second parameter to WebLayerTreeView::setViewportSize
index fc967d0..ae19f4f 100644 (file)
@@ -472,7 +472,8 @@ public:
     virtual void asyncTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, WGC3Denum type, const void* pixels) { }
     virtual void asyncTexSubImage2DCHROMIUM(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Denum type, const void* pixels) { }
 
-    GrGLInterface* createGrGLInterface();
+    // FIXME: Make implementations of this class override this method instead and then remove onCreateGrGLInterface().
+    virtual GrGLInterface* createGrGLInterface() { return onCreateGrGLInterface(); }
 
 protected:
     virtual GrGLInterface* onCreateGrGLInterface() { return 0; }
index 6b247e2..21100c4 100644 (file)
@@ -1,3 +1,26 @@
+2013-02-05  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Provide compositor offscreen context through the WebLayerTreeViewClient interface
+        https://bugs.webkit.org/show_bug.cgi?id=107776
+
+        Reviewed by James Robinson.
+
+        Allow the compositor thread's context to be retrieved on either thread,
+        so the main thread can create and pass the context to the impl thread
+        via its own mechanisms.
+
+        Move the code to bind the GrGLInterface to a WebGraphicsContext3D into
+        chromium's GraphicsContext3DPrivate. The chromium-side code will need
+        to implement this code itself.
+
+        * platform/chromium/support/GraphicsContext3DPrivate.cpp:
+        (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
+        (WebCore):
+        (WebCore::GraphicsContext3DPrivate::grContext):
+        * platform/chromium/support/GraphicsContext3DPrivate.h:
+        * platform/graphics/gpu/SharedGraphicsContext3D.cpp:
+        (WebCore::SharedGraphicsContext3D::getForImplThread):
+
 2013-02-05  Tony Gentilcore  <tonyg@chromium.org>
 
         Continue making XSSAuditor thread safe: Remove dependency on the parser's tokenizer
index 0d571b4..ebcdca8 100644 (file)
@@ -71,7 +71,6 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
     if (m_grContext) {
         m_impl->setMemoryAllocationChangedCallbackCHROMIUM(0);
         m_grContext->contextDestroyed();
-        GrSafeUnref(m_grContext);
     }
 }
 
@@ -114,17 +113,33 @@ private:
     GrContext* m_context;
 };
 
+namespace {
+void bindWebGraphicsContext3DGLContextCallback(const GrGLInterface* interface)
+{
+    reinterpret_cast<WebKit::WebGraphicsContext3D*>(interface->fCallbackData)->makeContextCurrent();
+}
+}
+
 GrContext* GraphicsContext3DPrivate::grContext()
 {
-    if (!m_grContext) {
-        SkAutoTUnref<GrGLInterface> interface(m_impl->createGrGLInterface());
-        m_grContext = GrContext::Create(kOpenGL_Shaders_GrEngine, reinterpret_cast<GrPlatform3DContext>(interface.get()));
-        if (m_grContext) {
-            m_grContext->setTextureCacheLimits(maxGaneshTextureCacheCount, maxGaneshTextureCacheBytes);
-            m_grContextMemoryAllocationCallbackAdapter = adoptPtr(new GrMemoryAllocationChangedCallbackAdapter(m_grContext));
-            m_impl->setMemoryAllocationChangedCallbackCHROMIUM(m_grContextMemoryAllocationCallbackAdapter.get());
-        }
-    }
+    if (m_grContext)
+        return m_grContext;
+
+    SkAutoTUnref<GrGLInterface> interface(m_impl->createGrGLInterface());
+    if (!interface)
+        return 0;
+
+    interface->fCallback = bindWebGraphicsContext3DGLContextCallback;
+    interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(m_impl.get());
+
+    m_grContext.reset(GrContext::Create(kOpenGL_Shaders_GrEngine, reinterpret_cast<GrPlatform3DContext>(interface.get())));
+    if (!m_grContext)
+        return 0;
+
+    m_grContext->setTextureCacheLimits(maxGaneshTextureCacheCount, maxGaneshTextureCacheBytes);
+    m_grContextMemoryAllocationCallbackAdapter = adoptPtr(new GrMemoryAllocationChangedCallbackAdapter(m_grContext));
+    m_impl->setMemoryAllocationChangedCallbackCHROMIUM(m_grContextMemoryAllocationCallbackAdapter.get());
+
     return m_grContext;
 }
 
index 5bbb85a..d193a6c 100644 (file)
@@ -114,7 +114,7 @@ private:
     // used to resize the Canvas.
     SkBitmap m_resizingBitmap;
 
-    GrContext* m_grContext;
+    SkAutoTUnref<GrContext> m_grContext;
 };
 
 } // namespace WebCore
index d1d5cb1..a7074b7 100644 (file)
@@ -95,7 +95,6 @@ static PassRefPtr<GraphicsContext3D> getOrCreateContextForImplThread(ContextOper
 
 PassRefPtr<GraphicsContext3D> SharedGraphicsContext3D::getForImplThread()
 {
-    ASSERT(!isMainThread());
     return getOrCreateContextForImplThread(Get);
 }
 
index ced88e2..19a1f31 100644 (file)
@@ -1,3 +1,13 @@
+2013-02-05  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Provide compositor offscreen context through the WebLayerTreeViewClient interface
+        https://bugs.webkit.org/show_bug.cgi?id=107776
+
+        Reviewed by James Robinson.
+
+        * WebKit.gyp:
+        * src/WebGraphicsContext3D.cpp: Removed.
+
 2013-02-05  Mark Lam  <mark.lam@apple.com>
 
         Introduced back-end database classes + a few small fixes.
index 55101f8..48869bc 100644 (file)
                 'src/WebGeolocationPermissionRequestManager.cpp',
                 'src/WebGeolocationPosition.cpp',
                 'src/WebGlyphCache.cpp',
-                'src/WebGraphicsContext3D.cpp',
                 'src/WebHistoryItem.cpp',
                 'src/WebHitTestResult.cpp',
                 'src/WebIconLoadingCompletionImpl.cpp',
diff --git a/Source/WebKit/chromium/src/WebGraphicsContext3D.cpp b/Source/WebKit/chromium/src/WebGraphicsContext3D.cpp
deleted file mode 100644 (file)
index 3d62184..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2011 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/WebGraphicsContext3D.h>
-
-#include "GrGLInterface.h"
-
-namespace WebKit {
-
-namespace {
-    void bindWebGraphicsContext3DGLContextCallback(const GrGLInterface* interface)
-    {
-        reinterpret_cast<WebGraphicsContext3D*>(interface->fCallbackData)->makeContextCurrent();
-    }
-}
-
-GrGLInterface* WebGraphicsContext3D::createGrGLInterface()
-{
-    GrGLInterface* interface = onCreateGrGLInterface();
-    if (interface) {
-        interface->fCallback = bindWebGraphicsContext3DGLContextCallback;
-        interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this);
-    }
-    return interface;
-}
-
-} // namespace WebKit