Bug 1499580 - Check enum in CompressedTexSubImage. r=kvark
authorJeff Gilbert <jgilbert@mozilla.com>
Wed, 17 Oct 2018 19:13:14 +0000
changeset 500255 c29585c36177f6c1fa00049c519f89b12bd779e3
parent 500197 b94a2aa50ef2a049dace3fb54fbaf825c6503a25
child 500256 a58c07d9a7fa325c65fb00b7a6b2b8cc25a7af1d
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1499580
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1499580 - Check enum in CompressedTexSubImage. r=kvark Also skip some redundent `compression` checks. Differential Revision: https://phabricator.services.mozilla.com/D8938
dom/canvas/WebGLTextureUpload.cpp
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -1299,21 +1299,16 @@ WebGLTexture::TexSubImage(TexImageTarget
     {
         return;
     }
     MOZ_ASSERT(imageInfo);
 
     auto dstUsage = imageInfo->mFormat;
     auto dstFormat = dstUsage->format;
 
-    if (dstFormat->compression) {
-        mContext->ErrorInvalidEnum("Specified TexImage must not be compressed.");
-        return;
-    }
-
     if (!mContext->IsWebGL2() && dstFormat->d) {
         mContext->ErrorInvalidOperation("Function may not be called on a texture of"
                                         " format %s.",
                                         dstFormat->name);
         return;
     }
 
     ////////////////////////////////////
@@ -1417,27 +1412,21 @@ WebGLTexture::CompressedTexImage(TexImag
     if (!ValidateTexImageSpecification(target, level, blob->mWidth,
                                        blob->mHeight, blob->mDepth, &imageInfo))
     {
         return;
     }
     MOZ_ASSERT(imageInfo);
 
     auto usage = mContext->mFormatUsage->GetSizedTexUsage(internalFormat);
-    if (!usage) {
-        mContext->ErrorInvalidEnum("Invalid internalFormat: 0x%04x",
-                                   internalFormat);
+    if (!usage || !usage->format->compression) {
+        mContext->ErrorInvalidEnumArg("internalFormat", internalFormat);
         return;
     }
-
     auto format = usage->format;
-    if (!format->compression) {
-        mContext->ErrorInvalidEnum("Specified internalFormat must be compressed.");
-        return;
-    }
 
     if (!ValidateTargetForFormat(mContext, target, format))
         return;
 
     ////////////////////////////////////
     // Get source info
 
     if (!ValidateCompressedTexUnpack(mContext, blob->mWidth, blob->mHeight,
@@ -1535,21 +1524,20 @@ WebGLTexture::CompressedTexSubImage(TexI
 
     auto dstUsage = imageInfo->mFormat;
     auto dstFormat = dstUsage->format;
 
     ////////////////////////////////////
     // Get source info
 
     auto srcUsage = mContext->mFormatUsage->GetSizedTexUsage(sizedUnpackFormat);
-    if (!srcUsage->format->compression) {
-        mContext->ErrorInvalidEnum("Specified format must be compressed.");
+    if (!srcUsage || !srcUsage->format->compression) {
+        mContext->ErrorInvalidEnumArg("sizedUnpackFormat", sizedUnpackFormat);
         return;
     }
-
     if (srcUsage != dstUsage) {
         mContext->ErrorInvalidOperation("`format` must match the format of the"
                                         " existing texture image.");
         return;
     }
 
     auto format = srcUsage->format;
     MOZ_ASSERT(format == dstFormat);