Bug 1063053 - Add stronger types to WebGL texture code for better debug/compile time checking. r=jgilbert,kamidphish
This commit is contained in:
@@ -24,7 +24,7 @@ WebGLFramebuffer::WrapObject(JSContext* cx)
|
||||
}
|
||||
|
||||
WebGLFramebuffer::WebGLFramebuffer(WebGLContext* context)
|
||||
: WebGLBindableName()
|
||||
: WebGLBindableName<GLenum>()
|
||||
, WebGLContextBoundObject(context)
|
||||
, mStatus(0)
|
||||
, mDepthAttachment(LOCAL_GL_DEPTH_ATTACHMENT)
|
||||
@@ -42,6 +42,7 @@ WebGLFramebuffer::WebGLFramebuffer(WebGLContext* context)
|
||||
|
||||
WebGLFramebuffer::Attachment::Attachment(GLenum aAttachmentPoint)
|
||||
: mAttachmentPoint(aAttachmentPoint)
|
||||
, mTexImageTarget(LOCAL_GL_NONE)
|
||||
, mNeedsFinalize(false)
|
||||
{}
|
||||
|
||||
@@ -84,9 +85,9 @@ WebGLFramebuffer::GetFormatForAttachment(const WebGLFramebuffer::Attachment& att
|
||||
|
||||
if (attachment.Texture()) {
|
||||
const WebGLTexture& tex = *attachment.Texture();
|
||||
MOZ_ASSERT(tex.HasImageInfoAt(tex.Target(), 0));
|
||||
MOZ_ASSERT(tex.HasImageInfoAt(attachment.ImageTarget(), 0));
|
||||
|
||||
const WebGLTexture::ImageInfo& imgInfo = tex.ImageInfoAt(tex.Target(), 0);
|
||||
const WebGLTexture::ImageInfo& imgInfo = tex.ImageInfoAt(attachment.ImageTarget(), 0);
|
||||
return imgInfo.WebGLFormat();
|
||||
}
|
||||
|
||||
@@ -130,7 +131,7 @@ WebGLFramebuffer::Attachment::IsReadableFloat() const
|
||||
}
|
||||
|
||||
void
|
||||
WebGLFramebuffer::Attachment::SetTexImage(WebGLTexture* tex, GLenum target, GLint level)
|
||||
WebGLFramebuffer::Attachment::SetTexImage(WebGLTexture* tex, TexImageTarget target, GLint level)
|
||||
{
|
||||
mTexturePtr = tex;
|
||||
mRenderbufferPtr = nullptr;
|
||||
@@ -395,14 +396,18 @@ WebGLFramebuffer::Attachment::FinalizeAttachment(GLContext* gl, GLenum attachmen
|
||||
if (Texture()) {
|
||||
MOZ_ASSERT(gl == Texture()->Context()->gl);
|
||||
|
||||
const GLenum imageTarget = ImageTarget().get();
|
||||
const GLint mipLevel = MipLevel();
|
||||
const GLuint glName = Texture()->GLName();
|
||||
|
||||
if (attachmentLoc == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
|
||||
gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_DEPTH_ATTACHMENT,
|
||||
TexImageTarget(), Texture()->GLName(), TexImageLevel());
|
||||
imageTarget, glName, mipLevel);
|
||||
gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_STENCIL_ATTACHMENT,
|
||||
TexImageTarget(), Texture()->GLName(), TexImageLevel());
|
||||
imageTarget, glName, mipLevel);
|
||||
} else {
|
||||
gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, attachmentLoc,
|
||||
TexImageTarget(), Texture()->GLName(), TexImageLevel());
|
||||
imageTarget, glName, mipLevel);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -500,7 +505,7 @@ WebGLFramebuffer::FramebufferRenderbuffer(GLenum target,
|
||||
void
|
||||
WebGLFramebuffer::FramebufferTexture2D(GLenum target,
|
||||
GLenum attachment,
|
||||
GLenum textarget,
|
||||
TexImageTarget texImageTarget,
|
||||
WebGLTexture* wtex,
|
||||
GLint level)
|
||||
{
|
||||
@@ -512,16 +517,9 @@ WebGLFramebuffer::FramebufferTexture2D(GLenum target,
|
||||
if (target != LOCAL_GL_FRAMEBUFFER)
|
||||
return mContext->ErrorInvalidEnumInfo("framebufferTexture2D: target", target);
|
||||
|
||||
if (textarget != LOCAL_GL_TEXTURE_2D &&
|
||||
(textarget < LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X ||
|
||||
textarget > LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))
|
||||
{
|
||||
return mContext->ErrorInvalidEnumInfo("framebufferTexture2D: invalid texture target", textarget);
|
||||
}
|
||||
|
||||
if (wtex) {
|
||||
bool isTexture2D = wtex->Target() == LOCAL_GL_TEXTURE_2D;
|
||||
bool isTexTarget2D = textarget == LOCAL_GL_TEXTURE_2D;
|
||||
bool isTexTarget2D = texImageTarget == LOCAL_GL_TEXTURE_2D;
|
||||
if (isTexture2D != isTexTarget2D) {
|
||||
return mContext->ErrorInvalidOperation("framebufferTexture2D: mismatched texture and texture target");
|
||||
}
|
||||
@@ -555,7 +553,7 @@ WebGLFramebuffer::FramebufferTexture2D(GLenum target,
|
||||
if (wtex)
|
||||
wtex->AttachTo(this, attachment);
|
||||
|
||||
a->SetTexImage(wtex, textarget, level);
|
||||
a->SetTexImage(wtex, texImageTarget, level);
|
||||
}
|
||||
|
||||
WebGLFramebuffer::Attachment*
|
||||
|
||||
Reference in New Issue
Block a user