Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1869)

Unified Diff: webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc

Issue 470973002: gpu: Remove WebGraphicsContext3D::makeContextCurrent() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix in unittests Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc
diff --git a/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc b/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc
index 5c7bc39ec3a68288b4b2f509e57c939028d09fb7..fb2013c922270c856ac3dca16016a7f7ef2a5077 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)
« no previous file with comments | « webkit/common/gpu/grcontext_for_webgraphicscontext3d.h ('k') | webkit/common/gpu/webgraphicscontext3d_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698