Title: [285517] branches/safari-612-branch/Source/WebCore

Diff

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (285516 => 285517)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-11-09 19:41:58 UTC (rev 285516)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-11-09 19:42:03 UTC (rev 285517)
@@ -1,50 +1,54 @@
-2021-11-08  Kocsen Chung  <[email protected]>
+2021-11-09  Alan Coon  <[email protected]>
 
-        Cherry-pick r285333. rdar://problem/83576009
+        Apply patch. rdar://problem/83419159
 
-    Avoid sending video data to Web process for canvas.drawImage(video)
-    https://bugs.webkit.org/show_bug.cgi?id=230766
-    <rdar://problem/83576009>
-    
-    Reviewed by Simon Fraser.
-    
-    Using nativeImageForCurrentTime() to get the image to paint on to the
-    canvas results in a ShareableBitmap being created to send to the
-    Web process, the identifier for which we then send back to the GPU
-    process for the drawImage() call. But if we use
-    paintCurrentFrameInContext(), this uses the PaintFrameForMedia
-    message, which just sends the MediaPlayer ID and avoids the bitmap
-    creation.
-    
-    * html/canvas/CanvasRenderingContext2DBase.cpp:
-    (WebCore::CanvasRenderingContext2DBase::drawImage):
-    * platform/graphics/ImageBuffer.h:
-    (WebCore::ImageBuffer::isRemote const):
-    
-    
-    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285333 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+    2021-11-08  Kocsen Chung  <[email protected]>
 
-    2021-11-04  Cameron McCormack  <[email protected]>
+            Cherry-pick r285333. rdar://problem/83576009
 
-            Avoid sending video data to Web process for canvas.drawImage(video)
-            https://bugs.webkit.org/show_bug.cgi?id=230766
-            <rdar://problem/83576009>
+        Avoid sending video data to Web process for canvas.drawImage(video)
+        https://bugs.webkit.org/show_bug.cgi?id=230766
+        <rdar://problem/83576009>
 
-            Reviewed by Simon Fraser.
+        Reviewed by Simon Fraser.
 
-            Using nativeImageForCurrentTime() to get the image to paint on to the
-            canvas results in a ShareableBitmap being created to send to the
-            Web process, the identifier for which we then send back to the GPU
-            process for the drawImage() call. But if we use
-            paintCurrentFrameInContext(), this uses the PaintFrameForMedia
-            message, which just sends the MediaPlayer ID and avoids the bitmap
-            creation.
+        Using nativeImageForCurrentTime() to get the image to paint on to the
+        canvas results in a ShareableBitmap being created to send to the
+        Web process, the identifier for which we then send back to the GPU
+        process for the drawImage() call. But if we use
+        paintCurrentFrameInContext(), this uses the PaintFrameForMedia
+        message, which just sends the MediaPlayer ID and avoids the bitmap
+        creation.
 
-            * html/canvas/CanvasRenderingContext2DBase.cpp:
-            (WebCore::CanvasRenderingContext2DBase::drawImage):
-            * platform/graphics/ImageBuffer.h:
-            (WebCore::ImageBuffer::isRemote const):
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::drawImage):
+        * platform/graphics/ImageBuffer.h:
+        (WebCore::ImageBuffer::isRemote const):
 
+
+        git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285333 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+        2021-11-04  Cameron McCormack  <[email protected]>
+
+                Avoid sending video data to Web process for canvas.drawImage(video)
+                https://bugs.webkit.org/show_bug.cgi?id=230766
+                <rdar://problem/83576009>
+
+                Reviewed by Simon Fraser.
+
+                Using nativeImageForCurrentTime() to get the image to paint on to the
+                canvas results in a ShareableBitmap being created to send to the
+                Web process, the identifier for which we then send back to the GPU
+                process for the drawImage() call. But if we use
+                paintCurrentFrameInContext(), this uses the PaintFrameForMedia
+                message, which just sends the MediaPlayer ID and avoids the bitmap
+                creation.
+
+                * html/canvas/CanvasRenderingContext2DBase.cpp:
+                (WebCore::CanvasRenderingContext2DBase::drawImage):
+                * platform/graphics/ImageBuffer.h:
+                (WebCore::ImageBuffer::isRemote const):
+
 2021-11-08  Kocsen Chung  <[email protected]>
 
         Cherry-pick r283470. rdar://problem/85166382
@@ -7774,11 +7778,7 @@
             * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
             (WebCore::GraphicsContextGLOpenGL::reshapeDisplayBufferBacking):
 
-<<<<<<< THEIRS
 2021-09-22  Alan Coon  <[email protected]>
-=======
-        This is in preparation for removing content scanning completely.
->>>>>>> OURS
 
         Cherry-pick r281431. rdar://problem/83429553
 

Modified: branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (285516 => 285517)


--- branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2021-11-09 19:41:58 UTC (rev 285516)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2021-11-09 19:42:03 UTC (rev 285517)
@@ -95,23 +95,26 @@
 MediaPlayerPrivateAVFoundation::MediaRenderingMode MediaPlayerPrivateAVFoundation::currentRenderingMode() const
 {
     if (platformLayer())
-        return MediaRenderingToLayer;
+        return MediaRenderingMode::MediaRenderingToLayer;
 
     if (hasContextRenderer())
-        return MediaRenderingToContext;
+        return MediaRenderingMode::MediaRenderingToContext;
 
-    return MediaRenderingNone;
+    return MediaRenderingMode::MediaRenderingNone;
 }
 
 MediaPlayerPrivateAVFoundation::MediaRenderingMode MediaPlayerPrivateAVFoundation::preferredRenderingMode() const
 {
     if (assetStatus() == MediaPlayerAVAssetStatusUnknown)
-        return MediaRenderingNone;
+        return MediaRenderingMode::MediaRenderingNone;
 
+    if (m_readyState >= MediaPlayer::ReadyState::HaveMetadata && !haveBeenAskedToPaint())
+        return MediaRenderingMode::MediaRenderingToLayer;
+
     if (supportsAcceleratedRendering() && m_player->renderingCanBeAccelerated())
-        return MediaRenderingToLayer;
+        return MediaRenderingMode::MediaRenderingToLayer;
 
-    return MediaRenderingToContext;
+    return MediaRenderingMode::MediaRenderingToContext;
 }
 
 void MediaPlayerPrivateAVFoundation::setUpVideoRendering()
@@ -122,20 +125,22 @@
     MediaRenderingMode currentMode = currentRenderingMode();
     MediaRenderingMode preferredMode = preferredRenderingMode();
 
-    if (currentMode == preferredMode && currentMode != MediaRenderingNone)
+    if (currentMode == preferredMode && currentMode != MediaRenderingMode::MediaRenderingNone)
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER, preferredMode);
+
     switch (preferredMode) {
-    case MediaRenderingNone:
+    case MediaRenderingMode::MediaRenderingNone:
         tearDownVideoRendering();
         break;
 
-    case MediaRenderingToContext:
+    case MediaRenderingMode::MediaRenderingToContext:
         destroyVideoLayer();
         createContextVideoRenderer();
         break;
 
-    case MediaRenderingToLayer:
+    case MediaRenderingMode::MediaRenderingToLayer:
         destroyContextVideoRenderer();
         createVideoLayer();
         break;
@@ -142,7 +147,7 @@
     }
 
     // If using a movie layer, inform the client so the compositing tree is updated.
-    if (currentMode == MediaRenderingToLayer || preferredMode == MediaRenderingToLayer)
+    if (currentMode == MediaRenderingMode::MediaRenderingToLayer || preferredMode == MediaRenderingMode::MediaRenderingToLayer)
         setNeedsRenderingModeChanged();
 }
 
@@ -152,6 +157,8 @@
         return;
     m_needsRenderingModeChanged = true;
 
+    ALWAYS_LOG(LOGIDENTIFIER);
+
     queueTaskOnEventLoop([weakThis = makeWeakPtr(*this)] {
         if (weakThis)
             weakThis->renderingModeChanged();
@@ -462,7 +469,7 @@
 
     setUpVideoRendering();
 
-    if (currentRenderingMode() == MediaRenderingToLayer || preferredRenderingMode() == MediaRenderingToLayer)
+    if (currentRenderingMode() == MediaRenderingMode::MediaRenderingToLayer || preferredRenderingMode() == MediaRenderingMode::MediaRenderingToLayer)
         setNeedsRenderingModeChanged();
 }
 
@@ -586,10 +593,12 @@
     if (m_visible == visible)
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER, visible);
+
     m_visible = visible;
     if (visible)
         setUpVideoRendering();
-    
+
     platformSetVisible(visible);
 }
 
@@ -1122,6 +1131,20 @@
     return cache;
 }
 
+String convertEnumerationToString(MediaPlayerPrivateAVFoundation::MediaRenderingMode enumerationValue)
+{
+    static const NeverDestroyed<String> values[] = {
+        MAKE_STATIC_STRING_IMPL("MediaRenderingNone"),
+        MAKE_STATIC_STRING_IMPL("MediaRenderingToContext"),
+        MAKE_STATIC_STRING_IMPL("MediaRenderingToLayer"),
+    };
+    static_assert(static_cast<size_t>(MediaPlayerPrivateAVFoundation::MediaRenderingMode::MediaRenderingNone) == 0, "MediaRenderingMode::MediaRenderingNone is not 0 as expected");
+    static_assert(static_cast<size_t>(MediaPlayerPrivateAVFoundation::MediaRenderingMode::MediaRenderingToContext) == 1, "MediaRenderingMode::MediaRenderingToContext is not 1 as expected");
+    static_assert(static_cast<size_t>(MediaPlayerPrivateAVFoundation::MediaRenderingMode::MediaRenderingToLayer) == 2, "MediaRenderingMode::MediaRenderingToLayer is not 2 as expected");
+    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
+    return values[static_cast<size_t>(enumerationValue)];
+}
+
 } // namespace WebCore
 
 #endif

Modified: branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h (285516 => 285517)


--- branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h	2021-11-09 19:41:58 UTC (rev 285516)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h	2021-11-09 19:42:03 UTC (rev 285517)
@@ -153,6 +153,12 @@
     WTFLogChannel& logChannel() const final;
 #endif
 
+    enum class MediaRenderingMode : uint8_t {
+        MediaRenderingNone,
+        MediaRenderingToContext,
+        MediaRenderingToLayer
+    };
+
 protected:
     explicit MediaPlayerPrivateAVFoundation(MediaPlayer*);
     virtual ~MediaPlayerPrivateAVFoundation();
@@ -270,7 +276,6 @@
     static bool isUnsupportedMIMEType(const String&);
     static const HashSet<String, ASCIICaseInsensitiveHash>& staticMIMETypeList();
 
-protected:
     void updateStates();
 
     void setHasVideo(bool);
@@ -285,7 +290,6 @@
     void setNetworkState(MediaPlayer::NetworkState);
     void setReadyState(MediaPlayer::ReadyState);
 
-    enum MediaRenderingMode { MediaRenderingNone, MediaRenderingToContext, MediaRenderingToLayer };
     MediaRenderingMode currentRenderingMode() const;
     MediaRenderingMode preferredRenderingMode() const;
 
@@ -294,6 +298,7 @@
     bool isReadyForVideoSetup() const;
     virtual void setUpVideoRendering();
     virtual void tearDownVideoRendering();
+    virtual bool haveBeenAskedToPaint() const { return false; }
     bool hasSetUpVideoRendering() const;
 
     void mainThreadCallback();
@@ -374,6 +379,24 @@
     bool m_needsRenderingModeChanged { false };
 };
 
+String convertEnumerationToString(MediaPlayerPrivateAVFoundation::MediaRenderingMode);
+
 } // namespace WebCore
 
+namespace WTF {
+
+template<typename Type>
+struct LogArgument;
+
+template<> struct EnumTraits<WebCore::MediaPlayerPrivateAVFoundation::MediaRenderingMode> {
+using values = EnumValues<
+    WebCore::MediaPlayerPrivateAVFoundation::MediaRenderingMode,
+    WebCore::MediaPlayerPrivateAVFoundation::MediaRenderingMode::MediaRenderingNone,
+    WebCore::MediaPlayerPrivateAVFoundation::MediaRenderingMode::MediaRenderingToContext,
+    WebCore::MediaPlayerPrivateAVFoundation::MediaRenderingMode::MediaRenderingToLayer
+    >;
+};
+
+}; // namespace WTF
+
 #endif // ENABLE(VIDEO) && USE(AVFOUNDATION)

Modified: branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (285516 => 285517)


--- branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2021-11-09 19:41:58 UTC (rev 285516)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2021-11-09 19:42:03 UTC (rev 285517)
@@ -869,7 +869,7 @@
     if (!metaDataAvailable() || context.paintingDisabled())
         return;
 
-    if (currentRenderingMode() == MediaRenderingToLayer && !imageGenerator(m_avfWrapper)) {
+    if (currentRenderingMode() == MediaRenderingMode::MediaRenderingToLayer && !imageGenerator(m_avfWrapper)) {
         // We're being told to render into a context, but we already have the
         // video layer, which probably means we've been called from <canvas>.
         createContextVideoRenderer();

Modified: branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (285516 => 285517)


--- branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2021-11-09 19:41:58 UTC (rev 285516)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2021-11-09 19:42:03 UTC (rev 285517)
@@ -333,6 +333,7 @@
     bool supportsPauseAtHostTime() const final { return true; }
     bool playAtHostTime(const MonotonicTime&) final;
     bool pauseAtHostTime(const MonotonicTime&) final;
+    bool haveBeenAskedToPaint() const { return m_haveBeenAskedToPaint; }
 
     RetainPtr<AVURLAsset> m_avAsset;
     RetainPtr<AVPlayer> m_avPlayer;
@@ -439,6 +440,7 @@
 #endif
     bool m_runningModalPaint { false };
     bool m_waitForVideoOutputMediaDataWillChangeTimedOut { false };
+    bool m_haveBeenAskedToPaint { false };
 };
 
 }

Modified: branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (285516 => 285517)


--- branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2021-11-09 19:41:58 UTC (rev 285516)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2021-11-09 19:42:03 UTC (rev 285517)
@@ -627,6 +627,8 @@
     if (!m_avPlayer)
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER);
+
     m_videoLayer = adoptNS([PAL::allocAVPlayerLayerInstance() init]);
     [m_videoLayer setPlayer:m_avPlayer.get()];
 
@@ -680,7 +682,7 @@
 
 bool MediaPlayerPrivateAVFoundationObjC::hasAvailableVideoFrame() const
 {
-    if (currentRenderingMode() == MediaRenderingToLayer)
+    if (currentRenderingMode() == MediaRenderingMode::MediaRenderingToLayer)
         return m_cachedIsReadyForDisplay;
 
     if (m_videoOutput && (m_lastPixelBuffer || [m_videoOutput hasNewPixelBufferForItemTime:[m_avPlayerItem currentTime]]))
@@ -1814,7 +1816,7 @@
         return;
 
     // We can ignore the request if we are already rendering to a layer.
-    if (currentRenderingMode() == MediaRenderingToLayer)
+    if (currentRenderingMode() == MediaRenderingMode::MediaRenderingToLayer)
         return;
 
     // paint() is best effort, so only paint if we already have an image generator or video output available.
@@ -2460,6 +2462,8 @@
     if (!m_avPlayerItem || readyState() < MediaPlayer::ReadyState::HaveCurrentData)
         return false;
 
+    m_haveBeenAskedToPaint = true;
+
     if (!m_videoOutput)
         createVideoOutput();
     ASSERT(m_videoOutput);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to