Title: [273464] trunk/Source/WebKit
Revision
273464
Author
peng.l...@apple.com
Date
2021-02-24 17:18:07 -0800 (Wed, 24 Feb 2021)

Log Message

[GPUP] Refactor RemoteImageDecoderAVF::createFrameImageAtIndex()
https://bugs.webkit.org/show_bug.cgi?id=222300

Reviewed by Jer Noble.

Use callOnMainThreadAndWait() instead of callOnMainThread() and remove the semaphore.

No new tests, this has no behavior change.

* GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in:
* WebProcess/GPU/media/RemoteImageDecoderAVF.cpp:
(WebKit::RemoteImageDecoderAVF::createFrameImageAtIndex):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (273463 => 273464)


--- trunk/Source/WebKit/ChangeLog	2021-02-25 01:18:01 UTC (rev 273463)
+++ trunk/Source/WebKit/ChangeLog	2021-02-25 01:18:07 UTC (rev 273464)
@@ -1,3 +1,18 @@
+2021-02-24  Peng Liu  <peng.l...@apple.com>
+
+        [GPUP] Refactor RemoteImageDecoderAVF::createFrameImageAtIndex()
+        https://bugs.webkit.org/show_bug.cgi?id=222300
+
+        Reviewed by Jer Noble.
+
+        Use callOnMainThreadAndWait() instead of callOnMainThread() and remove the semaphore.
+
+        No new tests, this has no behavior change.
+
+        * GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in:
+        * WebProcess/GPU/media/RemoteImageDecoderAVF.cpp:
+        (WebKit::RemoteImageDecoderAVF::createFrameImageAtIndex):
+
 2021-02-24  Chris Dumez  <cdu...@apple.com>
 
         Unreviewed, fix build with the latest iOS SDK.

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in (273463 => 273464)


--- trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in	2021-02-25 01:18:01 UTC (rev 273463)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in	2021-02-25 01:18:07 UTC (rev 273464)
@@ -32,7 +32,7 @@
     DeleteDecoder(WebCore::ImageDecoderIdentifier identifier)
     SetExpectedContentSize(WebCore::ImageDecoderIdentifier identifier, long long expectedContentSize)
     SetData(WebCore::ImageDecoderIdentifier identifier, IPC::SharedBufferDataReference data, bool allDataReceived) -> (uint32_t frameCount, WebCore::IntSize size, bool hasTrack, Optional<Vector<WebCore::ImageDecoder::FrameInfo>> frameInfos) Synchronous
-    CreateFrameImageAtIndex(WebCore::ImageDecoderIdentifier identifier, uint32_t index) -> (Optional<MachSendRight> sendRight) Async
+    CreateFrameImageAtIndex(WebCore::ImageDecoderIdentifier identifier, uint32_t index) -> (Optional<MachSendRight> sendRight) Synchronous
 }
 
 #endif

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.cpp (273463 => 273464)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.cpp	2021-02-25 01:18:01 UTC (rev 273463)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.cpp	2021-02-25 01:18:07 UTC (rev 273464)
@@ -40,7 +40,6 @@
 #include <WebCore/SharedBuffer.h>
 #include <WebCore/UTIUtilities.h>
 #include <wtf/MachSendRight.h>
-#include <wtf/threads/BinarySemaphore.h>
 
 namespace WebKit {
 
@@ -171,32 +170,22 @@
     if (isMainThread())
         return nullptr;
 
-    BinarySemaphore decodeSemaphore;
-    callOnMainThread([this, protectedThis = makeRef(*this), index, &decodeSemaphore] {
-        gpuProcessConnection().connection().sendWithAsyncReply(Messages::RemoteImageDecoderAVFProxy::CreateFrameImageAtIndex(m_identifier, index), [&](auto&& sendRight) {
-            if (!sendRight) {
-                decodeSemaphore.signal();
-                return;
-            }
+    callOnMainThreadAndWait([this, protectedThis = makeRef(*this), index] {
+        Optional<MachSendRight> sendRight;
+        if (!gpuProcessConnection().connection().sendSync(Messages::RemoteImageDecoderAVFProxy::CreateFrameImageAtIndex(m_identifier, index), Messages::RemoteImageDecoderAVFProxy::CreateFrameImageAtIndex::Reply(sendRight), 0))
+            return;
 
-            auto surface = WebCore::IOSurface::createFromSendRight(WTFMove(*sendRight), sRGBColorSpaceRef());
-            if (!surface) {
-                decodeSemaphore.signal();
-                return;
-            }
+        if (!sendRight)
+            return;
 
-            auto image = IOSurface::sinkIntoImage(WTFMove(surface));
-            if (!image) {
-                decodeSemaphore.signal();
-                return;
-            }
+        auto surface = WebCore::IOSurface::createFromSendRight(WTFMove(*sendRight), sRGBColorSpaceRef());
+        if (!surface)
+            return;
 
+        if (auto image = IOSurface::sinkIntoImage(WTFMove(surface)))
             m_frameImages.add(index, image);
-            decodeSemaphore.signal();
-        });
     });
 
-    decodeSemaphore.wait();
     if (m_frameImages.contains(index))
         return m_frameImages.get(index);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to