зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1167504 - Part 7: Remove BindableName - Buffer. r=jgilbert
This commit is contained in:
Родитель
88aef4ad04
Коммит
bdc3ac4601
|
@ -71,7 +71,7 @@ WebGL2Context::ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer,
|
|||
}
|
||||
|
||||
ErrorInvalidOperation("%s: buffer already bound to a incompatible target %s",
|
||||
info, EnumName(buffer->Target().get()));
|
||||
info, EnumName(buffer->Target()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ WebGL2Context::GetBufferSubData(GLenum target, GLintptr offset,
|
|||
{
|
||||
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.
|
||||
|
@ -168,7 +168,7 @@ WebGL2Context::GetBufferSubData(GLenum target, GLintptr offset,
|
|||
// 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.
|
||||
|
@ -179,7 +179,7 @@ WebGL2Context::GetBufferSubData(GLenum target, GLintptr offset,
|
|||
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();
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
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);
|
||||
|
@ -35,6 +36,18 @@ WebGLBuffer::Delete()
|
|||
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()
|
||||
{
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "WebGLBindableName.h"
|
||||
#include "WebGLObjectModel.h"
|
||||
#include "WebGLStrongTypes.h"
|
||||
#include "WebGLTypes.h"
|
||||
|
@ -21,7 +20,6 @@ class WebGLElementArrayCache;
|
|||
|
||||
class WebGLBuffer final
|
||||
: public nsWrapperCache
|
||||
, public WebGLBindableName<BufferBinding>
|
||||
, public WebGLRefCountedObject<WebGLBuffer>
|
||||
, public LinkedListElement<WebGLBuffer>
|
||||
, public WebGLContextBoundObject
|
||||
|
@ -41,6 +39,10 @@ public:
|
|||
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);
|
||||
|
||||
|
@ -52,13 +54,17 @@ public:
|
|||
|
||||
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;
|
||||
|
|
|
@ -600,7 +600,7 @@ WebGLContext::DoFakeVertexAttrib0(GLuint vertexCount)
|
|||
}
|
||||
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) {
|
||||
|
@ -626,7 +626,7 @@ WebGLContext::UndoFakeVertexAttrib0()
|
|||
|
||||
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,
|
||||
|
@ -645,7 +645,7 @@ WebGLContext::UndoFakeVertexAttrib0()
|
|||
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
|
||||
|
|
|
@ -24,21 +24,21 @@ 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
|
||||
|
|
|
@ -1127,12 +1127,12 @@ WebGLContext::AssertCachedBindings()
|
|||
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());
|
||||
|
|
Загрузка…
Ссылка в новой задаче