tizen beta release
[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
65     // Takes full name of extension; for example,
66     // "GL_EXT_texture_format_BGRA8888".
67     virtual bool supports(const String&) = 0;
68
69     // Certain OpenGL and WebGL implementations may support enabling
70     // extensions lazily. This method may only be called with
71     // extension names for which supports returns true.
72     virtual void ensureEnabled(const String&) = 0;
73
74     // Takes full name of extension: for example, "GL_EXT_texture_format_BGRA8888".
75     // Checks to see whether the given extension is actually enabled (see ensureEnabled).
76     // Has no other side-effects.
77     virtual bool isEnabled(const String&) = 0;
78
79     enum ExtensionsEnumType {
80         // GL_EXT_texture_format_BGRA8888 enums
81         BGRA_EXT = 0x80E1,
82
83         // GL_ARB_robustness enums
84         GUILTY_CONTEXT_RESET_ARB = 0x8253,
85         INNOCENT_CONTEXT_RESET_ARB = 0x8254,
86         UNKNOWN_CONTEXT_RESET_ARB = 0x8255,
87
88         // GL_EXT/OES_packed_depth_stencil enums
89         DEPTH24_STENCIL8 = 0x88F0,
90         
91         // GL_ANGLE_framebuffer_blit names
92         READ_FRAMEBUFFER = 0x8CA8,
93         DRAW_FRAMEBUFFER = 0x8CA9,
94         DRAW_FRAMEBUFFER_BINDING = 0x8CA6, 
95         READ_FRAMEBUFFER_BINDING = 0x8CAA,
96         
97         // GL_ANGLE_framebuffer_multisample names
98         RENDERBUFFER_SAMPLES = 0x8CAB,
99         FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
100         MAX_SAMPLES = 0x8D57,
101
102         // GL_OES_standard_derivatives names
103         FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B,
104
105         // GL_OES_rgb8_rgba8 names
106         RGB8_OES = 0x8051,
107         RGBA8_OES = 0x8058,
108         
109         // GL_OES_vertex_array_object names
110         VERTEX_ARRAY_BINDING_OES = 0x85B5,
111
112         // GL_ANGLE_translated_shader_source
113         TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93A0,
114
115         // GL_ARB_texture_rectangle
116         TEXTURE_RECTANGLE_ARB =  0x84F5,
117         TEXTURE_BINDING_RECTANGLE_ARB = 0x84F6,
118     };
119
120     // GL_ARB_robustness
121     // Note: This method's behavior differs from the GL_ARB_robustness
122     // specification in the following way:
123     // The implementation must not reset the error state during this call.
124     // If getGraphicsResetStatusARB returns an error, it should continue
125     // returning the same error. Restoring the GraphicsContext3D is handled
126     // externally.
127     virtual int getGraphicsResetStatusARB() = 0;
128     
129     // GL_ANGLE_framebuffer_blit
130     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;
131     
132     // GL_ANGLE_framebuffer_multisample
133     virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) = 0;
134     
135     // GL_OES_vertex_array_object
136     virtual Platform3DObject createVertexArrayOES() = 0;
137     virtual void deleteVertexArrayOES(Platform3DObject) = 0;
138     virtual GC3Dboolean isVertexArrayOES(Platform3DObject) = 0;
139     virtual void bindVertexArrayOES(Platform3DObject) = 0;
140
141     // GL_ANGLE_translated_shader_source
142     virtual String getTranslatedShaderSourceANGLE(Platform3DObject) = 0;
143 };
144
145 } // namespace WebCore
146
147 #endif // Extensions3D_h