Misc from initial review vidyo.
draft
Misc from initial review vidyo.
--- a/dom/canvas/TexUnpackBlob.cpp
+++ b/dom/canvas/TexUnpackBlob.cpp
@@ -330,17 +330,17 @@ TexUnpackSurface::OriginsForDOM(WebGLCon
gl::OriginPos* const out_dst)
{
// Our surfaces are TopLeft.
*out_src = gl::OriginPos::TopLeft;
// WebGL specs the default as passing DOM elements top-left first.
// Thus y-flip would give us bottom-left.
*out_dst = webgl->mPixelStore_FlipY ? gl::OriginPos::BottomLeft
- : gl::OriginPos::TopLeft;
+ : gl::OriginPos::TopLeft;
}
/*static*/ bool
TexUnpackSurface::UploadDataSurface(bool isSubImage, WebGLContext* webgl,
TexImageTarget target, GLint level,
const webgl::DriverUnpackInfo* dui, GLint xOffset,
GLint yOffset, GLint zOffset, GLsizei width,
GLsizei height, gfx::DataSourceSurface* surf,
@@ -409,16 +409,18 @@ TexUnpackSurface::UploadDataSurface(bool
return false;
const GLint kMaxUnpackAlignment = 8;
size_t unpackAlignment;
if (!GuessAlignment(map.GetData(), width, map.GetStride(), kMaxUnpackAlignment,
&unpackAlignment))
{
return false;
+ // TODO: Consider using UNPACK_ settings to set the stride based on the too-large
+ // alignment used for many SourceSurfaces.
}
gl->MakeCurrent();
ScopedUnpackReset scopedReset(webgl);
gl->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, unpackAlignment);
const GLsizei depth = 1;
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1683,16 +1683,17 @@ ValidateTexImageTarget(WebGLContext* web
bool
GuessAlignmentFromStride(size_t width, size_t stride, size_t maxAlignment,
size_t* const out_alignment);
class UniqueBuffer
{
+ // Like UniquePtr<>, but for void* and malloc/calloc/free.
void* mBuffer;
public:
UniqueBuffer()
: mBuffer(nullptr)
{ }
explicit UniqueBuffer(void* buffer)
--- a/dom/canvas/WebGLExtensionSRGB.cpp
+++ b/dom/canvas/WebGLExtensionSRGB.cpp
@@ -42,17 +42,17 @@ WebGLExtensionSRGB::WebGLExtensionSRGB(W
usage = fua->EditUsage(webgl::EffectiveFormat::SRGB8_ALPHA8);
usage->isRenderable = true;
usage->isFilterable = true;
pi = {LOCAL_GL_SRGB_ALPHA, LOCAL_GL_UNSIGNED_BYTE};
dui = {LOCAL_GL_SRGB_ALPHA, LOCAL_GL_SRGB_ALPHA, LOCAL_GL_UNSIGNED_BYTE};
fua->AddUnsizedTexFormat(pi, usage);
usage->AddUnpack(pi, dui);
- fua->AddRBFormat(LOCAL_GL_SRGB_ALPHA, usage);
+ fua->AddRBFormat(LOCAL_GL_SRGB8_ALPHA8, usage);
}
WebGLExtensionSRGB::~WebGLExtensionSRGB()
{
}
bool
WebGLExtensionSRGB::IsSupported(const WebGLContext* webgl)
--- a/dom/canvas/WebGLFormats.cpp
+++ b/dom/canvas/WebGLFormats.cpp
@@ -666,23 +666,17 @@ FormatUsageAuthority::CreateForWebGL2(gl
fnAddES3TexFormat(FOO(DEPTH_COMPONENT16 ), true, false);
fnAddES3TexFormat(FOO(DEPTH_COMPONENT24 ), true, false);
fnAddES3TexFormat(FOO(DEPTH_COMPONENT32F), true, false);
fnAddES3TexFormat(FOO(DEPTH24_STENCIL8 ), true, false);
fnAddES3TexFormat(FOO(DEPTH32F_STENCIL8 ), true, false);
// GLES 3.0.4, p205-206, "Required Renderbuffer Formats"
fnAddES3TexFormat(FOO(STENCIL_INDEX8), true, false);
-/*
- // GLES 3.0.4, p128, table 3.12.
- // Unsized RGBA/RGB formats are renderable, other unsized are not.
- fnAddES3TexFormat(FOO(Luminance8Alpha8, false, true);
- fnAddES3TexFormat(FOO(Luminance8 , false, true);
- fnAddES3TexFormat(FOO(Alpha8 , false, true);
-*/
+
// GLES 3.0.4, p147, table 3.19
// GLES 3.0.4, p286+, $C.1 "ETC Compressed Texture Image Formats"
// (jgilbert) I can't find where these are established as filterable.
fnAddES3TexFormat(FOO(COMPRESSED_RGB8_ETC2 ), false, true);
fnAddES3TexFormat(FOO(COMPRESSED_SRGB8_ETC2 ), false, true);
fnAddES3TexFormat(FOO(COMPRESSED_RGBA8_ETC2_EAC ), false, true);
fnAddES3TexFormat(FOO(COMPRESSED_SRGB8_ALPHA8_ETC2_EAC ), false, true);
fnAddES3TexFormat(FOO(COMPRESSED_R11_EAC ), false, true);
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -1078,18 +1078,16 @@ WebGLTexture::TexImage(const char* funcN
if (!ValidateTexImageSpecification(funcName, target, level, blob->mWidth,
blob->mHeight, blob->mDepth, border, &imageInfo))
{
return;
}
MOZ_ASSERT(imageInfo);
const webgl::PackingInfo srcPacking = { unpackFormat, unpackType };
- if (!ValidateUnpackEnums(srcPacking, mContext, funcName))
- return;
auto dstUsage = mContext->mFormatUsage->GetSizedTexUsage(internalFormat);
if (!dstUsage) {
if (internalFormat != unpackFormat) {
mContext->ErrorInvalidOperation("%s: Unsized internalFormat must match"
" unpack format.",
funcName);
return;
@@ -1101,16 +1099,25 @@ WebGLTexture::TexImage(const char* funcN
if (!dstUsage) {
mContext->ErrorInvalidOperation("%s: Invalid internalformat/format/type:"
" 0x%04x/0x%04x/0x%04x",
funcName, internalFormat, unpackFormat,
unpackType);
return;
}
+ const webgl::DriverUnpackInfo* driverUnpackInfo;
+ if (!dstUsage->IsUnpackValid(srcPacking, &driverUnpackInfo)) {
+ mContext->ErrorInvalidOperation("%s: Mismatched internalFormat and format/type:"
+ " 0x%04x and 0x%04x/0x%04x",
+ funcName, internalFormat, unpackFormat,
+ unpackType);
+ return;
+ }
+
////////////////////////////////////
// Get source info
const bool isFunc3D = Is3D(target);
if (!blob->ValidateUnpack(mContext, funcName, isFunc3D, srcPacking))
return;
////////////////////////////////////
// Check that source and dest info are compatible
@@ -1124,25 +1131,16 @@ WebGLTexture::TexImage(const char* funcN
mContext->ErrorInvalidOperation("%s: With format %s, this function may only"
" be called with target=TEXTURE_2D,"
" data=null, and level=0.",
funcName, dstFormat->name);
return;
}
}
- const webgl::DriverUnpackInfo* driverUnpackInfo;
- if (!dstUsage->IsUnpackValid(srcPacking, &driverUnpackInfo)) {
- mContext->ErrorInvalidOperation("%s: Mismatched internalFormat and format/type:"
- " 0x%04x and 0x%04x/0x%04x",
- funcName, internalFormat, unpackFormat,
- unpackType);
- return;
- }
-
////////////////////////////////////
// Do the thing!
mContext->gl->MakeCurrent();
// It's tempting to do allocation first, and TexSubImage second, but this is generally
// slower.