Diff
Modified: trunk/LayoutTests/ChangeLog (237305 => 237306)
--- trunk/LayoutTests/ChangeLog 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/LayoutTests/ChangeLog 2018-10-19 22:19:12 UTC (rev 237306)
@@ -1,3 +1,15 @@
+2018-10-19 Justin Fan <justin_...@apple.com>
+
+ [WebGPU] Add stubs for WebGPUSwapChain and WebGPURenderingContext
+ https://bugs.webkit.org/show_bug.cgi?id=190742
+
+ Reviewed by Dean Jackson.
+
+ Updated basic webgpu feature detection test to check for WebGPURenderingContext.
+
+ * webgpu/webgpu-enabled-expected.txt:
+ * webgpu/webgpu-enabled.html:
+
2018-10-19 Wenson Hsieh <wenson_hs...@apple.com>
[iOS] [Datalist] Can't pick datalist suggestions in a stock WKWebView
Modified: trunk/LayoutTests/webgpu/webgpu-enabled-expected.txt (237305 => 237306)
--- trunk/LayoutTests/webgpu/webgpu-enabled-expected.txt 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/LayoutTests/webgpu/webgpu-enabled-expected.txt 2018-10-19 22:19:12 UTC (rev 237306)
@@ -1,6 +1,4 @@
PASS [object WebGPU] is defined.
-PASS [object WebGPUAdapter] is defined.
-PASS [object WebGPUDevice] is defined.
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/webgpu/webgpu-enabled.html (237305 => 237306)
--- trunk/LayoutTests/webgpu/webgpu-enabled.html 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/LayoutTests/webgpu/webgpu-enabled.html 2018-10-19 22:19:12 UTC (rev 237306)
@@ -7,11 +7,22 @@
window.testRunner.dumpAsText();
function runTest() {
+ let canvas = document.createElement("canvas");
+ let context = canvas.getContext("webgpu");
+ if (!context)
+ testFailed("Could not create WebGPU context!");
+
shouldBeDefined(window.webgpu);
window.webgpu.requestAdapter({ powerPreference: "default" }).then(adapter => {
- shouldBeDefined(adapter);
+ if (!adapter) {
+ testFailed("Could not create default WebGPUAdapter!")
+ return;
+ }
let defaultDevice = adapter.createDevice();
- shouldBeDefined(defaultDevice);
+ if (!defaultDevice) {
+ testFailed("Could not create WebGPUDevice!");
+ return;
+ }
}).catch(error => {
testFailed(error);
});
Modified: trunk/Source/WebCore/CMakeLists.txt (237305 => 237306)
--- trunk/Source/WebCore/CMakeLists.txt 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/CMakeLists.txt 2018-10-19 22:19:12 UTC (rev 237306)
@@ -451,6 +451,9 @@
Modules/webgpu/WebGPUAdapter.idl
Modules/webgpu/WebGPUAdapterDescriptor.idl
Modules/webgpu/WebGPUDevice.idl
+ Modules/webgpu/WebGPURenderingContext.idl
+ Modules/webgpu/WebGPUSwapChain.idl
+ Modules/webgpu/WebGPUSwapChainDescriptor.idl
Modules/websockets/CloseEvent.idl
Modules/websockets/WebSocket.idl
Modified: trunk/Source/WebCore/ChangeLog (237305 => 237306)
--- trunk/Source/WebCore/ChangeLog 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/ChangeLog 2018-10-19 22:19:12 UTC (rev 237306)
@@ -1,3 +1,48 @@
+2018-10-19 Justin Fan <justin_...@apple.com>
+
+ [WebGPU] Add stubs for WebGPUSwapChain and WebGPURenderingContext
+ https://bugs.webkit.org/show_bug.cgi?id=190742
+
+ Reviewed by Dean Jackson.
+
+ Test: updated webgpu-enabled.html to check for WebGPURenderingContext.
+
+ Implement support for creating a "webgpu" context from an HTML canvas.
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * Modules/webgpu/WebGPURenderingContext.cpp: Added.
+ (WebCore::WebGPURenderingContext::create):
+ (WebCore::WebGPURenderingContext::WebGPURenderingContext):
+ * Modules/webgpu/WebGPURenderingContext.h: Added.
+ * Modules/webgpu/WebGPURenderingContext.idl: Added.
+ * Modules/webgpu/WebGPUSwapChain.cpp: Added.
+ (WebCore::WebGPUSwapChain::configure):
+ (WebCore::WebGPUSwapChain::present):
+ (WebCore::WebGPUSwapChain::reshape):
+ (WebCore::WebGPUSwapChain::markLayerComposited):
+ * Modules/webgpu/WebGPUSwapChain.h: Added.
+ (WebCore::WebGPUSwapChain::WebGPUSwapChain):
+ * Modules/webgpu/WebGPUSwapChain.idl: Added.
+ * Modules/webgpu/WebGPUSwapChainDescriptor.h: Added.
+ * Modules/webgpu/WebGPUSwapChainDescriptor.idl: Added.
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/WebCoreBuiltinNames.h:
+ * dom/Document.cpp:
+ (WebCore::Document::getCSSCanvasContext):
+ * dom/Document.h:
+ * dom/Document.idl:
+ * html/HTMLCanvasElement.cpp:
+ (WebCore::HTMLCanvasElement::getContext):
+ (WebCore::HTMLCanvasElement::isWebGPUType):
+ (WebCore::HTMLCanvasElement::createContextWebGPU):
+ (WebCore::HTMLCanvasElement::getContextWebGPU):
+ * html/HTMLCanvasElement.h:
+ * html/HTMLCanvasElement.idl:
+ * html/canvas/CanvasRenderingContext.h:
+ (WebCore::CanvasRenderingContext::isWebGPU const):
+
2018-10-19 John Wilander <wilan...@apple.com>
Only cap lifetime of persistent cookies created client-side through document.cookie when resource load statistics is enabled
Modified: trunk/Source/WebCore/DerivedSources.make (237305 => 237306)
--- trunk/Source/WebCore/DerivedSources.make 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/DerivedSources.make 2018-10-19 22:19:12 UTC (rev 237306)
@@ -372,6 +372,9 @@
$(WebCore)/Modules/webgpu/WebGPUAdapter.idl \
$(WebCore)/Modules/webgpu/WebGPUAdapterDescriptor.idl \
$(WebCore)/Modules/webgpu/WebGPUDevice.idl \
+ $(WebCore)/Modules/webgpu/WebGPURenderingContext.idl \
+ $(WebCore)/Modules/webgpu/WebGPUSwapChain.idl \
+ $(WebCore)/Modules/webgpu/WebGPUSwapChainDescriptor.idl \
$(WebCore)/Modules/websockets/CloseEvent.idl \
$(WebCore)/Modules/websockets/WebSocket.idl \
$(WebCore)/Modules/webvr/DOMWindowWebVR.idl \
Added: trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.cpp (0 => 237306)
--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.cpp 2018-10-19 22:19:12 UTC (rev 237306)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2018 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#include "config.h"
+#include "WebGPURenderingContext.h"
+
+#if ENABLE(WEBGPU)
+
+namespace WebCore {
+
+std::unique_ptr<WebGPURenderingContext> WebGPURenderingContext::create(CanvasBase& canvas)
+{
+ auto context = std::unique_ptr<WebGPURenderingContext>(new WebGPURenderingContext(canvas));
+ context->suspendIfNeeded();
+ return context;
+}
+
+WebGPURenderingContext::WebGPURenderingContext(CanvasBase& canvas)
+ : WebGPUSwapChain(canvas)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)
Added: trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.h (0 => 237306)
--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.h (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.h 2018-10-19 22:19:12 UTC (rev 237306)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2018 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. AND ITS CONTRIBUTORS ``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 ITS 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(WEBGPU)
+
+#include "WebGPUSwapChain.h"
+
+namespace WebCore {
+
+class WebGPURenderingContext final : public WebGPUSwapChain {
+public:
+ static std::unique_ptr<WebGPURenderingContext> create(CanvasBase&);
+
+private:
+ WebGPURenderingContext(CanvasBase&);
+ // CanvasRenderingContext
+ bool isWebGPU() const final { return true; }
+ // ActiveDOMObject
+ const char* activeDOMObjectName() const final { return "WebGPURenderingContext"; }
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::WebGPURenderingContext, isWebGPU())
+
+#endif // ENABLE(WEBGPU)
Added: trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.idl (0 => 237306)
--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.idl (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.idl 2018-10-19 22:19:12 UTC (rev 237306)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2018 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
+
+[
+ Conditional=WEBGPU,
+ EnabledAtRuntime=WebGPU
+] interface WebGPURenderingContext : WebGPUSwapChain {
+};
Added: trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.cpp (0 => 237306)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.cpp 2018-10-19 22:19:12 UTC (rev 237306)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#include "config.h"
+#include "WebGPUSwapChain.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WebGPUSwapChainDescriptor.h"
+
+namespace WebCore {
+
+WebGPUSwapChain::~WebGPUSwapChain() = default;
+
+void WebGPUSwapChain::configure(const WebGPUSwapChainDescriptor& descriptor)
+{
+ reshape(descriptor.width, descriptor.height);
+}
+
+void WebGPUSwapChain::present()
+{
+ markLayerComposited();
+}
+
+void WebGPUSwapChain::reshape(int width, int height)
+{
+ m_width = width;
+ m_height = height;
+}
+
+void WebGPUSwapChain::markLayerComposited()
+{
+ // FIXME: Unimplemented stub.
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)
Added: trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.h (0 => 237306)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.h (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.h 2018-10-19 22:19:12 UTC (rev 237306)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2018 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. AND ITS CONTRIBUTORS ``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 ITS 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(WEBGPU)
+
+#include "GPUBasedCanvasRenderingContext.h"
+
+namespace WebCore {
+
+struct WebGPUSwapChainDescriptor;
+
+class WebGPUSwapChain : public GPUBasedCanvasRenderingContext {
+public:
+ virtual ~WebGPUSwapChain() = 0;
+ void configure(const WebGPUSwapChainDescriptor&);
+ // FIXME: WebGPUTexture getNextTexture();
+ void present();
+
+protected:
+ WebGPUSwapChain(CanvasBase& canvas)
+ : GPUBasedCanvasRenderingContext(canvas)
+ {
+ }
+
+ const char* activeDOMObjectName() const override { return "WebGPUSwapChain"; }
+
+private:
+ // GPUBasedRenderingContext
+ void reshape(int width, int height) final;
+ void markLayerComposited() final;
+
+ // ActiveDOMObject
+ // FIXME: Stubs.
+ bool hasPendingActivity() const override { return false; }
+ void stop() override { }
+ bool canSuspendForDocumentSuspension() const override { return false; }
+
+ unsigned long m_width;
+ unsigned long m_height;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)
Added: trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.idl (0 => 237306)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.idl (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.idl 2018-10-19 22:19:12 UTC (rev 237306)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2018 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
+
+[
+ Conditional=WEBGPU,
+ EnabledAtRuntime=WebGPU,
+ SkipVTableValidation
+] interface WebGPUSwapChain {
+ void configure(WebGPUSwapChainDescriptor descriptor);
+ // WebGPUTexture getNextTexture();
+ void present();
+};
Added: trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChainDescriptor.h (0 => 237306)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChainDescriptor.h (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChainDescriptor.h 2018-10-19 22:19:12 UTC (rev 237306)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2018 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. AND ITS CONTRIBUTORS ``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 ITS 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(WEBGPU)
+
+namespace WebCore {
+
+struct WebGPUSwapChainDescriptor {
+ // FIXME: More texture properties.
+ unsigned long width;
+ unsigned long height;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)
Added: trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChainDescriptor.idl (0 => 237306)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChainDescriptor.idl (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChainDescriptor.idl 2018-10-19 22:19:12 UTC (rev 237306)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
+
+typedef unsigned long u32;
+
+[
+ Conditional=WEBGPU,
+ EnabledAtRuntime=WebGPU
+] dictionary WebGPUSwapChainDescriptor {
+ // WebGPUTextureUsageFlags usage;
+ // WebGPUTextureFormatEnum format;
+ u32 width;
+ u32 height;
+};
Modified: trunk/Source/WebCore/Sources.txt (237305 => 237306)
--- trunk/Source/WebCore/Sources.txt 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/Sources.txt 2018-10-19 22:19:12 UTC (rev 237306)
@@ -299,6 +299,8 @@
Modules/webgpu/WebGPU.cpp
Modules/webgpu/WebGPUAdapter.cpp
Modules/webgpu/WebGPUDevice.cpp
+Modules/webgpu/WebGPURenderingContext.cpp
+Modules/webgpu/WebGPUSwapChain.cpp
Modules/webvr/NavigatorWebVR.cpp
Modules/webvr/VRDisplay.cpp
@@ -3175,6 +3177,9 @@
JSWebGPUAdapter.cpp
JSWebGPUAdapterDescriptor.cpp
JSWebGPUDevice.cpp
+JSWebGPURenderingContext.cpp
+JSWebGPUSwapChain.cpp
+JSWebGPUSwapChainDescriptor.cpp
JSWebMetalBuffer.cpp
JSWebMetalCommandBuffer.cpp
JSWebMetalCommandQueue.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (237305 => 237306)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-10-19 22:19:12 UTC (rev 237306)
@@ -13754,6 +13754,9 @@
D0843A4C20FEC16500FE860E /* GraphicsContext3DManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DManager.cpp; sourceTree = "<group>"; };
D086FE9609D53AAB005BC74D /* UnlinkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkCommand.h; sourceTree = "<group>"; };
D086FE9709D53AAB005BC74D /* UnlinkCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnlinkCommand.cpp; sourceTree = "<group>"; };
+ D093D225217951D400329217 /* WebGPURenderingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPURenderingContext.h; sourceTree = "<group>"; };
+ D093D227217951D400329217 /* WebGPURenderingContext.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPURenderingContext.idl; sourceTree = "<group>"; };
+ D093D2292179541600329217 /* WebGPURenderingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPURenderingContext.cpp; sourceTree = "<group>"; };
D0A20D542092A0A600E0C259 /* WebGLCompressedTextureASTC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLCompressedTextureASTC.h; sourceTree = "<group>"; };
D0A20D562092A0A600E0C259 /* WebGLCompressedTextureASTC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLCompressedTextureASTC.cpp; sourceTree = "<group>"; };
D0A3A7301405A39800FB8ED3 /* ResourceLoaderOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoaderOptions.h; sourceTree = "<group>"; };
@@ -13768,6 +13771,11 @@
D0CAAE9C216824A7001C91C7 /* WebMetalComputeCommandEncoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebMetalComputeCommandEncoder.cpp; sourceTree = "<group>"; };
D0CAAE9D216824A7001C91C7 /* WebMetalBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebMetalBuffer.h; sourceTree = "<group>"; };
D0CAAE9E216824A8001C91C7 /* WebMetalCommandBuffer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebMetalCommandBuffer.cpp; sourceTree = "<group>"; };
+ D0DA0BE4217930E2007FE2AC /* WebGPUSwapChain.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUSwapChain.h; sourceTree = "<group>"; };
+ D0DA0BE5217930E2007FE2AC /* WebGPUSwapChain.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUSwapChain.cpp; sourceTree = "<group>"; };
+ D0DA0BE6217930E2007FE2AC /* WebGPUSwapChain.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUSwapChain.idl; sourceTree = "<group>"; };
+ D0DA0BE821793B56007FE2AC /* WebGPUSwapChainDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUSwapChainDescriptor.h; sourceTree = "<group>"; };
+ D0DA0BE921793B56007FE2AC /* WebGPUSwapChainDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUSwapChainDescriptor.idl; sourceTree = "<group>"; };
D0EDA772143E303C0028E383 /* CachedRawResource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedRawResource.cpp; sourceTree = "<group>"; };
D0EDA773143E303C0028E383 /* CachedRawResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedRawResource.h; sourceTree = "<group>"; };
D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PingLoader.cpp; sourceTree = "<group>"; };
@@ -25359,6 +25367,14 @@
D00F595321701D8C000D71DB /* WebGPUDevice.cpp */,
D00F595221701D8C000D71DB /* WebGPUDevice.h */,
D00F595421701D8C000D71DB /* WebGPUDevice.idl */,
+ D093D2292179541600329217 /* WebGPURenderingContext.cpp */,
+ D093D225217951D400329217 /* WebGPURenderingContext.h */,
+ D093D227217951D400329217 /* WebGPURenderingContext.idl */,
+ D0DA0BE5217930E2007FE2AC /* WebGPUSwapChain.cpp */,
+ D0DA0BE4217930E2007FE2AC /* WebGPUSwapChain.h */,
+ D0DA0BE6217930E2007FE2AC /* WebGPUSwapChain.idl */,
+ D0DA0BE821793B56007FE2AC /* WebGPUSwapChainDescriptor.h */,
+ D0DA0BE921793B56007FE2AC /* WebGPUSwapChainDescriptor.idl */,
);
path = webgpu;
sourceTree = "<group>";
Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (237305 => 237306)
--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2018-10-19 22:19:12 UTC (rev 237306)
@@ -177,6 +177,9 @@
macro(WebGPUAdapter) \
macro(WebGPUAdapterDescriptor) \
macro(WebGPUDevice) \
+ macro(WebGPURenderingContext) \
+ macro(WebGPUSwapChain) \
+ macro(WebGPUSwapChainDescriptor) \
macro(WebMetalBuffer) \
macro(WebMetalCommandBuffer) \
macro(WebMetalCommandQueue) \
Modified: trunk/Source/WebCore/dom/Document.cpp (237305 => 237306)
--- trunk/Source/WebCore/dom/Document.cpp 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/dom/Document.cpp 2018-10-19 22:19:12 UTC (rev 237306)
@@ -310,6 +310,9 @@
#if ENABLE(WEBGL2)
#include "WebGL2RenderingContext.h"
#endif
+#if ENABLE(WEBGPU)
+#include "WebGPURenderingContext.h"
+#endif
#if ENABLE(WEBMETAL)
#include "WebMetalRenderingContext.h"
#endif
@@ -5887,6 +5890,10 @@
if (is<WebGL2RenderingContext>(*context))
return RenderingContext { RefPtr<WebGL2RenderingContext> { &downcast<WebGL2RenderingContext>(*context) } };
#endif
+#if ENABLE(WEBGPU)
+ if (is<WebGPURenderingContext>(*context))
+ return RenderingContext { RefPtr<WebGPURenderingContext> { &downcast<WebGPURenderingContext>(*context) } };
+#endif
#if ENABLE(WEBMETAL)
if (is<WebMetalRenderingContext>(*context))
return RenderingContext { RefPtr<WebMetalRenderingContext> { &downcast<WebMetalRenderingContext>(*context) } };
Modified: trunk/Source/WebCore/dom/Document.h (237305 => 237306)
--- trunk/Source/WebCore/dom/Document.h 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/dom/Document.h 2018-10-19 22:19:12 UTC (rev 237306)
@@ -191,6 +191,7 @@
class WebAnimation;
class WebGL2RenderingContext;
class WebGLRenderingContext;
+class WebGPURenderingContext;
class WebMetalRenderingContext;
class WindowProxy;
class XPathEvaluator;
@@ -318,6 +319,9 @@
#if ENABLE(WEBGL2)
RefPtr<WebGL2RenderingContext>,
#endif
+#if ENABLE(WEBGPU)
+ RefPtr<WebGPURenderingContext>,
+#endif
#if ENABLE(WEBMETAL)
RefPtr<WebMetalRenderingContext>,
#endif
Modified: trunk/Source/WebCore/dom/Document.idl (237305 => 237306)
--- trunk/Source/WebCore/dom/Document.idl 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/dom/Document.idl 2018-10-19 22:19:12 UTC (rev 237306)
@@ -25,6 +25,9 @@
#if defined(ENABLE_WEBGL2) && ENABLE_WEBGL2
WebGL2RenderingContext or
#endif
+#if defined(ENABLE_WEBGPU) && ENABLE_WEBGPU
+ WebGPURenderingContext or
+#endif
#if defined(ENABLE_WEBMETAL) && ENABLE_WEBMETAL
WebMetalRenderingContext or
#endif
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (237305 => 237306)
--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2018-10-19 22:19:12 UTC (rev 237306)
@@ -75,6 +75,10 @@
#include "WebGL2RenderingContext.h"
#endif
+#if ENABLE(WEBGPU)
+#include "WebGPURenderingContext.h"
+#endif
+
#if ENABLE(WEBMETAL)
#include "WebMetalRenderingContext.h"
#endif
@@ -238,6 +242,14 @@
}
#endif
+#if ENABLE(WEBGPU)
+ if (m_context->isWebGPU()) {
+ if (!isWebGPUType(contextId))
+ return std::optional<RenderingContext> { std::nullopt };
+ return std::optional<RenderingContext> { RefPtr<WebGPURenderingContext> { &downcast<WebGPURenderingContext>(*m_context) } };
+ }
+#endif
+
#if ENABLE(WEBMETAL)
if (m_context->isWebMetal()) {
if (!isWebMetalType(contextId))
@@ -287,6 +299,15 @@
}
#endif
+#if ENABLE(WEBGPU)
+ if (isWebGPUType(contextId)) {
+ auto context = createContextWebGPU(contextId);
+ if (!context)
+ return std::optional<RenderingContext> { std::nullopt };
+ return std::optional<RenderingContext> { RefPtr<WebGPURenderingContext> { context } };
+ }
+#endif
+
#if ENABLE(WEBMETAL)
if (isWebMetalType(contextId)) {
auto context = createContextWebMetal(contextId);
@@ -317,6 +338,11 @@
return getContextWebGL(type);
#endif
+#if ENABLE(WEBGPU)
+ if (HTMLCanvasElement::isWebGPUType(type))
+ return getContextWebGPU(type);
+#endif
+
return nullptr;
}
@@ -437,6 +463,47 @@
#endif // ENABLE(WEBGL)
+#if ENABLE(WEBGPU)
+
+bool HTMLCanvasElement::isWebGPUType(const String& type)
+{
+ return type == "webgpu";
+}
+
+WebGPURenderingContext* HTMLCanvasElement::createContextWebGPU(const String& type)
+{
+ ASSERT_UNUSED(type, HTMLCanvasElement::isWebGPUType(type));
+ ASSERT(!m_context);
+
+ if (!RuntimeEnabledFeatures::sharedFeatures().webGPUEnabled())
+ return nullptr;
+
+ m_context = WebGPURenderingContext::create(*this);
+ if (m_context) {
+ // Need to make sure a RenderLayer and compositing layer get created for the Canvas.
+ invalidateStyleAndLayerComposition();
+ }
+
+ return static_cast<WebGPURenderingContext*>(m_context.get());
+}
+
+WebGPURenderingContext* HTMLCanvasElement::getContextWebGPU(const String& type)
+{
+ ASSERT_UNUSED(type, HTMLCanvasElement::isWebGPUType(type));
+
+ if (!RuntimeEnabledFeatures::sharedFeatures().webGPUEnabled())
+ return nullptr;
+
+ if (m_context && !m_context->isWebGPU())
+ return nullptr;
+
+ if (!m_context)
+ return createContextWebGPU(type);
+ return static_cast<WebGPURenderingContext*>(m_context.get());
+}
+
+#endif // ENABLE(WEBGPU)
+
#if ENABLE(WEBMETAL)
bool HTMLCanvasElement::isWebMetalType(const String& type)
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (237305 => 237306)
--- trunk/Source/WebCore/html/HTMLCanvasElement.h 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h 2018-10-19 22:19:12 UTC (rev 237306)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2018 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alp Toker <a...@atoker.com>
* Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
*
@@ -51,6 +51,7 @@
class MediaSample;
class MediaStream;
class WebGLRenderingContextBase;
+class WebGPURenderingContext;
class WebMetalRenderingContext;
struct UncachedString;
@@ -97,6 +98,11 @@
WebGLRenderingContextBase* createContextWebGL(const String&, WebGLContextAttributes&& = { });
WebGLRenderingContextBase* getContextWebGL(const String&, WebGLContextAttributes&& = { });
#endif
+#if ENABLE(WEBGPU)
+ static bool isWebGPUType(const String&);
+ WebGPURenderingContext* createContextWebGPU(const String&);
+ WebGPURenderingContext* getContextWebGPU(const String&);
+#endif
#if ENABLE(WEBMETAL)
static bool isWebMetalType(const String&);
WebMetalRenderingContext* createContextWebMetal(const String&);
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.idl (237305 => 237306)
--- trunk/Source/WebCore/html/HTMLCanvasElement.idl 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.idl 2018-10-19 22:19:12 UTC (rev 237306)
@@ -31,6 +31,9 @@
#if defined(ENABLE_WEBGL2) && ENABLE_WEBGL2
WebGL2RenderingContext or
#endif
+#if defined(ENABLE_WEBGPU) && ENABLE_WEBGPU
+ WebGPURenderingContext or
+#endif
#if defined(ENABLE_WEBMETAL) && ENABLE_WEBMETAL
WebMetalRenderingContext or
#endif
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext.h (237305 => 237306)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext.h 2018-10-19 22:00:32 UTC (rev 237305)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext.h 2018-10-19 22:19:12 UTC (rev 237306)
@@ -55,6 +55,9 @@
virtual bool isWebGL1() const { return false; }
virtual bool isWebGL2() const { return false; }
bool isWebGL() const { return isWebGL1() || isWebGL2(); }
+#if ENABLE(WEBGPU)
+ virtual bool isWebGPU() const { return false; }
+#endif
#if ENABLE(WEBMETAL)
virtual bool isWebMetal() const { return false; }
#endif