From 84300074d3bd5f0467cb06c2233ecca27cc83e7c Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Tue, 15 Jul 2014 09:55:33 +1000 Subject: [PATCH] Bug 1705305 - Rename WebGLTexture::ImageInfo::WebGLFormat to WebGLTexture::ImageInfo::WebGLInternalFormat.; r=bjacob --HG-- extra : rebase_source : 72cb9f5d79b6c349697f107ff1689a421cefbe66 extra : source : ccc10059a97fe9a9fd684cbdb553c75c6403808c --- dom/canvas/WebGLContext.cpp | 3 ++- dom/canvas/WebGLContextDraw.cpp | 2 +- dom/canvas/WebGLContextGL.cpp | 24 ++++++++++++------------ dom/canvas/WebGLContextValidate.cpp | 2 +- dom/canvas/WebGLFramebuffer.cpp | 19 +++++++++++-------- dom/canvas/WebGLTexture.cpp | 17 +++++++++-------- dom/canvas/WebGLTexture.h | 16 +++++++++------- 7 files changed, 45 insertions(+), 38 deletions(-) diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 6288e63348f..bfbee4787cc 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -1809,7 +1809,8 @@ bool WebGLContext::TexImageFromVideoElement(const TexImageTarget texImageTarget, } bool ok = gl->BlitHelper()->BlitImageToTexture(srcImage.get(), srcImage->GetSize(), tex->GLName(), texImageTarget.get(), mPixelStoreFlipY); if (ok) { - tex->SetImageInfo(texImageTarget, level, srcImage->GetSize().width, srcImage->GetSize().height, format, type, WebGLImageDataStatus::InitializedImageData); + tex->SetImageInfo(texImageTarget, level, srcImage->GetSize().width, srcImage->GetSize().height, internalformat, type, + WebGLImageDataStatus::InitializedImageData); tex->Bind(TexImageTargetToTexTarget(texImageTarget)); } srcImage = nullptr; diff --git a/dom/canvas/WebGLContextDraw.cpp b/dom/canvas/WebGLContextDraw.cpp index c035af411d9..b3cf6790fa1 100644 --- a/dom/canvas/WebGLContextDraw.cpp +++ b/dom/canvas/WebGLContextDraw.cpp @@ -676,7 +676,7 @@ WebGLContext::BindFakeBlackTexturesHelper( } bool alpha = s == WebGLTextureFakeBlackStatus::UninitializedImageData && - FormatHasAlpha(boundTexturesArray[i]->ImageInfoBase().WebGLFormat()); + FormatHasAlpha(boundTexturesArray[i]->ImageInfoBase().WebGLInternalFormat()); UniquePtr& blackTexturePtr = alpha ? transparentTextureScopedPtr diff --git a/dom/canvas/WebGLContextGL.cpp b/dom/canvas/WebGLContextGL.cpp index cbd9ac54e9d..9b4c5f9cb67 100644 --- a/dom/canvas/WebGLContextGL.cpp +++ b/dom/canvas/WebGLContextGL.cpp @@ -509,7 +509,7 @@ WebGLContext::CopyTexImage2D(GLenum rawTexImgTarget, sizeMayChange = width != imageInfo.Width() || height != imageInfo.Height() || - format != imageInfo.WebGLFormat() || + internalformat != imageInfo.WebGLInternalFormat() || type != imageInfo.WebGLType(); } @@ -526,7 +526,7 @@ WebGLContext::CopyTexImage2D(GLenum rawTexImgTarget, } } - tex->SetImageInfo(texImageTarget, level, width, height, format, type, + tex->SetImageInfo(texImageTarget, level, width, height, internalformat, type, WebGLImageDataStatus::InitializedImageData); } @@ -595,7 +595,7 @@ WebGLContext::CopyTexSubImage2D(GLenum rawTexImgTarget, tex->DoDeferredImageInitialization(texImageTarget, level); } - return CopyTexSubImage2D_base(texImageTarget, level, imageInfo.WebGLFormat().get(), xoffset, yoffset, x, y, width, height, true); + return CopyTexSubImage2D_base(texImageTarget, level, imageInfo.WebGLInternalFormat().get(), xoffset, yoffset, x, y, width, height, true); } @@ -915,12 +915,12 @@ WebGLContext::GenerateMipmap(GLenum rawTarget) if (!tex->IsFirstImagePowerOfTwo()) return ErrorInvalidOperation("generateMipmap: Level zero of texture does not have power-of-two width and height."); - TexInternalFormat webGLFormat = tex->ImageInfoAt(imageTarget, 0).WebGLFormat(); - if (IsTextureFormatCompressed(webGLFormat)) + TexInternalFormat webGLInternalFormat = tex->ImageInfoAt(imageTarget, 0).WebGLInternalFormat(); + if (IsTextureFormatCompressed(webGLInternalFormat)) return ErrorInvalidOperation("generateMipmap: Texture data at level zero is compressed."); if (IsExtensionEnabled(WebGLExtensionID::WEBGL_depth_texture) && - (IsGLDepthFormat(webGLFormat) || IsGLDepthStencilFormat(webGLFormat))) + (IsGLDepthFormat(webGLInternalFormat) || IsGLDepthStencilFormat(webGLInternalFormat))) { return ErrorInvalidOperation("generateMipmap: " "A texture that has a base internal format of " @@ -1176,10 +1176,10 @@ WebGLContext::GetFramebufferAttachmentParameter(JSContext* cx, switch (pname) { case LOCAL_GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: if (IsExtensionEnabled(WebGLExtensionID::EXT_sRGB)) { - const TexInternalFormat webGLFormat = - fba.Texture()->ImageInfoBase().WebGLFormat(); - return (webGLFormat == LOCAL_GL_SRGB || - webGLFormat == LOCAL_GL_SRGB_ALPHA) ? + const TexInternalFormat webGLInternalFormat = + fba.Texture()->ImageInfoBase().WebGLInternalFormat(); + return (webGLInternalFormat == LOCAL_GL_SRGB || + webGLInternalFormat == LOCAL_GL_SRGB_ALPHA) ? JS::NumberValue(uint32_t(LOCAL_GL_SRGB)) : JS::NumberValue(uint32_t(LOCAL_GL_LINEAR)); } @@ -3595,7 +3595,7 @@ GLenum WebGLContext::CheckedTexImage2D(TexImageTarget texImageTarget, const WebGLTexture::ImageInfo& imageInfo = tex->ImageInfoAt(texImageTarget, level); sizeMayChange = width != imageInfo.Width() || height != imageInfo.Height() || - format != imageInfo.WebGLFormat() || + format != imageInfo.WebGLInternalFormat() || type != imageInfo.WebGLType(); } @@ -3725,7 +3725,7 @@ WebGLContext::TexImage2D_base(TexImageTarget texImageTarget, GLint level, GLenum // have NoImageData at this point. MOZ_ASSERT(imageInfoStatusIfSuccess != WebGLImageDataStatus::NoImageData); - tex->SetImageInfo(texImageTarget, level, width, height, format, type, imageInfoStatusIfSuccess); + tex->SetImageInfo(texImageTarget, level, width, height, internalformat, type, imageInfoStatusIfSuccess); } void diff --git a/dom/canvas/WebGLContextValidate.cpp b/dom/canvas/WebGLContextValidate.cpp index d6a01a3bfa4..b27706f8afb 100644 --- a/dom/canvas/WebGLContextValidate.cpp +++ b/dom/canvas/WebGLContextValidate.cpp @@ -1410,7 +1410,7 @@ WebGLContext::ValidateTexImage(GLuint dims, TexImageTarget texImageTarget, /* Require the format and type to match that of the existing * texture as created */ - if (imageInfo.WebGLFormat() != format || + if (imageInfo.WebGLInternalFormat() != internalFormat || imageInfo.WebGLType() != type) { ErrorInvalidOperation("%s: format or type doesn't match the existing texture", diff --git a/dom/canvas/WebGLFramebuffer.cpp b/dom/canvas/WebGLFramebuffer.cpp index 339f8ffb6b3..014caa7e17d 100644 --- a/dom/canvas/WebGLFramebuffer.cpp +++ b/dom/canvas/WebGLFramebuffer.cpp @@ -3,16 +3,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "WebGLContext.h" #include "WebGLFramebuffer.h" + +#include "WebGLContext.h" +#include "WebGLContextUtils.h" #include "WebGLExtensions.h" #include "WebGLRenderbuffer.h" -#include "WebGLTexture.h" -#include "mozilla/dom/WebGLRenderingContextBinding.h" -#include "WebGLTexture.h" #include "WebGLRenderbuffer.h" +#include "WebGLTexture.h" +#include "WebGLTexture.h" + #include "GLContext.h" -#include "WebGLContextUtils.h" + +#include "mozilla/dom/WebGLRenderingContextBinding.h" using namespace mozilla; using namespace mozilla::gl; @@ -77,7 +80,7 @@ WebGLFramebuffer::Attachment::HasAlpha() const MOZ_ASSERT(HasImage()); if (Texture() && Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel)) - return FormatHasAlpha(Texture()->ImageInfoAt(mTexImageTarget, mTexImageLevel).WebGLFormat()); + return FormatHasAlpha(Texture()->ImageInfoAt(mTexImageTarget, mTexImageLevel).WebGLInternalFormat()); else if (Renderbuffer()) return FormatHasAlpha(Renderbuffer()->InternalFormat()); else return false; @@ -94,7 +97,7 @@ WebGLFramebuffer::GetFormatForAttachment(const WebGLFramebuffer::Attachment& att MOZ_ASSERT(tex.HasImageInfoAt(attachment.ImageTarget(), 0)); const WebGLTexture::ImageInfo& imgInfo = tex.ImageInfoAt(attachment.ImageTarget(), 0); - return imgInfo.WebGLFormat().get(); + return imgInfo.WebGLInternalFormat().get(); } if (attachment.Renderbuffer()) @@ -328,7 +331,7 @@ WebGLFramebuffer::Attachment::IsComplete() const MOZ_ASSERT(Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel)); const WebGLTexture::ImageInfo& imageInfo = Texture()->ImageInfoAt(mTexImageTarget, mTexImageLevel); - GLenum webGLFormat = imageInfo.WebGLFormat().get(); + GLenum webGLFormat = imageInfo.WebGLInternalFormat().get(); if (mAttachmentPoint == LOCAL_GL_DEPTH_ATTACHMENT) return IsValidFBOTextureDepthFormat(webGLFormat); diff --git a/dom/canvas/WebGLTexture.cpp b/dom/canvas/WebGLTexture.cpp index 28a62ac6d26..b0d7ec3bba8 100644 --- a/dom/canvas/WebGLTexture.cpp +++ b/dom/canvas/WebGLTexture.cpp @@ -52,7 +52,7 @@ int64_t WebGLTexture::ImageInfo::MemoryUsage() const { if (mImageDataStatus == WebGLImageDataStatus::NoImageData) return 0; - int64_t bitsPerTexel = WebGLContext::GetBitsPerTexel(mWebGLFormat, mWebGLType); + int64_t bitsPerTexel = WebGLContext::GetBitsPerTexel(mWebGLInternalFormat, mWebGLType); return int64_t(mWidth) * int64_t(mHeight) * bitsPerTexel/8; } @@ -137,8 +137,9 @@ WebGLTexture::Bind(TexTarget aTexTarget) { void WebGLTexture::SetImageInfo(TexImageTarget aTexImageTarget, GLint aLevel, - GLsizei aWidth, GLsizei aHeight, - TexInternalFormat aFormat, TexType aType, WebGLImageDataStatus aStatus) + GLsizei aWidth, GLsizei aHeight, + TexInternalFormat aInternalFormat, TexType aType, + WebGLImageDataStatus aStatus) { MOZ_ASSERT(TexImageTargetToTexTarget(aTexImageTarget) == mTarget); if (TexImageTargetToTexTarget(aTexImageTarget) != mTarget) @@ -146,7 +147,7 @@ WebGLTexture::SetImageInfo(TexImageTarget aTexImageTarget, GLint aLevel, EnsureMaxLevelWithCustomImagesAtLeast(aLevel); - ImageInfoAt(aTexImageTarget, aLevel) = ImageInfo(aWidth, aHeight, aFormat, aType, aStatus); + ImageInfoAt(aTexImageTarget, aLevel) = ImageInfo(aWidth, aHeight, aInternalFormat, aType, aStatus); if (aLevel > 0) SetCustomMipmap(); @@ -542,13 +543,13 @@ WebGLTexture::DoDeferredImageInitialization(TexImageTarget imageTarget, GLint le mContext->MakeContextCurrent(); // Try to clear with glCLear. - TexInternalFormat format = imageInfo.mWebGLFormat; + TexInternalFormat internalformat = imageInfo.mWebGLInternalFormat; TexType type = imageInfo.mWebGLType; - WebGLTexelFormat texelformat = GetWebGLTexelFormat(format, type); + WebGLTexelFormat texelformat = GetWebGLTexelFormat(internalformat, type); bool cleared = ClearWithTempFB(mContext, GLName(), imageTarget, level, - format, imageInfo.mHeight, imageInfo.mWidth); + internalformat, imageInfo.mHeight, imageInfo.mWidth); if (cleared) { SetImageDataStatus(imageTarget, level, WebGLImageDataStatus::InitializedImageData); return; @@ -572,7 +573,7 @@ WebGLTexture::DoDeferredImageInitialization(TexImageTarget imageTarget, GLint le GLenum driverType = DriverTypeFromType(gl, type); GLenum driverInternalFormat = LOCAL_GL_NONE; GLenum driverFormat = LOCAL_GL_NONE; - DriverFormatsFromFormatAndType(gl, format, type, &driverInternalFormat, &driverFormat); + DriverFormatsFromFormatAndType(gl, internalformat, type, &driverInternalFormat, &driverFormat); mContext->GetAndFlushUnderlyingGLErrors(); gl->fTexImage2D(imageTarget.get(), level, driverInternalFormat, diff --git a/dom/canvas/WebGLTexture.h b/dom/canvas/WebGLTexture.h index 000c875dfd5..dfdf55180b0 100644 --- a/dom/canvas/WebGLTexture.h +++ b/dom/canvas/WebGLTexture.h @@ -67,18 +67,18 @@ public: { public: ImageInfo() - : mWebGLFormat(LOCAL_GL_NONE) + : mWebGLInternalFormat(LOCAL_GL_NONE) , mWebGLType(LOCAL_GL_NONE) , mImageDataStatus(WebGLImageDataStatus::NoImageData) {} ImageInfo(GLsizei width, GLsizei height, - TexInternalFormat webGLFormat, + TexInternalFormat webGLInternalFormat, TexType webGLType, WebGLImageDataStatus status) : WebGLRectangleObject(width, height) - , mWebGLFormat(webGLFormat) + , mWebGLInternalFormat(webGLInternalFormat) , mWebGLType(webGLType) , mImageDataStatus(status) { @@ -90,7 +90,7 @@ public: return mImageDataStatus == a.mImageDataStatus && mWidth == a.mWidth && mHeight == a.mHeight && - mWebGLFormat == a.mWebGLFormat && + mWebGLInternalFormat == a.mWebGLInternalFormat && mWebGLType == a.mWebGLType; } bool operator!=(const ImageInfo& a) const { @@ -114,7 +114,8 @@ public: * It can be converted to a value to be passed to driver with * DriverFormatsFromFormatAndType(). */ - TexInternalFormat WebGLFormat() const { return mWebGLFormat; } + TexInternalFormat WebGLInternalFormat() const { return mWebGLInternalFormat; } + /*! This is the type passed from JS to WebGL. * It can be converted to a value to be passed to driver with * DriverTypeFromType(). @@ -122,7 +123,7 @@ public: TexType WebGLType() const { return mWebGLType; } protected: - TexInternalFormat mWebGLFormat; //!< This is the WebGL/GLES format + TexInternalFormat mWebGLInternalFormat; //!< This is the WebGL/GLES internal format. TexType mWebGLType; //!< This is the WebGL/GLES type WebGLImageDataStatus mImageDataStatus; @@ -227,7 +228,8 @@ public: void SetImageInfo(TexImageTarget aTarget, GLint aLevel, GLsizei aWidth, GLsizei aHeight, - TexInternalFormat aFormat, TexType aType, WebGLImageDataStatus aStatus); + TexInternalFormat aInternalFormat, TexType aType, + WebGLImageDataStatus aStatus); void SetMinFilter(TexMinFilter aMinFilter) { mMinFilter = aMinFilter;