summaryrefslogtreecommitdiffstats
path: root/meta/recipes-rp/wpewebkit/wpewebkit/0001-REGRESSION-r217927-WPE-2.22-GSTREAMER_GL-Video-appea.patch
blob: 9c3ca612f24e8acf306e9f26d0e55606466f1ec1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
From 4f91f0a3061cc45330f9d764cd8e6fd0af5fe116 Mon Sep 17 00:00:00 2001
From: Carlos Alberto Lopez Perez <clopez@igalia.com>
Date: Wed, 9 May 2018 14:37:46 +0200
Subject: [PATCH] REGRESSION(r217927): [WPE-2.22][GSTREAMER_GL] Video appears
 as pink/green with gstreamer-imx (i.MX6)

* r217927 <https://trac.webkit.org/r217927> causes issues (video
  appears as pink/green) with gstreamer-imx plugin.

* This patch reverts r217927 meanwhile a better solution is not
  found.

Issue tracked upstream at: https://webkit.org/b/185470
---
 .../MediaPlayerPrivateGStreamerBase.cpp       | 18 ++++--------------
 .../gstreamer/VideoTextureCopierGStreamer.cpp | 19 ++-----------------
 .../gstreamer/VideoTextureCopierGStreamer.h   |  9 +--------
 .../graphics/texmap/TextureMapperGL.cpp       |  2 --
 .../graphics/texmap/TextureMapperGL.h         |  3 +--
 5 files changed, 8 insertions(+), 43 deletions(-)

diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
index 1dfb9696..deff6a32 100644
--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
@@ -58,16 +58,6 @@
 #endif
 
 #if USE(GSTREAMER_GL)
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define GST_GL_CAPS_FORMAT "{ BGRx, BGRA }"
-#define TEXTURE_MAPPER_COLOR_CONVERT_FLAG TextureMapperGL::ShouldConvertTextureBGRAToRGBA
-#define TEXTURE_COPIER_COLOR_CONVERT_FLAG VideoTextureCopierGStreamer::ColorConversion::ConvertBGRAToRGBA
-#else
-#define GST_GL_CAPS_FORMAT "{ xRGB, ARGB }"
-#define TEXTURE_MAPPER_COLOR_CONVERT_FLAG TextureMapperGL::ShouldConvertTextureARGBToRGBA
-#define TEXTURE_COPIER_COLOR_CONVERT_FLAG VideoTextureCopierGStreamer::ColorConversion::ConvertARGBToRGBA
-#endif
-
 #include <gst/app/gstappsink.h>
 
 #if USE(LIBEPOXY)
@@ -215,7 +205,7 @@ public:
             return;
 
 #if USE(GSTREAMER_GL)
-        m_flags = flags | (m_hasAlphaChannel ? TextureMapperGL::ShouldBlend : 0) | TEXTURE_MAPPER_COLOR_CONVERT_FLAG;
+        m_flags = flags | (m_hasAlphaChannel ? TextureMapperGL::ShouldBlend : 0);
 
         if (gstGLEnabled) {
             m_isMapped = gst_video_frame_map(&m_videoFrame, &videoInfo, m_buffer, static_cast<GstMapFlags>(GST_MAP_READ | GST_MAP_GL));
@@ -1003,7 +993,7 @@ bool MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture(Graphics
         size = size.transposedSize();
 
     if (!m_videoTextureCopier)
-        m_videoTextureCopier = std::make_unique<VideoTextureCopierGStreamer>(TEXTURE_COPIER_COLOR_CONVERT_FLAG);
+        m_videoTextureCopier = std::make_unique<VideoTextureCopierGStreamer>();
 
     return m_videoTextureCopier->copyVideoTextureToPlatformTexture(textureID, size, outputTexture, outputTarget, level, internalFormat, format, type, flipY, m_videoSourceOrientation);
 }
@@ -1033,7 +1023,7 @@ NativeImagePtr MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime()
     context->makeContextCurrent();
 
     if (!m_videoTextureCopier)
-        m_videoTextureCopier = std::make_unique<VideoTextureCopierGStreamer>(TEXTURE_COPIER_COLOR_CONVERT_FLAG);
+        m_videoTextureCopier = std::make_unique<VideoTextureCopierGStreamer>();
 
     if (!m_videoTextureCopier->copyVideoTextureToPlatformTexture(textureID, size, 0, GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, false, m_videoSourceOrientation))
         return nullptr;
@@ -1132,7 +1122,7 @@ GstElement* MediaPlayerPrivateGStreamerBase::createVideoSinkGL()
 
     gst_bin_add_many(GST_BIN(videoSink), upload, colorconvert, appsink, nullptr);
 
-    GRefPtr<GstCaps> caps = adoptGRef(gst_caps_from_string("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), format = (string) " GST_GL_CAPS_FORMAT));
+    GRefPtr<GstCaps> caps = adoptGRef(gst_caps_from_string("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), format = (string) { RGBA }"));
 
     result &= gst_element_link_pads(upload, "src", colorconvert, "sink");
     result &= gst_element_link_pads_filtered(colorconvert, "src", appsink, "sink", caps.get());
diff --git a/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp
index 135333ea..46354e9c 100644
--- a/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp
@@ -29,7 +29,7 @@
 
 namespace WebCore {
 
-VideoTextureCopierGStreamer::VideoTextureCopierGStreamer(ColorConversion colorConversion)
+VideoTextureCopierGStreamer::VideoTextureCopierGStreamer()
 {
     GLContext* previousContext = GLContext::current();
     ASSERT(previousContext);
@@ -51,7 +51,6 @@ VideoTextureCopierGStreamer::VideoTextureCopierGStreamer(ColorConversion colorCo
     glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
     glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 8, vertices, GL_STATIC_DRAW);
 
-    updateColorConversionMatrix(colorConversion);
     updateTextureSpaceMatrix();
 
     previousContext->makeContextCurrent();
@@ -75,20 +74,6 @@ VideoTextureCopierGStreamer::~VideoTextureCopierGStreamer()
         previousContext->makeContextCurrent();
 }
 
-void VideoTextureCopierGStreamer::updateColorConversionMatrix(ColorConversion colorConversion)
-{
-    switch (colorConversion) {
-    case ColorConversion::ConvertBGRAToRGBA:
-        m_colorConversionMatrix.setMatrix(0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
-        break;
-    case ColorConversion::ConvertARGBToRGBA:
-        m_colorConversionMatrix.setMatrix(0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0);
-        break;
-    default:
-        RELEASE_ASSERT_NOT_REACHED();
-    }
-}
-
 void VideoTextureCopierGStreamer::updateTextureSpaceMatrix()
 {
     m_textureSpaceMatrix.makeIdentity();
@@ -193,7 +178,7 @@ bool VideoTextureCopierGStreamer::copyVideoTextureToPlatformTexture(GLuint input
     m_shaderProgram->setMatrix(m_shaderProgram->modelViewMatrixLocation(), m_modelViewMatrix);
     m_shaderProgram->setMatrix(m_shaderProgram->projectionMatrixLocation(), m_projectionMatrix);
     m_shaderProgram->setMatrix(m_shaderProgram->textureSpaceMatrixLocation(), m_textureSpaceMatrix);
-    m_shaderProgram->setMatrix(m_shaderProgram->textureColorSpaceMatrixLocation(), m_colorConversionMatrix);
+    m_shaderProgram->setMatrix(m_shaderProgram->textureColorSpaceMatrixLocation(), TransformationMatrix());
 
     // Perform the copy.
 #if !USE(OPENGL_ES)
diff --git a/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.h
index ed1d58f7..fa277b06 100644
--- a/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.h
+++ b/Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.h
@@ -34,16 +34,10 @@ class ImageOrientation;
 
 class VideoTextureCopierGStreamer {
 public:
-    enum class ColorConversion {
-        ConvertBGRAToRGBA,
-        ConvertARGBToRGBA
-    };
-
-    VideoTextureCopierGStreamer(ColorConversion);
+    VideoTextureCopierGStreamer();
     ~VideoTextureCopierGStreamer();
 
     bool copyVideoTextureToPlatformTexture(GLuint inputTexture, IntSize& frameSize, GLuint outputTexture, GLenum outputTarget, GLint level, GLenum internalFormat, GLenum format, GLenum type, bool flipY, ImageOrientation& sourceOrientation);
-    void updateColorConversionMatrix(ColorConversion);
     void updateTextureSpaceMatrix();
     void updateTransformationMatrix();
     GLuint resultTexture() { return m_resultTexture; }
@@ -61,7 +55,6 @@ private:
     TransformationMatrix m_modelViewMatrix;
     TransformationMatrix m_projectionMatrix;
     TransformationMatrix m_textureSpaceMatrix;
-    TransformationMatrix m_colorConversionMatrix;
     GLuint m_resultTexture { 0 };
 };
 
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
index ad68f2bd..ae66e9af 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
@@ -443,8 +443,6 @@ static TransformationMatrix colorSpaceMatrixForFlags(TextureMapperGL::Flags flag
     TransformationMatrix matrix;
     if (flags & TextureMapperGL::ShouldConvertTextureBGRAToRGBA)
         matrix.setMatrix(0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
-    else if (flags & TextureMapperGL::ShouldConvertTextureARGBToRGBA)
-        matrix.setMatrix(0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0);
 
     return matrix;
 }
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
index e1e3905d..c753dff5 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
@@ -52,8 +52,7 @@ public:
         ShouldRotateTexture90 = 0x10,
         ShouldRotateTexture180 = 0x20,
         ShouldRotateTexture270 = 0x40,
-        ShouldConvertTextureBGRAToRGBA = 0x80,
-        ShouldConvertTextureARGBToRGBA = 0x100
+        ShouldConvertTextureBGRAToRGBA = 0x80
     };
 
     typedef int Flags;
-- 
2.18.0