OSDN Git Service

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