author | Dan Glastonbury <dglastonbury@mozilla.com> |
Mon, 17 Nov 2014 12:21:04 +1000 | |
changeset 240272 | f5f0ee65aa5bc03c2eac5007e60073674d246ed0 |
parent 240271 | 53ebcaa07a4bad42711a1853716dfdba0124198f |
child 240273 | 28be41369dfeacebb6d96b0c5254a5f839a781cc |
push id | 4311 |
push user | raliiev@mozilla.com |
push date | Mon, 12 Jan 2015 19:37:41 +0000 |
treeherder | mozilla-beta@150c9fed433b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jgilbert |
bugs | 1002281 |
milestone | 36.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/canvas/WebGLBindableName.h +++ b/dom/canvas/WebGLBindableName.h @@ -9,50 +9,62 @@ #include "WebGLTypes.h" #include "GLDefs.h" #include "mozilla/TypeTraits.h" #include "mozilla/Assertions.h" namespace mozilla { -/** Represents a GL name that can be bound to a target. +/** Represents a binding to a GL binding point */ template<typename T> -class WebGLBindableName +class WebGLBindable { public: + WebGLBindable() : mTarget(LOCAL_GL_NONE) { } + bool HasEverBeenBound() const { return mTarget != LOCAL_GL_NONE; } - WebGLBindableName() - : mGLName(0) - , mTarget(LOCAL_GL_NONE) - { } - - void BindTo(T target) - { + void BindTo(T target) { MOZ_ASSERT(target != LOCAL_GL_NONE, "Can't bind to GL_NONE."); MOZ_ASSERT(!HasEverBeenBound() || mTarget == target, "Rebinding is illegal."); bool targetChanged = (target != mTarget); mTarget = target; if (targetChanged) OnTargetChanged(); } - bool HasEverBeenBound() const { return mTarget != LOCAL_GL_NONE; } - GLuint GLName() const { return mGLName; } T Target() const { MOZ_ASSERT(HasEverBeenBound()); return mTarget; } protected: - //! Called after mTarget has been changed by BindTo(target). virtual void OnTargetChanged() {} - GLuint mGLName; T mTarget; }; + +/** Represents a GL name that can be bound to a target. + */ +template<typename T> +class WebGLBindableName + : public WebGLBindable<T> +{ +public: + + WebGLBindableName(GLuint name) + : WebGLBindable<T>() + , mGLName(name) + { } + GLuint GLName() const { return mGLName; } + +protected: + const GLuint mGLName; +}; + + } // namespace mozilla #endif // !WEBGLBINDABLENAME_H_
--- a/dom/canvas/WebGLBuffer.cpp +++ b/dom/canvas/WebGLBuffer.cpp @@ -7,23 +7,21 @@ #include "GLContext.h" #include "mozilla/dom/WebGLRenderingContextBinding.h" #include "WebGLContext.h" #include "WebGLElementArrayCache.h" using namespace mozilla; -WebGLBuffer::WebGLBuffer(WebGLContext *context) - : WebGLBindableName<BufferBinding>() +WebGLBuffer::WebGLBuffer(WebGLContext* context, GLuint buf) + : WebGLBindableName<BufferBinding>(buf) , WebGLContextBoundObject(context) , mByteLength(0) { - mContext->MakeContextCurrent(); - mContext->gl->fGenBuffers(1, &mGLName); mContext->mBuffers.insertBack(this); } WebGLBuffer::~WebGLBuffer() { DeleteOnce(); } void
--- a/dom/canvas/WebGLBuffer.h +++ b/dom/canvas/WebGLBuffer.h @@ -22,17 +22,17 @@ class WebGLElementArrayCache; class WebGLBuffer MOZ_FINAL : public nsWrapperCache , public WebGLBindableName<BufferBinding> , public WebGLRefCountedObject<WebGLBuffer> , public LinkedListElement<WebGLBuffer> , public WebGLContextBoundObject { public: - explicit WebGLBuffer(WebGLContext* aContext); + explicit WebGLBuffer(WebGLContext* context, GLuint buf); void Delete(); size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; WebGLsizeiptr ByteLength() const { return mByteLength; } void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; }
--- a/dom/canvas/WebGLContextBuffers.cpp +++ b/dom/canvas/WebGLContextBuffers.cpp @@ -356,17 +356,21 @@ WebGLContext::BufferSubData(GLenum targe } already_AddRefed<WebGLBuffer> WebGLContext::CreateBuffer() { if (IsContextLost()) return nullptr; - nsRefPtr<WebGLBuffer> globj = new WebGLBuffer(this); + GLuint buf = 0; + MakeContextCurrent(); + gl->fGenBuffers(1, &buf); + + nsRefPtr<WebGLBuffer> globj = new WebGLBuffer(this, buf); return globj.forget(); } void WebGLContext::DeleteBuffer(WebGLBuffer *buffer) { if (IsContextLost()) return;
--- a/dom/canvas/WebGLContextGL.cpp +++ b/dom/canvas/WebGLContextGL.cpp @@ -1367,17 +1367,22 @@ WebGLContext::GetRenderbufferParameter(G return JS::NullValue(); } already_AddRefed<WebGLTexture> WebGLContext::CreateTexture() { if (IsContextLost()) return nullptr; - nsRefPtr<WebGLTexture> globj = new WebGLTexture(this); + + GLuint tex = 0; + MakeContextCurrent(); + gl->fGenTextures(1, &tex); + + nsRefPtr<WebGLTexture> globj = new WebGLTexture(this, tex); return globj.forget(); } static GLenum GetAndClearError(GLenum* errorVar) { MOZ_ASSERT(errorVar); GLenum ret = *errorVar; @@ -3093,17 +3098,22 @@ WebGLContext::ValidateProgram(WebGLProgr gl->fValidateProgram(progname); } already_AddRefed<WebGLFramebuffer> WebGLContext::CreateFramebuffer() { if (IsContextLost()) return nullptr; - nsRefPtr<WebGLFramebuffer> globj = new WebGLFramebuffer(this); + + GLuint fbo = 0; + MakeContextCurrent(); + gl->fGenFramebuffers(1, &fbo); + + nsRefPtr<WebGLFramebuffer> globj = new WebGLFramebuffer(this, fbo); return globj.forget(); } already_AddRefed<WebGLRenderbuffer> WebGLContext::CreateRenderbuffer() { if (IsContextLost()) return nullptr;
--- a/dom/canvas/WebGLFramebuffer.cpp +++ b/dom/canvas/WebGLFramebuffer.cpp @@ -21,26 +21,24 @@ using namespace mozilla; using namespace mozilla::gl; JSObject* WebGLFramebuffer::WrapObject(JSContext* cx) { return dom::WebGLFramebufferBinding::Wrap(cx, this); } -WebGLFramebuffer::WebGLFramebuffer(WebGLContext* context) - : WebGLBindableName<FBTarget>() +WebGLFramebuffer::WebGLFramebuffer(WebGLContext* context, GLuint fbo) + : WebGLBindableName<FBTarget>(fbo) , WebGLContextBoundObject(context) , mStatus(0) , mDepthAttachment(LOCAL_GL_DEPTH_ATTACHMENT) , mStencilAttachment(LOCAL_GL_STENCIL_ATTACHMENT) , mDepthStencilAttachment(LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) { - mContext->MakeContextCurrent(); - mContext->gl->fGenFramebuffers(1, &mGLName); mContext->mFramebuffers.insertBack(this); mColorAttachments.SetLength(1); mColorAttachments[0].mAttachmentPoint = LOCAL_GL_COLOR_ATTACHMENT0; } WebGLFramebuffer::Attachment::Attachment(FBAttachment aAttachmentPoint) : mAttachmentPoint(aAttachmentPoint)
--- a/dom/canvas/WebGLFramebuffer.h +++ b/dom/canvas/WebGLFramebuffer.h @@ -29,17 +29,17 @@ class WebGLFramebuffer MOZ_FINAL , public WebGLRefCountedObject<WebGLFramebuffer> , public LinkedListElement<WebGLFramebuffer> , public WebGLContextBoundObject , public SupportsWeakPtr<WebGLFramebuffer> { public: MOZ_DECLARE_REFCOUNTED_TYPENAME(WebGLFramebuffer) - explicit WebGLFramebuffer(WebGLContext* context); + explicit WebGLFramebuffer(WebGLContext* context, GLuint fbo); struct Attachment { // deleting a texture or renderbuffer immediately detaches it WebGLRefPtr<WebGLTexture> mTexturePtr; WebGLRefPtr<WebGLRenderbuffer> mRenderbufferPtr; FBAttachment mAttachmentPoint; TexImageTarget mTexImageTarget;
--- a/dom/canvas/WebGLRenderbuffer.cpp +++ b/dom/canvas/WebGLRenderbuffer.cpp @@ -37,18 +37,18 @@ NeedsDepthStencilEmu(GLContext* gl, GLen return !SupportsDepthStencil(gl); } JSObject* WebGLRenderbuffer::WrapObject(JSContext *cx) { return dom::WebGLRenderbufferBinding::Wrap(cx, this); } -WebGLRenderbuffer::WebGLRenderbuffer(WebGLContext *context) - : WebGLBindableName<RBTarget>() +WebGLRenderbuffer::WebGLRenderbuffer(WebGLContext* context) + : WebGLBindable<RBTarget>() , WebGLContextBoundObject(context) , mPrimaryRB(0) , mSecondaryRB(0) , mInternalFormat(0) , mInternalFormatForGL(0) , mImageDataStatus(WebGLImageDataStatus::NoImageData) { mContext->MakeContextCurrent();
--- a/dom/canvas/WebGLRenderbuffer.h +++ b/dom/canvas/WebGLRenderbuffer.h @@ -13,17 +13,17 @@ #include "nsWrapperCache.h" #include "mozilla/LinkedList.h" namespace mozilla { class WebGLRenderbuffer MOZ_FINAL : public nsWrapperCache - , public WebGLBindableName<RBTarget> + , public WebGLBindable<RBTarget> , public WebGLRefCountedObject<WebGLRenderbuffer> , public LinkedListElement<WebGLRenderbuffer> , public WebGLRectangleObject , public WebGLContextBoundObject , public WebGLFramebufferAttachable { public: explicit WebGLRenderbuffer(WebGLContext* context);
--- a/dom/canvas/WebGLSampler.cpp +++ b/dom/canvas/WebGLSampler.cpp @@ -8,17 +8,18 @@ #include "GLContext.h" #include "mozilla/dom/WebGL2RenderingContextBinding.h" using namespace mozilla; WebGLSampler::WebGLSampler(WebGLContext* context) - : WebGLContextBoundObject(context) + : WebGLBindableName<GLenum>(0), + WebGLContextBoundObject(context) { MOZ_CRASH("Not Implemented."); } WebGLSampler::~WebGLSampler() {} void
--- a/dom/canvas/WebGLSampler.h +++ b/dom/canvas/WebGLSampler.h @@ -11,18 +11,18 @@ #include "nsWrapperCache.h" #include "mozilla/LinkedList.h" namespace mozilla { class WebGLSampler MOZ_FINAL - : public WebGLBindableName<GLenum> - , public nsWrapperCache + : public nsWrapperCache + , public WebGLBindableName<GLenum> , public WebGLRefCountedObject<WebGLSampler> , public LinkedListElement<WebGLSampler> , public WebGLContextBoundObject { friend class WebGLContext2; public:
--- a/dom/canvas/WebGLTexture.cpp +++ b/dom/canvas/WebGLTexture.cpp @@ -14,37 +14,35 @@ #include "WebGLTexelConversions.h" #include <algorithm> #include "mozilla/MathAlgorithms.h" using namespace mozilla; JSObject* -WebGLTexture::WrapObject(JSContext *cx) { +WebGLTexture::WrapObject(JSContext* cx) { return dom::WebGLTextureBinding::Wrap(cx, this); } -WebGLTexture::WebGLTexture(WebGLContext *context) - : WebGLBindableName<TexTarget>() +WebGLTexture::WebGLTexture(WebGLContext* context, GLuint tex) + : WebGLBindableName<TexTarget>(tex) , WebGLContextBoundObject(context) , mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR) , mMagFilter(LOCAL_GL_LINEAR) , mWrapS(LOCAL_GL_REPEAT) , mWrapT(LOCAL_GL_REPEAT) , mFacesCount(0) , mMaxLevelWithCustomImages(0) , mHaveGeneratedMipmap(false) , mImmutable(false) , mBaseMipmapLevel(0) , mMaxMipmapLevel(1000) , mFakeBlackStatus(WebGLTextureFakeBlackStatus::IncompleteTexture) { - mContext->MakeContextCurrent(); - mContext->gl->fGenTextures(1, &mGLName); mContext->mTextures.insertBack(this); } void WebGLTexture::Delete() { mImageInfos.Clear(); mContext->MakeContextCurrent(); mContext->gl->fDeleteTextures(1, &mGLName);
--- a/dom/canvas/WebGLTexture.h +++ b/dom/canvas/WebGLTexture.h @@ -33,17 +33,17 @@ class WebGLTexture MOZ_FINAL : public nsWrapperCache , public WebGLBindableName<TexTarget> , public WebGLRefCountedObject<WebGLTexture> , public LinkedListElement<WebGLTexture> , public WebGLContextBoundObject , public WebGLFramebufferAttachable { public: - explicit WebGLTexture(WebGLContext* aContext); + explicit WebGLTexture(WebGLContext* aContext, GLuint tex); void Delete(); WebGLContext *GetParentObject() const { return Context(); } virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
--- a/dom/canvas/WebGLTransformFeedback.cpp +++ b/dom/canvas/WebGLTransformFeedback.cpp @@ -8,17 +8,18 @@ #include "GLContext.h" #include "mozilla/dom/WebGL2RenderingContextBinding.h" using namespace mozilla; WebGLTransformFeedback::WebGLTransformFeedback(WebGLContext* context) - : WebGLContextBoundObject(context) + : WebGLBindableName<GLenum>(0) + , WebGLContextBoundObject(context) { MOZ_CRASH("Not Implemented."); } WebGLTransformFeedback::~WebGLTransformFeedback() {} void
--- a/dom/canvas/WebGLTransformFeedback.h +++ b/dom/canvas/WebGLTransformFeedback.h @@ -11,18 +11,18 @@ #include "nsWrapperCache.h" #include "mozilla/LinkedList.h" namespace mozilla { class WebGLTransformFeedback MOZ_FINAL - : public WebGLBindableName<GLenum> - , public nsWrapperCache + : public nsWrapperCache + , public WebGLBindableName<GLenum> , public WebGLRefCountedObject<WebGLTransformFeedback> , public LinkedListElement<WebGLTransformFeedback> , public WebGLContextBoundObject { friend class WebGLContext; public:
--- a/dom/canvas/WebGLVertexArray.cpp +++ b/dom/canvas/WebGLVertexArray.cpp @@ -15,18 +15,19 @@ using namespace mozilla; JSObject* WebGLVertexArray::WrapObject(JSContext *cx) { return dom::WebGLVertexArrayBinding::Wrap(cx, this); } WebGLVertexArray::WebGLVertexArray(WebGLContext* context) - : WebGLBindableName<VAOBinding>() + : WebGLBindable<VAOBinding>() , WebGLContextBoundObject(context) + , mGLName(0) { context->mVertexArrays.insertBack(this); } WebGLVertexArray* WebGLVertexArray::Create(WebGLContext* context) { WebGLVertexArray* array;
--- a/dom/canvas/WebGLVertexArray.h +++ b/dom/canvas/WebGLVertexArray.h @@ -17,17 +17,17 @@ #include "mozilla/LinkedList.h" namespace mozilla { class WebGLVertexArrayFake; class WebGLVertexArray : public nsWrapperCache - , public WebGLBindableName<VAOBinding> + , public WebGLBindable<VAOBinding> , public WebGLRefCountedObject<WebGLVertexArray> , public LinkedListElement<WebGLVertexArray> , public WebGLContextBoundObject { // ----------------------------------------------------------------------------- // PUBLIC public: static WebGLVertexArray* Create(WebGLContext* context); @@ -56,16 +56,18 @@ public: virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray) // ------------------------------------------------------------------------- // MEMBER FUNCTIONS + GLuint GLName() const { return mGLName; } + void EnsureAttrib(GLuint index); bool HasAttrib(GLuint index) { return index < mAttribs.Length(); } bool IsAttribArrayEnabled(GLuint index) { return HasAttrib(index) && mAttribs[index].enabled; } @@ -77,16 +79,17 @@ protected: virtual ~WebGLVertexArray() { MOZ_ASSERT(IsDeleted()); }; // ------------------------------------------------------------------------- // MEMBERS + GLuint mGLName; nsTArray<WebGLVertexAttribData> mAttribs; WebGLRefPtr<WebGLBuffer> mElementArrayBuffer; // ------------------------------------------------------------------------- // FRIENDSHIPS friend class WebGLVertexArrayFake; friend class WebGLContext;