Bug 1750310 - Centralize and reuse pixelstorei pack/unpack handling. r=lsalzman
* Accept that finding an explicit unpack for a given stride might fail. * Directly use the logic from the GLES spec for unpacking stride calculations. * Use structuredSrcSize member. * Calc explicit unpack based on dstStride, not srcStride. Differential Revision: https://phabricator.services.mozilla.com/D136052
This commit is contained in:
@@ -168,8 +168,8 @@ class ContextGenerationInfo final {
|
||||
std::array<float, 4> mClearColor = {{0, 0, 0, 0}};
|
||||
std::array<float, 4> mBlendColor = {{0, 0, 0, 0}};
|
||||
std::array<float, 2> mDepthRange = {{0, 1}};
|
||||
webgl::PixelPackState mPixelPackState;
|
||||
WebGLPixelStore mPixelUnpackState;
|
||||
webgl::PixelPackingState mPixelPackState;
|
||||
webgl::PixelUnpackStateWebgl mPixelUnpackState;
|
||||
|
||||
std::vector<GLenum> mCompressedTextureFormats;
|
||||
|
||||
@@ -1533,9 +1533,9 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
const webgl::PackingInfo& pi,
|
||||
const webgl::TexUnpackBlobDesc&) const;
|
||||
void TexImage(uint8_t funcDims, GLenum target, GLint level,
|
||||
GLenum respecFormat, const ivec3& offset, const ivec3& size,
|
||||
GLint border, const webgl::PackingInfo& pi,
|
||||
const TexImageSource& src) const;
|
||||
GLenum respecFormat, const ivec3& offset,
|
||||
const Maybe<ivec3>& size, GLint border,
|
||||
const webgl::PackingInfo& pi, const TexImageSource& src) const;
|
||||
void CompressedTexImage(bool sub, uint8_t funcDims, GLenum target,
|
||||
GLint level, GLenum format, const ivec3& offset,
|
||||
const ivec3& size, GLint border,
|
||||
@@ -1565,8 +1565,9 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
GLenum unpackFormat, GLenum unpackType, const T& anySrc,
|
||||
ErrorResult& out_error) const {
|
||||
const TexImageSourceAdapter src(&anySrc, &out_error);
|
||||
TexImage(2, target, level, internalFormat, {0, 0, 0}, {width, height, 1},
|
||||
border, {unpackFormat, unpackType}, src);
|
||||
TexImage(2, target, level, internalFormat, {0, 0, 0},
|
||||
Some(ivec3{width, height, 1}), border, {unpackFormat, unpackType},
|
||||
src);
|
||||
}
|
||||
|
||||
void TexImage2D(GLenum target, GLint level, GLenum internalFormat,
|
||||
@@ -1575,8 +1576,9 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
const dom::ArrayBufferView& view, GLuint viewElemOffset,
|
||||
ErrorResult&) const {
|
||||
const TexImageSourceAdapter src(&view, viewElemOffset);
|
||||
TexImage(2, target, level, internalFormat, {0, 0, 0}, {width, height, 1},
|
||||
border, {unpackFormat, unpackType}, src);
|
||||
TexImage(2, target, level, internalFormat, {0, 0, 0},
|
||||
Some(ivec3{width, height, 1}), border, {unpackFormat, unpackType},
|
||||
src);
|
||||
}
|
||||
|
||||
// -
|
||||
@@ -1587,8 +1589,8 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
GLenum unpackType, const T& anySrc,
|
||||
ErrorResult& out_error) const {
|
||||
const TexImageSourceAdapter src(&anySrc, &out_error);
|
||||
TexImage(2, target, level, 0, {xOffset, yOffset, 0}, {width, height, 1}, 0,
|
||||
{unpackFormat, unpackType}, src);
|
||||
TexImage(2, target, level, 0, {xOffset, yOffset, 0},
|
||||
Some(ivec3{width, height, 1}), 0, {unpackFormat, unpackType}, src);
|
||||
}
|
||||
|
||||
void TexSubImage2D(GLenum target, GLint level, GLint xOffset, GLint yOffset,
|
||||
@@ -1596,8 +1598,8 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
GLenum unpackType, const dom::ArrayBufferView& view,
|
||||
GLuint viewElemOffset, ErrorResult&) const {
|
||||
const TexImageSourceAdapter src(&view, viewElemOffset);
|
||||
TexImage(2, target, level, 0, {xOffset, yOffset, 0}, {width, height, 1}, 0,
|
||||
{unpackFormat, unpackType}, src);
|
||||
TexImage(2, target, level, 0, {xOffset, yOffset, 0},
|
||||
Some(ivec3{width, height, 1}), 0, {unpackFormat, unpackType}, src);
|
||||
}
|
||||
|
||||
// -
|
||||
@@ -1609,7 +1611,8 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
ErrorResult& out_error) const {
|
||||
const TexImageSourceAdapter src(&anySrc, &out_error);
|
||||
TexImage(3, target, level, internalFormat, {0, 0, 0},
|
||||
{width, height, depth}, border, {unpackFormat, unpackType}, src);
|
||||
Some(ivec3{width, height, depth}), border,
|
||||
{unpackFormat, unpackType}, src);
|
||||
}
|
||||
|
||||
void TexImage3D(GLenum target, GLint level, GLenum internalFormat,
|
||||
@@ -1619,7 +1622,8 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
ErrorResult&) const {
|
||||
const TexImageSourceAdapter src(&view, viewElemOffset);
|
||||
TexImage(3, target, level, internalFormat, {0, 0, 0},
|
||||
{width, height, depth}, border, {unpackFormat, unpackType}, src);
|
||||
Some(ivec3{width, height, depth}), border,
|
||||
{unpackFormat, unpackType}, src);
|
||||
}
|
||||
|
||||
// -
|
||||
@@ -1631,7 +1635,8 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
const T& anySrc, ErrorResult& out_error) const {
|
||||
const TexImageSourceAdapter src(&anySrc, &out_error);
|
||||
TexImage(3, target, level, 0, {xOffset, yOffset, zOffset},
|
||||
{width, height, depth}, 0, {unpackFormat, unpackType}, src);
|
||||
Some(ivec3{width, height, depth}), 0, {unpackFormat, unpackType},
|
||||
src);
|
||||
}
|
||||
|
||||
void TexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset,
|
||||
@@ -1641,7 +1646,8 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
GLuint srcElemOffset, ErrorResult&) const {
|
||||
const TexImageSourceAdapter src(&maybeSrcView, srcElemOffset);
|
||||
TexImage(3, target, level, 0, {xOffset, yOffset, zOffset},
|
||||
{width, height, depth}, 0, {unpackFormat, unpackType}, src);
|
||||
Some(ivec3{width, height, depth}), 0, {unpackFormat, unpackType},
|
||||
src);
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
@@ -1763,14 +1769,17 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
}
|
||||
|
||||
// -------------------
|
||||
// Forward legacy TexImageSource uploads for default width/height
|
||||
// legacy TexImageSource uploads without width/height.
|
||||
// The width/height params are webgl2 only, and let you do subrect
|
||||
// selection with e.g. width < UNPACK_ROW_LENGTH.
|
||||
|
||||
template <typename TexImageSourceT>
|
||||
void TexImage2D(GLenum target, GLint level, GLenum internalFormat,
|
||||
GLenum unpackFormat, GLenum unpackType,
|
||||
const TexImageSourceT& anySrc, ErrorResult& out_error) const {
|
||||
TexImage2D(target, level, internalFormat, 0, 0, 0, unpackFormat, unpackType,
|
||||
anySrc, out_error);
|
||||
const TexImageSourceAdapter src(&anySrc, &out_error);
|
||||
TexImage(2, target, level, internalFormat, {}, {}, 0,
|
||||
{unpackFormat, unpackType}, src);
|
||||
}
|
||||
|
||||
template <typename TexImageSourceT>
|
||||
@@ -1778,8 +1787,9 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
GLenum unpackFormat, GLenum unpackType,
|
||||
const TexImageSourceT& anySrc,
|
||||
ErrorResult& out_error) const {
|
||||
TexSubImage2D(target, level, xOffset, yOffset, 0, 0, unpackFormat,
|
||||
unpackType, anySrc, out_error);
|
||||
const TexImageSourceAdapter src(&anySrc, &out_error);
|
||||
TexImage(2, target, level, 0, {xOffset, yOffset, 0}, {}, 0,
|
||||
{unpackFormat, unpackType}, src);
|
||||
}
|
||||
|
||||
// ------------------------ Uniforms and attributes ------------------------
|
||||
|
||||
Reference in New Issue
Block a user