2012-12-09 03:02:29 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#ifndef WEBGL_UNIFORM_LOCATION_H_
|
|
|
|
#define WEBGL_UNIFORM_LOCATION_H_
|
2012-12-09 03:02:29 +04:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
#include "GLDefs.h"
|
|
|
|
#include "mozilla/WeakPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS
|
|
|
|
#include "nsISupportsImpl.h" // NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING
|
|
|
|
#include "nsWrapperCache.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
|
2012-12-09 03:02:29 +04:00
|
|
|
#include "WebGLObjectModel.h"
|
2013-06-11 00:00:35 +04:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
struct JSContext;
|
2015-01-10 05:40:56 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class WebGLActiveInfo;
|
|
|
|
class WebGLContext;
|
2015-01-13 11:07:26 +03:00
|
|
|
class WebGLProgram;
|
2015-01-13 06:51:20 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
namespace webgl {
|
|
|
|
struct LinkedProgramInfo;
|
2016-07-22 09:25:41 +03:00
|
|
|
struct UniformInfo;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace webgl
|
2015-01-16 02:40:39 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class WebGLUniformLocation final
|
2015-01-16 02:40:39 +03:00
|
|
|
: public nsWrapperCache
|
|
|
|
, public WebGLContextBoundObject
|
2012-12-09 03:02:29 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-01-16 02:40:39 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLUniformLocation)
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLUniformLocation)
|
2012-12-09 03:02:29 +04:00
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto) override;
|
2012-12-09 03:02:29 +04:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
WebGLContext* GetParentObject() const {
|
|
|
|
return mContext;
|
|
|
|
}
|
2014-06-26 17:30:49 +04:00
|
|
|
|
2016-07-14 22:04:31 +03:00
|
|
|
//////
|
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
const WeakPtr<const webgl::LinkedProgramInfo> mLinkInfo;
|
2016-07-14 22:04:31 +03:00
|
|
|
webgl::UniformInfo* const mInfo;
|
2015-01-16 02:40:39 +03:00
|
|
|
const GLuint mLoc;
|
2016-05-25 17:27:41 +03:00
|
|
|
const size_t mArrayIndex;
|
2016-07-14 22:04:31 +03:00
|
|
|
|
|
|
|
//////
|
2015-01-10 08:03:54 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
WebGLUniformLocation(WebGLContext* webgl, const webgl::LinkedProgramInfo* linkInfo,
|
2016-07-14 22:04:31 +03:00
|
|
|
webgl::UniformInfo* info, GLuint loc, size_t arrayIndex);
|
2015-01-10 08:03:54 +03:00
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
bool ValidateForProgram(const WebGLProgram* prog) const;
|
2018-10-17 07:18:15 +03:00
|
|
|
bool ValidateSizeAndType(uint8_t setterElemSize,
|
|
|
|
webgl::AttribBaseType setterType) const;
|
2018-07-27 07:46:33 +03:00
|
|
|
bool ValidateArrayLength(uint8_t setterElemSize, size_t setterArraySize) const;
|
2015-01-13 11:07:26 +03:00
|
|
|
|
2016-07-14 22:04:31 +03:00
|
|
|
JS::Value GetUniform(JSContext* js) const;
|
2015-01-13 11:07:26 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
// Needed for certain helper functions like ValidateObject.
|
|
|
|
// `WebGLUniformLocation`s can't be 'Deleted' in the WebGL sense.
|
|
|
|
bool IsDeleted() const { return false; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
~WebGLUniformLocation();
|
2012-12-09 03:02:29 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#endif // WEBGL_UNIFORM_LOCATION_H_
|