Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixel pack and unpack state is cached but also asked from the underlying context #14337

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
103 changes: 19 additions & 84 deletions Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,6 @@ void WebGL2RenderingContext::initializeNewContext()
m_boundIndexedUniformBuffers.resize(getIntParameter(GraphicsContextGL::MAX_UNIFORM_BUFFER_BINDINGS));
m_uniformBufferOffsetAlignment = getIntParameter(GraphicsContextGL::UNIFORM_BUFFER_OFFSET_ALIGNMENT);

m_packRowLength = 0;
m_packSkipPixels = 0;
m_packSkipRows = 0;
m_unpackRowLength = 0;
m_unpackImageHeight = 0;
m_unpackSkipPixels = 0;
m_unpackSkipRows = 0;
m_unpackSkipImages = 0;

m_max3DTextureSize = m_context->getInteger(GraphicsContextGL::MAX_3D_TEXTURE_SIZE);
m_max3DTextureLevel = WebGLTexture::computeLevelCount(m_max3DTextureSize, m_max3DTextureSize);
m_maxArrayTextureLayers = m_context->getInteger(GraphicsContextGL::MAX_ARRAY_TEXTURE_LAYERS);
Expand All @@ -190,38 +181,6 @@ void WebGL2RenderingContext::initializeNewContext()
m_boundSamplers.resize(m_textureUnits.size());
}

void WebGL2RenderingContext::resetUnpackParameters()
{
WebGLRenderingContextBase::resetUnpackParameters();

if (m_unpackRowLength)
m_context->pixelStorei(GraphicsContextGL::UNPACK_ROW_LENGTH, 0);
if (m_unpackImageHeight)
m_context->pixelStorei(GraphicsContextGL::UNPACK_IMAGE_HEIGHT, 0);
if (m_unpackSkipPixels)
m_context->pixelStorei(GraphicsContextGL::UNPACK_SKIP_PIXELS, 0);
if (m_unpackSkipRows)
m_context->pixelStorei(GraphicsContextGL::UNPACK_SKIP_ROWS, 0);
if (m_unpackSkipImages)
m_context->pixelStorei(GraphicsContextGL::UNPACK_SKIP_IMAGES, 0);
}

void WebGL2RenderingContext::restoreUnpackParameters()
{
WebGLRenderingContextBase::restoreUnpackParameters();

if (m_unpackRowLength)
m_context->pixelStorei(GraphicsContextGL::UNPACK_ROW_LENGTH, m_unpackRowLength);
if (m_unpackImageHeight)
m_context->pixelStorei(GraphicsContextGL::UNPACK_IMAGE_HEIGHT, m_unpackImageHeight);
if (m_unpackSkipPixels)
m_context->pixelStorei(GraphicsContextGL::UNPACK_SKIP_PIXELS, m_unpackSkipPixels);
if (m_unpackSkipRows)
m_context->pixelStorei(GraphicsContextGL::UNPACK_SKIP_ROWS, m_unpackSkipRows);
if (m_unpackSkipImages)
m_context->pixelStorei(GraphicsContextGL::UNPACK_SKIP_IMAGES, m_unpackSkipImages);
}

long long WebGL2RenderingContext::getInt64Parameter(GCGLenum pname)
{
return m_context->getInteger64(pname);
Expand Down Expand Up @@ -409,7 +368,7 @@ bool WebGL2RenderingContext::validateAndCacheBufferBinding(const AbstractLocker&

IntRect WebGL2RenderingContext::getTextureSourceSubRectangle(GCGLsizei width, GCGLsizei height)
{
return IntRect(m_unpackSkipPixels, m_unpackSkipRows, width, height);
return IntRect(m_unpackParameters.skipPixels, m_unpackParameters.skipRows, width, height);
}

RefPtr<WebGLTexture> WebGL2RenderingContext::validateTexImageBinding(TexImageFunctionID functionID, GCGLenum target)
Expand Down Expand Up @@ -563,28 +522,28 @@ void WebGL2RenderingContext::pixelStorei(GCGLenum pname, GCGLint param)
}
switch (pname) {
case GraphicsContextGL::PACK_ROW_LENGTH:
m_packRowLength = param;
m_packParameters.rowLength = param;
break;
case GraphicsContextGL::PACK_SKIP_PIXELS:
m_packSkipPixels = param;
m_packParameters.skipPixels = param;
break;
case GraphicsContextGL::PACK_SKIP_ROWS:
m_packSkipRows = param;
m_packParameters.skipRows = param;
break;
case GraphicsContextGL::UNPACK_ROW_LENGTH:
m_unpackRowLength = param;
m_unpackParameters.rowLength = param;
break;
case GraphicsContextGL::UNPACK_IMAGE_HEIGHT:
m_unpackImageHeight = param;
m_unpackParameters.imageHeight = param;
break;
case GraphicsContextGL::UNPACK_SKIP_PIXELS:
m_unpackSkipPixels = param;
m_unpackParameters.skipPixels = param;
break;
case GraphicsContextGL::UNPACK_SKIP_ROWS:
m_unpackSkipRows = param;
m_unpackParameters.skipRows = param;
break;
case GraphicsContextGL::UNPACK_SKIP_IMAGES:
m_unpackSkipImages = param;
m_unpackParameters.skipImages = param;
break;
default:
WebGLRenderingContextBase::pixelStorei(pname, param);
Expand Down Expand Up @@ -1015,7 +974,7 @@ ExceptionOr<void> WebGL2RenderingContext::texImage3D(GCGLenum target, GCGLint le
return { };
}

return WebGLRenderingContextBase::texImageSourceHelper(TexImageFunctionID::TexImage3D, target, level, internalformat, border, format, type, 0, 0, 0, getTextureSourceSubRectangle(width, height), depth, m_unpackImageHeight, WTFMove(source));
return WebGLRenderingContextBase::texImageSourceHelper(TexImageFunctionID::TexImage3D, target, level, internalformat, border, format, type, 0, 0, 0, getTextureSourceSubRectangle(width, height), depth, m_unpackParameters.imageHeight, WTFMove(source));
}

void WebGL2RenderingContext::texImage3D(GCGLenum target, GCGLint level, GCGLint internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, GCGLenum format, GCGLenum type, RefPtr<ArrayBufferView>&& srcData)
Expand Down Expand Up @@ -1161,7 +1120,7 @@ ExceptionOr<void> WebGL2RenderingContext::texSubImage3D(GCGLenum target, GCGLint
return { };
}

return WebGLRenderingContextBase::texImageSourceHelper(TexImageFunctionID::TexSubImage3D, target, level, 0, 0, format, type, xoffset, yoffset, zoffset, getTextureSourceSubRectangle(width, height), depth, m_unpackImageHeight, WTFMove(source));
return WebGLRenderingContextBase::texImageSourceHelper(TexImageFunctionID::TexSubImage3D, target, level, 0, 0, format, type, xoffset, yoffset, zoffset, getTextureSourceSubRectangle(width, height), depth, m_unpackParameters.imageHeight, WTFMove(source));
}

void WebGL2RenderingContext::copyTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
Expand Down Expand Up @@ -2998,30 +2957,6 @@ GCGLuint WebGL2RenderingContext::maxTransformFeedbackSeparateAttribs() const
return m_maxTransformFeedbackSeparateAttribs;
}

WebGLRenderingContextBase::PixelStoreParams WebGL2RenderingContext::getPackPixelStoreParams() const
{
PixelStoreParams params;
params.alignment = m_packAlignment;
params.rowLength = m_packRowLength;
params.skipPixels = m_packSkipPixels;
params.skipRows = m_packSkipRows;
return params;
}

WebGLRenderingContextBase::PixelStoreParams WebGL2RenderingContext::getUnpackPixelStoreParams(TexImageDimension dimension) const
{
PixelStoreParams params;
params.alignment = m_unpackAlignment;
params.rowLength = m_unpackRowLength;
params.skipPixels = m_unpackSkipPixels;
params.skipRows = m_unpackSkipRows;
if (dimension == TexImageDimension::Tex3D) {
params.imageHeight = m_unpackImageHeight;
params.skipImages = m_unpackSkipImages;
}
return params;
}

bool WebGL2RenderingContext::checkAndTranslateAttachments(const char* functionName, GCGLenum target, Vector<GCGLenum>& attachments)
{
if (!validateFramebufferTarget(target)) {
Expand Down Expand Up @@ -3158,11 +3093,11 @@ WebGLAny WebGL2RenderingContext::getParameter(GCGLenum pname)
case GraphicsContextGL::MIN_PROGRAM_TEXEL_OFFSET:
return getIntParameter(pname);
case GraphicsContextGL::PACK_ROW_LENGTH:
return getIntParameter(pname);
return m_packParameters.rowLength;
case GraphicsContextGL::PACK_SKIP_PIXELS:
return getIntParameter(pname);
return m_packParameters.skipPixels;
case GraphicsContextGL::PACK_SKIP_ROWS:
return getIntParameter(pname);
return m_packParameters.skipRows;
case GraphicsContextGL::PIXEL_PACK_BUFFER_BINDING:
return m_boundPixelPackBuffer;
case GraphicsContextGL::PIXEL_UNPACK_BUFFER_BINDING:
Expand Down Expand Up @@ -3196,15 +3131,15 @@ WebGLAny WebGL2RenderingContext::getParameter(GCGLenum pname)
case GraphicsContextGL::UNIFORM_BUFFER_OFFSET_ALIGNMENT:
return getIntParameter(pname);
case GraphicsContextGL::UNPACK_IMAGE_HEIGHT:
return getIntParameter(pname);
return m_unpackParameters.imageHeight;
case GraphicsContextGL::UNPACK_ROW_LENGTH:
return getIntParameter(pname);
return m_unpackParameters.rowLength;
case GraphicsContextGL::UNPACK_SKIP_IMAGES:
return getIntParameter(pname);
return m_unpackParameters.skipImages;
case GraphicsContextGL::UNPACK_SKIP_PIXELS:
return getIntParameter(pname);
return m_unpackParameters.skipPixels;
case GraphicsContextGL::UNPACK_SKIP_ROWS:
return getIntParameter(pname);
return m_unpackParameters.skipRows;
case GraphicsContextGL::VERTEX_ARRAY_BINDING:
if (m_boundVertexArrayObject->isDefaultObject())
return nullptr;
Expand Down
16 changes: 0 additions & 16 deletions Source/WebCore/html/canvas/WebGL2RenderingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@ class WebGL2RenderingContext final : public WebGLRenderingContextBase {

GCGLuint maxTransformFeedbackSeparateAttribs() const;

PixelStoreParams getPackPixelStoreParams() const override;
PixelStoreParams getUnpackPixelStoreParams(TexImageDimension) const override;

bool checkAndTranslateAttachments(const char* functionName, GCGLenum, Vector<GCGLenum>&);

void addMembersToOpaqueRoots(JSC::AbstractSlotVisitor&) override;
Expand All @@ -283,11 +280,6 @@ class WebGL2RenderingContext final : public WebGLRenderingContextBase {

void initializeNewContext() final;

// Set all ES 3.0 unpack parameters to their default value.
void resetUnpackParameters() final;
// Restore the client's ES 3.0 unpack parameters.
void restoreUnpackParameters() final;

RefPtr<ArrayBufferView> arrayBufferViewSliceFactory(const char* const functionName, const ArrayBufferView& data, unsigned startByte, unsigned bytelength);
RefPtr<ArrayBufferView> sliceArrayBufferView(const char* const functionName, const ArrayBufferView& data, GCGLuint srcOffset, GCGLuint length);

Expand Down Expand Up @@ -361,14 +353,6 @@ class WebGL2RenderingContext final : public WebGLRenderingContextBase {

Vector<RefPtr<WebGLSampler>> m_boundSamplers;

GCGLint m_packRowLength { 0 };
GCGLint m_packSkipPixels { 0 };
GCGLint m_packSkipRows { 0 };
GCGLint m_unpackSkipPixels { 0 };
GCGLint m_unpackSkipRows { 0 };
GCGLint m_unpackRowLength { 0 };
GCGLint m_unpackImageHeight { 0 };
GCGLint m_unpackSkipImages { 0 };
GCGLint m_uniformBufferOffsetAlignment { 0 };
GCGLuint m_maxTransformFeedbackSeparateAttribs { 0 };
GCGLint m_max3DTextureSize { 0 };
Expand Down