/src/mozilla-central/dom/canvas/WebGLUniformLocation.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_UNIFORM_LOCATION_H_ |
7 | | #define WEBGL_UNIFORM_LOCATION_H_ |
8 | | |
9 | | #include "GLDefs.h" |
10 | | #include "mozilla/WeakPtr.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 "nsWrapperCache.h" |
14 | | |
15 | | #include "WebGLObjectModel.h" |
16 | | |
17 | | struct JSContext; |
18 | | |
19 | | namespace mozilla { |
20 | | class WebGLActiveInfo; |
21 | | class WebGLContext; |
22 | | class WebGLProgram; |
23 | | |
24 | | namespace webgl { |
25 | | struct LinkedProgramInfo; |
26 | | struct UniformInfo; |
27 | | } // namespace webgl |
28 | | |
29 | | class WebGLUniformLocation final |
30 | | : public nsWrapperCache |
31 | | , public WebGLContextBoundObject |
32 | | { |
33 | | public: |
34 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLUniformLocation) |
35 | | NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLUniformLocation) |
36 | | |
37 | | virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto) override; |
38 | | |
39 | 0 | WebGLContext* GetParentObject() const { |
40 | 0 | return mContext; |
41 | 0 | } |
42 | | |
43 | | ////// |
44 | | |
45 | | const WeakPtr<const webgl::LinkedProgramInfo> mLinkInfo; |
46 | | webgl::UniformInfo* const mInfo; |
47 | | const GLuint mLoc; |
48 | | const size_t mArrayIndex; |
49 | | |
50 | | ////// |
51 | | |
52 | | WebGLUniformLocation(WebGLContext* webgl, const webgl::LinkedProgramInfo* linkInfo, |
53 | | webgl::UniformInfo* info, GLuint loc, size_t arrayIndex); |
54 | | |
55 | | bool ValidateForProgram(const WebGLProgram* prog) const; |
56 | | bool ValidateSizeAndType(uint8_t setterElemSize, GLenum setterType) const; |
57 | | bool ValidateArrayLength(uint8_t setterElemSize, size_t setterArraySize) const; |
58 | | |
59 | | JS::Value GetUniform(JSContext* js) const; |
60 | | |
61 | | // Needed for certain helper functions like ValidateObject. |
62 | | // `WebGLUniformLocation`s can't be 'Deleted' in the WebGL sense. |
63 | 0 | bool IsDeleted() const { return false; } |
64 | | |
65 | | protected: |
66 | | ~WebGLUniformLocation(); |
67 | | }; |
68 | | |
69 | | } // namespace mozilla |
70 | | |
71 | | #endif // WEBGL_UNIFORM_LOCATION_H_ |