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

Unified Diff: mojo/gles2/gles2_impl.cc

Issue 413303002: mojo: Convert gles2 to the new thunking system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add forgotten file. Created 6 years, 5 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
« no previous file with comments | « mojo/gles2/BUILD.gn ('k') | mojo/gles2/gles2_support_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/gles2/gles2_impl.cc
diff --git a/mojo/gles2/gles2_impl.cc b/mojo/gles2/gles2_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..59b427846589649b4cc59b963646a7abc99da2c4
--- /dev/null
+++ b/mojo/gles2/gles2_impl.cc
@@ -0,0 +1,82 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/public/c/gles2/gles2.h"
+
+#include "gpu/command_buffer/client/gles2_interface.h"
+#include "mojo/gles2/gles2_context.h"
+
+using mojo::gles2::GLES2Context;
+
+namespace {
+
+const MojoAsyncWaiter* g_async_waiter = NULL;
+gpu::gles2::GLES2Interface* g_gpu_interface = NULL;
+
+} // namespace
+
+extern "C" {
+
+void MojoGLES2Initialize(const MojoAsyncWaiter* async_waiter) {
+ DCHECK(!g_async_waiter);
+ DCHECK(async_waiter);
+ g_async_waiter = async_waiter;
+}
+
+void MojoGLES2Terminate() {
+ DCHECK(g_async_waiter);
+ g_async_waiter = NULL;
+}
+
+MojoGLES2Context MojoGLES2CreateContext(
+ MojoHandle handle,
+ MojoGLES2ContextLost lost_callback,
+ void* closure) {
+ mojo::MessagePipeHandle mph(handle);
+ mojo::ScopedMessagePipeHandle scoped_handle(mph);
+ scoped_ptr<GLES2Context> client(new GLES2Context(g_async_waiter,
+ scoped_handle.Pass(),
+ lost_callback,
+ closure));
+ if (!client->Initialize())
+ client.reset();
+ return client.release();
+}
+
+void MojoGLES2DestroyContext(MojoGLES2Context context) {
+ delete static_cast<GLES2Context*>(context);
+}
+
+void MojoGLES2MakeCurrent(MojoGLES2Context context) {
+ gpu::gles2::GLES2Interface* interface = NULL;
+ if (context) {
+ GLES2Context* client = static_cast<GLES2Context*>(context);
+ interface = client->interface();
+ DCHECK(interface);
+ }
+ g_gpu_interface = interface;
+}
+
+void MojoGLES2SwapBuffers() {
+ assert(g_gpu_interface);
+ g_gpu_interface->SwapBuffers();
+}
+
+void* MojoGLES2GetGLES2Interface(MojoGLES2Context context) {
+ return static_cast<GLES2Context*>(context)->interface();
+}
+
+void* MojoGLES2GetContextSupport(MojoGLES2Context context) {
+ return static_cast<GLES2Context*>(context)->context_support();
+}
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+ ReturnType gl##Function PARAMETERS { \
+ assert(g_gpu_interface); \
+ return g_gpu_interface->Function ARGUMENTS; \
+ }
+#include "mojo/public/c/gles2/gles2_call_visitor_autogen.h"
+#undef VISIT_GL_CALL
+
+} // extern "C"
« no previous file with comments | « mojo/gles2/BUILD.gn ('k') | mojo/gles2/gles2_support_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698