summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordongseong.hwang <dongseong.hwang@intel.com>2014-08-29 01:47:17 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-29 08:48:22 +0000
commit3ed758c9a46ec8579cc3a5cb2955161a8a322f0b (patch)
tree5871da45f3afd06f9a433cd07fd9156ceca68406
parente407013f55b72cb9e0a86aec541bd8eba5efe90f (diff)
downloadchromium_src-3ed758c9a46ec8579cc3a5cb2955161a8a322f0b.zip
chromium_src-3ed758c9a46ec8579cc3a5cb2955161a8a322f0b.tar.gz
chromium_src-3ed758c9a46ec8579cc3a5cb2955161a8a322f0b.tar.bz2
gpu: Remove WebGraphicsContext3D::makeContextCurrent()
We don't need to call it before using GL context anymore. BUG=404121 Review URL: https://codereview.chromium.org/470973002 Cr-Commit-Position: refs/heads/master@{#292592}
-rw-r--r--cc/test/test_context_provider.h2
-rw-r--r--content/browser/android/in_process/synchronous_compositor_factory_impl.cc2
-rw-r--r--content/browser/android/in_process/synchronous_compositor_factory_impl.h6
-rw-r--r--content/browser/gpu/gpu_ipc_browsertests.cc2
-rw-r--r--content/browser/renderer_host/image_transport_factory_android.cc2
-rw-r--r--content/common/gpu/client/context_provider_command_buffer.cc2
-rw-r--r--content/common/gpu/client/gl_helper_benchmark.cc2
-rw-r--r--content/common/gpu/client/gl_helper_unittest.cc2
-rw-r--r--content/common/gpu/client/gpu_in_process_context_tests.cc2
-rw-r--r--content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc29
-rw-r--r--content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h9
-rw-r--r--content/renderer/android/synchronous_compositor_factory.h6
-rw-r--r--content/renderer/media/android/webmediaplayer_android.cc2
-rw-r--r--content/renderer/renderer_webkitplatformsupport_impl.cc39
-rw-r--r--content/shell/renderer/test_runner/TestPlugin.cpp4
-rw-r--r--webkit/common/gpu/context_provider_in_process.cc2
-rw-r--r--webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc34
-rw-r--r--webkit/common/gpu/grcontext_for_webgraphicscontext3d.h4
-rw-r--r--webkit/common/gpu/webgraphicscontext3d_impl.cc1
-rw-r--r--webkit/common/gpu/webgraphicscontext3d_impl.h8
-rw-r--r--webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc31
-rw-r--r--webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h5
22 files changed, 87 insertions, 109 deletions
diff --git a/cc/test/test_context_provider.h b/cc/test/test_context_provider.h
index a57fb58..75c7663 100644
--- a/cc/test/test_context_provider.h
+++ b/cc/test/test_context_provider.h
@@ -45,7 +45,7 @@ class TestContextProvider : public ContextProvider {
// This returns the TestWebGraphicsContext3D but is valid to call
// before the context is bound to a thread. This is needed to set up
// state on the test context before binding. Don't call
- // makeContextCurrent on the context returned from this method.
+ // InitializeOnCurrentThread on the context returned from this method.
TestWebGraphicsContext3D* UnboundTestContext3d();
TestContextSupport* support() { return &support_; }
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
index e624e9b..b7a2cc2 100644
--- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
@@ -216,7 +216,7 @@ SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) {
return factory;
}
-blink::WebGraphicsContext3D*
+webkit::gpu::WebGraphicsContext3DImpl*
SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) {
return WrapContextWithAttributes(CreateOffscreenContext(attributes),
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.h b/content/browser/android/in_process/synchronous_compositor_factory_impl.h
index 0c3cb7c..2ae75e5 100644
--- a/content/browser/android/in_process/synchronous_compositor_factory_impl.h
+++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.h
@@ -44,9 +44,9 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
const std::string& debug_name) OVERRIDE;
virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
int view_id) OVERRIDE;
- virtual blink::WebGraphicsContext3D* CreateOffscreenGraphicsContext3D(
- const blink::WebGraphicsContext3D::Attributes& attributes) OVERRIDE;
-
+ virtual webkit::gpu::WebGraphicsContext3DImpl*
+ CreateOffscreenGraphicsContext3D(
+ const blink::WebGraphicsContext3D::Attributes& attributes) OVERRIDE;
SynchronousInputEventFilter* synchronous_input_event_filter() {
return &synchronous_input_event_filter_;
diff --git a/content/browser/gpu/gpu_ipc_browsertests.cc b/content/browser/gpu/gpu_ipc_browsertests.cc
index 477ff1d..eb3c6ce 100644
--- a/content/browser/gpu/gpu_ipc_browsertests.cc
+++ b/content/browser/gpu/gpu_ipc_browsertests.cc
@@ -47,7 +47,7 @@ class ContextTestBase : public content::ContentBrowserTest {
WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(),
NULL));
CHECK(context_.get());
- context_->makeContextCurrent();
+ context_->InitializeOnCurrentThread();
context_support_ = context_->GetContextSupport();
ContentBrowserTest::SetUpOnMainThread();
}
diff --git a/content/browser/renderer_host/image_transport_factory_android.cc b/content/browser/renderer_host/image_transport_factory_android.cc
index b7adb06..919b709 100644
--- a/content/browser/renderer_host/image_transport_factory_android.cc
+++ b/content/browser/renderer_host/image_transport_factory_android.cc
@@ -83,7 +83,7 @@ CmdBufferImageTransportFactory::CmdBufferImageTransportFactory() {
limits,
NULL));
context_->setContextLostCallback(context_lost_listener_.get());
- if (context_->makeContextCurrent())
+ if (context_->InitializeOnCurrentThread())
context_->pushGroupMarkerEXT(
base::StringPrintf("CmdBufferImageTransportFactory-%p",
context_.get()).c_str());
diff --git a/content/common/gpu/client/context_provider_command_buffer.cc b/content/common/gpu/client/context_provider_command_buffer.cc
index f23283e..a4c3111 100644
--- a/content/common/gpu/client/context_provider_command_buffer.cc
+++ b/content/common/gpu/client/context_provider_command_buffer.cc
@@ -91,7 +91,7 @@ bool ContextProviderCommandBuffer::BindToCurrentThread() {
if (lost_context_callback_proxy_)
return true;
- if (!context3d_->makeContextCurrent())
+ if (!context3d_->InitializeOnCurrentThread())
return false;
InitializeCapabilities();
diff --git a/content/common/gpu/client/gl_helper_benchmark.cc b/content/common/gpu/client/gl_helper_benchmark.cc
index 225db42..caf7fe7 100644
--- a/content/common/gpu/client/gl_helper_benchmark.cc
+++ b/content/common/gpu/client/gl_helper_benchmark.cc
@@ -61,7 +61,7 @@ class GLHelperTest : public testing::Test {
bool lose_context_when_out_of_memory = false;
context_ = webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl::
CreateOffscreenContext(attributes, lose_context_when_out_of_memory);
- context_->makeContextCurrent();
+ context_->InitializeOnCurrentThread();
helper_.reset(
new content::GLHelper(context_->GetGLInterface(),
diff --git a/content/common/gpu/client/gl_helper_unittest.cc b/content/common/gpu/client/gl_helper_unittest.cc
index 280ef1b..13027fc 100644
--- a/content/common/gpu/client/gl_helper_unittest.cc
+++ b/content/common/gpu/client/gl_helper_unittest.cc
@@ -59,7 +59,7 @@ class GLHelperTest : public testing::Test {
context_ =
WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
attributes, lose_context_when_out_of_memory);
- context_->makeContextCurrent();
+ context_->InitializeOnCurrentThread();
context_support_ = context_->GetContextSupport();
helper_.reset(
new content::GLHelper(context_->GetGLInterface(), context_support_));
diff --git a/content/common/gpu/client/gpu_in_process_context_tests.cc b/content/common/gpu/client/gpu_in_process_context_tests.cc
index 8288237..4b7f914 100644
--- a/content/common/gpu/client/gpu_in_process_context_tests.cc
+++ b/content/common/gpu/client/gpu_in_process_context_tests.cc
@@ -24,7 +24,7 @@ class ContextTestBase : public testing::Test {
typedef WebGraphicsContext3DInProcessCommandBufferImpl WGC3DIPCBI;
context_ = WGC3DIPCBI::CreateOffscreenContext(
attributes, lose_context_when_out_of_memory);
- context_->makeContextCurrent();
+ context_->InitializeOnCurrentThread();
context_support_ = context_->GetContextSupport();
}
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
index 093fbe9..9b8ca6a 100644
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
@@ -28,7 +28,6 @@
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_cmd_helper.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
-#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/client/gles2_trace_implementation.h"
#include "gpu/command_buffer/client/transfer_buffer.h"
#include "gpu/command_buffer/common/constants.h"
@@ -65,28 +64,6 @@ scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup>
return it->second;
}
-// Singleton used to initialize and terminate the gles2 library.
-class GLES2Initializer {
- public:
- GLES2Initializer() {
- gles2::Initialize();
- }
-
- ~GLES2Initializer() {
- gles2::Terminate();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-
-base::LazyInstance<GLES2Initializer> g_gles2_initializer =
- LAZY_INSTANCE_INITIALIZER;
-
-////////////////////////////////////////////////////////////////////////////////
-
} // namespace anonymous
WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits::SharedMemoryLimits()
@@ -226,9 +203,6 @@ bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer(
bool WebGraphicsContext3DCommandBufferImpl::CreateContext(bool onscreen) {
TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::CreateContext");
- // Ensure the gles2 library is initialized first in a thread safe way.
- g_gles2_initializer.Get();
-
scoped_refptr<gpu::gles2::ShareGroup> gles2_share_group;
scoped_ptr<base::AutoLock> share_group_lock;
@@ -296,12 +270,11 @@ bool WebGraphicsContext3DCommandBufferImpl::CreateContext(bool onscreen) {
return true;
}
-bool WebGraphicsContext3DCommandBufferImpl::makeContextCurrent() {
+bool WebGraphicsContext3DCommandBufferImpl::InitializeOnCurrentThread() {
if (!MaybeInitializeGL()) {
DLOG(ERROR) << "Failed to initialize context.";
return false;
}
- gles2::SetGLContext(GetGLInterface());
if (gpu::error::IsError(command_buffer_->GetLastError())) {
LOG(ERROR) << "Context dead on arrival. Last error: "
<< command_buffer_->GetLastError();
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
index 9aebaf0..8857202 100644
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
@@ -142,14 +142,11 @@ class WebGraphicsContext3DCommandBufferImpl
return mem_limits_.mapped_memory_reclaim_limit;
}
+ // WebGraphicsContext3DImpl methods
+ virtual bool InitializeOnCurrentThread() OVERRIDE;
+
//----------------------------------------------------------------------
// WebGraphicsContext3D methods
-
- // Must be called after initialize() and before any of the following methods.
- // Permanently binds to the first calling thread. Returns false if the
- // graphics context fails to create. Do not call from more than one thread.
- virtual bool makeContextCurrent();
-
virtual bool isContextLost();
virtual WGC3Denum getGraphicsResetStatusARB();
diff --git a/content/renderer/android/synchronous_compositor_factory.h b/content/renderer/android/synchronous_compositor_factory.h
index c21d82ac..e5d9aa0 100644
--- a/content/renderer/android/synchronous_compositor_factory.h
+++ b/content/renderer/android/synchronous_compositor_factory.h
@@ -21,6 +21,7 @@ class OutputSurface;
namespace webkit {
namespace gpu {
class ContextProviderWebContext;
+class WebGraphicsContext3DImpl;
}
}
@@ -57,8 +58,9 @@ class SynchronousCompositorFactory {
const std::string& debug_name) = 0;
virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
int frame_id) = 0;
- virtual blink::WebGraphicsContext3D* CreateOffscreenGraphicsContext3D(
- const blink::WebGraphicsContext3D::Attributes& attributes) = 0;
+ virtual webkit::gpu::WebGraphicsContext3DImpl*
+ CreateOffscreenGraphicsContext3D(
+ const blink::WebGraphicsContext3D::Attributes& attributes) = 0;
protected:
SynchronousCompositorFactory() {}
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index c3d6cec..7acf0ad 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -532,7 +532,7 @@ void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas,
if (!provider)
return;
blink::WebGraphicsContext3D* context3D = provider->context3d();
- if (!context3D || !context3D->makeContextCurrent())
+ if (!context3D)
return;
// Copy video texture into a RGBA texture based bitmap first as video texture
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index 2516000..797285f 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -952,26 +952,35 @@ RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D(
if (!RenderThreadImpl::current())
return NULL;
+ scoped_ptr<webkit::gpu::WebGraphicsContext3DImpl> context;
+ bool must_use_synchronous_factory = false;
#if defined(OS_ANDROID)
if (SynchronousCompositorFactory* factory =
SynchronousCompositorFactory::GetInstance()) {
- return factory->CreateOffscreenGraphicsContext3D(attributes);
+ context.reset(factory->CreateOffscreenGraphicsContext3D(attributes));
+ must_use_synchronous_factory = true;
}
#endif
-
- scoped_refptr<GpuChannelHost> gpu_channel_host(
- RenderThreadImpl::current()->EstablishGpuChannelSync(
- CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
-
- WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
- bool lose_context_when_out_of_memory = false;
- return WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
- gpu_channel_host.get(),
- attributes,
- lose_context_when_out_of_memory,
- GURL(attributes.topDocumentURL),
- limits,
- static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context));
+ if (!must_use_synchronous_factory) {
+ scoped_refptr<GpuChannelHost> gpu_channel_host(
+ RenderThreadImpl::current()->EstablishGpuChannelSync(
+ CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
+
+ WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
+ bool lose_context_when_out_of_memory = false;
+ context.reset(WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
+ gpu_channel_host.get(),
+ attributes,
+ lose_context_when_out_of_memory,
+ GURL(attributes.topDocumentURL),
+ limits,
+ static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context)));
+ }
+ // Most likely the GPU process exited and the attempt to reconnect to it
+ // failed. Need to try to restore the context again later.
+ if (!context || !context->InitializeOnCurrentThread())
+ return NULL;
+ return context.release();
}
//------------------------------------------------------------------------------
diff --git a/content/shell/renderer/test_runner/TestPlugin.cpp b/content/shell/renderer/test_runner/TestPlugin.cpp
index cb33167..b7bcfd3 100644
--- a/content/shell/renderer/test_runner/TestPlugin.cpp
+++ b/content/shell/renderer/test_runner/TestPlugin.cpp
@@ -192,10 +192,6 @@ bool TestPlugin::initialize(WebPluginContainer* container)
{
WebGraphicsContext3D::Attributes attrs;
m_context = Platform::current()->createOffscreenGraphicsContext3D(attrs);
- if (m_context && !m_context->makeContextCurrent()) {
- delete m_context;
- m_context = 0;
- }
if (!initScene())
return false;
diff --git a/webkit/common/gpu/context_provider_in_process.cc b/webkit/common/gpu/context_provider_in_process.cc
index e4ca1d8..b02d961 100644
--- a/webkit/common/gpu/context_provider_in_process.cc
+++ b/webkit/common/gpu/context_provider_in_process.cc
@@ -95,7 +95,7 @@ bool ContextProviderInProcess::BindToCurrentThread() {
if (lost_context_callback_proxy_)
return true;
- if (!context3d_->makeContextCurrent())
+ if (!context3d_->InitializeOnCurrentThread())
return false;
InitializeCapabilities();
diff --git a/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc b/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc
index 5c7bc39..fb2013c 100644
--- a/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc
+++ b/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc
@@ -5,24 +5,46 @@
#include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
#include "base/debug/trace_event.h"
-#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
+#include "base/lazy_instance.h"
+#include "gpu/command_buffer/client/gles2_lib.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
+#include "webkit/common/gpu/webgraphicscontext3d_impl.h"
namespace webkit {
namespace gpu {
-static void BindWebGraphicsContext3DGLContextCallback(
- const GrGLInterface* interface) {
- reinterpret_cast<blink::WebGraphicsContext3D*>(
- interface->fCallbackData)->makeContextCurrent();
+namespace {
+
+// Singleton used to initialize and terminate the gles2 library.
+class GLES2Initializer {
+ public:
+ GLES2Initializer() { gles2::Initialize(); }
+
+ ~GLES2Initializer() { gles2::Terminate(); }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
+};
+
+base::LazyInstance<GLES2Initializer> g_gles2_initializer =
+ LAZY_INSTANCE_INITIALIZER;
+
+void BindWebGraphicsContext3DGLContextCallback(const GrGLInterface* interface) {
+ gles2::SetGLContext(reinterpret_cast<WebGraphicsContext3DImpl*>(
+ interface->fCallbackData)->GetGLInterface());
}
+} // namespace anonymous
+
GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D(
- blink::WebGraphicsContext3D* context3d) {
+ WebGraphicsContext3DImpl* context3d) {
if (!context3d)
return;
+ // Ensure the gles2 library is initialized first in a thread safe way.
+ g_gles2_initializer.Get();
+ gles2::SetGLContext(context3d->GetGLInterface());
skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(
context3d->createGrGLInterface());
if (!interface)
diff --git a/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h b/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h
index 5c983aa..5ea712b 100644
--- a/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h
+++ b/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h
@@ -10,10 +10,10 @@
#include "webkit/common/gpu/webkit_gpu_export.h"
class GrContext;
-namespace blink { class WebGraphicsContext3D; }
namespace webkit {
namespace gpu {
+class WebGraphicsContext3DImpl;
// This class binds an offscreen GrContext to an offscreen context3d. The
// context3d is used by the GrContext so must be valid as long as this class
@@ -21,7 +21,7 @@ namespace gpu {
class WEBKIT_GPU_EXPORT GrContextForWebGraphicsContext3D {
public:
explicit GrContextForWebGraphicsContext3D(
- blink::WebGraphicsContext3D* context3d);
+ WebGraphicsContext3DImpl* context3d);
virtual ~GrContextForWebGraphicsContext3D();
GrContext* get() { return gr_context_.get(); }
diff --git a/webkit/common/gpu/webgraphicscontext3d_impl.cc b/webkit/common/gpu/webgraphicscontext3d_impl.cc
index abf9d95..012d487 100644
--- a/webkit/common/gpu/webgraphicscontext3d_impl.cc
+++ b/webkit/common/gpu/webgraphicscontext3d_impl.cc
@@ -937,7 +937,6 @@ DELEGATE_TO_GL_5(renderbufferStorageMultisampleEXT,
WGC3Denum, WGC3Dsizei, WGC3Dsizei)
GrGLInterface* WebGraphicsContext3DImpl::createGrGLInterface() {
- makeContextCurrent();
return skia_bindings::CreateCommandBufferSkiaGLBinding();
}
diff --git a/webkit/common/gpu/webgraphicscontext3d_impl.h b/webkit/common/gpu/webgraphicscontext3d_impl.h
index 5cb055d..9097b8f 100644
--- a/webkit/common/gpu/webgraphicscontext3d_impl.h
+++ b/webkit/common/gpu/webgraphicscontext3d_impl.h
@@ -46,6 +46,13 @@ class WebGraphicsContext3DErrorMessageCallback;
class WEBKIT_GPU_EXPORT WebGraphicsContext3DImpl
: public NON_EXPORTED_BASE(blink::WebGraphicsContext3D) {
public:
+ virtual ~WebGraphicsContext3DImpl();
+
+ // Must be called before any of the following methods. Permanently binds to
+ // the first calling thread. Returns false if the graphics context fails to
+ // initialize. Do not call from more than one thread.
+ virtual bool InitializeOnCurrentThread() = 0;
+
//----------------------------------------------------------------------
// WebGraphicsContext3D methods
@@ -570,7 +577,6 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DImpl
friend class WebGraphicsContext3DErrorMessageCallback;
WebGraphicsContext3DImpl();
- virtual ~WebGraphicsContext3DImpl();
::gpu::gles2::GLES2ImplementationErrorMessageCallback*
getErrorMessageCallback();
diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
index 2dc7dc8..c96f464 100644
--- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
+++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
@@ -17,10 +17,8 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
-#include "base/lazy_instance.h"
#include "base/logging.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
-#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
#include "ui/gfx/size.h"
@@ -32,28 +30,6 @@ using gpu::GLInProcessContext;
namespace webkit {
namespace gpu {
-namespace {
-
-// Singleton used to initialize and terminate the gles2 library.
-class GLES2Initializer {
- public:
- GLES2Initializer() {
- ::gles2::Initialize();
- }
-
- ~GLES2Initializer() {
- ::gles2::Terminate();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
-};
-
-static base::LazyInstance<GLES2Initializer> g_gles2_initializer =
- LAZY_INSTANCE_INITIALIZER;
-
-} // namespace anonymous
-
// static
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
@@ -129,9 +105,6 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
if (initialize_failed_)
return false;
- // Ensure the gles2 library is initialized first in a thread safe way.
- g_gles2_initializer.Get();
-
if (!context_) {
// TODO(kbr): More work will be needed in this implementation to
// properly support GPU switching. Like in the out-of-process
@@ -172,10 +145,10 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
return true;
}
-bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() {
+bool
+WebGraphicsContext3DInProcessCommandBufferImpl::InitializeOnCurrentThread() {
if (!MaybeInitializeGL())
return false;
- ::gles2::SetGLContext(GetGLInterface());
return context_ && !isContextLost();
}
diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
index 0248dff..62197fd 100644
--- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
+++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
@@ -60,10 +60,11 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
size_t GetMappedMemoryLimit();
+ // WebGraphicsContext3DImpl methods
+ virtual bool InitializeOnCurrentThread() OVERRIDE;
+
//----------------------------------------------------------------------
// WebGraphicsContext3D methods
- virtual bool makeContextCurrent();
-
virtual bool isContextLost();
virtual WGC3Denum getGraphicsResetStatusARB();