2012-12-08 23:02:29 +00: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 04:03:50 +00:00
|
|
|
#ifndef WEBGL_UNIFORM_LOCATION_H_
|
|
|
|
#define WEBGL_UNIFORM_LOCATION_H_
|
2012-12-08 23:02:29 +00:00
|
|
|
|
2015-01-15 23:40:39 +00: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 00:37:28 +00:00
|
|
|
|
2012-12-08 23:02:29 +00:00
|
|
|
#include "WebGLObjectModel.h"
|
2013-06-10 20:00:35 +00:00
|
|
|
|
2015-01-15 23:40:39 +00:00
|
|
|
struct JSContext;
|
2015-01-10 02:40:56 +00:00
|
|
|
|
2015-01-15 23:40:39 +00:00
|
|
|
namespace mozilla {
|
|
|
|
class WebGLActiveInfo;
|
|
|
|
class WebGLContext;
|
2015-01-13 08:07:26 +00:00
|
|
|
class WebGLProgram;
|
2015-01-13 03:51:20 +00:00
|
|
|
|
2015-01-15 23:40:39 +00:00
|
|
|
namespace webgl {
|
|
|
|
struct LinkedProgramInfo;
|
2016-07-22 06:25:41 +00:00
|
|
|
struct UniformInfo;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace webgl
|
2015-01-15 23:40:39 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class WebGLUniformLocation final
|
2015-01-15 23:40:39 +00:00
|
|
|
: public nsWrapperCache
|
|
|
|
, public WebGLContextBoundObject
|
2012-12-08 23:02:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-01-15 23:40:39 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLUniformLocation)
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLUniformLocation)
|
2012-12-08 23:02:29 +00:00
|
|
|
|
2015-07-15 00:37:28 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto) override;
|
2012-12-08 23:02:29 +00:00
|
|
|
|
2015-01-15 23:40:39 +00:00
|
|
|
WebGLContext* GetParentObject() const {
|
|
|
|
return mContext;
|
|
|
|
}
|
2014-06-26 13:30:49 +00:00
|
|
|
|
2016-07-14 19:04:31 +00:00
|
|
|
//////
|
|
|
|
|
2015-01-15 23:40:39 +00:00
|
|
|
const WeakPtr<const webgl::LinkedProgramInfo> mLinkInfo;
|
2016-07-14 19:04:31 +00:00
|
|
|
webgl::UniformInfo* const mInfo;
|
2015-01-15 23:40:39 +00:00
|
|
|
const GLuint mLoc;
|
2016-05-25 14:27:41 +00:00
|
|
|
const size_t mArrayIndex;
|
2016-07-14 19:04:31 +00:00
|
|
|
|
|
|
|
//////
|
2015-01-10 05:03:54 +00:00
|
|
|
|
2015-01-15 23:40:39 +00:00
|
|
|
WebGLUniformLocation(WebGLContext* webgl, const webgl::LinkedProgramInfo* linkInfo,
|
2016-07-14 19:04:31 +00:00
|
|
|
webgl::UniformInfo* info, GLuint loc, size_t arrayIndex);
|
2015-01-10 05:03:54 +00:00
|
|
|
|
2016-07-14 19:04:31 +00:00
|
|
|
bool ValidateForProgram(WebGLProgram* prog, const char* funcName) const;
|
2015-01-15 23:40:39 +00:00
|
|
|
bool ValidateSizeAndType(uint8_t setterElemSize, GLenum setterType,
|
2016-07-14 19:04:31 +00:00
|
|
|
const char* funcName) const;
|
2015-01-15 23:40:39 +00:00
|
|
|
bool ValidateArrayLength(uint8_t setterElemSize, size_t setterArraySize,
|
2016-07-14 19:04:31 +00:00
|
|
|
const char* funcName) const;
|
2015-01-13 08:07:26 +00:00
|
|
|
|
2016-07-14 19:04:31 +00:00
|
|
|
JS::Value GetUniform(JSContext* js) const;
|
2015-01-13 08:07:26 +00:00
|
|
|
|
2015-01-15 23:40:39 +00: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-08 23:02:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-14 04:03:50 +00:00
|
|
|
#endif // WEBGL_UNIFORM_LOCATION_H_
|