Title: [239036] trunk/Source/WebCore
Revision
239036
Author
[email protected]
Date
2018-12-10 11:37:49 -0800 (Mon, 10 Dec 2018)

Log Message

[iOS] Make WebGPU work with remote layer hosting
https://bugs.webkit.org/show_bug.cgi?id=192508
<rdar://problem/46560649>

Reviewed by Tim Horton.

WebGPU wasn't working on iOS because we were not correctly
identifying the CALayers for remote hosting. Fix this by
adding a new CALayer type, WebGPULayer. This will also
eventually hold the code to render WebGPU into a canvas.

Covered by the existing reference tests (on device).

* SourcesCocoa.txt: Add new files.
* WebCore.xcodeproj/project.pbxproj: Ditto.

* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm: Recognise the WebGPULayer
class for remote hosting.
(WebCore::PlatformCALayerCocoa::layerTypeForPlatformLayer):
(WebCore::PlatformCALayerCocoa::PlatformCALayerCocoa):

* platform/graphics/cocoa/WebGPULayer.h: Added. Very simple inheritance
from CAMetalLayer.
* platform/graphics/cocoa/WebGPULayer.mm: Added.
(-[WebGPULayer init]):
(-[WebGPULayer copyImageSnapshotWithColorSpace:]):

* platform/graphics/gpu/GPUSwapChain.h: Reference WebGPULayer rather
than CALayer.

* platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm: Ensure that
the WebGPULayer has a reference back to this object, which it
will use in the future.
(WebCore::GPUSwapChain::create):
(WebCore::GPUSwapChain::GPUSwapChain):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (239035 => 239036)


--- trunk/Source/WebCore/ChangeLog	2018-12-10 18:06:37 UTC (rev 239035)
+++ trunk/Source/WebCore/ChangeLog	2018-12-10 19:37:49 UTC (rev 239036)
@@ -1,3 +1,41 @@
+2018-12-10  Dean Jackson  <[email protected]>
+
+        [iOS] Make WebGPU work with remote layer hosting
+        https://bugs.webkit.org/show_bug.cgi?id=192508
+        <rdar://problem/46560649>
+
+        Reviewed by Tim Horton.
+
+        WebGPU wasn't working on iOS because we were not correctly
+        identifying the CALayers for remote hosting. Fix this by
+        adding a new CALayer type, WebGPULayer. This will also
+        eventually hold the code to render WebGPU into a canvas.
+
+        Covered by the existing reference tests (on device).
+
+        * SourcesCocoa.txt: Add new files.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm: Recognise the WebGPULayer
+        class for remote hosting.
+        (WebCore::PlatformCALayerCocoa::layerTypeForPlatformLayer):
+        (WebCore::PlatformCALayerCocoa::PlatformCALayerCocoa):
+
+        * platform/graphics/cocoa/WebGPULayer.h: Added. Very simple inheritance
+        from CAMetalLayer.
+        * platform/graphics/cocoa/WebGPULayer.mm: Added.
+        (-[WebGPULayer init]):
+        (-[WebGPULayer copyImageSnapshotWithColorSpace:]):
+
+        * platform/graphics/gpu/GPUSwapChain.h: Reference WebGPULayer rather
+        than CALayer.
+
+        * platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm: Ensure that
+        the WebGPULayer has a reference back to this object, which it
+        will use in the future.
+        (WebCore::GPUSwapChain::create):
+        (WebCore::GPUSwapChain::GPUSwapChain):
+
 2018-12-10  Truitt Savell  <[email protected]>
 
         Unreviewed, rolling out r238965.

Modified: trunk/Source/WebCore/SourcesCocoa.txt (239035 => 239036)


--- trunk/Source/WebCore/SourcesCocoa.txt	2018-12-10 18:06:37 UTC (rev 239035)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2018-12-10 19:37:49 UTC (rev 239036)
@@ -309,6 +309,7 @@
 platform/graphics/cocoa/WebCoreCALayerExtras.mm
 platform/graphics/cocoa/WebCoreDecompressionSession.mm
 platform/graphics/cocoa/WebGLLayer.mm
+platform/graphics/cocoa/WebGPULayer.mm
 platform/graphics/cocoa/WebMetalLayer.mm
 platform/graphics/cocoa/TextTrackRepresentationCocoa.mm
 

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (239035 => 239036)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-12-10 18:06:37 UTC (rev 239035)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-12-10 19:37:49 UTC (rev 239036)
@@ -963,6 +963,7 @@
 		31741AAD16636609008A5B7E /* SimulatedClickOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		317D3FF3215599F40034E3B9 /* PointerEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 317D3FF2215599E30034E3B9 /* PointerEvent.h */; };
 		31815A311F9A6C8F00FCBF89 /* ImageBitmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D26BBF1F86D189008FF255 /* ImageBitmap.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		318436DE21B9DAAF00ED383E /* WebGPULayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 318436DB21B9DAA000ED383E /* WebGPULayer.h */; };
 		318891611AB7EEA100EA627B /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = CDF419991AB0DA14004E64E1 /* [email protected] */; };
 		318EAD4D1FA91380008CEF86 /* ImageBitmapRenderingContextSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 318EAD4A1FA91157008CEF86 /* ImageBitmapRenderingContextSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		31955A88160D199200858025 /* RenderSnapshottedPlugIn.h in Headers */ = {isa = PBXBuildFile; fileRef = 31E8D8BB160BC94C004CE8F5 /* RenderSnapshottedPlugIn.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7021,6 +7022,8 @@
 		317D3FEF215599E10034E3B9 /* PointerEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PointerEvent.idl; sourceTree = "<group>"; };
 		317D3FF1215599E20034E3B9 /* PointerEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PointerEvent.cpp; sourceTree = "<group>"; };
 		317D3FF2215599E30034E3B9 /* PointerEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PointerEvent.h; sourceTree = "<group>"; };
+		318436DB21B9DAA000ED383E /* WebGPULayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGPULayer.h; sourceTree = "<group>"; };
+		318436DD21B9DAA000ED383E /* WebGPULayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebGPULayer.mm; sourceTree = "<group>"; };
 		3189E6DB16B2103500386EA3 /* plugIns.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = plugIns.css; sourceTree = "<group>"; };
 		318EAD4A1FA91157008CEF86 /* ImageBitmapRenderingContextSettings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageBitmapRenderingContextSettings.h; sourceTree = "<group>"; };
 		318EAD4C1FA91352008CEF86 /* ImageBitmapRenderingContextSettings.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ImageBitmapRenderingContextSettings.idl; sourceTree = "<group>"; };
@@ -24419,6 +24422,8 @@
 				CD5D27751E8318E000D80A3D /* WebCoreDecompressionSession.mm */,
 				49FFBF3D11C93EE3006A7118 /* WebGLLayer.h */,
 				49FFBF3E11C93EE3006A7118 /* WebGLLayer.mm */,
+				318436DB21B9DAA000ED383E /* WebGPULayer.h */,
+				318436DD21B9DAA000ED383E /* WebGPULayer.mm */,
 				316BDB8A1E6E153000DE0D5A /* WebMetalLayer.h */,
 				D045AD1D2168230B000A6E9B /* WebMetalLayer.mm */,
 			);
@@ -31659,6 +31664,7 @@
 				0C3F1F5B10C8871200D72CE1 /* WebGLUniformLocation.h in Headers */,
 				6F995A261A7078B100A735F4 /* WebGLVertexArrayObject.h in Headers */,
 				77A17A7812F28642004E02F6 /* WebGLVertexArrayObjectOES.h in Headers */,
+				318436DE21B9DAAF00ED383E /* WebGPULayer.h in Headers */,
 				A5B81CB71FAA44620037D1E6 /* WebHeapAgent.h in Headers */,
 				A5840E25187B8AC200843B10 /* WebInjectedScriptHost.h in Headers */,
 				A584FE301864CB8400843B10 /* WebInjectedScriptManager.h in Headers */,

Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm (239035 => 239036)


--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm	2018-12-10 18:06:37 UTC (rev 239035)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm	2018-12-10 19:37:49 UTC (rev 239036)
@@ -40,9 +40,6 @@
 #import "WebGLLayer.h"
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
 #import <wtf/SoftLinking.h>
-#if ENABLE(WEBMETAL)
-#import "WebMetalLayer.h"
-#endif
 #import "WebLayer.h"
 #import "WebSystemBackdropLayer.h"
 #import "WebTiledBackingLayer.h"
@@ -53,6 +50,14 @@
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/RetainPtr.h>
 
+#if ENABLE(WEBGPU)
+#import "WebGPULayer.h"
+#endif
+
+#if ENABLE(WEBMETAL)
+#import "WebMetalLayer.h"
+#endif
+
 #if PLATFORM(IOS_FAMILY)
 #import "FontAntialiasingStateSaver.h"
 #import "WAKWindow.h"
@@ -203,6 +208,11 @@
     if ([layer isKindOfClass:[WebGLLayer class]])
         return LayerTypeContentsProvidedLayer;
 
+#if ENABLE(WEBGPU)
+    if ([layer isKindOfClass:[WebGPULayer class]])
+        return LayerTypeContentsProvidedLayer;
+#endif
+
 #if ENABLE(WEBMETAL)
     if ([layer isKindOfClass:[WebMetalLayer class]])
         return LayerTypeContentsProvidedLayer;
@@ -260,7 +270,7 @@
         layerClass = getAVPlayerLayerClass();
         break;
     case LayerTypeContentsProvidedLayer:
-        // We don't create PlatformCALayerCocoas wrapped around WebGLLayers or WebMetalLayers.
+        // We don't create PlatformCALayerCocoas wrapped around WebGLLayers, WebGPULayers or WebMetalLayers.
         ASSERT_NOT_REACHED();
         break;
     case LayerTypeShapeLayer:

Added: trunk/Source/WebCore/platform/graphics/cocoa/WebGPULayer.h (0 => 239036)


--- trunk/Source/WebCore/platform/graphics/cocoa/WebGPULayer.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/WebGPULayer.h	2018-12-10 19:37:49 UTC (rev 239036)
@@ -0,0 +1,48 @@
+/*
+ * 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. ``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(WEBGPU)
+
+#import <Metal/Metal.h>
+#import <QuartzCore/QuartzCore.h>
+
+namespace WebCore {
+class GPUSwapChain;
+}
+
+@interface WebGPULayer : CAMetalLayer {
+    WebCore::GPUSwapChain* _swapChain;
+    float _deviceScaleFactor;
+}
+
+@property (nonatomic) WebCore::GPUSwapChain* swapChain;
+
+- (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace;
+
+@end
+
+#endif
Property changes on: trunk/Source/WebCore/platform/graphics/cocoa/WebGPULayer.h
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Author Id Revision HeadURL \ No newline at end of property

Added: trunk/Source/WebCore/platform/graphics/cocoa/WebGPULayer.mm (0 => 239036)


--- trunk/Source/WebCore/platform/graphics/cocoa/WebGPULayer.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/WebGPULayer.mm	2018-12-10 19:37:49 UTC (rev 239036)
@@ -0,0 +1,63 @@
+/*
+ * 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. ``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.
+ */
+
+#include "config.h"
+#import "WebGPULayer.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUSwapChain.h"
+#import "GraphicsContextCG.h"
+
+@implementation WebGPULayer
+
+@synthesize swapChain=_swapChain;
+
+- (id)init
+{
+    self = [super init];
+
+    // FIXME: WebGPU - handle retina correctly.
+    _deviceScaleFactor = 1;
+
+#if PLATFORM(MAC)
+    self.contentsScale = _deviceScaleFactor;
+    self.colorspace = WebCore::sRGBColorSpaceRef();
+#endif
+    return self;
+}
+
+- (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace
+{
+    if (!_swapChain)
+        return nullptr;
+
+    UNUSED_PARAM(colorSpace);
+    return nullptr;
+}
+
+@end
+
+#endif

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChain.h (239035 => 239036)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChain.h	2018-12-10 18:06:37 UTC (rev 239035)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChain.h	2018-12-10 19:37:49 UTC (rev 239036)
@@ -32,8 +32,8 @@
 #include <wtf/RetainPtr.h>
 
 OBJC_CLASS CALayer;
-OBJC_CLASS CAMetalLayer;
-OBJC_PROTOCOL(CAMetalDrawable);
+OBJC_CLASS CAMetalDrawable;
+OBJC_CLASS WebGPULayer;
 
 namespace WebCore {
 
@@ -43,7 +43,7 @@
 
 using PlatformDrawableSmartPtr = RetainPtr<CAMetalDrawable>;
 using PlatformLayer = CALayer;
-using PlatformSwapLayerSmartPtr = RetainPtr<CAMetalLayer>;
+using PlatformSwapLayerSmartPtr = RetainPtr<WebGPULayer>;
 
 class GPUSwapChain : public RefCounted<GPUSwapChain> {
 public:

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm (239035 => 239036)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm	2018-12-10 18:06:37 UTC (rev 239035)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm	2018-12-10 19:37:49 UTC (rev 239036)
@@ -32,6 +32,7 @@
 #import "GPUTexture.h"
 #import "GPUTextureFormatEnum.h"
 #import "Logging.h"
+#import "WebGPULayer.h"
 
 #import <Metal/Metal.h>
 #import <QuartzCore/QuartzCore.h>
@@ -45,7 +46,7 @@
 
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    platformLayer = adoptNS([[CAMetalLayer alloc] init]);
+    platformLayer = adoptNS([[WebGPULayer alloc] init]);
 
     [platformLayer setOpaque:0];
     [platformLayer setName:@"WebGPU Layer"];
@@ -66,6 +67,7 @@
 GPUSwapChain::GPUSwapChain(PlatformSwapLayerSmartPtr&& platformLayer)
     : m_platformSwapLayer(WTFMove(platformLayer))
 {
+    platformLayer.get().swapChain = this;
 }
 
 void GPUSwapChain::setDevice(const GPUDevice& device)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to