diff --git a/dom/canvas/ClientWebGLContext.cpp b/dom/canvas/ClientWebGLContext.cpp index f50fc7cbd624..75ef0eea63d5 100644 --- a/dom/canvas/ClientWebGLContext.cpp +++ b/dom/canvas/ClientWebGLContext.cpp @@ -4142,7 +4142,8 @@ void webgl::TexUnpackBlobDesc::Shrink(const webgl::PackingInfo& pi) { CheckedInt(unpack.metrics.bytesPerRowStride) * unpack.metrics.totalRows; if (bytesUpperBound.isValid()) { - cpuData->Shrink(bytesUpperBound.value()); + auto& span = *cpuData; + span = span.subspan(0, std::min(span.size(), bytesUpperBound.value())); } } } @@ -4218,7 +4219,7 @@ void ClientWebGLContext::TexImage(uint8_t funcDims, GLenum imageTarget, return Some(webgl::TexUnpackBlobDesc{imageTarget, size.value(), gfxAlphaType::NonPremult, - Some(RawBuffer<>{*range}), + Some(*range), {}}); }); } diff --git a/dom/canvas/DrawTargetWebgl.cpp b/dom/canvas/DrawTargetWebgl.cpp index 6055fa72e17f..ecb02d76da29 100644 --- a/dom/canvas/DrawTargetWebgl.cpp +++ b/dom/canvas/DrawTargetWebgl.cpp @@ -621,13 +621,13 @@ bool SharedContextWebgl::SetNoClipMask() { } mWebgl->ActiveTexture(1); mWebgl->BindTexture(LOCAL_GL_TEXTURE_2D, mNoClipMask); - static const uint8_t solidMask[4] = {0xFF, 0xFF, 0xFF, 0xFF}; - mWebgl->TexImage( - 0, LOCAL_GL_RGBA8, {0, 0, 0}, {LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE}, - {LOCAL_GL_TEXTURE_2D, - {1, 1, 1}, - gfxAlphaType::NonPremult, - Some(RawBuffer(Range(solidMask, sizeof(solidMask))))}); + static const auto solidMask = std::array{0xFF, 0xFF, 0xFF, 0xFF}; + mWebgl->TexImage(0, LOCAL_GL_RGBA8, {0, 0, 0}, + {LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE}, + {LOCAL_GL_TEXTURE_2D, + {1, 1, 1}, + gfxAlphaType::NonPremult, + Some(Span{solidMask})}); InitTexParameters(mNoClipMask, false); mWebgl->ActiveTexture(0); mLastClipMask = mNoClipMask; @@ -1916,11 +1916,11 @@ bool SharedContextWebgl::UploadSurface(DataSourceSurface* aData, int32_t bpp = BytesPerPixel(aFormat); // Get the data pointer range considering the sampling rect offset and // size. - Range range( + Span range( map.GetData() + aSrcRect.y * size_t(stride) + aSrcRect.x * bpp, std::max(aSrcRect.height - 1, 0) * size_t(stride) + aSrcRect.width * bpp); - texDesc.cpuData = Some(RawBuffer(range)); + texDesc.cpuData = Some(range); // If the stride happens to be 4 byte aligned, assume that is the // desired alignment regardless of format (even A8). Otherwise, we // default to byte alignment. diff --git a/dom/canvas/TexUnpackBlob.cpp b/dom/canvas/TexUnpackBlob.cpp index 8598c362273f..e9e64fe9b99e 100644 --- a/dom/canvas/TexUnpackBlob.cpp +++ b/dom/canvas/TexUnpackBlob.cpp @@ -476,8 +476,7 @@ bool TexUnpackBytes::Validate(const WebGLContext* const webgl, CheckedInt availBytes = 0; if (mDesc.cpuData) { - const auto& range = mDesc.cpuData->Data(); - availBytes = range.length(); + availBytes = mDesc.cpuData->size(); } else if (mDesc.pboOffset) { const auto& pboOffset = *mDesc.pboOffset; @@ -514,11 +513,7 @@ bool TexUnpackBytes::TexOrSubImage(bool isSubImage, bool needsRespec, const uint8_t* uploadPtr = nullptr; if (mDesc.cpuData) { - const auto range = mDesc.cpuData->Data(); - uploadPtr = range.begin().get(); - if (!uploadPtr) { - MOZ_ASSERT(!range.length()); - } + uploadPtr = mDesc.cpuData->data(); } else if (mDesc.pboOffset) { uploadPtr = reinterpret_cast(*mDesc.pboOffset); } diff --git a/dom/canvas/WebGLTypes.h b/dom/canvas/WebGLTypes.h index ca1454f59bec..c85b4ec9b395 100644 --- a/dom/canvas/WebGLTypes.h +++ b/dom/canvas/WebGLTypes.h @@ -1097,7 +1097,7 @@ struct TexUnpackBlobDesc final { uvec3 size; gfxAlphaType srcAlphaType = gfxAlphaType::NonPremult; - Maybe> cpuData; + Maybe> cpuData; Maybe pboOffset; Maybe structuredSrcSize;