mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 05:56:38 +02:00
247 lines
10 KiB
Diff
247 lines
10 KiB
Diff
Submodule qtwebengine contains modified content
|
|
diff --git a/qtwebengine/src/core/stream_video_node.cpp b/qtwebengine/src/core/stream_video_node.cpp
|
|
index 29922f86..baa39d3b 100644
|
|
--- a/qtwebengine/src/core/stream_video_node.cpp
|
|
+++ b/qtwebengine/src/core/stream_video_node.cpp
|
|
@@ -62,38 +62,45 @@ protected:
|
|
const char *vertexShader() const override {
|
|
// Keep in sync with cc::VertexShaderVideoTransform
|
|
static const char *shader =
|
|
- "attribute highp vec4 a_position;\n"
|
|
- "attribute mediump vec2 a_texCoord;\n"
|
|
- "uniform highp mat4 matrix;\n"
|
|
- "uniform highp mat4 texMatrix;\n"
|
|
- "varying mediump vec2 v_texCoord;\n"
|
|
- "void main() {\n"
|
|
- " gl_Position = matrix * a_position;\n"
|
|
- " v_texCoord = vec4(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)).xy;\n"
|
|
- "}";
|
|
+ R"SHADER(#version 150 core
|
|
+in vec4 a_position;
|
|
+in vec2 a_texCoord;
|
|
+uniform mat4 matrix;
|
|
+uniform mat4 texMatrix;
|
|
+out vec2 v_texCoord;
|
|
+void main() {
|
|
+ gl_Position = matrix * a_position;
|
|
+ v_texCoord = vec4(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)).xy;
|
|
+}
|
|
+ )SHADER";
|
|
return shader;
|
|
}
|
|
|
|
const char *fragmentShader() const override {
|
|
// Keep in sync with cc::FragmentShaderRGBATexAlpha
|
|
static const char *shaderExternal =
|
|
- "#extension GL_OES_EGL_image_external : require\n"
|
|
- "varying mediump vec2 v_texCoord;\n"
|
|
- "uniform samplerExternalOES s_texture;\n"
|
|
- "uniform lowp float alpha;\n"
|
|
- "void main() {\n"
|
|
- " lowp vec4 texColor = texture2D(s_texture, v_texCoord);\n"
|
|
- " gl_FragColor = texColor * alpha;\n"
|
|
- "}";
|
|
+ R"SHADER(#version 150 core
|
|
+#extension GL_OES_EGL_image_external : require
|
|
+in vec2 v_texCoord;
|
|
+uniform samplerExternalOES s_texture;
|
|
+uniform float alpha;
|
|
+out vec4 fragColor;
|
|
+void main() {
|
|
+ vec4 texColor = texture(s_texture, v_texCoord);
|
|
+ fragColor = texColor * alpha;
|
|
+}
|
|
+ )SHADER";
|
|
static const char *shader2DRect =
|
|
- "#extension GL_ARB_texture_rectangle : require\n"
|
|
- "varying mediump vec2 v_texCoord;\n"
|
|
- "uniform sampler2DRect s_texture;\n"
|
|
- "uniform lowp float alpha;\n"
|
|
- "void main() {\n"
|
|
- " lowp vec4 texColor = texture2DRect(s_texture, v_texCoord);\n"
|
|
- " gl_FragColor = texColor * alpha;\n"
|
|
- "}";
|
|
+ R"SHADER(#version 150 core
|
|
+in vec2 v_texCoord;
|
|
+uniform sampler2D s_texture;
|
|
+uniform float alpha;
|
|
+out vec4 fragColor;
|
|
+void main() {
|
|
+ vec4 texColor = texture(s_texture, v_texCoord);
|
|
+ fragColor = texColor * alpha;
|
|
+}
|
|
+ )SHADER";
|
|
if (m_target == ExternalTarget)
|
|
return shaderExternal;
|
|
else
|
|
diff --git a/qtwebengine/src/core/yuv_video_node.cpp b/qtwebengine/src/core/yuv_video_node.cpp
|
|
index 4a436d95..dc4b6ff9 100644
|
|
--- a/qtwebengine/src/core/yuv_video_node.cpp
|
|
+++ b/qtwebengine/src/core/yuv_video_node.cpp
|
|
@@ -59,39 +59,41 @@ public:
|
|
YUVVideoMaterialShader(const gfx::ColorSpace &colorSpace)
|
|
{
|
|
static const char *shaderHead =
|
|
- "varying mediump vec2 v_yaTexCoord;\n"
|
|
- "varying mediump vec2 v_uvTexCoord;\n"
|
|
- "uniform sampler2D y_texture;\n"
|
|
- "uniform sampler2D u_texture;\n"
|
|
- "uniform sampler2D v_texture;\n"
|
|
- "uniform mediump float alpha;\n"
|
|
- "uniform mediump vec4 ya_clamp_rect;\n"
|
|
- "uniform mediump vec4 uv_clamp_rect;\n";
|
|
- static const char *shader =
|
|
- "void main() {\n"
|
|
- " mediump vec2 ya_clamped =\n"
|
|
- " max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord));\n"
|
|
- " mediump float y_raw = texture2D(y_texture, ya_clamped).x;\n"
|
|
- " mediump vec2 uv_clamped =\n"
|
|
- " max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord));\n"
|
|
- " mediump float u_unsigned = texture2D(u_texture, uv_clamped).x;\n"
|
|
- " mediump float v_unsigned = texture2D(v_texture, uv_clamped).x;\n"
|
|
- " mediump vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned);\n"
|
|
- " mediump vec3 rgb = DoColorConversion(yuv);\n"
|
|
- " gl_FragColor = vec4(rgb, 1.0) * alpha;\n"
|
|
- "}";
|
|
+ R"SHADER(#version 150 core
|
|
+in vec2 v_yaTexCoord;
|
|
+in vec2 v_uvTexCoord;
|
|
+uniform sampler2D y_texture;
|
|
+uniform sampler2D u_texture;
|
|
+uniform sampler2D v_texture;
|
|
+uniform float alpha;
|
|
+uniform vec4 ya_clamp_rect;
|
|
+uniform vec4 uv_clamp_rect;
|
|
+out vec4 fragColor;
|
|
+ )SHADER";
|
|
+
|
|
+ static const char *shader = R"SHADER(
|
|
+void main() {
|
|
+ vec2 ya_clamped =
|
|
+ max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord));
|
|
+ float y_raw = texture(y_texture, ya_clamped).x;
|
|
+ vec2 uv_clamped =
|
|
+ max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord));
|
|
+ float u_unsigned = texture(u_texture, uv_clamped).x;
|
|
+ float v_unsigned = texture(v_texture, uv_clamped).x;
|
|
+ vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned);
|
|
+ vec3 rgb = DoColorConversion(yuv);
|
|
+ fragColor = vec4(rgb, 1.0) * alpha;
|
|
+}
|
|
+ )SHADER";
|
|
+
|
|
// Invalid or unspecified color spaces should be treated as REC709.
|
|
gfx::ColorSpace src = colorSpace.IsValid() ? colorSpace : gfx::ColorSpace::CreateREC709();
|
|
gfx::ColorSpace dst = gfx::ColorSpace::CreateSRGB();
|
|
std::unique_ptr<gfx::ColorTransform> transform =
|
|
gfx::ColorTransform::NewColorTransform(src, dst, gfx::ColorTransform::Intent::INTENT_PERCEPTUAL);
|
|
|
|
- QByteArray header(shaderHead);
|
|
- if (QOpenGLContext::currentContext()->isOpenGLES())
|
|
- header = QByteArray("precision mediump float;\n") + header;
|
|
-
|
|
m_csShader = QByteArray::fromStdString(transform->GetShaderSource());
|
|
- m_fragmentShader = header + m_csShader + QByteArray(shader);
|
|
+ m_fragmentShader = QByteArray(shaderHead) + m_csShader + QByteArray(shader);
|
|
}
|
|
void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
|
|
|
|
@@ -108,20 +110,22 @@ protected:
|
|
const char *vertexShader() const override {
|
|
// Keep in sync with logic in VertexShader in components/viz/service/display/shader.cc
|
|
const char *shader =
|
|
- "attribute highp vec4 a_position;\n"
|
|
- "attribute mediump vec2 a_texCoord;\n"
|
|
- "uniform highp mat4 matrix;\n"
|
|
- "varying mediump vec2 v_yaTexCoord;\n"
|
|
- "varying mediump vec2 v_uvTexCoord;\n"
|
|
- "uniform mediump vec2 yaTexScale;\n"
|
|
- "uniform mediump vec2 yaTexOffset;\n"
|
|
- "uniform mediump vec2 uvTexScale;\n"
|
|
- "uniform mediump vec2 uvTexOffset;\n"
|
|
- "void main() {\n"
|
|
- " gl_Position = matrix * a_position;\n"
|
|
- " v_yaTexCoord = a_texCoord * yaTexScale + yaTexOffset;\n"
|
|
- " v_uvTexCoord = a_texCoord * uvTexScale + uvTexOffset;\n"
|
|
- "}";
|
|
+ R"SHADER(#version 150 core
|
|
+in vec4 a_position;
|
|
+in vec2 a_texCoord;
|
|
+uniform mat4 matrix;
|
|
+out vec2 v_yaTexCoord;
|
|
+out vec2 v_uvTexCoord;
|
|
+uniform vec2 yaTexScale;
|
|
+uniform vec2 yaTexOffset;
|
|
+uniform vec2 uvTexScale;
|
|
+uniform vec2 uvTexOffset;
|
|
+void main() {
|
|
+ gl_Position = matrix * a_position;
|
|
+ v_yaTexCoord = a_texCoord * yaTexScale + yaTexOffset;
|
|
+ v_uvTexCoord = a_texCoord * uvTexScale + uvTexOffset;
|
|
+}
|
|
+ )SHADER";
|
|
return shader;
|
|
}
|
|
|
|
@@ -168,33 +172,35 @@ public:
|
|
YUVAVideoMaterialShader(const gfx::ColorSpace &colorSpace) : YUVVideoMaterialShader(colorSpace)
|
|
{
|
|
static const char *shaderHead =
|
|
- "varying mediump vec2 v_yaTexCoord;\n"
|
|
- "varying mediump vec2 v_uvTexCoord;\n"
|
|
- "uniform sampler2D y_texture;\n"
|
|
- "uniform sampler2D u_texture;\n"
|
|
- "uniform sampler2D v_texture;\n"
|
|
- "uniform sampler2D a_texture;\n"
|
|
- "uniform mediump float alpha;\n"
|
|
- "uniform mediump vec4 ya_clamp_rect;\n"
|
|
- "uniform mediump vec4 uv_clamp_rect;\n";
|
|
+ R"SHADER(#version 150 core
|
|
+in vec2 v_yaTexCoord;
|
|
+in vec2 v_uvTexCoord;
|
|
+uniform sampler2D y_texture;
|
|
+uniform sampler2D u_texture;
|
|
+uniform sampler2D v_texture;
|
|
+uniform sampler2D a_texture;
|
|
+uniform float alpha;
|
|
+uniform vec4 ya_clamp_rect;
|
|
+uniform vec4 uv_clamp_rect;
|
|
+out vec4 fragColor;
|
|
+ )SHADER";
|
|
static const char *shader =
|
|
- "void main() {\n"
|
|
- " mediump vec2 ya_clamped =\n"
|
|
- " max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord));\n"
|
|
- " mediump float y_raw = texture2D(y_texture, ya_clamped).x;\n"
|
|
- " mediump vec2 uv_clamped =\n"
|
|
- " max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord));\n"
|
|
- " mediump float u_unsigned = texture2D(u_texture, uv_clamped).x;\n"
|
|
- " mediump float v_unsigned = texture2D(v_texture, uv_clamped).x;\n"
|
|
- " mediump float a_raw = texture2D(a_texture, ya_clamped).x;\n"
|
|
- " mediump vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned);\n"
|
|
- " mediump vec3 rgb = DoColorConversion(yuv);\n"
|
|
- " gl_FragColor = vec4(rgb, 1.0) * (alpha * a_raw);\n"
|
|
- "}";
|
|
- QByteArray header(shaderHead);
|
|
- if (QOpenGLContext::currentContext()->isOpenGLES())
|
|
- header = QByteArray("precision mediump float;\n") + header;
|
|
- m_fragmentShader = header + m_csShader + QByteArray(shader);
|
|
+ R"SHADER(
|
|
+void main() {
|
|
+ vec2 ya_clamped =
|
|
+ max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord));
|
|
+ float y_raw = texture(y_texture, ya_clamped).x;
|
|
+ vec2 uv_clamped =
|
|
+ max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord));
|
|
+ float u_unsigned = texture(u_texture, uv_clamped).x;
|
|
+ float v_unsigned = texture(v_texture, uv_clamped).x;
|
|
+ float a_raw = texture(a_texture, ya_clamped).x;
|
|
+ vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned);
|
|
+ vec3 rgb = DoColorConversion(yuv);
|
|
+ fragColor = vec4(rgb, 1.0) * (alpha * a_raw);
|
|
+}
|
|
+ )SHADER";
|
|
+ m_fragmentShader = QByteArray(shaderHead) + m_csShader + QByteArray(shader);
|
|
}
|
|
void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
|
|
|