Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebGPU] Virtualize PresentationContext
https://bugs.webkit.org/show_bug.cgi?id=250632 rdar://104270153 Reviewed by Tadeu Zagallo. PresentationContext is how we composite results into a window. Its implementation in https://bugs.webkit.org/show_bug.cgi?id=247587 is set up only for WebKit's compositing using IOSurfaces. However, it's convenient if we could have another implementation of them that could use CAMetalLayer directly, so that we could develop WebGPU without having to build all of WebCore. This patch turns PresentationContext into a base class with virtual methods, and provides two implementations of them: One for IOSurfaces, that WebKit will use, and one for CAMetalLayer. The IOSurface implementation isn't modified at all; it's simply moved from the existing implementation. This patch doesn't actually implement the CAMetalLayer implementation; this patch is already quite large without it, and I want to keep my patches small to aid reviewing. I will implement getCurrentTextureView() and present() in my next patch. No test because there is no behavior change. * Source/WebGPU/WebGPU.xcodeproj/project.pbxproj: * Source/WebGPU/WebGPU/Device.h: * Source/WebGPU/WebGPU/PresentationContext.h: (WebGPU::PresentationContext::createInvalid): (WebGPU::PresentationContext::isPresentationContextIOSurface const): (WebGPU::PresentationContext::isPresentationContextCoreAnimation const): (WebGPU::PresentationContext::create): Deleted. (WebGPU::PresentationContext::displayBuffer const): Deleted. (WebGPU::PresentationContext::drawingBuffer const): Deleted. * Source/WebGPU/WebGPU/PresentationContext.mm: (WebGPU::PresentationContext::create): (WebGPU::PresentationContext::getPreferredFormat): (WebGPU::PresentationContext::present): (WebGPU::optionsFor32BitSurface): Deleted. (WebGPU::createIOSurface): Deleted. (WebGPU::createSurfaceFromDescriptor): Deleted. (WebGPU::Device::createSurface): Deleted. (WebGPU::PresentationContext::PresentationContext): Deleted. (WebGPU::PresentationContext::nextDrawable): Deleted. (wgpuSurfaceCocoaCustomSurfaceGetDisplayBuffer): Deleted. (wgpuSurfaceCocoaCustomSurfaceGetDrawingBuffer): Deleted. * Source/WebGPU/WebGPU/PresentationContextCoreAnimation.h: Copied from Source/WebGPU/WebGPU/PresentationContext.h. (WebGPU::PresentationContextCoreAnimation::create): * Source/WebGPU/WebGPU/PresentationContextCoreAnimation.mm: Copied from Source/WebGPU/WebGPU/PresentationContext.h. (WebGPU::PresentationContextCoreAnimation::PresentationContextCoreAnimation): (WebGPU::PresentationContextCoreAnimation::configure): (WebGPU::PresentationContextCoreAnimation::present): (WebGPU::PresentationContextCoreAnimation::getCurrentTextureView): * Source/WebGPU/WebGPU/PresentationContextIOSurface.h: Copied from Source/WebGPU/WebGPU/PresentationContext.h. (WebGPU::PresentationContextIOSurface::create): (WebGPU::PresentationContextIOSurface::displayBuffer const): (WebGPU::PresentationContextIOSurface::drawingBuffer const): * Source/WebGPU/WebGPU/PresentationContextIOSurface.mm: Copied from Source/WebGPU/WebGPU/PresentationContext.mm. (WebGPU::optionsFor32BitSurface): (WebGPU::createIOSurface): (WebGPU::createSurfaceFromDescriptor): (WebGPU::PresentationContextIOSurface::PresentationContextIOSurface): (WebGPU::PresentationContextIOSurface::configure): (WebGPU::PresentationContextIOSurface::present): (WebGPU::PresentationContextIOSurface::getCurrentTextureView): (WebGPU::PresentationContextIOSurface::nextDrawable): (wgpuSurfaceCocoaCustomSurfaceGetDisplayBuffer): (wgpuSurfaceCocoaCustomSurfaceGetDrawingBuffer): Canonical link: https://commits.webkit.org/259022@main
- Loading branch information
Showing
8 changed files
with
362 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2021-2022 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 | ||
|
||
#import "PresentationContext.h" | ||
|
||
namespace WebGPU { | ||
|
||
class Device; | ||
class TextureView; | ||
|
||
class PresentationContextCoreAnimation : public PresentationContext { | ||
WTF_MAKE_FAST_ALLOCATED; | ||
public: | ||
static Ref<PresentationContextCoreAnimation> create(const WGPUSurfaceDescriptor& descriptor) | ||
{ | ||
return adoptRef(*new PresentationContextCoreAnimation(descriptor)); | ||
} | ||
|
||
virtual ~PresentationContextCoreAnimation(); | ||
|
||
void configure(Device&, const WGPUSwapChainDescriptor&) override; | ||
|
||
void present() override; | ||
TextureView* getCurrentTextureView() override; // FIXME: This should return a TextureView&. | ||
|
||
bool isPresentationContextCoreAnimation() const override { return true; } | ||
|
||
private: | ||
PresentationContextCoreAnimation(const WGPUSurfaceDescriptor&); | ||
}; | ||
|
||
} // namespace WebGPU | ||
|
||
SPECIALIZE_TYPE_TRAITS_WEBGPU_PRESENTATION_CONTEXT(PresentationContextCoreAnimation, isPresentationContextCoreAnimation()); |
Oops, something went wrong.