Line data Source code
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 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLUniformLocation)
35 0 : 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 : }
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 char* funcName) const;
56 : bool ValidateSizeAndType(uint8_t setterElemSize, GLenum setterType,
57 : const char* funcName) const;
58 : bool ValidateArrayLength(uint8_t setterElemSize, size_t setterArraySize,
59 : const char* funcName) const;
60 :
61 : JS::Value GetUniform(JSContext* js) const;
62 :
63 : // Needed for certain helper functions like ValidateObject.
64 : // `WebGLUniformLocation`s can't be 'Deleted' in the WebGL sense.
65 : bool IsDeleted() const { return false; }
66 :
67 : protected:
68 : ~WebGLUniformLocation();
69 : };
70 :
71 : } // namespace mozilla
72 :
73 : #endif // WEBGL_UNIFORM_LOCATION_H_
|