tagging audio streams and changing audio sink to pulseaudio
[profile/ivi/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     //   GL_CHROMIUM_copy_texture
70     //   GL_CHROMIUM_flipy
71
72     // Takes full name of extension; for example,
73     // "GL_EXT_texture_format_BGRA8888".
74     virtual bool supports(const String&) = 0;
75
76     // Certain OpenGL and WebGL implementations may support enabling
77     // extensions lazily. This method may only be called with
78     // extension names for which supports returns true.
79     virtual void ensureEnabled(const String&) = 0;
80
81     // Takes full name of extension: for example, "GL_EXT_texture_format_BGRA8888".
82     // Checks to see whether the given extension is actually enabled (see ensureEnabled).
83     // Has no other side-effects.
84     virtual bool isEnabled(const String&) = 0;
85
86     enum ExtensionsEnumType {
87         // GL_EXT_texture_format_BGRA8888 enums
88         BGRA_EXT = 0x80E1,
89
90         // GL_ARB_robustness enums
91         GUILTY_CONTEXT_RESET_ARB = 0x8253,
92         INNOCENT_CONTEXT_RESET_ARB = 0x8254,
93         UNKNOWN_CONTEXT_RESET_ARB = 0x8255,
94
95         // GL_EXT/OES_packed_depth_stencil enums
96         DEPTH24_STENCIL8 = 0x88F0,
97         
98         // GL_ANGLE_framebuffer_blit names
99         READ_FRAMEBUFFER = 0x8CA8,
100         DRAW_FRAMEBUFFER = 0x8CA9,
101         DRAW_FRAMEBUFFER_BINDING = 0x8CA6, 
102         READ_FRAMEBUFFER_BINDING = 0x8CAA,
103         
104         // GL_ANGLE_framebuffer_multisample names
105         RENDERBUFFER_SAMPLES = 0x8CAB,
106         FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
107         MAX_SAMPLES = 0x8D57,
108
109         // GL_OES_standard_derivatives names
110         FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B,
111
112         // GL_OES_rgb8_rgba8 names
113         RGB8_OES = 0x8051,
114         RGBA8_OES = 0x8058,
115         
116         // GL_OES_vertex_array_object names
117         VERTEX_ARRAY_BINDING_OES = 0x85B5,
118
119         // GL_ANGLE_translated_shader_source
120         TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93A0,
121
122         // GL_ARB_texture_rectangle
123         TEXTURE_RECTANGLE_ARB =  0x84F5,
124         TEXTURE_BINDING_RECTANGLE_ARB = 0x84F6,
125
126         // GL_EXT_texture_compression_dxt1
127         // GL_EXT_texture_compression_s3tc
128         COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0,
129         COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1,
130         COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2,
131         COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3,
132
133         // GL_OES_compressed_ETC1_RGB8_texture
134         ETC1_RGB8_OES = 0x8D64,
135
136         // GL_IMG_texture_compression_pvrtc
137         COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00,
138         COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01,
139         COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02,
140         COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03,
141
142         // GL_EXT_texture_filter_anisotropic
143         TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE,
144         MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF,
145
146         // GL_CHROMIUM_flipy
147         UNPACK_FLIP_Y_CHROMIUM = 0x9240,
148
149         // GL_CHROMIUM_copy_texture
150         UNPACK_PREMULTIPLY_ALPHA_CHROMIUM = 0x9241,
151         UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM = 0x9242
152     };
153
154     // GL_ARB_robustness
155     // Note: This method's behavior differs from the GL_ARB_robustness
156     // specification in the following way:
157     // The implementation must not reset the error state during this call.
158     // If getGraphicsResetStatusARB returns an error, it should continue
159     // returning the same error. Restoring the GraphicsContext3D is handled
160     // externally.
161     virtual int getGraphicsResetStatusARB() = 0;
162     
163     // GL_ANGLE_framebuffer_blit
164     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;
165     
166     // GL_ANGLE_framebuffer_multisample
167     virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) = 0;
168     
169     // GL_OES_vertex_array_object
170     virtual Platform3DObject createVertexArrayOES() = 0;
171     virtual void deleteVertexArrayOES(Platform3DObject) = 0;
172     virtual GC3Dboolean isVertexArrayOES(Platform3DObject) = 0;
173     virtual void bindVertexArrayOES(Platform3DObject) = 0;
174
175     // GL_ANGLE_translated_shader_source
176     virtual String getTranslatedShaderSourceANGLE(Platform3DObject) = 0;
177
178 #if !PLATFORM(EFL)
179     // GL_CHROMIUM_copy_texture
180     virtual void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum) = 0;
181 #endif
182 };
183
184 } // namespace WebCore
185
186 #endif // Extensions3D_h