Bug 1705305 - Rename WebGLTexture::ImageInfo::WebGLFormat to WebGLTexture::ImageInfo::WebGLInternalFormat.; r=bjacob

--HG--
extra : rebase_source : 72cb9f5d79b6c349697f107ff1689a421cefbe66
extra : source : ccc10059a97fe9a9fd684cbdb553c75c6403808c
This commit is contained in:
Dan Glastonbury 2014-07-15 09:55:33 +10:00
parent 3f8deea4e9
commit 84300074d3
7 changed files with 45 additions and 38 deletions

View File

@ -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;

View File

@ -676,7 +676,7 @@ WebGLContext::BindFakeBlackTexturesHelper(
}
bool alpha = s == WebGLTextureFakeBlackStatus::UninitializedImageData &&
FormatHasAlpha(boundTexturesArray[i]->ImageInfoBase().WebGLFormat());
FormatHasAlpha(boundTexturesArray[i]->ImageInfoBase().WebGLInternalFormat());
UniquePtr<FakeBlackTexture>&
blackTexturePtr = alpha
? transparentTextureScopedPtr

View File

@ -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

View File

@ -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",

View File

@ -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);

View File

@ -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,

View File

@ -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;