• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "mojo/public/gles2/gles2_private.h"
6 
7 #include <assert.h>
8 #include <stddef.h>
9 
10 #include "mojo/public/c/gles2/gles2.h"
11 #include "mojo/public/gles2/gles2_interface.h"
12 
13 static mojo::GLES2Support* g_gles2_support = NULL;
14 static mojo::GLES2Interface* g_gles2_interface = NULL;
15 
16 extern "C" {
17 
MojoGLES2Initialize(const MojoAsyncWaiter * async_waiter)18 void MojoGLES2Initialize(const MojoAsyncWaiter* async_waiter) {
19   assert(g_gles2_support);
20   return g_gles2_support->Initialize(async_waiter);
21 }
22 
MojoGLES2Terminate()23 void MojoGLES2Terminate() {
24   assert(g_gles2_support);
25   return g_gles2_support->Terminate();
26 }
27 
MojoGLES2CreateContext(MojoHandle handle,MojoGLES2ContextLost lost_callback,MojoGLES2DrawAnimationFrame animation_callback,void * closure)28 MojoGLES2Context MojoGLES2CreateContext(
29     MojoHandle handle,
30     MojoGLES2ContextLost lost_callback,
31     MojoGLES2DrawAnimationFrame animation_callback,
32     void* closure) {
33   return g_gles2_support->CreateContext(mojo::MessagePipeHandle(handle),
34                                         lost_callback,
35                                         animation_callback,
36                                         closure);
37 }
38 
MojoGLES2DestroyContext(MojoGLES2Context context)39 void MojoGLES2DestroyContext(MojoGLES2Context context) {
40   return g_gles2_support->DestroyContext(context);
41 }
42 
MojoGLES2MakeCurrent(MojoGLES2Context context)43 void MojoGLES2MakeCurrent(MojoGLES2Context context) {
44   assert(g_gles2_support);
45   g_gles2_support->MakeCurrent(context);
46   g_gles2_interface = g_gles2_support->GetGLES2InterfaceForCurrentContext();
47 }
48 
MojoGLES2SwapBuffers()49 void MojoGLES2SwapBuffers() {
50   assert(g_gles2_support);
51   return g_gles2_support->SwapBuffers();
52 }
53 
MojoGLES2RequestAnimationFrames(MojoGLES2Context context)54 void MojoGLES2RequestAnimationFrames(MojoGLES2Context context) {
55   assert(g_gles2_support);
56   return g_gles2_support->RequestAnimationFrames(context);
57 }
58 
MojoGLES2CancelAnimationFrames(MojoGLES2Context context)59 void MojoGLES2CancelAnimationFrames(MojoGLES2Context context) {
60   assert(g_gles2_support);
61   return g_gles2_support->CancelAnimationFrames(context);
62 }
63 
MojoGLES2GetGLES2Interface(MojoGLES2Context context)64 void* MojoGLES2GetGLES2Interface(MojoGLES2Context context) {
65   assert(g_gles2_support);
66   return g_gles2_support->GetGLES2Interface(context);
67 }
68 
MojoGLES2GetContextSupport(MojoGLES2Context context)69 void* MojoGLES2GetContextSupport(MojoGLES2Context context) {
70   assert(g_gles2_support);
71   return g_gles2_support->GetContextSupport(context);
72 }
73 
74 #define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
75   ReturnType gl##Function PARAMETERS {                             \
76     return g_gles2_interface->Function ARGUMENTS;                  \
77   }
78 #include "mojo/public/c/gles2/gles2_call_visitor_autogen.h"
79 #undef VISIT_GL_CALL
80 
81 }  // extern "C"
82 
83 namespace mojo {
84 
~GLES2Support()85 GLES2Support::~GLES2Support() {}
86 
Init(GLES2Support * gles2_support)87 void GLES2Support::Init(GLES2Support* gles2_support) {
88   assert(!g_gles2_support);
89   g_gles2_support = gles2_support;
90 }
91 
92 }  // namespace mojo
93