Title: [257709] trunk/Source
Revision
257709
Author
[email protected]
Date
2020-03-02 07:34:07 -0800 (Mon, 02 Mar 2020)

Log Message

LocalSampleBufferDisplayLayer is not computing the correct bounds/position in GPUProcess
https://bugs.webkit.org/show_bug.cgi?id=208370

Reviewed by Eric Carlson.

Source/WebCore:

When in GPUProcess, we need to update the bounds of the remote LocalSampleBufferDisplayLayer.
In case of samples with rotation, the computation was wrong.
Move the rotation logic from MediaPLayerPrivateMediaStreamAVFObjC to LocalSampleBufferDisplayLayer.
This allows in WebKit2 to send the rotation information with the bounds information.
Remove the bounds getter since it is no longer used.
Covered by manual tests.

* platform/graphics/avfoundation/SampleBufferDisplayLayer.h:
* platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h:
* platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm:
(WebCore::LocalSampleBufferDisplayLayer::updateBoundsAndPosition):
(WebCore::LocalSampleBufferDisplayLayer::updateRootLayerBoundsAndPosition):
(WebCore::LocalSampleBufferDisplayLayer::enqueueSample):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateDisplayLayer):
* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::captureOutputDidOutputSampleBufferFromConnection):

Source/WebKit:

Remove the bounds getter logic.
Make use of new LocalSampleBufferDisplayLayer routine to properly update the layer bounds.

* GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp:
(WebKit::RemoteSampleBufferDisplayLayer::updateBoundsAndPosition):
* GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.h:
* GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.messages.in:
* GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.cpp:
(WebKit::RemoteSampleBufferDisplayLayerManager::createLayer):
* GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.messages.in:
* WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp:
(WebKit::SampleBufferDisplayLayer::SampleBufferDisplayLayer):
(WebKit::SampleBufferDisplayLayer::updateBoundsAndPosition):
* WebProcess/GPU/webrtc/SampleBufferDisplayLayer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257708 => 257709)


--- trunk/Source/WebCore/ChangeLog	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebCore/ChangeLog	2020-03-02 15:34:07 UTC (rev 257709)
@@ -1,3 +1,28 @@
+2020-03-02  Youenn Fablet  <[email protected]>
+
+        LocalSampleBufferDisplayLayer is not computing the correct bounds/position in GPUProcess
+        https://bugs.webkit.org/show_bug.cgi?id=208370
+
+        Reviewed by Eric Carlson.
+
+        When in GPUProcess, we need to update the bounds of the remote LocalSampleBufferDisplayLayer.
+        In case of samples with rotation, the computation was wrong.
+        Move the rotation logic from MediaPLayerPrivateMediaStreamAVFObjC to LocalSampleBufferDisplayLayer.
+        This allows in WebKit2 to send the rotation information with the bounds information.
+        Remove the bounds getter since it is no longer used.
+        Covered by manual tests.
+
+        * platform/graphics/avfoundation/SampleBufferDisplayLayer.h:
+        * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h:
+        * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm:
+        (WebCore::LocalSampleBufferDisplayLayer::updateBoundsAndPosition):
+        (WebCore::LocalSampleBufferDisplayLayer::updateRootLayerBoundsAndPosition):
+        (WebCore::LocalSampleBufferDisplayLayer::enqueueSample):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateDisplayLayer):
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::captureOutputDidOutputSampleBufferFromConnection):
+
 2020-03-02  Rob Buis  <[email protected]>
 
         Add referrerpolicy attribute support for anchors

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/SampleBufferDisplayLayer.h (257708 => 257709)


--- trunk/Source/WebCore/platform/graphics/avfoundation/SampleBufferDisplayLayer.h	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/SampleBufferDisplayLayer.h	2020-03-02 15:34:07 UTC (rev 257709)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "MediaSample.h"
 #include "PlatformLayer.h"
 #include <wtf/WeakPtr.h>
 
@@ -55,9 +56,8 @@
 
     virtual void updateDisplayMode(bool hideDisplayLayer, bool hideRootLayer) = 0;
 
-    virtual CGRect bounds() const = 0;
     virtual void updateAffineTransform(CGAffineTransform) = 0;
-    virtual void updateBoundsAndPosition(CGRect, CGPoint) = 0;
+    virtual void updateBoundsAndPosition(CGRect, MediaSample::VideoRotation) = 0;
 
     virtual void flush() = 0;
     virtual void flushAndRemoveImage() = 0;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h (257708 => 257709)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h	2020-03-02 15:34:07 UTC (rev 257709)
@@ -50,19 +50,21 @@
     void layerErrorDidChange();
     void rootLayerBoundsDidChange();
 
+    CGRect bounds() const;
+
     PlatformLayer* displayLayer();
 
     PlatformLayer* rootLayer() final;
 
-    void updateRootLayerBoundsAndPosition(CGRect, CGPoint);
+    enum class ShouldUpdateRootLayer { No, Yes };
+    void updateRootLayerBoundsAndPosition(CGRect, MediaSample::VideoRotation, ShouldUpdateRootLayer);
 
     bool didFail() const final;
 
     void updateDisplayMode(bool hideDisplayLayer, bool hideRootLayer) final;
 
-    CGRect bounds() const final;
     void updateAffineTransform(CGAffineTransform)  final;
-    void updateBoundsAndPosition(CGRect, CGPoint) final;
+    void updateBoundsAndPosition(CGRect, MediaSample::VideoRotation) final;
 
     void flush() final;
     void flushAndRemoveImage() final;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm (257708 => 257709)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm	2020-03-02 15:34:07 UTC (rev 257709)
@@ -249,21 +249,26 @@
     });
 }
 
-void LocalSampleBufferDisplayLayer::updateBoundsAndPosition(CGRect videoBounds, CGPoint position)
+void LocalSampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, MediaSample::VideoRotation rotation)
 {
-    runWithoutAnimations([&] {
-        m_sampleBufferDisplayLayer.get().bounds = videoBounds;
-        m_sampleBufferDisplayLayer.get().position = position;
-    });
+    updateRootLayerBoundsAndPosition(bounds, rotation, ShouldUpdateRootLayer::No);
 }
 
-void LocalSampleBufferDisplayLayer::updateRootLayerBoundsAndPosition(CGRect videoBounds, CGPoint position)
+void LocalSampleBufferDisplayLayer::updateRootLayerBoundsAndPosition(CGRect bounds, MediaSample::VideoRotation rotation, ShouldUpdateRootLayer shouldUpdateRootLayer)
 {
     runWithoutAnimations([&] {
-        m_rootLayer.get().bounds = videoBounds;
-        m_rootLayer.get().position = position;
-        m_sampleBufferDisplayLayer.get().bounds = videoBounds;
+        CGPoint position = { bounds.size.width / 2, bounds.size.height / 2};
+
+        if (shouldUpdateRootLayer == ShouldUpdateRootLayer::Yes) {
+            m_rootLayer.get().position = position;
+            m_rootLayer.get().bounds = bounds;
+        }
+
+        if (rotation == MediaSample::VideoRotation::Right || rotation == MediaSample::VideoRotation::Left)
+            std::swap(bounds.size.width, bounds.size.height);
+
         m_sampleBufferDisplayLayer.get().position = position;
+        m_sampleBufferDisplayLayer.get().bounds = bounds;
     });
 }
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (257708 => 257709)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2020-03-02 15:34:07 UTC (rev 257709)
@@ -1046,12 +1046,7 @@
     if (!m_sampleBufferDisplayLayer)
         return;
 
-    auto bounds = rootLayer().bounds;
-    auto videoBounds = bounds;
-    if (m_videoRotation == MediaSample::VideoRotation::Right || m_videoRotation == MediaSample::VideoRotation::Left)
-        std::swap(videoBounds.size.width, videoBounds.size.height);
-
-    m_sampleBufferDisplayLayer->updateBoundsAndPosition(videoBounds, { bounds.size.width / 2, bounds.size.height / 2});
+    m_sampleBufferDisplayLayer->updateBoundsAndPosition(rootLayer().bounds, m_videoRotation);
 }
 
 void MediaPlayerPrivateMediaStreamAVFObjC::rootLayerBoundsDidChange()

Modified: trunk/Source/WebKit/ChangeLog (257708 => 257709)


--- trunk/Source/WebKit/ChangeLog	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebKit/ChangeLog	2020-03-02 15:34:07 UTC (rev 257709)
@@ -1,3 +1,25 @@
+2020-03-02  Youenn Fablet  <[email protected]>
+
+        LocalSampleBufferDisplayLayer is not computing the correct bounds/position in GPUProcess
+        https://bugs.webkit.org/show_bug.cgi?id=208370
+
+        Reviewed by Eric Carlson.
+
+        Remove the bounds getter logic.
+        Make use of new LocalSampleBufferDisplayLayer routine to properly update the layer bounds.
+
+        * GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp:
+        (WebKit::RemoteSampleBufferDisplayLayer::updateBoundsAndPosition):
+        * GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.h:
+        * GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.messages.in:
+        * GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.cpp:
+        (WebKit::RemoteSampleBufferDisplayLayerManager::createLayer):
+        * GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.messages.in:
+        * WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp:
+        (WebKit::SampleBufferDisplayLayer::SampleBufferDisplayLayer):
+        (WebKit::SampleBufferDisplayLayer::updateBoundsAndPosition):
+        * WebProcess/GPU/webrtc/SampleBufferDisplayLayer.h:
+
 2020-03-02  youenn fablet  <[email protected]>
 
         Enable audio MediaStreamTrack rendering in GPUProcess if audio capture happens in GPUProcess

Modified: trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp (257708 => 257709)


--- trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp	2020-03-02 15:34:07 UTC (rev 257709)
@@ -80,9 +80,9 @@
     m_sampleBufferDisplayLayer->updateAffineTransform(transform);
 }
 
-void RemoteSampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, CGPoint position)
+void RemoteSampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, WebCore::MediaSample::VideoRotation rotation)
 {
-    m_sampleBufferDisplayLayer->updateRootLayerBoundsAndPosition(bounds, position);
+    m_sampleBufferDisplayLayer->updateRootLayerBoundsAndPosition(bounds, rotation, LocalSampleBufferDisplayLayer::ShouldUpdateRootLayer::Yes);
 }
 
 void RemoteSampleBufferDisplayLayer::flush()

Modified: trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.h (257708 => 257709)


--- trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.h	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.h	2020-03-02 15:34:07 UTC (rev 257709)
@@ -59,7 +59,7 @@
 
     void updateDisplayMode(bool hideDisplayLayer, bool hideRootLayer);
     void updateAffineTransform(CGAffineTransform);
-    void updateBoundsAndPosition(CGRect, CGPoint);
+    void updateBoundsAndPosition(CGRect, WebCore::MediaSample::VideoRotation);
     void flush();
     void flushAndRemoveImage();
     void enqueueSample(WebCore::RemoteVideoSample&&);

Modified: trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.messages.in (257708 => 257709)


--- trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.messages.in	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.messages.in	2020-03-02 15:34:07 UTC (rev 257709)
@@ -26,7 +26,7 @@
 messages -> RemoteSampleBufferDisplayLayer NotRefCounted {
     UpdateDisplayMode(bool hideDisplayLayer, bool hideRootLayer)
     UpdateAffineTransform(CGAffineTransform transform)
-    UpdateBoundsAndPosition(CGRect bounds, CGPoint position)
+    UpdateBoundsAndPosition(CGRect bounds, WebCore::MediaSample::VideoRotation rotation)
     Flush()
     FlushAndRemoveImage()
     EnqueueSample(WebCore::RemoteVideoSample sample)

Modified: trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.cpp (257708 => 257709)


--- trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.cpp	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.cpp	2020-03-02 15:34:07 UTC (rev 257709)
@@ -53,9 +53,9 @@
     ASSERT(!m_layers.contains(identifier));
     auto layer = RemoteSampleBufferDisplayLayer::create(identifier, m_connection.copyRef(), hideRootLayer, size);
     if (!layer)
-        return reply({ }, { });
+        return reply({ });
 
-    reply(layer->contextID(), layer->bounds());
+    reply(layer->contextID());
     m_layers.add(identifier, WTFMove(layer));
 }
 

Modified: trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.messages.in (257708 => 257709)


--- trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.messages.in	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.messages.in	2020-03-02 15:34:07 UTC (rev 257709)
@@ -24,7 +24,7 @@
 #if PLATFORM(COCOA) && ENABLE(GPU_PROCESS) && ENABLE(VIDEO_TRACK) && ENABLE(MEDIA_STREAM)
 
 messages -> RemoteSampleBufferDisplayLayerManager NotRefCounted {
-    CreateLayer(WebKit::SampleBufferDisplayLayerIdentifier id, bool hideRootLayer, WebCore::IntSize size) -> (Optional<WebKit::LayerHostingContextID> contextID, CGRect bounds) Synchronous
+    CreateLayer(WebKit::SampleBufferDisplayLayerIdentifier id, bool hideRootLayer, WebCore::IntSize size) -> (Optional<WebKit::LayerHostingContextID> contextID) Synchronous
     ReleaseLayer(WebKit::SampleBufferDisplayLayerIdentifier id)
 }
 

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp (257708 => 257709)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp	2020-03-02 15:34:07 UTC (rev 257709)
@@ -56,7 +56,7 @@
     manager.addLayer(*this);
 
     Optional<LayerHostingContextID> contextId;
-    if (!m_connection->sendSync(Messages::RemoteSampleBufferDisplayLayerManager::CreateLayer { m_identifier, hideRootLayer, size }, Messages::RemoteSampleBufferDisplayLayerManager::CreateLayer::Reply { contextId, m_bounds }, 0))
+    if (!m_connection->sendSync(Messages::RemoteSampleBufferDisplayLayerManager::CreateLayer { m_identifier, hideRootLayer, size }, Messages::RemoteSampleBufferDisplayLayerManager::CreateLayer::Reply { contextId }, 0))
         return;
 
     if (!contextId)
@@ -82,20 +82,14 @@
     m_connection->send(Messages::RemoteSampleBufferDisplayLayer::UpdateDisplayMode { hideDisplayLayer, hideRootLayer }, m_identifier);
 }
 
-CGRect SampleBufferDisplayLayer::bounds() const
-{
-    return m_bounds;
-}
-
 void SampleBufferDisplayLayer::updateAffineTransform(CGAffineTransform transform)
 {
     m_connection->send(Messages::RemoteSampleBufferDisplayLayer::UpdateAffineTransform { transform }, m_identifier);
 }
 
-void SampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, CGPoint position)
+void SampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, MediaSample::VideoRotation rotation)
 {
-    m_bounds = bounds;
-    m_connection->send(Messages::RemoteSampleBufferDisplayLayer::UpdateBoundsAndPosition { bounds, position }, m_identifier);
+    m_connection->send(Messages::RemoteSampleBufferDisplayLayer::UpdateBoundsAndPosition { bounds, rotation }, m_identifier);
 }
 
 void SampleBufferDisplayLayer::flush()

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.h (257708 => 257709)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.h	2020-03-02 15:04:56 UTC (rev 257708)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.h	2020-03-02 15:34:07 UTC (rev 257709)
@@ -51,9 +51,8 @@
     // WebCore::SampleBufferDisplayLayer
     bool didFail() const final;
     void updateDisplayMode(bool hideDisplayLayer, bool hideRootLayer) final;
-    CGRect bounds() const final;
     void updateAffineTransform(CGAffineTransform) final;
-    void updateBoundsAndPosition(CGRect, CGPoint) final;
+    void updateBoundsAndPosition(CGRect, WebCore::MediaSample::VideoRotation) final;
     void flush() final;
     void flushAndRemoveImage() final;
     void enqueueSample(WebCore::MediaSample&) final;
@@ -67,7 +66,6 @@
     SampleBufferDisplayLayerIdentifier m_identifier;
 
     RetainPtr<PlatformLayer> m_videoLayer;
-    CGRect m_bounds;
     bool m_didFail { false };
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to