diff options
Diffstat (limited to 'src/plugins/symbian/videooutput')
15 files changed, 1982 insertions, 0 deletions
diff --git a/src/plugins/symbian/videooutput/s60videodisplay.cpp b/src/plugins/symbian/videooutput/s60videodisplay.cpp new file mode 100644 index 000000000..35e234e98 --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videodisplay.cpp @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videodisplay.h" +#include <QtGui/QApplication> +#include <QtGui/QDesktopWidget> +#include <coecntrl.h> +#include <w32std.h> + +S60VideoDisplay::S60VideoDisplay(QObject *parent) +: QObject(parent) +, m_fullScreen(false) +, m_visible(true) +, m_aspectRatioMode(Qt::KeepAspectRatio) +, m_paintingEnabled(false) +, m_rotation(0.0f) +{ + connect(this, SIGNAL(displayRectChanged(QRect, QRect)), + this, SLOT(updateContentRect())); + connect(this, SIGNAL(nativeSizeChanged(QSize)), + this, SLOT(updateContentRect())); +} + +S60VideoDisplay::~S60VideoDisplay() +{ + +} + +RWindow *S60VideoDisplay::windowHandle() const +{ + return winId() ? static_cast<RWindow *>(winId()->DrawableWindow()) : 0; +} + +QRect S60VideoDisplay::clipRect() const +{ + QRect displayableRect; +#ifdef VIDEOOUTPUT_GRAPHICS_SURFACES + if (RWindow *window = windowHandle()) + displayableRect = QRect(0, 0, window->Size().iWidth, window->Size().iHeight); +#else + displayableRect = QApplication::desktop()->screenGeometry(); +#endif + return extentRect().intersected(displayableRect); +} + +QRect S60VideoDisplay::contentRect() const +{ + return m_contentRect; +} + +void S60VideoDisplay::setFullScreen(bool enabled) +{ + if (m_fullScreen != enabled) { + m_fullScreen = enabled; + emit fullScreenChanged(m_fullScreen); + } +} + +bool S60VideoDisplay::isFullScreen() const +{ + return m_fullScreen; +} + +void S60VideoDisplay::setVisible(bool enabled) +{ + if (m_visible != enabled) { + m_visible = enabled; + emit visibilityChanged(m_visible); + } +} + +bool S60VideoDisplay::isVisible() const +{ + return m_visible; +} + +void S60VideoDisplay::setAspectRatioMode(Qt::AspectRatioMode mode) +{ + if (m_aspectRatioMode != mode) { + m_aspectRatioMode = mode; + emit aspectRatioModeChanged(m_aspectRatioMode); + } +} + +Qt::AspectRatioMode S60VideoDisplay::aspectRatioMode() const +{ + return m_aspectRatioMode; +} + +void S60VideoDisplay::setNativeSize(const QSize &size) +{ + if (m_nativeSize != size) { + m_nativeSize = size; + emit nativeSizeChanged(m_nativeSize); + } +} + +const QSize& S60VideoDisplay::nativeSize() const +{ + return m_nativeSize; +} + +void S60VideoDisplay::setPaintingEnabled(bool enabled) +{ + if (m_paintingEnabled != enabled) { + m_paintingEnabled = enabled; + emit paintingEnabledChanged(m_paintingEnabled); + } +} + +bool S60VideoDisplay::isPaintingEnabled() const +{ + return m_paintingEnabled; +} + +void S60VideoDisplay::setRotation(qreal value) +{ + if (value != m_rotation) { + m_rotation = value; + emit rotationChanged(m_rotation); + } +} + +qreal S60VideoDisplay::rotation() const +{ + return m_rotation; +} + +void S60VideoDisplay::updateContentRect() +{ + if (isPaintingEnabled()) { + const int dx = qMax(0, extentRect().width() - nativeSize().width()); + const int dy = qMax(0, extentRect().height() - nativeSize().height()); + QRect contentRect(QPoint(dx/2, dy/2), nativeSize()); + if (m_contentRect != contentRect) { + m_contentRect = contentRect; + emit contentRectChanged(m_contentRect); + } + } +} + diff --git a/src/plugins/symbian/videooutput/s60videodisplay.h b/src/plugins/symbian/videooutput/s60videodisplay.h new file mode 100644 index 000000000..e16e7bb71 --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videodisplay.h @@ -0,0 +1,188 @@ +/** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEODISPLAY_H +#define S60VIDEODISPLAY_H + +#include <QtCore/QMetaType> +#include <QtCore/QObject> +#include <QtCore/QRect> +#include <QtCore/QSize> +#include <QtGui/qwindowdefs.h> + +class CFbsBitmap; +class RWindow; + +QT_USE_NAMESPACE + +/* + * This class defines a common API used by Symbian camera and mediaplayer + * backends to render to on-screen video outputs, i.e. implementations of + * QVideoWidgetControl and QVideoWindowControl. + */ +class S60VideoDisplay : public QObject +{ + Q_OBJECT +public: + S60VideoDisplay(QObject *parent); + virtual ~S60VideoDisplay(); + + /* + * Returns native Symbian handle of the window to be used for rendering + */ + RWindow *windowHandle() const; + + /* + * Returns Qt WId (CCoeControl* on Symbian) + */ + virtual WId winId() const = 0; + + /* + * Returns video display rectangle + * + * This is the rectangle which includes both the video content itself, plus + * any border bars which added around the video. The aspect ratio of this + * rectangle therefore may differ from that of the nativeSize(). + * + * If running on a platform supporting video rendering to graphics + * surfaces (i.e. if VIDEOOUTPUT_GRAPHICS_SURFACES is defined), the return + * value is the relative to the origin of the video window. Otherwise, the + * return value is an absolute screen rectangle. + * + * Note that this rectangle can extend beyond the bounds of the screen or of + * the video window. + * + * When using QVideoWindowControl, the size of the extentRect matches the + * displayRect; if running on a platform which supports only DSA rendering, + * the origin differs as described above. + * + * See also clipRect, contentRect + */ + virtual QRect extentRect() const = 0; + + /* + * Returns video clipping rectangle + * + * This rectangle is the intersection of displayRect() with either the window + * rectangle (on platforms supporting video rendering to graphics surfaces), + * or the screen rectangle (on platforms supporting only DSA video rendering). + * + * If running on a platform supporting video rendering to graphics + * surfaces (i.e. if VIDEOOUTPUT_GRAPHICS_SURFACES is defined), the return + * value is the relative to the origin of the video window. Otherwise, the + * return value is an absolute screen rectangle. + * + * See also extentRect, contentRect + */ + QRect clipRect() const; + + /* + * Returns video content rectangle + * + * This is the rectangle in which the video content is rendered, i.e. its + * size is that of extentRect() minus border bars. The aspect ratio of this + * rectangle is therefore equal to that of the nativeSize(). + * + * This rectangle is always relative to the window in which video is rendered. + * + * See also extentRect, clipRect + */ + QRect contentRect() const; + + void setFullScreen(bool enabled); + bool isFullScreen() const; + + void setVisible(bool visible); + bool isVisible() const; + + void setAspectRatioMode(Qt::AspectRatioMode mode); + Qt::AspectRatioMode aspectRatioMode() const; + + const QSize& nativeSize() const; + + void setPaintingEnabled(bool enabled); + bool isPaintingEnabled() const; + + void setRotation(qreal value); + qreal rotation() const; + +public slots: + void setNativeSize(const QSize &size); + + /* + * Provide new video frame + * + * If setPaintingEnabled(true) has been called, the frame is rendered to + * the display. + * + * If a QWidget is available to the control (i.e. the control is a + * QVideoWidgetControl), the frame is rendered via QPainter. Otherwise, the + * frame is blitted to the window using native Symbian drawing APIs. + */ + virtual void setFrame(const CFbsBitmap &bitmap) = 0; + +signals: + void windowHandleChanged(RWindow *); + void displayRectChanged(QRect extentRect, QRect clipRect); + void fullScreenChanged(bool); + void visibilityChanged(bool); + void aspectRatioModeChanged(Qt::AspectRatioMode); + void nativeSizeChanged(QSize); + void contentRectChanged(QRect); + void paintingEnabledChanged(bool); + void rotationChanged(qreal); + void beginVideoWindowNativePaint(); + void endVideoWindowNativePaint(); + +private slots: + void updateContentRect(); + +private: + QRect m_contentRect; + bool m_fullScreen; + bool m_visible; + Qt::AspectRatioMode m_aspectRatioMode; + QSize m_nativeSize; + bool m_paintingEnabled; + qreal m_rotation; +}; + +#endif // S60VIDEODISPLAY_H + diff --git a/src/plugins/symbian/videooutput/s60videooutpututils.cpp b/src/plugins/symbian/videooutput/s60videooutpututils.cpp new file mode 100644 index 000000000..feac346d1 --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videooutpututils.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videooutpututils.h" + +#ifdef PRIVATE_QTGUI_HEADERS_AVAILABLE +#if QT_VERSION >= 0x040601 && !defined(__WINSCW__) +#include <QtGui/private/qt_s60_p.h> +#include <QtGui/private/qwidget_p.h> +#define USE_PRIVATE_QTGUI_APIS +#endif // QT_VERSION >= 0x040601 && !defined(__WINSCW__) +#endif // PRIVATE_QTGUI_HEADERS_AVAILABLE + +namespace S60VideoOutputUtils +{ + +void setIgnoreFocusChanged(QWidget *widget) +{ +#ifdef USE_PRIVATE_QTGUI_APIS + // Warning: if this flag is not set, the application may crash due to + // CGraphicsContext being called from within the context of + // QGraphicsVideoItem::paint(), when the video widget is shown. + static_cast<QSymbianControl *>(widget->winId())->setIgnoreFocusChanged(true); +#else + Q_UNUSED(widget) +#endif +} + +void setNativePaintMode(QWidget *widget, NativePaintMode mode) +{ +#ifdef USE_PRIVATE_QTGUI_APIS + QWidgetPrivate *widgetPrivate = qt_widget_private(widget->window()); + widgetPrivate->createExtra(); + QWExtra::NativePaintMode widgetMode = QWExtra::Default; + switch (mode) { + case Default: + break; + case ZeroFill: + widgetMode = QWExtra::ZeroFill; + break; + case BlitWriteAlpha: +#if QT_VERSION >= 0x040704 + widgetMode = QWExtra::BlitWriteAlpha; +#endif + break; + case Disable: + widgetMode = QWExtra::Disable; + break; + } + widgetPrivate->extraData()->nativePaintMode = widgetMode; +#else + Q_UNUSED(widget) + Q_UNUSED(mode) +#endif +} + +void setNativePaintMode(WId wid, NativePaintMode mode) +{ +#ifdef USE_PRIVATE_QTGUI_APIS + QWidget *window = static_cast<QSymbianControl *>(wid)->widget()->window(); + setNativePaintMode(window, mode); +#else + Q_UNUSED(wid) + Q_UNUSED(mode) +#endif +} + +void setReceiveNativePaintEvents(QWidget *widget, bool enabled) +{ +#ifdef USE_PRIVATE_QTGUI_APIS + QWidgetPrivate *widgetPrivate = qt_widget_private(widget); + widgetPrivate->createExtra(); + widgetPrivate->extraData()->receiveNativePaintEvents = enabled; +#else + Q_UNUSED(widget) + Q_UNUSED(enabled) +#endif +} + +} // namespace S60VideoOutputUtils + diff --git a/src/plugins/symbian/videooutput/s60videooutpututils.h b/src/plugins/symbian/videooutput/s60videooutpututils.h new file mode 100644 index 000000000..6d83062c3 --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videooutpututils.h @@ -0,0 +1,71 @@ +/** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOOUTPUTUTILS_H +#define S60VIDEOOUTPUTUTILS_H + +#include <QtCore/qglobal.h> +#include <QtGui/qwindowdefs.h> + +QT_FORWARD_DECLARE_CLASS(QWidget) + +/* + * Helper functions used by video output. + */ +namespace S60VideoOutputUtils +{ + +enum NativePaintMode +{ + Default, + ZeroFill, + BlitWriteAlpha, + Disable +}; + +void setIgnoreFocusChanged(QWidget *widget); +void setNativePaintMode(QWidget *widget, NativePaintMode mode); +void setNativePaintMode(WId wid, NativePaintMode mode); +void setReceiveNativePaintEvents(QWidget *widget, bool enabled); + +} // namespace S60VideoOutputUtils + +#endif // S60VIDEOOUTPUTUTILS_H + diff --git a/src/plugins/symbian/videooutput/s60videowidget.cpp b/src/plugins/symbian/videooutput/s60videowidget.cpp new file mode 100644 index 000000000..44c0919ba --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videowidget.cpp @@ -0,0 +1,237 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videowidget.h" +#include "s60videooutpututils.h" + +#include <QtCore/QVariant> +#include <QtCore/QEvent> +#include <QtGui/QApplication> +#include <QtGui/QPainter> + +#include <coemain.h> // CCoeEnv +#include <coecntrl.h> // CCoeControl +#include <w32std.h> + +using namespace S60VideoOutputUtils; + +const int NullOrdinalPosition = -1; + +S60VideoWidget::S60VideoWidget(QWidget *parent) +: QWidget(parent) +, m_pixmap(NULL) +, m_paintingEnabled(false) +, m_topWinId(0) +, m_ordinalPosition(NullOrdinalPosition) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setPalette(QPalette(Qt::black)); + setAutoFillBackground(false); + if (!parent) + setProperty("_q_DummyWindowSurface", true); + S60VideoOutputUtils::setIgnoreFocusChanged(this); +} + +S60VideoWidget::~S60VideoWidget() +{ + +} + +bool S60VideoWidget::event(QEvent *event) +{ + if (event->type() == QEvent::WinIdChange) + updateOrdinalPosition(); + return QWidget::event(event); +} + +void S60VideoWidget::paintEvent(QPaintEvent *event) +{ + if (m_paintingEnabled && m_pixmap) { + QPainter painter(this); + if (m_pixmap->size() != m_contentRect.size()) + qWarning("pixmap size does not match expected value"); + painter.drawPixmap(m_contentRect.topLeft(), *m_pixmap); + } +} + +void S60VideoWidget::setVisible(bool visible) +{ + queueReactivateWindow(); + QWidget::setVisible(visible); +} + + +WId S60VideoWidget::videoWinId() const +{ + WId wid = 0; + if (internalWinId()) + wid = internalWinId(); + else if (parentWidget() && effectiveWinId()) + wid = effectiveWinId(); + return wid; +} + +void S60VideoWidget::setPixmap(const QPixmap *pixmap) +{ + m_pixmap = pixmap; + update(); +} + +void S60VideoWidget::setContentRect(const QRect &rect) +{ + if (m_contentRect != rect) { + m_contentRect = rect; + update(); + } +} + +void S60VideoWidget::setWindowBackgroundColor() +{ + if (WId wid = internalWinId()) + static_cast<RWindow *>(wid->DrawableWindow())->SetBackgroundColor(TRgb(0, 0, 0, 255)); +} + +WId S60VideoWidget::topWinId() const +{ + return m_topWinId; +} + +void S60VideoWidget::setTopWinId(WId id) +{ + m_topWinId = id; + updateOrdinalPosition(); +#ifdef VIDEOOUTPUT_GRAPHICS_SURFACES + // This function may be called from a paint event, so defer any window + // manipulation until painting is complete. + QMetaObject::invokeMethod(this, "setWindowsNonFading", Qt::QueuedConnection); +#endif +} + +void S60VideoWidget::setOrdinalPosition(int ordinalPosition) +{ + m_ordinalPosition = ordinalPosition; + updateOrdinalPosition(); +} + +int S60VideoWidget::ordinalPosition() const +{ + return m_ordinalPosition; +} + +void S60VideoWidget::updateOrdinalPosition() +{ + if ((m_ordinalPosition != NullOrdinalPosition) && m_topWinId) { + if (WId wid = videoWinId()) { + int topOrdinalPosition = m_topWinId->DrawableWindow()->OrdinalPosition(); + queueReactivateWindow(); + wid->DrawableWindow()->SetOrdinalPosition(m_ordinalPosition + topOrdinalPosition); + } + } +} + +void S60VideoWidget::queueReactivateWindow() +{ + if (!parent()) { + if (QWidget *activeWindow = QApplication::activeWindow()) + QMetaObject::invokeMethod(this, "reactivateWindow", Qt::QueuedConnection, + Q_ARG(QWidget *, activeWindow)); + } +} + +void S60VideoWidget::reactivateWindow(QWidget *widget) +{ + widget->activateWindow(); +} + +void S60VideoWidget::setWindowsNonFading() +{ + winId()->DrawableWindow()->SetNonFading(ETrue); + if (m_topWinId) + m_topWinId->DrawableWindow()->SetNonFading(ETrue); +} + +void S60VideoWidget::beginNativePaintEvent(const QRect &rect) +{ + Q_UNUSED(rect) + emit beginVideoWidgetNativePaint(); +} + +void S60VideoWidget::endNativePaintEvent(const QRect &rect) +{ + Q_UNUSED(rect) + CCoeEnv::Static()->WsSession().Flush(); + emit endVideoWidgetNativePaint(); +} + +void S60VideoWidget::setPaintingEnabled(bool enabled) +{ + if (enabled) { +#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES + setAttribute(Qt::WA_OpaquePaintEvent, false); + setAttribute(Qt::WA_NoSystemBackground, false); + S60VideoOutputUtils::setReceiveNativePaintEvents(this, false); + S60VideoOutputUtils::setNativePaintMode(this, Default); +#else + S60VideoOutputUtils::setNativePaintMode(this, Default); +#endif // !VIDEOOUTPUT_GRAPHICS_SURFACES + } else { +#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + S60VideoOutputUtils::setReceiveNativePaintEvents(this, true); + S60VideoOutputUtils::setNativePaintMode(this, ZeroFill); +#else + S60VideoOutputUtils::setNativePaintMode(this, Disable); +#endif // !VIDEOOUTPUT_GRAPHICS_SURFACES + winId(); // Create native window handle + } + m_paintingEnabled = enabled; + setWindowBackgroundColor(); +} + +void S60VideoWidget::setFullScreen(bool enabled) +{ + if (enabled) + showFullScreen(); + else + showMaximized(); +} + diff --git a/src/plugins/symbian/videooutput/s60videowidget.h b/src/plugins/symbian/videooutput/s60videowidget.h new file mode 100644 index 000000000..30e7a3bd0 --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videowidget.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOWIDGET_H +#define S60VIDEOWIDGET_H + +#include <QtGui/QWidget> + +QT_USE_NAMESPACE + +class S60VideoWidget : public QWidget +{ + Q_OBJECT +public: + S60VideoWidget(QWidget *parent = 0); + ~S60VideoWidget(); + + // QWidget + bool event(QEvent *event); + void paintEvent(QPaintEvent *event); + void setVisible(bool visible); + + WId videoWinId() const; + void setPixmap(const QPixmap *pixmap); + void setWindowBackgroundColor(); + void setTopWinId(WId id); + WId topWinId() const; + void setOrdinalPosition(int ordinalPosition); + int ordinalPosition() const; + +public slots: + void beginNativePaintEvent(const QRect &rect); + void endNativePaintEvent(const QRect &rect); + void setPaintingEnabled(bool enabled); + void setFullScreen(bool enabled); + void setContentRect(const QRect &rect); + +signals: + void beginVideoWidgetNativePaint(); + void endVideoWidgetNativePaint(); + +private: + void updateOrdinalPosition(); + void queueReactivateWindow(); + +private slots: + void reactivateWindow(QWidget *window); + void setWindowsNonFading(); + +private: + const QPixmap *m_pixmap; + QRect m_contentRect; + bool m_paintingEnabled; + WId m_topWinId; + int m_ordinalPosition; +}; + +#endif // S60VIDEOWIDGET_H + diff --git a/src/plugins/symbian/videooutput/s60videowidgetcontrol.cpp b/src/plugins/symbian/videooutput/s60videowidgetcontrol.cpp new file mode 100644 index 000000000..46cb2963e --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videowidgetcontrol.cpp @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videowidgetcontrol.h" +#include "s60videowidgetdisplay.h" + +S60VideoWidgetControl::S60VideoWidgetControl(QObject *parent) +: QVideoWidgetControl(parent) +, m_display(new S60VideoWidgetDisplay(this)) +{ + connect(m_display, SIGNAL(nativeSizeChanged(QSize)), + this, SIGNAL(nativeSizeChanged())); +} + +S60VideoWidgetControl::~S60VideoWidgetControl() +{ + +} + +QWidget *S60VideoWidgetControl::videoWidget() +{ + return m_display->widget(); +} + +Qt::AspectRatioMode S60VideoWidgetControl::aspectRatioMode() const +{ + return m_display->aspectRatioMode(); +} + +void S60VideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode ratio) +{ + m_display->setAspectRatioMode(ratio); +} + +bool S60VideoWidgetControl::isFullScreen() const +{ + return m_display->isFullScreen(); +} + +void S60VideoWidgetControl::setFullScreen(bool fullScreen) +{ + m_display->setFullScreen(fullScreen); +} + +int S60VideoWidgetControl::brightness() const +{ + return 0; +} + +void S60VideoWidgetControl::setBrightness(int brightness) +{ + Q_UNUSED(brightness); +} + +int S60VideoWidgetControl::contrast() const +{ + return 0; +} + +void S60VideoWidgetControl::setContrast(int contrast) +{ + Q_UNUSED(contrast); +} + +int S60VideoWidgetControl::hue() const +{ + return 0; +} + +void S60VideoWidgetControl::setHue(int hue) +{ + Q_UNUSED(hue); +} + +int S60VideoWidgetControl::saturation() const +{ + return 0; +} + +void S60VideoWidgetControl::setSaturation(int saturation) +{ + Q_UNUSED(saturation); +} + +S60VideoWidgetDisplay *S60VideoWidgetControl::display() const +{ + return m_display; +} + +void S60VideoWidgetControl::setTopWinId(WId id) +{ + m_display->setTopWinId(id); +} + +WId S60VideoWidgetControl::topWinId() const +{ + return m_display->topWinId(); +} + +int S60VideoWidgetControl::ordinalPosition() const +{ + return m_display->ordinalPosition(); +} + +void S60VideoWidgetControl::setOrdinalPosition(int ordinalPosition) +{ + m_display->setOrdinalPosition(ordinalPosition); +} + +const QRect &S60VideoWidgetControl::extentRect() const +{ + return m_display->explicitExtentRect(); +} + +void S60VideoWidgetControl::setExtentRect(const QRect &rect) +{ + m_display->setExplicitExtentRect(rect); +} + +QSize S60VideoWidgetControl::nativeSize() const +{ + return m_display->nativeSize(); +} + +qreal S60VideoWidgetControl::rotation() const +{ + return m_display->rotation(); +} + +void S60VideoWidgetControl::setRotation(qreal value) +{ + m_display->setRotation(value); +} diff --git a/src/plugins/symbian/videooutput/s60videowidgetcontrol.h b/src/plugins/symbian/videooutput/s60videowidgetcontrol.h new file mode 100644 index 000000000..eb103b6b8 --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videowidgetcontrol.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOWIDGETCONTROL_H +#define S60VIDEOWIDGETCONTROL_H + +#include <qvideowidgetcontrol.h> + +QT_USE_NAMESPACE + +class S60VideoWidgetDisplay; + +class S60VideoWidgetControl : public QVideoWidgetControl +{ + Q_OBJECT + + /** + * WId of the topmost window in the application, used to calculate the + * absolute ordinal position of the video widget. + * This is used by the "window" implementation of QGraphicsVideoItem. + */ + Q_PROPERTY(WId topWinId READ topWinId WRITE setTopWinId) + + /** + * Ordinal position of the video widget, relative to the topmost window + * in the application. If both the topWinId property and the ordinalPosition + * property are set, the absolute ordinal position of the video widget is + * the sum of the topWinId ordinal position and the value of the + * ordinalPosition property. + * This is used by the "window" implementation of QGraphicsVideoItem. + */ + Q_PROPERTY(int ordinalPosition READ ordinalPosition WRITE setOrdinalPosition) + + /** + * Extent of the video, relative to this video widget. + * This is used by the "window" implementation of QGraphicsVideoItem. + */ + Q_PROPERTY(QRect extentRect READ extentRect WRITE setExtentRect) + + /** + * Native size of video. + * This is used by the "window" implementation of QGraphicsVideoItem. + */ + Q_PROPERTY(QSize nativeSize READ nativeSize) + + /** + * Rotation to be applied to video. + * Angle is measured in degrees, with positive values counter-clockwise. + * Zero is at 12 o'clock. + */ + Q_PROPERTY(qreal rotation READ rotation WRITE setRotation) + +public: + S60VideoWidgetControl(QObject *parent); + ~S60VideoWidgetControl(); + +public: + // QVideoWidgetControl + QWidget *videoWidget(); + Qt::AspectRatioMode aspectRatioMode() const; + void setAspectRatioMode(Qt::AspectRatioMode ratio); + bool isFullScreen() const; + void setFullScreen(bool fullScreen); + int brightness() const; + void setBrightness(int brightness); + int contrast() const; + void setContrast(int contrast); + int hue() const; + void setHue(int hue); + int saturation() const; + void setSaturation(int saturation); + + S60VideoWidgetDisplay *display() const; + + WId topWinId() const; + void setTopWinId(WId id); + int ordinalPosition() const; + void setOrdinalPosition(int ordinalPosition); + const QRect &extentRect() const; + void setExtentRect(const QRect &rect); + QSize nativeSize() const; + qreal rotation() const; + void setRotation(qreal value); + +signals: + void nativeSizeChanged(); + +private: + S60VideoWidgetDisplay *m_display; +}; + +#endif // S60VIDEOWIDGETCONTROL_H + diff --git a/src/plugins/symbian/videooutput/s60videowidgetdisplay.cpp b/src/plugins/symbian/videooutput/s60videowidgetdisplay.cpp new file mode 100644 index 000000000..de7440dbf --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videowidgetdisplay.cpp @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videowidget.h" +#include "s60videowidgetdisplay.h" +#include <QtCore/QEvent> +#include <QtCore/QVariant> +#include <fbs.h> +#include <w32std.h> + +S60VideoWidgetDisplay::S60VideoWidgetDisplay(QObject *parent) +: S60VideoDisplay(parent) +, m_widget(new S60VideoWidget) +{ + connect(this, SIGNAL(paintingEnabledChanged(bool)), m_widget, SLOT(setPaintingEnabled(bool))); + connect(this, SIGNAL(fullScreenChanged(bool)), m_widget, SLOT(setFullScreen(bool))); + connect(this, SIGNAL(contentRectChanged(const QRect&)), m_widget, SLOT(setContentRect(const QRect &))); +#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES + connect(m_widget, SIGNAL(beginVideoWidgetNativePaint()), this, SIGNAL(beginVideoWindowNativePaint())); + connect(m_widget, SIGNAL(endVideoWidgetNativePaint()), this, SIGNAL(endVideoWindowNativePaint())); +#endif + m_widget->installEventFilter(this); + m_widget->setPaintingEnabled(false); +} + +S60VideoWidgetDisplay::~S60VideoWidgetDisplay() +{ + // Notify observers that window is about to be destroyed + QScopedPointer<QWidget> widget(m_widget); + m_widget = 0; + emit windowHandleChanged(windowHandle()); + // Widget will be deleted by QScopedPointer +} + +bool S60VideoWidgetDisplay::eventFilter(QObject *object, QEvent *e) +{ + if (object == m_widget) { + switch (e->type()) { + case QEvent::ParentChange: + if (QWidget *parent = m_widget->parentWidget()) + parent->setProperty("_q_DummyWindowSurface", true); + break; + case QEvent::WinIdChange: + m_widget->setWindowBackgroundColor(); + emit windowHandleChanged(windowHandle()); + break; + case QEvent::Resize: + emit displayRectChanged(extentRect(), clipRect()); + break; +#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES + case QEvent::Move: + // TODO: this is insufficient - we also need to respond to changes in + // the position of ancestor widgets + emit displayRectChanged(extentRect(), clipRect()); + break; +#endif + case QEvent::Show: + emit windowHandleChanged(windowHandle()); + emit visibilityChanged(true); + break; + case QEvent::Hide: + emit visibilityChanged(false); + break; + default: + // Do nothing + break; + } + } + return false; +} + +WId S60VideoWidgetDisplay::winId() const +{ + return m_widget ? m_widget->videoWinId() : 0; +} + +QRect S60VideoWidgetDisplay::extentRect() const +{ + QRect rect; + if (const RWindow *window = windowHandle()) { + const TSize size = window ? window->Size() : TSize(); + if (m_explicitExtentRect.isValid()) + rect = m_explicitExtentRect; + else + rect = QRect(0, 0, size.iWidth, size.iHeight); +#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES + const TPoint pos = window ? window->AbsPosition() : TPoint(); + rect.moveTopLeft(QPoint(pos.iX, pos.iY)); +#endif + } + return rect; +} + +void S60VideoWidgetDisplay::setFrame(const CFbsBitmap &bitmap) +{ + m_pixmap = QPixmap::fromSymbianCFbsBitmap(const_cast<CFbsBitmap*>(&bitmap)); + m_widget->setPixmap(&m_pixmap); +} + +QWidget *S60VideoWidgetDisplay::widget() const +{ + return m_widget; +} + +void S60VideoWidgetDisplay::setTopWinId(WId id) +{ + m_widget->setTopWinId(id); +} + +WId S60VideoWidgetDisplay::topWinId() const +{ + return m_widget->topWinId(); +} + +void S60VideoWidgetDisplay::setOrdinalPosition(int ordinalPosition) +{ + m_widget->setOrdinalPosition(ordinalPosition); +} + +int S60VideoWidgetDisplay::ordinalPosition() const +{ + return m_widget->ordinalPosition(); +} + +const QRect &S60VideoWidgetDisplay::explicitExtentRect() const +{ + return m_explicitExtentRect; +} + +void S60VideoWidgetDisplay::setExplicitExtentRect(const QRect &rect) +{ + if (rect != m_explicitExtentRect) { + m_explicitExtentRect = rect; + emit displayRectChanged(extentRect(), clipRect()); + } +} diff --git a/src/plugins/symbian/videooutput/s60videowidgetdisplay.h b/src/plugins/symbian/videooutput/s60videowidgetdisplay.h new file mode 100644 index 000000000..d3d92d953 --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videowidgetdisplay.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOWIDGETDISPLAY_H +#define S60VIDEOWIDGETDISPLAY_H + +#include "s60videodisplay.h" +#include <QtGui/qwindowdefs.h> +#include <QtGui/QPixmap> + +class CFbsBitmap; +class S60VideoWidget; +class QWidget; + +QT_USE_NAMESPACE + +class S60VideoWidgetDisplay : public S60VideoDisplay +{ + Q_OBJECT +public: + S60VideoWidgetDisplay(QObject *parent); + ~S60VideoWidgetDisplay(); + + // QObject + bool eventFilter(QObject *object, QEvent *e); + + // S60VideoDisplay + WId winId() const; + QRect extentRect() const; + void setFrame(const CFbsBitmap &bitmap); + + QWidget *widget() const; + WId topWinId() const; + void setTopWinId(WId id); + void setOrdinalPosition(int ordinalPosition); + int ordinalPosition() const; + const QRect &explicitExtentRect() const; + void setExplicitExtentRect(const QRect &rect); + +private: + S60VideoWidget *m_widget; + QPixmap m_pixmap; + QRect m_explicitExtentRect; +}; + +#endif // S60VIDEOWIDGETDISPLAY_H + diff --git a/src/plugins/symbian/videooutput/s60videowindowcontrol.cpp b/src/plugins/symbian/videooutput/s60videowindowcontrol.cpp new file mode 100644 index 000000000..db33a5f32 --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videowindowcontrol.cpp @@ -0,0 +1,178 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videowindowcontrol.h" +#include "s60videowindowdisplay.h" + +S60VideoWindowControl::S60VideoWindowControl(QObject *parent) +: QVideoWindowControl(parent) +, m_display(new S60VideoWindowDisplay(this)) +{ + connect(m_display, SIGNAL(nativeSizeChanged(QSize)), + this, SIGNAL(nativeSizeChanged())); + connect(m_display, SIGNAL(fullScreenChanged(bool)), + this, SIGNAL(fullScreenChanged(bool))); +} + +S60VideoWindowControl::~S60VideoWindowControl() +{ + +} + +WId S60VideoWindowControl::winId() const +{ + return m_display->winId(); +} + +void S60VideoWindowControl::setWinId(WId id) +{ + m_display->setWinId(id); +} + +QRect S60VideoWindowControl::displayRect() const +{ + return m_display->displayRect(); +} + +void S60VideoWindowControl::setDisplayRect(const QRect &rect) +{ + m_display->setDisplayRect(rect); +} + +Qt::AspectRatioMode S60VideoWindowControl::aspectRatioMode() const +{ + return m_display->aspectRatioMode(); +} + +void S60VideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode ratio) +{ + m_display->setAspectRatioMode(ratio); +} + +QSize S60VideoWindowControl::customAspectRatio() const +{ + return QSize(); +} + +void S60VideoWindowControl::setCustomAspectRatio(const QSize &customRatio) +{ + Q_UNUSED(customRatio); +} + +void S60VideoWindowControl::repaint() +{ + m_display->repaint(); +} + +int S60VideoWindowControl::brightness() const +{ + return 0; +} + +void S60VideoWindowControl::setBrightness(int brightness) +{ + Q_UNUSED(brightness) +} + +int S60VideoWindowControl::contrast() const +{ + return 0; +} + +void S60VideoWindowControl::setContrast(int contrast) +{ + Q_UNUSED(contrast) +} + +int S60VideoWindowControl::hue() const +{ + return 0; +} + +void S60VideoWindowControl::setHue(int hue) +{ + Q_UNUSED(hue) +} + +int S60VideoWindowControl::saturation() const +{ + return 0; +} + +void S60VideoWindowControl::setSaturation(int saturation) +{ + Q_UNUSED(saturation) +} + +bool S60VideoWindowControl::isFullScreen() const +{ + return m_display->isFullScreen(); +} + +void S60VideoWindowControl::setFullScreen(bool fullScreen) +{ + m_display->setFullScreen(fullScreen); +} + +QSize S60VideoWindowControl::nativeSize() const +{ + return m_display->nativeSize(); +} + +void S60VideoWindowControl::refreshDisplay() +{ + m_display->refreshDisplay(); +} + +S60VideoWindowDisplay *S60VideoWindowControl::display() const +{ + return m_display; +} + +qreal S60VideoWindowControl::rotation() const +{ + return m_display->rotation(); +} + +void S60VideoWindowControl::setRotation(qreal value) +{ + m_display->setRotation(value); +} diff --git a/src/plugins/symbian/videooutput/s60videowindowcontrol.h b/src/plugins/symbian/videooutput/s60videowindowcontrol.h new file mode 100644 index 000000000..a62d29a13 --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videowindowcontrol.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOWINDOWCONTROL_H +#define S60VIDEOWINDOWCONTROL_H + +#include <qvideowindowcontrol.h> + +class S60VideoWindowDisplay; + +QT_USE_NAMESPACE + +class S60VideoWindowControl : public QVideoWindowControl +{ + Q_OBJECT + + /** + * Rotation to be applied to video. + * Angle is measured in degrees, with positive values counter-clockwise. + * Zero is at 12 o'clock. + */ + Q_PROPERTY(qreal rotation READ rotation WRITE setRotation) + +public: + S60VideoWindowControl(QObject *parent); + ~S60VideoWindowControl(); + +public: + // QVideoWindowControl + WId winId() const; + void setWinId(WId id); + QRect displayRect() const; + void setDisplayRect(const QRect &rect); + bool isFullScreen() const; + void setFullScreen(bool fullScreen); + void repaint(); + QSize nativeSize() const; + Qt::AspectRatioMode aspectRatioMode() const; + void setAspectRatioMode(Qt::AspectRatioMode mode); + QSize customAspectRatio() const; + void setCustomAspectRatio(const QSize &customRatio); + int brightness() const; + void setBrightness(int brightness); + int contrast() const; + void setContrast(int contrast); + int hue() const; + void setHue(int hue); + int saturation() const; + void setSaturation(int saturation); + + S60VideoWindowDisplay *display() const; + + qreal rotation() const; + void setRotation(qreal value); + +public slots: + void refreshDisplay(); + +private: + S60VideoWindowDisplay *m_display; +}; + +#endif // S60VIDEOWINDOWCONTROL_H + diff --git a/src/plugins/symbian/videooutput/s60videowindowdisplay.cpp b/src/plugins/symbian/videooutput/s60videowindowdisplay.cpp new file mode 100644 index 000000000..a8bdb8b4a --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videowindowdisplay.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videowindowdisplay.h" +#include "s60videooutpututils.h" +#include <QtCore/QVariant> +#include <coecntrl.h> +#include <w32std.h> + +using namespace S60VideoOutputUtils; + +S60VideoWindowDisplay::S60VideoWindowDisplay(QObject *parent) +: S60VideoDisplay(parent) +, m_winId(0) +, m_bitmap(0) +{ + parent->setProperty("colorKey", Qt::transparent); +} + +S60VideoWindowDisplay::~S60VideoWindowDisplay() +{ + +} + +WId S60VideoWindowDisplay::winId() const +{ + return m_winId; +} + +QRect S60VideoWindowDisplay::extentRect() const +{ + QRect rect = displayRect(); +#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES + if (RWindow *window = windowHandle()) { + const TPoint windowPos = window->AbsPosition(); + rect.translate(windowPos.iX, windowPos.iY); + } +#endif // VIDEOOUTPUT_GRAPHICS_SURFACES + return rect; +} + +void S60VideoWindowDisplay::setFrame(const CFbsBitmap &bitmap) +{ + m_bitmap = const_cast<CFbsBitmap*>(&bitmap); + if (m_winId) { + // Blit the bitmap into the native window owned by m_winId + CWindowGc &gc = m_winId->SystemGc(); + RWindow *window = windowHandle(); + gc.Activate(*window); + const QPoint offsetQ = displayRect().topLeft() + contentRect().topLeft(); + const TPoint offsetT(offsetQ.x(), offsetQ.y()); + const TRect winRect(offsetT, m_bitmap->SizeInPixels()); + window->BeginRedraw(winRect); + gc.BitBlt(offsetT, m_bitmap); + window->EndRedraw(); + gc.Deactivate(); + } +} + +void S60VideoWindowDisplay::setWinId(WId id) +{ + if (m_winId != id) { + m_winId = id; + if (m_winId) { + static_cast<RWindow *>(m_winId->DrawableWindow())->SetBackgroundColor(TRgb(0, 0, 0, 0)); +#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES + if (QSysInfo::s60Version() >= QSysInfo::SV_S60_5_0) + S60VideoOutputUtils::setNativePaintMode(m_winId, BlitWriteAlpha); +#endif // !VIDEOOUTPUT_GRAPHICS_SURFACES + } + emit windowHandleChanged(windowHandle()); + } +} + +void S60VideoWindowDisplay::setDisplayRect(const QRect &rect) +{ + if (m_displayRect != rect) { + // If QGraphicsVideoItem moves out of screen, display rect is invalidated + if (rect == QRect(QPoint(-1,-1), QSize(1,1))) + emit visibilityChanged(false); + else + emit visibilityChanged(true); + m_displayRect = rect; + emit displayRectChanged(extentRect(), clipRect()); + } +} + +QRect S60VideoWindowDisplay::displayRect() const +{ + return m_displayRect; +} + +void S60VideoWindowDisplay::repaint() +{ + // TODO +} + +void S60VideoWindowDisplay::refreshDisplay() +{ + emit displayRectChanged(extentRect(), clipRect()); +} + diff --git a/src/plugins/symbian/videooutput/s60videowindowdisplay.h b/src/plugins/symbian/videooutput/s60videowindowdisplay.h new file mode 100644 index 000000000..8e749dcf3 --- /dev/null +++ b/src/plugins/symbian/videooutput/s60videowindowdisplay.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOWINDOWDISPLAY_H +#define S60VIDEOWINDOWDISPLAY_H + +#include "s60videodisplay.h" + +QT_USE_NAMESPACE + +class S60VideoWindowDisplay : public S60VideoDisplay +{ +public: + S60VideoWindowDisplay(QObject *parent); + ~S60VideoWindowDisplay(); + + // S60VideoDisplay + WId winId() const; + QRect extentRect() const; + void setFrame(const CFbsBitmap &bitmap); + + void setWinId(WId id); + void setDisplayRect(const QRect &rect); + QRect displayRect() const; + void repaint(); + void refreshDisplay(); + +private: + WId m_winId; + QRect m_displayRect; + CFbsBitmap *m_bitmap; +}; + +#endif // S60VIDEOWINDOWDISPLAY_H + diff --git a/src/plugins/symbian/videooutput/videooutput.pri b/src/plugins/symbian/videooutput/videooutput.pri new file mode 100644 index 000000000..13aa7a0fc --- /dev/null +++ b/src/plugins/symbian/videooutput/videooutput.pri @@ -0,0 +1,37 @@ +INCLUDEPATH += $$PWD + +message("VideoOutput: using common implementation") + +contains(surfaces_s60_enabled, yes) { + message("VideoOutput: graphics surface rendering supported") + DEFINES += VIDEOOUTPUT_GRAPHICS_SURFACES +} else { + message("VideoOutput: no graphics surface rendering support - DSA only") +} + +exists($$[QT_INSTALL_HEADERS]/QtGui/private/qwidget_p.h) { + DEFINES += PRIVATE_QTGUI_HEADERS_AVAILABLE + message("VideoOutput: private QtGui headers are available") +} else { + message("VideoOutput: private QtGui headers not available - video and viewfinder may not be rendered correctly") +} + +HEADERS += $$PWD/s60videodisplay.h \ + $$PWD/s60videooutpututils.h \ + $$PWD/s60videowidget.h \ + $$PWD/s60videowidgetcontrol.h \ + $$PWD/s60videowidgetdisplay.h \ + $$PWD/s60videowindowcontrol.h \ + $$PWD/s60videowindowdisplay.h + +SOURCES += $$PWD/s60videodisplay.cpp \ + $$PWD/s60videooutpututils.cpp \ + $$PWD/s60videowidget.cpp \ + $$PWD/s60videowidgetcontrol.cpp \ + $$PWD/s60videowidgetdisplay.cpp \ + $$PWD/s60videowindowcontrol.cpp \ + $$PWD/s60videowindowdisplay.cpp + +LIBS *= -lcone +LIBS *= -lws32 + |