OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * | |
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 */ | |
25 | |
26 #ifndef Extensions3D_h | |
27 #define Extensions3D_h | |
28 | |
29 #include "platform/graphics/GraphicsTypes3D.h" | |
30 | |
31 #include "wtf/text/WTFString.h" | |
32 | |
33 namespace WebCore { | |
34 | |
35 class GraphicsContext3D; | |
36 class ImageBuffer; | |
37 | |
38 // The supported extensions are defined below. | |
39 // | |
40 // Calling any extension function not supported by the current context | |
41 // must be a no-op; in particular, it may not have side effects. In | |
42 // this situation, if the function has a return value, 0 is returned. | |
43 class Extensions3D { | |
44 public: | |
45 ~Extensions3D(); | |
46 | |
47 // Supported extensions: | |
48 // GL_EXT_texture_format_BGRA8888 | |
49 // GL_EXT_read_format_bgra | |
50 // GL_ARB_robustness | |
51 // GL_ARB_texture_non_power_of_two / GL_OES_texture_npot | |
52 // GL_EXT_packed_depth_stencil / GL_OES_packed_depth_stencil | |
53 // GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample | |
54 // GL_OES_texture_float | |
55 // GL_OES_texture_float_linear | |
56 // GL_OES_texture_half_float | |
57 // GL_OES_texture_half_float_linear | |
58 // GL_OES_standard_derivatives | |
59 // GL_OES_rgb8_rgba8 | |
60 // GL_OES_vertex_array_object | |
61 // GL_OES_element_index_uint | |
62 // GL_ANGLE_translated_shader_source | |
63 // GL_ARB_texture_rectangle (only the subset required to | |
64 // implement IOSurface binding; it's recommended to support | |
65 // this only on Mac OS X to limit the amount of code dependent | |
66 // on this extension) | |
67 // GL_EXT_texture_compression_dxt1 | |
68 // GL_EXT_texture_compression_s3tc | |
69 // GL_OES_compressed_ETC1_RGB8_texture | |
70 // GL_IMG_texture_compression_pvrtc | |
71 // EXT_texture_filter_anisotropic | |
72 // GL_EXT_debug_marker | |
73 // GL_CHROMIUM_copy_texture | |
74 // GL_CHROMIUM_flipy | |
75 // GL_ARB_draw_buffers / GL_EXT_draw_buffers | |
76 // GL_ANGLE_instanced_arrays | |
77 | |
78 // GL_CHROMIUM_shallow_flush : only supported if an ipc command buffer is
used. | |
79 // GL_CHROMIUM_resource_safe : indicating that textures/renderbuffers are
always initialized before read/write. | |
80 // GL_CHROMIUM_strict_attribs : indicating a GL error is generated for out
-of-bounds buffer accesses. | |
81 // GL_CHROMIUM_post_sub_buffer | |
82 // GL_CHROMIUM_map_sub | |
83 // GL_CHROMIUM_swapbuffers_complete_callback | |
84 // GL_CHROMIUM_rate_limit_offscreen_context | |
85 // GL_CHROMIUM_paint_framebuffer_canvas | |
86 // GL_CHROMIUM_iosurface (Mac OS X specific) | |
87 // GL_CHROMIUM_command_buffer_query | |
88 // GL_ANGLE_texture_usage | |
89 // GL_EXT_debug_marker | |
90 // GL_EXT_texture_storage | |
91 // GL_EXT_occlusion_query_boolean | |
92 | |
93 // Takes full name of extension; for example, | |
94 // "GL_EXT_texture_format_BGRA8888". | |
95 bool supports(const String&); | |
96 | |
97 // Certain OpenGL and WebGL implementations may support enabling | |
98 // extensions lazily. This method may only be called with | |
99 // extension names for which supports returns true. | |
100 void ensureEnabled(const String&); | |
101 | |
102 // Takes full name of extension: for example, "GL_EXT_texture_format_BGRA888
8". | |
103 // Checks to see whether the given extension is actually enabled (see ensure
Enabled). | |
104 // Has no other side-effects. | |
105 bool isEnabled(const String&); | |
106 | |
107 enum ExtensionsEnumType { | |
108 // GL_EXT_texture_format_BGRA8888 enums | |
109 BGRA_EXT = 0x80E1, | |
110 | |
111 // GL_ARB_robustness/GL_CHROMIUM_lose_context enums | |
112 GUILTY_CONTEXT_RESET_ARB = 0x8253, | |
113 INNOCENT_CONTEXT_RESET_ARB = 0x8254, | |
114 UNKNOWN_CONTEXT_RESET_ARB = 0x8255, | |
115 | |
116 // GL_EXT/OES_packed_depth_stencil enums | |
117 DEPTH24_STENCIL8 = 0x88F0, | |
118 | |
119 // GL_ANGLE_framebuffer_blit names | |
120 READ_FRAMEBUFFER = 0x8CA8, | |
121 DRAW_FRAMEBUFFER = 0x8CA9, | |
122 DRAW_FRAMEBUFFER_BINDING = 0x8CA6, | |
123 READ_FRAMEBUFFER_BINDING = 0x8CAA, | |
124 | |
125 // GL_ANGLE_framebuffer_multisample names | |
126 RENDERBUFFER_SAMPLES = 0x8CAB, | |
127 FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56, | |
128 MAX_SAMPLES = 0x8D57, | |
129 | |
130 // GL_OES_standard_derivatives names | |
131 FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B, | |
132 | |
133 // GL_OES_rgb8_rgba8 names | |
134 RGB8_OES = 0x8051, | |
135 RGBA8_OES = 0x8058, | |
136 | |
137 // GL_OES_vertex_array_object names | |
138 VERTEX_ARRAY_BINDING_OES = 0x85B5, | |
139 | |
140 // GL_ANGLE_translated_shader_source | |
141 TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93A0, | |
142 | |
143 // GL_ARB_texture_rectangle | |
144 TEXTURE_RECTANGLE_ARB = 0x84F5, | |
145 TEXTURE_BINDING_RECTANGLE_ARB = 0x84F6, | |
146 | |
147 // GL_EXT_texture_compression_dxt1 | |
148 // GL_EXT_texture_compression_s3tc | |
149 COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0, | |
150 COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1, | |
151 COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2, | |
152 COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3, | |
153 | |
154 // GL_OES_compressed_ETC1_RGB8_texture | |
155 ETC1_RGB8_OES = 0x8D64, | |
156 | |
157 // GL_IMG_texture_compression_pvrtc | |
158 COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00, | |
159 COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01, | |
160 COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02, | |
161 COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03, | |
162 | |
163 // GL_AMD_compressed_ATC_texture | |
164 COMPRESSED_ATC_RGB_AMD = 0x8C92, | |
165 COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8C93, | |
166 COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87EE, | |
167 | |
168 // GL_EXT_texture_filter_anisotropic | |
169 TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE, | |
170 MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF, | |
171 | |
172 // GL_CHROMIUM_flipy | |
173 UNPACK_FLIP_Y_CHROMIUM = 0x9240, | |
174 | |
175 // GL_CHROMIUM_copy_texture | |
176 UNPACK_PREMULTIPLY_ALPHA_CHROMIUM = 0x9241, | |
177 UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM = 0x9242, | |
178 | |
179 // GL_ARB_draw_buffers / GL_EXT_draw_buffers | |
180 MAX_DRAW_BUFFERS_EXT = 0x8824, | |
181 DRAW_BUFFER0_EXT = 0x8825, | |
182 DRAW_BUFFER1_EXT = 0x8826, | |
183 DRAW_BUFFER2_EXT = 0x8827, | |
184 DRAW_BUFFER3_EXT = 0x8828, | |
185 DRAW_BUFFER4_EXT = 0x8829, | |
186 DRAW_BUFFER5_EXT = 0x882A, | |
187 DRAW_BUFFER6_EXT = 0x882B, | |
188 DRAW_BUFFER7_EXT = 0x882C, | |
189 DRAW_BUFFER8_EXT = 0x882D, | |
190 DRAW_BUFFER9_EXT = 0x882E, | |
191 DRAW_BUFFER10_EXT = 0x882F, | |
192 DRAW_BUFFER11_EXT = 0x8830, | |
193 DRAW_BUFFER12_EXT = 0x8831, | |
194 DRAW_BUFFER13_EXT = 0x8832, | |
195 DRAW_BUFFER14_EXT = 0x8833, | |
196 DRAW_BUFFER15_EXT = 0x8834, | |
197 MAX_COLOR_ATTACHMENTS_EXT = 0x8CDF, | |
198 COLOR_ATTACHMENT0_EXT = 0x8CE0, | |
199 COLOR_ATTACHMENT1_EXT = 0x8CE1, | |
200 COLOR_ATTACHMENT2_EXT = 0x8CE2, | |
201 COLOR_ATTACHMENT3_EXT = 0x8CE3, | |
202 COLOR_ATTACHMENT4_EXT = 0x8CE4, | |
203 COLOR_ATTACHMENT5_EXT = 0x8CE5, | |
204 COLOR_ATTACHMENT6_EXT = 0x8CE6, | |
205 COLOR_ATTACHMENT7_EXT = 0x8CE7, | |
206 COLOR_ATTACHMENT8_EXT = 0x8CE8, | |
207 COLOR_ATTACHMENT9_EXT = 0x8CE9, | |
208 COLOR_ATTACHMENT10_EXT = 0x8CEA, | |
209 COLOR_ATTACHMENT11_EXT = 0x8CEB, | |
210 COLOR_ATTACHMENT12_EXT = 0x8CEC, | |
211 COLOR_ATTACHMENT13_EXT = 0x8CED, | |
212 COLOR_ATTACHMENT14_EXT = 0x8CEE, | |
213 COLOR_ATTACHMENT15_EXT = 0x8CEF, | |
214 | |
215 // GL_OES_EGL_image_external | |
216 GL_TEXTURE_EXTERNAL_OES = 0x8D65, | |
217 | |
218 // GL_CHROMIUM_map_sub (enums inherited from GL_ARB_vertex_buffer_object
) | |
219 READ_ONLY = 0x88B8, | |
220 WRITE_ONLY = 0x88B9, | |
221 | |
222 // GL_ANGLE_texture_usage | |
223 GL_TEXTURE_USAGE_ANGLE = 0x93A2, | |
224 GL_FRAMEBUFFER_ATTACHMENT_ANGLE = 0x93A3, | |
225 | |
226 // GL_EXT_texture_storage | |
227 BGRA8_EXT = 0x93A1, | |
228 | |
229 // GL_EXT_occlusion_query_boolean | |
230 ANY_SAMPLES_PASSED_EXT = 0x8C2F, | |
231 ANY_SAMPLES_PASSED_CONSERVATIVE_EXT = 0x8D6A, | |
232 CURRENT_QUERY_EXT = 0x8865, | |
233 QUERY_RESULT_EXT = 0x8866, | |
234 QUERY_RESULT_AVAILABLE_EXT = 0x8867, | |
235 | |
236 // GL_CHROMIUM_command_buffer_query | |
237 COMMANDS_ISSUED_CHROMIUM = 0x84F2, | |
238 | |
239 // GL_ANGLE_instanced_arrays | |
240 VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88FE | |
241 }; | |
242 | |
243 // GL_ARB_robustness | |
244 // Note: This method's behavior differs from the GL_ARB_robustness | |
245 // specification in the following way: | |
246 // The implementation must not reset the error state during this call. | |
247 // If getGraphicsResetStatusARB returns an error, it should continue | |
248 // returning the same error. Restoring the GraphicsContext3D is handled | |
249 // externally. | |
250 int getGraphicsResetStatusARB(); | |
251 | |
252 // GL_ANGLE_framebuffer_blit | |
253 void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long ds
tX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filte
r); | |
254 | |
255 // GL_ANGLE_framebuffer_multisample | |
256 void renderbufferStorageMultisample(unsigned long target, unsigned long samp
les, unsigned long internalformat, unsigned long width, unsigned long height); | |
257 | |
258 // GL_OES_vertex_array_object | |
259 Platform3DObject createVertexArrayOES(); | |
260 void deleteVertexArrayOES(Platform3DObject); | |
261 GC3Dboolean isVertexArrayOES(Platform3DObject); | |
262 void bindVertexArrayOES(Platform3DObject); | |
263 | |
264 // GL_ANGLE_translated_shader_source | |
265 String getTranslatedShaderSourceANGLE(Platform3DObject); | |
266 | |
267 // GL_CHROMIUM_copy_texture | |
268 // canUseCopyTextureCHROMIUM(...) is used to check if copyTextureCHROMIUM(..
.) can work for the specified | |
269 // format, type and level for the destination texture. | |
270 bool canUseCopyTextureCHROMIUM(GC3Denum destFormat, GC3Denum destType, GC3Di
nt level); | |
271 void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Di
nt, GC3Denum, GC3Denum); | |
272 | |
273 // GL_EXT_debug_marker | |
274 void insertEventMarkerEXT(const String&); | |
275 void pushGroupMarkerEXT(const String&); | |
276 void popGroupMarkerEXT(void); | |
277 | |
278 // GL_ARB_draw_buffers / GL_EXT_draw_buffers | |
279 void drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs); | |
280 | |
281 // GL_CHROMIUM_map_sub | |
282 void* mapBufferSubDataCHROMIUM(unsigned target, int offset, int size, unsign
ed access); | |
283 void unmapBufferSubDataCHROMIUM(const void*); | |
284 void* mapTexSubImage2DCHROMIUM(unsigned target, int level, int xoffset, int
yoffset, int width, int height, unsigned format, unsigned type, unsigned access)
; | |
285 void unmapTexSubImage2DCHROMIUM(const void*); | |
286 | |
287 // GL_CHROMIUM_rate_limit_offscreen_context | |
288 void rateLimitOffscreenContextCHROMIUM(); | |
289 | |
290 // GL_CHROMIUM_paint_framebuffer_canvas | |
291 void paintFramebufferToCanvas(int framebuffer, int width, int height, bool p
remultiplyAlpha, ImageBuffer*); | |
292 | |
293 // GL_CHROMIUM_iosurface | |
294 // To avoid needing to expose extraneous enums, assumes internal format | |
295 // RGBA, format BGRA, and type UNSIGNED_INT_8_8_8_8_REV. | |
296 void texImageIOSurface2DCHROMIUM(unsigned target, int width, int height, uin
t32_t ioSurfaceId, unsigned plane); | |
297 | |
298 // GL_EXT_texture_storage | |
299 void texStorage2DEXT(unsigned target, int levels, unsigned internalformat, i
nt width, int height); | |
300 | |
301 // GL_EXT_occlusion_query | |
302 Platform3DObject createQueryEXT(); | |
303 void deleteQueryEXT(Platform3DObject); | |
304 GC3Dboolean isQueryEXT(Platform3DObject); | |
305 void beginQueryEXT(GC3Denum, Platform3DObject); | |
306 void endQueryEXT(GC3Denum); | |
307 void getQueryivEXT(GC3Denum, GC3Denum, GC3Dint*); | |
308 void getQueryObjectuivEXT(Platform3DObject, GC3Denum, GC3Duint*); | |
309 | |
310 // GL_CHROMIUM_shallow_flush | |
311 void shallowFlushCHROMIUM(); | |
312 | |
313 // GL_ANGLE_instanced_arrays | |
314 void drawArraysInstancedANGLE(GC3Denum mode, GC3Dint first, GC3Dsizei count,
GC3Dsizei primcount); | |
315 void drawElementsInstancedANGLE(GC3Denum mode, GC3Dsizei count, GC3Denum typ
e, GC3Dintptr offset, GC3Dsizei primcount); | |
316 void vertexAttribDivisorANGLE(GC3Duint index, GC3Duint divisor); | |
317 | |
318 // GL_CHROMIUM_lose_context | |
319 void loseContextCHROMIUM(GC3Denum, GC3Denum); | |
320 | |
321 private: | |
322 // Instances of this class are strictly owned by the GraphicsContext3D imple
mentation and do not | |
323 // need to be instantiated by any other code. | |
324 friend class GraphicsContext3D; | |
325 explicit Extensions3D(GraphicsContext3D*); | |
326 | |
327 // Weak pointer back to GraphicsContext3D. | |
328 GraphicsContext3D* m_context; | |
329 }; | |
330 | |
331 } // namespace WebCore | |
332 | |
333 #endif // Extensions3D_h | |
OLD | NEW |