summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMansoor Chishtie <mchishtie@blackberry.com>2014-03-03 13:58:12 -0600
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-04 16:53:56 +0100
commit1a15c1a9bd7ec912c3d4b40b85ed534adf568d0f (patch)
tree25d0129b63cc25c3b504e4ca81d3e87a05122e71 /src
parente85a581c518f11fcf9080ba356a4538a23f04212 (diff)
Add opacity control to video texture streaming
Modified fragment shader of StreamVideoMaterialShader class to support alpha. Added m_id_opacity member to the class and update it with state.opacity. Change-Id: I92173fac84c48862fb92f3a6338acf8c9bf91bc1 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/stream_video_node.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/stream_video_node.cpp b/src/core/stream_video_node.cpp
index 8f8723bd3..c46b14f1c 100644
--- a/src/core/stream_video_node.cpp
+++ b/src/core/stream_video_node.cpp
@@ -72,14 +72,15 @@ protected:
}
virtual const char *fragmentShader() const {
- // Keep in sync with cc::FragmentShaderOESImageExternal
+ // Keep in sync with cc::FragmentShaderRGBATexAlpha
static const char *shader =
"#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"
" vec4 texColor = texture2D(s_texture, v_texCoord);\n"
- " gl_FragColor = texColor;\n"
+ " gl_FragColor = texColor * alpha;\n"
"}";
return shader;
}
@@ -87,10 +88,12 @@ protected:
virtual void initialize() {
m_id_matrix = program()->uniformLocation("matrix");
m_id_sTexture = program()->uniformLocation("s_texture");
+ m_id_opacity = program()->uniformLocation("alpha");
}
int m_id_matrix;
int m_id_sTexture;
+ int m_id_opacity;
};
void StreamVideoMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
@@ -102,7 +105,9 @@ void StreamVideoMaterialShader::updateState(const RenderState &state, QSGMateria
mat->m_texture->bind();
- // TODO(mchishtie): handle state.opacity() when shader implements it
+ if (state.isOpacityDirty())
+ program()->setUniformValue(m_id_opacity, state.opacity());
+
if (state.isMatrixDirty())
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
}