Bug 817186 - Split out WebGLUniformLocation into separate files

This commit is contained in:
Saurabh Anand 2012-12-07 13:44:43 +05:30
parent 63a06aaf89
commit 9031c9f696
3 changed files with 64 additions and 47 deletions

View File

@ -11,6 +11,7 @@
#include "WebGLShader.h" #include "WebGLShader.h"
#include "WebGLBuffer.h" #include "WebGLBuffer.h"
#include "WebGLProgram.h" #include "WebGLProgram.h"
#include "WebGLUniformLocation.h"
#include "WebGLRenderbuffer.h" #include "WebGLRenderbuffer.h"
#include "WebGLTexture.h" #include "WebGLTexture.h"
#include "WebGLVertexAttribData.h" #include "WebGLVertexAttribData.h"
@ -71,7 +72,6 @@ class nsIPropertyBag;
namespace mozilla { namespace mozilla {
class WebGLFramebuffer; class WebGLFramebuffer;
class WebGLUniformLocation;
class WebGLMemoryPressureObserver; class WebGLMemoryPressureObserver;
class WebGLContextBoundObject; class WebGLContextBoundObject;
class WebGLActiveInfo; class WebGLActiveInfo;
@ -1653,52 +1653,6 @@ public:
mDepthStencilAttachment; mDepthStencilAttachment;
}; };
class WebGLUniformLocation MOZ_FINAL
: public nsISupports
, public WebGLContextBoundObject
{
public:
WebGLUniformLocation(WebGLContext *context, WebGLProgram *program, GLint location, const WebGLUniformInfo& info)
: WebGLContextBoundObject(context)
, mProgram(program)
, mProgramGeneration(program->Generation())
, mLocation(location)
, mInfo(info)
{
mElementSize = info.ElementSize();
}
~WebGLUniformLocation() {
}
// needed for certain helper functions like ValidateObject.
// WebGLUniformLocation's can't be 'Deleted' in the WebGL sense.
bool IsDeleted() const { return false; }
const WebGLUniformInfo &Info() const { return mInfo; }
WebGLProgram *Program() const { return mProgram; }
GLint Location() const { return mLocation; }
uint32_t ProgramGeneration() const { return mProgramGeneration; }
int ElementSize() const { return mElementSize; }
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(WebGLUniformLocation)
protected:
// nsRefPtr, not WebGLRefPtr, so that we don't prevent the program from being explicitly deleted.
// we just want to avoid having a dangling pointer.
nsRefPtr<WebGLProgram> mProgram;
uint32_t mProgramGeneration;
GLint mLocation;
WebGLUniformInfo mInfo;
int mElementSize;
friend class WebGLProgram;
};
class WebGLActiveInfo MOZ_FINAL class WebGLActiveInfo MOZ_FINAL
: public nsISupports : public nsISupports
{ {

View File

@ -14,6 +14,16 @@ WebGLUniformLocation::WrapObject(JSContext *cx, JSObject *scope)
return dom::WebGLUniformLocationBinding::Wrap(cx, scope, this); return dom::WebGLUniformLocationBinding::Wrap(cx, scope, this);
} }
WebGLUniformLocation::WebGLUniformLocation(WebGLContext *context, WebGLProgram *program, GLint location, const WebGLUniformInfo& info)
: WebGLContextBoundObject(context)
, mProgram(program)
, mProgramGeneration(program->Generation())
, mLocation(location)
, mInfo(info)
{
mElementSize = info.ElementSize();
}
NS_IMPL_CYCLE_COLLECTION_CLASS(WebGLUniformLocation) NS_IMPL_CYCLE_COLLECTION_CLASS(WebGLUniformLocation)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebGLUniformLocation) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebGLUniformLocation)

View File

@ -0,0 +1,53 @@
/* -*- 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 WEBGLUNIFORMLOCATION_H_
#define WEBGLUNIFORMLOCATION_H_
#include "WebGLObjectModel.h"
namespace mozilla {
class WebGLUniformLocation MOZ_FINAL
: public nsISupports
, public WebGLContextBoundObject
{
public:
WebGLUniformLocation(WebGLContext *context, WebGLProgram *program, GLint location, const WebGLUniformInfo& info);
~WebGLUniformLocation() {
}
// needed for certain helper functions like ValidateObject.
// WebGLUniformLocation's can't be 'Deleted' in the WebGL sense.
bool IsDeleted() const { return false; }
const WebGLUniformInfo &Info() const { return mInfo; }
WebGLProgram *Program() const { return mProgram; }
GLint Location() const { return mLocation; }
uint32_t ProgramGeneration() const { return mProgramGeneration; }
int ElementSize() const { return mElementSize; }
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(WebGLUniformLocation)
protected:
// nsRefPtr, not WebGLRefPtr, so that we don't prevent the program from being explicitly deleted.
// we just want to avoid having a dangling pointer.
nsRefPtr<WebGLProgram> mProgram;
uint32_t mProgramGeneration;
GLint mLocation;
WebGLUniformInfo mInfo;
int mElementSize;
friend class WebGLProgram;
};
} // namespace mozilla
#endif