Bug 632546 - pass is-object test - r=vlad, a=jrmuizel

This commit is contained in:
Benoit Jacob 2011-02-11 18:11:30 -05:00
Родитель 236b2c1826
Коммит e960d744fa
5 изменённых файлов: 55 добавлений и 44 удалений

Просмотреть файл

@ -666,7 +666,7 @@ public:
WebGLBuffer(WebGLContext *context, WebGLuint name) : WebGLBuffer(WebGLContext *context, WebGLuint name) :
WebGLContextBoundObject(context), WebGLContextBoundObject(context),
mName(name), mDeleted(PR_FALSE), mName(name), mDeleted(PR_FALSE), mHasEverBeenBound(PR_FALSE),
mByteLength(0), mTarget(LOCAL_GL_NONE), mData(nsnull) mByteLength(0), mTarget(LOCAL_GL_NONE), mData(nsnull)
{ } { }
@ -687,6 +687,8 @@ public:
} }
PRBool Deleted() const { return mDeleted; } PRBool Deleted() const { return mDeleted; }
PRBool HasEverBeenBound() { return mHasEverBeenBound; }
void SetHasEverBeenBound(PRBool x) { mHasEverBeenBound = x; }
GLuint GLName() const { return mName; } GLuint GLName() const { return mName; }
GLuint ByteLength() const { return mByteLength; } GLuint ByteLength() const { return mByteLength; }
GLenum Target() const { return mTarget; } GLenum Target() const { return mTarget; }
@ -764,6 +766,7 @@ public:
protected: protected:
WebGLuint mName; WebGLuint mName;
PRBool mDeleted; PRBool mDeleted;
PRBool mHasEverBeenBound;
GLuint mByteLength; GLuint mByteLength;
GLenum mTarget; GLenum mTarget;
@ -771,7 +774,7 @@ protected:
PRBool mHasCachedMaxUbyteElement; PRBool mHasCachedMaxUbyteElement;
PRUint16 mCachedMaxUshortElement; PRUint16 mCachedMaxUshortElement;
PRBool mHasCachedMaxUshortElement; PRBool mHasCachedMaxUshortElement;
void* mData; // in the case of an Element Array Buffer, we keep a copy. void* mData; // in the case of an Element Array Buffer, we keep a copy.
}; };
@ -790,7 +793,7 @@ public:
WebGLTexture(WebGLContext *context, WebGLuint name) : WebGLTexture(WebGLContext *context, WebGLuint name) :
WebGLContextBoundObject(context), WebGLContextBoundObject(context),
mDeleted(PR_FALSE), mName(name), mDeleted(PR_FALSE), mHasEverBeenBound(PR_FALSE), mName(name),
mTarget(0), mTarget(0),
mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR), mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR),
mMagFilter(LOCAL_GL_LINEAR), mMagFilter(LOCAL_GL_LINEAR),
@ -811,6 +814,8 @@ public:
} }
PRBool Deleted() { return mDeleted; } PRBool Deleted() { return mDeleted; }
PRBool HasEverBeenBound() { return mHasEverBeenBound; }
void SetHasEverBeenBound(PRBool x) { mHasEverBeenBound = x; }
WebGLuint GLName() { return mName; } WebGLuint GLName() { return mName; }
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@ -821,6 +826,7 @@ protected:
friend class WebGLFramebuffer; friend class WebGLFramebuffer;
PRBool mDeleted; PRBool mDeleted;
PRBool mHasEverBeenBound;
WebGLuint mName; WebGLuint mName;
// we store information about the various images that are part of // we store information about the various images that are part of
@ -925,7 +931,7 @@ public:
// this function should only be called by bindTexture(). // this function should only be called by bindTexture().
// it assumes that the GL context is already current. // it assumes that the GL context is already current.
PRBool firstTimeThisTextureIsBound = mTarget == 0; PRBool firstTimeThisTextureIsBound = !mHasEverBeenBound;
if (!firstTimeThisTextureIsBound && aTarget != mTarget) { if (!firstTimeThisTextureIsBound && aTarget != mTarget) {
mContext->ErrorInvalidOperation("bindTexture: this texture has already been bound to a different target"); mContext->ErrorInvalidOperation("bindTexture: this texture has already been bound to a different target");
@ -949,6 +955,8 @@ public:
if (mTarget == LOCAL_GL_TEXTURE_CUBE_MAP && !mContext->gl->IsGLES2()) if (mTarget == LOCAL_GL_TEXTURE_CUBE_MAP && !mContext->gl->IsGLES2())
mContext->gl->fTexParameteri(mTarget, LOCAL_GL_TEXTURE_WRAP_R, LOCAL_GL_CLAMP_TO_EDGE); mContext->gl->fTexParameteri(mTarget, LOCAL_GL_TEXTURE_WRAP_R, LOCAL_GL_CLAMP_TO_EDGE);
} }
mHasEverBeenBound = PR_TRUE;
} }
void SetImageInfo(WebGLenum aTarget, WebGLint aLevel, void SetImageInfo(WebGLenum aTarget, WebGLint aLevel,
@ -1385,7 +1393,7 @@ public:
WebGLContextBoundObject(context), WebGLContextBoundObject(context),
mName(name), mName(name),
mInternalFormat(0), mInternalFormat(0),
mDeleted(PR_FALSE), mInitialized(PR_FALSE) mDeleted(PR_FALSE), mHasEverBeenBound(PR_FALSE), mInitialized(PR_FALSE)
{ } { }
void Delete() { void Delete() {
@ -1395,6 +1403,8 @@ public:
mDeleted = PR_TRUE; mDeleted = PR_TRUE;
} }
PRBool Deleted() const { return mDeleted; } PRBool Deleted() const { return mDeleted; }
PRBool HasEverBeenBound() { return mHasEverBeenBound; }
void SetHasEverBeenBound(PRBool x) { mHasEverBeenBound = x; }
WebGLuint GLName() const { return mName; } WebGLuint GLName() const { return mName; }
PRBool Initialized() const { return mInitialized; } PRBool Initialized() const { return mInitialized; }
@ -1411,6 +1421,7 @@ protected:
WebGLenum mInternalFormat; WebGLenum mInternalFormat;
PRBool mDeleted; PRBool mDeleted;
PRBool mHasEverBeenBound;
PRBool mInitialized; PRBool mInitialized;
friend class WebGLFramebuffer; friend class WebGLFramebuffer;
@ -1515,7 +1526,7 @@ public:
WebGLFramebuffer(WebGLContext *context, WebGLuint name) : WebGLFramebuffer(WebGLContext *context, WebGLuint name) :
WebGLContextBoundObject(context), WebGLContextBoundObject(context),
mName(name), mDeleted(PR_FALSE), mName(name), mDeleted(PR_FALSE), mHasEverBeenBound(PR_FALSE),
mColorAttachment(LOCAL_GL_COLOR_ATTACHMENT0), mColorAttachment(LOCAL_GL_COLOR_ATTACHMENT0),
mDepthAttachment(LOCAL_GL_DEPTH_ATTACHMENT), mDepthAttachment(LOCAL_GL_DEPTH_ATTACHMENT),
mStencilAttachment(LOCAL_GL_STENCIL_ATTACHMENT), mStencilAttachment(LOCAL_GL_STENCIL_ATTACHMENT),
@ -1529,6 +1540,8 @@ public:
mDeleted = PR_TRUE; mDeleted = PR_TRUE;
} }
PRBool Deleted() { return mDeleted; } PRBool Deleted() { return mDeleted; }
PRBool HasEverBeenBound() { return mHasEverBeenBound; }
void SetHasEverBeenBound(PRBool x) { mHasEverBeenBound = x; }
WebGLuint GLName() { return mName; } WebGLuint GLName() { return mName; }
nsresult FramebufferRenderbuffer(WebGLenum target, nsresult FramebufferRenderbuffer(WebGLenum target,
@ -1819,6 +1832,7 @@ protected:
WebGLuint mName; WebGLuint mName;
PRPackedBool mDeleted; PRPackedBool mDeleted;
PRBool mHasEverBeenBound;
// we only store pointers to attached renderbuffers, not to attached textures, because // we only store pointers to attached renderbuffers, not to attached textures, because
// we will only need to initialize renderbuffers. Textures are already initialized. // we will only need to initialize renderbuffers. Textures are already initialized.

Просмотреть файл

@ -211,6 +211,7 @@ WebGLContext::BindBuffer(WebGLenum target, nsIWebGLBuffer *bobj)
if ((buf->Target() != LOCAL_GL_NONE) && (target != buf->Target())) if ((buf->Target() != LOCAL_GL_NONE) && (target != buf->Target()))
return ErrorInvalidOperation("BindBuffer: buffer already bound to a different target"); return ErrorInvalidOperation("BindBuffer: buffer already bound to a different target");
buf->SetTarget(target); buf->SetTarget(target);
buf->SetHasEverBeenBound(PR_TRUE);
} }
MakeContextCurrent(); MakeContextCurrent();
@ -239,6 +240,7 @@ WebGLContext::BindFramebuffer(WebGLenum target, nsIWebGLFramebuffer *fbobj)
gl->fBindFramebuffer(target, gl->GetOffscreenFBO()); gl->fBindFramebuffer(target, gl->GetOffscreenFBO());
} else { } else {
gl->fBindFramebuffer(target, framebuffername); gl->fBindFramebuffer(target, framebuffername);
wfb->SetHasEverBeenBound(PR_TRUE);
} }
mBoundFramebuffer = wfb; mBoundFramebuffer = wfb;
@ -259,6 +261,9 @@ WebGLContext::BindRenderbuffer(WebGLenum target, nsIWebGLRenderbuffer *rbobj)
if (!GetConcreteObjectAndGLName("bindRenderBuffer", rbobj, &wrb, &renderbuffername, &isNull)) if (!GetConcreteObjectAndGLName("bindRenderBuffer", rbobj, &wrb, &renderbuffername, &isNull))
return NS_OK; return NS_OK;
if (!isNull)
wrb->SetHasEverBeenBound(PR_TRUE);
MakeContextCurrent(); MakeContextCurrent();
gl->fBindRenderbuffer(target, renderbuffername); gl->fBindRenderbuffer(target, renderbuffername);
@ -2535,11 +2540,14 @@ NS_IMETHODIMP
WebGLContext::IsBuffer(nsIWebGLBuffer *bobj, WebGLboolean *retval) WebGLContext::IsBuffer(nsIWebGLBuffer *bobj, WebGLboolean *retval)
{ {
PRBool isDeleted; PRBool isDeleted;
WebGLuint obj; WebGLuint buffername;
PRBool ok = GetGLName<WebGLBuffer>("isBuffer", bobj, &obj, 0, &isDeleted) && !isDeleted; WebGLBuffer *buffer;
PRBool ok = GetConcreteObjectAndGLName("isBuffer", bobj, &buffer, &buffername, nsnull, &isDeleted) &&
!isDeleted &&
buffer->HasEverBeenBound();
if (ok) { if (ok) {
MakeContextCurrent(); MakeContextCurrent();
ok = gl->fIsBuffer(obj); ok = gl->fIsBuffer(buffername);
} }
*retval = ok; *retval = ok;
@ -2550,11 +2558,14 @@ NS_IMETHODIMP
WebGLContext::IsFramebuffer(nsIWebGLFramebuffer *fbobj, WebGLboolean *retval) WebGLContext::IsFramebuffer(nsIWebGLFramebuffer *fbobj, WebGLboolean *retval)
{ {
PRBool isDeleted; PRBool isDeleted;
WebGLuint obj; WebGLuint fbname;
PRBool ok = GetGLName<WebGLFramebuffer>("isFramebuffer", fbobj, &obj, 0, &isDeleted) && !isDeleted; WebGLFramebuffer *fb;
PRBool ok = GetConcreteObjectAndGLName("isFramebuffer", fbobj, &fb, &fbname, nsnull, &isDeleted) &&
!isDeleted &&
fb->HasEverBeenBound();
if (ok) { if (ok) {
MakeContextCurrent(); MakeContextCurrent();
ok = gl->fIsFramebuffer(obj); ok = gl->fIsFramebuffer(fbname);
} }
*retval = ok; *retval = ok;
@ -2566,18 +2577,10 @@ WebGLContext::IsProgram(nsIWebGLProgram *pobj, WebGLboolean *retval)
{ {
PRBool isDeleted; PRBool isDeleted;
WebGLProgram *prog = nsnull; WebGLProgram *prog = nsnull;
PRBool ok = GetConcreteObject("isProgram", pobj, &prog, 0, &isDeleted, PR_FALSE); PRBool ok = GetConcreteObject("isProgram", pobj, &prog, nsnull, &isDeleted, PR_FALSE) &&
if (!ok) { !isDeleted;
*retval = PR_FALSE;
return NS_OK;
}
if (isDeleted) {
*retval = PR_FALSE;
} else {
*retval = PR_TRUE;
}
*retval = ok;
return NS_OK; return NS_OK;
} }
@ -2585,11 +2588,14 @@ NS_IMETHODIMP
WebGLContext::IsRenderbuffer(nsIWebGLRenderbuffer *rbobj, WebGLboolean *retval) WebGLContext::IsRenderbuffer(nsIWebGLRenderbuffer *rbobj, WebGLboolean *retval)
{ {
PRBool isDeleted; PRBool isDeleted;
WebGLuint obj; WebGLuint rbname;
PRBool ok = GetGLName<WebGLRenderbuffer>("isRenderBuffer", rbobj, &obj, 0, &isDeleted) && !isDeleted; WebGLRenderbuffer *rb;
PRBool ok = GetConcreteObjectAndGLName("isRenderBuffer", rbobj, &rb, &rbname, nsnull, &isDeleted) &&
!isDeleted &&
rb->HasEverBeenBound();
if (ok) { if (ok) {
MakeContextCurrent(); MakeContextCurrent();
ok = gl->fIsRenderbuffer(obj); ok = gl->fIsRenderbuffer(rbname);
} }
*retval = ok; *retval = ok;
@ -2601,18 +2607,10 @@ WebGLContext::IsShader(nsIWebGLShader *sobj, WebGLboolean *retval)
{ {
PRBool isDeleted; PRBool isDeleted;
WebGLShader *shader = nsnull; WebGLShader *shader = nsnull;
PRBool ok = GetConcreteObject("isShader", sobj, &shader, 0, &isDeleted, PR_FALSE); PRBool ok = GetConcreteObject("isShader", sobj, &shader, nsnull, &isDeleted, PR_FALSE) &&
if (!ok) { !isDeleted;
*retval = PR_FALSE;
return NS_OK;
}
if (isDeleted) {
*retval = PR_FALSE;
} else {
*retval = PR_TRUE;
}
*retval = ok;
return NS_OK; return NS_OK;
} }
@ -2620,11 +2618,14 @@ NS_IMETHODIMP
WebGLContext::IsTexture(nsIWebGLTexture *tobj, WebGLboolean *retval) WebGLContext::IsTexture(nsIWebGLTexture *tobj, WebGLboolean *retval)
{ {
PRBool isDeleted; PRBool isDeleted;
WebGLuint obj; WebGLuint texname;
PRBool ok = GetGLName<WebGLTexture>("isTexture", tobj, &obj, 0, &isDeleted) && !isDeleted; WebGLTexture *tex;
PRBool ok = GetConcreteObjectAndGLName("isTexture", tobj, &tex, &texname, nsnull, &isDeleted) &&
!isDeleted &&
tex->HasEverBeenBound();
if (ok) { if (ok) {
MakeContextCurrent(); MakeContextCurrent();
ok = gl->fIsTexture(obj); ok = gl->fIsTexture(texname);
} }
*retval = ok; *retval = ok;

Просмотреть файл

@ -1,9 +1,7 @@
conformance/context-attributes.html conformance/context-attributes.html
conformance/gl-enum-tests.html conformance/gl-enum-tests.html
conformance/gl-get-active-attribute.html conformance/gl-get-active-attribute.html
conformance/gl-get-calls.html
conformance/gl-uniform-bool.html conformance/gl-uniform-bool.html
conformance/gl-vertexattribpointer.html conformance/gl-vertexattribpointer.html
conformance/glsl-2types-of-textures-on-same-unit.html conformance/glsl-2types-of-textures-on-same-unit.html
conformance/is-object.html
conformance/uninitialized-test.html conformance/uninitialized-test.html

Просмотреть файл

@ -2,7 +2,6 @@ conformance/canvas-test.html
conformance/canvas-test.html conformance/canvas-test.html
conformance/context-attributes.html conformance/context-attributes.html
conformance/gl-enum-tests.html conformance/gl-enum-tests.html
conformance/gl-get-calls.html
conformance/gl-object-get-calls.html conformance/gl-object-get-calls.html
conformance/gl-vertexattribpointer.html conformance/gl-vertexattribpointer.html
conformance/texture-npot.html conformance/texture-npot.html

Просмотреть файл

@ -4,5 +4,4 @@ conformance/gl-get-active-attribute.html
conformance/gl-uniform-bool.html conformance/gl-uniform-bool.html
conformance/gl-vertexattribpointer.html conformance/gl-vertexattribpointer.html
conformance/glsl-2types-of-textures-on-same-unit.html conformance/glsl-2types-of-textures-on-same-unit.html
conformance/is-object.html
conformance/tex-image-and-sub-image-2d-with-array-buffer-view.html conformance/tex-image-and-sub-image-2d-with-array-buffer-view.html