Home | History | Annotate | Download | only in graphics
      1 /*
      2  * Copyright (C) 2010 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 
     60     // Takes full name of extension; for example,
     61     // "GL_EXT_texture_format_BGRA8888".
     62     virtual bool supports(const String&) = 0;
     63 
     64     // Certain OpenGL and WebGL implementations may support enabling
     65     // extensions lazily. This method may only be called with
     66     // extension names for which supports returns true.
     67     virtual void ensureEnabled(const String&) = 0;
     68 
     69     // Takes full name of extension: for example, "GL_EXT_texture_format_BGRA8888".
     70     // Checks to see whether the given extension is actually enabled (see ensureEnabled).
     71     // Has no other side-effects.
     72     virtual bool isEnabled(const String&) = 0;
     73 
     74     enum ExtensionsEnumType {
     75         // GL_EXT_texture_format_BGRA8888 enums
     76         BGRA_EXT = 0x80E1,
     77 
     78         // GL_ARB_robustness enums
     79         GUILTY_CONTEXT_RESET_ARB = 0x8253,
     80         INNOCENT_CONTEXT_RESET_ARB = 0x8254,
     81         UNKNOWN_CONTEXT_RESET_ARB = 0x8255,
     82 
     83         // GL_EXT/OES_packed_depth_stencil enums
     84         DEPTH24_STENCIL8 = 0x88F0,
     85 
     86         // GL_ANGLE_framebuffer_blit names
     87         READ_FRAMEBUFFER = 0x8CA8,
     88         DRAW_FRAMEBUFFER = 0x8CA9,
     89         DRAW_FRAMEBUFFER_BINDING = 0x8CA6,
     90         READ_FRAMEBUFFER_BINDING = 0x8CAA,
     91 
     92         // GL_ANGLE_framebuffer_multisample names
     93         RENDERBUFFER_SAMPLES = 0x8CAB,
     94         FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
     95         MAX_SAMPLES = 0x8D57,
     96 
     97         // GL_OES_standard_derivatives names
     98         FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B,
     99 
    100         // GL_OES_rgb8_rgba8 names
    101         RGB8_OES = 0x8051,
    102         RGBA8_OES = 0x8058,
    103 
    104         // GL_OES_vertex_array_object names
    105         VERTEX_ARRAY_BINDING_OES = 0x85B5,
    106     };
    107 
    108     // GL_ARB_robustness
    109     virtual int getGraphicsResetStatusARB() = 0;
    110 
    111     // GL_ANGLE_framebuffer_blit
    112     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;
    113 
    114     // GL_ANGLE_framebuffer_multisample
    115     virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) = 0;
    116 
    117     // GL_OES_vertex_array_object
    118     virtual Platform3DObject createVertexArrayOES() = 0;
    119     virtual void deleteVertexArrayOES(Platform3DObject) = 0;
    120     virtual GC3Dboolean isVertexArrayOES(Platform3DObject) = 0;
    121     virtual void bindVertexArrayOES(Platform3DObject) = 0;
    122 };
    123 
    124 } // namespace WebCore
    125 
    126 #endif // Extensions3D_h
    127