OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/lib/gl/gles2/gl2ext_ppapi.h" | 5 #include "ppapi/lib/gl/gles2/gl2ext_ppapi.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #ifndef GL_FALSE | 9 #ifndef GL_FALSE |
10 #define GL_FALSE 0 | 10 #define GL_FALSE 0 |
11 #endif // GL_FALSE | 11 #endif // GL_FALSE |
12 | 12 |
13 #ifndef GL_TRUE | 13 #ifndef GL_TRUE |
14 #define GL_TRUE 1 | 14 #define GL_TRUE 1 |
15 #endif // GL_TRUE | 15 #endif // GL_TRUE |
16 | 16 |
17 #if defined(__GNUC__) && !defined(__APPLE__) | 17 #if defined(__GNUC__) && !defined(__APPLE__) |
18 #define PP_TLS __thread | 18 #define PP_TLS __thread |
19 #elif defined(_MSC_VER) | 19 #elif defined(_MSC_VER) |
20 #define PP_TLS __declspec(thread) | 20 #define PP_TLS __declspec(thread) |
21 #else | 21 #else |
22 // TODO(alokp): Fix all other platforms. | 22 // TODO(alokp): Fix all other platforms. |
23 #define PP_TLS | 23 #define PP_TLS |
24 #endif | 24 #endif |
25 | 25 |
26 // TODO(alokp): This will need to be thread-safe if we build gles2 as a | 26 // TODO(alokp): This will need to be thread-safe if we build gles2 as a |
27 // shared library. | 27 // shared library. |
28 static const struct PPB_OpenGLES2* g_gles2_interface = NULL; | 28 static const struct PPB_OpenGLES2* g_gles2_interface = NULL; |
| 29 static const struct PPB_OpenGLES2InstancedArrays* |
| 30 g_gles2_instanced_arrays_interface = NULL; |
| 31 static const struct PPB_OpenGLES2FramebufferBlit* |
| 32 g_gles2_framebuffer_blit_interface = NULL; |
| 33 static const struct PPB_OpenGLES2FramebufferMultisample* |
| 34 g_gles2_framebuffer_multisample_interface = NULL; |
| 35 static const struct PPB_OpenGLES2ChromiumEnableFeature* |
| 36 g_gles2_chromium_enable_feature_interface = NULL; |
| 37 static const struct PPB_OpenGLES2ChromiumMapSub* |
| 38 g_gles2_chromium_map_sub_interface = NULL; |
29 | 39 |
30 // TODO(alokp): Make sure PP_TLS works on all supported platforms. | 40 // TODO(alokp): Make sure PP_TLS works on all supported platforms. |
31 static PP_TLS PP_Resource g_current_context = 0; | 41 static PP_TLS PP_Resource g_current_context = 0; |
32 | 42 |
33 GLboolean GL_APIENTRY glInitializePPAPI( | 43 GLboolean GL_APIENTRY glInitializePPAPI( |
34 PPB_GetInterface get_browser_interface) { | 44 PPB_GetInterface get_browser_interface) { |
35 if (!g_gles2_interface) { | 45 if (!g_gles2_interface) { |
36 g_gles2_interface = get_browser_interface(PPB_OPENGLES2_INTERFACE); | 46 g_gles2_interface = get_browser_interface(PPB_OPENGLES2_INTERFACE); |
37 } | 47 } |
| 48 if (!g_gles2_instanced_arrays_interface) { |
| 49 g_gles2_instanced_arrays_interface = |
| 50 get_browser_interface(PPB_OPENGLES2_INSTANCEDARRAYS_INTERFACE); |
| 51 } |
| 52 if (!g_gles2_framebuffer_blit_interface) { |
| 53 g_gles2_framebuffer_blit_interface = |
| 54 get_browser_interface(PPB_OPENGLES2_FRAMEBUFFERBLIT_INTERFACE); |
| 55 } |
| 56 if (!g_gles2_framebuffer_multisample_interface) { |
| 57 g_gles2_framebuffer_multisample_interface = |
| 58 get_browser_interface(PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE); |
| 59 } |
| 60 if (!g_gles2_chromium_enable_feature_interface) { |
| 61 g_gles2_chromium_enable_feature_interface = |
| 62 get_browser_interface(PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE); |
| 63 } |
| 64 if (!g_gles2_chromium_map_sub_interface) { |
| 65 g_gles2_chromium_map_sub_interface = |
| 66 get_browser_interface(PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE); |
| 67 } |
38 return g_gles2_interface ? GL_TRUE : GL_FALSE; | 68 return g_gles2_interface ? GL_TRUE : GL_FALSE; |
39 } | 69 } |
40 | 70 |
41 GLboolean GL_APIENTRY glTerminatePPAPI() { | 71 GLboolean GL_APIENTRY glTerminatePPAPI() { |
42 g_gles2_interface = NULL; | 72 g_gles2_interface = NULL; |
43 return GL_TRUE; | 73 return GL_TRUE; |
44 } | 74 } |
45 | 75 |
46 void GL_APIENTRY glSetCurrentContextPPAPI(PP_Resource context) { | 76 void GL_APIENTRY glSetCurrentContextPPAPI(PP_Resource context) { |
47 g_current_context = context; | 77 g_current_context = context; |
48 } | 78 } |
49 | 79 |
50 PP_Resource GL_APIENTRY glGetCurrentContextPPAPI() { | 80 PP_Resource GL_APIENTRY glGetCurrentContextPPAPI() { |
51 return g_current_context; | 81 return g_current_context; |
52 } | 82 } |
53 | 83 |
54 const struct PPB_OpenGLES2* GL_APIENTRY glGetInterfacePPAPI() { | 84 const struct PPB_OpenGLES2* GL_APIENTRY glGetInterfacePPAPI() { |
55 return g_gles2_interface; | 85 return g_gles2_interface; |
56 } | 86 } |
57 | 87 |
| 88 const struct PPB_OpenGLES2InstancedArrays* GL_APIENTRY |
| 89 glGetInstancedArraysInterfacePPAPI() { |
| 90 return g_gles2_instanced_arrays_interface; |
| 91 } |
| 92 |
| 93 const struct PPB_OpenGLES2FramebufferBlit* GL_APIENTRY |
| 94 glGetFramebufferBlitInterfacePPAPI() { |
| 95 return g_gles2_framebuffer_blit_interface; |
| 96 } |
| 97 |
| 98 const struct PPB_OpenGLES2FramebufferMultisample* GL_APIENTRY |
| 99 glGetFramebufferMultisampleInterfacePPAPI() { |
| 100 return g_gles2_framebuffer_multisample_interface; |
| 101 } |
| 102 |
| 103 const struct PPB_OpenGLES2ChromiumEnableFeature* GL_APIENTRY |
| 104 glGetChromiumEnableFeatureInterfacePPAPI() { |
| 105 return g_gles2_chromium_enable_feature_interface; |
| 106 } |
| 107 |
| 108 const struct PPB_OpenGLES2ChromiumMapSub* GL_APIENTRY |
| 109 glGetChromiumMapSubInterfacePPAPI() { |
| 110 return g_gles2_chromium_map_sub_interface; |
| 111 } |
OLD | NEW |