Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (217784 => 217785)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2017-06-05 16:05:04 UTC (rev 217784)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2017-06-05 16:25:55 UTC (rev 217785)
@@ -87,14 +87,11 @@
#include "BitmapTextureGL.h"
#include "BitmapTexturePool.h"
#include "TextureMapperGL.h"
-#endif
-#if USE(COORDINATED_GRAPHICS_THREADED)
#include "TextureMapperPlatformLayerBuffer.h"
-#endif
-
#if USE(CAIRO) && ENABLE(ACCELERATED_2D_CANVAS)
#include <cairo-gl.h>
#endif
+#endif // USE(TEXTURE_MAPPER_GL)
#if ENABLE(LEGACY_ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA)
#include "SharedBuffer.h"
@@ -176,7 +173,7 @@
}
#endif
-#if USE(COORDINATED_GRAPHICS_THREADED) && USE(GSTREAMER_GL)
+#if USE(GSTREAMER_GL)
class GstVideoFrameHolder : public TextureMapperPlatformLayerBuffer::UnmanagedBufferDataHolder {
public:
explicit GstVideoFrameHolder(GstSample* sample, TextureMapperGL::Flags flags)
@@ -216,7 +213,7 @@
GLuint m_textureID;
bool m_isValid { false };
};
-#endif // USE(COORDINATED_GRAPHICS_THREADED) && USE(GSTREAMER_GL)
+#endif // USE(GSTREAMER_GL)
MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* player)
: m_player(player)
@@ -223,18 +220,12 @@
, m_fpsSink(nullptr)
, m_readyState(MediaPlayer::HaveNothing)
, m_networkState(MediaPlayer::Empty)
-#if USE(GSTREAMER_GL) || USE(COORDINATED_GRAPHICS_THREADED)
+#if USE(TEXTURE_MAPPER_GL)
+ , m_platformLayerProxy(adoptRef(new TextureMapperPlatformLayerProxy()))
, m_drawTimer(RunLoop::main(), this, &MediaPlayerPrivateGStreamerBase::repaint)
#endif
- , m_usingFallbackVideoSink(false)
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
- , m_cdmSession(nullptr)
-#endif
{
g_mutex_init(&m_sampleMutex);
-#if USE(COORDINATED_GRAPHICS_THREADED)
- m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy());
-#endif
}
MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase()
@@ -244,13 +235,18 @@
#endif
m_notifier.cancelPendingNotifications();
-#if USE(GSTREAMER_GL) || USE(COORDINATED_GRAPHICS_THREADED)
- m_drawTimer.stop();
- {
+#if USE(TEXTURE_MAPPER_GL)
+#if USE(GSTREAMER_GL)
+ bool shouldCancelRepaint = !m_renderingCanBeAccelerated;
+#else
+ bool shouldCancelRepaint = true;
+#endif
+ if (shouldCancelRepaint) {
+ m_drawTimer.stop();
LockHolder locker(m_drawMutex);
m_drawCondition.notifyOne();
}
-#endif
+#endif // USE(TEXTURE_MAPPER_GL)
if (m_videoSink) {
g_signal_handlers_disconnect_matched(m_videoSink.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
@@ -269,11 +265,6 @@
if (m_volumeElement)
g_signal_handlers_disconnect_matched(m_volumeElement.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
-#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
- if (client())
- client()->platformLayerWillBeDestroyed();
-#endif
-
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
m_cdmSession = nullptr;
#endif
@@ -682,7 +673,7 @@
}
#endif
-#if USE(COORDINATED_GRAPHICS_THREADED)
+#if USE(TEXTURE_MAPPER_GL)
void MediaPlayerPrivateGStreamerBase::pushTextureToCompositor()
{
#if !USE(GSTREAMER_GL)
@@ -738,9 +729,9 @@
updateTexture(buffer->textureGL(), videoInfo);
buffer->setExtraFlags(texMapFlagFromOrientation(m_videoSourceOrientation) | (GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? TextureMapperGL::ShouldBlend : 0));
m_platformLayerProxy->pushNextBuffer(WTFMove(buffer));
-#endif
+#endif // USE(GSTREAMER_GL)
}
-#endif
+#endif // USE(TEXTURE_MAPPER_GL)
void MediaPlayerPrivateGStreamerBase::repaint()
{
@@ -747,23 +738,19 @@
ASSERT(m_sample);
ASSERT(isMainThread());
-#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
- if (m_renderingCanBeAccelerated && client()) {
- client()->setPlatformLayerNeedsDisplay();
+ m_player->repaint();
+
+#if USE(TEXTURE_MAPPER_GL)
#if USE(GSTREAMER_GL)
+ bool shouldNotifyDraw = !m_renderingCanBeAccelerated;
+#else
+ bool shouldNotifyDraw = true;
+#endif
+ if (shouldNotifyDraw) {
LockHolder lock(m_drawMutex);
m_drawCondition.notifyOne();
-#endif
- return;
}
-#endif
-
- m_player->repaint();
-
-#if USE(GSTREAMER_GL) || USE(COORDINATED_GRAPHICS_THREADED)
- LockHolder lock(m_drawMutex);
- m_drawCondition.notifyOne();
-#endif
+#endif // USE(TEXTURE_MAPPER_GL)
}
void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstSample* sample)
@@ -780,7 +767,9 @@
m_notifier.notify(MainThreadNotification::SizeChanged, [this] { m_player->sizeChanged(); });
}
-#if USE(COORDINATED_GRAPHICS_THREADED)
+#if !USE(TEXTURE_MAPPER_GL)
+ repaint();
+#else
if (!m_renderingCanBeAccelerated) {
LockHolder locker(m_drawMutex);
m_drawTimer.startOneShot(0_s);
@@ -798,20 +787,7 @@
m_drawCondition.wait(m_drawMutex);
}
#endif
- return;
-#else
-#if USE(GSTREAMER_GL)
- {
- ASSERT(!isMainThread());
-
- LockHolder locker(m_drawMutex);
- m_drawTimer.startOneShot(0_s);
- m_drawCondition.wait(m_drawMutex);
- }
-#else
- repaint();
-#endif
-#endif
+#endif // !USE(TEXTURE_MAPPER_GL)
}
void MediaPlayerPrivateGStreamerBase::repaintCallback(MediaPlayerPrivateGStreamerBase* player, GstSample* sample)
@@ -833,7 +809,7 @@
player->triggerRepaint(sample.get());
return GST_FLOW_OK;
}
-#endif
+#endif // USE(GSTREAMER_GL)
void MediaPlayerPrivateGStreamerBase::setSize(const IntSize& size)
{
@@ -864,58 +840,7 @@
context.drawImage(*image, rect, gstImage->rect(), paintingOptions);
}
-#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
-void MediaPlayerPrivateGStreamerBase::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
-{
- if (!m_player->visible())
- return;
-
- if (m_usingFallbackVideoSink) {
- RefPtr<BitmapTexture> texture;
- IntSize size;
- TextureMapperGL::Flags flags;
- {
- WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
-
- GstVideoInfo videoInfo;
- if (UNLIKELY(!getSampleVideoInfo(m_sample.get(), videoInfo)))
- return;
-
- size = IntSize(GST_VIDEO_INFO_WIDTH(&videoInfo), GST_VIDEO_INFO_HEIGHT(&videoInfo));
- flags = texMapFlagFromOrientation(m_videoSourceOrientation) | (GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? TextureMapperGL::ShouldBlend : 0);
- texture = textureMapper.acquireTextureFromPool(size, GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag);
- updateTexture(static_cast<BitmapTextureGL&>(*texture), videoInfo);
- }
- TextureMapperGL& texmapGL = reinterpret_cast<TextureMapperGL&>(textureMapper);
- BitmapTextureGL* textureGL = static_cast<BitmapTextureGL*>(texture.get());
- texmapGL.drawTexture(textureGL->id(), flags, textureGL->size(), targetRect, matrix, opacity);
- return;
- }
-
#if USE(GSTREAMER_GL)
- WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
-
- GstVideoInfo videoInfo;
- if (!getSampleVideoInfo(m_sample.get(), videoInfo))
- return;
-
- GstBuffer* buffer = gst_sample_get_buffer(m_sample.get());
- GstVideoFrame videoFrame;
- if (!gst_video_frame_map(&videoFrame, &videoInfo, buffer, static_cast<GstMapFlags>(GST_MAP_READ | GST_MAP_GL)))
- return;
-
- unsigned textureID = *reinterpret_cast<unsigned*>(videoFrame.data[0]);
- TextureMapperGL::Flags flags = texMapFlagFromOrientation(m_videoSourceOrientation) | (GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? TextureMapperGL::ShouldBlend : 0);
-
- IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&videoInfo), GST_VIDEO_INFO_HEIGHT(&videoInfo));
- TextureMapperGL& textureMapperGL = reinterpret_cast<TextureMapperGL&>(textureMapper);
- textureMapperGL.drawTexture(textureID, flags, size, targetRect, matrix, opacity);
- gst_video_frame_unmap(&videoFrame);
-#endif
-}
-#endif
-
-#if USE(GSTREAMER_GL)
bool MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture(GraphicsContext3D* context, Platform3DObject outputTexture, GC3Denum outputTarget, GC3Dint level, GC3Denum internalFormat, GC3Denum format, GC3Denum type, bool premultiplyAlpha, bool flipY)
{
UNUSED_PARAM(context);
@@ -1085,7 +1010,7 @@
}
return videoSink;
}
-#endif
+#endif // USE(GSTREAMER_GL)
GstElement* MediaPlayerPrivateGStreamerBase::createVideoSink()
{
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (217784 => 217785)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h 2017-06-05 16:05:04 UTC (rev 217784)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h 2017-06-05 16:25:55 UTC (rev 217785)
@@ -58,7 +58,7 @@
void registerWebKitGStreamerElements();
class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface
-#if USE(COORDINATED_GRAPHICS_THREADED) || (USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS))
+#if USE(TEXTURE_MAPPER_GL)
, public PlatformLayer
#endif
{
@@ -107,7 +107,7 @@
void acceleratedRenderingStateChanged() override;
-#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+#if USE(TEXTURE_MAPPER_GL)
PlatformLayer* platformLayer() const override { return const_cast<MediaPlayerPrivateGStreamerBase*>(this); }
#if PLATFORM(WIN_CAIRO)
// FIXME: Accelerated rendering has not been implemented for WinCairo yet.
@@ -115,14 +115,8 @@
#else
bool supportsAcceleratedRendering() const override { return true; }
#endif
- void paintToTextureMapper(TextureMapper&, const FloatRect&, const TransformationMatrix&, float) override;
#endif
-#if USE(COORDINATED_GRAPHICS_THREADED)
- PlatformLayer* platformLayer() const override { return const_cast<MediaPlayerPrivateGStreamerBase*>(this); }
- bool supportsAcceleratedRendering() const override { return true; }
-#endif
-
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
void needKey(RefPtr<Uint8Array>);
void setCDMSession(CDMSession*) override;
@@ -158,6 +152,13 @@
GstGLDisplay* gstGLDisplay() const { return m_glDisplay.get(); }
#endif
+#if USE(TEXTURE_MAPPER_GL)
+ void updateTexture(BitmapTextureGL&, GstVideoInfo&);
+ RefPtr<TextureMapperPlatformLayerProxy> proxy() const override { return m_platformLayerProxy.copyRef(); }
+ void swapBuffersIfNeeded() override { };
+ void pushTextureToCompositor();
+#endif
+
GstElement* videoSink() const { return m_videoSink.get(); }
void setStreamVolumeElement(GstStreamVolume*);
@@ -200,45 +201,34 @@
IntSize m_size;
mutable GMutex m_sampleMutex;
GRefPtr<GstSample> m_sample;
-#if USE(GSTREAMER_GL) || USE(COORDINATED_GRAPHICS_THREADED)
- RunLoop::Timer<MediaPlayerPrivateGStreamerBase> m_drawTimer;
-#endif
+
mutable FloatSize m_videoSize;
- bool m_usingFallbackVideoSink;
+ bool m_usingFallbackVideoSink { false };
bool m_renderingCanBeAccelerated { false };
+
#if USE(TEXTURE_MAPPER_GL)
- void updateTexture(BitmapTextureGL&, GstVideoInfo&);
+ RefPtr<GraphicsContext3D> m_context3D;
+ RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
+ Condition m_drawCondition;
+ Lock m_drawMutex;
+ RunLoop::Timer<MediaPlayerPrivateGStreamerBase> m_drawTimer;
#endif
+
#if USE(GSTREAMER_GL)
GRefPtr<GstGLContext> m_glContext;
GRefPtr<GstGLDisplay> m_glDisplay;
+ std::unique_ptr<VideoTextureCopierGStreamer> m_videoTextureCopier;
#endif
-#if USE(COORDINATED_GRAPHICS_THREADED)
- RefPtr<TextureMapperPlatformLayerProxy> proxy() const override { return m_platformLayerProxy.copyRef(); }
- void swapBuffersIfNeeded() override { };
- void pushTextureToCompositor();
- RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
-#endif
-
-#if USE(GSTREAMER_GL) || USE(COORDINATED_GRAPHICS_THREADED)
- RefPtr<GraphicsContext3D> m_context3D;
- Condition m_drawCondition;
- Lock m_drawMutex;
-#endif
-
ImageOrientation m_videoSourceOrientation;
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
std::unique_ptr<CDMSession> createSession(const String&, CDMSessionClient*) override;
- CDMSession* m_cdmSession;
+ CDMSession* m_cdmSession { nullptr };
Lock m_protectionMutex;
Condition m_protectionCondition;
String m_lastGenerateKeyRequestKeySystemUuid;
HashSet<uint32_t> m_handledProtectionEvents;
#endif
-#if USE(GSTREAMER_GL)
- std::unique_ptr<VideoTextureCopierGStreamer> m_videoTextureCopier;
-#endif
};
}
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp (217784 => 217785)
--- trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp 2017-06-05 16:05:04 UTC (rev 217784)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp 2017-06-05 16:25:55 UTC (rev 217785)
@@ -69,7 +69,7 @@
class VideoRenderRequestScheduler {
public:
VideoRenderRequestScheduler()
-#if !USE(COORDINATED_GRAPHICS_THREADED)
+#if !USE(TEXTURE_MAPPER_GL)
: m_timer(RunLoop::main(), this, &VideoRenderRequestScheduler::render)
#endif
{
@@ -86,7 +86,7 @@
LockHolder locker(m_sampleMutex);
m_sample = nullptr;
m_unlocked = true;
-#if !USE(COORDINATED_GRAPHICS_THREADED)
+#if !USE(TEXTURE_MAPPER_GL)
m_timer.stop();
m_dataCondition.notifyOne();
#endif
@@ -108,7 +108,7 @@
if (!m_sample)
return false;
-#if USE(COORDINATED_GRAPHICS_THREADED)
+#if USE(TEXTURE_MAPPER_GL)
auto sample = WTFMove(m_sample);
locker.unlockEarly();
if (LIKELY(GST_IS_SAMPLE(sample.get())))
@@ -123,7 +123,7 @@
private:
-#if !USE(COORDINATED_GRAPHICS_THREADED)
+#if !USE(TEXTURE_MAPPER_GL)
void render()
{
LockHolder locker(m_sampleMutex);
@@ -138,7 +138,7 @@
Lock m_sampleMutex;
GRefPtr<GstSample> m_sample;
-#if !USE(COORDINATED_GRAPHICS_THREADED)
+#if !USE(TEXTURE_MAPPER_GL)
RunLoop::Timer<VideoRenderRequestScheduler> m_timer;
Condition m_dataCondition;
GRefPtr<WebKitVideoSink> m_sink;
@@ -198,7 +198,6 @@
if (format == GST_VIDEO_FORMAT_UNKNOWN)
return nullptr;
-#if !(USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS))
// Cairo's ARGB has pre-multiplied alpha while GStreamer's doesn't.
// Here we convert to Cairo's ARGB.
if (format == GST_VIDEO_FORMAT_ARGB || format == GST_VIDEO_FORMAT_BGRA) {
@@ -258,7 +257,6 @@
sample = adoptGRef(gst_sample_new(newBuffer, priv->currentCaps, nullptr, nullptr));
gst_buffer_unref(newBuffer);
}
-#endif
return sample;
}