WebCore/html/canvas/WebGLGetInfo.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 2009 Apple Inc. All Rights Reserved.
       
     3  * Copyright (C) 2009 Google Inc. All Rights Reserved.
       
     4  *
       
     5  * Redistribution and use in source and binary forms, with or without
       
     6  * modification, are permitted provided that the following conditions
       
     7  * are met:
       
     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 INC. ``AS IS'' AND ANY
       
    15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       
    17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
       
    18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       
    19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       
    20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       
    21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
       
    22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
       
    24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    25  */
       
    26 
       
    27 #ifndef WebGLGetInfo_h
       
    28 #define WebGLGetInfo_h
       
    29 
       
    30 #include "wtf/PassRefPtr.h"
       
    31 #include "wtf/RefPtr.h"
       
    32 #include "PlatformString.h"
       
    33 
       
    34 #include "WebGLBuffer.h"
       
    35 #include "Float32Array.h"
       
    36 #include "WebGLFramebuffer.h"
       
    37 #include "Int32Array.h"
       
    38 // FIXME: implement WebGLObjectArray
       
    39 //#include "WebGLObjectArray.h"
       
    40 #include "WebGLProgram.h"
       
    41 #include "WebGLRenderbuffer.h"
       
    42 #include "WebGLTexture.h"
       
    43 #include "Uint8Array.h"
       
    44 
       
    45 namespace WebCore {
       
    46 
       
    47 // A tagged union representing the result of get queries like
       
    48 // getParameter (encompassing getBooleanv, getIntegerv, getFloatv) and
       
    49 // similar variants. For reference counted types, increments and
       
    50 // decrements the reference count of the target object.
       
    51 
       
    52 class WebGLGetInfo {
       
    53 public:
       
    54     enum Type {
       
    55         kTypeBool,
       
    56         kTypeBoolArray,
       
    57         kTypeFloat,
       
    58         kTypeLong,
       
    59         kTypeNull,
       
    60         kTypeString,
       
    61         kTypeUnsignedLong,
       
    62         kTypeWebGLBuffer,
       
    63         kTypeWebGLFloatArray,
       
    64         kTypeWebGLFramebuffer,
       
    65         kTypeWebGLIntArray,
       
    66         kTypeWebGLObjectArray,
       
    67         kTypeWebGLProgram,
       
    68         kTypeWebGLRenderbuffer,
       
    69         kTypeWebGLTexture,
       
    70         kTypeWebGLUnsignedByteArray
       
    71     };
       
    72 
       
    73     WebGLGetInfo(bool value);
       
    74     WebGLGetInfo(const bool* value, int size);
       
    75     WebGLGetInfo(float value);
       
    76     WebGLGetInfo(long value);
       
    77     // Represents the NULL value and type
       
    78     WebGLGetInfo();
       
    79     WebGLGetInfo(const String& value);
       
    80     WebGLGetInfo(unsigned long value);
       
    81     WebGLGetInfo(PassRefPtr<WebGLBuffer> value);
       
    82     WebGLGetInfo(PassRefPtr<Float32Array> value);
       
    83     WebGLGetInfo(PassRefPtr<WebGLFramebuffer> value);
       
    84     WebGLGetInfo(PassRefPtr<Int32Array> value);
       
    85     // FIXME: implement WebGLObjectArray
       
    86     // WebGLGetInfo(PassRefPtr<WebGLObjectArray> value);
       
    87     WebGLGetInfo(PassRefPtr<WebGLProgram> value);
       
    88     WebGLGetInfo(PassRefPtr<WebGLRenderbuffer> value);
       
    89     WebGLGetInfo(PassRefPtr<WebGLTexture> value);
       
    90     WebGLGetInfo(PassRefPtr<Uint8Array> value);
       
    91 
       
    92     virtual ~WebGLGetInfo();
       
    93 
       
    94     Type getType() const;
       
    95 
       
    96     bool getBool() const;
       
    97     const Vector<bool>& getBoolArray() const;
       
    98     float getFloat() const;
       
    99     long getLong() const;
       
   100     const String& getString() const;
       
   101     unsigned long getUnsignedLong() const;
       
   102     PassRefPtr<WebGLBuffer> getWebGLBuffer() const;
       
   103     PassRefPtr<Float32Array> getWebGLFloatArray() const;
       
   104     PassRefPtr<WebGLFramebuffer> getWebGLFramebuffer() const;
       
   105     PassRefPtr<Int32Array> getWebGLIntArray() const;
       
   106     // FIXME: implement WebGLObjectArray
       
   107     // PassRefPtr<WebGLObjectArray> getWebGLObjectArray() const;
       
   108     PassRefPtr<WebGLProgram> getWebGLProgram() const;
       
   109     PassRefPtr<WebGLRenderbuffer> getWebGLRenderbuffer() const;
       
   110     PassRefPtr<WebGLTexture> getWebGLTexture() const;
       
   111     PassRefPtr<Uint8Array> getWebGLUnsignedByteArray() const;
       
   112 
       
   113 private:
       
   114     Type m_type;
       
   115     bool m_bool;
       
   116     Vector<bool> m_boolArray;
       
   117     float m_float;
       
   118     long m_long;
       
   119     String m_string;
       
   120     unsigned long m_unsignedLong;
       
   121     RefPtr<WebGLBuffer> m_webglBuffer;
       
   122     RefPtr<Float32Array> m_webglFloatArray;
       
   123     RefPtr<WebGLFramebuffer> m_webglFramebuffer;
       
   124     RefPtr<Int32Array> m_webglIntArray;
       
   125     // FIXME: implement WebGLObjectArray
       
   126     // RefPtr<WebGLObjectArray> m_webglObjectArray;
       
   127     RefPtr<WebGLProgram> m_webglProgram;
       
   128     RefPtr<WebGLRenderbuffer> m_webglRenderbuffer;
       
   129     RefPtr<WebGLTexture> m_webglTexture;
       
   130     RefPtr<Uint8Array> m_webglUnsignedByteArray;
       
   131 };
       
   132 
       
   133 } // namespace WebCore
       
   134 
       
   135 #endif  // WebGLGetInfo_h