From e960d744fad61697fca95b67d169cca0cc8174d5 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Fri, 11 Feb 2011 18:11:30 -0500 Subject: [PATCH] Bug 632546 - pass is-object test - r=vlad, a=jrmuizel --- content/canvas/src/WebGLContext.h | 26 +++++-- content/canvas/src/WebGLContextGL.cpp | 69 ++++++++++--------- .../canvas/test/webgl/failing_tests_linux.txt | 2 - .../canvas/test/webgl/failing_tests_mac.txt | 1 - .../test/webgl/failing_tests_windows.txt | 1 - 5 files changed, 55 insertions(+), 44 deletions(-) diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index 0b0248a277bc..9309a6b55d42 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -666,7 +666,7 @@ public: WebGLBuffer(WebGLContext *context, WebGLuint name) : WebGLContextBoundObject(context), - mName(name), mDeleted(PR_FALSE), + mName(name), mDeleted(PR_FALSE), mHasEverBeenBound(PR_FALSE), mByteLength(0), mTarget(LOCAL_GL_NONE), mData(nsnull) { } @@ -687,6 +687,8 @@ public: } PRBool Deleted() const { return mDeleted; } + PRBool HasEverBeenBound() { return mHasEverBeenBound; } + void SetHasEverBeenBound(PRBool x) { mHasEverBeenBound = x; } GLuint GLName() const { return mName; } GLuint ByteLength() const { return mByteLength; } GLenum Target() const { return mTarget; } @@ -764,6 +766,7 @@ public: protected: WebGLuint mName; PRBool mDeleted; + PRBool mHasEverBeenBound; GLuint mByteLength; GLenum mTarget; @@ -771,7 +774,7 @@ protected: PRBool mHasCachedMaxUbyteElement; PRUint16 mCachedMaxUshortElement; PRBool mHasCachedMaxUshortElement; - + void* mData; // in the case of an Element Array Buffer, we keep a copy. }; @@ -790,7 +793,7 @@ public: WebGLTexture(WebGLContext *context, WebGLuint name) : WebGLContextBoundObject(context), - mDeleted(PR_FALSE), mName(name), + mDeleted(PR_FALSE), mHasEverBeenBound(PR_FALSE), mName(name), mTarget(0), mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR), mMagFilter(LOCAL_GL_LINEAR), @@ -811,6 +814,8 @@ public: } PRBool Deleted() { return mDeleted; } + PRBool HasEverBeenBound() { return mHasEverBeenBound; } + void SetHasEverBeenBound(PRBool x) { mHasEverBeenBound = x; } WebGLuint GLName() { return mName; } NS_DECL_ISUPPORTS @@ -821,6 +826,7 @@ protected: friend class WebGLFramebuffer; PRBool mDeleted; + PRBool mHasEverBeenBound; WebGLuint mName; // we store information about the various images that are part of @@ -925,7 +931,7 @@ public: // this function should only be called by bindTexture(). // it assumes that the GL context is already current. - PRBool firstTimeThisTextureIsBound = mTarget == 0; + PRBool firstTimeThisTextureIsBound = !mHasEverBeenBound; if (!firstTimeThisTextureIsBound && aTarget != mTarget) { 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()) mContext->gl->fTexParameteri(mTarget, LOCAL_GL_TEXTURE_WRAP_R, LOCAL_GL_CLAMP_TO_EDGE); } + + mHasEverBeenBound = PR_TRUE; } void SetImageInfo(WebGLenum aTarget, WebGLint aLevel, @@ -1385,7 +1393,7 @@ public: WebGLContextBoundObject(context), mName(name), mInternalFormat(0), - mDeleted(PR_FALSE), mInitialized(PR_FALSE) + mDeleted(PR_FALSE), mHasEverBeenBound(PR_FALSE), mInitialized(PR_FALSE) { } void Delete() { @@ -1395,6 +1403,8 @@ public: mDeleted = PR_TRUE; } PRBool Deleted() const { return mDeleted; } + PRBool HasEverBeenBound() { return mHasEverBeenBound; } + void SetHasEverBeenBound(PRBool x) { mHasEverBeenBound = x; } WebGLuint GLName() const { return mName; } PRBool Initialized() const { return mInitialized; } @@ -1411,6 +1421,7 @@ protected: WebGLenum mInternalFormat; PRBool mDeleted; + PRBool mHasEverBeenBound; PRBool mInitialized; friend class WebGLFramebuffer; @@ -1515,7 +1526,7 @@ public: WebGLFramebuffer(WebGLContext *context, WebGLuint name) : WebGLContextBoundObject(context), - mName(name), mDeleted(PR_FALSE), + mName(name), mDeleted(PR_FALSE), mHasEverBeenBound(PR_FALSE), mColorAttachment(LOCAL_GL_COLOR_ATTACHMENT0), mDepthAttachment(LOCAL_GL_DEPTH_ATTACHMENT), mStencilAttachment(LOCAL_GL_STENCIL_ATTACHMENT), @@ -1529,6 +1540,8 @@ public: mDeleted = PR_TRUE; } PRBool Deleted() { return mDeleted; } + PRBool HasEverBeenBound() { return mHasEverBeenBound; } + void SetHasEverBeenBound(PRBool x) { mHasEverBeenBound = x; } WebGLuint GLName() { return mName; } nsresult FramebufferRenderbuffer(WebGLenum target, @@ -1819,6 +1832,7 @@ protected: WebGLuint mName; PRPackedBool mDeleted; + PRBool mHasEverBeenBound; // we only store pointers to attached renderbuffers, not to attached textures, because // we will only need to initialize renderbuffers. Textures are already initialized. diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index a9440fc924f7..192b3572f25f 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -211,6 +211,7 @@ WebGLContext::BindBuffer(WebGLenum target, nsIWebGLBuffer *bobj) if ((buf->Target() != LOCAL_GL_NONE) && (target != buf->Target())) return ErrorInvalidOperation("BindBuffer: buffer already bound to a different target"); buf->SetTarget(target); + buf->SetHasEverBeenBound(PR_TRUE); } MakeContextCurrent(); @@ -239,6 +240,7 @@ WebGLContext::BindFramebuffer(WebGLenum target, nsIWebGLFramebuffer *fbobj) gl->fBindFramebuffer(target, gl->GetOffscreenFBO()); } else { gl->fBindFramebuffer(target, framebuffername); + wfb->SetHasEverBeenBound(PR_TRUE); } mBoundFramebuffer = wfb; @@ -259,6 +261,9 @@ WebGLContext::BindRenderbuffer(WebGLenum target, nsIWebGLRenderbuffer *rbobj) if (!GetConcreteObjectAndGLName("bindRenderBuffer", rbobj, &wrb, &renderbuffername, &isNull)) return NS_OK; + if (!isNull) + wrb->SetHasEverBeenBound(PR_TRUE); + MakeContextCurrent(); gl->fBindRenderbuffer(target, renderbuffername); @@ -2535,11 +2540,14 @@ NS_IMETHODIMP WebGLContext::IsBuffer(nsIWebGLBuffer *bobj, WebGLboolean *retval) { PRBool isDeleted; - WebGLuint obj; - PRBool ok = GetGLName("isBuffer", bobj, &obj, 0, &isDeleted) && !isDeleted; + WebGLuint buffername; + WebGLBuffer *buffer; + PRBool ok = GetConcreteObjectAndGLName("isBuffer", bobj, &buffer, &buffername, nsnull, &isDeleted) && + !isDeleted && + buffer->HasEverBeenBound(); if (ok) { MakeContextCurrent(); - ok = gl->fIsBuffer(obj); + ok = gl->fIsBuffer(buffername); } *retval = ok; @@ -2550,11 +2558,14 @@ NS_IMETHODIMP WebGLContext::IsFramebuffer(nsIWebGLFramebuffer *fbobj, WebGLboolean *retval) { PRBool isDeleted; - WebGLuint obj; - PRBool ok = GetGLName("isFramebuffer", fbobj, &obj, 0, &isDeleted) && !isDeleted; + WebGLuint fbname; + WebGLFramebuffer *fb; + PRBool ok = GetConcreteObjectAndGLName("isFramebuffer", fbobj, &fb, &fbname, nsnull, &isDeleted) && + !isDeleted && + fb->HasEverBeenBound(); if (ok) { MakeContextCurrent(); - ok = gl->fIsFramebuffer(obj); + ok = gl->fIsFramebuffer(fbname); } *retval = ok; @@ -2566,18 +2577,10 @@ WebGLContext::IsProgram(nsIWebGLProgram *pobj, WebGLboolean *retval) { PRBool isDeleted; WebGLProgram *prog = nsnull; - PRBool ok = GetConcreteObject("isProgram", pobj, &prog, 0, &isDeleted, PR_FALSE); - if (!ok) { - *retval = PR_FALSE; - return NS_OK; - } - - if (isDeleted) { - *retval = PR_FALSE; - } else { - *retval = PR_TRUE; - } + PRBool ok = GetConcreteObject("isProgram", pobj, &prog, nsnull, &isDeleted, PR_FALSE) && + !isDeleted; + *retval = ok; return NS_OK; } @@ -2585,11 +2588,14 @@ NS_IMETHODIMP WebGLContext::IsRenderbuffer(nsIWebGLRenderbuffer *rbobj, WebGLboolean *retval) { PRBool isDeleted; - WebGLuint obj; - PRBool ok = GetGLName("isRenderBuffer", rbobj, &obj, 0, &isDeleted) && !isDeleted; + WebGLuint rbname; + WebGLRenderbuffer *rb; + PRBool ok = GetConcreteObjectAndGLName("isRenderBuffer", rbobj, &rb, &rbname, nsnull, &isDeleted) && + !isDeleted && + rb->HasEverBeenBound(); if (ok) { MakeContextCurrent(); - ok = gl->fIsRenderbuffer(obj); + ok = gl->fIsRenderbuffer(rbname); } *retval = ok; @@ -2601,18 +2607,10 @@ WebGLContext::IsShader(nsIWebGLShader *sobj, WebGLboolean *retval) { PRBool isDeleted; WebGLShader *shader = nsnull; - PRBool ok = GetConcreteObject("isShader", sobj, &shader, 0, &isDeleted, PR_FALSE); - if (!ok) { - *retval = PR_FALSE; - return NS_OK; - } - - if (isDeleted) { - *retval = PR_FALSE; - } else { - *retval = PR_TRUE; - } + PRBool ok = GetConcreteObject("isShader", sobj, &shader, nsnull, &isDeleted, PR_FALSE) && + !isDeleted; + *retval = ok; return NS_OK; } @@ -2620,11 +2618,14 @@ NS_IMETHODIMP WebGLContext::IsTexture(nsIWebGLTexture *tobj, WebGLboolean *retval) { PRBool isDeleted; - WebGLuint obj; - PRBool ok = GetGLName("isTexture", tobj, &obj, 0, &isDeleted) && !isDeleted; + WebGLuint texname; + WebGLTexture *tex; + PRBool ok = GetConcreteObjectAndGLName("isTexture", tobj, &tex, &texname, nsnull, &isDeleted) && + !isDeleted && + tex->HasEverBeenBound(); if (ok) { MakeContextCurrent(); - ok = gl->fIsTexture(obj); + ok = gl->fIsTexture(texname); } *retval = ok; diff --git a/content/canvas/test/webgl/failing_tests_linux.txt b/content/canvas/test/webgl/failing_tests_linux.txt index 62450c2c0393..c9b45f9dfb21 100644 --- a/content/canvas/test/webgl/failing_tests_linux.txt +++ b/content/canvas/test/webgl/failing_tests_linux.txt @@ -1,9 +1,7 @@ conformance/context-attributes.html conformance/gl-enum-tests.html conformance/gl-get-active-attribute.html -conformance/gl-get-calls.html conformance/gl-uniform-bool.html conformance/gl-vertexattribpointer.html conformance/glsl-2types-of-textures-on-same-unit.html -conformance/is-object.html conformance/uninitialized-test.html diff --git a/content/canvas/test/webgl/failing_tests_mac.txt b/content/canvas/test/webgl/failing_tests_mac.txt index 873d917b6267..960d0846db16 100644 --- a/content/canvas/test/webgl/failing_tests_mac.txt +++ b/content/canvas/test/webgl/failing_tests_mac.txt @@ -2,7 +2,6 @@ conformance/canvas-test.html conformance/canvas-test.html conformance/context-attributes.html conformance/gl-enum-tests.html -conformance/gl-get-calls.html conformance/gl-object-get-calls.html conformance/gl-vertexattribpointer.html conformance/texture-npot.html diff --git a/content/canvas/test/webgl/failing_tests_windows.txt b/content/canvas/test/webgl/failing_tests_windows.txt index 55de12dcfaaf..cdeca2bb6650 100644 --- a/content/canvas/test/webgl/failing_tests_windows.txt +++ b/content/canvas/test/webgl/failing_tests_windows.txt @@ -4,5 +4,4 @@ conformance/gl-get-active-attribute.html conformance/gl-uniform-bool.html conformance/gl-vertexattribpointer.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