-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebGL default framebuffer state management should be part of WebGLRen…
…deringContext https://bugs.webkit.org/show_bug.cgi?id=263963 rdar://117788476 Reviewed by Dan Glastonbury. Move the default framebuffer dirty buffer accounting from GraphicsContextGL to WebGLDefaultFramebuffer class. This is the beginning of moving all the default framebuffer state and objects to the WebGL layer. Currently the implementation is in lower level at GraphicsContextGL level. This is work towards implementing premultipliedAlpha=false compositing. * Source/WebCore/CMakeLists.txt: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h: * Source/WebCore/html/canvas/WebGL2RenderingContext.cpp: (WebCore::WebGL2RenderingContext::initializeDefaultObjects): (WebCore::WebGL2RenderingContext::updateBuffersToAutoClear): (WebCore::WebGL2RenderingContext::initializeVertexArrayObjects): Deleted. * Source/WebCore/html/canvas/WebGL2RenderingContext.h: * Source/WebCore/html/canvas/WebGLDefaultFramebuffer.cpp: Added. (WebCore::WebGLDefaultFramebuffer::create): (WebCore::WebGLDefaultFramebuffer::WebGLDefaultFramebuffer): (WebCore::WebGLDefaultFramebuffer::reshape): (WebCore::WebGLDefaultFramebuffer::markBuffersClear): (WebCore::WebGLDefaultFramebuffer::markAllUnpreservedBuffersDirty): * Source/WebCore/html/canvas/WebGLDefaultFramebuffer.h: Copied from Source/WebCore/html/canvas/WebGLRenderingContext.h. (WebCore::WebGLDefaultFramebuffer::object const): (WebCore::WebGLDefaultFramebuffer::hasStencil const): (WebCore::WebGLDefaultFramebuffer::hasDepth const): (WebCore::WebGLDefaultFramebuffer::dirtyBuffers const): * Source/WebCore/html/canvas/WebGLRenderingContext.cpp: (WebCore::WebGLRenderingContext::initializeDefaultObjects): (WebCore::WebGLRenderingContext::initializeVertexArrayObjects): Deleted. * Source/WebCore/html/canvas/WebGLRenderingContext.h: * Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp: (WebCore::ScopedDisableRasterizerDiscard::ScopedDisableRasterizerDiscard): (WebCore::ScopedDisableRasterizerDiscard::~ScopedDisableRasterizerDiscard): (WebCore::ScopedEnableBackbuffer::ScopedEnableBackbuffer): (WebCore::ScopedEnableBackbuffer::~ScopedEnableBackbuffer): (WebCore::WebGLRenderingContextBase::initializeNewContext): (WebCore::WebGLRenderingContextBase::initializeContextState): (WebCore::WebGLRenderingContextBase::initializeDefaultObjects): (WebCore::WebGLRenderingContextBase::markContextChangedAndNotifyCanvasObserver): (WebCore::WebGLRenderingContextBase::clearIfComposited): (WebCore::WebGLRenderingContextBase::reshape): (WebCore::WebGLRenderingContextBase::setFramebuffer): (WebCore::WebGLRenderingContextBase::prepareForDisplay): (WebCore::WebGLRenderingContextBase::restoreStateAfterClear): Deleted. * Source/WebCore/html/canvas/WebGLRenderingContextBase.h: * Source/WebCore/platform/graphics/GraphicsContextGL.cpp: (WebCore::GraphicsContextGL::markContextChanged): Deleted. (WebCore::GraphicsContextGL::setBuffersToAutoClear): Deleted. (WebCore::GraphicsContextGL::getBuffersToAutoClear const): Deleted. (WebCore::GraphicsContextGL::markLayerComposited): Deleted. * Source/WebCore/platform/graphics/GraphicsContextGL.h: * Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp: (WebCore::GraphicsContextGLANGLE::reshape): * Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm: (WebCore::GraphicsContextGLCocoa::prepareForDisplayWithFinishedSignal): * Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.cpp: (WebCore::GraphicsContextGLGBM::prepareForDisplay): * Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp: (WebCore::GraphicsContextGLTextureMapperANGLE::prepareForDisplay): * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp: (WebKit::RemoteGraphicsContextGL::markContextChanged): Deleted. * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h: * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in: * Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp: (WebKit::RemoteGraphicsContextGLProxy::markContextChanged): Deleted. * Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h: * Source/WebKit/WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm: * Source/WebKit/WebProcess/GPU/graphics/gbm/RemoteGraphicsContextGLProxyGBM.cpp: (WebKit::RemoteGraphicsContextGLProxyGBM::prepareForDisplay): * Source/WebKit/WebProcess/GPU/graphics/wc/RemoteGraphicsContextGLProxyWC.cpp: * Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm: (TestWebKitAPI::changeContextContents): (TestWebKitAPI::TEST_P): Canonical link: https://commits.webkit.org/270263@main
- Loading branch information
1 parent
681701c
commit f4b3b4b
Showing
26 changed files
with
245 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
#include "config.h" | ||
|
||
#if ENABLE(WEBGL) | ||
#include "WebGLDefaultFramebuffer.h" | ||
|
||
namespace WebCore { | ||
|
||
std::unique_ptr<WebGLDefaultFramebuffer> WebGLDefaultFramebuffer::create(WebGLRenderingContextBase& context, IntSize size) | ||
{ | ||
auto instance = std::unique_ptr<WebGLDefaultFramebuffer> { new WebGLDefaultFramebuffer(context) }; | ||
instance->reshape(size); | ||
return instance; | ||
} | ||
|
||
WebGLDefaultFramebuffer::WebGLDefaultFramebuffer(WebGLRenderingContextBase& context) | ||
: m_context(context) | ||
{ | ||
auto attributes = m_context.graphicsContextGL()->contextAttributes(); | ||
m_hasStencil = attributes.stencil; | ||
m_hasDepth = attributes.depth; | ||
if (!attributes.preserveDrawingBuffer) { | ||
m_unpreservedBuffers = GraphicsContextGL::COLOR_BUFFER_BIT; | ||
if (m_hasStencil) | ||
m_unpreservedBuffers |= GraphicsContextGL::STENCIL_BUFFER_BIT; | ||
if (m_hasDepth) | ||
m_unpreservedBuffers |= GraphicsContextGL::DEPTH_BUFFER_BIT; | ||
} | ||
} | ||
|
||
void WebGLDefaultFramebuffer::reshape(IntSize size) | ||
{ | ||
m_context.graphicsContextGL()->reshape(size.width(), size.height()); | ||
} | ||
|
||
void WebGLDefaultFramebuffer::markBuffersClear(GCGLbitfield clearBuffers) | ||
{ | ||
m_dirtyBuffers &= ~clearBuffers; | ||
} | ||
|
||
void WebGLDefaultFramebuffer::markAllUnpreservedBuffersDirty() | ||
{ | ||
m_dirtyBuffers = m_unpreservedBuffers; | ||
} | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#if ENABLE(WEBGL) | ||
|
||
#include "WebGLRenderingContextBase.h" | ||
|
||
namespace WebCore { | ||
|
||
// Implementation for the WebGL context default framebuffer. | ||
class WebGLDefaultFramebuffer { | ||
WTF_MAKE_FAST_ALLOCATED; | ||
WTF_MAKE_NONCOPYABLE(WebGLDefaultFramebuffer); | ||
public: | ||
static std::unique_ptr<WebGLDefaultFramebuffer> create(WebGLRenderingContextBase&, IntSize); | ||
~WebGLDefaultFramebuffer() = default; | ||
|
||
PlatformGLObject object() const { return 0; } | ||
bool hasStencil() const { return m_hasStencil; } | ||
bool hasDepth() const { return m_hasDepth; } | ||
void reshape(IntSize); | ||
GCGLbitfield dirtyBuffers() const { return m_dirtyBuffers; } | ||
void markBuffersClear(GCGLbitfield clearBuffers); | ||
void markAllUnpreservedBuffersDirty(); | ||
|
||
private: | ||
WebGLDefaultFramebuffer(WebGLRenderingContextBase&); | ||
|
||
WebGLRenderingContextBase& m_context; | ||
GCGLbitfield m_unpreservedBuffers { 0 }; | ||
GCGLbitfield m_dirtyBuffers { 0 }; | ||
bool m_hasStencil : 1; | ||
bool m_hasDepth : 1; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.