Skip to content
Permalink
Browse files
Fix clearIfComposited for indexed color write masks
https://bugs.webkit.org/show_bug.cgi?id=241511

Patch by Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> on 2022-06-13
Reviewed by Kimmo Kinnunen.

Implicit clears must correctly restore color write mask state.

* Source/WebCore/html/canvas/OESDrawBuffersIndexed.cpp:
(WebCore::OESDrawBuffersIndexed::colorMaskiOES):
* Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::clearIfComposited):
(WebCore::WebGLRenderingContextBase::restoreStateAfterClear):
* Source/WebCore/html/canvas/WebGLRenderingContextBase.h:

Canonical link: https://commits.webkit.org/251490@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295485 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
lexaknyazev authored and webkit-commit-queue committed Jun 13, 2022
1 parent 1fdca14 commit 079a232dc08adf3a0db860f0ed7044eb6c18d772
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
@@ -105,6 +105,14 @@ void OESDrawBuffersIndexed::colorMaskiOES(GCGLuint buf, GCGLboolean red, GCGLboo
if (!m_context || m_context->isContextLost())
return;

// Used in WebGLRenderingContextBase::clearIfComposited
if (!buf) {
m_context->m_colorMask[0] = red;
m_context->m_colorMask[1] = green;
m_context->m_colorMask[2] = blue;
m_context->m_colorMask[3] = alpha;
}

m_context->graphicsContextGL()->colorMaskiOES(buf, red, green, blue, alpha);
}

@@ -1361,7 +1361,10 @@ bool WebGLRenderingContextBase::clearIfComposited(WebGLRenderingContextBase::Cle
m_colorMask[3] ? m_clearColor[3] : 0);
} else
m_context->clearColor(0, 0, 0, 0);
m_context->colorMask(true, true, true, true);
if (m_oesDrawBuffersIndexed)
m_context->colorMaskiOES(0, true, true, true, true);
else
m_context->colorMask(true, true, true, true);
GCGLbitfield clearMask = GraphicsContextGL::COLOR_BUFFER_BIT;
if (contextAttributes.depth) {
if (!combinedClear || !m_depthMask || !(mask & GraphicsContextGL::DEPTH_BUFFER_BIT))
@@ -1405,8 +1408,10 @@ void WebGLRenderingContextBase::restoreStateAfterClear()
m_context->enable(GraphicsContextGL::SCISSOR_TEST);
m_context->clearColor(m_clearColor[0], m_clearColor[1],
m_clearColor[2], m_clearColor[3]);
m_context->colorMask(m_colorMask[0], m_colorMask[1],
m_colorMask[2], m_colorMask[3]);
if (m_oesDrawBuffersIndexed)
m_context->colorMaskiOES(0, m_colorMask[0], m_colorMask[1], m_colorMask[2], m_colorMask[3]);
else
m_context->colorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], m_colorMask[3]);
m_context->clearDepth(m_clearDepth);
m_context->clearStencil(m_clearStencil);
m_context->stencilMaskSeparate(GraphicsContextGL::FRONT, m_stencilMask);
@@ -446,6 +446,7 @@ class WebGLRenderingContextBase : public GraphicsContextGL::Client, public GPUBa

friend class EXTTextureCompressionBPTC;
friend class EXTTextureCompressionRGTC;
friend class OESDrawBuffersIndexed;
friend class OESVertexArrayObject;
friend class WebGLCompressedTextureASTC;
friend class WebGLCompressedTextureATC;

0 comments on commit 079a232

Please sign in to comment.