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 "core/html/canvas/WebGLBuffer.h" 31 #include "core/html/canvas/WebGLFramebuffer.h" 32 #include "core/html/canvas/WebGLProgram.h" 33 #include "core/html/canvas/WebGLRenderbuffer.h" 34 #include "core/html/canvas/WebGLTexture.h" 35 #include "core/html/canvas/WebGLVertexArrayObjectOES.h" 36 #include "wtf/Float32Array.h" 37 #include "wtf/Int32Array.h" 38 #include "wtf/PassRefPtr.h" 39 #include "wtf/RefPtr.h" 40 #include "wtf/Uint32Array.h" 41 #include "wtf/Uint8Array.h" 42 #include "wtf/text/WTFString.h" 43 44 namespace blink { 45 46 // A tagged union representing the result of get queries like 47 // getParameter (encompassing getBooleanv, getIntegerv, getFloatv) and 48 // similar variants. For reference counted types, increments and 49 // decrements the reference count of the target object. 50 51 class WebGLGetInfo FINAL { 52 STACK_ALLOCATED(); 53 public: 54 enum Type { 55 kTypeBool, 56 kTypeBoolArray, 57 kTypeFloat, 58 kTypeInt, 59 kTypeNull, 60 kTypeString, 61 kTypeUnsignedInt, 62 kTypeWebGLBuffer, 63 kTypeWebGLFloatArray, 64 kTypeWebGLFramebuffer, 65 kTypeWebGLIntArray, 66 kTypeWebGLObjectArray, 67 kTypeWebGLProgram, 68 kTypeWebGLRenderbuffer, 69 kTypeWebGLTexture, 70 kTypeWebGLUnsignedByteArray, 71 kTypeWebGLUnsignedIntArray, 72 kTypeWebGLVertexArrayObjectOES, 73 }; 74 75 explicit WebGLGetInfo(bool value); 76 WebGLGetInfo(const bool* value, int size); 77 explicit WebGLGetInfo(float value); 78 explicit WebGLGetInfo(int value); 79 // Represents the null value and type. 80 WebGLGetInfo(); 81 explicit WebGLGetInfo(const String& value); 82 explicit WebGLGetInfo(unsigned value); 83 explicit WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLBuffer> value); 84 explicit WebGLGetInfo(PassRefPtr<Float32Array> value); 85 explicit WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLFramebuffer> value); 86 explicit WebGLGetInfo(PassRefPtr<Int32Array> value); 87 // FIXME: implement WebGLObjectArray 88 // WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLObjectArray> value); 89 explicit WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLProgram> value); 90 explicit WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLRenderbuffer> value); 91 explicit WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLTexture> value); 92 explicit WebGLGetInfo(PassRefPtr<Uint8Array> value); 93 explicit WebGLGetInfo(PassRefPtr<Uint32Array> value); 94 explicit WebGLGetInfo(PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> value); 95 96 Type getType() const; 97 98 bool getBool() const; 99 const Vector<bool>& getBoolArray() const; 100 float getFloat() const; 101 int getInt() const; 102 const String& getString() const; 103 unsigned getUnsignedInt() const; 104 PassRefPtrWillBeRawPtr<WebGLBuffer> getWebGLBuffer() const; 105 PassRefPtr<Float32Array> getWebGLFloatArray() const; 106 PassRefPtrWillBeRawPtr<WebGLFramebuffer> getWebGLFramebuffer() const; 107 PassRefPtr<Int32Array> getWebGLIntArray() const; 108 // FIXME: implement WebGLObjectArray 109 // PassRefPtr<WebGLObjectArray> getWebGLObjectArray() const; 110 PassRefPtrWillBeRawPtr<WebGLProgram> getWebGLProgram() const; 111 PassRefPtrWillBeRawPtr<WebGLRenderbuffer> getWebGLRenderbuffer() const; 112 PassRefPtrWillBeRawPtr<WebGLTexture> getWebGLTexture() const; 113 PassRefPtr<Uint8Array> getWebGLUnsignedByteArray() const; 114 PassRefPtr<Uint32Array> getWebGLUnsignedIntArray() const; 115 PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> getWebGLVertexArrayObjectOES() const; 116 117 private: 118 Type m_type; 119 bool m_bool; 120 Vector<bool> m_boolArray; 121 float m_float; 122 int m_int; 123 String m_string; 124 unsigned m_unsignedInt; 125 RefPtrWillBeMember<WebGLBuffer> m_webglBuffer; 126 RefPtr<Float32Array> m_webglFloatArray; 127 RefPtrWillBeMember<WebGLFramebuffer> m_webglFramebuffer; 128 RefPtr<Int32Array> m_webglIntArray; 129 // FIXME: implement WebGLObjectArray 130 // RefPtr<WebGLObjectArray> m_webglObjectArray; 131 RefPtrWillBeMember<WebGLProgram> m_webglProgram; 132 RefPtrWillBeMember<WebGLRenderbuffer> m_webglRenderbuffer; 133 RefPtrWillBeMember<WebGLTexture> m_webglTexture; 134 RefPtr<Uint8Array> m_webglUnsignedByteArray; 135 RefPtr<Uint32Array> m_webglUnsignedIntArray; 136 RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_webglVertexArrayObject; 137 }; 138 139 } // namespace blink 140 141 #endif // WebGLGetInfo_h 142