Bug 1521243 - Show a warning for invalid declarations and filter icon for overridden...
[gecko.git] / dom / canvas / WebGLUniformLocation.h
blob8feac3d4c8c166bf11a394fe540ae5fcdc257c10
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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/. */
6 #ifndef WEBGL_UNIFORM_LOCATION_H_
7 #define WEBGL_UNIFORM_LOCATION_H_
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"
15 #include "WebGLObjectModel.h"
17 struct JSContext;
19 namespace mozilla {
20 class WebGLActiveInfo;
21 class WebGLContext;
22 class WebGLProgram;
24 namespace webgl {
25 struct LinkedProgramInfo;
26 struct UniformInfo;
27 } // namespace webgl
29 class WebGLUniformLocation final : public nsWrapperCache,
30 public WebGLContextBoundObject {
31 public:
32 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLUniformLocation)
33 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLUniformLocation)
35 virtual JSObject* WrapObject(JSContext* js,
36 JS::Handle<JSObject*> givenProto) override;
38 WebGLContext* GetParentObject() const { return mContext; }
40 //////
42 const WeakPtr<const webgl::LinkedProgramInfo> mLinkInfo;
43 webgl::UniformInfo* const mInfo;
44 const GLuint mLoc;
45 const size_t mArrayIndex;
47 //////
49 WebGLUniformLocation(WebGLContext* webgl,
50 const webgl::LinkedProgramInfo* linkInfo,
51 webgl::UniformInfo* info, GLuint loc, size_t arrayIndex);
53 bool ValidateForProgram(const WebGLProgram* prog) const;
54 bool ValidateSizeAndType(uint8_t setterElemSize,
55 webgl::AttribBaseType setterType) const;
56 bool ValidateArrayLength(uint8_t setterElemSize,
57 size_t setterArraySize) const;
59 JS::Value GetUniform(JSContext* js) const;
61 // Needed for certain helper functions like ValidateObject.
62 // `WebGLUniformLocation`s can't be 'Deleted' in the WebGL sense.
63 bool IsDeleted() const { return false; }
65 protected:
66 ~WebGLUniformLocation();
69 } // namespace mozilla
71 #endif // WEBGL_UNIFORM_LOCATION_H_