Title: [289604] trunk/Source
Revision
289604
Author
[email protected]
Date
2022-02-10 21:40:16 -0800 (Thu, 10 Feb 2022)

Log Message

Separate out setVolatile() from setNonVolatile() on IOSurface-backed buffers
https://bugs.webkit.org/show_bug.cgi?id=236475

Reviewed by Tim Horton.

setVolatile(true) and setVolatile(false) are quite different in their needs, so
separate them out into separate functions.

setVolatile(true) can be done asynchronously (as a future patch will). The
return value tells if you succeeded in making the surfaced volatile, i.e. if it
was not in-use.

setVolatile(false) has to be synchronous, and the return value tells you whether
you need to repaint the entire surface.

Source/WebCore:

* platform/graphics/ConcreteImageBuffer.h:
* platform/graphics/ImageBuffer.h:
* platform/graphics/ImageBufferBackend.h:
(WebCore::ImageBufferBackend::releaseGraphicsContext):
(WebCore::ImageBufferBackend::setVolatile):
(WebCore::ImageBufferBackend::setNonVolatile):
* platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
(WebCore::ImageBufferIOSurfaceBackend::setVolatile):
(WebCore::ImageBufferIOSurfaceBackend::setNonVolatile):
* platform/graphics/cg/ImageBufferIOSurfaceBackend.h:

Source/WebKit:

* Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::setBufferVolatility):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (289603 => 289604)


--- trunk/Source/WebCore/ChangeLog	2022-02-11 05:36:37 UTC (rev 289603)
+++ trunk/Source/WebCore/ChangeLog	2022-02-11 05:40:16 UTC (rev 289604)
@@ -1,3 +1,31 @@
+2022-02-10  Simon Fraser  <[email protected]>
+
+        Separate out setVolatile() from setNonVolatile() on IOSurface-backed buffers
+        https://bugs.webkit.org/show_bug.cgi?id=236475
+
+        Reviewed by Tim Horton.
+
+        setVolatile(true) and setVolatile(false) are quite different in their needs, so
+        separate them out into separate functions.
+        
+        setVolatile(true) can be done asynchronously (as a future patch will). The
+        return value tells if you succeeded in making the surfaced volatile, i.e. if it
+        was not in-use.
+        
+        setVolatile(false) has to be synchronous, and the return value tells you whether
+        you need to repaint the entire surface.
+
+        * platform/graphics/ConcreteImageBuffer.h:
+        * platform/graphics/ImageBuffer.h:
+        * platform/graphics/ImageBufferBackend.h:
+        (WebCore::ImageBufferBackend::releaseGraphicsContext):
+        (WebCore::ImageBufferBackend::setVolatile):
+        (WebCore::ImageBufferBackend::setNonVolatile):
+        * platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
+        (WebCore::ImageBufferIOSurfaceBackend::setVolatile):
+        (WebCore::ImageBufferIOSurfaceBackend::setNonVolatile):
+        * platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
+
 2022-02-10  Alan Bujtas  <[email protected]>
 
         [LFC][IFC] Non-content runs (e.g. inline box start/end) do not need "within the line" flip

Modified: trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h (289603 => 289604)


--- trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h	2022-02-11 05:36:37 UTC (rev 289603)
+++ trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h	2022-02-11 05:40:16 UTC (rev 289604)
@@ -289,10 +289,18 @@
             return backend->releaseGraphicsContext();
     }
 
-    VolatilityState setVolatile(bool isVolatile) override
+    bool setVolatile() override
     {
         if (auto* backend = ensureBackendCreated())
-            return backend->setVolatile(isVolatile);
+            return backend->setVolatile();
+            
+        return true; // Just claim we succeedded.
+    }
+
+    VolatilityState setNonVolatile() override
+    {
+        if (auto* backend = ensureBackendCreated())
+            return backend->setNonVolatile();
         return VolatilityState::Valid;
     }
 

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (289603 => 289604)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2022-02-11 05:36:37 UTC (rev 289603)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2022-02-11 05:40:16 UTC (rev 289604)
@@ -88,9 +88,12 @@
 
     virtual bool isInUse() const = 0;
     virtual void releaseGraphicsContext() = 0;
-    virtual VolatilityState setVolatile(bool) = 0;
     virtual void releaseBufferToPool() = 0;
 
+    // Returns true on success.
+    virtual bool setVolatile() = 0;
+    virtual VolatilityState setNonVolatile() = 0;
+
     virtual std::unique_ptr<ThreadSafeImageBufferFlusher> createFlusher() = 0;
 
     virtual RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const = 0;

Modified: trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h (289603 => 289604)


--- trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h	2022-02-11 05:36:37 UTC (rev 289603)
+++ trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h	2022-02-11 05:40:16 UTC (rev 289604)
@@ -116,9 +116,12 @@
 
     virtual bool isInUse() const { return false; }
     virtual void releaseGraphicsContext() { ASSERT_NOT_REACHED(); }
-    virtual VolatilityState setVolatile(bool) { return VolatilityState::Valid; }
     virtual void releaseBufferToPool() { }
 
+    // Returns true on success.
+    virtual bool setVolatile() { return true; }
+    virtual VolatilityState setNonVolatile() { return VolatilityState::Valid; }
+
     virtual std::unique_ptr<ThreadSafeImageBufferFlusher> createFlusher() { return nullptr; }
 
     void applyBaseTransformToContext() const;

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


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp	2022-02-11 05:36:37 UTC (rev 289603)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp	2022-02-11 05:40:16 UTC (rev 289604)
@@ -234,11 +234,20 @@
     return m_surface->releaseGraphicsContext();
 }
 
-VolatilityState ImageBufferIOSurfaceBackend::setVolatile(bool isVolatile)
+bool ImageBufferIOSurfaceBackend::setVolatile()
 {
-    return m_surface->setVolatile(isVolatile);
+    if (m_surface->isInUse())
+        return false;
+
+    m_surface->setVolatile(true);
+    return true;
 }
 
+VolatilityState ImageBufferIOSurfaceBackend::setNonVolatile()
+{
+    return m_surface->setVolatile(false);
+}
+
 void ImageBufferIOSurfaceBackend::releaseBufferToPool()
 {
     IOSurface::moveToPool(WTFMove(m_surface));

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h (289603 => 289604)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h	2022-02-11 05:36:37 UTC (rev 289603)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h	2022-02-11 05:40:16 UTC (rev 289604)
@@ -68,9 +68,11 @@
 
     bool isInUse() const override;
     void releaseGraphicsContext() override;
-    VolatilityState setVolatile(bool) override;
     void releaseBufferToPool() override;
 
+    bool setVolatile() override;
+    VolatilityState setNonVolatile() override;
+
     void ensureNativeImagesHaveCopiedBackingStore() final;
 
     static RetainPtr<CGColorSpaceRef> contextColorSpace(const GraphicsContext&);

Modified: trunk/Source/WebKit/ChangeLog (289603 => 289604)


--- trunk/Source/WebKit/ChangeLog	2022-02-11 05:36:37 UTC (rev 289603)
+++ trunk/Source/WebKit/ChangeLog	2022-02-11 05:40:16 UTC (rev 289604)
@@ -1,5 +1,26 @@
 2022-02-10  Simon Fraser  <[email protected]>
 
+        Separate out setVolatile() from setNonVolatile() on IOSurface-backed buffers
+        https://bugs.webkit.org/show_bug.cgi?id=236475
+
+        Reviewed by Tim Horton.
+
+        setVolatile(true) and setVolatile(false) are quite different in their needs, so
+        separate them out into separate functions.
+        
+        setVolatile(true) can be done asynchronously (as a future patch will). The
+        return value tells if you succeeded in making the surfaced volatile, i.e. if it
+        was not in-use.
+        
+        setVolatile(false) has to be synchronous, and the return value tells you whether
+        you need to repaint the entire surface.
+
+        * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
+        * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::setBufferVolatility):
+
+2022-02-10  Simon Fraser  <[email protected]>
+
         Have RemoteLayerBackingStore talk to RemoteLayerBackingStoreCollection directly
         https://bugs.webkit.org/show_bug.cgi?id=236463
 

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h (289603 => 289604)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h	2022-02-11 05:36:37 UTC (rev 289603)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h	2022-02-11 05:40:16 UTC (rev 289604)
@@ -136,13 +136,17 @@
         void discard();
     };
 
+    // Used in the WebContent Process.
     Buffer m_frontBuffer;
     Buffer m_backBuffer;
     Buffer m_secondaryBackBuffer;
+
+    // Used in the UI Process.
     std::optional<ImageBufferBackendHandle> m_bufferHandle;
     // FIXME: This should be removed and m_bufferHandle should be used to ref the buffer once ShareableBitmap::Handle
     // can be encoded multiple times. http://webkit.org/b/234169
     std::optional<MachSendRight> m_contentsBufferHandle;
+
 #if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER)
     std::optional<ImageBufferBackendHandle> m_displayListBufferHandle;
 #endif

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm (289603 => 289604)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm	2022-02-11 05:36:37 UTC (rev 289603)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm	2022-02-11 05:40:16 UTC (rev 289604)
@@ -526,8 +526,7 @@
 
         buffer.imageBuffer->releaseGraphicsContext();
 
-        if (!buffer.imageBuffer->isInUse()) {
-            buffer.imageBuffer->setVolatile(true);
+        if (buffer.imageBuffer->setVolatile()) {
             buffer.isVolatile = true;
             return true;
         }
@@ -540,7 +539,7 @@
         if (!buffer.imageBuffer || !buffer.isVolatile)
             return false;
 
-        auto previousState = buffer.imageBuffer->setVolatile(false);
+        auto previousState = buffer.imageBuffer->setNonVolatile();
         buffer.isVolatile = false;
 
         return previousState == WebCore::VolatilityState::Empty;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to