bug 879802 - Clean up the #includes in the WebGL implementation - r=bjacob

This commit is contained in:
Guillaume Abadie 2013-06-10 16:00:35 -04:00
parent d0f9a03c5f
commit af723a2ae6
25 changed files with 423 additions and 317 deletions

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "WebGLTexture.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
using namespace mozilla;

View File

@ -0,0 +1,52 @@
/* -*- 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/. */
#ifndef WEBGLACTIVEINFO_H_
#define WEBGLACTIVEINFO_H_
#include "WebGLTypes.h"
#include "nsISupports.h"
#include "nsString.h"
#include "jsapi.h"
namespace mozilla {
class WebGLActiveInfo MOZ_FINAL
: public nsISupports
{
public:
WebGLActiveInfo(WebGLint size, WebGLenum type, const nsACString& name) :
mSize(size),
mType(type),
mName(NS_ConvertASCIItoUTF16(name))
{}
// WebIDL attributes
WebGLint Size() const {
return mSize;
}
WebGLenum Type() const {
return mType;
}
void GetName(nsString& retval) const {
retval = mName;
}
JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope);
NS_DECL_ISUPPORTS
protected:
WebGLint mSize;
WebGLenum mType;
nsString mName;
};
} // namespace mozilla
#endif

View File

@ -6,8 +6,9 @@
#ifndef WEBGLBUFFER_H_
#define WEBGLBUFFER_H_
#include "WebGLElementArrayCache.h"
#include "WebGLObjectModel.h"
#include "WebGLElementArrayCache.h"
#include "GLDefs.h"
#include "nsWrapperCache.h"
@ -15,6 +16,8 @@
namespace mozilla {
class WebGLElementArrayCache;
class WebGLBuffer MOZ_FINAL
: public nsISupports
, public WebGLRefCountedObject<WebGLBuffer>

View File

@ -7,6 +7,10 @@
#include "WebGLObjectModel.h"
#include "WebGLExtensions.h"
#include "WebGLContextUtils.h"
#include "WebGLBuffer.h"
#include "WebGLVertexAttribData.h"
#include "WebGLMemoryMultiReporterWrapper.h"
#include "WebGLFramebuffer.h"
#include "AccessCheck.h"
#include "nsIConsoleService.h"

View File

@ -7,17 +7,9 @@
#define WEBGLCONTEXT_H_
#include "mozilla/Attributes.h"
#include "WebGLElementArrayCache.h"
#include "GLDefs.h"
#include "WebGLActiveInfo.h"
#include "WebGLObjectModel.h"
#include "WebGLShader.h"
#include "WebGLBuffer.h"
#include "WebGLProgram.h"
#include "WebGLUniformLocation.h"
#include "WebGLFramebuffer.h"
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
#include "WebGLVertexAttribData.h"
#include "WebGLShaderPrecisionFormat.h"
#include <stdarg.h>
#include "nsTArray.h"
@ -75,61 +67,21 @@ class WebGLMemoryPressureObserver;
class WebGLContextBoundObject;
class WebGLActiveInfo;
class WebGLExtensionBase;
class WebGLBuffer;
class WebGLVertexAttribData;
class WebGLShader;
class WebGLProgram;
class WebGLUniformLocation;
class WebGLFramebuffer;
class WebGLRenderbuffer;
class WebGLShaderPrecisionFormat;
class WebGLTexture;
namespace dom {
struct WebGLContextAttributes;
struct WebGLContextAttributesInitializer;
}
struct VertexAttrib0Status {
enum { Default, EmulatedUninitializedArray, EmulatedInitializedArray };
};
namespace WebGLTexelConversions {
/*
* The formats that may participate, either as source or destination formats,
* in WebGL texture conversions. This includes:
* - all the formats accepted by WebGL.texImage2D, e.g. RGBA4444
* - additional formats provided by extensions, e.g. RGB32F
* - additional source formats, depending on browser details, used when uploading
* textures from DOM elements. See gfxImageSurface::Format().
*/
enum WebGLTexelFormat
{
// dummy error code returned by GetWebGLTexelFormat in error cases,
// after assertion failure (so this never happens in debug builds)
BadFormat,
// dummy pseudo-format meaning "use the other format".
// For example, if SrcFormat=Auto and DstFormat=RGB8, then the source
// is implicitly treated as being RGB8 itself.
Auto,
// 1-channel formats
R8,
A8,
D16, // used for WEBGL_depth_texture extension
D32, // used for WEBGL_depth_texture extension
R32F, // used for OES_texture_float extension
A32F, // used for OES_texture_float extension
// 2-channel formats
RA8,
RA32F,
D24S8, // used for WEBGL_depth_texture extension
// 3-channel formats
RGB8,
BGRX8, // used for DOM elements. Source format only.
RGB565,
RGB32F, // used for OES_texture_float extension
// 4-channel formats
RGBA8,
BGRA8, // used for DOM elements
RGBA5551,
RGBA4444,
RGBA32F // used for OES_texture_float extension
};
} // end namespace WebGLTexelConversions
using WebGLTexelConversions::WebGLTexelFormat;
WebGLTexelFormat GetWebGLTexelFormat(GLenum format, GLenum type);
@ -1188,46 +1140,6 @@ ToSupports(WebGLContext* context)
return static_cast<nsIDOMWebGLRenderingContext*>(context);
}
class WebGLActiveInfo MOZ_FINAL
: public nsISupports
{
public:
WebGLActiveInfo(WebGLint size, WebGLenum type, const nsACString& name) :
mSize(size),
mType(type),
mName(NS_ConvertASCIItoUTF16(name))
{}
// WebIDL attributes
WebGLint Size() const {
return mSize;
}
WebGLenum Type() const {
return mType;
}
void GetName(nsString& retval) const {
retval = mName;
}
JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope);
NS_DECL_ISUPPORTS
protected:
WebGLint mSize;
WebGLenum mType;
nsString mName;
};
inline const WebGLRectangleObject *WebGLContext::FramebufferRectangleObject() const {
return mBoundFramebuffer ? mBoundFramebuffer->RectangleObject()
: static_cast<const WebGLRectangleObject*>(this);
}
/**
** Template implementations
**/
@ -1299,148 +1211,6 @@ WebGLContext::ValidateObject(const char* info, ObjectType *aObject)
return ValidateObjectAssumeNonNull(info, aObject);
}
class WebGLMemoryMultiReporterWrapper
{
WebGLMemoryMultiReporterWrapper();
~WebGLMemoryMultiReporterWrapper();
static WebGLMemoryMultiReporterWrapper* sUniqueInstance;
// here we store plain pointers, not RefPtrs: we don't want the
// WebGLMemoryMultiReporterWrapper unique instance to keep alive all
// WebGLContexts ever created.
typedef nsTArray<const WebGLContext*> ContextsArrayType;
ContextsArrayType mContexts;
nsCOMPtr<nsIMemoryMultiReporter> mReporter;
static WebGLMemoryMultiReporterWrapper* UniqueInstance();
static ContextsArrayType & Contexts() { return UniqueInstance()->mContexts; }
friend class WebGLContext;
public:
static void AddWebGLContext(const WebGLContext* c) {
Contexts().AppendElement(c);
}
static void RemoveWebGLContext(const WebGLContext* c) {
ContextsArrayType & contexts = Contexts();
contexts.RemoveElement(c);
if (contexts.IsEmpty()) {
delete sUniqueInstance;
sUniqueInstance = nullptr;
}
}
static int64_t GetTextureMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLTexture *texture = contexts[i]->mTextures.getFirst();
texture;
texture = texture->getNext())
{
result += texture->MemoryUsage();
}
}
return result;
}
static int64_t GetTextureCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLTexture *texture = contexts[i]->mTextures.getFirst();
texture;
texture = texture->getNext())
{
result++;
}
}
return result;
}
static int64_t GetBufferMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLBuffer *buffer = contexts[i]->mBuffers.getFirst();
buffer;
buffer = buffer->getNext())
{
result += buffer->ByteLength();
}
}
return result;
}
static int64_t GetBufferCacheMemoryUsed();
static int64_t GetBufferCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLBuffer *buffer = contexts[i]->mBuffers.getFirst();
buffer;
buffer = buffer->getNext())
{
result++;
}
}
return result;
}
static int64_t GetRenderbufferMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLRenderbuffer *rb = contexts[i]->mRenderbuffers.getFirst();
rb;
rb = rb->getNext())
{
result += rb->MemoryUsage();
}
}
return result;
}
static int64_t GetRenderbufferCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLRenderbuffer *rb = contexts[i]->mRenderbuffers.getFirst();
rb;
rb = rb->getNext())
{
result++;
}
}
return result;
}
static int64_t GetShaderSize();
static int64_t GetShaderCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLShader *shader = contexts[i]->mShaders.getFirst();
shader;
shader = shader->getNext())
{
result++;
}
}
return result;
}
static int64_t GetContextCount() {
return Contexts().Length();
}
};
class WebGLMemoryPressureObserver MOZ_FINAL
: public nsIObserver
{

View File

@ -5,6 +5,15 @@
#include "WebGLContext.h"
#include "WebGLContextUtils.h"
#include "WebGLBuffer.h"
#include "WebGLVertexAttribData.h"
#include "WebGLShader.h"
#include "WebGLProgram.h"
#include "WebGLUniformLocation.h"
#include "WebGLFramebuffer.h"
#include "WebGLRenderbuffer.h"
#include "WebGLShaderPrecisionFormat.h"
#include "WebGLTexture.h"
#include "nsString.h"
#include "nsDebug.h"
@ -45,6 +54,10 @@ static const int MAX_DRAW_CALLS_SINCE_FLUSH = 100;
// WebGL API
//
inline const WebGLRectangleObject *WebGLContext::FramebufferRectangleObject() const {
return mBoundFramebuffer ? mBoundFramebuffer->RectangleObject()
: static_cast<const WebGLRectangleObject*>(this);
}
void
WebGLContext::ActiveTexture(WebGLenum texture)

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "WebGLMemoryMultiReporterWrapper.h"
#include "nsIMemoryReporter.h"
using namespace mozilla;

View File

@ -4,6 +4,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "WebGLBuffer.h"
#include "WebGLVertexAttribData.h"
#include "WebGLShader.h"
#include "WebGLProgram.h"
#include "WebGLUniformLocation.h"
#include "WebGLFramebuffer.h"
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/Preferences.h"

View File

@ -6,10 +6,10 @@
#ifndef WEBGLEXTENSIONS_H_
#define WEBGLEXTENSIONS_H_
#include "WebGLContext.h"
namespace mozilla {
class WebGLContext;
class WebGLExtensionBase
: public nsISupports
, public WebGLContextBoundObject

View File

@ -5,6 +5,8 @@
#include "WebGLContext.h"
#include "WebGLFramebuffer.h"
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "nsContentUtils.h"

View File

@ -0,0 +1,165 @@
/* -*- 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/. */
#ifndef WEBGLMEMORYMULTIREPORTWRAPER_H_
#define WEBGLMEMORYMULTIREPORTWRAPER_H_
#include "WebGLContext.h"
#include "WebGLBuffer.h"
#include "WebGLVertexAttribData.h"
#include "WebGLShader.h"
#include "WebGLProgram.h"
#include "WebGLUniformLocation.h"
#include "WebGLTexture.h"
#include "WebGLRenderbuffer.h"
namespace mozilla {
class WebGLMemoryMultiReporterWrapper
{
WebGLMemoryMultiReporterWrapper();
~WebGLMemoryMultiReporterWrapper();
static WebGLMemoryMultiReporterWrapper* sUniqueInstance;
// here we store plain pointers, not RefPtrs: we don't want the
// WebGLMemoryMultiReporterWrapper unique instance to keep alive all
// WebGLContexts ever created.
typedef nsTArray<const WebGLContext*> ContextsArrayType;
ContextsArrayType mContexts;
nsCOMPtr<nsIMemoryMultiReporter> mReporter;
static WebGLMemoryMultiReporterWrapper* UniqueInstance();
static ContextsArrayType & Contexts() { return UniqueInstance()->mContexts; }
friend class WebGLContext;
public:
static void AddWebGLContext(const WebGLContext* c) {
Contexts().AppendElement(c);
}
static void RemoveWebGLContext(const WebGLContext* c) {
ContextsArrayType & contexts = Contexts();
contexts.RemoveElement(c);
if (contexts.IsEmpty()) {
delete sUniqueInstance;
sUniqueInstance = nullptr;
}
}
static int64_t GetTextureMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLTexture *texture = contexts[i]->mTextures.getFirst();
texture;
texture = texture->getNext())
{
result += texture->MemoryUsage();
}
}
return result;
}
static int64_t GetTextureCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLTexture *texture = contexts[i]->mTextures.getFirst();
texture;
texture = texture->getNext())
{
result++;
}
}
return result;
}
static int64_t GetBufferMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLBuffer *buffer = contexts[i]->mBuffers.getFirst();
buffer;
buffer = buffer->getNext())
{
result += buffer->ByteLength();
}
}
return result;
}
static int64_t GetBufferCacheMemoryUsed();
static int64_t GetBufferCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLBuffer *buffer = contexts[i]->mBuffers.getFirst();
buffer;
buffer = buffer->getNext())
{
result++;
}
}
return result;
}
static int64_t GetRenderbufferMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLRenderbuffer *rb = contexts[i]->mRenderbuffers.getFirst();
rb;
rb = rb->getNext())
{
result += rb->MemoryUsage();
}
}
return result;
}
static int64_t GetRenderbufferCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLRenderbuffer *rb = contexts[i]->mRenderbuffers.getFirst();
rb;
rb = rb->getNext())
{
result++;
}
}
return result;
}
static int64_t GetShaderSize();
static int64_t GetShaderCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLShader *shader = contexts[i]->mShaders.getFirst();
shader;
shader = shader->getNext())
{
result++;
}
}
return result;
}
static int64_t GetContextCount() {
return Contexts().Length();
}
};
} // namespace mozilla
#endif

View File

@ -8,18 +8,7 @@
#include "nsCycleCollectionNoteChild.h"
#include "nsICanvasRenderingContextInternal.h"
// Manual reflection of WebIDL typedefs
typedef uint32_t WebGLenum;
typedef uint32_t WebGLbitfield;
typedef int32_t WebGLint;
typedef int32_t WebGLsizei;
typedef int64_t WebGLsizeiptr;
typedef int64_t WebGLintptr;
typedef uint32_t WebGLuint;
typedef float WebGLfloat;
typedef float WebGLclampf;
typedef bool WebGLboolean;
#include "WebGLTypes.h"
namespace mozilla {

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "WebGLShader.h"
#include "WebGLProgram.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "nsContentUtils.h"

View File

@ -7,7 +7,6 @@
#define WEBGLPROGRAM_H_
#include "WebGLObjectModel.h"
#include "WebGLShader.h"
#include "nsWrapperCache.h"
@ -16,6 +15,9 @@
namespace mozilla {
class WebGLShader;
class WebGLUniformInfo;
typedef nsDataHashtable<nsCStringHashKey, nsCString> CStringMap;
typedef nsDataHashtable<nsCStringHashKey, WebGLUniformInfo> CStringToUniformInfoMap;

View File

@ -5,6 +5,7 @@
#include "WebGLContext.h"
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "nsContentUtils.h"

View File

@ -3,6 +3,7 @@
* 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/. */
#include "WebGLObjectModel.h"
#include "WebGLShader.h"
#include "WebGLContext.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"

View File

@ -7,6 +7,7 @@
#define WEBGLSHADER_H_
#include "WebGLObjectModel.h"
#include "WebGLUniformInfo.h"
#include "nsWrapperCache.h"
@ -21,46 +22,6 @@ struct WebGLMappedIdentifier {
WebGLMappedIdentifier(const nsACString& o, const nsACString& m) : original(o), mapped(m) {}
};
struct WebGLUniformInfo {
uint32_t arraySize;
bool isArray;
ShDataType type;
WebGLUniformInfo(uint32_t s = 0, bool a = false, ShDataType t = SH_NONE)
: arraySize(s), isArray(a), type(t) {}
int ElementSize() const {
switch (type) {
case SH_INT:
case SH_FLOAT:
case SH_BOOL:
case SH_SAMPLER_2D:
case SH_SAMPLER_CUBE:
return 1;
case SH_INT_VEC2:
case SH_FLOAT_VEC2:
case SH_BOOL_VEC2:
return 2;
case SH_INT_VEC3:
case SH_FLOAT_VEC3:
case SH_BOOL_VEC3:
return 3;
case SH_INT_VEC4:
case SH_FLOAT_VEC4:
case SH_BOOL_VEC4:
case SH_FLOAT_MAT2:
return 4;
case SH_FLOAT_MAT3:
return 9;
case SH_FLOAT_MAT4:
return 16;
default:
NS_ABORT(); // should never get here
return 0;
}
}
};
class WebGLShader MOZ_FINAL
: public nsISupports
, public WebGLRefCountedObject<WebGLShader>

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "WebGLShaderPrecisionFormat.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
using namespace mozilla;

View File

@ -32,7 +32,7 @@
#define __restrict
#endif
#include "WebGLTexture.h"
#include "WebGLTypes.h"
#include "mozilla/StandardInteger.h"
#if defined _MSC_VER

View File

@ -7,18 +7,14 @@
#define WEBGLTEXTURE_H_
#include "WebGLObjectModel.h"
#include "WebGLRenderbuffer.h"
#include "nsWrapperCache.h"
#include "mozilla/LinkedList.h"
#include "mozilla/CheckedInt.h"
#include <algorithm>
namespace mozilla {
enum FakeBlackStatus { DoNotNeedFakeBlack, DoNeedFakeBlack, DontKnowIfNeedFakeBlack };
// Zero is not an integer power of two.
inline bool is_pot_assuming_nonnegative(WebGLsizei x)
{

View File

@ -0,0 +1,76 @@
/* -*- 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/. */
#ifndef WEBGLTYPES_H_
#define WEBGLTYPES_H_
// Manual reflection of WebIDL typedefs
typedef uint32_t WebGLenum;
typedef uint32_t WebGLbitfield;
typedef int32_t WebGLint;
typedef int32_t WebGLsizei;
typedef int64_t WebGLsizeiptr;
typedef int64_t WebGLintptr;
typedef uint32_t WebGLuint;
typedef float WebGLfloat;
typedef float WebGLclampf;
typedef bool WebGLboolean;
namespace mozilla {
enum FakeBlackStatus { DoNotNeedFakeBlack, DoNeedFakeBlack, DontKnowIfNeedFakeBlack };
struct VertexAttrib0Status {
enum { Default, EmulatedUninitializedArray, EmulatedInitializedArray };
};
namespace WebGLTexelConversions {
/*
* The formats that may participate, either as source or destination formats,
* in WebGL texture conversions. This includes:
* - all the formats accepted by WebGL.texImage2D, e.g. RGBA4444
* - additional formats provided by extensions, e.g. RGB32F
* - additional source formats, depending on browser details, used when uploading
* textures from DOM elements. See gfxImageSurface::Format().
*/
enum WebGLTexelFormat
{
// dummy error code returned by GetWebGLTexelFormat in error cases,
// after assertion failure (so this never happens in debug builds)
BadFormat,
// dummy pseudo-format meaning "use the other format".
// For example, if SrcFormat=Auto and DstFormat=RGB8, then the source
// is implicitly treated as being RGB8 itself.
Auto,
// 1-channel formats
R8,
A8,
D16, // used for WEBGL_depth_texture extension
D32, // used for WEBGL_depth_texture extension
R32F, // used for OES_texture_float extension
A32F, // used for OES_texture_float extension
// 2-channel formats
RA8,
RA32F,
D24S8, // used for WEBGL_depth_texture extension
// 3-channel formats
RGB8,
BGRX8, // used for DOM elements. Source format only.
RGB565,
RGB32F, // used for OES_texture_float extension
// 4-channel formats
RGBA8,
BGRA8, // used for DOM elements
RGBA5551,
RGBA4444,
RGBA32F // used for OES_texture_float extension
};
} // end namespace WebGLTexelConversions
} // namespace mozilla
#endif

View File

@ -0,0 +1,55 @@
/* -*- 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/. */
#ifndef WEBGLUNIFORMINFO_H_
#define WEBGLUNIFORMINFO_H_
#include "angle/ShaderLang.h"
namespace mozilla {
struct WebGLUniformInfo {
uint32_t arraySize;
bool isArray;
ShDataType type;
WebGLUniformInfo(uint32_t s = 0, bool a = false, ShDataType t = SH_NONE)
: arraySize(s), isArray(a), type(t) {}
int ElementSize() const {
switch (type) {
case SH_INT:
case SH_FLOAT:
case SH_BOOL:
case SH_SAMPLER_2D:
case SH_SAMPLER_CUBE:
return 1;
case SH_INT_VEC2:
case SH_FLOAT_VEC2:
case SH_BOOL_VEC2:
return 2;
case SH_INT_VEC3:
case SH_FLOAT_VEC3:
case SH_BOOL_VEC3:
return 3;
case SH_INT_VEC4:
case SH_FLOAT_VEC4:
case SH_BOOL_VEC4:
case SH_FLOAT_MAT2:
return 4;
case SH_FLOAT_MAT3:
return 9;
case SH_FLOAT_MAT4:
return 16;
default:
NS_ABORT(); // should never get here
return 0;
}
}
};
} // namespace mozilla
#endif

View File

@ -4,6 +4,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "WebGLUniformLocation.h"
#include "WebGLShader.h"
#include "WebGLProgram.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
using namespace mozilla;

View File

@ -7,9 +7,12 @@
#define WEBGLUNIFORMLOCATION_H_
#include "WebGLObjectModel.h"
#include "WebGLUniformInfo.h"
namespace mozilla {
class WebGLProgram;
class WebGLUniformLocation MOZ_FINAL
: public nsISupports
, public WebGLContextBoundObject

View File

@ -1,17 +1,15 @@
/* -*- 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/. */
#ifndef WEBGLVERTEXATTRIBDATA_H_
#define WEBGLVERTEXATTRIBDATA_H_
#include "WebGLObjectModel.h"
namespace mozilla {
class WebGLBuffer;
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef WEBGLVERTEXATTRIBDATA_H_
#define WEBGLVERTEXATTRIBDATA_H_
namespace mozilla {
class WebGLBuffer;
struct WebGLVertexAttribData {
// note that these initial values are what GL initializes vertex attribs to
WebGLVertexAttribData()
@ -55,8 +53,8 @@ struct WebGLVertexAttribData {
if (stride) return stride;
return size * componentSize();
}
};
};
} // namespace mozilla
inline void ImplCycleCollectionUnlink(mozilla::WebGLVertexAttribData& aField)
@ -72,6 +70,6 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
{
CycleCollectionNoteEdgeName(aCallback, aName, aFlags);
aCallback.NoteXPCOMChild(aField.buf);
}
}
#endif