Title: [292249] trunk
Revision
292249
Author
[email protected]
Date
2022-04-01 18:29:03 -0700 (Fri, 01 Apr 2022)

Log Message

Hoist the IOSurfacePool out of IOSurface
https://bugs.webkit.org/show_bug.cgi?id=238675

Reviewed by Tim Horton.
Source/WebCore:

A future patch will break the assumption that there is a singleton IOSurfacePool per
process, so we can't have IOSurface::create() consult the pool internally. Instead,
pass the pool to the create() functions, and to the moveToPool() function.

Callers in the web process pass IOSurfacePool::sharedPool(); those in the UI process
pass nullptr to avoid pool creation there.

* Modules/system-preview/ARKitBadgeSystemImage.mm:
(WebCore::ARKitBadgeSystemImage::draw const):
* platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::IOSurfacePool::addSurface):
* platform/graphics/cg/IOSurfacePool.h:
* platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
(WebCore::ImageBufferIOSurfaceBackend::create):
(WebCore::ImageBufferIOSurfaceBackend::releaseBufferToPool):
* platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
(WebCore::GraphicsContextGLCocoa::allocateAndBindDisplayBufferBacking):
* platform/graphics/cocoa/IOSurface.h: createFromImageBuffer() was unused; remove it.
* platform/graphics/cocoa/IOSurface.mm:
(WebCore::IOSurface::create):
(WebCore::IOSurface::createFromImage):
(WebCore::IOSurface::moveToPool):
(WebCore::IOSurface::surfaceFromPool): Deleted.
* testing/WebFakeXRDevice.cpp:
(WebCore::SimulatedXRDevice::frameTimerFired):

Source/WebKit:

A future patch will break the assumption that there is a singleton IOSurfacePool per
process, so we can't have IOSurface::create() consult the pool internally. Instead,
pass the pool to the create() functions, and to the moveToPool() function.

Callers in the web process pass IOSurfacePool::sharedPool(); those in the UI process
pass nullptr to avoid pool creation there.

* GPUProcess/media/RemoteImageDecoderAVFProxy.cpp:
(WebKit::RemoteImageDecoderAVFProxy::createFrameImageAtIndex):
* GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
(WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime):
* Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _takeViewSnapshot]):
(-[WKWebView _snapshotRectAfterScreenUpdates:rectInViewCoordinates:intoImageOfWidth:completionHandler:]):
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::takeViewSnapshot):
* WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp:
(WebKit::ImageBufferShareableMappedIOSurfaceBackend::create):

Tools:

A future patch will break the assumption that there is a singleton IOSurfacePool per
process, so we can't have IOSurface::create() consult the pool internally. Instead,
pass the pool to the create() functions, and to the moveToPool() function.

Callers in the web process pass IOSurfacePool::sharedPool(); those in the UI process
pass nullptr to avoid pool creation there.

* DumpRenderTree/ios/PixelDumpSupportIOS.mm:
(createBitmapContextFromWebView):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (292248 => 292249)


--- trunk/Source/WebCore/ChangeLog	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebCore/ChangeLog	2022-04-02 01:29:03 UTC (rev 292249)
@@ -1,3 +1,36 @@
+2022-04-01  Simon Fraser  <[email protected]>
+
+        Hoist the IOSurfacePool out of IOSurface
+        https://bugs.webkit.org/show_bug.cgi?id=238675
+
+        Reviewed by Tim Horton.
+
+        A future patch will break the assumption that there is a singleton IOSurfacePool per
+        process, so we can't have IOSurface::create() consult the pool internally. Instead,
+        pass the pool to the create() functions, and to the moveToPool() function.
+
+        Callers in the web process pass IOSurfacePool::sharedPool(); those in the UI process
+        pass nullptr to avoid pool creation there.
+
+        * Modules/system-preview/ARKitBadgeSystemImage.mm:
+        (WebCore::ARKitBadgeSystemImage::draw const):
+        * platform/graphics/cg/IOSurfacePool.cpp:
+        (WebCore::IOSurfacePool::addSurface):
+        * platform/graphics/cg/IOSurfacePool.h:
+        * platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
+        (WebCore::ImageBufferIOSurfaceBackend::create):
+        (WebCore::ImageBufferIOSurfaceBackend::releaseBufferToPool):
+        * platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
+        (WebCore::GraphicsContextGLCocoa::allocateAndBindDisplayBufferBacking):
+        * platform/graphics/cocoa/IOSurface.h: createFromImageBuffer() was unused; remove it.
+        * platform/graphics/cocoa/IOSurface.mm:
+        (WebCore::IOSurface::create):
+        (WebCore::IOSurface::createFromImage):
+        (WebCore::IOSurface::moveToPool):
+        (WebCore::IOSurface::surfaceFromPool): Deleted.
+        * testing/WebFakeXRDevice.cpp:
+        (WebCore::SimulatedXRDevice::frameTimerFired):
+
 2022-04-01  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r292072.

Modified: trunk/Source/WebCore/Modules/system-preview/ARKitBadgeSystemImage.mm (292248 => 292249)


--- trunk/Source/WebCore/Modules/system-preview/ARKitBadgeSystemImage.mm	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebCore/Modules/system-preview/ARKitBadgeSystemImage.mm	2022-04-02 01:29:03 UTC (rev 292249)
@@ -32,7 +32,7 @@
 #import "FloatRect.h"
 #import "GeometryUtilities.h"
 #import "GraphicsContext.h"
-#import "IOSurface.h"
+#import "IOSurfacePool.h"
 #import <CoreGraphics/CoreGraphics.h>
 #import <CoreImage/CoreImage.h>
 #import <wtf/NeverDestroyed.h>
@@ -192,7 +192,7 @@
     CIImage *translatedImage = [croppedImage imageByApplyingTransform:CGAffineTransformMakeTranslation(-flippedInsetBadgeRect.origin.x, -flippedInsetBadgeRect.origin.y)];
 
     auto surfaceDimension = useSmallBadge ? smallBadgeDimension : largeBadgeDimension;
-    std::unique_ptr<IOSurface> badgeSurface = IOSurface::create({ surfaceDimension, surfaceDimension }, DestinationColorSpace::SRGB());
+    std::unique_ptr<IOSurface> badgeSurface = IOSurface::create(&IOSurfacePool::sharedPool(), { surfaceDimension, surfaceDimension }, DestinationColorSpace::SRGB());
     IOSurfaceRef surface = badgeSurface->surface();
     [ciContext render:translatedImage toIOSurface:surface bounds:badgeRect colorSpace:sRGBColorSpaceRef()];
     cgImage = useSmallBadge ? badgeSurface->createImage() : badgeSurface->createImage();

Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp (292248 => 292249)


--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp	2022-04-02 01:29:03 UTC (rev 292249)
@@ -170,7 +170,7 @@
     return true;
 }
 
-void IOSurfacePool::addSurface(std::unique_ptr<IOSurface> surface)
+void IOSurfacePool::addSurface(std::unique_ptr<IOSurface>&& surface)
 {
     Locker locker { m_lock };
     if (!shouldCacheSurface(*surface))

Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h (292248 => 292249)


--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h	2022-04-02 01:29:03 UTC (rev 292249)
@@ -50,7 +50,7 @@
     WEBCORE_EXPORT static IOSurfacePool& sharedPool();
 
     std::unique_ptr<IOSurface> takeSurface(IntSize, const DestinationColorSpace&, IOSurface::Format);
-    WEBCORE_EXPORT void addSurface(std::unique_ptr<IOSurface>);
+    WEBCORE_EXPORT void addSurface(std::unique_ptr<IOSurface>&&);
 
     void discardAllSurfaces();
 

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp (292248 => 292249)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp	2022-04-02 01:29:03 UTC (rev 292249)
@@ -29,7 +29,7 @@
 #if HAVE(IOSURFACE)
 
 #include "GraphicsContextCG.h"
-#include "IOSurface.h"
+#include "IOSurfacePool.h"
 #include "IntRect.h"
 #include "PixelBuffer.h"
 #include <CoreGraphics/CoreGraphics.h>
@@ -87,7 +87,7 @@
     if (backendSize.isEmpty())
         return nullptr;
 
-    auto surface = IOSurface::create(backendSize, backendSize, parameters.colorSpace, IOSurface::formatForPixelFormat(parameters.pixelFormat));
+    auto surface = IOSurface::create(&IOSurfacePool::sharedPool(), backendSize, backendSize, parameters.colorSpace, IOSurface::formatForPixelFormat(parameters.pixelFormat));
     if (!surface)
         return nullptr;
 
@@ -262,7 +262,7 @@
 
 void ImageBufferIOSurfaceBackend::releaseBufferToPool()
 {
-    IOSurface::moveToPool(WTFMove(m_surface));
+    IOSurface::moveToPool(WTFMove(m_surface), &IOSurfacePool::sharedPool());
 }
 
 void ImageBufferIOSurfaceBackend::ensureNativeImagesHaveCopiedBackingStore()

Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm (292248 => 292249)


--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm	2022-04-02 01:29:03 UTC (rev 292249)
@@ -33,6 +33,7 @@
 #import "ANGLEUtilitiesCocoa.h"
 #import "CVUtilities.h"
 #import "GraphicsContextGLIOSurfaceSwapChain.h"
+#import "IOSurfacePool.h"
 #import "Logging.h"
 #import "PixelBuffer.h"
 #import "ProcessIdentity.h"
@@ -573,7 +574,7 @@
 bool GraphicsContextGLCocoa::allocateAndBindDisplayBufferBacking()
 {
     ASSERT(!getInternalFramebufferSize().isEmpty());
-    auto backing = IOSurface::create(getInternalFramebufferSize(), DestinationColorSpace::SRGB());
+    auto backing = IOSurface::create(&IOSurfacePool::sharedPool(), getInternalFramebufferSize(), DestinationColorSpace::SRGB());
     if (!backing)
         return false;
     if (m_resourceOwner)

Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (292248 => 292249)


--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h	2022-04-02 01:29:03 UTC (rev 292249)
@@ -45,7 +45,7 @@
 
 class GraphicsContext;
 class HostWindow;
-class ImageBuffer;
+class IOSurfacePool;
 class ProcessIdentity;
 
 enum class PixelFormat : uint8_t;
@@ -100,20 +100,18 @@
         uint32_t m_flags;
     };
 
-    WEBCORE_EXPORT static std::unique_ptr<IOSurface> create(IntSize, const DestinationColorSpace&, Format = Format::BGRA);
-    WEBCORE_EXPORT static std::unique_ptr<IOSurface> create(IntSize, IntSize contextSize, const DestinationColorSpace&, Format = Format::BGRA);
+    WEBCORE_EXPORT static std::unique_ptr<IOSurface> create(IOSurfacePool*, IntSize, const DestinationColorSpace&, Format = Format::BGRA);
+    WEBCORE_EXPORT static std::unique_ptr<IOSurface> create(IOSurfacePool*, IntSize, IntSize contextSize, const DestinationColorSpace&, Format = Format::BGRA);
+
+    WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromImage(IOSurfacePool*, CGImageRef);
+
     WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromSendRight(const WTF::MachSendRight&&, const DestinationColorSpace&);
     WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromSurface(IOSurfaceRef, const DestinationColorSpace&);
-    WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromImage(CGImageRef);
-    
-#if USE(IOSURFACE_CANVAS_BACKING_STORE)
-    static std::unique_ptr<IOSurface> createFromImageBuffer(RefPtr<ImageBuffer>);
-#endif
 
+    WEBCORE_EXPORT static void moveToPool(std::unique_ptr<IOSurface>&&, IOSurfacePool*);
+
     WEBCORE_EXPORT ~IOSurface();
 
-    WEBCORE_EXPORT static void moveToPool(std::unique_ptr<IOSurface>&&);
-
     WEBCORE_EXPORT static IntSize maximumSize();
     WEBCORE_EXPORT static void setMaximumSize(IntSize);
 
@@ -160,7 +158,7 @@
 
 #if HAVE(IOSURFACE_ACCELERATOR)
     WEBCORE_EXPORT static bool allowConversionFromFormatToFormat(Format, Format);
-    WEBCORE_EXPORT static void convertToFormat(std::unique_ptr<WebCore::IOSurface>&& inSurface, Format, Function<void(std::unique_ptr<WebCore::IOSurface>)>&&);
+    WEBCORE_EXPORT static void convertToFormat(IOSurfacePool*, std::unique_ptr<WebCore::IOSurface>&& inSurface, Format, Function<void(std::unique_ptr<WebCore::IOSurface>)>&&);
 #endif // HAVE(IOSURFACE_ACCELERATOR)
 
     WEBCORE_EXPORT void setOwnershipIdentity(const ProcessIdentity&);
@@ -172,7 +170,6 @@
     IOSurface(IntSize, IntSize contextSize, const DestinationColorSpace&, Format, bool& success);
     IOSurface(IOSurfaceRef, const DestinationColorSpace&);
 
-    static std::unique_ptr<IOSurface> surfaceFromPool(IntSize, IntSize contextSize, const DestinationColorSpace&, Format);
     IntSize contextSize() const { return m_contextSize; }
     void setContextSize(IntSize);
 

Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (292248 => 292249)


--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm	2022-04-02 01:29:03 UTC (rev 292249)
@@ -30,7 +30,6 @@
 #import "GraphicsContextCG.h"
 #import "HostWindow.h"
 #import "IOSurfacePool.h"
-#import "ImageBuffer.h"
 #import "Logging.h"
 #import "PlatformScreen.h"
 #import "ProcessIdentity.h"
@@ -44,27 +43,20 @@
 
 namespace WebCore {
 
-inline std::unique_ptr<IOSurface> IOSurface::surfaceFromPool(IntSize size, IntSize contextSize, const DestinationColorSpace& colorSpace, Format pixelFormat)
+std::unique_ptr<IOSurface> IOSurface::create(IOSurfacePool* pool, IntSize size, const DestinationColorSpace& colorSpace, Format pixelFormat)
 {
-    auto cachedSurface = IOSurfacePool::sharedPool().takeSurface(size, colorSpace, pixelFormat);
-    if (!cachedSurface)
-        return nullptr;
-
-    cachedSurface->setContextSize(contextSize);
-    return cachedSurface;
+    return IOSurface::create(pool, size, size, colorSpace, pixelFormat);
 }
 
-std::unique_ptr<IOSurface> IOSurface::create(IntSize size, const DestinationColorSpace& colorSpace, Format pixelFormat)
+std::unique_ptr<IOSurface> IOSurface::create(IOSurfacePool* pool, IntSize size, IntSize contextSize, const DestinationColorSpace& colorSpace, Format pixelFormat)
 {
-    return IOSurface::create(size, size, colorSpace, pixelFormat);
-}
-
-std::unique_ptr<IOSurface> IOSurface::create(IntSize size, IntSize contextSize, const DestinationColorSpace& colorSpace, Format pixelFormat)
-{
-    if (auto cachedSurface = surfaceFromPool(size, contextSize, colorSpace, pixelFormat)) {
+    std::unique_ptr<IOSurface> cachedSurface;
+    if (pool && (cachedSurface = pool->takeSurface(size, colorSpace, pixelFormat))) {
+        cachedSurface->setContextSize(contextSize);
         LOG_WITH_STREAM(IOSurface, stream << "IOSurface::create took from pool: " << *cachedSurface);
         return cachedSurface;
     }
+
     bool success = false;
     auto surface = std::unique_ptr<IOSurface>(new IOSurface(size, contextSize, colorSpace, pixelFormat, success));
     if (!success) {
@@ -87,7 +79,7 @@
     return std::unique_ptr<IOSurface>(new IOSurface(surface, colorSpace));
 }
 
-std::unique_ptr<IOSurface> IOSurface::createFromImage(CGImageRef image)
+std::unique_ptr<IOSurface> IOSurface::createFromImage(IOSurfacePool* pool, CGImageRef image)
 {
     if (!image)
         return nullptr;
@@ -95,7 +87,7 @@
     size_t width = CGImageGetWidth(image);
     size_t height = CGImageGetHeight(image);
 
-    auto surface = IOSurface::create(IntSize(width, height), DestinationColorSpace { CGImageGetColorSpace(image) });
+    auto surface = IOSurface::create(pool, IntSize(width, height), DestinationColorSpace { CGImageGetColorSpace(image) });
     if (!surface)
         return nullptr;
     auto surfaceContext = surface->ensurePlatformContext();
@@ -104,9 +96,10 @@
     return surface;
 }
 
-void IOSurface::moveToPool(std::unique_ptr<IOSurface>&& surface)
+void IOSurface::moveToPool(std::unique_ptr<IOSurface>&& surface, IOSurfacePool* pool)
 {
-    IOSurfacePool::sharedPool().addSurface(WTFMove(surface));
+    if (pool)
+        pool->addSurface(WTFMove(surface));
 }
 
 static NSDictionary *optionsForBiplanarSurface(IntSize size, unsigned pixelFormat, size_t firstPlaneBytesPerPixel, size_t secondPlaneBytesPerPixel)
@@ -481,7 +474,7 @@
     return true;
 }
 
-void IOSurface::convertToFormat(std::unique_ptr<IOSurface>&& inSurface, Format format, WTF::Function<void(std::unique_ptr<IOSurface>)>&& callback)
+void IOSurface::convertToFormat(IOSurfacePool* pool, std::unique_ptr<IOSurface>&& inSurface, Format format, WTF::Function<void(std::unique_ptr<IOSurface>)>&& callback)
 {
     static IOSurfaceAcceleratorRef accelerator;
     if (!accelerator) {
@@ -496,7 +489,7 @@
         return;
     }
 
-    auto destinationSurface = IOSurface::create(inSurface->size(), inSurface->colorSpace(), format);
+    auto destinationSurface = IOSurface::create(pool, inSurface->size(), inSurface->colorSpace(), format);
     if (!destinationSurface) {
         callback(nullptr);
         return;

Modified: trunk/Source/WebCore/testing/WebFakeXRDevice.cpp (292248 => 292249)


--- trunk/Source/WebCore/testing/WebFakeXRDevice.cpp	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebCore/testing/WebFakeXRDevice.cpp	2022-04-02 01:29:03 UTC (rev 292249)
@@ -157,7 +157,7 @@
 
     for (auto& layer : m_layers) {
 #if USE(IOSURFACE_FOR_XR_LAYER_DATA)
-        data.layers.add(layer.key, FrameData::LayerData { .surface = IOSurface::create(recommendedResolution(PlatformXR::SessionMode::ImmersiveVr), DestinationColorSpace::SRGB()) });
+        data.layers.add(layer.key, FrameData::LayerData { .surface = IOSurface::create(nullptr, recommendedResolution(PlatformXR::SessionMode::ImmersiveVr), DestinationColorSpace::SRGB()) });
 #else
         data.layers.add(layer.key, FrameData::LayerData { .opaqueTexture = layer.value });
 #endif

Modified: trunk/Source/WebKit/ChangeLog (292248 => 292249)


--- trunk/Source/WebKit/ChangeLog	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebKit/ChangeLog	2022-04-02 01:29:03 UTC (rev 292249)
@@ -1,3 +1,30 @@
+2022-04-01  Simon Fraser  <[email protected]>
+
+        Hoist the IOSurfacePool out of IOSurface
+        https://bugs.webkit.org/show_bug.cgi?id=238675
+
+        Reviewed by Tim Horton.
+
+        A future patch will break the assumption that there is a singleton IOSurfacePool per
+        process, so we can't have IOSurface::create() consult the pool internally. Instead,
+        pass the pool to the create() functions, and to the moveToPool() function.
+
+        Callers in the web process pass IOSurfacePool::sharedPool(); those in the UI process
+        pass nullptr to avoid pool creation there.
+
+        * GPUProcess/media/RemoteImageDecoderAVFProxy.cpp:
+        (WebKit::RemoteImageDecoderAVFProxy::createFrameImageAtIndex):
+        * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
+        (WebKit::RemoteMediaPlayerProxy::nativeImageForCurrentTime):
+        * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
+        * UIProcess/API/ios/WKWebViewIOS.mm:
+        (-[WKWebView _takeViewSnapshot]):
+        (-[WKWebView _snapshotRectAfterScreenUpdates:rectInViewCoordinates:intoImageOfWidth:completionHandler:]):
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::takeViewSnapshot):
+        * WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp:
+        (WebKit::ImageBufferShareableMappedIOSurfaceBackend::create):
+
 2022-04-01  Jigen Zhou  <[email protected]>
 
         Fix build break after r292225 for Playstation.

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.cpp (292248 => 292249)


--- trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.cpp	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.cpp	2022-04-02 01:29:03 UTC (rev 292249)
@@ -128,7 +128,7 @@
         return;
     }
 
-    auto surface = IOSurface::createFromImage(frameImage.get());
+    auto surface = IOSurface::createFromImage(nullptr, frameImage.get());
     if (!surface) {
         completionHandler(std::nullopt, DestinationColorSpace::SRGB());
         return;

Modified: trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm (292248 => 292249)


--- trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm	2022-04-02 01:29:03 UTC (rev 292249)
@@ -112,7 +112,7 @@
         return;
     }
 
-    auto surface = WebCore::IOSurface::createFromImage(platformImage.get());
+    auto surface = WebCore::IOSurface::createFromImage(nullptr, platformImage.get());
     if (!surface) {
         completionHandler(std::nullopt, DestinationColorSpace::SRGB());
         return;

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h (292248 => 292249)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h	2022-04-02 01:29:03 UTC (rev 292249)
@@ -27,7 +27,7 @@
 
 #include "ImageBufferBackendHandle.h"
 #include <WebCore/FloatRect.h>
-#include <WebCore/IOSurface.h>
+#include <WebCore/ImageBuffer.h>
 #include <WebCore/Region.h>
 #include <wtf/MachSendRight.h>
 #include <wtf/MonotonicTime.h>

Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (292248 => 292249)


--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2022-04-02 01:29:03 UTC (rev 292249)
@@ -57,7 +57,7 @@
 #import "_WKActivatedElementInfoInternal.h"
 #import <WebCore/ColorCocoa.h>
 #import <WebCore/GraphicsContextCG.h>
-#import <WebCore/IOSurface.h>
+#import <WebCore/IOSurfacePool.h>
 #import <WebCore/LocalCurrentTraitCollection.h>
 #import <WebCore/MIMETypeRegistry.h>
 #import <WebCore/RuntimeApplicationChecks.h>
@@ -1083,7 +1083,7 @@
 #else
     WebCore::IOSurface::Format snapshotFormat = WebCore::IOSurface::Format::BGRA;
 #endif
-    auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(snapshotSize), WebCore::DestinationColorSpace::SRGB(), snapshotFormat);
+    auto surface = WebCore::IOSurface::create(nullptr, WebCore::expandedIntSize(snapshotSize), WebCore::DestinationColorSpace::SRGB(), snapshotFormat);
     if (!surface)
         return nullptr;
     CARenderServerRenderLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, reinterpret_cast<uint64_t>(self.layer), surface->surface(), 0, 0, &transform);
@@ -1092,7 +1092,7 @@
     WebCore::IOSurface::Format compressedFormat = WebCore::IOSurface::Format::YUV422;
     if (WebCore::IOSurface::allowConversionFromFormatToFormat(snapshotFormat, compressedFormat)) {
         auto viewSnapshot = WebKit::ViewSnapshot::create(nullptr);
-        WebCore::IOSurface::convertToFormat(WTFMove(surface), WebCore::IOSurface::Format::YUV422, [viewSnapshot](std::unique_ptr<WebCore::IOSurface> convertedSurface) {
+        WebCore::IOSurface::convertToFormat(nullptr, WTFMove(surface), WebCore::IOSurface::Format::YUV422, [viewSnapshot](std::unique_ptr<WebCore::IOSurface> convertedSurface) {
             if (convertedSurface)
                 viewSnapshot->setSurface(WTFMove(convertedSurface));
         });
@@ -3333,7 +3333,7 @@
     NSString *displayName = self.window.screen.displayConfiguration.name;
     if (displayName && !self.window.hidden) {
         TraceScope snapshotScope(RenderServerSnapshotStart, RenderServerSnapshotEnd);
-        auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebCore::DestinationColorSpace::SRGB());
+        auto surface = WebCore::IOSurface::create(nullptr, WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebCore::DestinationColorSpace::SRGB());
         if (!surface) {
             completionHandler(nullptr);
             return;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (292248 => 292249)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2022-04-02 01:29:03 UTC (rev 292249)
@@ -4726,7 +4726,7 @@
 
     auto croppedSnapshotImage = adoptCF(CGImageCreateWithImageInRect(windowSnapshotImage.get(), NSRectToCGRect([window convertRectToBacking:croppedImageRect])));
 
-    auto surface = WebCore::IOSurface::createFromImage(croppedSnapshotImage.get());
+    auto surface = WebCore::IOSurface::createFromImage(nullptr, croppedSnapshotImage.get());
     if (!surface)
         return nullptr;
 

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp (292248 => 292249)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp	2022-04-02 01:29:03 UTC (rev 292249)
@@ -30,6 +30,7 @@
 
 #include "Logging.h"
 #include <WebCore/GraphicsContextCG.h>
+#include <WebCore/IOSurfacePool.h>
 #include <pal/spi/cocoa/IOSurfaceSPI.h>
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/StdLibExtras.h>
@@ -45,7 +46,7 @@
     if (backendSize.isEmpty())
         return nullptr;
 
-    auto surface = IOSurface::create(backendSize, backendSize, parameters.colorSpace, IOSurface::formatForPixelFormat(parameters.pixelFormat));
+    auto surface = IOSurface::create(&IOSurfacePool::sharedPool(), backendSize, backendSize, parameters.colorSpace, IOSurface::formatForPixelFormat(parameters.pixelFormat));
     if (!surface)
         return nullptr;
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp (292248 => 292249)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp	2022-04-02 01:29:03 UTC (rev 292249)
@@ -36,6 +36,7 @@
 #import <WebCore/EventRegion.h>
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/GraphicsLayerCA.h>
+#import <WebCore/IOSurface.h>
 #import <WebCore/LengthFunctions.h>
 #import <WebCore/PlatformCAFilters.h>
 #import <WebCore/PlatformCALayerCocoa.h>

Modified: trunk/Tools/ChangeLog (292248 => 292249)


--- trunk/Tools/ChangeLog	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Tools/ChangeLog	2022-04-02 01:29:03 UTC (rev 292249)
@@ -1,3 +1,20 @@
+2022-04-01  Simon Fraser  <[email protected]>
+
+        Hoist the IOSurfacePool out of IOSurface
+        https://bugs.webkit.org/show_bug.cgi?id=238675
+
+        Reviewed by Tim Horton.
+        
+        A future patch will break the assumption that there is a singleton IOSurfacePool per
+        process, so we can't have IOSurface::create() consult the pool internally. Instead,
+        pass the pool to the create() functions, and to the moveToPool() function.
+
+        Callers in the web process pass IOSurfacePool::sharedPool(); those in the UI process
+        pass nullptr to avoid pool creation there.
+
+        * DumpRenderTree/ios/PixelDumpSupportIOS.mm:
+        (createBitmapContextFromWebView):
+
 2022-03-31  Jonathan Bedard  <[email protected]>
 
         [Merge-Queue] Canonicalize commit without rebase

Modified: trunk/Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm (292248 => 292249)


--- trunk/Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm	2022-04-02 01:18:27 UTC (rev 292248)
+++ trunk/Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm	2022-04-02 01:29:03 UTC (rev 292249)
@@ -72,7 +72,7 @@
 #else
     WebCore::IOSurface::Format snapshotFormat = WebCore::IOSurface::Format::BGRA;
 #endif
-    auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(snapshotSize), WebCore::DestinationColorSpace::SRGB(), snapshotFormat);
+    auto surface = WebCore::IOSurface::create(nullptr, WebCore::expandedIntSize(snapshotSize), WebCore::DestinationColorSpace::SRGB(), snapshotFormat);
     RetainPtr<CGImageRef> cgImage = surface->createImage();
 
     void* bitmapBuffer = nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to