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