From: Caroline Chao Date: Fri, 19 Oct 2012 12:34:38 +0000 (+0200) Subject: Fix for QuickTime 7 media player backend X-Git-Tag: upstream/5.2.95+rc1~162 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8907cecc0dbe72deec3273f4800008b005c90544;p=platform%2Fupstream%2Fqtmultimedia.git Fix for QuickTime 7 media player backend Fix build on Mac 10.6 (32bits) Task-number: QTBUG-27179 Change-Id: If0b83605650966bf801b5fbb06d02c113d0b4214 Reviewed-by: Andy Nichols --- diff --git a/src/plugins/qt7/qt7movierenderer.mm b/src/plugins/qt7/qt7movierenderer.mm index 7fa36a5..f150829 100644 --- a/src/plugins/qt7/qt7movierenderer.mm +++ b/src/plugins/qt7/qt7movierenderer.mm @@ -55,6 +55,8 @@ #include #include +#include + QT_USE_NAMESPACE //#define USE_MAIN_MONITOR_COLOR_SPACE 1 diff --git a/src/plugins/qt7/qt7movieviewrenderer.h b/src/plugins/qt7/qt7movieviewrenderer.h index ade4929..00b658b 100644 --- a/src/plugins/qt7/qt7movieviewrenderer.h +++ b/src/plugins/qt7/qt7movieviewrenderer.h @@ -61,6 +61,8 @@ class QT7PlayerSession; class QT7PlayerService; class QGLWidget; class QGLFramebufferObject; +class QWindow; +class QOpenGLContext; class QT7MovieViewRenderer : public QT7VideoRendererControl { @@ -88,7 +90,8 @@ private: QSize m_nativeSize; QAbstractVideoSurface *m_surface; QVideoFrame m_currentFrame; - QGLWidget *m_glWidget; + QWindow *m_window; + QOpenGLContext *m_context; QGLFramebufferObject *m_fbo; CIContext *m_ciContext; diff --git a/src/plugins/qt7/qt7movieviewrenderer.mm b/src/plugins/qt7/qt7movieviewrenderer.mm index 4a15756..8578eb3 100644 --- a/src/plugins/qt7/qt7movieviewrenderer.mm +++ b/src/plugins/qt7/qt7movieviewrenderer.mm @@ -137,7 +137,7 @@ private: @interface HiddenQTMovieView : QTMovieView { @private - QWidget *m_window; + QWindow *m_window; QT7MovieViewRenderer *m_renderer; QReadWriteLock m_rendererLock; } @@ -160,10 +160,10 @@ private: QWriteLocker lock(&self->m_rendererLock); self->m_renderer = renderer; - self->m_window = new QWidget; - self->m_window->setWindowOpacity(0.0); - self->m_window->show(); - self->m_window->hide(); + self->m_window = new QWindow; + self->m_window->setOpacity(0.0); + self->m_window->setGeometry(0,0,1,1); + self->m_window->create(); [(NSView *)(self->m_window->winId()) addSubview:self]; [self setDrawRect:QRect(0,0,1,1)]; @@ -173,7 +173,7 @@ private: - (void) dealloc { - delete self->m_window; + self->m_window->deleteLater(); [super dealloc]; } @@ -273,7 +273,8 @@ QT7MovieViewRenderer::QT7MovieViewRenderer(QObject *parent) m_movie(0), m_movieView(0), m_surface(0), - m_glWidget(0), + m_window(0), + m_context(0), m_fbo(0), m_ciContext(0), m_pendingRenderEvent(false) @@ -289,7 +290,7 @@ QT7MovieViewRenderer::~QT7MovieViewRenderer() [(HiddenQTMovieView*)m_movieView release]; [m_ciContext release]; delete m_fbo; - delete m_glWidget; + delete m_window; } void QT7MovieViewRenderer::setupVideoOutput() @@ -364,24 +365,35 @@ QVideoFrame QT7MovieViewRenderer::convertCIImageToGLTexture(const QVideoFrame &f if (frame.handleType() != QAbstractVideoBuffer::CoreImageHandle) return QVideoFrame(); - if (!m_glWidget) { + if (!m_window) { QOpenGLContext *qGlContext = 0; if (m_surface) qGlContext = qobject_cast(m_surface->property("GLContext").value()); if (qGlContext) { - QGLContext *surfaceContext = QGLContext::fromOpenGLContext(qGlContext); - m_glWidget = new QGLWidget(); + m_window = new QWindow(); - QGLContext *context = new QGLContext(surfaceContext->format()); - m_glWidget->setContext(context, surfaceContext); + QSurfaceFormat format(qGlContext->format()); + + m_context = new QOpenGLContext(m_window); + m_context->setShareContext(qGlContext); + m_context->setFormat(format); + m_context->create(); + + m_window->setFormat(format); + m_window->setGeometry(0, 0, 1, 1); + m_window->setSurfaceType(QWindow::OpenGLSurface); + m_window->create(); } else { return QVideoFrame(); } } - m_glWidget->makeCurrent(); + if (!m_context) + return QVideoFrame(); + + m_context->makeCurrent(m_window); if (!m_fbo || m_fbo->size() != frame.size()) { delete m_fbo; @@ -414,6 +426,7 @@ QVideoFrame QT7MovieViewRenderer::convertCIImageToGLTexture(const QVideoFrame &f [m_ciContext drawImage:ciImg inRect:dRect fromRect:sRect]; } + p.endNativePainting(); QAbstractVideoBuffer *buffer = new TextureVideoBuffer(m_fbo->texture()); @@ -462,7 +475,6 @@ void QT7MovieViewRenderer::setSurface(QAbstractVideoSurface *surface) void QT7MovieViewRenderer::renderFrame(const QVideoFrame &frame) { - QMutexLocker locker(&m_mutex); m_currentFrame = frame;