/src/mozilla-central/dom/canvas/WebGLActiveInfo.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #ifndef WEBGL_ACTIVE_INFO_H_ |
7 | | #define WEBGL_ACTIVE_INFO_H_ |
8 | | |
9 | | #include "GLDefs.h" |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS |
12 | | #include "nsISupportsImpl.h" // NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING |
13 | | #include "nsString.h" |
14 | | #include "nsWrapperCache.h" |
15 | | |
16 | | namespace mozilla { |
17 | | |
18 | | class WebGLContext; |
19 | | |
20 | | class WebGLActiveInfo final |
21 | | : public nsWrapperCache |
22 | | { |
23 | | public: |
24 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLActiveInfo) |
25 | | NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLActiveInfo) |
26 | | |
27 | | virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto) override; |
28 | | |
29 | 0 | WebGLContext* GetParentObject() const { |
30 | 0 | return mWebGL; |
31 | 0 | } |
32 | | |
33 | | WebGLContext* const mWebGL; |
34 | | |
35 | | // ActiveInfo state: |
36 | | const uint32_t mElemCount; // `size` |
37 | | const GLenum mElemType; // `type` |
38 | | const nsCString mBaseUserName; // `name`, but ASCII, and without any final "[0]". |
39 | | |
40 | | // Not actually part of ActiveInfo: |
41 | | const bool mIsArray; |
42 | | const uint8_t mElemSize; |
43 | | const nsCString mBaseMappedName; // Without any final "[0]". |
44 | | |
45 | | bool IsSampler() const; |
46 | | |
47 | | WebGLActiveInfo(WebGLContext* webgl, GLint elemCount, GLenum elemType, bool isArray, |
48 | | const nsACString& baseUserName, const nsACString& baseMappedName); |
49 | | |
50 | | /* GLES 2.0.25, p33: |
51 | | * This command will return as much information about active |
52 | | * attributes as possible. If no information is available, length will |
53 | | * be set to zero and name will be an empty string. This situation |
54 | | * could arise if GetActiveAttrib is issued after a failed link. |
55 | | * |
56 | | * It's the same for GetActiveUniform. |
57 | | */ |
58 | 0 | static WebGLActiveInfo* CreateInvalid(WebGLContext* webgl) { |
59 | 0 | return new WebGLActiveInfo(webgl); |
60 | 0 | } |
61 | | |
62 | | // WebIDL attributes |
63 | 0 | GLint Size() const { |
64 | 0 | return mElemCount; |
65 | 0 | } |
66 | | |
67 | 0 | GLenum Type() const { |
68 | 0 | return mElemType; |
69 | 0 | } |
70 | | |
71 | 0 | void GetName(nsString& retval) const { |
72 | 0 | CopyASCIItoUTF16(mBaseUserName, retval); |
73 | 0 | if (mIsArray) |
74 | 0 | retval.AppendLiteral("[0]"); |
75 | 0 | } |
76 | | |
77 | | private: |
78 | | explicit WebGLActiveInfo(WebGLContext* webgl) |
79 | | : mWebGL(webgl) |
80 | | , mElemCount(0) |
81 | | , mElemType(0) |
82 | | , mBaseUserName("") |
83 | | , mIsArray(false) |
84 | | , mElemSize(0) |
85 | | , mBaseMappedName("") |
86 | 0 | { } |
87 | | |
88 | | // Private destructor, to discourage deletion outside of Release(): |
89 | 0 | ~WebGLActiveInfo() { } |
90 | | }; |
91 | | |
92 | | ////////// |
93 | | |
94 | | bool IsElemTypeSampler(GLenum elemType); |
95 | | |
96 | | } // namespace mozilla |
97 | | |
98 | | #endif // WEBGL_ACTIVE_INFO_H_ |