Bug 1293845 - Handle zero-size TexSubImage. - r=mtseng
MozReview-Commit-ID: J4cT3oqPTLa
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -179,16 +179,19 @@ WebGLContext::ValidateUnpackPixels(const
return false;
}
static bool
ValidateUnpackBytes(WebGLContext* webgl, const char* funcName, uint32_t width,
uint32_t height, uint32_t depth, const webgl::PackingInfo& pi,
uint32_t byteCount, webgl::TexUnpackBlob* blob)
{
+ if (!width || !height || !depth)
+ return true;
+
const auto bytesPerPixel = webgl::BytesPerPixel(pi);
const auto bytesPerRow = CheckedUint32(blob->mRowLength) * bytesPerPixel;
const auto rowStride = RoundUpToMultipleOf(bytesPerRow, blob->mAlignment);
const auto fullRows = byteCount / rowStride;
if (!fullRows.isValid()) {
webgl->ErrorOutOfMemory("%s: Unacceptable upload size calculated.");
return false;