Diff
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (295593 => 295594)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2022-06-16 15:22:07 UTC (rev 295594)
@@ -5129,11 +5129,16 @@
&& (format == GraphicsContextGL::RGB || format == GraphicsContextGL::RGBA)
&& type == GraphicsContextGL::UNSIGNED_BYTE
&& !level) {
- if (video->player() && m_context->copyTextureFromMedia(*video->player(), texture->object(), target, level, internalformat, format, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
+ if (auto player = video->player()) {
+#if PLATFORM(COCOA) && !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+ player->willBeAskedToPaintGL();
+#endif
+ if (m_context->copyTextureFromMedia(*player, texture->object(), target, level, internalformat, format, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
#if !USE(ANGLE)
- texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), type);
+ texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), type);
#endif // !USE(ANGLE)
- return { };
+ return { };
+ }
}
}
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (295593 => 295594)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2022-06-16 15:22:07 UTC (rev 295594)
@@ -1089,6 +1089,14 @@
return m_private->videoFrameForCurrentTime();
}
+
+#if PLATFORM(COCOA) && !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+void MediaPlayer::willBeAskedToPaintGL()
+{
+ m_private->willBeAskedToPaintGL();
+}
+#endif
+
RefPtr<NativeImage> MediaPlayer::nativeImageForCurrentTime()
{
return m_private->nativeImageForCurrentTime();
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (295593 => 295594)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2022-06-16 15:22:07 UTC (rev 295594)
@@ -473,6 +473,11 @@
#if !USE(AVFOUNDATION)
bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY);
#endif
+
+#if PLATFORM(COCOA) && !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+ void willBeAskedToPaintGL();
+#endif
+
RefPtr<VideoFrame> videoFrameForCurrentTime();
RefPtr<NativeImage> nativeImageForCurrentTime();
DestinationColorSpace colorSpace();
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (295593 => 295594)
--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2022-06-16 15:22:07 UTC (rev 295594)
@@ -182,6 +182,10 @@
#if !USE(AVFOUNDATION)
virtual bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) { return false; }
#endif
+#if PLATFORM(COCOA) && !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+ virtual void willBeAskedToPaintGL() { }
+#endif
+
virtual RefPtr<VideoFrame> videoFrameForCurrentTime() { return nullptr; }
virtual RefPtr<NativeImage> nativeImageForCurrentTime() { return nullptr; }
virtual DestinationColorSpace colorSpace() = 0;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (295593 => 295594)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2022-06-16 15:22:07 UTC (rev 295594)
@@ -222,6 +222,9 @@
bool updateLastImage();
void paint(GraphicsContext&, const FloatRect&) override;
void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) override;
+#if PLATFORM(COCOA) && !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+ void willBeAskedToPaintGL() final;
+#endif
RefPtr<VideoFrame> videoFrameForCurrentTime() final;
DestinationColorSpace colorSpace() final;
@@ -284,6 +287,8 @@
void checkNewVideoFrameMetadata(CMTime);
MediaTime clampTimeToLastSeekTime(const MediaTime&) const;
+ bool shouldEnsureLayer() const;
+
friend class MediaSourcePrivateAVFObjC;
struct PendingSeek {
@@ -341,7 +346,9 @@
bool m_seeking;
SeekState m_seekCompleted { SeekCompleted };
mutable bool m_loadingProgressed;
+#if !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
bool m_hasBeenAskedToPaintGL { false };
+#endif
bool m_hasAvailableVideoFrame { false };
bool m_allRenderersHaveAvailableSamples { false };
bool m_visible { false };
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (295593 => 295594)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2022-06-16 15:22:07 UTC (rev 295594)
@@ -725,16 +725,22 @@
context.drawNativeImage(*image, imageRect.size(), outputRect, imageRect);
}
-RefPtr<VideoFrame> MediaPlayerPrivateMediaSourceAVFObjC::videoFrameForCurrentTime()
+#if !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+void MediaPlayerPrivateMediaSourceAVFObjC::willBeAskedToPaintGL()
{
// We have been asked to paint into a WebGL canvas, so take that as a signal to create
// a decompression session, even if that means the native video can't also be displayed
// in page.
- if (!m_hasBeenAskedToPaintGL) {
- m_hasBeenAskedToPaintGL = true;
- acceleratedRenderingStateChanged();
- }
+ if (m_hasBeenAskedToPaintGL)
+ return;
+ m_hasBeenAskedToPaintGL = true;
+ acceleratedRenderingStateChanged();
+}
+#endif
+
+RefPtr<VideoFrame> MediaPlayerPrivateMediaSourceAVFObjC::videoFrameForCurrentTime()
+{
if (!m_isGatheringVideoFrameMetadata)
updateLastPixelBuffer();
if (!m_lastPixelBuffer)
@@ -758,9 +764,18 @@
return true;
}
+bool MediaPlayerPrivateMediaSourceAVFObjC::shouldEnsureLayer() const
+{
+#if !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+ if (!m_hasBeenAskedToPaintGL)
+ return true;
+#endif
+ return isVideoOutputAvailable();
+}
+
void MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged()
{
- if (!m_hasBeenAskedToPaintGL || isVideoOutputAvailable()) {
+ if (shouldEnsureLayer()) {
destroyDecompressionSession();
ensureLayer();
} else {
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (295593 => 295594)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2022-06-16 15:22:07 UTC (rev 295594)
@@ -341,7 +341,10 @@
void setVideoInlineSizeIfPossible(const WebCore::FloatSize&);
void nativeImageForCurrentTime(CompletionHandler<void(std::optional<WTF::MachSendRight>&&, WebCore::DestinationColorSpace)>&&);
void colorSpace(CompletionHandler<void(WebCore::DestinationColorSpace)>&&);
+#if !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+ void willBeAskedToPaintGL();
#endif
+#endif
void videoFrameForCurrentTimeIfChanged(CompletionHandler<void(std::optional<RemoteVideoFrameProxy::Properties>&&, bool)>&&);
#if !RELEASE_LOG_DISABLED
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in (295593 => 295594)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in 2022-06-16 15:22:07 UTC (rev 295594)
@@ -125,7 +125,10 @@
#if PLATFORM(COCOA)
NativeImageForCurrentTime() -> (std::optional<MachSendRight> sendRight, WebCore::DestinationColorSpace colorSpace) Synchronous
ColorSpace() -> (WebCore::DestinationColorSpace colorSpace) Synchronous
+#if !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+ void WillBeAskedToPaintGL()
#endif
+#endif
VideoFrameForCurrentTimeIfChanged() -> (std::optional<WebKit::RemoteVideoFrameProxy::Properties> videoFrame, bool changed) Synchronous
PlayAtHostTime(MonotonicTime time)
Modified: trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm (295593 => 295594)
--- trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm 2022-06-16 15:22:07 UTC (rev 295594)
@@ -134,6 +134,14 @@
completionHandler(m_player->colorSpace());
}
+#if !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+void RemoteMediaPlayerProxy::willBeAskedToPaintGL()
+{
+ if (m_player)
+ m_player->willBeAskedToPaintGL();
+}
+#endif
+
} // namespace WebKit
#endif // ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (295593 => 295594)
--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp 2022-06-16 15:22:07 UTC (rev 295594)
@@ -1024,6 +1024,17 @@
}
#endif
+#if PLATFORM(COCOA) && !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+void MediaPlayerPrivateRemote::willBeAskedToPaintGL()
+{
+ if (m_hasBeenAskedToPaintGL)
+ return;
+
+ m_hasBeenAskedToPaintGL = true;
+ connection().send(Messages::RemoteMediaPlayerProxy::WillBeAskedToPaintGL(), m_id);
+}
+#endif
+
RefPtr<WebCore::VideoFrame> MediaPlayerPrivateRemote::videoFrameForCurrentTime()
{
if (readyState() < MediaPlayer::ReadyState::HaveCurrentData)
Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (295593 => 295594)
--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2022-06-16 15:05:12 UTC (rev 295593)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2022-06-16 15:22:07 UTC (rev 295594)
@@ -295,6 +295,9 @@
#if !USE(AVFOUNDATION)
bool copyVideoTextureToPlatformTexture(WebCore::GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) final;
#endif
+#if PLATFORM(COCOA) && !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+ void willBeAskedToPaintGL() final;
+#endif
RefPtr<WebCore::VideoFrame> videoFrameForCurrentTime() final;
RefPtr<WebCore::NativeImage> nativeImageForCurrentTime() final;
WebCore::DestinationColorSpace colorSpace() final;
@@ -475,6 +478,9 @@
#endif
std::optional<WebCore::VideoFrameMetadata> m_videoFrameMetadata;
bool m_isGatheringVideoFrameMetadata { false };
+#if PLATFORM(COCOA) && !HAVE(LOW_AV_SAMPLE_BUFFER_PRUNING_INTERVAL)
+ bool m_hasBeenAskedToPaintGL { false };
+#endif
};
} // namespace WebKit