summaryrefslogtreecommitdiffstats
path: root/src/core/stream_video_node.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-28 10:58:35 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-28 12:26:52 +0000
commitb76be3dfc52ee7eb508e2837c9d83c8f79a5cb26 (patch)
treec4f5103ae55c7a8ae71f99ba2229cfd2fc63ae20 /src/core/stream_video_node.cpp
parent2cb021c2978d5d8ab5ba565f10d9eddc27c6347f (diff)
Support IOSurface frames
Support getting video as IOSurface frames on OS X. With Chromium 45 we only get IOSurface frame when using non-default command-line flags. Change-Id: Ibf5226db53fa6fb51112bec9061d701918798ddd Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'src/core/stream_video_node.cpp')
-rw-r--r--src/core/stream_video_node.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/core/stream_video_node.cpp b/src/core/stream_video_node.cpp
index 7481d49ed..fdae5fee2 100644
--- a/src/core/stream_video_node.cpp
+++ b/src/core/stream_video_node.cpp
@@ -43,6 +43,7 @@ namespace QtWebEngineCore {
class StreamVideoMaterialShader : public QSGMaterialShader
{
public:
+ StreamVideoMaterialShader(TextureTarget target) : m_target(target) { }
virtual void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
virtual char const *const *attributeNames() const Q_DECL_OVERRIDE {
@@ -57,7 +58,7 @@ public:
protected:
virtual const char *vertexShader() const Q_DECL_OVERRIDE {
// Keep in sync with cc::VertexShaderVideoTransform
- const char *shader =
+ static const char *shader =
"attribute highp vec4 a_position;\n"
"attribute mediump vec2 a_texCoord;\n"
"uniform highp mat4 matrix;\n"
@@ -72,7 +73,7 @@ protected:
virtual const char *fragmentShader() const Q_DECL_OVERRIDE {
// Keep in sync with cc::FragmentShaderRGBATexAlpha
- static const char *shader =
+ static const char *shaderExternal =
"#extension GL_OES_EGL_image_external : require\n"
"varying mediump vec2 v_texCoord;\n"
"uniform samplerExternalOES s_texture;\n"
@@ -81,7 +82,19 @@ protected:
" lowp vec4 texColor = texture2D(s_texture, v_texCoord);\n"
" gl_FragColor = texColor * alpha;\n"
"}";
- return 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"
+ "}";
+ if (m_target == ExternalTarget)
+ return shaderExternal;
+ else
+ return shader2DRect;
}
virtual void initialize() {
@@ -95,6 +108,7 @@ protected:
int m_id_texMatrix;
int m_id_sTexture;
int m_id_opacity;
+ TextureTarget m_target;
};
void StreamVideoMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
@@ -115,28 +129,33 @@ void StreamVideoMaterialShader::updateState(const RenderState &state, QSGMateria
program()->setUniformValue(m_id_texMatrix, mat->m_texMatrix);
}
-StreamVideoMaterial::StreamVideoMaterial(QSGTexture *texture)
+StreamVideoMaterial::StreamVideoMaterial(QSGTexture *texture, TextureTarget target)
: m_texture(texture)
+ , m_target(target)
{
}
QSGMaterialShader *StreamVideoMaterial::createShader() const
{
- return new StreamVideoMaterialShader;
+ return new StreamVideoMaterialShader(m_target);
}
-StreamVideoNode::StreamVideoNode(QSGTexture *texture)
+StreamVideoNode::StreamVideoNode(QSGTexture *texture, bool flip, TextureTarget target)
: m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
+ , m_flip(flip)
{
setGeometry(&m_geometry);
setFlag(QSGNode::OwnsMaterial);
- m_material = new StreamVideoMaterial(texture);
+ m_material = new StreamVideoMaterial(texture, target);
setMaterial(m_material);
}
void StreamVideoNode::setRect(const QRectF &rect)
{
- QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 0, 1, 1));
+ if (m_flip)
+ QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 1, 1, -1));
+ else
+ QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 0, 1, 1));
}
void StreamVideoNode::setTextureMatrix(const QMatrix4x4 &matrix)