Title: [288026] trunk/Source/WebCore
Revision
288026
Author
[email protected]
Date
2022-01-14 12:43:18 -0800 (Fri, 14 Jan 2022)

Log Message

MediaPlayerPrivateMediaStreamAVFObjC::m_videoTransform is redundant
https://bugs.webkit.org/show_bug.cgi?id=235181

Patch by Kimmo Kinnunen <[email protected]> on 2022-01-14
Reviewed by Youenn Fablet.

The video sample transform was stored as a member variable during video sample
enqueuing. However, this is just a normal video sample property, and
does not need to be handled specially. The member variable anyway ended up being assigned
during use. Calculating the transform is not a heavy operation, since it
is accessed once per video paint.

This simplifies the future code where the underlying video frame would be
used as-is by WebGL, as there we need to have the correct transform.

No new tests, refactor.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::videoSampleAvailable):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoSample):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateRenderingMode):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288025 => 288026)


--- trunk/Source/WebCore/ChangeLog	2022-01-14 20:41:15 UTC (rev 288025)
+++ trunk/Source/WebCore/ChangeLog	2022-01-14 20:43:18 UTC (rev 288026)
@@ -1,5 +1,30 @@
 2022-01-14  Kimmo Kinnunen  <[email protected]>
 
+        MediaPlayerPrivateMediaStreamAVFObjC::m_videoTransform is redundant
+        https://bugs.webkit.org/show_bug.cgi?id=235181
+
+        Reviewed by Youenn Fablet.
+
+        The video sample transform was stored as a member variable during video sample
+        enqueuing. However, this is just a normal video sample property, and
+        does not need to be handled specially. The member variable anyway ended up being assigned
+        during use. Calculating the transform is not a heavy operation, since it
+        is accessed once per video paint.
+
+        This simplifies the future code where the underlying video frame would be
+        used as-is by WebGL, as there we need to have the correct transform.
+
+        No new tests, refactor.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::videoSampleAvailable):
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoSample):
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateRenderingMode):
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext):
+
+2022-01-14  Kimmo Kinnunen  <[email protected]>
+
         gl.texImage2D upload of getUserMedia streams via <video> element fails
         https://bugs.webkit.org/show_bug.cgi?id=230617
         <rdar://problem/83407577>

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (288025 => 288026)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2022-01-14 20:41:15 UTC (rev 288025)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2022-01-14 20:43:18 UTC (rev 288026)
@@ -136,7 +136,7 @@
 
     void flushRenderers();
 
-    void processNewVideoSample(MediaSample&, bool hasChangedOrientation, VideoSampleMetadata, Seconds);
+    void processNewVideoSample(MediaSample&, VideoSampleMetadata, Seconds);
     void enqueueVideoSample(MediaSample&);
     void requestNotificationWhenReadyForVideoData();
 
@@ -248,7 +248,6 @@
     float m_volume { 1 };
     DisplayMode m_displayMode { None };
     PlaybackState m_playbackState { PlaybackState::None };
-    std::optional<CGAffineTransform> m_videoTransform;
 
     // Used on both main thread and sample thread.
     std::unique_ptr<SampleBufferDisplayLayer> m_sampleBufferDisplayLayer;

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2022-01-14 20:41:15 UTC (rev 288025)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2022-01-14 20:43:18 UTC (rev 288026)
@@ -247,7 +247,7 @@
 void MediaPlayerPrivateMediaStreamAVFObjC::videoSampleAvailable(MediaSample& sample, VideoSampleMetadata metadata)
 {
     auto presentationTime = MonotonicTime::now().secondsSinceEpoch();
-    processNewVideoSample(sample, sample.videoRotation() != m_videoRotation || sample.videoMirrored() != m_videoMirrored, metadata, presentationTime);
+    processNewVideoSample(sample, metadata, presentationTime);
     enqueueVideoSample(sample);
 }
 
@@ -277,7 +277,7 @@
     m_sampleBufferDisplayLayer->enqueueSample(sample);
 }
 
-void MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoSample(MediaSample& sample, bool hasChangedOrientation, VideoSampleMetadata metadata, Seconds presentationTime)
+void MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoSample(MediaSample& sample, VideoSampleMetadata metadata, Seconds presentationTime)
 {
     if (!isMainThread()) {
         {
@@ -284,13 +284,10 @@
             Locker locker { m_currentVideoSampleLock };
             m_currentVideoSample = &sample;
         }
-        callOnMainThread([weakThis = WeakPtr { *this }, hasChangedOrientation, metadata, presentationTime]() mutable {
+        callOnMainThread([weakThis = WeakPtr { *this }, metadata, presentationTime]() mutable {
             if (!weakThis)
                 return;
 
-            if (hasChangedOrientation)
-                weakThis->m_videoTransform = { };
-
             RefPtr<MediaSample> sample;
             {
                 Locker locker { weakThis->m_currentVideoSampleLock };
@@ -299,7 +296,7 @@
             if (!sample)
                 return;
 
-            weakThis->processNewVideoSample(*sample, hasChangedOrientation, metadata, presentationTime);
+            weakThis->processNewVideoSample(*sample, metadata, presentationTime);
         });
         return;
     }
@@ -307,9 +304,6 @@
     if (!m_activeVideoTrack)
         return;
 
-    if (hasChangedOrientation)
-        m_videoTransform = { };
-
     if (!m_imagePainter.mediaSample || m_displayMode != PausedImage) {
         m_imagePainter.mediaSample = &sample;
         m_imagePainter.cgImage = nullptr;
@@ -721,7 +715,6 @@
         return;
 
     scheduleDeferredTask([this] {
-        m_videoTransform = { };
         if (m_player)
             m_player->renderingModeChanged();
     });
@@ -1004,9 +997,7 @@
 
     auto& image = m_imagePainter.cgImage;
     FloatRect imageRect { FloatPoint::zero(), image->size() };
-    if (!m_videoTransform)
-        m_videoTransform = videoTransformationMatrix(*m_imagePainter.mediaSample);
-    AffineTransform videoTransform = *m_videoTransform;
+    AffineTransform videoTransform = videoTransformationMatrix(*m_imagePainter.mediaSample);
     FloatRect transformedDestRect = valueOrDefault(videoTransform.inverse()).mapRect(destRect);
     context.concatCTM(videoTransform);
     context.drawNativeImage(*image, imageRect.size(), transformedDestRect, imageRect);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to