Bug 1293845 - Handle zero-size TexSubImage. - r=mtseng draft
authorJeff Gilbert <jgilbert@mozilla.com>
Wed, 10 Aug 2016 15:16:05 -0700
changeset 399349 0c3c29e1c8bf2971c141cd5b99724066e072ef3f
parent 399348 39f01a6f5a21dd993b31318814200b94deb1d469
child 399350 ee7de0b7a341eb4f2cce02ea7553202bf5335ad1
push id25807
push userbmo:jgilbert@mozilla.com
push dateWed, 10 Aug 2016 22:21:10 +0000
reviewersmtseng
bugs1293845
milestone51.0a1
Bug 1293845 - Handle zero-size TexSubImage. - r=mtseng MozReview-Commit-ID: J4cT3oqPTLa
dom/canvas/WebGLTextureUpload.cpp
--- 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;