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