<!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>[259945] releases/WebKitGTK/webkit-2.28/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/259945">259945</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2020-04-12 06:02:50 -0700 (Sun, 12 Apr 2020)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/258197">r258197</a> - [GStreamer][GL] External OES textures rendering support
https://bugs.webkit.org/show_bug.cgi?id=208572

Patch by Philippe Normand <philn@igalia.com> on 2020-03-10
Reviewed by Žan Doberšek.

For hardware that contains native YUV samplers, some drivers may
only support external-oes import of YUV textures, so by supporting
this texture target in the MediaPlayer we can avoid some costly
operations in the pipeline.

* platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp:
(webKitGLVideoSinkSetMediaPlayerPrivate):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::GstVideoFrameHolder::GstVideoFrameHolder):
(WebCore::GstVideoFrameHolder::platformLayerBuffer):
(WebCore::MediaPlayerPrivateGStreamer::paint):
* platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp:
(WebCore::VideoTextureCopierGStreamer::copyVideoTextureToPlatformTexture):
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
(WebCore::TextureMapperGL::drawTextureExternalOES):
* platform/graphics/texmap/TextureMapperGL.h:
* platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp:
(WebCore::TextureMapperPlatformLayerBuffer::clone):
(WebCore::TextureMapperPlatformLayerBuffer::paintToTextureMapper):
* platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h:
* platform/graphics/texmap/TextureMapperShaderProgram.cpp:
(WebCore::TextureMapperShaderProgram::create):
* platform/graphics/texmap/TextureMapperShaderProgram.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit228SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamercpp">releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicsgstreamerVideoTextureCopierGStreamercpp">releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperGLcpp">releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperGLh">releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h</a></li>
<li><a href="#releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperGLHeadersh">releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGLHeaders.h</a></li>
<li><a href="#releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperPlatformLayerBuffercpp">releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperPlatformLayerBufferh">releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h</a></li>
<li><a href="#releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperShaderProgramcpp">releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperShaderProgramh">releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit228SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog (259944 => 259945)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog  2020-04-12 09:28:45 UTC (rev 259944)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog     2020-04-12 13:02:50 UTC (rev 259945)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2020-03-10  Philippe Normand  <philn@igalia.com>
+
+        [GStreamer][GL] External OES textures rendering support
+        https://bugs.webkit.org/show_bug.cgi?id=208572
+
+        Reviewed by Žan Doberšek.
+
+        For hardware that contains native YUV samplers, some drivers may
+        only support external-oes import of YUV textures, so by supporting
+        this texture target in the MediaPlayer we can avoid some costly
+        operations in the pipeline.
+
+        * platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp:
+        (webKitGLVideoSinkSetMediaPlayerPrivate):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::GstVideoFrameHolder::GstVideoFrameHolder):
+        (WebCore::GstVideoFrameHolder::platformLayerBuffer):
+        (WebCore::MediaPlayerPrivateGStreamer::paint):
+        * platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp:
+        (WebCore::VideoTextureCopierGStreamer::copyVideoTextureToPlatformTexture):
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
+        (WebCore::TextureMapperGL::drawTextureExternalOES):
+        * platform/graphics/texmap/TextureMapperGL.h:
+        * platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp:
+        (WebCore::TextureMapperPlatformLayerBuffer::clone):
+        (WebCore::TextureMapperPlatformLayerBuffer::paintToTextureMapper):
+        * platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h:
+        * platform/graphics/texmap/TextureMapperShaderProgram.cpp:
+        (WebCore::TextureMapperShaderProgram::create):
+        * platform/graphics/texmap/TextureMapperShaderProgram.h:
+
</ins><span class="cx"> 2020-03-08  Konstantin Tokarev  <annulen@yandex.ru>
</span><span class="cx"> 
</span><span class="cx">         [GTK] Fix compilation with disabled OpenGL
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (259944 => 259945)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp        2020-04-12 09:28:45 UTC (rev 259944)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp   2020-04-12 13:02:50 UTC (rev 259945)
</span><span class="lines">@@ -206,10 +206,13 @@
</span><span class="cx"> #if USE(GSTREAMER_GL)
</span><span class="cx">         m_flags = flags | (m_hasAlphaChannel ? TextureMapperGL::ShouldBlend : 0);
</span><span class="cx"> 
</span><ins>+        GstMemory* memory = gst_buffer_peek_memory(m_buffer.get(), 0);
+        if (gst_is_gl_memory(memory))
+            m_textureTarget = gst_gl_memory_get_texture_target(GST_GL_MEMORY_CAST(memory));
+
</ins><span class="cx"> #if USE(WPE_VIDEO_PLANE_DISPLAY_DMABUF)
</span><span class="cx">         m_dmabufFD = -1;
</span><span class="cx">         gsize offset;
</span><del>-        GstMemory* memory = gst_buffer_peek_memory(m_buffer.get(), 0);
</del><span class="cx">         if (gst_is_gl_memory_egl(memory)) {
</span><span class="cx">             GstGLMemoryEGL* eglMemory = (GstGLMemoryEGL*) memory;
</span><span class="cx">             gst_egl_image_export_dmabuf(eglMemory->image, &m_dmabufFD, &m_dmabufStride, &offset);
</span><span class="lines">@@ -331,8 +334,11 @@
</span><span class="cx"> 
</span><span class="cx">         using Buffer = TextureMapperPlatformLayerBuffer;
</span><span class="cx"> 
</span><ins>+        if (m_textureTarget == GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
+            return makeUnique<Buffer>(Buffer::TextureVariant { Buffer::ExternalOESTexture { m_textureID } }, m_size, m_flags, GL_DONT_CARE);
+
</ins><span class="cx">         if ((GST_VIDEO_INFO_IS_RGB(&m_videoFrame.info) && GST_VIDEO_INFO_N_PLANES(&m_videoFrame.info) == 1))
</span><del>-            return makeUnique<Buffer>(Buffer::TextureVariant { Buffer::RGBTexture { *static_cast<GLuint*>(m_videoFrame.data[0]) } }, m_size, m_flags, GL_RGBA);
</del><ins>+            return makeUnique<Buffer>(Buffer::TextureVariant { Buffer::RGBTexture { m_textureID } }, m_size, m_flags, GL_RGBA);
</ins><span class="cx"> 
</span><span class="cx">         if (GST_VIDEO_INFO_IS_YUV(&m_videoFrame.info)) {
</span><span class="cx">             if (GST_VIDEO_INFO_N_COMPONENTS(&m_videoFrame.info) < 3 || GST_VIDEO_INFO_N_PLANES(&m_videoFrame.info) > 3)
</span><span class="lines">@@ -342,7 +348,7 @@
</span><span class="cx">                 // IMX VPU decoder decodes YUV data only into the Y texture from which the sampler
</span><span class="cx">                 // then directly produces RGBA data. Textures for other planes aren't used, but
</span><span class="cx">                 // that's decoder's problem. We have to treat that Y texture as having RGBA data.
</span><del>-                return makeUnique<Buffer>(Buffer::TextureVariant { Buffer::RGBTexture { *static_cast<GLuint*>(m_videoFrame.data[0]) } }, m_size, m_flags, GL_RGBA);
</del><ins>+                return makeUnique<Buffer>(Buffer::TextureVariant { Buffer::RGBTexture { m_textureID } }, m_size, m_flags, GL_RGBA);
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             unsigned numberOfPlanes = GST_VIDEO_INFO_N_PLANES(&m_videoFrame.info);
</span><span class="lines">@@ -395,6 +401,7 @@
</span><span class="cx">     Optional<GstVideoDecoderPlatform> m_videoDecoderPlatform;
</span><span class="cx">     TextureMapperGL::Flags m_flags { };
</span><span class="cx">     GLuint m_textureID { 0 };
</span><ins>+    GstGLTextureTarget m_textureTarget { GST_GL_TEXTURE_TARGET_NONE };
</ins><span class="cx">     bool m_isMapped { false };
</span><span class="cx">     bool m_hasMappedTextures { false };
</span><span class="cx"> #if USE(WPE_VIDEO_PLANE_DISPLAY_DMABUF)
</span><span class="lines">@@ -3388,13 +3395,15 @@
</span><span class="cx">     if (!gst_video_info_from_caps(&videoInfo, caps))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (!GST_VIDEO_INFO_IS_RGB(&videoInfo)) {
-        if (!m_colorConvert) {
-            GstMemory* mem = gst_buffer_peek_memory(buffer, 0);
-            GstGLContext* context = ((GstGLBaseMemory*)mem)->context;
-            m_colorConvert = adoptGRef(gst_gl_color_convert_new(context));
-        }
</del><ins>+    GstMemory* memory = gst_buffer_peek_memory(buffer, 0);
+    bool hasExternalOESTexture = false;
+    if (gst_is_gl_memory(memory))
+        hasExternalOESTexture = gst_gl_memory_get_texture_target(GST_GL_MEMORY_CAST(memory)) == GST_GL_TEXTURE_TARGET_EXTERNAL_OES;
</ins><span class="cx"> 
</span><ins>+    if (!GST_VIDEO_INFO_IS_RGB(&videoInfo) || hasExternalOESTexture) {
+        if (!m_colorConvert)
+            m_colorConvert = adoptGRef(gst_gl_color_convert_new(GST_GL_BASE_MEMORY_CAST(memory)->context));
+
</ins><span class="cx">         if (!m_colorConvertInputCaps || !gst_caps_is_equal(m_colorConvertInputCaps.get(), caps)) {
</span><span class="cx">             m_colorConvertInputCaps = caps;
</span><span class="cx">             m_colorConvertOutputCaps = adoptGRef(gst_caps_copy(caps));
</span><span class="lines">@@ -3403,7 +3412,8 @@
</span><span class="cx"> #else
</span><span class="cx">             const char* formatString = GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? "RGBA" : "RGBx";
</span><span class="cx"> #endif
</span><del>-            gst_caps_set_simple(m_colorConvertOutputCaps.get(), "format", G_TYPE_STRING, formatString, nullptr);
</del><ins>+            gst_caps_set_simple(m_colorConvertOutputCaps.get(), "format", G_TYPE_STRING, formatString,
+                "texture-target", G_TYPE_STRING, GST_GL_TEXTURE_TARGET_2D_STR, nullptr);
</ins><span class="cx">             if (!gst_gl_color_convert_set_caps(m_colorConvert.get(), caps, m_colorConvertOutputCaps.get()))
</span><span class="cx">                 return;
</span><span class="cx">         }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicsgstreamerVideoTextureCopierGStreamercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp (259944 => 259945)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp        2020-04-12 09:28:45 UTC (rev 259944)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp   2020-04-12 13:02:50 UTC (rev 259945)
</span><span class="lines">@@ -178,7 +178,11 @@
</span><span class="cx">                 options = TextureMapperShaderProgram::TextureYUV;
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><del>-        });
</del><ins>+        },
+        [&](const Buffer::ExternalOESTexture&) {
+            options = TextureMapperShaderProgram::TextureExternalOES;
+        }
+    );
</ins><span class="cx"> 
</span><span class="cx">     if (options != m_shaderOptions) {
</span><span class="cx">         m_shaderProgram = TextureMapperShaderProgram::create(options);
</span><span class="lines">@@ -252,6 +256,15 @@
</span><span class="cx">                 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
</span><span class="cx">                 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
</span><span class="cx">             }
</span><ins>+        },
+        [&](const Buffer::ExternalOESTexture& texture) {
+            glUniform1i(m_shaderProgram->externalOESTextureLocation(), 0);
+
+            glActiveTexture(GL_TEXTURE0);
+            glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture.id);
+            glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+            glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+            glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
</ins><span class="cx">         });
</span><span class="cx"> 
</span><span class="cx">     m_shaderProgram->setMatrix(m_shaderProgram->modelViewMatrixLocation(), m_modelViewMatrix);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperGLcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (259944 => 259945)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp       2020-04-12 09:28:45 UTC (rev 259944)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp  2020-04-12 13:02:50 UTC (rev 259945)
</span><span class="lines">@@ -773,7 +773,12 @@
</span><span class="cx">     glUseProgram(program.programID());
</span><span class="cx"> 
</span><span class="cx">     bool repeatWrap = wrapMode() == RepeatWrap && m_contextAttributes.supportsNPOTTextures;
</span><del>-    GLenum target = flags & ShouldUseARBTextureRect ? GLenum(GL_TEXTURE_RECTANGLE_ARB) : GLenum(GL_TEXTURE_2D);
</del><ins>+    GLenum target;
+    if (flags & ShouldUseExternalOESTextureRect)
+        target = GLenum(GL_TEXTURE_EXTERNAL_OES);
+    else
+        target = flags & ShouldUseARBTextureRect ? GLenum(GL_TEXTURE_RECTANGLE_ARB) : GLenum(GL_TEXTURE_2D);
+
</ins><span class="cx">     for (unsigned i = 0; i < texturesAndSamplers.size(); ++i) {
</span><span class="cx">         auto& textureAndSampler = texturesAndSamplers[i];
</span><span class="cx"> 
</span><span class="lines">@@ -961,6 +966,13 @@
</span><span class="cx">     return makeUnique<TextureMapperGL>();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TextureMapperGL::drawTextureExternalOES(GLuint texture, Flags flags, const IntSize& size, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity)
+{
+    Ref<TextureMapperShaderProgram> program = data().getShaderProgram(TextureMapperShaderProgram::Option::TextureExternalOES);
+    drawTexturedQuadWithProgram(program.get(), { { texture, program->externalOESTextureLocation() } },
+        flags | TextureMapperGL::ShouldUseExternalOESTextureRect, size, targetRect, modelViewMatrix, opacity);
+}
+
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #endif // USE(TEXTURE_MAPPER_GL)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperGLh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h (259944 => 259945)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h 2020-04-12 09:28:45 UTC (rev 259944)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h    2020-04-12 13:02:50 UTC (rev 259945)
</span><span class="lines">@@ -56,7 +56,8 @@
</span><span class="cx">         ShouldRotateTexture270 = 0x40,
</span><span class="cx">         ShouldConvertTextureBGRAToRGBA = 0x80,
</span><span class="cx">         ShouldConvertTextureARGBToRGBA = 0x100,
</span><del>-        ShouldNotBlend = 0x200
</del><ins>+        ShouldNotBlend = 0x200,
+        ShouldUseExternalOESTextureRect = 0x400
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     typedef int Flags;
</span><span class="lines">@@ -86,6 +87,7 @@
</span><span class="cx">     void drawFiltered(const BitmapTexture& sourceTexture, const BitmapTexture* contentTexture, const FilterOperation&, int pass);
</span><span class="cx"> 
</span><span class="cx">     void setEnableEdgeDistanceAntialiasing(bool enabled) { m_enableEdgeDistanceAntialiasing = enabled; }
</span><ins>+    void drawTextureExternalOES(GLuint texture, Flags, const IntSize&, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void drawTexturedQuadWithProgram(TextureMapperShaderProgram&, uint32_t texture, Flags, const IntSize&, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperGLHeadersh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGLHeaders.h (259944 => 259945)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGLHeaders.h  2020-04-12 09:28:45 UTC (rev 259944)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperGLHeaders.h     2020-04-12 13:02:50 UTC (rev 259945)
</span><span class="lines">@@ -52,3 +52,7 @@
</span><span class="cx"> #ifndef GL_UNPACK_SKIP_PIXELS
</span><span class="cx"> #define GL_UNPACK_SKIP_PIXELS 0x0CF4
</span><span class="cx"> #endif
</span><ins>+
+#ifndef GL_TEXTURE_EXTERNAL_OES
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#endif
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperPlatformLayerBuffercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp (259944 => 259945)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp      2020-04-12 09:28:45 UTC (rev 259944)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp 2020-04-12 13:02:50 UTC (rev 259945)
</span><span class="lines">@@ -87,6 +87,11 @@
</span><span class="cx">         {
</span><span class="cx">             notImplemented();
</span><span class="cx">             return nullptr;
</span><ins>+        },
+        [](const ExternalOESTexture&)
+        {
+            notImplemented();
+            return nullptr;
</ins><span class="cx">         });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -141,6 +146,10 @@
</span><span class="cx">                     texture.yuvToRgbMatrix, m_extraFlags, m_size, targetRect, modelViewMatrix, opacity);
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><ins>+        },
+        [&](const ExternalOESTexture& texture) {
+            ASSERT(texture.id);
+            texmapGL.drawTextureExternalOES(texture.id, m_extraFlags, m_size, targetRect, modelViewMatrix, opacity);
</ins><span class="cx">         });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperPlatformLayerBufferh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h (259944 => 259945)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h        2020-04-12 09:28:45 UTC (rev 259944)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h   2020-04-12 13:02:50 UTC (rev 259945)
</span><span class="lines">@@ -53,7 +53,10 @@
</span><span class="cx">         std::array<unsigned, 3> yuvPlaneOffset;
</span><span class="cx">         std::array<GLfloat, 9> yuvToRgbMatrix;
</span><span class="cx">     };
</span><del>-    using TextureVariant = WTF::Variant<RGBTexture, YUVTexture>;
</del><ins>+    struct ExternalOESTexture {
+        GLuint id;
+    };
+    using TextureVariant = WTF::Variant<RGBTexture, YUVTexture, ExternalOESTexture>;
</ins><span class="cx"> 
</span><span class="cx">     TextureMapperPlatformLayerBuffer(TextureVariant&&, const IntSize&, TextureMapperGL::Flags, GLint internalFormat);
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperShaderProgramcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp (259944 => 259945)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp    2020-04-12 09:28:45 UTC (rev 259944)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp       2020-04-12 13:02:50 UTC (rev 259945)
</span><span class="lines">@@ -160,6 +160,14 @@
</span><span class="cx">     GLSL_DIRECTIVE(define GAUSSIAN_KERNEL_STEP 0.2)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+#define OES_EGL_IMAGE_EXTERNAL_DIRECTIVE \
+    GLSL_DIRECTIVE(ifdef ENABLE_TextureExternalOES) \
+        GLSL_DIRECTIVE(extension GL_OES_EGL_image_external : require) \
+        GLSL_DIRECTIVE(define SamplerExternalOESType samplerExternalOES) \
+    GLSL_DIRECTIVE(else) \
+        GLSL_DIRECTIVE(define SamplerExternalOESType sampler2D) \
+    GLSL_DIRECTIVE(endif)
+
</ins><span class="cx"> // Common header for all versions. We define the matrices variables here to keep the precision
</span><span class="cx"> // directives scope: the first one applies to the matrices variables and the next one to the
</span><span class="cx"> // rest of them. The precision is only used in GLES.
</span><span class="lines">@@ -167,10 +175,9 @@
</span><span class="cx">     RECT_TEXTURE_DIRECTIVE
</span><span class="cx">     ANTIALIASING_TEX_COORD_DIRECTIVE
</span><span class="cx">     BLUR_CONSTANTS
</span><ins>+    OES_EGL_IMAGE_EXTERNAL_DIRECTIVE
</ins><span class="cx"> #if USE(OPENGL_ES)
</span><span class="cx">     TEXTURE_SPACE_MATRIX_PRECISION_DIRECTIVE
</span><del>-#endif
-#if USE(OPENGL_ES)
</del><span class="cx">     STRINGIFY(
</span><span class="cx">         precision TextureSpaceMatrixPrecision float;
</span><span class="cx">     )
</span><span class="lines">@@ -211,6 +218,7 @@
</span><span class="cx">         uniform SamplerType s_samplerU;
</span><span class="cx">         uniform SamplerType s_samplerV;
</span><span class="cx">         uniform sampler2D s_contentTexture;
</span><ins>+        uniform SamplerExternalOESType s_externalOESTexture;
</ins><span class="cx">         uniform float u_opacity;
</span><span class="cx">         uniform float u_filterAmount;
</span><span class="cx">         uniform mat3 u_yuvToRgb;
</span><span class="lines">@@ -374,6 +382,12 @@
</span><span class="cx">             color = sourceOver(contentColor, color);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        void applyTextureExternalOES(inout vec4 color, vec2 texCoord)
+        {
+            vec4 contentColor = texture2D(s_externalOESTexture, texCoord);
+            color = sourceOver(contentColor, color);
+        }
+
</ins><span class="cx">         void applySolidColor(inout vec4 color) { color *= u_color; }
</span><span class="cx"> 
</span><span class="cx">         void main(void)
</span><span class="lines">@@ -400,6 +414,7 @@
</span><span class="cx">             applyBlurFilterIfNeeded(color, texCoord);
</span><span class="cx">             applyAlphaBlurIfNeeded(color, texCoord);
</span><span class="cx">             applyContentTextureIfNeeded(color, texCoord);
</span><ins>+            applyTextureExternalOESIfNeeded(color, texCoord);
</ins><span class="cx">             gl_FragColor = color;
</span><span class="cx">         }
</span><span class="cx">     );
</span><span class="lines">@@ -432,6 +447,7 @@
</span><span class="cx">     SET_APPLIER_FROM_OPTIONS(AlphaBlur);
</span><span class="cx">     SET_APPLIER_FROM_OPTIONS(ContentTexture);
</span><span class="cx">     SET_APPLIER_FROM_OPTIONS(ManualRepeat);
</span><ins>+    SET_APPLIER_FROM_OPTIONS(TextureExternalOES);
</ins><span class="cx"> 
</span><span class="cx">     StringBuilder vertexShaderBuilder;
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit228SourceWebCoreplatformgraphicstexmapTextureMapperShaderProgramh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h (259944 => 259945)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h      2020-04-12 09:28:45 UTC (rev 259944)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h 2020-04-12 13:02:50 UTC (rev 259945)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx">         TextureNV12      = 1L << 19,
</span><span class="cx">         TextureNV21      = 1L << 20,
</span><span class="cx">         TexturePackedYUV = 1L << 21,
</span><ins>+        TextureExternalOES = 1L << 22,
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     typedef unsigned Options;
</span><span class="lines">@@ -96,6 +97,7 @@
</span><span class="cx">     TEXMAP_DECLARE_UNIFORM(blurRadius)
</span><span class="cx">     TEXMAP_DECLARE_UNIFORM(shadowOffset)
</span><span class="cx">     TEXMAP_DECLARE_SAMPLER(contentTexture)
</span><ins>+    TEXMAP_DECLARE_SAMPLER(externalOESTexture)
</ins><span class="cx"> 
</span><span class="cx">     void setMatrix(GLuint, const TransformationMatrix&);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>