[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.24
[framework/web/webkit-efl.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_OES_texture_float
56     //   GL_OES_standard_derivatives
57     //   GL_OES_rgb8_rgba8
58     //   GL_OES_vertex_array_object
59     //   GL_ANGLE_translated_shader_source
60     //   GL_ARB_texture_rectangle (only the subset required to
61     //     implement IOSurface binding; it's recommended to support
62     //     this only on Mac OS X to limit the amount of code dependent
63     //     on this extension)
64     //   GL_EXT_texture_compression_dxt1
65     //   GL_EXT_texture_compression_s3tc
66     //   GL_OES_compressed_ETC1_RGB8_texture
67     //   GL_IMG_texture_compression_pvrtc
68     //   EXT_texture_filter_anisotropic
69
70     // Takes full name of extension; for example,
71     // "GL_EXT_texture_format_BGRA8888".
72     virtual bool supports(const String&) = 0;
73
74     // Certain OpenGL and WebGL implementations may support enabling
75     // extensions lazily. This method may only be called with
76     // extension names for which supports returns true.
77     virtual void ensureEnabled(const String&) = 0;
78
79     // Takes full name of extension: for example, "GL_EXT_texture_format_BGRA8888".
80     // Checks to see whether the given extension is actually enabled (see ensureEnabled).
81     // Has no other side-effects.
82     virtual bool isEnabled(const String&) = 0;
83
84     enum ExtensionsEnumType {
85         // GL_EXT_texture_format_BGRA8888 enums
86         BGRA_EXT = 0x80E1,
87
88         // GL_ARB_robustness enums
89         GUILTY_CONTEXT_RESET_ARB = 0x8253,
90         INNOCENT_CONTEXT_RESET_ARB = 0x8254,
91         UNKNOWN_CONTEXT_RESET_ARB = 0x8255,
92
93         // GL_EXT/OES_packed_depth_stencil enums
94         DEPTH24_STENCIL8 = 0x88F0,
95         
96         // GL_ANGLE_framebuffer_blit names
97         READ_FRAMEBUFFER = 0x8CA8,
98         DRAW_FRAMEBUFFER = 0x8CA9,
99         DRAW_FRAMEBUFFER_BINDING = 0x8CA6, 
100         READ_FRAMEBUFFER_BINDING = 0x8CAA,
101         
102         // GL_ANGLE_framebuffer_multisample names
103         RENDERBUFFER_SAMPLES = 0x8CAB,
104         FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
105         MAX_SAMPLES = 0x8D57,
106
107         // GL_OES_standard_derivatives names
108         FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B,
109
110         // GL_OES_rgb8_rgba8 names
111         RGB8_OES = 0x8051,
112         RGBA8_OES = 0x8058,
113         
114         // GL_OES_vertex_array_object names
115         VERTEX_ARRAY_BINDING_OES = 0x85B5,
116
117         // GL_ANGLE_translated_shader_source
118         TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93A0,
119
120         // GL_ARB_texture_rectangle
121         TEXTURE_RECTANGLE_ARB =  0x84F5,
122         TEXTURE_BINDING_RECTANGLE_ARB = 0x84F6,
123
124         // GL_EXT_texture_compression_dxt1
125         // GL_EXT_texture_compression_s3tc
126         COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0,
127         COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1,
128         COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2,
129         COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3,
130
131         // GL_OES_compressed_ETC1_RGB8_texture
132         ETC1_RGB8_OES = 0x8D64,
133
134         // GL_IMG_texture_compression_pvrtc
135         COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00,
136         COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01,
137         COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02,
138         COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03,
139
140         // GL_EXT_texture_filter_anisotropic
141         TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE,
142         MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF,
143     };
144
145     // GL_ARB_robustness
146     // Note: This method's behavior differs from the GL_ARB_robustness
147     // specification in the following way:
148     // The implementation must not reset the error state during this call.
149     // If getGraphicsResetStatusARB returns an error, it should continue
150     // returning the same error. Restoring the GraphicsContext3D is handled
151     // externally.
152     virtual int getGraphicsResetStatusARB() = 0;
153     
154     // GL_ANGLE_framebuffer_blit
155     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;
156     
157     // GL_ANGLE_framebuffer_multisample
158     virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) = 0;
159     
160     // GL_OES_vertex_array_object
161     virtual Platform3DObject createVertexArrayOES() = 0;
162     virtual void deleteVertexArrayOES(Platform3DObject) = 0;
163     virtual GC3Dboolean isVertexArrayOES(Platform3DObject) = 0;
164     virtual void bindVertexArrayOES(Platform3DObject) = 0;
165
166     // GL_ANGLE_translated_shader_source
167     virtual String getTranslatedShaderSourceANGLE(Platform3DObject) = 0;
168 };
169
170 } // namespace WebCore
171
172 #endif // Extensions3D_h