Bug 1167504 - Part 1: Remove BindableName - Framebuffer. r=jgilbert

This commit is contained in:
Dan Glastonbury 2015-05-21 09:50:28 +10:00
parent c2ca93a152
commit b4512d210b
4 changed files with 46 additions and 13 deletions

View File

@ -159,9 +159,11 @@ WebGLContext::BindFramebuffer(GLenum target, WebGLFramebuffer* wfb)
if (!wfb) {
gl->fBindFramebuffer(target, 0);
} else {
wfb->BindTo(target);
GLuint framebuffername = wfb->GLName();
GLuint framebuffername = wfb->mGLName;
gl->fBindFramebuffer(target, framebuffername);
#ifdef ANDROID
wfb->mIsFB = true;
#endif
}
switch (target) {
@ -1691,9 +1693,22 @@ WebGLContext::IsFramebuffer(WebGLFramebuffer* fb)
if (IsContextLost())
return false;
return ValidateObjectAllowDeleted("isFramebuffer", fb) &&
!fb->IsDeleted() &&
fb->HasEverBeenBound();
if (!ValidateObjectAllowDeleted("isFramebuffer", fb))
return false;
if (fb->IsDeleted())
return false;
#ifdef ANDROID
if (gl->WorkAroundDriverBugs() &&
gl->Renderer() == GLRenderer::AndroidEmulator)
{
return fb->mIsFB;
}
#endif
MakeContextCurrent();
return gl->fIsFramebuffer(fb->mGLName);
}
bool

View File

@ -1098,15 +1098,15 @@ WebGLContext::AssertCachedBindings()
// Bound object state
if (IsWebGL2()) {
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->GLName()
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->mGLName
: 0;
AssertUintParamCorrect(gl, LOCAL_GL_DRAW_FRAMEBUFFER_BINDING, bound);
bound = mBoundReadFramebuffer ? mBoundReadFramebuffer->GLName() : 0;
bound = mBoundReadFramebuffer ? mBoundReadFramebuffer->mGLName : 0;
AssertUintParamCorrect(gl, LOCAL_GL_READ_FRAMEBUFFER_BINDING, bound);
} else {
MOZ_ASSERT(mBoundDrawFramebuffer == mBoundReadFramebuffer);
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->GLName()
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->mGLName
: 0;
AssertUintParamCorrect(gl, LOCAL_GL_FRAMEBUFFER_BINDING, bound);
}

View File

@ -404,14 +404,18 @@ WebGLFramebuffer::AttachPoint::FinalizeAttachment(gl::GLContext* gl,
// WebGLFramebuffer
WebGLFramebuffer::WebGLFramebuffer(WebGLContext* webgl, GLuint fbo)
: WebGLBindableName<FBTarget>(fbo)
, WebGLContextBoundObject(webgl)
: WebGLContextBoundObject(webgl)
, mGLName(fbo)
, mStatus(0)
, mReadBufferMode(LOCAL_GL_COLOR_ATTACHMENT0)
, mColorAttachment0(this, LOCAL_GL_COLOR_ATTACHMENT0)
, mDepthAttachment(this, LOCAL_GL_DEPTH_ATTACHMENT)
, mStencilAttachment(this, LOCAL_GL_STENCIL_ATTACHMENT)
, mDepthStencilAttachment(this, LOCAL_GL_DEPTH_STENCIL_ATTACHMENT)
#ifdef ANDROID
, mIsFB(false)
#endif
{
mContext->mFramebuffers.insertBack(this);
}
@ -432,6 +436,10 @@ WebGLFramebuffer::Delete()
mContext->MakeContextCurrent();
mContext->gl->fDeleteFramebuffers(1, &mGLName);
LinkedListElement<WebGLFramebuffer>::removeFrom(mContext->mFramebuffers);
#ifdef ANDROID
mIsFB = false;
#endif
}
void

View File

@ -8,7 +8,6 @@
#include "mozilla/LinkedList.h"
#include "nsWrapperCache.h"
#include "WebGLBindableName.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
@ -23,12 +22,13 @@ namespace gl {
class WebGLFramebuffer final
: public nsWrapperCache
, public WebGLBindableName<FBTarget>
, public WebGLRefCountedObject<WebGLFramebuffer>
, public LinkedListElement<WebGLFramebuffer>
, public WebGLContextBoundObject
, public SupportsWeakPtr<WebGLFramebuffer>
{
friend class WebGLContext;
public:
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLFramebuffer)
@ -53,7 +53,6 @@ public:
}
bool IsDefined() const;
bool IsDeleteRequested() const;
TexInternalFormat EffectiveInternalFormat() const;
@ -99,6 +98,8 @@ public:
FBAttachment attachmentLoc) const;
};
const GLuint mGLName;
private:
mutable GLenum mStatus;
@ -111,6 +112,15 @@ private:
AttachPoint mDepthStencilAttachment;
nsTArray<AttachPoint> mMoreColorAttachments;
#ifdef ANDROID
// Bug 1140459: Some drivers (including our test slaves!) don't
// give reasonable answers for IsRenderbuffer, maybe others.
// This shows up on Android 2.3 emulator.
//
// So we track the `is a Framebuffer` state ourselves.
bool mIsFB;
#endif
public:
WebGLFramebuffer(WebGLContext* webgl, GLuint fbo);