WebKit Bugzilla
Attachment 346759 Details for
Bug 188405
: [Nicosia] Add the Nicosia-specific PlatformLayer type alias
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188405-20180808102051.patch (text/plain), 34.17 KB, created by
Zan Dobersek
on 2018-08-08 01:20:52 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2018-08-08 01:20:52 PDT
Size:
34.17 KB
patch
obsolete
>Subversion Revision: 234686 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7392f6bfa954ff4f5950c7042dd3b8c24e4554a4..31a84e3858a238c1ce0ff51232839fb37c8220ea 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,97 @@ >+2018-08-08 Zan Dobersek <zdobersek@igalia.com> >+ >+ [Nicosia] Add the Nicosia-specific PlatformLayer type alias >+ https://bugs.webkit.org/show_bug.cgi?id=188405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a Nicosia-specific PlatformLayer type alias that points to the >+ Nicosia::PlatformLayer type. This is guarded by the USE(NICOSIA) macro, >+ which guards additional code in this patch but will be added to other >+ Nicosia-specific classes later. >+ >+ To keep things buildable when USE(NICOSIA) is defined, additional >+ changes are made to classes that operate with platform layers. >+ Cairo-specific ImageBuffer implementation and the related >+ ImageBufferData class are modified to work with a Nicosia::ContentLayer >+ object. This object is using the TextureMapper-specific Impl class which >+ internally keeps a TextureMapperPlatformLayerProxy object. This way >+ we can reuse existing code that also works with an object of this type, >+ only difference is where the proxy object is kept. Main difference is in >+ the ImageBuffer::platformLayer() method, where pointer to the >+ Nicosia::ContentLayer object is returned when USE(NICOSIA) is enabled. >+ >+ Similar approach is taked for the MediaPlayerPrivateGStreamerBase class. >+ When USE(NICOSIA) is enabled, a Nicosia::ContentLayer object is >+ constructed, and with the TextureMapper-specific Impl we again operate >+ on the TextureMapperPlatformLayerProxy object like before, so all of >+ the proxy-specific code is bundled into helper lambdas that operate on >+ the given proxy object. In the platformLayer() method, we again return >+ pointer to the Nicosia::ContentLayer object when USE(NICOSIA) is on. >+ >+ For the GraphicsContext3D integration, we have to provide a separate >+ class that replicates most of the functionality currently present in the >+ TextureMapperGC3DPlatformLayer class. Main difference is that in the new >+ Nicosia::GC3DLayer class, a Nicosia::ContentLayer object is spawned with >+ the TextureMapper-specific Impl. The proxy object held by that Impl is >+ then again used to push new buffers into the rendering pipeline. As >+ before, pointer to the Nicosia::ContentLayer is returned in the >+ GraphicsContext3D::platformLayer() object. >+ >+ Integration of the GraphicsContext3D class into Nicosia layering needs >+ further work in the future. Target should be providing a class that is >+ not specific to the TextureMapper layer. Additionally, when USE(NICOSIA) >+ is enabled, we remove the TextureMapperGC3DPlatformLayer class from >+ compilation since it depends on a PlatformLayer type alias to the >+ TextureMapperPlatformLayerProxyProvider class. >+ >+ This patch also doesn't address the abundance of macros that this code >+ now uses. While USE(NICOSIA) is introduced, we have to work around >+ four additional macros in this code: USE(TEXTURE_MAPPER), >+ USE(TEXTURE_MAPPER_GL), USE(COORDINATED_GRAPHICS) and >+ USE(COORDINATED_GRAPHICS_THREADED). In a lot of places these are used >+ interchangeably, but they should be merged and simplified in use. I hope >+ to approach this once the USE(NICOSIA) functionality lands and is turned >+ on for ports that currently build with USE(COORDINATED_GRAPHICS). >+ >+ * platform/TextureMapper.cmake: >+ * platform/graphics/GraphicsContext3D.h: >+ * platform/graphics/PlatformLayer.h: >+ * platform/graphics/cairo/ImageBufferCairo.cpp: >+ (WebCore::ImageBufferData::ImageBufferData): >+ (WebCore::ImageBufferData::~ImageBufferData): >+ (WebCore::ImageBufferData::swapBuffersIfNeeded): >+ (WebCore::ImageBuffer::platformLayer const): >+ * platform/graphics/cairo/ImageBufferDataCairo.h: >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp: >+ (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase): >+ (WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase): >+ (WebCore::MediaPlayerPrivateGStreamerBase::platformLayer const): >+ (WebCore::MediaPlayerPrivateGStreamerBase::swapBuffersIfNeeded): >+ (WebCore::MediaPlayerPrivateGStreamerBase::pushTextureToCompositor): >+ (WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint): >+ (WebCore::MediaPlayerPrivateGStreamerBase::flushCurrentBuffer): >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h: >+ * platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp: Added. >+ (Nicosia::GC3DLayer::GC3DLayer): >+ (Nicosia::GC3DLayer::~GC3DLayer): >+ (Nicosia::GC3DLayer::makeContextCurrent): >+ (Nicosia::GC3DLayer::platformContext): >+ (Nicosia::GC3DLayer::swapBuffersIfNeeded): >+ * platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h: Added. >+ (Nicosia::GC3DLayer::contentLayer const): >+ * platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp: >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ (WebCore::GraphicsContext3D::makeContextCurrent): >+ (WebCore::GraphicsContext3D::platformGraphicsContext3D): >+ (WebCore::GraphicsContext3D::platformLayer const): >+ * platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp: >+ * platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h: >+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp: >+ (WebCore::CoordinatedGraphicsLayer::setContentsToPlatformLayer): >+ (WebCore::CoordinatedGraphicsLayer::syncPlatformLayer): >+ (WebCore::CoordinatedGraphicsLayer::updatePlatformLayer): >+ > 2018-08-07 Saam Barati <sbarati@apple.com> > > ResourceUsageOverlay should use physical footprint for its "Footprint" label >diff --git a/Source/WebCore/platform/TextureMapper.cmake b/Source/WebCore/platform/TextureMapper.cmake >index 09dea6794a25c06084252111b02f7d2d35e0317d..3c78fea50c001564d82c64ab2d3536fb9a1a502b 100644 >--- a/Source/WebCore/platform/TextureMapper.cmake >+++ b/Source/WebCore/platform/TextureMapper.cmake >@@ -60,6 +60,7 @@ if (USE_COORDINATED_GRAPHICS) > > platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.cpp > platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp >+ platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp > ) > else () > list(APPEND WebCore_SOURCES >diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h >index 4308acf142522ab9da30061c7a8365b6a290fee7..b5f9bb7ccf9624428a9c27ae180e45513269cb8e 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext3D.h >+++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h >@@ -74,6 +74,12 @@ OBJC_CLASS WebGLLayer; > typedef struct __IOSurface* IOSurfaceRef; > #endif // PLATFORM(COCOA) > >+#if USE(NICOSIA) >+namespace Nicosia { >+class GC3DLayer; >+} >+#endif >+ > #if !PLATFORM(COCOA) > typedef unsigned GLuint; > typedef void* PlatformGraphicsContext3D; >@@ -1481,7 +1487,10 @@ private: > // Errors raised by synthesizeGLError(). > ListHashSet<GC3Denum> m_syntheticErrors; > >-#if USE(TEXTURE_MAPPER) >+#if USE(NICOSIA) && USE(TEXTURE_MAPPER) >+ friend class Nicosia::GC3DLayer; >+ std::unique_ptr<Nicosia::GC3DLayer> m_nicosiaLayer; >+#elif USE(TEXTURE_MAPPER) > friend class TextureMapperGC3DPlatformLayer; > std::unique_ptr<TextureMapperGC3DPlatformLayer> m_texmapLayer; > #else >diff --git a/Source/WebCore/platform/graphics/PlatformLayer.h b/Source/WebCore/platform/graphics/PlatformLayer.h >index 10fcf1485ece12b247cb36fd647e72165af78f50..92ba32d1017097eb2f7cd3695226f33fd93ddcdf 100644 >--- a/Source/WebCore/platform/graphics/PlatformLayer.h >+++ b/Source/WebCore/platform/graphics/PlatformLayer.h >@@ -30,6 +30,11 @@ OBJC_CLASS CALayer; > typedef CALayer PlatformLayer; > #elif PLATFORM(WIN) && USE(CA) > typedef struct _CACFLayer PlatformLayer; >+#elif USE(NICOSIA) >+namespace Nicosia { >+class PlatformLayer; >+} >+typedef Nicosia::PlatformLayer PlatformLayer; > #elif USE(COORDINATED_GRAPHICS_THREADED) > namespace WebCore { > class TextureMapperPlatformLayerProxyProvider; >diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp >index 89a41f1f578aff6b72b69de24647fb5e74ef207e..456af786d09259017c43175d2d640871762e8a4e 100644 >--- a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp >+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp >@@ -91,8 +91,13 @@ ImageBufferData::ImageBufferData(const IntSize& size, RenderingMode renderingMod > #endif > { > #if ENABLE(ACCELERATED_2D_CANVAS) && USE(COORDINATED_GRAPHICS_THREADED) >- if (m_renderingMode == RenderingMode::Accelerated) >+ if (m_renderingMode == RenderingMode::Accelerated) { >+#if USE(NICOSIA) >+ m_nicosiaLayer = Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)); >+#else > m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy); >+#endif >+ } > #endif > } > >@@ -102,6 +107,10 @@ ImageBufferData::~ImageBufferData() > return; > > #if ENABLE(ACCELERATED_2D_CANVAS) >+#if USE(COORDINATED_GRAPHICS_THREADED) && USE(NICOSIA) >+ downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).invalidateClient(); >+#endif >+ > GLContext* previousActiveContext = GLContext::current(); > PlatformDisplay::sharedDisplayForCompositing().sharingGLContext()->makeContextCurrent(); > >@@ -139,10 +148,12 @@ void ImageBufferData::createCompositorBuffer() > cairo_set_antialias(m_compositorCr.get(), CAIRO_ANTIALIAS_NONE); > } > >+#if !USE(NICOSIA) > RefPtr<TextureMapperPlatformLayerProxy> ImageBufferData::proxy() const > { > return m_platformLayerProxy.copyRef(); > } >+#endif > > void ImageBufferData::swapBuffersIfNeeded() > { >@@ -150,8 +161,18 @@ void ImageBufferData::swapBuffersIfNeeded() > > if (!m_compositorTexture) { > createCompositorBuffer(); >- LockHolder holder(m_platformLayerProxy->lock()); >- m_platformLayerProxy->pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_compositorTexture, m_size, TextureMapperGL::ShouldBlend, GL_RGBA)); >+ >+ auto proxyOperation = >+ [this](TextureMapperPlatformLayerProxy& proxy) >+ { >+ LockHolder holder(proxy.lock()); >+ proxy.pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_compositorTexture, m_size, TextureMapperGL::ShouldBlend, GL_RGBA)); >+ }; >+#if USE(NICOSIA) >+ proxyOperation(downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy()); >+#else >+ proxyOperation(*m_platformLayerProxy); >+#endif > } > > // It would be great if we could just swap the buffers here as we do with webgl, but that breaks the cases >@@ -671,8 +692,13 @@ void ImageBufferData::paintToTextureMapper(TextureMapper& textureMapper, const F > PlatformLayer* ImageBuffer::platformLayer() const > { > #if ENABLE(ACCELERATED_2D_CANVAS) >+#if USE(NICOSIA) >+ if (m_data.m_renderingMode == RenderingMode::Accelerated) >+ return m_data.m_nicosiaLayer.get(); >+#else > if (m_data.m_texture) > return const_cast<ImageBufferData*>(&m_data); >+#endif > #endif > return 0; > } >diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h b/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h >index 120528fd4a0f7286c146c7636ea0bbecc8e4429b..a3dd949396268bd133acc02a56682ff0fb6c2bf5 100644 >--- a/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h >+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h >@@ -38,6 +38,10 @@ > #include "TextureMapperPlatformLayerProxyProvider.h" > #endif > >+#if ENABLE(ACCELERATED_2D_CANVAS) && USE(NICOSIA) >+#include "NicosiaContentLayerTextureMapperImpl.h" >+#endif >+ > namespace WebCore { > > class IntSize; >@@ -45,8 +49,12 @@ class TextureMapperPlatformLayerProxy; > > class ImageBufferData > #if ENABLE(ACCELERATED_2D_CANVAS) >+#if USE(NICOSIA) >+ : public Nicosia::ContentLayerTextureMapperImpl::Client >+#else > : public PlatformLayer > #endif >+#endif > { > public: > ImageBufferData(const IntSize&, RenderingMode); >@@ -62,14 +70,23 @@ public: > void createCairoGLSurface(); > > #if USE(COORDINATED_GRAPHICS_THREADED) >+#if USE(NICOSIA) >+ void swapBuffersIfNeeded() override; >+#else > RefPtr<TextureMapperPlatformLayerProxy> proxy() const override; > void swapBuffersIfNeeded() override; >+#endif > void createCompositorBuffer(); > >- RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy; > RefPtr<cairo_surface_t> m_compositorSurface; > uint32_t m_compositorTexture; > RefPtr<cairo_t> m_compositorCr; >+ >+#if USE(NICOSIA) >+ RefPtr<Nicosia::ContentLayer> m_nicosiaLayer; >+#else >+ RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy; >+#endif > #else > virtual void paintToTextureMapper(TextureMapper&, const FloatRect& target, const TransformationMatrix&, float opacity); > #endif >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >index d73f241996e5ab54208e9799bd626f7dde210e38..6aa14d7784e437279eb779cf76d895ecb176d62e 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >@@ -284,13 +284,21 @@ MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* pl > , m_networkState(MediaPlayer::Empty) > , m_drawTimer(RunLoop::main(), this, &MediaPlayerPrivateGStreamerBase::repaint) > #if USE(TEXTURE_MAPPER_GL) >+#if USE(NICOSIA) >+ , m_nicosiaLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this))) >+#else > , m_platformLayerProxy(adoptRef(new TextureMapperPlatformLayerProxy())) > #endif >+#endif > { > } > > MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase() > { >+#if USE(TEXTURE_MAPPER_GL) && USE(NICOSIA) >+ downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).invalidateClient(); >+#endif >+ > #if ENABLE(ENCRYPTED_MEDIA) > m_protectionCondition.notifyAll(); > #endif >@@ -735,6 +743,20 @@ void MediaPlayerPrivateGStreamerBase::acceleratedRenderingStateChanged() > } > > #if USE(TEXTURE_MAPPER_GL) >+PlatformLayer* MediaPlayerPrivateGStreamerBase::platformLayer() const >+{ >+#if USE(NICOSIA) >+ return m_nicosiaLayer.ptr(); >+#else >+ return const_cast<MediaPlayerPrivateGStreamerBase*>(this); >+#endif >+} >+ >+#if USE(NICOSIA) >+void MediaPlayerPrivateGStreamerBase::swapBuffersIfNeeded() >+{ >+} >+#else > RefPtr<TextureMapperPlatformLayerProxy> MediaPlayerPrivateGStreamerBase::proxy() const > { > return m_platformLayerProxy.copyRef(); >@@ -743,6 +765,7 @@ RefPtr<TextureMapperPlatformLayerProxy> MediaPlayerPrivateGStreamerBase::proxy() > void MediaPlayerPrivateGStreamerBase::swapBuffersIfNeeded() > { > } >+#endif > > void MediaPlayerPrivateGStreamerBase::pushTextureToCompositor() > { >@@ -750,32 +773,42 @@ void MediaPlayerPrivateGStreamerBase::pushTextureToCompositor() > if (!GST_IS_SAMPLE(m_sample.get())) > return; > >- LockHolder holder(m_platformLayerProxy->lock()); >+ auto proxyOperation = >+ [&](TextureMapperPlatformLayerProxy& proxy) >+ { >+ LockHolder holder(proxy.lock()); > >- if (!m_platformLayerProxy->isActive()) >- return; >+ if (!proxy.isActive()) >+ return; > >- std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation), !m_usingFallbackVideoSink); >+ std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation), !m_usingFallbackVideoSink); > > #if USE(GSTREAMER_GL) >- GLuint textureID = frameHolder->textureID(); >- if (textureID) { >- std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = std::make_unique<TextureMapperPlatformLayerBuffer>(textureID, frameHolder->size(), frameHolder->flags(), GraphicsContext3D::RGBA); >- layerBuffer->setUnmanagedBufferDataHolder(WTFMove(frameHolder)); >- m_platformLayerProxy->pushNextBuffer(WTFMove(layerBuffer)); >- } else >+ GLuint textureID = frameHolder->textureID(); >+ if (textureID) { >+ std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = std::make_unique<TextureMapperPlatformLayerBuffer>(textureID, frameHolder->size(), frameHolder->flags(), GraphicsContext3D::RGBA); >+ layerBuffer->setUnmanagedBufferDataHolder(WTFMove(frameHolder)); >+ proxy.pushNextBuffer(WTFMove(layerBuffer)); >+ } else >+#endif >+ { >+ std::unique_ptr<TextureMapperPlatformLayerBuffer> buffer = proxy.getAvailableBuffer(frameHolder->size(), GL_DONT_CARE); >+ if (UNLIKELY(!buffer)) { >+ auto texture = BitmapTextureGL::create(TextureMapperContextAttributes::get()); >+ texture->reset(frameHolder->size(), frameHolder->hasAlphaChannel() ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag); >+ buffer = std::make_unique<TextureMapperPlatformLayerBuffer>(WTFMove(texture)); >+ } >+ frameHolder->updateTexture(buffer->textureGL()); >+ buffer->setExtraFlags(texMapFlagFromOrientation(m_videoSourceOrientation) | (frameHolder->hasAlphaChannel() ? TextureMapperGL::ShouldBlend : 0)); >+ proxy.pushNextBuffer(WTFMove(buffer)); >+ } >+ }; >+ >+#if USE(NICOSIA) >+ proxyOperation(downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy()); >+#else >+ proxyOperation(*m_platformLayerProxy); > #endif >- { >- std::unique_ptr<TextureMapperPlatformLayerBuffer> buffer = m_platformLayerProxy->getAvailableBuffer(frameHolder->size(), GL_DONT_CARE); >- if (UNLIKELY(!buffer)) { >- auto texture = BitmapTextureGL::create(TextureMapperContextAttributes::get()); >- texture->reset(frameHolder->size(), frameHolder->hasAlphaChannel() ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag); >- buffer = std::make_unique<TextureMapperPlatformLayerBuffer>(WTFMove(texture)); >- } >- frameHolder->updateTexture(buffer->textureGL()); >- buffer->setExtraFlags(texMapFlagFromOrientation(m_videoSourceOrientation) | (frameHolder->hasAlphaChannel() ? TextureMapperGL::ShouldBlend : 0)); >- m_platformLayerProxy->pushNextBuffer(WTFMove(buffer)); >- } > } > #endif // USE(TEXTURE_MAPPER_GL) > >@@ -818,8 +851,18 @@ void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstSample* sample) > #if USE(TEXTURE_MAPPER_GL) > if (m_usingFallbackVideoSink) { > LockHolder lock(m_drawMutex); >- if (!m_platformLayerProxy->scheduleUpdateOnCompositorThread([this] { this->pushTextureToCompositor(); })) >+ auto proxyOperation = >+ [this](TextureMapperPlatformLayerProxy& proxy) >+ { >+ return proxy.scheduleUpdateOnCompositorThread([this] { this->pushTextureToCompositor(); }); >+ }; >+#if USE(NICOSIA) >+ if (!proxyOperation(downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy())) > return; >+#else >+ if (!proxyOperation(*m_platformLayerProxy)) >+ return; >+#endif > m_drawTimer.startOneShot(0_s); > m_drawCondition.wait(m_drawMutex); > } else >@@ -881,12 +924,20 @@ void MediaPlayerPrivateGStreamerBase::flushCurrentBuffer() > m_sample = adoptGRef(gst_sample_new(nullptr, gst_sample_get_caps(m_sample.get()), > gst_sample_get_segment(m_sample.get()), info ? gst_structure_copy(info) : nullptr)); > >- { >- LockHolder locker(m_platformLayerProxy->lock()); >+ auto proxyOperation = >+ [](TextureMapperPlatformLayerProxy& proxy) >+ { >+ LockHolder locker(proxy.lock()); > >- if (m_platformLayerProxy->isActive()) >- m_platformLayerProxy->dropCurrentBufferWhilePreservingTexture(); >- } >+ if (proxy.isActive()) >+ proxy.dropCurrentBufferWhilePreservingTexture(); >+ }; >+ >+#if USE(NICOSIA) >+ proxyOperation(downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy()); >+#else >+ proxyOperation(*m_platformLayerProxy); >+#endif > } > #endif > >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >index 30ca02e29d7a326c6d2b71a338bb194fa43b5e75..a4f024cd13af0c7f103809a0d63b155e16a3261e 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >@@ -37,8 +37,12 @@ > #include <wtf/WeakPtr.h> > > #if USE(TEXTURE_MAPPER_GL) >+#if USE(NICOSIA) >+#include "NicosiaContentLayerTextureMapperImpl.h" >+#else > #include "TextureMapperPlatformLayerProxyProvider.h" > #endif >+#endif > > typedef struct _GstStreamVolume GstStreamVolume; > typedef struct _GstVideoInfo GstVideoInfo; >@@ -63,8 +67,12 @@ void registerWebKitGStreamerElements(); > > class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface, public CanMakeWeakPtr<MediaPlayerPrivateGStreamerBase> > #if USE(TEXTURE_MAPPER_GL) >+#if USE(NICOSIA) >+ , public Nicosia::ContentLayerTextureMapperImpl::Client >+#else > , public PlatformLayer > #endif >+#endif > { > > public: >@@ -126,7 +134,7 @@ public: > void acceleratedRenderingStateChanged() override; > > #if USE(TEXTURE_MAPPER_GL) >- PlatformLayer* platformLayer() const override { return const_cast<MediaPlayerPrivateGStreamerBase*>(this); } >+ PlatformLayer* platformLayer() const override; > #if PLATFORM(WIN_CAIRO) > // FIXME: Accelerated rendering has not been implemented for WinCairo yet. > bool supportsAcceleratedRendering() const override { return false; } >@@ -175,9 +183,13 @@ protected: > #endif > > #if USE(TEXTURE_MAPPER_GL) >+ void pushTextureToCompositor(); >+#if USE(NICOSIA) >+ void swapBuffersIfNeeded() override; >+#else > RefPtr<TextureMapperPlatformLayerProxy> proxy() const override; > void swapBuffersIfNeeded() override; >- void pushTextureToCompositor(); >+#endif > #endif > > GstElement* videoSink() const { return m_videoSink.get(); } >@@ -238,8 +250,12 @@ protected: > RunLoop::Timer<MediaPlayerPrivateGStreamerBase> m_drawTimer; > > #if USE(TEXTURE_MAPPER_GL) >+#if USE(NICOSIA) >+ Ref<Nicosia::ContentLayer> m_nicosiaLayer; >+#else > RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy; > #endif >+#endif > > #if USE(GSTREAMER_GL) > GRefPtr<GstGLContext> m_glContext; >diff --git a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..6533c0d9fac580b165797b437342eb9429ffeec0 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp >@@ -0,0 +1,100 @@ >+/* >+ * Copyright (C) 2018 Metrological Group B.V. >+ * Copyright (C) 2018 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following >+ * disclaimer in the documentation and/or other materials provided >+ * with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "NicosiaGC3DLayer.h" >+ >+#if USE(NICOSIA) && USE(TEXTURE_MAPPER) >+ >+#if USE(COORDINATED_GRAPHICS_THREADED) >+#include "TextureMapperGL.h" >+#include "TextureMapperPlatformLayerBuffer.h" >+#include "TextureMapperPlatformLayerProxy.h" >+#endif >+ >+#include "GLContext.h" >+ >+namespace Nicosia { >+ >+using namespace WebCore; >+ >+GC3DLayer::GC3DLayer(GraphicsContext3D& context, GraphicsContext3D::RenderStyle renderStyle) >+ : m_context(context) >+ , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this))) >+{ >+ switch (renderStyle) { >+ case GraphicsContext3D::RenderOffscreen: >+ m_glContext = GLContext::createOffscreenContext(&PlatformDisplay::sharedDisplayForCompositing()); >+ break; >+ case GraphicsContext3D::RenderDirectlyToHostWindow: >+ ASSERT_NOT_REACHED(); >+ break; >+ } >+} >+ >+GC3DLayer::~GC3DLayer() >+{ >+ downcast<ContentLayerTextureMapperImpl>(m_contentLayer->impl()).invalidateClient(); >+} >+ >+bool GC3DLayer::makeContextCurrent() >+{ >+ ASSERT(m_glContext); >+ return m_glContext->makeContextCurrent(); >+} >+ >+PlatformGraphicsContext3D GC3DLayer::platformContext() >+{ >+ ASSERT(m_glContext); >+ return m_glContext->platformContext(); >+} >+ >+void GC3DLayer::swapBuffersIfNeeded() >+{ >+#if USE(COORDINATED_GRAPHICS_THREADED) >+ if (m_context.layerComposited()) >+ return; >+ >+ m_context.prepareTexture(); >+ IntSize textureSize(m_context.m_currentWidth, m_context.m_currentHeight); >+ TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context.m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0); >+ >+ { >+ auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).proxy(); >+ >+ LockHolder holder(proxy.lock()); >+ proxy.pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags, m_context.m_internalColorFormat)); >+ } >+ >+ m_context.markLayerComposited(); >+#endif >+} >+ >+} // namespace Nicosia >+ >+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER) >diff --git a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h >new file mode 100644 >index 0000000000000000000000000000000000000000..32db9dd37a6f0d9fa8d4d188eb18f8ae1475a00b >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h >@@ -0,0 +1,63 @@ >+/* >+ * Copyright (C) 2018 Metrological Group B.V. >+ * Copyright (C) 2018 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following >+ * disclaimer in the documentation and/or other materials provided >+ * with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if USE(NICOSIA) && USE(TEXTURE_MAPPER) >+ >+#include "GraphicsContext3D.h" >+#include "NicosiaContentLayerTextureMapperImpl.h" >+#include <memory> >+ >+namespace WebCore { >+class GLContext; >+} >+ >+namespace Nicosia { >+ >+class GC3DLayer : public ContentLayerTextureMapperImpl::Client { >+public: >+ GC3DLayer(WebCore::GraphicsContext3D&, WebCore::GraphicsContext3D::RenderStyle); >+ virtual ~GC3DLayer(); >+ >+ ContentLayer& contentLayer() const { return m_contentLayer; } >+ bool makeContextCurrent(); >+ PlatformGraphicsContext3D platformContext(); >+ >+ void swapBuffersIfNeeded() override; >+ >+private: >+ WebCore::GraphicsContext3D& m_context; >+ std::unique_ptr<WebCore::GLContext> m_glContext; >+ >+ Ref<ContentLayer> m_contentLayer; >+}; >+ >+} // namespace Nicosia >+ >+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER) >diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp >index a026e8cbbaab6af64d4fd0c5f7891998268e9b02..b7cc26a100f9ecd2ba9cf674fafc8dfd193f01cf 100644 >--- a/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp >+++ b/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp >@@ -53,6 +53,8 @@ > #include "Extensions3DOpenGL.h" > #endif > >+#include "NicosiaGC3DLayer.h" >+ > namespace WebCore { > > static const size_t MaxActiveContexts = 16; >@@ -105,7 +107,11 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attributes, Hos > : m_attrs(attributes) > { > ASSERT_UNUSED(sharedContext, !sharedContext); >+#if USE(NICOSIA) >+ m_nicosiaLayer = std::make_unique<Nicosia::GC3DLayer>(*this, renderStyle); >+#else > m_texmapLayer = std::make_unique<TextureMapperGC3DPlatformLayer>(*this, renderStyle); >+#endif > > makeContextCurrent(); > >@@ -270,7 +276,11 @@ void GraphicsContext3D::setErrorMessageCallback(std::unique_ptr<ErrorMessageCall > > bool GraphicsContext3D::makeContextCurrent() > { >+#if USE(NICOSIA) >+ return m_nicosiaLayer->makeContextCurrent(); >+#else > return m_texmapLayer->makeContextCurrent(); >+#endif > } > > void GraphicsContext3D::checkGPUStatus() >@@ -279,7 +289,11 @@ void GraphicsContext3D::checkGPUStatus() > > PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() > { >+#if USE(NICOSIA) >+ return m_nicosiaLayer->platformContext(); >+#else > return m_texmapLayer->platformContext(); >+#endif > } > > Platform3DObject GraphicsContext3D::platformTexture() const >@@ -298,7 +312,11 @@ bool GraphicsContext3D::isGLES2Compliant() const > > PlatformLayer* GraphicsContext3D::platformLayer() const > { >+#if USE(NICOSIA) >+ return &m_nicosiaLayer->contentLayer(); >+#else > return m_texmapLayer.get(); >+#endif > } > > #if PLATFORM(GTK) >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp >index 6c568e4544c3d7476832d2c5b24e8ae4bc011a8b..45a181133c4f18a8644d2f0cb13ca5af7a7d1a26 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp >@@ -20,7 +20,7 @@ > #include "config.h" > #include "TextureMapperGC3DPlatformLayer.h" > >-#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER) >+#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER) && !USE(NICOSIA) > > #include "BitmapTextureGL.h" > #include "GLContext.h" >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h >index bab5036c8589550edada37c5ca192c620d7096f2..e492a2513d648c26055418c5a0ec9d9f554e2a03 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h >@@ -19,7 +19,7 @@ > > #pragma once > >-#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER) >+#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER) && !USE(NICOSIA) > > #include "GraphicsContext3D.h" > #include "PlatformLayer.h" >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >index abaa71c46eb143502b3085c7d6830cf18f8e4375..be21680fbd2b191939dae5a0ca5f29f4b69d80d0 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >@@ -432,10 +432,13 @@ void CoordinatedGraphicsLayer::setContentsNeedsDisplay() > void CoordinatedGraphicsLayer::setContentsToPlatformLayer(PlatformLayer* platformLayer, ContentsLayerPurpose) > { > #if USE(COORDINATED_GRAPHICS_THREADED) >+#if USE(NICOSIA) >+#else > if (m_platformLayer != platformLayer) > m_shouldSyncPlatformLayer = true; > > m_platformLayer = platformLayer; >+#endif > notifyFlushRequired(); > #else > UNUSED_PARAM(platformLayer); >@@ -742,28 +745,34 @@ void CoordinatedGraphicsLayer::syncAnimations() > > void CoordinatedGraphicsLayer::syncPlatformLayer() > { >-#if USE(COORDINATED_GRAPHICS_THREADED) > if (!m_shouldSyncPlatformLayer) > return; > > m_shouldSyncPlatformLayer = false; >+#if USE(COORDINATED_GRAPHICS_THREADED) >+#if USE(NICOSIA) >+#else > m_layerState.platformLayerChanged = true; > if (m_platformLayer) > m_layerState.platformLayerProxy = m_platformLayer->proxy(); > #endif >+#endif > } > > void CoordinatedGraphicsLayer::updatePlatformLayer() > { >-#if USE(COORDINATED_GRAPHICS_THREADED) > if (!m_shouldUpdatePlatformLayer) > return; > > m_shouldUpdatePlatformLayer = false; >+#if USE(COORDINATED_GRAPHICS_THREADED) >+#if USE(NICOSIA) >+#else > m_layerState.platformLayerUpdated = true; > if (m_platformLayer) > m_platformLayer->swapBuffersIfNeeded(); > #endif >+#endif > } > > void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188405
:
346759
|
346761
|
346779
|
346784