2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef Extensions3D_h
27 #define Extensions3D_h
29 #include "GraphicsTypes3D.h"
31 #include <wtf/text/WTFString.h>
35 // This is a base class containing only pure virtual functions.
36 // Implementations must provide a subclass.
38 // The supported extensions are defined below and in subclasses,
39 // possibly platform-specific ones.
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.
46 virtual ~Extensions3D() {}
48 // Supported extensions:
49 // GL_EXT_texture_format_BGRA8888
50 // GL_EXT_read_format_bgra
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
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
65 // Takes full name of extension; for example,
66 // "GL_EXT_texture_format_BGRA8888".
67 virtual bool supports(const String&) = 0;
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;
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;
79 enum ExtensionsEnumType {
80 // GL_EXT_texture_format_BGRA8888 enums
83 // GL_ARB_robustness enums
84 GUILTY_CONTEXT_RESET_ARB = 0x8253,
85 INNOCENT_CONTEXT_RESET_ARB = 0x8254,
86 UNKNOWN_CONTEXT_RESET_ARB = 0x8255,
88 // GL_EXT/OES_packed_depth_stencil enums
89 DEPTH24_STENCIL8 = 0x88F0,
91 // GL_ANGLE_framebuffer_blit names
92 READ_FRAMEBUFFER = 0x8CA8,
93 DRAW_FRAMEBUFFER = 0x8CA9,
94 DRAW_FRAMEBUFFER_BINDING = 0x8CA6,
95 READ_FRAMEBUFFER_BINDING = 0x8CAA,
97 // GL_ANGLE_framebuffer_multisample names
98 RENDERBUFFER_SAMPLES = 0x8CAB,
99 FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
100 MAX_SAMPLES = 0x8D57,
102 // GL_OES_standard_derivatives names
103 FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B,
105 // GL_OES_rgb8_rgba8 names
109 // GL_OES_vertex_array_object names
110 VERTEX_ARRAY_BINDING_OES = 0x85B5,
112 // GL_ANGLE_translated_shader_source
113 TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93A0,
115 // GL_ARB_texture_rectangle
116 TEXTURE_RECTANGLE_ARB = 0x84F5,
117 TEXTURE_BINDING_RECTANGLE_ARB = 0x84F6,
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
127 virtual int getGraphicsResetStatusARB() = 0;
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;
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;
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;
141 // GL_ANGLE_translated_shader_source
142 virtual String getTranslatedShaderSourceANGLE(Platform3DObject) = 0;
145 } // namespace WebCore
147 #endif // Extensions3D_h