Skip to content

Commit

Permalink
gl/custom_shader: expose VideoRenderer.opengl()
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Mar 11, 2016
1 parent 850f10d commit 849f055
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 10 deletions.
5 changes: 3 additions & 2 deletions qml/QmlAV/QuickFBORenderer.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2015-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2015)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -56,6 +56,7 @@ class QuickFBORenderer : public QQuickFramebufferObject, public VideoRenderer
explicit QuickFBORenderer(QQuickItem *parent = 0);
VideoRendererId id() const Q_DECL_OVERRIDE;
bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE;
OpenGLVideo* opengl() const Q_DECL_OVERRIDE;

QObject *source() const;
void setSource(QObject *source);
Expand Down
9 changes: 7 additions & 2 deletions qml/QuickFBORenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2015-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2015)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -119,6 +119,11 @@ bool QuickFBORenderer::isSupported(VideoFormat::PixelFormat pixfmt) const
return OpenGLVideo::isSupported(pixfmt);
}

OpenGLVideo* QuickFBORenderer::opengl() const
{
return const_cast<OpenGLVideo*>(&d_func().glv);
}

bool QuickFBORenderer::receiveFrame(const VideoFrame &frame)
{
DPTR_D(QuickFBORenderer);
Expand Down
5 changes: 3 additions & 2 deletions src/QtAV/OpenGLRendererBase.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2014-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2014)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -47,6 +47,7 @@ class Q_AV_EXPORT OpenGLRendererBase : public VideoRenderer
public:
virtual ~OpenGLRendererBase();
bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE;
OpenGLVideo* opengl() const Q_DECL_OVERRIDE;
protected:
virtual bool receiveFrame(const VideoFrame& frame) Q_DECL_OVERRIDE;
//called in paintEvent before drawFrame() when required
Expand Down
2 changes: 1 addition & 1 deletion src/QtAV/VideoShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Q_AV_EXPORT VideoShader
* If return false (not implemented for example), fallback to call setUserUniformValue(name) for each userUniforms()
* Call program()->setUniformValue(...) here
*/
virtual bool setUserUniformValues() {return false;}
virtual void setUserUniformValues() {}
/*!
* \brief userSample
* The custom sampling function to replace texture2D()/texture() (replace %1 in shader).
Expand Down
10 changes: 9 additions & 1 deletion src/output/video/GraphicsItemRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,15 @@ void GraphicsItemRenderer::setOpenGL(bool o)
if (d.opengl == o)
return;
d.opengl = o;
emit openGLChanged();
Q_EMIT openGLChanged();
}

OpenGLVideo* GraphicsItemRenderer::opengl() const
{
#if QTAV_HAVE(OPENGL)
return const_cast<OpenGLVideo*>(&d_func().glv);
#endif
return NULL;
}

void GraphicsItemRenderer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Expand Down
9 changes: 7 additions & 2 deletions src/output/video/OpenGLRendererBase.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2014-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2014)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -69,6 +69,11 @@ bool OpenGLRendererBase::isSupported(VideoFormat::PixelFormat pixfmt) const
return OpenGLVideo::isSupported(pixfmt);
}

OpenGLVideo* OpenGLRendererBase::opengl() const
{
return const_cast<OpenGLVideo*>(&d_func().glv);
}

bool OpenGLRendererBase::receiveFrame(const VideoFrame& frame)
{
DPTR_D(OpenGLRendererBase);
Expand Down
2 changes: 2 additions & 0 deletions widgets/QtAVWidgets/GraphicsItemRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class Q_AVWIDGETS_EXPORT GraphicsItemRenderer : public GraphicsWidget, public QP
*/
bool isOpenGL() const;
void setOpenGL(bool o);

OpenGLVideo* opengl() const Q_DECL_OVERRIDE;
Q_SIGNALS:
void sourceAspectRatioChanged(qreal value) Q_DECL_OVERRIDE Q_DECL_FINAL;
void regionOfInterestChanged() Q_DECL_OVERRIDE;
Expand Down

0 comments on commit 849f055

Please sign in to comment.