<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[234688] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/234688">234688</a></dd>
<dt>Author</dt> <dd>zandobersek@gmail.com</dd>
<dt>Date</dt> <dd>2018-08-08 02:31:08 -0700 (Wed, 08 Aug 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Nicosia] Add the Nicosia-specific PlatformLayer type alias
https://bugs.webkit.org/show_bug.cgi?id=188405

Reviewed by Carlos Garcia Campos.

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):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformTextureMappercmake">trunk/Source/WebCore/platform/TextureMapper.cmake</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh">trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsPlatformLayerh">trunk/Source/WebCore/platform/graphics/PlatformLayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoImageBufferCairocpp">trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoImageBufferDataCairoh">trunk/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBasecpp">trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBaseh">trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapGraphicsContext3DTextureMappercpp">trunk/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperGC3DPlatformLayercpp">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperGC3DPlatformLayerh">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapcoordinatedCoordinatedGraphicsLayercpp">trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsnicosiatexmapNicosiaGC3DLayercpp">trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsnicosiatexmapNicosiaGC3DLayerh">trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/ChangeLog      2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -1,3 +1,97 @@
</span><ins>+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 Carlos Garcia Campos.
+
+        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):
+
</ins><span class="cx"> 2018-08-08  Manuel Rego Casasnovas  <rego@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [css-grid] Update behavior of percentage row tracks and gutters
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformTextureMappercmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/TextureMapper.cmake        2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake   2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx"> 
</span><span class="cx">         platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.cpp
</span><span class="cx">         platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp
</span><ins>+        platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp
</ins><span class="cx">     )
</span><span class="cx"> else ()
</span><span class="cx">     list(APPEND WebCore_SOURCES
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h       2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h  2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -74,6 +74,12 @@
</span><span class="cx"> typedef struct __IOSurface* IOSurfaceRef;
</span><span class="cx"> #endif // PLATFORM(COCOA)
</span><span class="cx"> 
</span><ins>+#if USE(NICOSIA)
+namespace Nicosia {
+class GC3DLayer;
+}
+#endif
+
</ins><span class="cx"> #if !PLATFORM(COCOA)
</span><span class="cx"> typedef unsigned GLuint;
</span><span class="cx"> typedef void* PlatformGraphicsContext3D;
</span><span class="lines">@@ -1481,7 +1487,10 @@
</span><span class="cx">     // Errors raised by synthesizeGLError().
</span><span class="cx">     ListHashSet<GC3Denum> m_syntheticErrors;
</span><span class="cx"> 
</span><del>-#if USE(TEXTURE_MAPPER)
</del><ins>+#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
+    friend class Nicosia::GC3DLayer;
+    std::unique_ptr<Nicosia::GC3DLayer> m_nicosiaLayer;
+#elif USE(TEXTURE_MAPPER)
</ins><span class="cx">     friend class TextureMapperGC3DPlatformLayer;
</span><span class="cx">     std::unique_ptr<TextureMapperGC3DPlatformLayer> m_texmapLayer;
</span><span class="cx"> #else
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsPlatformLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/PlatformLayer.h (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/PlatformLayer.h   2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/graphics/PlatformLayer.h      2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -30,6 +30,11 @@
</span><span class="cx"> typedef CALayer PlatformLayer;
</span><span class="cx"> #elif PLATFORM(WIN) && USE(CA)
</span><span class="cx"> typedef struct _CACFLayer PlatformLayer;
</span><ins>+#elif USE(NICOSIA)
+namespace Nicosia {
+class PlatformLayer;
+}
+typedef Nicosia::PlatformLayer PlatformLayer;
</ins><span class="cx"> #elif USE(COORDINATED_GRAPHICS_THREADED)
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class TextureMapperPlatformLayerProxyProvider;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoImageBufferCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp        2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp   2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -91,9 +91,14 @@
</span><span class="cx"> #endif
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(ACCELERATED_2D_CANVAS) && USE(COORDINATED_GRAPHICS_THREADED)
</span><del>-    if (m_renderingMode == RenderingMode::Accelerated)
</del><ins>+    if (m_renderingMode == RenderingMode::Accelerated) {
+#if USE(NICOSIA)
+        m_nicosiaLayer = Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this));
+#else
</ins><span class="cx">         m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy);
</span><span class="cx"> #endif
</span><ins>+    }
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ImageBufferData::~ImageBufferData()
</span><span class="lines">@@ -102,6 +107,10 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ACCELERATED_2D_CANVAS)
</span><ins>+#if USE(COORDINATED_GRAPHICS_THREADED) && USE(NICOSIA)
+    downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).invalidateClient();
+#endif
+
</ins><span class="cx">     GLContext* previousActiveContext = GLContext::current();
</span><span class="cx">     PlatformDisplay::sharedDisplayForCompositing().sharingGLContext()->makeContextCurrent();
</span><span class="cx"> 
</span><span class="lines">@@ -139,10 +148,12 @@
</span><span class="cx">     cairo_set_antialias(m_compositorCr.get(), CAIRO_ANTIALIAS_NONE);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if !USE(NICOSIA)
</ins><span class="cx"> RefPtr<TextureMapperPlatformLayerProxy> ImageBufferData::proxy() const
</span><span class="cx"> {
</span><span class="cx">     return m_platformLayerProxy.copyRef();
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> void ImageBufferData::swapBuffersIfNeeded()
</span><span class="cx"> {
</span><span class="lines">@@ -150,8 +161,18 @@
</span><span class="cx"> 
</span><span class="cx">     if (!m_compositorTexture) {
</span><span class="cx">         createCompositorBuffer();
</span><del>-        LockHolder holder(m_platformLayerProxy->lock());
-        m_platformLayerProxy->pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_compositorTexture, m_size, TextureMapperGL::ShouldBlend, GL_RGBA));
</del><ins>+
+        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
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // It would be great if we could just swap the buffers here as we do with webgl, but that breaks the cases
</span><span class="lines">@@ -671,9 +692,14 @@
</span><span class="cx"> PlatformLayer* ImageBuffer::platformLayer() const
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(ACCELERATED_2D_CANVAS)
</span><ins>+#if USE(NICOSIA)
+    if (m_data.m_renderingMode == RenderingMode::Accelerated)
+        return m_data.m_nicosiaLayer.get();
+#else
</ins><span class="cx">     if (m_data.m_texture)
</span><span class="cx">         return const_cast<ImageBufferData*>(&m_data);
</span><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoImageBufferDataCairoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h      2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h 2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -38,6 +38,10 @@
</span><span class="cx"> #include "TextureMapperPlatformLayerProxyProvider.h"
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(ACCELERATED_2D_CANVAS) && USE(NICOSIA)
+#include "NicosiaContentLayerTextureMapperImpl.h"
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class IntSize;
</span><span class="lines">@@ -45,8 +49,12 @@
</span><span class="cx"> 
</span><span class="cx"> class ImageBufferData
</span><span class="cx"> #if ENABLE(ACCELERATED_2D_CANVAS)
</span><ins>+#if USE(NICOSIA)
+    : public Nicosia::ContentLayerTextureMapperImpl::Client
+#else
</ins><span class="cx">     : public PlatformLayer
</span><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> {
</span><span class="cx"> public:
</span><span class="cx">     ImageBufferData(const IntSize&, RenderingMode);
</span><span class="lines">@@ -62,15 +70,24 @@
</span><span class="cx">     void createCairoGLSurface();
</span><span class="cx"> 
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS_THREADED)
</span><ins>+#if USE(NICOSIA)
+    void swapBuffersIfNeeded() override;
+#else
</ins><span class="cx">     RefPtr<TextureMapperPlatformLayerProxy> proxy() const override;
</span><span class="cx">     void swapBuffersIfNeeded() override;
</span><ins>+#endif
</ins><span class="cx">     void createCompositorBuffer();
</span><span class="cx"> 
</span><del>-    RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
</del><span class="cx">     RefPtr<cairo_surface_t> m_compositorSurface;
</span><span class="cx">     uint32_t m_compositorTexture;
</span><span class="cx">     RefPtr<cairo_t> m_compositorCr;
</span><ins>+
+#if USE(NICOSIA)
+    RefPtr<Nicosia::ContentLayer> m_nicosiaLayer;
</ins><span class="cx"> #else
</span><ins>+    RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
+#endif
+#else
</ins><span class="cx">     virtual void paintToTextureMapper(TextureMapper&, const FloatRect& target, const TransformationMatrix&, float opacity);
</span><span class="cx"> #endif
</span><span class="cx">     uint32_t m_texture;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp     2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -284,13 +284,21 @@
</span><span class="cx">     , m_networkState(MediaPlayer::Empty)
</span><span class="cx">     , m_drawTimer(RunLoop::main(), this, &MediaPlayerPrivateGStreamerBase::repaint)
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><ins>+#if USE(NICOSIA)
+    , m_nicosiaLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
+#else
</ins><span class="cx">     , m_platformLayerProxy(adoptRef(new TextureMapperPlatformLayerProxy()))
</span><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase()
</span><span class="cx"> {
</span><ins>+#if USE(TEXTURE_MAPPER_GL) && USE(NICOSIA)
+    downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).invalidateClient();
+#endif
+
</ins><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA)
</span><span class="cx">     m_protectionCondition.notifyAll();
</span><span class="cx"> #endif
</span><span class="lines">@@ -735,6 +743,20 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><ins>+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
</ins><span class="cx"> RefPtr<TextureMapperPlatformLayerProxy> MediaPlayerPrivateGStreamerBase::proxy() const
</span><span class="cx"> {
</span><span class="cx">     return m_platformLayerProxy.copyRef();
</span><span class="lines">@@ -743,6 +765,7 @@
</span><span class="cx"> void MediaPlayerPrivateGStreamerBase::swapBuffersIfNeeded()
</span><span class="cx"> {
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateGStreamerBase::pushTextureToCompositor()
</span><span class="cx"> {
</span><span class="lines">@@ -750,32 +773,42 @@
</span><span class="cx">     if (!GST_IS_SAMPLE(m_sample.get()))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    LockHolder holder(m_platformLayerProxy->lock());
</del><ins>+    auto proxyOperation =
+        [this](TextureMapperPlatformLayerProxy& proxy)
+        {
+            LockHolder holder(proxy.lock());
</ins><span class="cx"> 
</span><del>-    if (!m_platformLayerProxy->isActive())
-        return;
</del><ins>+            if (!proxy.isActive())
+                return;
</ins><span class="cx"> 
</span><del>-    std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation), !m_usingFallbackVideoSink);
</del><ins>+            std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation), !m_usingFallbackVideoSink);
</ins><span class="cx"> 
</span><span class="cx"> #if USE(GSTREAMER_GL)
</span><del>-    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
</del><ins>+            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
</ins><span class="cx"> #endif
</span><del>-    {
-        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));
-    }
</del><ins>+            {
+                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
</ins><span class="cx"> }
</span><span class="cx"> #endif // USE(TEXTURE_MAPPER_GL)
</span><span class="cx"> 
</span><span class="lines">@@ -818,8 +851,18 @@
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><span class="cx">     if (m_usingFallbackVideoSink) {
</span><span class="cx">         LockHolder lock(m_drawMutex);
</span><del>-        if (!m_platformLayerProxy->scheduleUpdateOnCompositorThread([this] { this->pushTextureToCompositor(); }))
</del><ins>+        auto proxyOperation =
+            [this](TextureMapperPlatformLayerProxy& proxy)
+            {
+                return proxy.scheduleUpdateOnCompositorThread([this] { this->pushTextureToCompositor(); });
+            };
+#if USE(NICOSIA)
+        if (!proxyOperation(downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy()))
</ins><span class="cx">             return;
</span><ins>+#else
+        if (!proxyOperation(*m_platformLayerProxy))
+            return;
+#endif
</ins><span class="cx">         m_drawTimer.startOneShot(0_s);
</span><span class="cx">         m_drawCondition.wait(m_drawMutex);
</span><span class="cx">     } else
</span><span class="lines">@@ -881,12 +924,20 @@
</span><span class="cx">     m_sample = adoptGRef(gst_sample_new(nullptr, gst_sample_get_caps(m_sample.get()),
</span><span class="cx">         gst_sample_get_segment(m_sample.get()), info ? gst_structure_copy(info) : nullptr));
</span><span class="cx"> 
</span><del>-    {
-        LockHolder locker(m_platformLayerProxy->lock());
</del><ins>+    auto proxyOperation =
+        [](TextureMapperPlatformLayerProxy& proxy)
+        {
+            LockHolder locker(proxy.lock());
</ins><span class="cx"> 
</span><del>-        if (m_platformLayerProxy->isActive())
-            m_platformLayerProxy->dropCurrentBufferWhilePreservingTexture();
-    }
</del><ins>+            if (proxy.isActive())
+                proxy.dropCurrentBufferWhilePreservingTexture();
+        };
+
+#if USE(NICOSIA)
+    proxyOperation(downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy());
+#else
+    proxyOperation(*m_platformLayerProxy);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h       2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h  2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -37,8 +37,12 @@
</span><span class="cx"> #include <wtf/WeakPtr.h>
</span><span class="cx"> 
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><ins>+#if USE(NICOSIA)
+#include "NicosiaContentLayerTextureMapperImpl.h"
+#else
</ins><span class="cx"> #include "TextureMapperPlatformLayerProxyProvider.h"
</span><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> typedef struct _GstStreamVolume GstStreamVolume;
</span><span class="cx"> typedef struct _GstVideoInfo GstVideoInfo;
</span><span class="lines">@@ -63,8 +67,12 @@
</span><span class="cx"> 
</span><span class="cx"> class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface, public CanMakeWeakPtr<MediaPlayerPrivateGStreamerBase>
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><ins>+#if USE(NICOSIA)
+    , public Nicosia::ContentLayerTextureMapperImpl::Client
+#else
</ins><span class="cx">     , public PlatformLayer
</span><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> {
</span><span class="cx"> 
</span><span class="cx"> public:
</span><span class="lines">@@ -126,7 +134,7 @@
</span><span class="cx">     void acceleratedRenderingStateChanged() override;
</span><span class="cx"> 
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><del>-    PlatformLayer* platformLayer() const override { return const_cast<MediaPlayerPrivateGStreamerBase*>(this); }
</del><ins>+    PlatformLayer* platformLayer() const override;
</ins><span class="cx"> #if PLATFORM(WIN_CAIRO)
</span><span class="cx">     // FIXME: Accelerated rendering has not been implemented for WinCairo yet.
</span><span class="cx">     bool supportsAcceleratedRendering() const override { return false; }
</span><span class="lines">@@ -175,10 +183,14 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><ins>+    void pushTextureToCompositor();
+#if USE(NICOSIA)
+    void swapBuffersIfNeeded() override;
+#else
</ins><span class="cx">     RefPtr<TextureMapperPlatformLayerProxy> proxy() const override;
</span><span class="cx">     void swapBuffersIfNeeded() override;
</span><del>-    void pushTextureToCompositor();
</del><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     GstElement* videoSink() const { return m_videoSink.get(); }
</span><span class="cx"> 
</span><span class="lines">@@ -238,8 +250,12 @@
</span><span class="cx">     RunLoop::Timer<MediaPlayerPrivateGStreamerBase> m_drawTimer;
</span><span class="cx"> 
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><ins>+#if USE(NICOSIA)
+    Ref<Nicosia::ContentLayer> m_nicosiaLayer;
+#else
</ins><span class="cx">     RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
</span><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> #if USE(GSTREAMER_GL)
</span><span class="cx">     GRefPtr<GstGLContext> m_glContext;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsnicosiatexmapNicosiaGC3DLayercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp (0 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp                               (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp  2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -0,0 +1,100 @@
</span><ins>+/*
+ * 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)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsnicosiatexmapNicosiaGC3DLayerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h (0 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h                         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h    2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+/*
+ * 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)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapGraphicsContext3DTextureMappercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp 2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp    2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -53,6 +53,8 @@
</span><span class="cx"> #include "Extensions3DOpenGL.h"
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#include "NicosiaGC3DLayer.h"
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> static const size_t MaxActiveContexts = 16;
</span><span class="lines">@@ -105,7 +107,11 @@
</span><span class="cx">     : m_attrs(attributes)
</span><span class="cx"> {
</span><span class="cx">     ASSERT_UNUSED(sharedContext, !sharedContext);
</span><ins>+#if USE(NICOSIA)
+    m_nicosiaLayer = std::make_unique<Nicosia::GC3DLayer>(*this, renderStyle);
+#else
</ins><span class="cx">     m_texmapLayer = std::make_unique<TextureMapperGC3DPlatformLayer>(*this, renderStyle);
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     makeContextCurrent();
</span><span class="cx"> 
</span><span class="lines">@@ -270,7 +276,11 @@
</span><span class="cx"> 
</span><span class="cx"> bool GraphicsContext3D::makeContextCurrent()
</span><span class="cx"> {
</span><ins>+#if USE(NICOSIA)
+    return m_nicosiaLayer->makeContextCurrent();
+#else
</ins><span class="cx">     return m_texmapLayer->makeContextCurrent();
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext3D::checkGPUStatus()
</span><span class="lines">@@ -279,7 +289,11 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
</span><span class="cx"> {
</span><ins>+#if USE(NICOSIA)
+    return m_nicosiaLayer->platformContext();
+#else
</ins><span class="cx">     return m_texmapLayer->platformContext();
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Platform3DObject GraphicsContext3D::platformTexture() const
</span><span class="lines">@@ -298,7 +312,11 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformLayer* GraphicsContext3D::platformLayer() const
</span><span class="cx"> {
</span><ins>+#if USE(NICOSIA)
+    return &m_nicosiaLayer->contentLayer();
+#else
</ins><span class="cx">     return m_texmapLayer.get();
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperGC3DPlatformLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp 2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp    2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "TextureMapperGC3DPlatformLayer.h"
</span><span class="cx"> 
</span><del>-#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER)
</del><ins>+#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER) && !USE(NICOSIA)
</ins><span class="cx"> 
</span><span class="cx"> #include "BitmapTextureGL.h"
</span><span class="cx"> #include "GLContext.h"
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperGC3DPlatformLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h   2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h      2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -19,7 +19,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><del>-#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER)
</del><ins>+#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER) && !USE(NICOSIA)
</ins><span class="cx"> 
</span><span class="cx"> #include "GraphicsContext3D.h"
</span><span class="cx"> #include "PlatformLayer.h"
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapcoordinatedCoordinatedGraphicsLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp (234687 => 234688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp   2018-08-08 09:14:35 UTC (rev 234687)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp      2018-08-08 09:31:08 UTC (rev 234688)
</span><span class="lines">@@ -432,10 +432,13 @@
</span><span class="cx"> void CoordinatedGraphicsLayer::setContentsToPlatformLayer(PlatformLayer* platformLayer, ContentsLayerPurpose)
</span><span class="cx"> {
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS_THREADED)
</span><ins>+#if USE(NICOSIA)
+#else
</ins><span class="cx">     if (m_platformLayer != platformLayer)
</span><span class="cx">         m_shouldSyncPlatformLayer = true;
</span><span class="cx"> 
</span><span class="cx">     m_platformLayer = platformLayer;
</span><ins>+#endif
</ins><span class="cx">     notifyFlushRequired();
</span><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(platformLayer);
</span><span class="lines">@@ -742,28 +745,34 @@
</span><span class="cx"> 
</span><span class="cx"> void CoordinatedGraphicsLayer::syncPlatformLayer()
</span><span class="cx"> {
</span><del>-#if USE(COORDINATED_GRAPHICS_THREADED)
</del><span class="cx">     if (!m_shouldSyncPlatformLayer)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_shouldSyncPlatformLayer = false;
</span><ins>+#if USE(COORDINATED_GRAPHICS_THREADED)
+#if USE(NICOSIA)
+#else
</ins><span class="cx">     m_layerState.platformLayerChanged = true;
</span><span class="cx">     if (m_platformLayer)
</span><span class="cx">         m_layerState.platformLayerProxy = m_platformLayer->proxy();
</span><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CoordinatedGraphicsLayer::updatePlatformLayer()
</span><span class="cx"> {
</span><del>-#if USE(COORDINATED_GRAPHICS_THREADED)
</del><span class="cx">     if (!m_shouldUpdatePlatformLayer)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_shouldUpdatePlatformLayer = false;
</span><ins>+#if USE(COORDINATED_GRAPHICS_THREADED)
+#if USE(NICOSIA)
+#else
</ins><span class="cx">     m_layerState.platformLayerUpdated = true;
</span><span class="cx">     if (m_platformLayer)
</span><span class="cx">         m_platformLayer->swapBuffersIfNeeded();
</span><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
</span></span></pre>
</div>
</div>

</body>
</html>