Title: [294197] trunk/Source
Revision
294197
Author
[email protected]
Date
2022-05-14 09:26:54 -0700 (Sat, 14 May 2022)

Log Message

WebCore::IOSurface refers to unused context size
https://bugs.webkit.org/show_bug.cgi?id=240385

Patch by Kimmo Kinnunen <[email protected]> on 2022-05-14
Reviewed by Simon Fraser.

Source/WebCore:

Remove unused IOSurface::m_contextSize.
Context related code makes IOSurface error-prone wrt
reusing the IOSurface in the pool.

* platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
(WebCore::ImageBufferIOSurfaceBackend::create):
* platform/graphics/cocoa/IOSurface.h:
* platform/graphics/cocoa/IOSurface.mm:
(WebCore::IOSurface::create):
(WebCore::IOSurface::IOSurface):
(WebCore::IOSurface::ensurePlatformContext):

Source/WebKit:

Adjust after removing the IOSurface context size parameter.
All call sites passed the surface size.

* WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp:
(WebKit::ImageBufferShareableMappedIOSurfaceBackend::create):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (294196 => 294197)


--- trunk/Source/WebCore/ChangeLog	2022-05-14 15:59:33 UTC (rev 294196)
+++ trunk/Source/WebCore/ChangeLog	2022-05-14 16:26:54 UTC (rev 294197)
@@ -1,3 +1,22 @@
+2022-05-14  Kimmo Kinnunen  <[email protected]>
+
+        WebCore::IOSurface refers to unused context size
+        https://bugs.webkit.org/show_bug.cgi?id=240385
+
+        Reviewed by Simon Fraser.
+
+        Remove unused IOSurface::m_contextSize.
+        Context related code makes IOSurface error-prone wrt
+        reusing the IOSurface in the pool.
+
+        * platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
+        (WebCore::ImageBufferIOSurfaceBackend::create):
+        * platform/graphics/cocoa/IOSurface.h:
+        * platform/graphics/cocoa/IOSurface.mm:
+        (WebCore::IOSurface::create):
+        (WebCore::IOSurface::IOSurface):
+        (WebCore::IOSurface::ensurePlatformContext):
+
 2022-05-14  Simon Fraser  <[email protected]>
 
         Use an OptionSet<> for DisplayList::AsTextFlags

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


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp	2022-05-14 15:59:33 UTC (rev 294196)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp	2022-05-14 16:26:54 UTC (rev 294197)
@@ -89,7 +89,7 @@
     if (backendSize.isEmpty())
         return nullptr;
 
-    auto surface = IOSurface::create(creationContext.surfacePool, backendSize, backendSize, parameters.colorSpace, IOSurface::formatForPixelFormat(parameters.pixelFormat));
+    auto surface = IOSurface::create(creationContext.surfacePool, backendSize, parameters.colorSpace, IOSurface::formatForPixelFormat(parameters.pixelFormat));
     if (!surface)
         return nullptr;
 

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


--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h	2022-05-14 15:59:33 UTC (rev 294196)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h	2022-05-14 16:26:54 UTC (rev 294197)
@@ -101,8 +101,6 @@
     };
 
     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&);
@@ -167,15 +165,11 @@
     void migrateColorSpaceToProperties();
 
 private:
-    IOSurface(IntSize, IntSize contextSize, const DestinationColorSpace&, Format, bool& success);
+    IOSurface(IntSize, const DestinationColorSpace&, Format, bool& success);
     IOSurface(IOSurfaceRef, const DestinationColorSpace&);
 
-    IntSize contextSize() const { return m_contextSize; }
-    void setContextSize(IntSize);
-
     DestinationColorSpace m_colorSpace;
     IntSize m_size;
-    IntSize m_contextSize;
     size_t m_totalBytes;
 
     std::unique_ptr<GraphicsContext> m_graphicsContext;

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


--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm	2022-05-14 15:59:33 UTC (rev 294196)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm	2022-05-14 16:26:54 UTC (rev 294197)
@@ -45,20 +45,16 @@
 
 std::unique_ptr<IOSurface> IOSurface::create(IOSurfacePool* pool, IntSize size, const DestinationColorSpace& colorSpace, Format pixelFormat)
 {
-    return IOSurface::create(pool, size, size, colorSpace, pixelFormat);
-}
-
-std::unique_ptr<IOSurface> IOSurface::create(IOSurfacePool* pool, IntSize size, IntSize contextSize, const DestinationColorSpace& colorSpace, Format 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;
+    if (pool) {
+        if (auto cachedSurface = pool->takeSurface(size, colorSpace, pixelFormat)) {
+            cachedSurface->releaseGraphicsContext();
+            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));
+    auto surface = std::unique_ptr<IOSurface>(new IOSurface(size, colorSpace, pixelFormat, success));
     if (!success) {
         LOG(IOSurface, "IOSurface::create failed to create %dx%d surface", size.width(), size.height());
         return nullptr;
@@ -174,14 +170,11 @@
 
 }
 
-IOSurface::IOSurface(IntSize size, IntSize contextSize, const DestinationColorSpace& colorSpace, Format format, bool& success)
+IOSurface::IOSurface(IntSize size, const DestinationColorSpace& colorSpace, Format format, bool& success)
     : m_colorSpace(colorSpace)
     , m_size(size)
-    , m_contextSize(contextSize)
 {
     ASSERT(!success);
-    ASSERT(contextSize.width() <= size.width());
-    ASSERT(contextSize.height() <= size.height());
     ASSERT(!size.isEmpty());
 
     NSDictionary *options;
@@ -314,17 +307,6 @@
     return adoptCF(CGIOSurfaceContextCreateImageReference(surface->ensurePlatformContext()));
 }
 
-void IOSurface::setContextSize(IntSize contextSize)
-{
-    if (contextSize == m_contextSize)
-        return;
-
-    // Release the graphics context and update the context size. Next time the graphics context is
-    // accessed, we will construct it again with the right size.
-    releaseGraphicsContext();
-    m_contextSize = contextSize;
-}
-
 CGContextRef IOSurface::ensurePlatformContext(const HostWindow* hostWindow)
 {
     if (m_cgContext)
@@ -353,7 +335,7 @@
         break;
     }
     
-    m_cgContext = adoptCF(CGIOSurfaceContextCreate(m_surface.get(), m_contextSize.width(), m_contextSize.height(), bitsPerComponent, bitsPerPixel, m_colorSpace.platformColorSpace(), bitmapInfo));
+    m_cgContext = adoptCF(CGIOSurfaceContextCreate(m_surface.get(), m_size.width(), m_size.height(), bitsPerComponent, bitsPerPixel, m_colorSpace.platformColorSpace(), bitmapInfo));
 
 #if PLATFORM(MAC)
     if (auto displayMask = primaryOpenGLDisplayMask()) {

Modified: trunk/Source/WebKit/ChangeLog (294196 => 294197)


--- trunk/Source/WebKit/ChangeLog	2022-05-14 15:59:33 UTC (rev 294196)
+++ trunk/Source/WebKit/ChangeLog	2022-05-14 16:26:54 UTC (rev 294197)
@@ -1,3 +1,16 @@
+2022-05-14  Kimmo Kinnunen  <[email protected]>
+
+        WebCore::IOSurface refers to unused context size
+        https://bugs.webkit.org/show_bug.cgi?id=240385
+
+        Reviewed by Simon Fraser.
+
+        Adjust after removing the IOSurface context size parameter.
+        All call sites passed the surface size.
+
+        * WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp:
+        (WebKit::ImageBufferShareableMappedIOSurfaceBackend::create):
+
 2022-05-08  Jean-Yves Avenard  <[email protected]>
 
         SharedBuffer should be copied and then attributed back to WebContent

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


--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp	2022-05-14 15:59:33 UTC (rev 294196)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp	2022-05-14 16:26:54 UTC (rev 294197)
@@ -46,7 +46,7 @@
     if (backendSize.isEmpty())
         return nullptr;
 
-    auto surface = IOSurface::create(creationContext.surfacePool, backendSize, backendSize, parameters.colorSpace, IOSurface::formatForPixelFormat(parameters.pixelFormat));
+    auto surface = IOSurface::create(creationContext.surfacePool, backendSize, parameters.colorSpace, IOSurface::formatForPixelFormat(parameters.pixelFormat));
     if (!surface)
         return nullptr;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to