Title: [270275] trunk/Source/WebKit
Revision
270275
Author
[email protected]
Date
2020-11-30 16:30:38 -0800 (Mon, 30 Nov 2020)

Log Message

GPU Process: IOSurfaces should not be mapped into the Web Content Process
https://bugs.webkit.org/show_bug.cgi?id=219368

Reviewed by Ryosuke Niwa.

Since the Web Content process sandbox will eventually not have access to IOKit,
it will not be able to map/lock/use IOSurfaces. Thankfully, all it really needs
to be able to do is carry a reference to the surface from the GPU process to the
UI process (where it is mapped and applied as layer contents).

* Shared/ConcreteShareableImageBuffer.h: Copied from Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h.
(WebKit::ConcreteShareableImageBuffer::create):
(WebKit::ConcreteShareableImageBuffer::ConcreteShareableImageBuffer):
(WebKit::ConcreteShareableImageBuffer::createImageBufferBackendHandle):
* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::encode const):
(WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
Add and adopt ConcreteShareableImageBuffer. This is a ConcreteImageBuffer that knows how
to create an ImageBufferBackendHandle, with no other behavior change.
Previously, we were (completely incorrectly) casting ConcreteImageBuffer to RemoteImageBufferProxy
to get this behavior, and somehow just got very lucky.

* SourcesCocoa.txt:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/GPU/graphics/PlatformImageBufferShareableBackend.h:
* WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h:
* WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp:
* WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h:
Remove the ImageBufferShareableIOSurfaceBackend create() method that takes
an ImageBufferBackendHandle, since we always use the Unmapped variant.
ImageBufferShareableIOSurfaceBackend is now only used:
- in the GPU process
- in the Web Content process when DOM rendering in the GPU process is disabled
In both cases, the process that uses ImageBufferShareableIOSurfaceBackend also
originates the surface, so does not create it from a handle.

* WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.cpp: Added.
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::create):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::createImageBufferBackendHandle const):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::context const):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::copyNativeImage const):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::copyImage const):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::draw):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::drawPattern):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::toDataURL const):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::toData const):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::toBGRAData const):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::getImageData const):
(WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::putImageData):
* WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.h: Added.
Add and adopt ImageBufferShareableUnmappedIOSurfaceBackend, which is a ImageBufferBackend
that cannot perform most ImageBufferBackend duties, except creating an ImageBufferBackendHandle,
which it does by cloning the existing handle. It explicitly does *not* map the IOSurface in the
process, and is meant for use in Web Content processes that do not have access to IOSurface.

* WebProcess/GPU/media/RemoteAudioSession.cpp:
Fix some unified source issues.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (270274 => 270275)


--- trunk/Source/WebKit/ChangeLog	2020-11-30 23:57:56 UTC (rev 270274)
+++ trunk/Source/WebKit/ChangeLog	2020-12-01 00:30:38 UTC (rev 270275)
@@ -1,3 +1,63 @@
+2020-11-30  Tim Horton  <[email protected]>
+
+        GPU Process: IOSurfaces should not be mapped into the Web Content Process
+        https://bugs.webkit.org/show_bug.cgi?id=219368
+
+        Reviewed by Ryosuke Niwa.
+
+        Since the Web Content process sandbox will eventually not have access to IOKit,
+        it will not be able to map/lock/use IOSurfaces. Thankfully, all it really needs
+        to be able to do is carry a reference to the surface from the GPU process to the
+        UI process (where it is mapped and applied as layer contents).
+
+        * Shared/ConcreteShareableImageBuffer.h: Copied from Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h.
+        (WebKit::ConcreteShareableImageBuffer::create):
+        (WebKit::ConcreteShareableImageBuffer::ConcreteShareableImageBuffer):
+        (WebKit::ConcreteShareableImageBuffer::createImageBufferBackendHandle):
+        * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::encode const):
+        (WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
+        Add and adopt ConcreteShareableImageBuffer. This is a ConcreteImageBuffer that knows how
+        to create an ImageBufferBackendHandle, with no other behavior change.
+        Previously, we were (completely incorrectly) casting ConcreteImageBuffer to RemoteImageBufferProxy
+        to get this behavior, and somehow just got very lucky.
+
+        * SourcesCocoa.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/GPU/graphics/PlatformImageBufferShareableBackend.h:
+        * WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h:
+        * WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp:
+        * WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h:
+        Remove the ImageBufferShareableIOSurfaceBackend create() method that takes
+        an ImageBufferBackendHandle, since we always use the Unmapped variant.
+        ImageBufferShareableIOSurfaceBackend is now only used:
+        - in the GPU process
+        - in the Web Content process when DOM rendering in the GPU process is disabled
+        In both cases, the process that uses ImageBufferShareableIOSurfaceBackend also
+        originates the surface, so does not create it from a handle.
+
+        * WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.cpp: Added.
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::create):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::createImageBufferBackendHandle const):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::context const):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::copyNativeImage const):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::copyImage const):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::draw):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::drawPattern):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::toDataURL const):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::toData const):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::toBGRAData const):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::getImageData const):
+        (WebKit::ImageBufferShareableUnmappedIOSurfaceBackend::putImageData):
+        * WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.h: Added.
+        Add and adopt ImageBufferShareableUnmappedIOSurfaceBackend, which is a ImageBufferBackend
+        that cannot perform most ImageBufferBackend duties, except creating an ImageBufferBackendHandle,
+        which it does by cloning the existing handle. It explicitly does *not* map the IOSurface in the
+        process, and is meant for use in Web Content processes that do not have access to IOSurface.
+
+        * WebProcess/GPU/media/RemoteAudioSession.cpp:
+        Fix some unified source issues.
+
 2020-11-30  Chris Dumez  <[email protected]>
 
         sessionStorage should not be cloned when a window is opened with rel=noopener

Copied: trunk/Source/WebKit/Shared/ConcreteShareableImageBuffer.h (from rev 270273, trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h) (0 => 270275)


--- trunk/Source/WebKit/Shared/ConcreteShareableImageBuffer.h	                        (rev 0)
+++ trunk/Source/WebKit/Shared/ConcreteShareableImageBuffer.h	2020-12-01 00:30:38 UTC (rev 270275)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2020 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 "ImageBufferBackendHandle.h"
+#include <WebCore/ConcreteImageBuffer.h>
+
+namespace WebKit {
+
+template<typename BackendType>
+class ConcreteShareableImageBuffer : public WebCore::ConcreteImageBuffer<BackendType> {
+    using BaseConcreteImageBuffer = WebCore::ConcreteImageBuffer<BackendType>;
+    using BaseConcreteImageBuffer::m_backend;
+
+public:
+    static auto create(const WebCore::FloatSize& size, WebCore::RenderingMode renderingMode, float resolutionScale, WebCore::ColorSpace colorSpace, WebCore::PixelFormat pixelFormat)
+    {
+        return BaseConcreteImageBuffer::template create<ConcreteShareableImageBuffer>(size, resolutionScale, colorSpace, pixelFormat, nullptr);
+    }
+
+    ConcreteShareableImageBuffer(std::unique_ptr<BackendType>&& backend)
+        : BaseConcreteImageBuffer(WTFMove(backend))
+    {
+    }
+
+    ImageBufferBackendHandle createImageBufferBackendHandle()
+    {
+        return m_backend->createImageBufferBackendHandle();
+    }
+};
+
+} // namespace WebKit

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm (270274 => 270275)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm	2020-11-30 23:57:56 UTC (rev 270274)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm	2020-12-01 00:30:38 UTC (rev 270275)
@@ -27,6 +27,7 @@
 #import "RemoteLayerBackingStore.h"
 
 #import "ArgumentCoders.h"
+#import "ConcreteShareableImageBuffer.h"
 #import "MachPort.h"
 #import "PlatformCALayerRemote.h"
 #import "PlatformRemoteImageBufferProxy.h"
@@ -105,10 +106,17 @@
     Optional<ImageBufferBackendHandle> handle;
     if (m_frontBuffer.imageBuffer) {
         // FIXME: We need to flatten the class hierarchy so we can avoid this bifurcation.
-        if (m_acceleratesDrawing)
-            handle = static_cast<AcceleratedRemoteImageBufferProxy *>(m_frontBuffer.imageBuffer.get())->createImageBufferBackendHandle();
-        else
-            handle = static_cast<UnacceleratedRemoteImageBufferProxy *>(m_frontBuffer.imageBuffer.get())->createImageBufferBackendHandle();
+        if (WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM)) {
+            if (m_acceleratesDrawing)
+                handle = static_cast<AcceleratedRemoteImageBufferProxy *>(m_frontBuffer.imageBuffer.get())->createImageBufferBackendHandle();
+            else
+                handle = static_cast<UnacceleratedRemoteImageBufferProxy *>(m_frontBuffer.imageBuffer.get())->createImageBufferBackendHandle();
+        } else {
+            if (m_acceleratesDrawing)
+                handle = static_cast<ConcreteShareableImageBuffer<AcceleratedImageBufferShareableBackend> *>(m_frontBuffer.imageBuffer.get())->createImageBufferBackendHandle();
+            else
+                handle = static_cast<ConcreteShareableImageBuffer<UnacceleratedImageBufferShareableBackend> *>(m_frontBuffer.imageBuffer.get())->createImageBufferBackendHandle();
+        }
     }
 
     encoder << handle;
@@ -185,9 +193,9 @@
     }
 
     if (m_acceleratesDrawing)
-        m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<AcceleratedImageBufferShareableBackend>::create(backingStoreSize(), 1, WebCore::ColorSpace::SRGB, pixelFormat(), nullptr);
+        m_frontBuffer.imageBuffer = ConcreteShareableImageBuffer<AcceleratedImageBufferShareableBackend>::create(backingStoreSize(), WebCore::RenderingMode::Accelerated, 1, WebCore::ColorSpace::SRGB, pixelFormat());
     else
-        m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<UnacceleratedImageBufferShareableBackend>::create(backingStoreSize(), 1, WebCore::ColorSpace::SRGB, pixelFormat(), nullptr);
+        m_frontBuffer.imageBuffer = ConcreteShareableImageBuffer<UnacceleratedImageBufferShareableBackend>::create(backingStoreSize(), WebCore::RenderingMode::Unaccelerated, 1, WebCore::ColorSpace::SRGB, pixelFormat());
 }
 
 bool RemoteLayerBackingStore::display()

Modified: trunk/Source/WebKit/SourcesCocoa.txt (270274 => 270275)


--- trunk/Source/WebKit/SourcesCocoa.txt	2020-11-30 23:57:56 UTC (rev 270274)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2020-12-01 00:30:38 UTC (rev 270275)
@@ -573,6 +573,7 @@
 WebProcess/EntryPoint/Cocoa/XPCService/WebContentServiceEntryPoint.mm
 
 WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp
+WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.cpp
 WebProcess/GPU/media/RemoteAudioSourceProvider.cpp
 WebProcess/GPU/media/RemoteAudioSourceProviderManager.cpp
 WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (270274 => 270275)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-11-30 23:57:56 UTC (rev 270274)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-12-01 00:30:38 UTC (rev 270275)
@@ -2951,6 +2951,9 @@
 		2D1B5D5C185869C8006C6596 /* ViewGestureControllerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewGestureControllerMessages.h; path = DerivedSources/WebKit2/ViewGestureControllerMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
 		2D1E8221216FFF5000A15265 /* WKWebEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKWebEvent.h; path = ios/WKWebEvent.h; sourceTree = "<group>"; };
 		2D1E8222216FFF5100A15265 /* WKWebEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKWebEvent.mm; path = ios/WKWebEvent.mm; sourceTree = "<group>"; };
+		2D25F3272575872400231A8B /* ConcreteShareableImageBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ConcreteShareableImageBuffer.h; sourceTree = "<group>"; };
+		2D25F32825758E9000231A8B /* ImageBufferShareableUnmappedIOSurfaceBackend.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageBufferShareableUnmappedIOSurfaceBackend.h; sourceTree = "<group>"; };
+		2D25F32925758E9100231A8B /* ImageBufferShareableUnmappedIOSurfaceBackend.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBufferShareableUnmappedIOSurfaceBackend.cpp; sourceTree = "<group>"; };
 		2D28A4951AF965A100F190C9 /* WKViewLayoutStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKViewLayoutStrategy.h; sourceTree = "<group>"; };
 		2D28A4961AF965A100F190C9 /* WKViewLayoutStrategy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKViewLayoutStrategy.mm; sourceTree = "<group>"; };
 		2D28F3E01885CCC1004B9EAE /* WebChromeClientIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebChromeClientIOS.mm; path = ios/WebChromeClientIOS.mm; sourceTree = "<group>"; };
@@ -6244,6 +6247,7 @@
 				BCF18637167D071E00A1A85A /* CacheModel.cpp */,
 				BC3065F91259344E00E71278 /* CacheModel.h */,
 				9BC59D6C1EFCCCB6001E8D09 /* CallbackID.h */,
+				2D25F3272575872400231A8B /* ConcreteShareableImageBuffer.h */,
 				CA05397823EE324400A553DC /* ContentAsStringIncludesChildFrames.h */,
 				5129EB1123D0DE7800AF1CD7 /* ContentWorldShared.h */,
 				5106D7BF18BDBE73000AB166 /* ContextMenuContextData.cpp */,
@@ -8721,6 +8725,8 @@
 			children = (
 				727A7F342407857D004D2931 /* ImageBufferShareableIOSurfaceBackend.cpp */,
 				727A7F352407857F004D2931 /* ImageBufferShareableIOSurfaceBackend.h */,
+				2D25F32925758E9100231A8B /* ImageBufferShareableUnmappedIOSurfaceBackend.cpp */,
+				2D25F32825758E9000231A8B /* ImageBufferShareableUnmappedIOSurfaceBackend.h */,
 			);
 			path = cocoa;
 			sourceTree = "<group>";

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/PlatformImageBufferShareableBackend.h (270274 => 270275)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/PlatformImageBufferShareableBackend.h	2020-11-30 23:57:56 UTC (rev 270274)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/PlatformImageBufferShareableBackend.h	2020-12-01 00:30:38 UTC (rev 270275)
@@ -31,6 +31,7 @@
 
 #if HAVE(IOSURFACE)
 #include "ImageBufferShareableIOSurfaceBackend.h"
+#include "ImageBufferShareableUnmappedIOSurfaceBackend.h"
 #endif
 
 namespace WebKit {
@@ -38,8 +39,10 @@
 using UnacceleratedImageBufferShareableBackend = ImageBufferShareableBitmapBackend;
 
 #if HAVE(IOSURFACE)
+using AcceleratedImageBufferShareableUnmappedBackend = ImageBufferShareableUnmappedIOSurfaceBackend;
 using AcceleratedImageBufferShareableBackend = ImageBufferShareableIOSurfaceBackend;
 #else
+using AcceleratedImageBufferShareableUnmappedBackend = UnacceleratedImageBufferShareableBackend;
 using AcceleratedImageBufferShareableBackend = UnacceleratedImageBufferShareableBackend;
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h (270274 => 270275)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h	2020-11-30 23:57:56 UTC (rev 270274)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h	2020-12-01 00:30:38 UTC (rev 270275)
@@ -33,7 +33,7 @@
 namespace WebKit {
 
 using UnacceleratedRemoteImageBufferProxy = RemoteImageBufferProxy<UnacceleratedImageBufferShareableBackend>;
-using AcceleratedRemoteImageBufferProxy = RemoteImageBufferProxy<AcceleratedImageBufferShareableBackend>;
+using AcceleratedRemoteImageBufferProxy = RemoteImageBufferProxy<AcceleratedImageBufferShareableUnmappedBackend>;
 
 } // namespace WebKit
 

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp (270274 => 270275)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp	2020-11-30 23:57:56 UTC (rev 270274)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp	2020-12-01 00:30:38 UTC (rev 270275)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "ImageBufferShareableIOSurfaceBackend.h"
 
-#if ENABLE(GPU_PROCESS)
+#if ENABLE(GPU_PROCESS) && HAVE(IOSURFACE)
 
 #include <WebCore/GraphicsContextCG.h>
 #include <wtf/IsoMallocInlines.h>
@@ -56,20 +56,6 @@
     return makeUnique<ImageBufferShareableIOSurfaceBackend>(size, backendSize, resolutionScale, colorSpace, pixelFormat, WTFMove(surface));
 }
 
-std::unique_ptr<ImageBufferShareableIOSurfaceBackend> ImageBufferShareableIOSurfaceBackend::create(const FloatSize& logicalSize, const IntSize& internalSize, float resolutionScale, ColorSpace colorSpace, PixelFormat pixelFormat, ImageBufferBackendHandle handle)
-{
-    if (!WTF::holds_alternative<MachSendRight>(handle)) {
-        ASSERT_NOT_REACHED();
-        return nullptr;
-    }
-
-    auto surface = IOSurface::createFromSendRight(WTFMove(WTF::get<MachSendRight>(handle)), cachedCGColorSpace(colorSpace));
-    if (!surface)
-        return nullptr;
-
-    return makeUnique<ImageBufferShareableIOSurfaceBackend>(logicalSize, internalSize, resolutionScale, colorSpace, pixelFormat, WTFMove(surface));
-}
-
 ImageBufferBackendHandle ImageBufferShareableIOSurfaceBackend::createImageBufferBackendHandle() const
 {
     return ImageBufferBackendHandle(m_surface->createSendRight());

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h (270274 => 270275)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h	2020-11-30 23:57:56 UTC (rev 270274)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h	2020-12-01 00:30:38 UTC (rev 270275)
@@ -25,9 +25,10 @@
 
 #pragma once
 
-#if ENABLE(GPU_PROCESS)
+#if ENABLE(GPU_PROCESS) && HAVE(IOSURFACE)
 
 #include "ImageBufferBackendHandle.h"
+#include <WebCore/GraphicsContext.h>
 #include <WebCore/ImageBufferIOSurfaceBackend.h>
 #include <wtf/IsoMalloc.h>
 
@@ -35,12 +36,11 @@
 
 class ShareableBitmap;
 
-class ImageBufferShareableIOSurfaceBackend : public WebCore::ImageBufferIOSurfaceBackend {
+class ImageBufferShareableIOSurfaceBackend final : public WebCore::ImageBufferIOSurfaceBackend {
     WTF_MAKE_ISO_ALLOCATED(ImageBufferShareableIOSurfaceBackend);
     WTF_MAKE_NONCOPYABLE(ImageBufferShareableIOSurfaceBackend);
 public:
     static std::unique_ptr<ImageBufferShareableIOSurfaceBackend> create(const WebCore::FloatSize& logicalSize, const float resolutionScale, WebCore::ColorSpace, WebCore::PixelFormat, const WebCore::HostWindow*);
-    static std::unique_ptr<ImageBufferShareableIOSurfaceBackend> create(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& internalSize, float resolutionScale, WebCore::ColorSpace, WebCore::PixelFormat, ImageBufferBackendHandle);
 
     using WebCore::ImageBufferIOSurfaceBackend::ImageBufferIOSurfaceBackend;
 
@@ -49,4 +49,4 @@
 
 } // namespace WebKit
 
-#endif // ENABLE(GPU_PROCESS)
+#endif // ENABLE(GPU_PROCESS) && HAVE(IOSURFACE)

Added: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.cpp (0 => 270275)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.cpp	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.cpp	2020-12-01 00:30:38 UTC (rev 270275)
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2020 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 "ImageBufferShareableUnmappedIOSurfaceBackend.h"
+
+#if HAVE(IOSURFACE)
+
+#include <WebCore/GraphicsContextCG.h>
+#include <wtf/IsoMallocInlines.h>
+#include <wtf/StdLibExtras.h>
+
+namespace WebKit {
+using namespace WebCore;
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(ImageBufferShareableUnmappedIOSurfaceBackend);
+
+std::unique_ptr<ImageBufferShareableUnmappedIOSurfaceBackend> ImageBufferShareableUnmappedIOSurfaceBackend::create(const FloatSize& logicalSize, const IntSize& internalSize, float resolutionScale, ColorSpace colorSpace, PixelFormat pixelFormat, ImageBufferBackendHandle handle)
+{
+    if (!WTF::holds_alternative<MachSendRight>(handle)) {
+        RELEASE_ASSERT_NOT_REACHED();
+        return nullptr;
+    }
+
+    return makeUnique<ImageBufferShareableUnmappedIOSurfaceBackend>(logicalSize, internalSize, resolutionScale, colorSpace, pixelFormat, WTFMove(handle));
+}
+
+ImageBufferBackendHandle ImageBufferShareableUnmappedIOSurfaceBackend::createImageBufferBackendHandle() const
+{
+    return WTF::get<MachSendRight>(m_handle).copySendRight();
+}
+
+GraphicsContext& ImageBufferShareableUnmappedIOSurfaceBackend::context() const
+{
+    RELEASE_ASSERT_NOT_REACHED();
+    return *(GraphicsContext*)nullptr;
+}
+
+RefPtr<NativeImage> ImageBufferShareableUnmappedIOSurfaceBackend::copyNativeImage(BackingStoreCopy) const
+{
+    RELEASE_ASSERT_NOT_REACHED();
+    return { };
+}
+
+RefPtr<Image> ImageBufferShareableUnmappedIOSurfaceBackend::copyImage(BackingStoreCopy, PreserveResolution) const
+{
+    RELEASE_ASSERT_NOT_REACHED();
+    return { };
+}
+
+void ImageBufferShareableUnmappedIOSurfaceBackend::draw(GraphicsContext&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&)
+{
+    RELEASE_ASSERT_NOT_REACHED();
+}
+
+void ImageBufferShareableUnmappedIOSurfaceBackend::drawPattern(GraphicsContext&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, const ImagePaintingOptions&)
+{
+    RELEASE_ASSERT_NOT_REACHED();
+}
+
+String ImageBufferShareableUnmappedIOSurfaceBackend::toDataURL(const String&, Optional<double>, PreserveResolution) const
+{
+    RELEASE_ASSERT_NOT_REACHED();
+    return { };
+}
+
+Vector<uint8_t> ImageBufferShareableUnmappedIOSurfaceBackend::toData(const String&, Optional<double>) const
+{
+    RELEASE_ASSERT_NOT_REACHED();
+    return { };
+}
+
+Vector<uint8_t> ImageBufferShareableUnmappedIOSurfaceBackend::toBGRAData() const
+{
+    RELEASE_ASSERT_NOT_REACHED();
+    return { };
+}
+
+RefPtr<ImageData> ImageBufferShareableUnmappedIOSurfaceBackend::getImageData(AlphaPremultiplication, const IntRect&) const
+{
+    RELEASE_ASSERT_NOT_REACHED();
+    return { };
+}
+
+void ImageBufferShareableUnmappedIOSurfaceBackend::putImageData(AlphaPremultiplication, const ImageData&, const IntRect&, const IntPoint&, AlphaPremultiplication)
+{
+    RELEASE_ASSERT_NOT_REACHED();
+}
+
+} // namespace WebKit
+
+#endif // HAVE(IOSURFACE)

Added: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.h (0 => 270275)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableUnmappedIOSurfaceBackend.h	2020-12-01 00:30:38 UTC (rev 270275)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2020 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 HAVE(IOSURFACE)
+
+#include "ImageBufferBackendHandle.h"
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/ImageBufferBackend.h>
+#include <wtf/IsoMalloc.h>
+
+namespace WebKit {
+
+class ShareableBitmap;
+
+class ImageBufferShareableUnmappedIOSurfaceBackend final : public WebCore::ImageBufferBackend {
+    WTF_MAKE_ISO_ALLOCATED(ImageBufferShareableUnmappedIOSurfaceBackend);
+    WTF_MAKE_NONCOPYABLE(ImageBufferShareableUnmappedIOSurfaceBackend);
+public:
+    static std::unique_ptr<ImageBufferShareableUnmappedIOSurfaceBackend> create(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& internalSize, float resolutionScale, WebCore::ColorSpace, WebCore::PixelFormat, ImageBufferBackendHandle);
+
+    ImageBufferShareableUnmappedIOSurfaceBackend(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& physicalSize, float resolutionScale, WebCore::ColorSpace colorSpace, WebCore::PixelFormat pixelFormat, ImageBufferBackendHandle&& handle)
+        : ImageBufferBackend(logicalSize, physicalSize, resolutionScale, colorSpace, pixelFormat)
+        , m_handle(WTFMove(handle))
+    {
+    }
+
+    ImageBufferBackendHandle createImageBufferBackendHandle() const;
+
+    WebCore::GraphicsContext& context() const override;
+    RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy) const override;
+    RefPtr<WebCore::Image> copyImage(WebCore::BackingStoreCopy, WebCore::PreserveResolution) const override;
+    void draw(WebCore::GraphicsContext&, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&) override;
+    void drawPattern(WebCore::GraphicsContext&, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::AffineTransform& patternTransform, const WebCore::FloatPoint& phase, const WebCore::FloatSize& spacing, const WebCore::ImagePaintingOptions&) override;
+    String toDataURL(const String& mimeType, Optional<double> quality, WebCore::PreserveResolution) const override;
+    Vector<uint8_t> toData(const String& mimeType, Optional<double> quality) const override;
+    Vector<uint8_t> toBGRAData() const override;
+    RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect&) const override;
+    void putImageData(WebCore::AlphaPremultiplication inputFormat, const WebCore::ImageData&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) override;
+
+    static constexpr bool isOriginAtUpperLeftCorner = true;
+    static constexpr bool isAccelerated = true;
+
+private:
+    ImageBufferBackendHandle m_handle;
+};
+
+} // namespace WebKit
+
+#endif // HAVE(IOSURFACE)

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.cpp (270274 => 270275)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.cpp	2020-11-30 23:57:56 UTC (rev 270274)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.cpp	2020-12-01 00:30:38 UTC (rev 270275)
@@ -29,9 +29,11 @@
 #if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
 
 #include "GPUConnectionToWebProcessMessages.h"
+#include "GPUProcessConnection.h"
 #include "GPUProcessProxy.h"
 #include "RemoteAudioSessionMessages.h"
 #include "RemoteAudioSessionProxyMessages.h"
+#include "WebProcess.h"
 #include <WebCore/PlatformMediaSessionManager.h>
 
 namespace WebKit {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to