Use NeverDestroyed instead of DEPRECATED_DEFINE_STATIC_LOCAL
[WebKit-https.git] / Source / WebCore / platform / graphics / Extensions3D.h
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 "GraphicsTypes3D.h"
30
31 #include <wtf/text/WTFString.h>
32
33 namespace WebCore {
34
35 // This is a base class containing only pure virtual functions.
36 // Implementations must provide a subclass.
37 //
38 // The supported extensions are defined below and in subclasses,
39 // possibly platform-specific ones.
40 //
41 // Calling any extension function not supported by the current context
42 // must be a no-op; in particular, it may not have side effects. In
43 // this situation, if the function has a return value, 0 is returned.
44 class Extensions3D {
45 public:
46     virtual ~Extensions3D() {}
47
48     // Supported extensions:
49     //   GL_EXT_texture_format_BGRA8888
50     //   GL_EXT_read_format_bgra
51     //   GL_ARB_robustness
52     //   GL_ARB_texture_non_power_of_two / GL_OES_texture_npot
53     //   GL_EXT_packed_depth_stencil / GL_OES_packed_depth_stencil
54     //   GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample
55     //   GL_IMG_multisampled_render_to_texture
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_ARB_draw_buffers / GL_EXT_draw_buffers
76     //   GL_ANGLE_instanced_arrays
77
78     // Takes full name of extension; for example,
79     // "GL_EXT_texture_format_BGRA8888".
80     virtual bool supports(const String&) = 0;
81
82     // Certain OpenGL and WebGL implementations may support enabling
83     // extensions lazily. This method may only be called with
84     // extension names for which supports returns true.
85     virtual void ensureEnabled(const String&) = 0;
86
87     // Takes full name of extension: for example, "GL_EXT_texture_format_BGRA8888".
88     // Checks to see whether the given extension is actually enabled (see ensureEnabled).
89     // Has no other side-effects.
90     virtual bool isEnabled(const String&) = 0;
91
92     enum ExtensionsEnumType {
93         // EXT_sRGB formats
94         SRGB_EXT = 0x8C40,
95         SRGB_ALPHA_EXT = 0x8C42,
96         SRGB8_ALPHA8_EXT = 0x8C43,
97         FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT = 0x8210,
98
99         // EXT_blend_minmax enums
100         MIN_EXT = 0x8007,
101         MAX_EXT = 0x8008,
102
103         // GL_EXT_texture_format_BGRA8888 enums
104         BGRA_EXT = 0x80E1,
105
106         // GL_ARB_robustness enums
107         GUILTY_CONTEXT_RESET_ARB = 0x8253,
108         INNOCENT_CONTEXT_RESET_ARB = 0x8254,
109         UNKNOWN_CONTEXT_RESET_ARB = 0x8255,
110
111         // GL_EXT/OES_packed_depth_stencil enums
112         DEPTH24_STENCIL8 = 0x88F0,
113         
114         // GL_ANGLE_framebuffer_blit names
115         READ_FRAMEBUFFER = 0x8CA8,
116         DRAW_FRAMEBUFFER = 0x8CA9,
117         DRAW_FRAMEBUFFER_BINDING = 0x8CA6, 
118         READ_FRAMEBUFFER_BINDING = 0x8CAA,
119         
120         // GL_ANGLE_framebuffer_multisample names
121         RENDERBUFFER_SAMPLES = 0x8CAB,
122         FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
123         MAX_SAMPLES = 0x8D57,
124
125         // GL_IMG_multisampled_render_to_texture
126         RENDERBUFFER_SAMPLES_IMG = 0x9133,
127         FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG = 0x9134,
128         MAX_SAMPLES_IMG = 0x9135,
129         TEXTURE_SAMPLES_IMG = 0x9136,
130
131         // GL_OES_standard_derivatives names
132         FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B,
133
134         // GL_OES_rgb8_rgba8 names
135         RGB8_OES = 0x8051,
136         RGBA8_OES = 0x8058,
137         
138         // GL_OES_vertex_array_object names
139         VERTEX_ARRAY_BINDING_OES = 0x85B5,
140
141         // GL_ANGLE_translated_shader_source
142         TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93A0,
143
144         // GL_ARB_texture_rectangle
145         TEXTURE_RECTANGLE_ARB =  0x84F5,
146         TEXTURE_BINDING_RECTANGLE_ARB = 0x84F6,
147
148         // GL_EXT_texture_compression_dxt1
149         // GL_EXT_texture_compression_s3tc
150         COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0,
151         COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1,
152         COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2,
153         COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3,
154
155         // GL_OES_compressed_ETC1_RGB8_texture
156         ETC1_RGB8_OES = 0x8D64,
157
158         // GL_IMG_texture_compression_pvrtc
159         COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00,
160         COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01,
161         COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02,
162         COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03,
163
164         // GL_AMD_compressed_ATC_texture
165         COMPRESSED_ATC_RGB_AMD = 0x8C92,
166         COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8C93,
167         COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87EE,
168
169         // GL_EXT_texture_filter_anisotropic
170         TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE,
171         MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF,
172
173         // GL_ARB_draw_buffers / GL_EXT_draw_buffers
174         MAX_DRAW_BUFFERS_EXT = 0x8824,
175         DRAW_BUFFER0_EXT = 0x8825,
176         DRAW_BUFFER1_EXT = 0x8826,
177         DRAW_BUFFER2_EXT = 0x8827,
178         DRAW_BUFFER3_EXT = 0x8828,
179         DRAW_BUFFER4_EXT = 0x8829,
180         DRAW_BUFFER5_EXT = 0x882A,
181         DRAW_BUFFER6_EXT = 0x882B,
182         DRAW_BUFFER7_EXT = 0x882C,
183         DRAW_BUFFER8_EXT = 0x882D,
184         DRAW_BUFFER9_EXT = 0x882E,
185         DRAW_BUFFER10_EXT = 0x882F,
186         DRAW_BUFFER11_EXT = 0x8830,
187         DRAW_BUFFER12_EXT = 0x8831,
188         DRAW_BUFFER13_EXT = 0x8832,
189         DRAW_BUFFER14_EXT = 0x8833,
190         DRAW_BUFFER15_EXT = 0x8834,
191         MAX_COLOR_ATTACHMENTS_EXT = 0x8CDF,
192         COLOR_ATTACHMENT0_EXT = 0x8CE0,
193         COLOR_ATTACHMENT1_EXT = 0x8CE1,
194         COLOR_ATTACHMENT2_EXT = 0x8CE2,
195         COLOR_ATTACHMENT3_EXT = 0x8CE3,
196         COLOR_ATTACHMENT4_EXT = 0x8CE4,
197         COLOR_ATTACHMENT5_EXT = 0x8CE5,
198         COLOR_ATTACHMENT6_EXT = 0x8CE6,
199         COLOR_ATTACHMENT7_EXT = 0x8CE7,
200         COLOR_ATTACHMENT8_EXT = 0x8CE8,
201         COLOR_ATTACHMENT9_EXT = 0x8CE9,
202         COLOR_ATTACHMENT10_EXT = 0x8CEA,
203         COLOR_ATTACHMENT11_EXT = 0x8CEB,
204         COLOR_ATTACHMENT12_EXT = 0x8CEC,
205         COLOR_ATTACHMENT13_EXT = 0x8CED,
206         COLOR_ATTACHMENT14_EXT = 0x8CEE,
207         COLOR_ATTACHMENT15_EXT = 0x8CEF
208     };
209
210     // GL_ARB_robustness
211     // Note: This method's behavior differs from the GL_ARB_robustness
212     // specification in the following way:
213     // The implementation must not reset the error state during this call.
214     // If getGraphicsResetStatusARB returns an error, it should continue
215     // returning the same error. Restoring the GraphicsContext3D is handled
216     // externally.
217     virtual int getGraphicsResetStatusARB() = 0;
218     
219     // GL_ANGLE_framebuffer_blit
220     virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) = 0;
221     
222     // GL_ANGLE_framebuffer_multisample
223     virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) = 0;
224     
225     // GL_OES_vertex_array_object
226     virtual Platform3DObject createVertexArrayOES() = 0;
227     virtual void deleteVertexArrayOES(Platform3DObject) = 0;
228     virtual GC3Dboolean isVertexArrayOES(Platform3DObject) = 0;
229     virtual void bindVertexArrayOES(Platform3DObject) = 0;
230
231     // GL_ANGLE_translated_shader_source
232     virtual String getTranslatedShaderSourceANGLE(Platform3DObject) = 0;
233
234     // EXT Robustness - uses getGraphicsResetStatusARB
235     virtual void readnPixelsEXT(int x, int y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, GC3Dsizei bufSize, void *data) = 0;
236     virtual void getnUniformfvEXT(GC3Duint program, int location, GC3Dsizei bufSize, float *params) = 0;
237     virtual void getnUniformivEXT(GC3Duint program, int location, GC3Dsizei bufSize, int *params) = 0;
238
239     // GL_EXT_debug_marker
240     virtual void insertEventMarkerEXT(const String&) = 0;
241     virtual void pushGroupMarkerEXT(const String&) = 0;
242     virtual void popGroupMarkerEXT(void) = 0;
243
244     // GL_ARB_draw_buffers / GL_EXT_draw_buffers
245     virtual void drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs) = 0;
246
247     // GL_ANGLE_instanced_arrays
248     virtual void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) = 0;
249     virtual void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount) = 0;
250     virtual void vertexAttribDivisor(GC3Duint index, GC3Duint divisor) = 0;
251
252     virtual bool isNVIDIA() = 0;
253     virtual bool isAMD() = 0;
254     virtual bool isIntel() = 0;
255     virtual bool isImagination() = 0;
256     virtual String vendor() = 0;
257
258     // Some configurations have bugs regarding built-in functions in their OpenGL drivers
259     // that must be avoided. Ports should implement these flags on such configurations.
260     virtual bool requiresBuiltInFunctionEmulation() = 0;
261     virtual bool requiresRestrictedMaximumTextureSize() = 0;
262
263 };
264
265 } // namespace WebCore
266
267 #endif // Extensions3D_h