summaryrefslogtreecommitdiffstats
path: root/webkit
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 /webkit
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}
Diffstat (limited to 'webkit')
-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
7 files changed, 43 insertions, 42 deletions
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();