author | Dan Glastonbury <dglastonbury@mozilla.com> |
Fri, 22 May 2015 15:49:30 +1000 | |
changeset 247875 | d71cc076307e8373ba134e871b098e04fc979a0f |
parent 247874 | 3b85d8441047756a0ce439ab50f8671c6e851318 |
child 247876 | 5756b0cdb987f4f56e6d3d2b69ad6f2716780a5c |
push id | 28885 |
push user | cbook@mozilla.com |
push date | Wed, 10 Jun 2015 13:18:59 +0000 |
treeherder | autoland@e101c589c242 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jgilbert |
bugs | 1167504 |
milestone | 41.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/WebGL2ContextBuffers.cpp +++ b/dom/canvas/WebGL2ContextBuffers.cpp @@ -66,17 +66,17 @@ WebGL2Context::ValidateBufferForTarget(G case LOCAL_GL_PIXEL_UNPACK_BUFFER: case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER: case LOCAL_GL_UNIFORM_BUFFER: return !buffer->HasEverBeenBound() || buffer->Target() != LOCAL_GL_ELEMENT_ARRAY_BUFFER; } ErrorInvalidOperation("%s: buffer already bound to a incompatible target %s", - info, EnumName(buffer->Target().get())); + info, EnumName(buffer->Target())); return false; } bool WebGL2Context::ValidateBufferUsageEnum(GLenum usage, const char* info) { switch (usage) { case LOCAL_GL_DYNAMIC_COPY: @@ -150,41 +150,41 @@ WebGL2Context::CopyBufferSubData(GLenum } void WebGL2Context::GetBufferSubData(GLenum target, GLintptr offset, const dom::Nullable<dom::ArrayBuffer>& maybeData) { if (IsContextLost()) return; - + // For the WebGLBuffer bound to the passed target, read // returnedData.byteLength bytes from the buffer starting at byte // offset offset and write them to returnedData. // If zero is bound to target, an INVALID_OPERATION error is // generated. if (!ValidateBufferTarget(target, "getBufferSubData")) return; // If offset is less than zero, an INVALID_VALUE error is // generated. if (offset < 0) - return ErrorInvalidValue("getBufferSubData: negative offset"); + return ErrorInvalidValue("getBufferSubData: negative offset"); // If returnedData is null then an INVALID_VALUE error is // generated. if (maybeData.IsNull()) return ErrorInvalidValue("getBufferSubData: returnedData is null"); WebGLRefPtr<WebGLBuffer>& bufferSlot = GetBufferSlotByTarget(target); WebGLBuffer* boundBuffer = bufferSlot.get(); if (!boundBuffer) return ErrorInvalidOperation("getBufferSubData: no buffer bound"); - + // If offset + returnedData.byteLength would extend beyond the end // of the buffer an INVALID_VALUE error is generated. const dom::ArrayBuffer& data = maybeData.Value(); data.ComputeLengthAndData(); CheckedInt<WebGLsizeiptr> neededByteLength = CheckedInt<WebGLsizeiptr>(offset) + data.Length(); if (!neededByteLength.isValid()) { ErrorInvalidValue("getBufferSubData: Integer overflow computing the needed"
--- a/dom/canvas/WebGLBuffer.cpp +++ b/dom/canvas/WebGLBuffer.cpp @@ -8,18 +8,19 @@ #include "GLContext.h" #include "mozilla/dom/WebGLRenderingContextBinding.h" #include "WebGLContext.h" #include "WebGLElementArrayCache.h" namespace mozilla { WebGLBuffer::WebGLBuffer(WebGLContext* webgl, GLuint buf) - : WebGLBindableName<BufferBinding>(buf) - , WebGLContextBoundObject(webgl) + : WebGLContextBoundObject(webgl) + , mGLName(buf) + , mTarget(LOCAL_GL_NONE) , mByteLength(0) { mContext->mBuffers.insertBack(this); } WebGLBuffer::~WebGLBuffer() { DeleteOnce(); @@ -31,16 +32,28 @@ WebGLBuffer::Delete() mContext->MakeContextCurrent(); mContext->gl->fDeleteBuffers(1, &mGLName); mByteLength = 0; mCache = nullptr; LinkedListElement<WebGLBuffer>::remove(); // remove from mContext->mBuffers } void +WebGLBuffer::BindTo(GLenum 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(); +} + +void WebGLBuffer::OnTargetChanged() { if (!mCache && mTarget == LOCAL_GL_ELEMENT_ARRAY_BUFFER) mCache = new WebGLElementArrayCache; } bool WebGLBuffer::ElementArrayCacheBufferData(const void* ptr,
--- a/dom/canvas/WebGLBuffer.h +++ b/dom/canvas/WebGLBuffer.h @@ -5,28 +5,26 @@ #ifndef WEBGL_BUFFER_H_ #define WEBGL_BUFFER_H_ #include "GLDefs.h" #include "mozilla/LinkedList.h" #include "mozilla/MemoryReporting.h" #include "nsWrapperCache.h" -#include "WebGLBindableName.h" #include "WebGLObjectModel.h" #include "WebGLStrongTypes.h" #include "WebGLTypes.h" namespace mozilla { class WebGLElementArrayCache; class WebGLBuffer final : public nsWrapperCache - , public WebGLBindableName<BufferBinding> , public WebGLRefCountedObject<WebGLBuffer> , public LinkedListElement<WebGLBuffer> , public WebGLContextBoundObject { public: explicit WebGLBuffer(WebGLContext* webgl, GLuint buf); void Delete(); @@ -36,34 +34,42 @@ public: WebGLsizeiptr ByteLength() const { return mByteLength; } void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; } bool ElementArrayCacheBufferData(const void* ptr, size_t bufferSizeInBytes); void ElementArrayCacheBufferSubData(size_t pos, const void* ptr, size_t updateSizeInBytes); + void BindTo(GLenum target); + bool HasEverBeenBound() const { return mTarget != LOCAL_GL_NONE; } + GLenum Target() const { return mTarget; } + bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count, uint32_t* const out_upperBound); bool IsElementArrayUsedWithMultipleTypes() const; WebGLContext* GetParentObject() const { return Context(); } virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override; + const GLenum mGLName; + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLBuffer) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer) protected: ~WebGLBuffer(); - virtual void OnTargetChanged() override; + void OnTargetChanged(); + + GLenum mTarget; WebGLsizeiptr mByteLength; nsAutoPtr<WebGLElementArrayCache> mCache; }; } // namespace mozilla #endif // WEBGL_BUFFER_H_
--- a/dom/canvas/WebGLContextDraw.cpp +++ b/dom/canvas/WebGLContextDraw.cpp @@ -595,17 +595,17 @@ WebGLContext::DoFakeVertexAttrib0(GLuint array[4 * i + 3] = mVertexAttrib0Vector[3]; } gl->fBufferData(LOCAL_GL_ARRAY_BUFFER, dataSize, array.get(), LOCAL_GL_DYNAMIC_DRAW); } else { gl->fBufferData(LOCAL_GL_ARRAY_BUFFER, dataSize, nullptr, LOCAL_GL_DYNAMIC_DRAW); } GLenum error = GetAndFlushUnderlyingGLErrors(); - gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mBoundArrayBuffer ? mBoundArrayBuffer->GLName() : 0); + gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mBoundArrayBuffer ? mBoundArrayBuffer->mGLName : 0); // note that we do this error checking and early return AFTER having restored the buffer binding above if (error) { ErrorOutOfMemory("Ran out of memory trying to construct a fake vertex attrib 0 array for a draw-operation " "with %d vertices. Try reducing the number of vertices.", vertexCount); return false; } } @@ -621,17 +621,17 @@ WebGLContext::UndoFakeVertexAttrib0() { WebGLVertexAttrib0Status whatDoesAttrib0Need = WhatDoesVertexAttrib0Need(); if (MOZ_LIKELY(whatDoesAttrib0Need == WebGLVertexAttrib0Status::Default)) return; if (mBoundVertexArray->HasAttrib(0) && mBoundVertexArray->mAttribs[0].buf) { const WebGLVertexAttribData& attrib0 = mBoundVertexArray->mAttribs[0]; - gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, attrib0.buf->GLName()); + gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, attrib0.buf->mGLName); if (attrib0.integer) { gl->fVertexAttribIPointer(0, attrib0.size, attrib0.type, attrib0.stride, reinterpret_cast<const GLvoid*>(attrib0.byteOffset)); } else { gl->fVertexAttribPointer(0, @@ -640,17 +640,17 @@ WebGLContext::UndoFakeVertexAttrib0() attrib0.normalized, attrib0.stride, reinterpret_cast<const GLvoid*>(attrib0.byteOffset)); } } else { gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0); } - gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mBoundArrayBuffer ? mBoundArrayBuffer->GLName() : 0); + gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mBoundArrayBuffer ? mBoundArrayBuffer->mGLName : 0); } WebGLContextFakeBlackStatus WebGLContext::ResolvedFakeBlackStatus() { // handle this case first, it's the generic case if (MOZ_LIKELY(mFakeBlackStatus == WebGLContextFakeBlackStatus::NotNeeded)) return mFakeBlackStatus;
--- a/dom/canvas/WebGLContextUnchecked.cpp +++ b/dom/canvas/WebGLContextUnchecked.cpp @@ -19,31 +19,31 @@ WebGLContextUnchecked::WebGLContextUnche // ----------------------------------------------------------------------------- // Buffer Objects void WebGLContextUnchecked::BindBuffer(GLenum target, WebGLBuffer* buffer) { gl->MakeCurrent(); - gl->fBindBuffer(target, buffer ? buffer->GLName() : 0); + gl->fBindBuffer(target, buffer ? buffer->mGLName : 0); } void WebGLContextUnchecked::BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer) { gl->MakeCurrent(); - gl->fBindBufferBase(target, index, buffer ? buffer->GLName() : 0); + gl->fBindBufferBase(target, index, buffer ? buffer->mGLName : 0); } void WebGLContextUnchecked::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer, WebGLintptr offset, WebGLsizeiptr size) { gl->MakeCurrent(); - gl->fBindBufferRange(target, index, buffer ? buffer->GLName() : 0, offset, size); + gl->fBindBufferRange(target, index, buffer ? buffer->mGLName : 0, offset, size); } void WebGLContextUnchecked::CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { gl->MakeCurrent(); gl->fCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size); }
--- a/dom/canvas/WebGLContextUtils.cpp +++ b/dom/canvas/WebGLContextUtils.cpp @@ -1122,22 +1122,22 @@ WebGLContext::AssertCachedBindings() bound = curTex ? curTex->mGLName : 0; AssertUintParamCorrect(gl, LOCAL_GL_TEXTURE_BINDING_2D, bound); curTex = ActiveBoundTextureForTarget(LOCAL_GL_TEXTURE_CUBE_MAP); bound = curTex ? curTex->mGLName : 0; AssertUintParamCorrect(gl, LOCAL_GL_TEXTURE_BINDING_CUBE_MAP, bound); // Buffers - bound = mBoundArrayBuffer ? mBoundArrayBuffer->GLName() : 0; + bound = mBoundArrayBuffer ? mBoundArrayBuffer->mGLName : 0; AssertUintParamCorrect(gl, LOCAL_GL_ARRAY_BUFFER_BINDING, bound); MOZ_ASSERT(mBoundVertexArray); WebGLBuffer* curBuff = mBoundVertexArray->mElementArrayBuffer; - bound = curBuff ? curBuff->GLName() : 0; + bound = curBuff ? curBuff->mGLName : 0; AssertUintParamCorrect(gl, LOCAL_GL_ELEMENT_ARRAY_BUFFER_BINDING, bound); MOZ_ASSERT(!GetAndFlushUnderlyingGLErrors()); #endif } void WebGLContext::AssertCachedState()