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