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_
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"
20 class WebGLActiveInfo
;
25 struct LinkedProgramInfo
;
29 class WebGLUniformLocation final
: public nsWrapperCache
,
30 public WebGLContextBoundObject
{
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
; }
42 const WeakPtr
<const webgl::LinkedProgramInfo
> mLinkInfo
;
43 webgl::UniformInfo
* const mInfo
;
45 const size_t mArrayIndex
;
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; }
66 ~WebGLUniformLocation();
69 } // namespace mozilla
71 #endif // WEBGL_UNIFORM_LOCATION_H_