Home | History | Annotate | Download | only in canvas
      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 "WebGLFloatArray.h"
     36 #include "WebGLFramebuffer.h"
     37 #include "WebGLIntArray.h"
     38 // FIXME: implement WebGLObjectArray
     39 //#include "WebGLObjectArray.h"
     40 #include "WebGLProgram.h"
     41 #include "WebGLRenderbuffer.h"
     42 #include "WebGLTexture.h"
     43 #include "WebGLUnsignedByteArray.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         kTypeFloat,
     57         kTypeLong,
     58         kTypeNull,
     59         kTypeString,
     60         kTypeUnsignedLong,
     61         kTypeWebGLBuffer,
     62         kTypeWebGLFloatArray,
     63         kTypeWebGLFramebuffer,
     64         kTypeWebGLIntArray,
     65         kTypeWebGLObjectArray,
     66         kTypeWebGLProgram,
     67         kTypeWebGLRenderbuffer,
     68         kTypeWebGLTexture,
     69         kTypeWebGLUnsignedByteArray
     70     };
     71 
     72     WebGLGetInfo(bool value);
     73     WebGLGetInfo(float value);
     74     WebGLGetInfo(long value);
     75     // Represents the NULL value and type
     76     WebGLGetInfo();
     77     WebGLGetInfo(const String& value);
     78     WebGLGetInfo(unsigned long value);
     79     WebGLGetInfo(PassRefPtr<WebGLBuffer> value);
     80     WebGLGetInfo(PassRefPtr<WebGLFloatArray> value);
     81     WebGLGetInfo(PassRefPtr<WebGLFramebuffer> value);
     82     WebGLGetInfo(PassRefPtr<WebGLIntArray> value);
     83     // FIXME: implement WebGLObjectArray
     84     // WebGLGetInfo(PassRefPtr<WebGLObjectArray> value);
     85     WebGLGetInfo(PassRefPtr<WebGLProgram> value);
     86     WebGLGetInfo(PassRefPtr<WebGLRenderbuffer> value);
     87     WebGLGetInfo(PassRefPtr<WebGLTexture> value);
     88     WebGLGetInfo(PassRefPtr<WebGLUnsignedByteArray> value);
     89 
     90     virtual ~WebGLGetInfo();
     91 
     92     Type getType() const;
     93 
     94     bool getBool() const;
     95     float getFloat() const;
     96     long getLong() const;
     97     const String& getString() const;
     98     unsigned long getUnsignedLong() const;
     99     PassRefPtr<WebGLBuffer> getWebGLBuffer() const;
    100     PassRefPtr<WebGLFloatArray> getWebGLFloatArray() const;
    101     PassRefPtr<WebGLFramebuffer> getWebGLFramebuffer() const;
    102     PassRefPtr<WebGLIntArray> getWebGLIntArray() const;
    103     // FIXME: implement WebGLObjectArray
    104     // PassRefPtr<WebGLObjectArray> getWebGLObjectArray() const;
    105     PassRefPtr<WebGLProgram> getWebGLProgram() const;
    106     PassRefPtr<WebGLRenderbuffer> getWebGLRenderbuffer() const;
    107     PassRefPtr<WebGLTexture> getWebGLTexture() const;
    108     PassRefPtr<WebGLUnsignedByteArray> getWebGLUnsignedByteArray() const;
    109 
    110 private:
    111     Type m_type;
    112     bool m_bool;
    113     float m_float;
    114     long m_long;
    115     String m_string;
    116     unsigned long m_unsignedLong;
    117     RefPtr<WebGLBuffer> m_webglBuffer;
    118     RefPtr<WebGLFloatArray> m_webglFloatArray;
    119     RefPtr<WebGLFramebuffer> m_webglFramebuffer;
    120     RefPtr<WebGLIntArray> m_webglIntArray;
    121     // FIXME: implement WebGLObjectArray
    122     // RefPtr<WebGLObjectArray> m_webglObjectArray;
    123     RefPtr<WebGLProgram> m_webglProgram;
    124     RefPtr<WebGLRenderbuffer> m_webglRenderbuffer;
    125     RefPtr<WebGLTexture> m_webglTexture;
    126     RefPtr<WebGLUnsignedByteArray> m_webglUnsignedByteArray;
    127 };
    128 
    129 } // namespace WebCore
    130 
    131 #endif  // WebGLGetInfo_h
    132