Title: [270605] trunk/Source
Revision
270605
Author
[email protected]
Date
2020-12-09 15:01:08 -0800 (Wed, 09 Dec 2020)

Log Message

[GPU Process]: Recording an in-process ImageBuffer drawing has to convert it to a NativeImage first
https://bugs.webkit.org/show_bug.cgi?id=219705

Reviewed by Wenson Hsieh.

Source/WebCore:

We will allow GraphicsContext::drawImageBuffer() to proceed with the
painting code path if the ImageBuffer is not a RemoteImageBuffer. In this
case ImageBuffer::draw() extracts a NativeImage from the ImageBuffer and
calls GraphicsContext::drawNativeImage() which will send the NativeImage
to GPUP.

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawImageBuffer):
* platform/graphics/GraphicsContextImpl.h:
(WebCore::GraphicsContextImpl::canDrawImageBuffer const):
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::canDrawImageBuffer const):
* platform/graphics/displaylists/DisplayListRecorder.h:
(WebCore::DisplayList::Recorder::Delegate::isCachedImageBuffer const):

Source/WebKit:

Override the virtual method isCachedImageBuffer() which in this case
answers the question: is this a remote ImageBuffer or not?

* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (270604 => 270605)


--- trunk/Source/WebCore/ChangeLog	2020-12-09 22:33:47 UTC (rev 270604)
+++ trunk/Source/WebCore/ChangeLog	2020-12-09 23:01:08 UTC (rev 270605)
@@ -1,3 +1,25 @@
+2020-12-09  Said Abou-Hallawa  <[email protected]>
+
+        [GPU Process]: Recording an in-process ImageBuffer drawing has to convert it to a NativeImage first
+        https://bugs.webkit.org/show_bug.cgi?id=219705
+
+        Reviewed by Wenson Hsieh.
+
+        We will allow GraphicsContext::drawImageBuffer() to proceed with the 
+        painting code path if the ImageBuffer is not a RemoteImageBuffer. In this
+        case ImageBuffer::draw() extracts a NativeImage from the ImageBuffer and
+        calls GraphicsContext::drawNativeImage() which will send the NativeImage
+        to GPUP.
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::drawImageBuffer):
+        * platform/graphics/GraphicsContextImpl.h:
+        (WebCore::GraphicsContextImpl::canDrawImageBuffer const):
+        * platform/graphics/displaylists/DisplayListRecorder.cpp:
+        (WebCore::DisplayList::Recorder::canDrawImageBuffer const):
+        * platform/graphics/displaylists/DisplayListRecorder.h:
+        (WebCore::DisplayList::Recorder::Delegate::isCachedImageBuffer const):
+
 2020-12-09  John Wilander  <[email protected]>
 
         PCM: Make JSON key names use underscores according to the W3C conversation

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (270604 => 270605)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2020-12-09 22:33:47 UTC (rev 270604)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2020-12-09 23:01:08 UTC (rev 270605)
@@ -803,7 +803,7 @@
     if (paintingDisabled())
         return;
 
-    if (m_impl) {
+    if (m_impl && m_impl->canDrawImageBuffer(image)) {
         m_impl->drawImageBuffer(image, destination, source, options);
         return;
     }

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.h (270604 => 270605)


--- trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.h	2020-12-09 22:33:47 UTC (rev 270604)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.h	2020-12-09 23:01:08 UTC (rev 270605)
@@ -39,6 +39,7 @@
     GraphicsContext& graphicsContext() const { return m_graphicsContext; }
 
     virtual bool hasPlatformContext() const = 0;
+    virtual bool canDrawImageBuffer(const ImageBuffer&) const { return true; }
     virtual PlatformGraphicsContext* platformContext() const = 0;
 
     virtual void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) = 0;

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (270604 => 270605)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2020-12-09 22:33:47 UTC (rev 270604)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2020-12-09 23:01:08 UTC (rev 270605)
@@ -137,6 +137,11 @@
     currentState().stateChange.accumulate(state, flags);
 }
 
+bool Recorder::canDrawImageBuffer(const ImageBuffer& imageBuffer) const
+{
+    return !m_delegate || m_delegate->isCachedImageBuffer(imageBuffer);
+}
+
 void Recorder::clearShadow()
 {
     append<ClearShadow>();

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (270604 => 270605)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h	2020-12-09 22:33:47 UTC (rev 270604)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h	2020-12-09 23:01:08 UTC (rev 270605)
@@ -67,6 +67,7 @@
         virtual void willAppendItemOfType(ItemType) { }
         virtual void didAppendItemOfType(ItemType) { }
         virtual void cacheNativeImage(NativeImage&) { }
+        virtual bool isCachedImageBuffer(const ImageBuffer&) const { return false; }
     };
 
     void flushContext(FlushIdentifier identifier) { append<FlushContext>(identifier); }
@@ -74,6 +75,7 @@
 private:
     friend class DrawGlyphsRecorder;
     bool hasPlatformContext() const override { return false; }
+    bool canDrawImageBuffer(const ImageBuffer&) const override;
     PlatformGraphicsContext* platformContext() const override { return nullptr; }
 
     void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) override;

Modified: trunk/Source/WebKit/ChangeLog (270604 => 270605)


--- trunk/Source/WebKit/ChangeLog	2020-12-09 22:33:47 UTC (rev 270604)
+++ trunk/Source/WebKit/ChangeLog	2020-12-09 23:01:08 UTC (rev 270605)
@@ -1,3 +1,15 @@
+2020-12-09  Said Abou-Hallawa  <[email protected]>
+
+        [GPU Process]: Recording an in-process ImageBuffer drawing has to convert it to a NativeImage first
+        https://bugs.webkit.org/show_bug.cgi?id=219705
+
+        Reviewed by Wenson Hsieh.
+
+        Override the virtual method isCachedImageBuffer() which in this case
+        answers the question: is this a remote ImageBuffer or not?
+
+        * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
+
 2020-12-09  Per Arne Vollan  <[email protected]>
 
         [macOS] Allow mach-lookup of com.apple.relatived.tempest in WebKit GPU process

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (270604 => 270605)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2020-12-09 22:33:47 UTC (rev 270604)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2020-12-09 23:01:08 UTC (rev 270605)
@@ -189,6 +189,15 @@
             m_remoteRenderingBackendProxy->remoteResourceCacheProxy().cacheNativeImage(image);
     }
 
+    bool isCachedImageBuffer(const WebCore::ImageBuffer& imageBuffer) const override
+    {
+        if (!m_remoteRenderingBackendProxy)
+            return false;
+        auto cachedImageBuffer = m_remoteRenderingBackendProxy->remoteResourceCacheProxy().cachedImageBuffer(imageBuffer.renderingResourceIdentifier());
+        ASSERT(!cachedImageBuffer || cachedImageBuffer == &imageBuffer);
+        return cachedImageBuffer;
+    }
+
     void changeDestinationImageBuffer(WebCore::RenderingResourceIdentifier nextImageBuffer) final
     {
         bool wasEmpty = m_drawingContext.displayList().isEmpty();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to