bool TexUnpackSurface::Validate(WebGLContext* webgl, const char* funcName, const webgl::PackingInfo& pi) { const auto& fullRows = mSurf->GetSize().height; return ValidateUnpackPixels(webgl, funcName, fullRows, 0, this); }
bool TexUnpackImage::Validate(WebGLContext* webgl, const char* funcName, const webgl::PackingInfo& pi) { if (!ValidatePIForDOM(webgl, funcName, pi)) return false; const auto fullRows = mImage->GetSize().height; return ValidateUnpackPixels(webgl, funcName, fullRows, 0, this); }
static bool ValidateUnpackBytes(WebGLContext* webgl, const char* funcName, const webgl::PackingInfo& pi, size_t availByteCount, webgl::TexUnpackBlob* blob) { if (!blob->mWidth || !blob->mHeight || !blob->mDepth) 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 = availByteCount / rowStride; if (!fullRows.isValid()) { webgl->ErrorOutOfMemory("%s: Unacceptable upload size calculated.", funcName); return false; } const auto bodyBytes = fullRows.value() * rowStride.value(); const auto tailPixels = (availByteCount - bodyBytes) / bytesPerPixel; return ValidateUnpackPixels(webgl, funcName, fullRows.value(), tailPixels, blob); }