diff options
author | Mansoor Chishtie <mchishtie@blackberry.com> | 2014-05-27 19:35:12 -0500 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-02 20:49:50 +0200 |
commit | 5e5a99fa374d4b83e548ada8c76fa191a27e4b51 (patch) | |
tree | 9ed2144ddc001fbbb7ca1964772b78bae015a61e /src/core/stream_video_node.cpp | |
parent | 65bf1a1334acce38983896241d3b211e1fa4659a (diff) |
Support EGLStream video streaming on QNX platform
On QNX platform, we implement video streaming via OpenGL
EGLStream streams. Changes were added to StreamVideo class
to support EGLStream objects. For non-QNX platforms, we
kept the StreamVideoNode class unchanged - assuming other
platforms will continue to support streaming via EGLImage
objects.
On QNX, cc::StreamVideoDrawQuad contains an
external OES texture that is associated with an
EGLStream. Before we draw with that texture, an
'acquire' is performed to grab latest video frame.
See EGL_KHR_stream specs from Khronos.
Change-Id: Ia3fe25e9047f475594a55591e3e11caa0eab1e6a
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src/core/stream_video_node.cpp')
-rw-r--r-- | src/core/stream_video_node.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/core/stream_video_node.cpp b/src/core/stream_video_node.cpp index c46b14f1c..a8d1f6fbe 100644 --- a/src/core/stream_video_node.cpp +++ b/src/core/stream_video_node.cpp @@ -47,7 +47,7 @@ class StreamVideoMaterialShader : public QSGMaterialShader public: virtual void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial); - virtual char const *const *attributeNames() const { + virtual char const *const *attributeNames() const Q_DECL_OVERRIDE { static const char *names[] = { "a_position", "a_texCoord", @@ -57,21 +57,22 @@ public: } protected: - virtual const char *vertexShader() const { + virtual const char *vertexShader() const Q_DECL_OVERRIDE { // Keep in sync with cc::VertexShaderVideoTransform 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 = a_texCoord;\n" + " v_texCoord = vec4(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)).xy;\n" "}"; return shader; } - virtual const char *fragmentShader() const { + virtual const char *fragmentShader() const Q_DECL_OVERRIDE { // Keep in sync with cc::FragmentShaderRGBATexAlpha static const char *shader = "#extension GL_OES_EGL_image_external : require\n" @@ -79,7 +80,7 @@ protected: "uniform samplerExternalOES s_texture;\n" "uniform lowp float alpha;\n" "void main() {\n" - " vec4 texColor = texture2D(s_texture, v_texCoord);\n" + " lowp vec4 texColor = texture2D(s_texture, v_texCoord);\n" " gl_FragColor = texColor * alpha;\n" "}"; return shader; @@ -88,10 +89,12 @@ protected: virtual void initialize() { m_id_matrix = program()->uniformLocation("matrix"); m_id_sTexture = program()->uniformLocation("s_texture"); + m_id_texMatrix = program()->uniformLocation("texMatrix"); m_id_opacity = program()->uniformLocation("alpha"); } int m_id_matrix; + int m_id_texMatrix; int m_id_sTexture; int m_id_opacity; }; @@ -110,6 +113,8 @@ void StreamVideoMaterialShader::updateState(const RenderState &state, QSGMateria if (state.isMatrixDirty()) program()->setUniformValue(m_id_matrix, state.combinedMatrix()); + + program()->setUniformValue(m_id_texMatrix, mat->m_texMatrix); } StreamVideoMaterial::StreamVideoMaterial(QSGTexture *texture) @@ -122,12 +127,6 @@ QSGMaterialShader *StreamVideoMaterial::createShader() const return new StreamVideoMaterialShader; } -int StreamVideoMaterial::compare(const QSGMaterial *other) const -{ - const StreamVideoMaterial *m = static_cast<const StreamVideoMaterial *>(other); - return (m_texture->textureId() - m->m_texture->textureId()); -} - StreamVideoNode::StreamVideoNode(QSGTexture *texture) : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) { @@ -141,3 +140,8 @@ void StreamVideoNode::setRect(const QRectF &rect) { QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 0, 1, 1)); } + +void StreamVideoNode::setTextureMatrix(const QMatrix4x4 &matrix) +{ + m_material->m_texMatrix = matrix; +} |