Commit 1a15c1a9 authored by Mansoor Chishtie's avatar Mansoor Chishtie Committed by The Qt Project
Browse files

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: default avatarJocelyn Turcotte <jocelyn.turcotte@digia.com>
Showing with 8 additions and 3 deletions
......@@ -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());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment