diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/multimedia/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/multimedia/shaders/abgr.frag | 17 | ||||
-rw-r--r-- | src/multimedia/shaders/argb.frag (renamed from src/multimedia/shaders/rgba.frag) | 3 | ||||
-rw-r--r-- | src/multimedia/shaders/bgra.frag | 3 | ||||
-rw-r--r-- | src/multimedia/shaders/rgb.vert (renamed from src/multimedia/shaders/rgba.vert) | 1 | ||||
-rw-r--r-- | src/multimedia/video/qvideotexturehelper.cpp | 20 |
6 files changed, 35 insertions, 16 deletions
diff --git a/src/multimedia/CMakeLists.txt b/src/multimedia/CMakeLists.txt index ff924771b..6cf4a6e6d 100644 --- a/src/multimedia/CMakeLists.txt +++ b/src/multimedia/CMakeLists.txt @@ -476,13 +476,14 @@ qt_internal_add_shaders(Multimedia "shaders" PREFIX "/qt-project.org/multimedia/shaders" FILES + "shaders/rgb.vert" + "shaders/abgr.frag" + "shaders/argb.frag" "shaders/bgra.frag" + "shaders/yuv.vert" "shaders/nv12.frag" "shaders/nv21.frag" - "shaders/rgba.frag" - "shaders/rgba.vert" "shaders/uyvy.frag" - "shaders/yuv.vert" "shaders/yuv_yv.frag" "shaders/yuyv.frag" "shaders/ayuv.frag" diff --git a/src/multimedia/shaders/abgr.frag b/src/multimedia/shaders/abgr.frag new file mode 100644 index 000000000..207993584 --- /dev/null +++ b/src/multimedia/shaders/abgr.frag @@ -0,0 +1,17 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 matrix; + mat4 colorMatrix; + float opacity; +} ubuf; + +layout(binding = 1) uniform sampler2D rgbTexture; + +void main() +{ + fragColor = texture(rgbTexture, qt_TexCoord).bgra * ubuf.colorMatrix * ubuf.opacity; +} diff --git a/src/multimedia/shaders/rgba.frag b/src/multimedia/shaders/argb.frag index 1623c2cc7..1fd7d1bdf 100644 --- a/src/multimedia/shaders/rgba.frag +++ b/src/multimedia/shaders/argb.frag @@ -5,6 +5,7 @@ layout(location = 0) out vec4 fragColor; layout(std140, binding = 0) uniform buf { mat4 matrix; + mat4 colorMatrix; float opacity; } ubuf; @@ -12,5 +13,5 @@ layout(binding = 1) uniform sampler2D rgbTexture; void main() { - fragColor = texture(rgbTexture, qt_TexCoord) * ubuf.opacity; + fragColor = texture(rgbTexture, qt_TexCoord) * ubuf.colorMatrix * ubuf.opacity; } diff --git a/src/multimedia/shaders/bgra.frag b/src/multimedia/shaders/bgra.frag index f04e3e721..c63908c42 100644 --- a/src/multimedia/shaders/bgra.frag +++ b/src/multimedia/shaders/bgra.frag @@ -5,6 +5,7 @@ layout(location = 0) out vec4 fragColor; layout(std140, binding = 0) uniform buf { mat4 matrix; + mat4 colorMatrix; float opacity; } ubuf; @@ -12,5 +13,5 @@ layout(binding = 1) uniform sampler2D rgbTexture; void main() { - fragColor = texture(rgbTexture, qt_TexCoord).bgra * ubuf.opacity; + fragColor = texture(rgbTexture, qt_TexCoord).grab * ubuf.colorMatrix * ubuf.opacity; } diff --git a/src/multimedia/shaders/rgba.vert b/src/multimedia/shaders/rgb.vert index ebc53a65f..db88cb0b8 100644 --- a/src/multimedia/shaders/rgba.vert +++ b/src/multimedia/shaders/rgb.vert @@ -7,6 +7,7 @@ layout(location = 0) out vec2 qt_TexCoord; layout(std140, binding = 0) uniform buf { mat4 matrix; + mat4 colorMatrix; float opacity; } ubuf; diff --git a/src/multimedia/video/qvideotexturehelper.cpp b/src/multimedia/video/qvideotexturehelper.cpp index e57e2f615..b9db64c5f 100644 --- a/src/multimedia/video/qvideotexturehelper.cpp +++ b/src/multimedia/video/qvideotexturehelper.cpp @@ -234,7 +234,7 @@ QString vertexShaderFileName(QVideoSurfaceFormat::PixelFormat format) case QVideoSurfaceFormat::Format_BGRA32_Premultiplied: case QVideoSurfaceFormat::Format_ABGR32: case QVideoSurfaceFormat::Format_BGR32: - return QStringLiteral(":/qt-project.org/multimedia/shaders/rgba.vert.qsb"); + return QStringLiteral(":/qt-project.org/multimedia/shaders/rgb.vert.qsb"); case QVideoSurfaceFormat::Format_YUV420P: case QVideoSurfaceFormat::Format_YUV422P: case QVideoSurfaceFormat::Format_YV12: @@ -273,11 +273,13 @@ QString fragmentShaderFileName(QVideoSurfaceFormat::PixelFormat format) case QVideoSurfaceFormat::Format_ARGB32: case QVideoSurfaceFormat::Format_ARGB32_Premultiplied: case QVideoSurfaceFormat::Format_RGB32: + return QStringLiteral(":/qt-project.org/multimedia/shaders/argb.frag.qsb"); case QVideoSurfaceFormat::Format_BGRA32: case QVideoSurfaceFormat::Format_BGRA32_Premultiplied: + return QStringLiteral(":/qt-project.org/multimedia/shaders/bgra.frag.qsb"); case QVideoSurfaceFormat::Format_ABGR32: case QVideoSurfaceFormat::Format_BGR32: - return QStringLiteral(":/qt-project.org/multimedia/shaders/rgba.frag.qsb"); + return QStringLiteral(":/qt-project.org/multimedia/shaders/abgr.frag.qsb"); case QVideoSurfaceFormat::Format_YUV420P: case QVideoSurfaceFormat::Format_YUV422P: case QVideoSurfaceFormat::Format_YV12: @@ -324,6 +326,7 @@ static QMatrix4x4 colorMatrix(QVideoSurfaceFormat::YCbCrColorSpace colorSpace) QByteArray uniformData(const QVideoSurfaceFormat &format, const QMatrix4x4 &transform, float opacity) { + QMatrix4x4 cmat; switch (format.pixelFormat()) { case QVideoSurfaceFormat::Format_Invalid: case QVideoSurfaceFormat::Format_Jpeg: @@ -347,14 +350,8 @@ QByteArray uniformData(const QVideoSurfaceFormat &format, const QMatrix4x4 &tran case QVideoSurfaceFormat::Format_BGRA32: case QVideoSurfaceFormat::Format_BGRA32_Premultiplied: case QVideoSurfaceFormat::Format_ABGR32: - case QVideoSurfaceFormat::Format_BGR32: { - // { matrix4x4, opacity } - QByteArray buf(16*4 + 4, Qt::Uninitialized); - char *data = buf.data(); - memcpy(data, transform.constData(), 64); - memcpy(data + 64, &opacity, 4); - return buf; - } + case QVideoSurfaceFormat::Format_BGR32: + break; case QVideoSurfaceFormat::Format_AYUV444: case QVideoSurfaceFormat::Format_AYUV444_Premultiplied: case QVideoSurfaceFormat::Format_YUV420P: @@ -366,13 +363,14 @@ QByteArray uniformData(const QVideoSurfaceFormat &format, const QMatrix4x4 &tran case QVideoSurfaceFormat::Format_NV21: case QVideoSurfaceFormat::Format_P010: case QVideoSurfaceFormat::Format_P016: + cmat = colorMatrix(format.yCbCrColorSpace()); break; } // { matrix4x4, colorMatrix, opacity, planeWidth[3] } QByteArray buf(64*2 + 4, Qt::Uninitialized); char *data = buf.data(); memcpy(data, transform.constData(), 64); - memcpy(data + 64, colorMatrix(format.yCbCrColorSpace()).constData(), 64); + memcpy(data + 64, cmat.constData(), 64); memcpy(data + 64 + 64, &opacity, 4); return buf; } |