From ffb3275775874a94a6882d5098ac963ad54c9bec Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Wed, 31 Mar 2010 10:40:42 +1000 Subject: Fixed incorrectly clipped video when rendered on QGLWidget Don't enable GL stencil/scissor test inside of native GL rendering block if it was not enabled by QPaintEngine (QGLWidget viewport case). Reviewed-by: Andrew den Exter --- src/multimedia/base/qpaintervideosurface.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/multimedia/base/qpaintervideosurface.cpp b/src/multimedia/base/qpaintervideosurface.cpp index b8028d8f..2fe941b 100644 --- a/src/multimedia/base/qpaintervideosurface.cpp +++ b/src/multimedia/base/qpaintervideosurface.cpp @@ -737,10 +737,15 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::paint( const QRectF &target, QPainter *painter, const QRectF &source) { if (m_frame.isValid()) { + bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); + bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); + painter->beginNativePainting(); - glEnable(GL_STENCIL_TEST); - glEnable(GL_SCISSOR_TEST); + if (stencilTestEnabled) + glEnable(GL_STENCIL_TEST); + if (scissorTestEnabled) + glEnable(GL_SCISSOR_TEST); const float txLeft = source.left() / m_frameSize.width(); const float txRight = source.right() / m_frameSize.width(); @@ -815,9 +820,6 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::paint( glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_FRAGMENT_PROGRAM_ARB); - glDisable(GL_STENCIL_TEST); - glDisable(GL_SCISSOR_TEST); - painter->endNativePainting(); } return QAbstractVideoSurface::NoError; @@ -1063,10 +1065,15 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::paint( const QRectF &target, QPainter *painter, const QRectF &source) { if (m_frame.isValid()) { + bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); + bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); + painter->beginNativePainting(); - glEnable(GL_STENCIL_TEST); - glEnable(GL_SCISSOR_TEST); + if (stencilTestEnabled) + glEnable(GL_STENCIL_TEST); + if (scissorTestEnabled) + glEnable(GL_SCISSOR_TEST); const int width = QGLContext::currentContext()->device()->width(); const int height = QGLContext::currentContext()->device()->height(); @@ -1158,9 +1165,6 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::paint( m_program.release(); - - glDisable(GL_SCISSOR_TEST); - glDisable(GL_STENCIL_TEST); painter->endNativePainting(); } return QAbstractVideoSurface::NoError; -- cgit v0.12