OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_Dev* | 29 static const struct PPB_OpenGLES2InstancedArrays* |
30 g_gles2_instanced_arrays_interface = NULL; | 30 g_gles2_instanced_arrays_interface = NULL; |
31 static const struct PPB_OpenGLES2FramebufferBlit_Dev* | 31 static const struct PPB_OpenGLES2FramebufferBlit* |
32 g_gles2_framebuffer_blit_interface = NULL; | 32 g_gles2_framebuffer_blit_interface = NULL; |
33 static const struct PPB_OpenGLES2FramebufferMultisample_Dev* | 33 static const struct PPB_OpenGLES2FramebufferMultisample* |
34 g_gles2_framebuffer_multisample_interface = NULL; | 34 g_gles2_framebuffer_multisample_interface = NULL; |
35 static const struct PPB_OpenGLES2ChromiumEnableFeature_Dev* | 35 static const struct PPB_OpenGLES2ChromiumEnableFeature* |
36 g_gles2_chromium_enable_feature_interface = NULL; | 36 g_gles2_chromium_enable_feature_interface = NULL; |
37 static const struct PPB_OpenGLES2ChromiumMapSub_Dev* | 37 static const struct PPB_OpenGLES2ChromiumMapSub* |
38 g_gles2_chromium_map_sub_interface = NULL; | 38 g_gles2_chromium_map_sub_interface = NULL; |
39 static const struct PPB_OpenGLES2Query_Dev* | 39 static const struct PPB_OpenGLES2Query* |
40 g_gles2_query_interface = NULL; | 40 g_gles2_query_interface = NULL; |
41 | 41 |
42 // TODO(alokp): Make sure PP_TLS works on all supported platforms. | 42 // TODO(alokp): Make sure PP_TLS works on all supported platforms. |
43 static PP_TLS PP_Resource g_current_context = 0; | 43 static PP_TLS PP_Resource g_current_context = 0; |
44 | 44 |
45 GLboolean GL_APIENTRY glInitializePPAPI( | 45 GLboolean GL_APIENTRY glInitializePPAPI( |
46 PPB_GetInterface get_browser_interface) { | 46 PPB_GetInterface get_browser_interface) { |
47 if (!g_gles2_interface) { | 47 if (!g_gles2_interface) { |
48 g_gles2_interface = get_browser_interface(PPB_OPENGLES2_INTERFACE); | 48 g_gles2_interface = get_browser_interface(PPB_OPENGLES2_INTERFACE); |
49 } | 49 } |
50 if (!g_gles2_instanced_arrays_interface) { | 50 if (!g_gles2_instanced_arrays_interface) { |
51 g_gles2_instanced_arrays_interface = | 51 g_gles2_instanced_arrays_interface = |
52 get_browser_interface(PPB_OPENGLES2_INSTANCEDARRAYS_DEV_INTERFACE); | 52 get_browser_interface(PPB_OPENGLES2_INSTANCEDARRAYS_INTERFACE); |
53 } | 53 } |
54 if (!g_gles2_framebuffer_blit_interface) { | 54 if (!g_gles2_framebuffer_blit_interface) { |
55 g_gles2_framebuffer_blit_interface = | 55 g_gles2_framebuffer_blit_interface = |
56 get_browser_interface(PPB_OPENGLES2_FRAMEBUFFERBLIT_DEV_INTERFACE); | 56 get_browser_interface(PPB_OPENGLES2_FRAMEBUFFERBLIT_INTERFACE); |
57 } | 57 } |
58 if (!g_gles2_framebuffer_multisample_interface) { | 58 if (!g_gles2_framebuffer_multisample_interface) { |
59 g_gles2_framebuffer_multisample_interface = | 59 g_gles2_framebuffer_multisample_interface = |
60 get_browser_interface( | 60 get_browser_interface( |
61 PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_DEV_INTERFACE); | 61 PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE); |
62 } | 62 } |
63 if (!g_gles2_chromium_enable_feature_interface) { | 63 if (!g_gles2_chromium_enable_feature_interface) { |
64 g_gles2_chromium_enable_feature_interface = | 64 g_gles2_chromium_enable_feature_interface = |
65 get_browser_interface( | 65 get_browser_interface( |
66 PPB_OPENGLES2_CHROMIUMENABLEFEATURE_DEV_INTERFACE); | 66 PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE); |
67 } | 67 } |
68 if (!g_gles2_chromium_map_sub_interface) { | 68 if (!g_gles2_chromium_map_sub_interface) { |
69 g_gles2_chromium_map_sub_interface = | 69 g_gles2_chromium_map_sub_interface = |
70 get_browser_interface(PPB_OPENGLES2_CHROMIUMMAPSUB_DEV_INTERFACE); | 70 get_browser_interface(PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE); |
71 } | 71 } |
72 if (!g_gles2_query_interface) { | 72 if (!g_gles2_query_interface) { |
73 g_gles2_query_interface = | 73 g_gles2_query_interface = |
74 get_browser_interface(PPB_OPENGLES2_QUERY_DEV_INTERFACE); | 74 get_browser_interface(PPB_OPENGLES2_QUERY_INTERFACE); |
75 } | 75 } |
76 return g_gles2_interface ? GL_TRUE : GL_FALSE; | 76 return g_gles2_interface ? GL_TRUE : GL_FALSE; |
77 } | 77 } |
78 | 78 |
79 GLboolean GL_APIENTRY glTerminatePPAPI() { | 79 GLboolean GL_APIENTRY glTerminatePPAPI() { |
80 g_gles2_interface = NULL; | 80 g_gles2_interface = NULL; |
81 return GL_TRUE; | 81 return GL_TRUE; |
82 } | 82 } |
83 | 83 |
84 void GL_APIENTRY glSetCurrentContextPPAPI(PP_Resource context) { | 84 void GL_APIENTRY glSetCurrentContextPPAPI(PP_Resource context) { |
85 g_current_context = context; | 85 g_current_context = context; |
86 } | 86 } |
87 | 87 |
88 PP_Resource GL_APIENTRY glGetCurrentContextPPAPI() { | 88 PP_Resource GL_APIENTRY glGetCurrentContextPPAPI() { |
89 return g_current_context; | 89 return g_current_context; |
90 } | 90 } |
91 | 91 |
92 const struct PPB_OpenGLES2* GL_APIENTRY glGetInterfacePPAPI() { | 92 const struct PPB_OpenGLES2* GL_APIENTRY glGetInterfacePPAPI() { |
93 return g_gles2_interface; | 93 return g_gles2_interface; |
94 } | 94 } |
95 | 95 |
96 const struct PPB_OpenGLES2InstancedArrays_Dev* GL_APIENTRY | 96 const struct PPB_OpenGLES2InstancedArrays* GL_APIENTRY |
97 glGetInstancedArraysInterfacePPAPI() { | 97 glGetInstancedArraysInterfacePPAPI() { |
98 return g_gles2_instanced_arrays_interface; | 98 return g_gles2_instanced_arrays_interface; |
99 } | 99 } |
100 | 100 |
101 const struct PPB_OpenGLES2FramebufferBlit_Dev* GL_APIENTRY | 101 const struct PPB_OpenGLES2FramebufferBlit* GL_APIENTRY |
102 glGetFramebufferBlitInterfacePPAPI() { | 102 glGetFramebufferBlitInterfacePPAPI() { |
103 return g_gles2_framebuffer_blit_interface; | 103 return g_gles2_framebuffer_blit_interface; |
104 } | 104 } |
105 | 105 |
106 const struct PPB_OpenGLES2FramebufferMultisample_Dev* GL_APIENTRY | 106 const struct PPB_OpenGLES2FramebufferMultisample* GL_APIENTRY |
107 glGetFramebufferMultisampleInterfacePPAPI() { | 107 glGetFramebufferMultisampleInterfacePPAPI() { |
108 return g_gles2_framebuffer_multisample_interface; | 108 return g_gles2_framebuffer_multisample_interface; |
109 } | 109 } |
110 | 110 |
111 const struct PPB_OpenGLES2ChromiumEnableFeature_Dev* GL_APIENTRY | 111 const struct PPB_OpenGLES2ChromiumEnableFeature* GL_APIENTRY |
112 glGetChromiumEnableFeatureInterfacePPAPI() { | 112 glGetChromiumEnableFeatureInterfacePPAPI() { |
113 return g_gles2_chromium_enable_feature_interface; | 113 return g_gles2_chromium_enable_feature_interface; |
114 } | 114 } |
115 | 115 |
116 const struct PPB_OpenGLES2ChromiumMapSub_Dev* GL_APIENTRY | 116 const struct PPB_OpenGLES2ChromiumMapSub* GL_APIENTRY |
117 glGetChromiumMapSubInterfacePPAPI() { | 117 glGetChromiumMapSubInterfacePPAPI() { |
118 return g_gles2_chromium_map_sub_interface; | 118 return g_gles2_chromium_map_sub_interface; |
119 } | 119 } |
120 | 120 |
121 const struct PPB_OpenGLES2Query_Dev* GL_APIENTRY | 121 const struct PPB_OpenGLES2Query* GL_APIENTRY |
122 glGetQueryInterfacePPAPI() { | 122 glGetQueryInterfacePPAPI() { |
123 return g_gles2_query_interface; | 123 return g_gles2_query_interface; |
124 } | 124 } |
OLD | NEW |