2013-06-11 00:00:35 +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_ACTIVE_INFO_H_
|
|
|
|
#define WEBGL_ACTIVE_INFO_H_
|
2013-06-11 00:00:35 +04:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
#include "GLDefs.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS
|
|
|
|
#include "nsISupportsImpl.h" // NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "nsString.h"
|
2015-01-16 02:40:39 +03:00
|
|
|
#include "nsWrapperCache.h"
|
2013-06-11 00:00:35 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
class WebGLContext;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class WebGLActiveInfo final
|
2015-01-16 02:40:39 +03:00
|
|
|
: public nsWrapperCache
|
2013-06-11 00:00:35 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-01-16 02:40:39 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLActiveInfo)
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLActiveInfo)
|
2015-01-10 08:03:54 +03:00
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto) override;
|
2015-01-16 02:40:39 +03:00
|
|
|
|
|
|
|
WebGLContext* GetParentObject() const {
|
|
|
|
return mWebGL;
|
|
|
|
}
|
|
|
|
|
|
|
|
WebGLContext* const mWebGL;
|
|
|
|
|
|
|
|
// ActiveInfo state:
|
2016-07-14 22:08:06 +03:00
|
|
|
const uint32_t mElemCount; // `size`
|
2015-01-16 02:40:39 +03:00
|
|
|
const GLenum mElemType; // `type`
|
|
|
|
const nsCString mBaseUserName; // `name`, but ASCII, and without any final "[0]".
|
|
|
|
|
|
|
|
// Not actually part of ActiveInfo:
|
|
|
|
const bool mIsArray;
|
|
|
|
const uint8_t mElemSize;
|
|
|
|
const nsCString mBaseMappedName; // Without any final "[0]".
|
|
|
|
|
2016-07-14 22:04:31 +03:00
|
|
|
bool IsSampler() const;
|
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
WebGLActiveInfo(WebGLContext* webgl, GLint elemCount, GLenum elemType, bool isArray,
|
|
|
|
const nsACString& baseUserName, const nsACString& baseMappedName);
|
2015-01-13 11:07:26 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
/* GLES 2.0.25, p33:
|
|
|
|
* This command will return as much information about active
|
|
|
|
* attributes as possible. If no information is available, length will
|
|
|
|
* be set to zero and name will be an empty string. This situation
|
|
|
|
* could arise if GetActiveAttrib is issued after a failed link.
|
|
|
|
*
|
|
|
|
* It's the same for GetActiveUniform.
|
|
|
|
*/
|
|
|
|
static WebGLActiveInfo* CreateInvalid(WebGLContext* webgl) {
|
|
|
|
return new WebGLActiveInfo(webgl);
|
|
|
|
}
|
|
|
|
|
|
|
|
// WebIDL attributes
|
2013-09-04 16:14:43 +04:00
|
|
|
GLint Size() const {
|
2015-01-16 02:40:39 +03:00
|
|
|
return mElemCount;
|
2013-06-11 00:00:35 +04:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
GLenum Type() const {
|
2015-01-16 02:40:39 +03:00
|
|
|
return mElemType;
|
2013-06-11 00:00:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetName(nsString& retval) const {
|
2015-01-16 02:40:39 +03:00
|
|
|
CopyASCIItoUTF16(mBaseUserName, retval);
|
|
|
|
if (mIsArray)
|
|
|
|
retval.AppendLiteral("[0]");
|
2013-06-11 00:00:35 +04:00
|
|
|
}
|
|
|
|
|
2015-01-13 11:07:26 +03:00
|
|
|
private:
|
2015-01-16 02:40:39 +03:00
|
|
|
explicit WebGLActiveInfo(WebGLContext* webgl)
|
|
|
|
: mWebGL(webgl)
|
|
|
|
, mElemCount(0)
|
|
|
|
, mElemType(0)
|
|
|
|
, mBaseUserName("")
|
|
|
|
, mIsArray(false)
|
|
|
|
, mElemSize(0)
|
|
|
|
, mBaseMappedName("")
|
|
|
|
{ }
|
2015-01-13 11:07:26 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
|
|
|
~WebGLActiveInfo() { }
|
2013-06-11 00:00:35 +04:00
|
|
|
};
|
|
|
|
|
2016-07-07 19:12:10 +03:00
|
|
|
//////////
|
|
|
|
|
2016-07-14 22:04:31 +03:00
|
|
|
bool IsElemTypeSampler(GLenum elemType);
|
2016-07-07 19:12:10 +03:00
|
|
|
|
2013-06-11 00:00:35 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#endif // WEBGL_ACTIVE_INFO_H_
|