diff options
Diffstat (limited to 'src/plugins')
117 files changed, 3947 insertions, 3021 deletions
diff --git a/src/plugins/accessible/compat/q3complexwidgets.cpp b/src/plugins/accessible/compat/q3complexwidgets.cpp index 9ff377d..4f77d52 100644 --- a/src/plugins/accessible/compat/q3complexwidgets.cpp +++ b/src/plugins/accessible/compat/q3complexwidgets.cpp @@ -274,7 +274,7 @@ QString Q3AccessibleTitleBar::text(Text t, int child) const return Q3TitleBar::tr("Contains commands to manipulate the window"); case 3: if (window && window->isMinimized()) - return Q3TitleBar::tr("Puts a minimized back to normal"); + return Q3TitleBar::tr("Puts a minimized window back to normal"); return Q3TitleBar::tr("Moves the window out of the way"); case 4: if (window && window->isMaximized()) diff --git a/src/plugins/accessible/widgets/main.cpp b/src/plugins/accessible/widgets/main.cpp index 667de88..9a9a778 100644 --- a/src/plugins/accessible/widgets/main.cpp +++ b/src/plugins/accessible/widgets/main.cpp @@ -234,8 +234,10 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec iface = new QAccessibleDisplay(widget, Grouping); } else if (classname == QLatin1String("QStatusBar")) { iface = new QAccessibleWidgetEx(widget, StatusBar); +#ifndef QT_NO_PROGRESSBAR } else if (classname == QLatin1String("QProgressBar")) { - iface = new QAccessibleDisplay(widget); + iface = new QAccessibleProgressBar(widget); +#endif } else if (classname == QLatin1String("QToolBar")) { iface = new QAccessibleWidgetEx(widget, ToolBar, widget->windowTitle()); #ifndef QT_NO_MENUBAR diff --git a/src/plugins/accessible/widgets/rangecontrols.cpp b/src/plugins/accessible/widgets/rangecontrols.cpp index cae56ea..e336c9d 100644 --- a/src/plugins/accessible/widgets/rangecontrols.cpp +++ b/src/plugins/accessible/widgets/rangecontrols.cpp @@ -799,7 +799,7 @@ int QAccessibleSlider::defaultAction(int /*child*/) const /*! \internal */ QString QAccessibleSlider::actionText(int /*action*/, Text /*t*/, int /*child*/) const { - return QString(QLatin1String("")); + return QLatin1String(""); } QAccessibleAbstractSlider::QAccessibleAbstractSlider(QWidget *w, Role r) diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 1aadd6c..aa51759 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -209,6 +209,62 @@ QAccessible::State QAccessibleButton::state(int child) const return state; } +int QAccessibleButton::actionCount() +{ + return 1; +} + +void QAccessibleButton::doAction(int actionIndex) +{ + switch (actionIndex) { + case 0: + button()->click(); + break; + } +} + +QString QAccessibleButton::description(int actionIndex) +{ + switch (actionIndex) { + case 0: + return QLatin1String("Clicks the button."); + default: + return QString(); + } +} + +QString QAccessibleButton::name(int actionIndex) +{ + switch (actionIndex) { + case 0: + return QLatin1String("Press"); + default: + return QString(); + } +} + +QString QAccessibleButton::localizedName(int actionIndex) +{ + switch (actionIndex) { + case 0: + return tr("Press"); + default: + return QString(); + } +} + +QStringList QAccessibleButton::keyBindings(int actionIndex) +{ + switch (actionIndex) { +#ifdef QT_NO_SHORTCUT + case 0: + return button()->shortcut().toString(); +#endif + default: + return QStringList(); + } +} + #ifndef QT_NO_TOOLBUTTON /*! \class QAccessibleToolButton @@ -756,6 +812,34 @@ void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex) #endif // QT_NO_LINEEDIT +#ifndef QT_NO_PROGRESSBAR +QAccessibleProgressBar::QAccessibleProgressBar(QWidget *o) + : QAccessibleDisplay(o) +{ + Q_ASSERT(progressBar()); +} + +QVariant QAccessibleProgressBar::currentValue() +{ + return progressBar()->value(); +} + +QVariant QAccessibleProgressBar::maximumValue() +{ + return progressBar()->maximum(); +} + +QVariant QAccessibleProgressBar::minimumValue() +{ + return progressBar()->minimum(); +} + +QProgressBar *QAccessibleProgressBar::progressBar() const +{ + return qobject_cast<QProgressBar *>(object()); +} +#endif + #endif // QT_NO_ACCESSIBILITY QT_END_NAMESPACE diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h index abe5bdc..0c1cf5e 100644 --- a/src/plugins/accessible/widgets/simplewidgets.h +++ b/src/plugins/accessible/widgets/simplewidgets.h @@ -42,6 +42,7 @@ #ifndef SIMPLEWIDGETS_H #define SIMPLEWIDGETS_H +#include <QtCore/qcoreapplication.h> #include <QtGui/qaccessible2.h> #include <QtGui/qaccessiblewidget.h> @@ -52,9 +53,12 @@ QT_BEGIN_NAMESPACE class QAbstractButton; class QLineEdit; class QToolButton; +class QProgressBar; -class QAccessibleButton : public QAccessibleWidgetEx +class QAccessibleButton : public QAccessibleWidgetEx, public QAccessibleActionInterface { + Q_ACCESSIBLE_OBJECT + Q_DECLARE_TR_FUNCTIONS(QAccessibleButton) public: QAccessibleButton(QWidget *w, Role r); @@ -64,6 +68,14 @@ public: QString actionText(int action, Text text, int child) const; bool doAction(int action, int child, const QVariantList ¶ms); + // QAccessibleActionInterface + int actionCount(); + void doAction(int actionIndex); + QString description(int actionIndex); + QString name(int actionIndex); + QString localizedName(int actionIndex); + QStringList keyBindings(int actionIndex); + protected: QAbstractButton *button() const; }; @@ -101,6 +113,7 @@ protected: class QAccessibleDisplay : public QAccessibleWidgetEx { + Q_ACCESSIBLE_OBJECT public: explicit QAccessibleDisplay(QWidget *w, Role role = StaticText); @@ -150,6 +163,24 @@ protected: }; #endif // QT_NO_LINEEDIT +#ifndef QT_NO_PROGRESSBAR +class QAccessibleProgressBar : public QAccessibleDisplay, public QAccessibleValueInterface +{ + Q_ACCESSIBLE_OBJECT +public: + explicit QAccessibleProgressBar(QWidget *o); + + // QAccessibleValueInterface + QVariant currentValue(); + QVariant maximumValue(); + QVariant minimumValue(); + inline void setCurrentValue(const QVariant &) {} + +protected: + QProgressBar *progressBar() const; +}; +#endif + #endif // QT_NO_ACCESSIBILITY QT_END_NAMESPACE diff --git a/src/plugins/audio/audio.pro b/src/plugins/audio/audio.pro new file mode 100644 index 0000000..e93b369 --- /dev/null +++ b/src/plugins/audio/audio.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +#SUBDIRS += ossaudio diff --git a/src/plugins/codecs/cn/cn.pro b/src/plugins/codecs/cn/cn.pro index a7b8b60..b0a8a91 100644 --- a/src/plugins/codecs/cn/cn.pro +++ b/src/plugins/codecs/cn/cn.pro @@ -12,3 +12,5 @@ SOURCES = qgb18030codec.cpp \ target.path += $$[QT_INSTALL_PLUGINS]/codecs INSTALLS += target + +symbian:TARGET.UID3=0x2001E615 diff --git a/src/plugins/codecs/jp/jp.pro b/src/plugins/codecs/jp/jp.pro index 8626912..6480e43 100644 --- a/src/plugins/codecs/jp/jp.pro +++ b/src/plugins/codecs/jp/jp.pro @@ -23,3 +23,5 @@ unix { target.path += $$[QT_INSTALL_PLUGINS]/codecs INSTALLS += target + +symbian:TARGET.UID3=0x2001E614 diff --git a/src/plugins/codecs/jp/qeucjpcodec.cpp b/src/plugins/codecs/jp/qeucjpcodec.cpp index bd3866a..93e3ca7 100644 --- a/src/plugins/codecs/jp/qeucjpcodec.cpp +++ b/src/plugins/codecs/jp/qeucjpcodec.cpp @@ -79,7 +79,6 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_TEXTCODEC -static const uchar Esc = 0x1b; static const uchar Ss2 = 0x8e; // Single Shift 2 static const uchar Ss3 = 0x8f; // Single Shift 3 diff --git a/src/plugins/codecs/kr/kr.pro b/src/plugins/codecs/kr/kr.pro index 9199e33..1cc28d8 100644 --- a/src/plugins/codecs/kr/kr.pro +++ b/src/plugins/codecs/kr/kr.pro @@ -16,3 +16,5 @@ wince*: { target.path += $$[QT_INSTALL_PLUGINS]/codecs INSTALLS += target + +symbian:TARGET.UID3=0x2001B2E5 diff --git a/src/plugins/codecs/kr/qeuckrcodec.cpp b/src/plugins/codecs/kr/qeuckrcodec.cpp index dd1ea5c..a912914 100644 --- a/src/plugins/codecs/kr/qeuckrcodec.cpp +++ b/src/plugins/codecs/kr/qeuckrcodec.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -// Most of the cp949 code was originally written by Joon-Kyu Park, and is included +// Most of the cp949 code was originally written by Joon-Kyu Park, and is included // in Qt with the author's permission and the grateful thanks of the Qt team. /*! \class QEucKrCodec diff --git a/src/plugins/codecs/tw/tw.pro b/src/plugins/codecs/tw/tw.pro index 8039f4b..2ebb94f 100644 --- a/src/plugins/codecs/tw/tw.pro +++ b/src/plugins/codecs/tw/tw.pro @@ -12,3 +12,5 @@ SOURCES = qbig5codec.cpp \ target.path += $$[QT_INSTALL_PLUGINS]/codecs INSTALLS += target + +symbian:TARGET.UID3=0x2001B2E4 diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index 5c60b2f..0706f01 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -1,44 +1,15 @@ TARGET = qdirectfbscreen include(../../qpluginbase.pri) +include($$QT_SOURCE_TREE/src/gui/embedded/directfb.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers -# These defines might be necessary if your DirectFB driver doesn't -# support all of the DirectFB API. -# -#DEFINES += QT_DIRECTFB_IMAGECACHE -#DEFINES += QT_NO_DIRECTFB_WM -#DEFINES += QT_NO_DIRECTFB_LAYER -#DEFINES += QT_NO_DIRECTFB_PALETTE -#DEFINES += QT_NO_DIRECTFB_PREALLOCATED -#DEFINES += QT_NO_DIRECTFB_MOUSE -#DEFINES += QT_NO_DIRECTFB_KEYBOARD -#DEFINES += QT_DIRECTFB_TIMING -#DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION -#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS -#DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" -#DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" - target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target -HEADERS = qdirectfbscreen.h \ - qdirectfbwindowsurface.h \ - qdirectfbpaintengine.h \ - qdirectfbpaintdevice.h \ - qdirectfbpixmap.h \ - qdirectfbkeyboard.h \ - qdirectfbmouse.h - -SOURCES = qdirectfbscreen.cpp \ - qdirectfbscreenplugin.cpp \ - qdirectfbwindowsurface.cpp \ - qdirectfbpaintengine.cpp \ - qdirectfbpaintdevice.cpp \ - qdirectfbpixmap.cpp \ - qdirectfbkeyboard.cpp \ - qdirectfbmouse.cpp +SOURCES += qdirectfbscreenplugin.cpp QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB LIBS += $$QT_LIBS_DIRECTFB -DEFINES += $$QT_DEFINES_DIRECTFB +DEFINES += $$QT_DEFINES_DIRECTFB QT_DIRECTFB_PLUGIN +contains(gfx-plugins, directfb):DEFINES += QT_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp index 3cf44af..da5c5a5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp @@ -41,7 +41,7 @@ #include "qdirectfbkeyboard.h" -#ifndef QT_NO_DIRECTFB +#ifndef QT_NO_QWS_DIRECTFB #include "qdirectfbscreen.h" #include <qobject.h> @@ -53,6 +53,8 @@ #include <fcntl.h> #include <errno.h> +QT_BEGIN_NAMESPACE + class KeyMap : public QHash<DFBInputDeviceKeySymbol, Qt::Key> { public: @@ -429,6 +431,6 @@ KeyMap::KeyMap() insert(DIKS_TILDE , Qt::Key_AsciiTilde); } +QT_END_NAMESPACE #include "qdirectfbkeyboard.moc" - -#endif // QT_NO_DIRECTFB +#endif // QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h index 94d7e2f..b41748e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h @@ -42,13 +42,16 @@ #ifndef QDIRECTFBKEYBOARD_H #define QDIRECTFBKEYBOARD_H +#include <qglobal.h> #include <QtGui/qkbd_qws.h> +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_HEADER -QT_MODULE(Gui) +QT_BEGIN_NAMESPACE -#ifndef QT_NO_DIRECTFB +QT_MODULE(Gui) class QDirectFBKeyboardHandlerPrivate; @@ -62,7 +65,9 @@ private: QDirectFBKeyboardHandlerPrivate *d; }; -#endif // QT_NO_DIRECTFB +QT_END_NAMESPACE + +#endif // QT_NO_QWS_DIRECTFB QT_END_HEADER diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp index 1ff3ca3..57b1950 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp @@ -41,6 +41,8 @@ #include "qdirectfbmouse.h" +#ifndef QT_NO_QWS_DIRECTFB + #include "qdirectfbscreen.h" #include <qsocketnotifier.h> @@ -49,6 +51,8 @@ #include <fcntl.h> #include <errno.h> +QT_BEGIN_NAMESPACE + class QDirectFBMouseHandlerPrivate : public QObject { Q_OBJECT @@ -117,8 +121,8 @@ QDirectFBMouseHandlerPrivate::QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler return; } - int flags = ::fcntl(fd, F_GETFL, 0); - ::fcntl(fd, F_SETFL, flags | O_NONBLOCK); + int flags = fcntl(fd, F_GETFL, 0); + fcntl(fd, F_SETFL, flags | O_NONBLOCK); // DirectFB seems to assume that the mouse always starts centered prevPoint = QPoint(screen->deviceWidth() / 2, screen->deviceHeight() / 2); @@ -203,6 +207,7 @@ void QDirectFBMouseHandlerPrivate::readMouseData() int wheel = 0; if (input.type == DIET_AXISMOTION) { +#if defined(QT_NO_DIRECTFB_LAYER) || defined(QT_DIRECTFB_WINDOW_AS_CURSOR) if (input.flags & DIEF_AXISABS) { switch (input.axis) { case DIAI_X: x = input.axisabs; break; @@ -222,6 +227,19 @@ void QDirectFBMouseHandlerPrivate::readMouseData() "unknown axis (releative) %d", input.axis); } } +#else + if (input.axis == DIAI_X || input.axis == DIAI_Y) { + DFBResult result = layer->GetCursorPosition(layer, &x, &y); + if (result != DFB_OK) { + DirectFBError("QDirectFBMouseHandler::readMouseData", + result); + } + } else if (input.axis == DIAI_Z) { + Q_ASSERT(input.flags & DIEF_AXISREL); + wheel = input.axisrel; + wheel *= -120; + } +#endif } Qt::MouseButtons buttons = Qt::NoButton; @@ -269,5 +287,8 @@ void QDirectFBMouseHandler::resume() d->setEnabled(true); } +QT_END_NAMESPACE #include "qdirectfbmouse.moc" +#endif // QT_NO_QWS_DIRECTFB + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h index eeab094..25790a3 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h @@ -42,13 +42,16 @@ #ifndef QDIRECTFBMOUSE_H #define QDIRECTFBMOUSE_H +#include <qglobal.h> #include <QtGui/qmouse_qws.h> +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_HEADER -QT_MODULE(Gui) +QT_BEGIN_NAMESPACE -#ifndef QT_NO_DIRECTFB +QT_MODULE(Gui) class QDirectFBMouseHandlerPrivate; @@ -65,8 +68,8 @@ protected: QDirectFBMouseHandlerPrivate *d; }; -#endif // QT_NO_DIRECTFB +QT_END_NAMESPACE QT_END_HEADER - +#endif // QT_NO_QWS_DIRECTFB #endif // QDIRECTFBMOUSE_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 9506fd0..cb4fb88 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -39,83 +39,113 @@ ** ****************************************************************************/ -#ifndef QT_NO_DIRECTFB - #include "qdirectfbscreen.h" #include "qdirectfbpaintdevice.h" #include "qdirectfbpaintengine.h" +#ifndef QT_NO_QWS_DIRECTFB + +QT_BEGIN_NAMESPACE + QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr) - : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr), - lock(DFBSurfaceLockFlags(0)), mem(0), engine(0) -{} + : QCustomRasterPaintDevice(0), dfbSurface(0), screen(scr), + bpl(-1), lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0), imageFormat(QImage::Format_Invalid) +{ +#ifdef QT_DIRECTFB_SUBSURFACE + subSurface = 0; + syncPending = false; +#endif +} QDirectFBPaintDevice::~QDirectFBPaintDevice() { - delete lockedImage; + if (QDirectFBScreen::instance()) { + unlockSurface(); +#ifdef QT_DIRECTFB_SUBSURFACE + releaseSubSurface(); +#endif + if (dfbSurface) { + screen->releaseDFBSurface(dfbSurface); + } + } delete engine; } - IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const { return dfbSurface; } - -void QDirectFBPaintDevice::lockDirectFB(DFBSurfaceLockFlags flags) +bool QDirectFBPaintDevice::lockSurface(DFBSurfaceLockFlags lockFlags) { - if (!(lock & flags)) { - if (lock) - unlockDirectFB(); - mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl); + if (lockFlgs && (lockFlags & ~lockFlgs)) + unlockSurface(); + if (!mem) { + Q_ASSERT(dfbSurface); +#ifdef QT_DIRECTFB_SUBSURFACE + if (!subSurface) { + DFBResult result; + subSurface = screen->getSubSurface(dfbSurface, QRect(), QDirectFBScreen::TrackSurface, &result); + if (result != DFB_OK || !subSurface) { + DirectFBError("Couldn't create sub surface", result); + return false; + } + } + IDirectFBSurface *surface = subSurface; +#else + IDirectFBSurface *surface = dfbSurface; +#endif + Q_ASSERT(surface); + mem = QDirectFBScreen::lockSurface(surface, lockFlags, &bpl); + lockFlgs = lockFlags; Q_ASSERT(mem); + Q_ASSERT(bpl > 0); const QSize s = size(); - lockedImage = new QImage(mem, s.width(), s.height(), bpl, - QDirectFBScreen::getImageFormat(dfbSurface)); - lock = flags; + lockedImage = QImage(mem, s.width(), s.height(), bpl, + QDirectFBScreen::getImageFormat(dfbSurface)); + return true; } +#ifdef QT_DIRECTFB_SUBSURFACE + if (syncPending) { + syncPending = false; + screen->waitIdle(); + } +#endif + return false; } - -void QDirectFBPaintDevice::unlockDirectFB() +void QDirectFBPaintDevice::unlockSurface() { - if (!lockedImage || !QDirectFBScreen::instance()) - return; - - dfbSurface->Unlock(dfbSurface); - delete lockedImage; - lockedImage = 0; - mem = 0; - lock = DFBSurfaceLockFlags(0); + if (QDirectFBScreen::instance() && lockFlgs) { +#ifdef QT_DIRECTFB_SUBSURFACE + IDirectFBSurface *surface = subSurface; +#else + IDirectFBSurface *surface = dfbSurface; +#endif + if (surface) { + surface->Unlock(surface); + lockFlgs = static_cast<DFBSurfaceLockFlags>(0); + mem = 0; + } + } } - void *QDirectFBPaintDevice::memory() const { return mem; } - QImage::Format QDirectFBPaintDevice::format() const { - return QDirectFBScreen::getImageFormat(dfbSurface); + return imageFormat; } - int QDirectFBPaintDevice::bytesPerLine() const { - if (bpl == -1) { - // Can only get the stride when we lock the surface - Q_ASSERT(!lockedImage); - QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this); - that->lockDirectFB(DSLF_READ); - Q_ASSERT(bpl != -1); - } + Q_ASSERT(!mem || bpl != -1); return bpl; } - QSize QDirectFBPaintDevice::size() const { int w, h; @@ -128,18 +158,14 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const if (!dfbSurface) return 0; - int w, h; - dfbSurface->GetSize(dfbSurface, &w, &h); - switch (metric) { case QPaintDevice::PdmWidth: - return w; case QPaintDevice::PdmHeight: - return h; + return (metric == PdmWidth ? size().width() : size().height()); case QPaintDevice::PdmWidthMM: - return (w * 1000) / dotsPerMeterX(); + return (size().width() * 1000) / dotsPerMeterX(); case QPaintDevice::PdmHeightMM: - return (h * 1000) / dotsPerMeterY(); + return (size().height() * 1000) / dotsPerMeterY(); case QPaintDevice::PdmPhysicalDpiX: case QPaintDevice::PdmDpiX: return (dotsPerMeterX() * 254) / 10000; // 0.0254 meters-per-inch @@ -147,12 +173,10 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const case QPaintDevice::PdmDpiY: return (dotsPerMeterY() * 254) / 10000; // 0.0254 meters-per-inch case QPaintDevice::PdmDepth: - DFBSurfacePixelFormat format; - dfbSurface->GetPixelFormat(dfbSurface, &format); - return QDirectFBScreen::depth(format); + return QDirectFBScreen::depth(imageFormat); case QPaintDevice::PdmNumColors: { - if (lockedImage) - return lockedImage->numColors(); + if (!lockedImage.isNull()) + return lockedImage.numColors(); DFBResult result; IDirectFBPalette *palette = 0; @@ -180,5 +204,18 @@ QPaintEngine *QDirectFBPaintDevice::paintEngine() const return engine; } +#ifdef QT_DIRECTFB_SUBSURFACE +void QDirectFBPaintDevice::releaseSubSurface() +{ + Q_ASSERT(QDirectFBScreen::instance()); + if (subSurface) { + unlockSurface(); + screen->releaseDFBSurface(subSurface); + subSurface = 0; + } +} #endif +QT_END_NAMESPACE + +#endif // QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index ad594a0..0b2d00c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -43,11 +43,14 @@ #define QDIRECTFBPAINTDEVICE_H #include <private/qpaintengine_raster_p.h> -#include <directfb.h> #include "qdirectfbscreen.h" +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) // Inherited by both window surface and pixmap @@ -57,10 +60,10 @@ class QDirectFBPaintDevice : public QCustomRasterPaintDevice public: ~QDirectFBPaintDevice(); - IDirectFBSurface *directFBSurface() const; + virtual IDirectFBSurface *directFBSurface() const; - void lockDirectFB(DFBSurfaceLockFlags lock); - void unlockDirectFB(); + bool lockSurface(DFBSurfaceLockFlags lockFlags); + void unlockSurface(); // Reimplemented from QCustomRasterPaintDevice: void *memory() const; @@ -68,9 +71,8 @@ public: int bytesPerLine() const; QSize size() const; int metric(QPaintDevice::PaintDeviceMetric metric) const; - DFBSurfaceLockFlags lockFlags() const { return lock; } + DFBSurfaceLockFlags lockFlags() const { return lockFlgs; } QPaintEngine *paintEngine() const; - protected: QDirectFBPaintDevice(QDirectFBScreen *scr); inline int dotsPerMeterX() const @@ -81,18 +83,26 @@ protected: { return (screen->deviceHeight() * 1000) / screen->physicalHeight(); } -protected: + IDirectFBSurface *dfbSurface; - QImage *lockedImage; +#ifdef QT_DIRECTFB_SUBSURFACE + void releaseSubSurface(); + IDirectFBSurface *subSurface; + friend class QDirectFBPaintEnginePrivate; + bool syncPending; +#endif + QImage lockedImage; QDirectFBScreen *screen; int bpl; - DFBSurfaceLockFlags lock; + DFBSurfaceLockFlags lockFlgs; uchar *mem; QDirectFBPaintEngine *engine; -private: - Q_DISABLE_COPY(QDirectFBPaintDevice); + QImage::Format imageFormat; }; +QT_END_NAMESPACE + QT_END_HEADER +#endif // QT_NO_QWS_DIRECTFB #endif //QDIRECTFBPAINTDEVICE_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 0101000..dd6b0d3 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -41,7 +41,7 @@ #include "qdirectfbpaintengine.h" -#ifndef QT_NO_DIRECTFB +#ifndef QT_NO_QWS_DIRECTFB #include "qdirectfbwindowsurface.h" #include "qdirectfbscreen.h" @@ -53,6 +53,9 @@ #include <qmath.h> #include <private/qpixmapdata_p.h> #include <private/qpixmap_raster_p.h> +#include <private/qimagepixmapcleanuphooks_p.h> + +QT_BEGIN_NAMESPACE class SurfaceCache; class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate @@ -90,6 +93,7 @@ public: inline void lock(); inline void unlock(); + static inline void unlock(QDirectFBPaintDevice *device); inline bool isSimpleBrush(const QBrush &brush) const; @@ -106,7 +110,7 @@ public: #endif void prepareForBlit(bool alpha); -private: + IDirectFBSurface *surface; bool antialiased; @@ -118,14 +122,14 @@ private: IDirectFB *fb; quint8 opacity; - bool dirtyClip; ClipType clipType; QDirectFBPaintDevice *dfbDevice; uint compositionModeStatus; - QDirectFBPaintEngine *q; + bool inClip; QRect currentClip; - friend class QDirectFBPaintEngine; + + QDirectFBPaintEngine *q; }; class SurfaceCache @@ -143,7 +147,9 @@ private: #ifdef QT_DIRECTFB_IMAGECACHE +QT_BEGIN_INCLUDE_NAMESPACE #include <private/qimage_p.h> +QT_END_INCLUDE_NAMESPACE struct CachedImage { IDirectFBSurface *surface; @@ -164,7 +170,8 @@ enum PaintOperation { DRAW_PIXMAP = 0x0008, DRAW_TILED_PIXMAP = 0x0010, STROKE_PATH = 0x0020, DRAW_PATH = 0x0040, DRAW_POINTS = 0x0080, DRAW_ELLIPSE = 0x0100, DRAW_POLYGON = 0x0200, DRAW_TEXT = 0x0400, FILL_PATH = 0x0800, - FILL_RECT = 0x1000, DRAW_COLORSPANS = 0x2000, ALL = 0xffff + FILL_RECT = 0x1000, DRAW_COLORSPANS = 0x2000, DRAW_ROUNDED_RECT = 0x4000, + ALL = 0xffff }; #endif @@ -216,6 +223,7 @@ template <class T> static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface); #define CLIPPED_PAINT(operation) { \ + d->unlock(); \ DFBRegion clipRegion; \ switch (d->clipType) { \ case QDirectFBPaintEnginePrivate::NoClip: \ @@ -235,7 +243,7 @@ static inline void drawRects(const T *rects, int n, const QTransform &transform, d->surface->SetClip(d->surface, &clipRegion); \ operation; \ } \ - d->dirtyClip = true; \ + d->updateClip(); \ break; } \ case QDirectFBPaintEnginePrivate::ComplexClip: \ case QDirectFBPaintEnginePrivate::ClipUnset: \ @@ -263,6 +271,7 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) QPixmapData *data = static_cast<QPixmap*>(device)->pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbPixmapData = static_cast<QDirectFBPixmapData*>(data); + QDirectFBPaintEnginePrivate::unlock(dfbPixmapData); d->dfbDevice = static_cast<QDirectFBPaintDevice*>(dfbPixmapData); } @@ -275,7 +284,9 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) } d->prepare(d->dfbDevice); + gccaps = AllFeatures; d->setCompositionMode(state()->composition_mode); + return QRasterPaintEngine::begin(device); } @@ -296,8 +307,8 @@ bool QDirectFBPaintEngine::end() void QDirectFBPaintEngine::clipEnabledChanged() { Q_D(QDirectFBPaintEngine); - d->dirtyClip = true; QRasterPaintEngine::clipEnabledChanged(); + d->updateClip(); } void QDirectFBPaintEngine::penChanged() @@ -340,26 +351,49 @@ void QDirectFBPaintEngine::setState(QPainterState *state) { Q_D(QDirectFBPaintEngine); QRasterPaintEngine::setState(state); - d->dirtyClip = true; d->setPen(state->pen); d->opacity = quint8(state->opacity * 255); d->setCompositionMode(state->compositionMode()); d->setTransform(state->transform()); d->setRenderHints(state->renderHints); + if (d->surface) + d->updateClip(); } void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); - d->dirtyClip = true; + const bool wasInClip = d->inClip; + d->inClip = true; QRasterPaintEngine::clip(path, op); + if (!wasInClip) { + d->inClip = false; + d->updateClip(); + } +} + +void QDirectFBPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) +{ + Q_D(QDirectFBPaintEngine); + const bool wasInClip = d->inClip; + d->inClip = true; + QRasterPaintEngine::clip(region, op); + if (!wasInClip) { + d->inClip = false; + d->updateClip(); + } } void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); - d->dirtyClip = true; + const bool wasInClip = d->inClip; + d->inClip = true; QRasterPaintEngine::clip(rect, op); + if (!wasInClip) { + d->inClip = false; + d->updateClip(); + } } void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) @@ -367,10 +401,9 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) Q_D(QDirectFBPaintEngine); const QPen &pen = state()->pen; const QBrush &brush = state()->brush; - if (brush == Qt::NoBrush && pen == Qt::NoPen) + if (brush.style() == Qt::NoBrush && pen.style() == Qt::NoPen) return; - d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || !d->simplePen @@ -381,14 +414,15 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) QRasterPaintEngine::drawRects(rects, rectCount); return; } - d->unlock(); - if (brush != Qt::NoBrush) { + + if (brush.style() != Qt::NoBrush) { d->setDFBColor(brush.color()); - CLIPPED_PAINT(::fillRects<QRect>(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(fillRects<QRect>)(rects, rectCount, state()->matrix, d->surface)); } - if (pen != Qt::NoPen) { + + if (pen.style() != Qt::NoPen) { d->setDFBColor(pen.color()); - CLIPPED_PAINT(::drawRects<QRect>(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects<QRect>)(rects, rectCount, state()->matrix, d->surface)); } } @@ -397,10 +431,9 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) Q_D(QDirectFBPaintEngine); const QPen &pen = state()->pen; const QBrush &brush = state()->brush; - if (brush == Qt::NoBrush && pen == Qt::NoPen) + if (brush.style() == Qt::NoBrush && pen.style() == Qt::NoPen) return; - d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || !d->simplePen @@ -411,21 +444,21 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) QRasterPaintEngine::drawRects(rects, rectCount); return; } - d->unlock(); - if (brush != Qt::NoBrush) { + + if (brush.style() != Qt::NoBrush) { d->setDFBColor(brush.color()); - CLIPPED_PAINT(::fillRects<QRectF>(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(fillRects<QRectF>(rects, rectCount, state()->matrix, d->surface)); } - if (pen != Qt::NoPen) { + + if (pen.style() != Qt::NoPen) { d->setDFBColor(pen.color()); - CLIPPED_PAINT(::drawRects<QRectF>(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects<QRectF>)(rects, rectCount, state()->matrix, d->surface)); } } void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) { Q_D(QDirectFBPaintEngine); - d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || !d->simplePen @@ -437,17 +470,15 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) } const QPen &pen = state()->pen; - if (pen != Qt::NoPen) { - d->unlock(); + if (pen.style() != Qt::NoPen) { d->setDFBColor(pen.color()); - CLIPPED_PAINT(::drawLines<QLine>(lines, lineCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines<QLine>)(lines, lineCount, state()->matrix, d->surface)); } } void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) { Q_D(QDirectFBPaintEngine); - d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || !d->simplePen @@ -459,10 +490,9 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) } const QPen &pen = state()->pen; - if (pen != Qt::NoPen) { - d->unlock(); + if (pen.style() != Qt::NoPen) { d->setDFBColor(pen.color()); - CLIPPED_PAINT(::drawLines<QLineF>(lines, lineCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines<QLineF>)(lines, lineCount, state()->matrix, d->surface)); } } @@ -490,7 +520,6 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, than the max image cache size we fall back to raster engine. */ - d->updateClip(); #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) @@ -509,10 +538,9 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, return; } #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE - d->unlock(); bool release; IDirectFBSurface *imgSurface = d->getSurface(image, &release); - d->prepareForBlit(QDirectFBScreen::hasAlpha(imgSurface)); + d->prepareForBlit(QDirectFBScreen::hasAlphaChannel(imgSurface)); CLIPPED_PAINT(d->blit(r, imgSurface, sr)); if (release) { #if (Q_DIRECTFB_VERSION >= 0x010000) @@ -533,28 +561,29 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, { Q_D(QDirectFBPaintEngine); - d->updateClip(); if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); - } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) - || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) { - RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); - const QImage *img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer(DSLF_READ); - d->lock(); - QRasterPaintEngine::drawImage(r, *img, sr); } else { - d->unlock(); - d->prepareForBlit(pixmap.hasAlphaChannel()); QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data); - dfbData->unlockDirectFB(); - IDirectFBSurface *s = dfbData->directFBSurface(); - - CLIPPED_PAINT(d->blit(r, s, sr)); + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip + || (state()->renderHints & QPainter::SmoothPixmapTransform + && state()->matrix.mapRect(r).size() != sr.size())) { + RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); + const QImage *img = dfbData->buffer(); + d->lock(); + QRasterPaintEngine::drawImage(r, *img, sr); + } else { + QDirectFBPaintEnginePrivate::unlock(dfbData); + d->prepareForBlit(pixmap.hasAlphaChannel()); + IDirectFBSurface *s = dfbData->directFBSurface(); + CLIPPED_PAINT(d->blit(r, s, sr)); + } } } @@ -568,24 +597,26 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, const QPointF &offset) { Q_D(QDirectFBPaintEngine); - d->updateClip(); if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); d->lock(); QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset); } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) { + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip + || (state()->renderHints & QPainter::SmoothPixmapTransform && state()->matrix.isScaling())) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); - const QImage *img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer(DSLF_READ); + QPixmapData *pixmapData = pixmap.pixmapData(); + Q_ASSERT(pixmapData->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(pixmapData); + const QImage *img = dfbData->buffer(); d->lock(); QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType); data->fromImage(*img, Qt::AutoColor); const QPixmap pix(data); QRasterPaintEngine::drawTiledPixmap(r, pix, offset); } else { - d->unlock(); - d->drawTiledPixmap(r, pixmap, offset); + CLIPPED_PAINT(d->drawTiledPixmap(r, pixmap, offset)); } } @@ -667,13 +698,19 @@ void QDirectFBPaintEngine::fill(const QVectorPath &path, const QBrush &brush) QRasterPaintEngine::fill(path, brush); } +void QDirectFBPaintEngine::drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode) +{ + RASTERFALLBACK(DRAW_ROUNDED_RECT, rect, xrad, yrad); + Q_D(QDirectFBPaintEngine); + d->lock(); + QRasterPaintEngine::drawRoundedRect(rect, xrad, yrad, mode); +} void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) { Q_D(QDirectFBPaintEngine); if (brush.style() == Qt::NoBrush) return; - d->updateClip(); if (d->clipType != QDirectFBPaintEnginePrivate::ComplexClip) { switch (brush.style()) { case Qt::SolidPattern: { @@ -684,7 +721,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) const QColor color = brush.color(); if (!color.isValid()) return; - d->unlock(); d->setDFBColor(color); const QRect r = state()->matrix.mapRect(rect).toRect(); CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height())); @@ -692,7 +728,8 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) case Qt::TexturePattern: { if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) - || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)) { + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) + || (state()->renderHints & QPainter::SmoothPixmapTransform && state()->matrix.isScaling())) { break; } @@ -700,7 +737,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) if (texture.pixmapData()->classId() != QPixmapData::DirectFBClass) break; - d->unlock(); CLIPPED_PAINT(d->drawTiledPixmap(rect, texture, rect.topLeft() - state()->brushOrigin)); return; } default: @@ -717,7 +753,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) if (!color.isValid()) return; Q_D(QDirectFBPaintEngine); - d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) { @@ -725,11 +760,9 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) d->lock(); QRasterPaintEngine::fillRect(rect, color); } else { - d->unlock(); d->setDFBColor(color); const QRect r = state()->matrix.mapRect(rect).toRect(); - d->surface->FillRectangle(d->surface, r.x(), r.y(), - r.width(), r.height()); + CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height())); } } @@ -754,9 +787,7 @@ void QDirectFBPaintEngine::initImageCache(int size) { Q_ASSERT(size >= 0); imageCache.setMaxCost(size); - typedef void (*_qt_image_cleanup_hook_64)(qint64); - extern Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64; - qt_image_cleanup_hook_64 = ::cachedImageCleanupHook; + QImagePixmapCleanupHooks::instance()->addImageHook(cachedImageCleanupHook); } #endif // QT_DIRECTFB_IMAGECACHE @@ -766,9 +797,9 @@ void QDirectFBPaintEngine::initImageCache(int size) QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) : surface(0), antialiased(false), simplePen(false), - transformationType(0), opacity(255), dirtyClip(true), + transformationType(0), opacity(255), clipType(ClipUnset), dfbDevice(0), - compositionModeStatus(0), q(p) + compositionModeStatus(0), inClip(false), q(p) { fb = QDirectFBScreen::instance()->dfb(); surfaceCache = new SurfaceCache; @@ -790,8 +821,7 @@ void QDirectFBPaintEnginePrivate::lock() // lock so we need to call the base implementation of prepare so // it updates its rasterBuffer to point to the new buffer address. Q_ASSERT(dfbDevice); - if (dfbDevice->lockFlags() != (DSLF_WRITE|DSLF_READ)) { - dfbDevice->lockDirectFB(DSLF_READ|DSLF_WRITE); + if (dfbDevice->lockSurface(DSLF_READ|DSLF_WRITE)) { prepare(dfbDevice); } } @@ -799,7 +829,21 @@ void QDirectFBPaintEnginePrivate::lock() void QDirectFBPaintEnginePrivate::unlock() { Q_ASSERT(dfbDevice); - dfbDevice->unlockDirectFB(); +#ifdef QT_DIRECTFB_SUBSURFACE + dfbDevice->syncPending = true; +#else + QDirectFBPaintEnginePrivate::unlock(dfbDevice); +#endif +} + +void QDirectFBPaintEnginePrivate::unlock(QDirectFBPaintDevice *device) +{ +#ifdef QT_NO_DIRECTFB_SUBSURFACE + Q_ASSERT(device); + device->unlockSurface(); +#else + Q_UNUSED(device); +#endif } void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform) @@ -830,6 +874,13 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m { if (!surface) return; + + static const bool forceRasterFallBack = qgetenv("QT_DIRECTFB_FORCE_RASTER").toInt() > 0; + if (forceRasterFallBack) { + compositionModeStatus = 0; + return; + } + compositionModeStatus = PorterDuff_SupportedBlits; switch (mode) { case QPainter::CompositionMode_Clear: @@ -867,10 +918,10 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m case QPainter::CompositionMode_Plus: surface->SetPorterDuff(surface, DSPD_ADD); break; -#endif case QPainter::CompositionMode_Xor: surface->SetPorterDuff(surface, DSPD_XOR); break; +#endif default: compositionModeStatus = 0; break; @@ -888,12 +939,12 @@ void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints) void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha) { - quint32 blittingFlags = alpha ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; + DFBSurfaceBlittingFlags blittingFlags = alpha ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; if (opacity != 255) { blittingFlags |= DSBLIT_BLEND_COLORALPHA; } surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); - surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blittingFlags)); + surface->SetBlittingFlags(surface, blittingFlags); } static inline uint ALPHA_MUL(uint x, uint a) @@ -915,9 +966,9 @@ void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, bool *release) { -#ifndef QT_DIRECTFB_IMAGECACHE +#ifdef QT_NO_DIRECTFB_IMAGECACHE *release = true; - return QDirectFBScreen::instance()->createDFBSurface(img, QDirectFBScreen::DontTrackSurface); + return QDirectFBScreen::instance()->createDFBSurface(img, img.format(), QDirectFBScreen::DontTrackSurface); #else const qint64 key = img.cacheKey(); *release = false; @@ -931,7 +982,7 @@ IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, boo const QImage::Format format = (img.format() == screen->alphaPixmapFormat() || QDirectFBPixmapData::hasAlphaChannel(img) ? screen->alphaPixmapFormat() : screen->pixelFormat()); - IDirectFBSurface *surface = screen->copyToDFBSurface(img, format, + IDirectFBSurface *surface = screen->createDFBSurface(img, format, cache ? QDirectFBScreen::TrackSurface : QDirectFBScreen::DontTrackSurface); @@ -979,7 +1030,6 @@ static inline qreal fixCoord(qreal rect_pos, qreal pixmapSize, qreal offset) void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &off) { - Q_ASSERT(!dirtyClip); Q_ASSERT(!(transformationType & Matrix_BlitsUnsupported)); const QTransform &transform = q->state()->matrix; const QRect destinationRect = transform.mapRect(dest).toRect().normalized(); @@ -1004,7 +1054,7 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data); - dfbData->unlockDirectFB(); + QDirectFBPaintEnginePrivate::unlock(dfbData); const QSize pixmapSize = dfbData->size(); IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); if (transform.isScaling()) { @@ -1013,8 +1063,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix offset.ry() *= transform.m22(); const QSizeF mappedSize(pixmapSize.width() * transform.m11(), pixmapSize.height() * transform.m22()); - qreal y = ::fixCoord(destinationRect.y(), mappedSize.height(), offset.y()); - const qreal startX = ::fixCoord(destinationRect.x(), mappedSize.width(), offset.x()); + qreal y = fixCoord(destinationRect.y(), mappedSize.height(), offset.y()); + const qreal startX = fixCoord(destinationRect.x(), mappedSize.width(), offset.x()); while (y <= destinationRect.bottom()) { qreal x = startX; while (x <= destinationRect.right()) { @@ -1025,8 +1075,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix y += mappedSize.height(); } } else { - qreal y = ::fixCoord(destinationRect.y(), pixmapSize.height(), offset.y()); - const qreal startX = ::fixCoord(destinationRect.x(), pixmapSize.width(), offset.x()); + qreal y = fixCoord(destinationRect.y(), pixmapSize.height(), offset.y()); + const qreal startX = fixCoord(destinationRect.x(), pixmapSize.width(), offset.x()); int horizontal = qMax(1, destinationRect.width() / pixmapSize.width()) + 1; if (startX != destinationRect.x()) ++horizontal; @@ -1072,9 +1122,7 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix void QDirectFBPaintEnginePrivate::updateClip() { - if (!dirtyClip) - return; - + Q_ASSERT(surface); currentClip = QRect(); const QClipData *clipData = clip(); if (!clipData || !clipData->enabled) { @@ -1096,14 +1144,12 @@ void QDirectFBPaintEnginePrivate::updateClip() } else { clipType = ComplexClip; } - - dirtyClip = false; } void QDirectFBPaintEnginePrivate::systemStateChanged() { - dirtyClip = true; QRasterPaintEnginePrivate::systemStateChanged(); + updateClip(); } IDirectFBSurface *SurfaceCache::getSurface(const uint *buf, int size) @@ -1114,7 +1160,7 @@ IDirectFBSurface *SurfaceCache::getSurface(const uint *buf, int size) clear(); const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size); - surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface); + surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface, 0); if (!surface) qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface"); @@ -1142,12 +1188,12 @@ template <class T> static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface) { if (n == 1) { - const QLine l = ::map(transform, lines[0]); + const QLine l = map(transform, lines[0]); surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); } else { QVarLengthArray<DFBRegion, 32> lineArray(n); for (int i=0; i<n; ++i) { - const QLine l = ::map(transform, lines[i]); + const QLine l = map(transform, lines[i]); lineArray[i].x1 = l.x1(); lineArray[i].y1 = l.y1(); lineArray[i].x2 = l.x2(); @@ -1161,12 +1207,12 @@ template <class T> static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface) { if (n == 1) { - const QRect r = ::mapRect(transform, rects[0]); + const QRect r = mapRect(transform, rects[0]); surface->FillRectangle(surface, r.x(), r.y(), r.width(), r.height()); } else { QVarLengthArray<DFBRectangle, 32> rectArray(n); for (int i=0; i<n; ++i) { - const QRect r = ::mapRect(transform, rects[i]); + const QRect r = mapRect(transform, rects[i]); rectArray[i].x = r.x(); rectArray[i].y = r.y(); rectArray[i].w = r.width(); @@ -1180,7 +1226,7 @@ template <class T> static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface) { for (int i=0; i<n; ++i) { - const QRect r = ::mapRect(transform, rects[i]); + const QRect r = mapRect(transform, rects[i]); surface->DrawRectangle(surface, r.x(), r.y(), r.width(), r.height()); } } @@ -1205,7 +1251,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * dbg << dev << "of type" << dev->devType(); } - dbg << QString("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0')) + dbg << QString::fromLatin1("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0')) << "simplePen" << simplePen << "clipType" << clipType << "compositionModeStatus" << compositionModeStatus; @@ -1227,4 +1273,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * } #endif // QT_DIRECTFB_WARN_ON_RASTERFALLBACKS -#endif // QT_NO_DIRECTFB + +QT_END_NAMESPACE + +#endif // QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h index 0469223..94cb556 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h @@ -45,8 +45,12 @@ #include <QtGui/qpaintengine.h> #include <private/qpaintengine_raster_p.h> +#ifndef QT_NO_QWS_DIRECTFB + QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) class QDirectFBPaintEnginePrivate; @@ -90,6 +94,7 @@ public: virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode); virtual void drawTextItem(const QPointF &p, const QTextItem &textItem); virtual void fill(const QVectorPath &path, const QBrush &brush); + virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode); virtual void clipEnabledChanged(); virtual void penChanged(); @@ -101,11 +106,16 @@ public: virtual void setState(QPainterState *state); virtual void clip(const QVectorPath &path, Qt::ClipOperation op); + virtual void clip(const QRegion ®ion, Qt::ClipOperation op); virtual void clip(const QRect &rect, Qt::ClipOperation op); static void initImageCache(int size); }; +QT_END_NAMESPACE + QT_END_HEADER +#endif // QT_NO_QWS_DIRECTFB + #endif // QPAINTENGINE_DIRECTFB_P_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 5b84cdd..b15888b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -41,26 +41,29 @@ #include "qdirectfbpixmap.h" +#ifndef QT_NO_QWS_DIRECTFB + #include "qdirectfbscreen.h" #include "qdirectfbpaintengine.h" #include <QtGui/qbitmap.h> +#include <QtCore/qfile.h> #include <directfb.h> + +QT_BEGIN_NAMESPACE + static int global_ser_no = 0; QDirectFBPixmapData::QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType) : QPixmapData(pixelType, DirectFBClass), QDirectFBPaintDevice(screen), - format(QImage::Format_Invalid), alpha(false) + alpha(false) { setSerialNumber(0); } QDirectFBPixmapData::~QDirectFBPixmapData() { - unlockDirectFB(); - if (dfbSurface && QDirectFBScreen::instance()) - screen->releaseDFBSurface(dfbSurface); } void QDirectFBPixmapData::resize(int width, int height) @@ -70,16 +73,21 @@ void QDirectFBPixmapData::resize(int width, int height) return; } - format = screen->pixelFormat(); - dfbSurface = QDirectFBScreen::instance()->createDFBSurface(QSize(width, height), - format, - QDirectFBScreen::TrackSurface); + imageFormat = screen->pixelFormat(); + dfbSurface = screen->createDFBSurface(QSize(width, height), + imageFormat, + QDirectFBScreen::TrackSurface); + d = QDirectFBScreen::depth(imageFormat); alpha = false; if (!dfbSurface) { invalidate(); qWarning("QDirectFBPixmapData::resize(): Unable to allocate surface"); return; } + + w = width; + h = height; + is_null = (w <= 0 || h <= 0); setSerialNumber(++global_ser_no); } @@ -156,39 +164,188 @@ static bool checkForAlphaPixels(const QImage &img) bool QDirectFBPixmapData::hasAlphaChannel(const QImage &img) { #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION - return ::checkForAlphaPixels(img); + return checkForAlphaPixels(img); #else return img.hasAlphaChannel(); #endif } +#ifdef QT_DIRECTFB_IMAGEPROVIDER +bool QDirectFBPixmapData::fromFile(const QString &filename, const char *format, + Qt::ImageConversionFlags flags) +{ + if (flags == Qt::AutoColor) { + if (filename.startsWith(QLatin1Char(':'))) { // resource + QFile file(filename); + if (!file.open(QIODevice::ReadOnly)) + return false; + const QByteArray data = file.readAll(); + file.close(); + return fromData(reinterpret_cast<const uchar*>(data.constData()), data.size(), format, flags); + } else { + DFBDataBufferDescription description; + description.flags = DBDESC_FILE; + const QByteArray fileNameData = filename.toLocal8Bit(); + description.file = fileNameData.constData(); + if (fromDataBufferDescription(description)) { + return true; + } + // fall back to Qt + } + } + return QPixmapData::fromFile(filename, format, flags); +} + +bool QDirectFBPixmapData::fromData(const uchar *buffer, uint len, const char *format, + Qt::ImageConversionFlags flags) +{ + if (flags == Qt::AutoColor) { + DFBDataBufferDescription description; + description.flags = DBDESC_MEMORY; + description.memory.data = buffer; + description.memory.length = len; + if (fromDataBufferDescription(description)) + return true; + // fall back to Qt + } + return QPixmapData::fromData(buffer, len, format, flags); +} -void QDirectFBPixmapData::fromImage(const QImage &i, - Qt::ImageConversionFlags flags) +template <typename T> struct QDirectFBInterfaceCleanupHandler { -#ifdef QT_NO_DIRECTFB_OPAQUE_DETECTION - Q_UNUSED(flags); + static void cleanup(T *t) { if (t) t->Release(t); } +}; + +template <typename T> +class QDirectFBPointer : public QScopedPointer<T, QDirectFBInterfaceCleanupHandler<T> > +{ +public: + QDirectFBPointer(T *t = 0) + : QScopedPointer<T, QDirectFBInterfaceCleanupHandler<T> >(t) + {} +}; + +bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescription &dataBufferDescription) +{ + IDirectFB *dfb = screen->dfb(); + Q_ASSERT(dfb); + DFBResult result = DFB_OK; + IDirectFBDataBuffer *dataBufferPtr; + if ((result = dfb->CreateDataBuffer(dfb, &dataBufferDescription, &dataBufferPtr)) != DFB_OK) { + DirectFBError("QDirectFBPixmapData::fromDataBufferDescription()", result); + return false; + } + QDirectFBPointer<IDirectFBDataBuffer> dataBuffer(dataBufferPtr); + + IDirectFBImageProvider *providerPtr; + if ((result = dataBuffer->CreateImageProvider(dataBuffer.data(), &providerPtr)) != DFB_OK) { + DirectFBError("QDirectFBPixmapData::fromDataBufferDescription(): Can't create image provider", result); + return false; + } + QDirectFBPointer<IDirectFBImageProvider> provider(providerPtr); + + DFBSurfaceDescription surfaceDescription; + if ((result = provider->GetSurfaceDescription(provider.data(), &surfaceDescription)) != DFB_OK) { + DirectFBError("QDirectFBPixmapData::fromDataBufferDescription(): Can't get surface description", result); + return false; + } + + DFBImageDescription imageDescription; + result = provider->GetImageDescription(provider.data(), &imageDescription); + if (result != DFB_OK) { + DirectFBError("QDirectFBPixmapData::fromSurfaceDescription(): Can't get image description", result); + return false; + } + + alpha = imageDescription.caps & (DICAPS_ALPHACHANNEL|DICAPS_COLORKEY); + imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat(); + + dfbSurface = screen->createDFBSurface(QSize(surfaceDescription.width, surfaceDescription.height), + imageFormat, QDirectFBScreen::TrackSurface); + + result = provider->RenderTo(provider.data(), dfbSurface, 0); + if (result != DFB_OK) { + DirectFBError("QDirectFBPixmapData::fromSurfaceDescription(): Can't render to surface", result); + return false; + } + + w = surfaceDescription.width; + h = surfaceDescription.height; + is_null = (w <= 0 || h <= 0); + d = QDirectFBScreen::depth(imageFormat); + setSerialNumber(++global_ser_no); + +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + screen->setDirectFBImageProvider(providerPtr); + provider.take(); +#endif + + return true; +} + #endif - const QImage img = (i.depth() == 1 ? i.convertToFormat(screen->alphaPixmapFormat()) : i); + +void QDirectFBPixmapData::fromImage(const QImage &img, + Qt::ImageConversionFlags flags) +{ + if (img.depth() == 1 || img.format() == QImage::Format_RGB32) { + fromImage(img.convertToFormat(screen->alphaPixmapFormat()), flags); + return; + } + if (img.hasAlphaChannel() #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) #endif ) { alpha = true; - format = screen->alphaPixmapFormat(); + imageFormat = screen->alphaPixmapFormat(); } else { alpha = false; - format = screen->pixelFormat(); + imageFormat = screen->pixelFormat(); } - dfbSurface = screen->copyToDFBSurface(img, format, - QDirectFBScreen::TrackSurface); + QImage image; + if (flags != Qt::AutoColor) { + image = img.convertToFormat(imageFormat, flags); + flags = Qt::AutoColor; + } else if (img.format() == QImage::Format_RGB32) { + image = img.convertToFormat(imageFormat, flags); + } else { + image = img; + } + + IDirectFBSurface *imageSurface = screen->createDFBSurface(image, image.format(), QDirectFBScreen::DontTrackSurface); + if (!imageSurface) { + qWarning("QDirectFBPixmapData::fromImage()"); + invalidate(); + return; + } + + dfbSurface = screen->createDFBSurface(image.size(), imageFormat, QDirectFBScreen::TrackSurface); if (!dfbSurface) { qWarning("QDirectFBPixmapData::fromImage()"); invalidate(); return; } + + if (image.hasAlphaChannel()) { + dfbSurface->Clear(dfbSurface, 0, 0, 0, 0); + dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL); + } else { + dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); + } + + dfbSurface->Blit(dfbSurface, imageSurface, 0, 0, 0); + imageSurface->Release(imageSurface); + + w = image.width(); + h = image.height(); + is_null = (w <= 0 || h <= 0); + d = QDirectFBScreen::depth(imageFormat); setSerialNumber(++global_ser_no); +#ifdef QT_NO_DIRECTFB_OPAQUE_DETECTION + Q_UNUSED(flags); +#endif } void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) @@ -197,16 +354,21 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) QPixmapData::copy(data, rect); return; } - unlockDirectFB(); - IDirectFBSurface *src = static_cast<const QDirectFBPixmapData*>(data)->directFBSurface(); + const QDirectFBPixmapData *otherData = static_cast<const QDirectFBPixmapData*>(data); +#ifdef QT_NO_DIRECTFB_SUBSURFACE + if (otherData->lockFlags()) { + const_cast<QDirectFBPixmapData*>(otherData)->unlockSurface(); + } +#endif + IDirectFBSurface *src = otherData->directFBSurface(); alpha = data->hasAlphaChannel(); - format = (alpha - ? QDirectFBScreen::instance()->alphaPixmapFormat() - : QDirectFBScreen::instance()->pixelFormat()); + imageFormat = (alpha + ? QDirectFBScreen::instance()->alphaPixmapFormat() + : QDirectFBScreen::instance()->pixelFormat()); - dfbSurface = screen->createDFBSurface(rect.size(), format, + dfbSurface = screen->createDFBSurface(rect.size(), imageFormat, QDirectFBScreen::TrackSurface); if (!dfbSurface) { qWarning("QDirectFBPixmapData::copy()"); @@ -222,6 +384,11 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) } const DFBRectangle blitRect = { rect.x(), rect.y(), rect.width(), rect.height() }; + w = rect.width(); + h = rect.height(); + d = otherData->d; + is_null = (w <= 0 || h <= 0); + unlockSurface(); DFBResult result = dfbSurface->Blit(dfbSurface, src, &blitRect, 0, 0); #if (Q_DIRECTFB_VERSION >= 0x010000) dfbSurface->ReleaseSource(dfbSurface); @@ -260,11 +427,12 @@ void QDirectFBPixmapData::fill(const QColor &color) alpha = (color.alpha() < 255); - if (alpha && ::isOpaqueFormat(format)) { + if (alpha && isOpaqueFormat(imageFormat)) { QSize size; dfbSurface->GetSize(dfbSurface, &size.rwidth(), &size.rheight()); screen->releaseDFBSurface(dfbSurface); - format = screen->alphaPixmapFormat(); + imageFormat = screen->alphaPixmapFormat(); + d = QDirectFBScreen::depth(imageFormat); dfbSurface = screen->createDFBSurface(size, screen->alphaPixmapFormat(), QDirectFBScreen::TrackSurface); setSerialNumber(++global_ser_no); if (!dfbSurface) { @@ -281,21 +449,21 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, Qt::TransformationMode mode) const { QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this); +#ifdef QT_NO_DIRECTFB_SUBSURFACE + if (lockFlags()) + that->unlockSurface(); +#endif + if (!dfbSurface || transform.type() != QTransform::TxScale || mode != Qt::FastTransformation) { const QImage *image = that->buffer(); Q_ASSERT(image); const QImage transformed = image->transformed(transform, mode); - that->unlockDirectFB(); QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType); data->fromImage(transformed, Qt::AutoColor); return QPixmap(data); } - that->unlockDirectFB(); - - int w, h; - dfbSurface->GetSize(dfbSurface, &w, &h); const QSize size = transform.mapRect(QRect(0, 0, w, h)).size(); if (size.isEmpty()) @@ -308,7 +476,7 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, flags = DSBLIT_BLEND_ALPHACHANNEL; } data->dfbSurface = screen->createDFBSurface(size, - format, + imageFormat, QDirectFBScreen::TrackSurface); if (flags & DSBLIT_BLEND_ALPHACHANNEL) { data->dfbSurface->Clear(data->dfbSurface, 0, 0, 0, 0); @@ -317,6 +485,10 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, const DFBRectangle destRect = { 0, 0, size.width(), size.height() }; data->dfbSurface->StretchBlit(data->dfbSurface, dfbSurface, 0, &destRect); + data->w = size.width(); + data->h = size.height(); + data->is_null = (data->w <= 0 || data->h <= 0); + #if (Q_DIRECTFB_VERSION >= 0x010000) data->dfbSurface->ReleaseSource(data->dfbSurface); #endif @@ -333,7 +505,7 @@ QImage QDirectFBPixmapData::toImage() const // DirectFB not to move the surface to videomemory. When that // happens we can use this (hopefully faster) codepath #ifndef QT_NO_DIRECTFB_PREALLOCATED - QImage ret(size(), QDirectFBScreen::getImageFormat(dfbSurface)); + QImage ret(w, h, QDirectFBScreen::getImageFormat(dfbSurface)); if (IDirectFBSurface *imgSurface = screen->createDFBSurface(ret, QDirectFBScreen::DontTrackSurface)) { if (hasAlphaChannel()) { imgSurface->SetBlittingFlags(imgSurface, DSBLIT_BLEND_ALPHACHANNEL); @@ -371,20 +543,30 @@ QPaintEngine *QDirectFBPixmapData::paintEngine() const QImage *QDirectFBPixmapData::buffer() { - lockDirectFB(DSLF_READ|DSLF_WRITE); - return lockedImage; -} - -QImage * QDirectFBPixmapData::buffer(DFBSurfaceLockFlags lockFlags) -{ - lockDirectFB(lockFlags); - return lockedImage; + if (!lockFlgs) { + lockSurface(DSLF_READ|DSLF_WRITE); + } + Q_ASSERT(lockFlgs); + Q_ASSERT(!lockedImage.isNull()); + return &lockedImage; } void QDirectFBPixmapData::invalidate() { + if (dfbSurface) { + screen->releaseDFBSurface(dfbSurface); + dfbSurface = 0; + } setSerialNumber(0); alpha = false; - format = QImage::Format_Invalid; + d = w = h = 0; + is_null = true; + imageFormat = QImage::Format_Invalid; } +QT_END_NAMESPACE + +#endif // QT_NO_QWS_DIRECTFB + + + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index b208203..b52b305 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -42,6 +42,10 @@ #ifndef QDIRECTFBPIXMAP_H #define QDIRECTFBPIXMAP_H +#include <qglobal.h> + +#ifndef QT_NO_QWS_DIRECTFB + #include <QtGui/private/qpixmapdata_p.h> #include <QtGui/private/qpaintengine_raster_p.h> #include "qdirectfbpaintdevice.h" @@ -49,6 +53,8 @@ QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) class QDirectFBPaintEngine; @@ -60,28 +66,39 @@ public: ~QDirectFBPixmapData(); // Re-implemented from QPixmapData: - void resize(int width, int height); - void fromImage(const QImage &image, Qt::ImageConversionFlags flags); - void copy(const QPixmapData *data, const QRect &rect); - void fill(const QColor &color); - inline bool hasAlphaChannel() const { return alpha; } - QPixmap transformed(const QTransform &matrix, - Qt::TransformationMode mode) const; - QImage toImage() const; - QPaintEngine* paintEngine() const; + virtual void resize(int width, int height); + virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags); +#ifdef QT_DIRECTFB_IMAGEPROVIDER + virtual bool fromFile(const QString &filename, const char *format, + Qt::ImageConversionFlags flags); + virtual bool fromData(const uchar *buffer, uint len, const char *format, + Qt::ImageConversionFlags flags); +#endif + virtual void copy(const QPixmapData *data, const QRect &rect); + virtual void fill(const QColor &color); + virtual QPixmap transformed(const QTransform &matrix, + Qt::TransformationMode mode) const; + virtual QImage toImage() const; + virtual QPaintEngine *paintEngine() const; virtual QImage *buffer(); - QImage *buffer(DFBSurfaceLockFlags lockFlags); - // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice - int metric(QPaintDevice::PaintDeviceMetric m) const {return QDirectFBPaintDevice::metric(m);} - inline QImage::Format pixelFormat() const { return format; } + virtual int metric(QPaintDevice::PaintDeviceMetric m) const { return QDirectFBPaintDevice::metric(m); } + + inline QImage::Format pixelFormat() const { return imageFormat; } static bool hasAlphaChannel(const QImage &img); + inline bool hasAlphaChannel() const { return alpha; } private: +#ifdef QT_DIRECTFB_IMAGEPROVIDER + bool fromDataBufferDescription(const DFBDataBufferDescription &dataBuffer); +#endif void invalidate(); - QImage::Format format; bool alpha; }; +QT_END_NAMESPACE + QT_END_HEADER +#endif // QT_NO_QWS_DIRECTFB + #endif // QDIRECTFBPIXMAP_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 4116854..449bc0d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -54,23 +54,36 @@ #include <QtCore/qvector.h> #include <QtCore/qrect.h> +#ifndef QT_NO_QWS_DIRECTFB + +QT_BEGIN_NAMESPACE + class QDirectFBScreenPrivate : public QObject, public QWSGraphicsSystem { + Q_OBJECT public: QDirectFBScreenPrivate(QDirectFBScreen *qptr); ~QDirectFBScreenPrivate(); void setFlipFlags(const QStringList &args); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - +public slots: +#ifdef QT_DIRECTFB_WM + void onWindowEvent(QWSWindow *window, QWSServer::WindowEvent event); +#endif +public: IDirectFB *dfb; - IDirectFBSurface *dfbSurface; DFBSurfaceFlipFlags flipFlags; + QDirectFBScreen::DirectFBFlags directFBFlags; + QImage::Format alphaPixmapFormat; + IDirectFBScreen *dfbScreen; +#ifdef QT_NO_DIRECTFB_WM + IDirectFBSurface *primarySurface; + QColor backgroundColor; +#endif #ifndef QT_NO_DIRECTFB_LAYER IDirectFBDisplayLayer *dfbLayer; #endif - IDirectFBScreen *dfbScreen; - QSet<IDirectFBSurface*> allocatedSurfaces; #ifndef QT_NO_DIRECTFB_MOUSE @@ -79,31 +92,48 @@ public: #ifndef QT_NO_DIRECTFB_KEYBOARD QDirectFBKeyboardHandler *keyboard; #endif - QDirectFBScreen::DirectFBFlags directFBFlags; - QImage::Format alphaPixmapFormat; - QColor backgroundColor; +#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + IDirectFBImageProvider *imageProvider; +#endif + IDirectFBSurface *cursorSurface; + qint64 cursorImageKey; + QDirectFBScreen *q; + static QDirectFBScreen *instance; }; +QDirectFBScreen *QDirectFBScreenPrivate::instance = 0; + QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr) - : QWSGraphicsSystem(qptr), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE) + : QWSGraphicsSystem(qptr), dfb(0), flipFlags(DSFLIP_NONE), + directFBFlags(QDirectFBScreen::NoFlags), alphaPixmapFormat(QImage::Format_Invalid), + dfbScreen(0) +#ifdef QT_NO_DIRECTFB_WM + , primarySurface(0) +#endif #ifndef QT_NO_DIRECTFB_LAYER , dfbLayer(0) #endif - , dfbScreen(0) #ifndef QT_NO_DIRECTFB_MOUSE , mouse(0) #endif #ifndef QT_NO_DIRECTFB_KEYBOARD , keyboard(0) #endif - , directFBFlags(QDirectFBScreen::NoFlags) - , alphaPixmapFormat(QImage::Format_Invalid) +#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + , imageProvider(0) +#endif + , cursorSurface(0) + , cursorImageKey(0) , q(qptr) { #ifndef QT_NO_QWS_SIGNALHANDLER QWSSignalHandler::instance()->addObject(this); #endif +#ifdef QT_DIRECTFB_WM + connect(QWSServer::instance(), SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)), + this, SLOT(onWindowEvent(QWSWindow*, QWSServer::WindowEvent))); +#endif } QDirectFBScreenPrivate::~QDirectFBScreenPrivate() @@ -114,13 +144,19 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate() #ifndef QT_NO_DIRECTFB_KEYBOARD delete keyboard; #endif +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + if (imageProvider) + imageProvider->Release(imageProvider); +#endif for (QSet<IDirectFBSurface*>::const_iterator it = allocatedSurfaces.begin(); it != allocatedSurfaces.end(); ++it) { (*it)->Release(*it); } - if (dfbSurface) - dfbSurface->Release(dfbSurface); +#ifdef QT_NO_DIRECTFB_WM + if (primarySurface) + primarySurface->Release(primarySurface); +#endif #ifndef QT_NO_DIRECTFB_LAYER if (dfbLayer) @@ -134,64 +170,77 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate() dfb->Release(dfb); } - - -// creates a preallocated surface with the same format as the image if -// possible. - -IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCreationOptions options) +IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &image, QImage::Format format, SurfaceCreationOptions options, DFBResult *resultPtr) { - if (img.isNull()) // assert? + if (image.isNull()) // assert? return 0; - if (QDirectFBScreen::getSurfacePixelFormat(img.format()) == DSPF_UNKNOWN) { - QImage image = img.convertToFormat(img.hasAlphaChannel() - ? d_ptr->alphaPixmapFormat - : pixelFormat()); - IDirectFBSurface *tmp = createDFBSurface(image, false); - if (!tmp) { - qWarning("Couldn't create surface createDFBSurface(QImage, bool)"); - return 0; - } - IDirectFBSurface *surface = copyDFBSurface(tmp, image.format(), options); - tmp->Release(tmp); - return surface; + if (QDirectFBScreen::getSurfacePixelFormat(format) == DSPF_UNKNOWN) { + format = QDirectFBPixmapData::hasAlphaChannel(image) ? d_ptr->alphaPixmapFormat : pixelFormat(); + } + if (image.format() != format) { + return createDFBSurface(image.convertToFormat(format), format, options | NoPreallocated, resultPtr); } - IDirectFBSurface *surface = createDFBSurface(QDirectFBScreen::getSurfaceDescription(img), options); -#ifdef QT_NO_DIRECTFB_PREALLOCATED - if (surface) { - int bpl; - uchar *mem = QDirectFBScreen::lockSurface(surface, DSLF_WRITE, &bpl); + DFBSurfaceDescription description; + memset(&description, 0, sizeof(DFBSurfaceDescription)); + description.width = image.width(); + description.height = image.height(); + description.flags = DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT; + initSurfaceDescriptionPixelFormat(&description, format); + bool doMemCopy = true; +#ifdef QT_DIRECTFB_PREALLOCATED + if (!(options & NoPreallocated)) { + doMemCopy = false; + description.flags |= DSDESC_PREALLOCATED; + description.preallocated[0].data = const_cast<uchar*>(image.bits()); + description.preallocated[0].pitch = image.bytesPerLine(); + description.preallocated[1].data = 0; + description.preallocated[1].pitch = 0; + } +#endif + DFBResult result; + IDirectFBSurface *surface = createDFBSurface(description, options, &result); + if (resultPtr) + *resultPtr = result; + if (!surface) { + DirectFBError("Couldn't create surface createDFBSurface(QImage, QImage::Format, SurfaceCreationOptions)", result); + return 0; + } + if (doMemCopy) { + int bplDFB; + uchar *mem = QDirectFBScreen::lockSurface(surface, DSLF_WRITE, &bplDFB); if (mem) { - const int h = img.height(); - const int w = img.width() * img.depth() / 8; - for (int i = 0; i < h; ++i) { - memcpy(mem, img.scanLine(i), w); - mem += bpl; + const int height = image.height(); + const int bplQt = image.bytesPerLine(); + if (bplQt == bplDFB && bplQt == (image.width() * image.depth() / 8)) { + memcpy(mem, image.bits(), image.numBytes()); + } else { + for (int i=0; i<height; ++i) { + memcpy(mem, image.scanLine(i), bplQt); + mem += bplDFB; + } } surface->Unlock(surface); } } -#endif -#ifndef QT_NO_DIRECTFB_PALETTE - if (img.numColors() != 0 && surface) - QDirectFBScreen::setSurfaceColorTable(surface, img); +#ifdef QT_DIRECTFB_PALETTE + if (image.numColors() != 0 && surface) + QDirectFBScreen::setSurfaceColorTable(surface, image); #endif return surface; } IDirectFBSurface *QDirectFBScreen::copyDFBSurface(IDirectFBSurface *src, QImage::Format format, - SurfaceCreationOptions options) + SurfaceCreationOptions options, + DFBResult *result) { Q_ASSERT(src); QSize size; src->GetSize(src, &size.rwidth(), &size.rheight()); - IDirectFBSurface *surface = createDFBSurface(size, format, options); - DFBSurfacePixelFormat dspf; - src->GetPixelFormat(src, &dspf); - DFBSurfaceBlittingFlags flags = QDirectFBScreen::hasAlpha(dspf) + IDirectFBSurface *surface = createDFBSurface(size, format, options, result); + DFBSurfaceBlittingFlags flags = QDirectFBScreen::hasAlphaChannel(surface) ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; if (flags & DSBLIT_BLEND_ALPHACHANNEL) @@ -207,7 +256,8 @@ IDirectFBSurface *QDirectFBScreen::copyDFBSurface(IDirectFBSurface *src, IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size, QImage::Format format, - SurfaceCreationOptions options) + SurfaceCreationOptions options, + DFBResult *result) { DFBSurfaceDescription desc; memset(&desc, 0, sizeof(DFBSurfaceDescription)); @@ -216,12 +266,14 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size, return 0; desc.width = size.width(); desc.height = size.height(); - return createDFBSurface(desc, options); + return createDFBSurface(desc, options, result); } -IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options) +IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options, DFBResult *resultPtr) { - DFBResult result = DFB_OK; + DFBResult tmp; + DFBResult &result = (resultPtr ? *resultPtr : tmp); + result = DFB_OK; IDirectFBSurface *newSurface = 0; if (!d_ptr->dfb) { @@ -275,75 +327,37 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, if (options & TrackSurface) { d_ptr->allocatedSurfaces.insert(newSurface); - - //qDebug("Created a new DirectFB surface at %p. New count = %d", - // newSurface, d_ptr->allocatedSurfaces.count()); } return newSurface; } -IDirectFBSurface *QDirectFBScreen::copyToDFBSurface(const QImage &img, - QImage::Format pixmapFormat, - SurfaceCreationOptions options) +#ifdef QT_DIRECTFB_SUBSURFACE +IDirectFBSurface *QDirectFBScreen::getSubSurface(IDirectFBSurface *surface, + const QRect &rect, + SurfaceCreationOptions options, + DFBResult *resultPtr) { - QImage image = img; - if (QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN -#ifdef QT_NO_DIRECTFB_PREALLOCATED - || image.format() != pixmapFormat -#endif -#ifdef QT_NO_DIRECTFB_PALETTE - || image.numColors() != 0 -#endif - ) { - image = image.convertToFormat(pixmapFormat); - } - - IDirectFBSurface *dfbSurface = createDFBSurface(image.size(), pixmapFormat, options); - if (!dfbSurface) { - qWarning("QDirectFBScreen::copyToDFBSurface() Couldn't create surface"); - return 0; - } - -#ifndef QT_NO_DIRECTFB_PREALLOCATED - IDirectFBSurface *imgSurface = createDFBSurface(image, DontTrackSurface); - if (!imgSurface) { - qWarning("QDirectFBScreen::copyToDFBSurface()"); - QDirectFBScreen::releaseDFBSurface(dfbSurface); - return 0; + Q_ASSERT(!(options & NoPreallocated)); + Q_ASSERT(surface); + DFBResult res; + DFBResult &result = (resultPtr ? *resultPtr : res); + IDirectFBSurface *subSurface = 0; + if (rect.isNull()) { + result = surface->GetSubSurface(surface, 0, &subSurface); + } else { + const DFBRectangle subRect = { rect.x(), rect.y(), rect.width(), rect.height() }; + result = surface->GetSubSurface(surface, &subRect, &subSurface); } - - Q_ASSERT(imgSurface); - DFBSurfaceBlittingFlags flags = img.hasAlphaChannel() - ? DSBLIT_BLEND_ALPHACHANNEL - : DSBLIT_NOFX; - if (flags & DSBLIT_BLEND_ALPHACHANNEL) - dfbSurface->Clear(dfbSurface, 0, 0, 0, 0); - - dfbSurface->SetBlittingFlags(dfbSurface, flags); - DFBResult result = dfbSurface->Blit(dfbSurface, imgSurface, 0, 0, 0); - if (result != DFB_OK) - DirectFBError("QDirectFBScreen::copyToDFBSurface()", result); - imgSurface->Release(imgSurface); -#if (Q_DIRECTFB_VERSION >= 0x010000) - dfbSurface->ReleaseSource(dfbSurface); -#endif -#else // QT_NO_DIRECTFB_PREALLOCATED - Q_ASSERT(image.format() == pixmapFormat); - int bpl; - uchar *mem = QDirectFBScreen::lockSurface(dfbSurface, DSLF_WRITE, &bpl); - if (mem) { - const int h = image.height(); - const int w = image.width() * image.depth() / 8; - for (int i=0; i<h; ++i) { - memcpy(mem, image.scanLine(i), w); - mem += bpl; - } - dfbSurface->Unlock(dfbSurface); + if (result != DFB_OK) { + DirectFBError("Can't get sub surface", result); + } else if (options & TrackSurface) { + d_ptr->allocatedSurfaces.insert(subSurface); } -#endif - return dfbSurface; + return subSurface; } +#endif + void QDirectFBScreen::releaseDFBSurface(IDirectFBSurface *surface) { @@ -366,10 +380,12 @@ IDirectFB *QDirectFBScreen::dfb() return d_ptr->dfb; } -IDirectFBSurface *QDirectFBScreen::dfbSurface() +#ifdef QT_NO_DIRECTFB_WM +IDirectFBSurface *QDirectFBScreen::primarySurface() { - return d_ptr->dfbSurface; + return d_ptr->primarySurface; } +#endif #ifndef QT_NO_DIRECTFB_LAYER IDirectFBDisplayLayer *QDirectFBScreen::dfbDisplayLayer() @@ -456,36 +472,6 @@ QImage::Format QDirectFBScreen::getImageFormat(IDirectFBSurface *surface) return QImage::Format_Invalid; } -DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const QImage &image) -{ - DFBSurfaceDescription description; - memset(&description, 0, sizeof(DFBSurfaceDescription)); - - const DFBSurfacePixelFormat format = getSurfacePixelFormat(image.format()); - - if (format == DSPF_UNKNOWN || image.isNull()) { - description.flags = DSDESC_NONE; - return description; - } - - description.flags = DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT; - QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description, image.format()); - description.width = image.width(); - description.height = image.height(); -#ifndef QT_NO_DIRECTFB_PREALLOCATED - description.flags |= DSDESC_PREALLOCATED; - description.preallocated[0].data = (void*)(image.bits()); - description.preallocated[0].pitch = image.bytesPerLine(); - description.preallocated[1].data = 0; - description.preallocated[1].pitch = 0; -#endif - - if (QDirectFBScreen::isPremultiplied(image.format())) - description.caps = DSCAPS_PREMULTIPLIED; - - return description; -} - DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const uint *buffer, int length) { @@ -501,7 +487,7 @@ DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const uint *buffer, description.preallocated[0].pitch = length * sizeof(uint); description.preallocated[1].data = 0; description.preallocated[1].pitch = 0; -return description; + return description; } #ifndef QT_NO_DIRECTFB_PALETTE @@ -542,7 +528,7 @@ void QDirectFBScreen::setSurfaceColorTable(IDirectFBSurface *surface, #endif // QT_NO_DIRECTFB_PALETTE -#if !defined(QT_NO_DIRECTFB_LAYER) && !defined(QT_NO_QWS_CURSOR) +#if defined QT_DIRECTFB_CURSOR class Q_GUI_EXPORT QDirectFBScreenCursor : public QScreenCursor { public: @@ -552,6 +538,11 @@ public: virtual void show(); virtual void hide(); private: +#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR + ~QDirectFBScreenCursor(); + bool createWindow(); + IDirectFBWindow *window; +#endif IDirectFBDisplayLayer *layer; }; @@ -567,11 +558,98 @@ QDirectFBScreenCursor::QDirectFBScreenCursor() enable = false; hwaccel = true; supportsAlpha = true; +#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR + window = 0; + DFBResult result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::hide: " + "Unable to set cooperative level", result); + } + result = layer->SetCursorOpacity(layer, 0); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::hide: " + "Unable to set cursor opacity", result); + } + + result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::hide: " + "Unable to set cooperative level", result); + } +#endif +} + +#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR +QDirectFBScreenCursor::~QDirectFBScreenCursor() +{ + if (window) { + window->Release(window); + window = 0; + } +} + +bool QDirectFBScreenCursor::createWindow() +{ + Q_ASSERT(!window); + Q_ASSERT(!cursor.isNull()); + DFBWindowDescription description; + memset(&description, 0, sizeof(DFBWindowDescription)); + description.flags = DWDESC_POSX|DWDESC_POSY|DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_CAPS|DWDESC_PIXELFORMAT|DWDESC_SURFACE_CAPS; + description.width = cursor.width(); + description.height = cursor.height(); + description.posx = pos.x() - hotspot.x(); + description.posy = pos.y() - hotspot.y(); +#if (Q_DIRECTFB_VERSION >= 0x010100) + description.flags |= DWDESC_OPTIONS; + description.options = DWOP_GHOST|DWOP_ALPHACHANNEL; +#endif + description.caps = DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER; + const QImage::Format format = QDirectFBScreen::instance()->alphaPixmapFormat(); + description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format); + if (QDirectFBScreen::isPremultiplied(format)) + description.surface_caps = DSCAPS_PREMULTIPLIED; + + DFBResult result = layer->CreateWindow(layer, &description, &window); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::createWindow: Unable to create window", result); + return false; + } + result = window->SetOpacity(window, 255); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::createWindow: Unable to set opacity ", result); + return false; + } + + result = window->SetStackingClass(window, DWSC_UPPER); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::createWindow: Unable to set stacking class ", result); + return false; + } + + result = window->RaiseToTop(window); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::createWindow: Unable to raise window ", result); + return false; + } + + return true; } +#endif void QDirectFBScreenCursor::move(int x, int y) { + pos = QPoint(x, y); +#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR + if (window) { + const QPoint p = pos - hotspot; + DFBResult result = window->MoveTo(window, p.x(), p.y()); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::move: Unable to move window", result); + } + } +#else layer->WarpCursor(layer, x, y); +#endif } void QDirectFBScreenCursor::hide() @@ -579,6 +657,7 @@ void QDirectFBScreenCursor::hide() if (enable) { enable = false; DFBResult result; +#ifndef QT_DIRECTFB_WINDOW_AS_CURSOR result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); if (result != DFB_OK) { DirectFBError("QDirectFBScreenCursor::hide: " @@ -594,6 +673,15 @@ void QDirectFBScreenCursor::hide() DirectFBError("QDirectFBScreenCursor::hide: " "Unable to set cooperative level", result); } +#else + if (window) { + result = window->SetOpacity(window, 0); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::hide: " + "Unable to set window opacity", result); + } + } +#endif } } @@ -607,7 +695,13 @@ void QDirectFBScreenCursor::show() DirectFBError("QDirectFBScreenCursor::show: " "Unable to set cooperative level", result); } - result = layer->SetCursorOpacity(layer, 255); + result = layer->SetCursorOpacity(layer, +#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR + 0 +#else + 255 +#endif + ); if (result != DFB_OK) { DirectFBError("QDirectFBScreenCursor::show: " "Unable to set cursor shape", result); @@ -617,6 +711,15 @@ void QDirectFBScreenCursor::show() DirectFBError("QDirectFBScreenCursor::show: " "Unable to set cooperative level", result); } +#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR + if (window) { + DFBResult result = window->SetOpacity(window, 255); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set window opacity", result); + } + } +#endif } } @@ -633,12 +736,15 @@ void QDirectFBScreenCursor::set(const QImage &image, int hotx, int hoty) cursor = image.convertToFormat(screen->alphaPixmapFormat()); size = cursor.size(); hotspot = QPoint(hotx, hoty); - IDirectFBSurface *surface = screen->createDFBSurface(cursor, QDirectFBScreen::DontTrackSurface); + DFBResult result = DFB_OK; + IDirectFBSurface *surface = screen->createDFBSurface(cursor, screen->alphaPixmapFormat(), + QDirectFBScreen::DontTrackSurface, &result); if (!surface) { - qWarning("QDirectFBScreenCursor::set: Unable to create surface"); + DirectFBError("QDirectFBScreenCursor::set: Unable to create surface", result); return; } - DFBResult result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); +#ifndef QT_DIRECTFB_WINDOW_AS_CURSOR + result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); if (result != DFB_OK) { DirectFBError("QDirectFBScreenCursor::show: " "Unable to set cooperative level", result); @@ -648,28 +754,72 @@ void QDirectFBScreenCursor::set(const QImage &image, int hotx, int hoty) DirectFBError("QDirectFBScreenCursor::show: " "Unable to set cursor shape", result); } - surface->Release(surface); result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); if (result != DFB_OK) { DirectFBError("QDirectFBScreenCursor::show: " "Unable to set cooperative level", result); } +#else + if (window || createWindow()) { + QSize windowSize; + result = window->GetSize(window, &windowSize.rwidth(), &windowSize.rheight()); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::set: " + "Unable to get window size", result); + } + result = window->Resize(window, size.width(), size.height()); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::set: Unable to resize window", result); + } + + IDirectFBSurface *windowSurface; + result = window->GetSurface(window, &windowSurface); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::set: Unable to get window surface", result); + } else { + result = windowSurface->Clear(windowSurface, 0, 0, 0, 0); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::set: Unable to clear surface", result); + } + + result = windowSurface->Blit(windowSurface, surface, 0, 0, 0); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::set: Unable to blit to surface", result); + } + } + result = windowSurface->Flip(windowSurface, 0, DSFLIP_NONE); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::set: Unable to flip window", result); + } + + windowSurface->Release(windowSurface); + } +#endif + surface->Release(surface); show(); } } -#endif // QT_NO_DIRECTFB_LAYER +#endif // QT_DIRECTFB_CURSOR QDirectFBScreen::QDirectFBScreen(int display_id) : QScreen(display_id, DirectFBClass), d_ptr(new QDirectFBScreenPrivate(this)) { + QDirectFBScreenPrivate::instance = this; } QDirectFBScreen::~QDirectFBScreen() { + if (QDirectFBScreenPrivate::instance == this) + QDirectFBScreenPrivate::instance = 0; delete d_ptr; } +QDirectFBScreen *QDirectFBScreen::instance() +{ + return QDirectFBScreenPrivate::instance; +} + int QDirectFBScreen::depth(DFBSurfacePixelFormat format) { switch (format) { @@ -713,6 +863,42 @@ int QDirectFBScreen::depth(DFBSurfacePixelFormat format) return 0; } +int QDirectFBScreen::depth(QImage::Format format) +{ + int depth = 0; + switch(format) { + case QImage::Format_Invalid: + case QImage::NImageFormats: + Q_ASSERT(false); + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + depth = 1; + break; + case QImage::Format_Indexed8: + depth = 8; + break; + case QImage::Format_RGB32: + case QImage::Format_ARGB32: + case QImage::Format_ARGB32_Premultiplied: + depth = 32; + break; + case QImage::Format_RGB555: + case QImage::Format_RGB16: + case QImage::Format_RGB444: + case QImage::Format_ARGB4444_Premultiplied: + depth = 16; + break; + case QImage::Format_RGB666: + case QImage::Format_ARGB6666_Premultiplied: + case QImage::Format_ARGB8565_Premultiplied: + case QImage::Format_ARGB8555_Premultiplied: + case QImage::Format_RGB888: + depth = 24; + break; + } + return depth; +} + void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args) { QRegExp flipRegexp(QLatin1String("^flip=([\\w,]*)$")); @@ -739,6 +925,18 @@ void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args) } } +#ifdef QT_DIRECTFB_WM +void QDirectFBScreenPrivate::onWindowEvent(QWSWindow *window, QWSServer::WindowEvent event) +{ + if (event == QWSServer::Raise) { + QWSWindowSurface *windowSurface = window->windowSurface(); + if (windowSurface && windowSurface->key() == QLatin1String("directfb")) { + static_cast<QDirectFBWindowSurface*>(windowSurface)->raise(); + } + } +} +#endif + QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType type) const { if (type == QPixmapData::BitmapType) @@ -747,6 +945,7 @@ QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType typ return new QDirectFBPixmapData(q, type); } +#if (Q_DIRECTFB_VERSION >= 0x000923) #ifdef QT_NO_DEBUG struct FlagDescription; static const FlagDescription *accelerationDescriptions = 0; @@ -804,9 +1003,6 @@ static const FlagDescription drawDescriptions[] = { }; #endif - - -#if (Q_DIRECTFB_VERSION >= 0x000923) static const QByteArray flagDescriptions(uint mask, const FlagDescription *flags) { #ifdef QT_NO_DEBUG @@ -846,9 +1042,9 @@ static void printDirectFBInfo(IDirectFB *fb, IDirectFBSurface *primarySurface) dev.name, dev.vendor, dev.driver.name, dev.driver.major, dev.driver.minor, dev.driver.vendor, DFB_PIXELFORMAT_INDEX(pixelFormat), QDirectFBScreen::getImageFormat(primarySurface), dev.acceleration_mask, - ::flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(), - dev.blitting_flags, ::flagDescriptions(dev.blitting_flags, blitDescriptions).constData(), - dev.drawing_flags, ::flagDescriptions(dev.drawing_flags, drawDescriptions).constData(), + flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(), + dev.blitting_flags, flagDescriptions(dev.blitting_flags, blitDescriptions).constData(), + dev.drawing_flags, flagDescriptions(dev.drawing_flags, drawDescriptions).constData(), (dev.video_memory >> 10)); } #endif @@ -856,7 +1052,7 @@ static void printDirectFBInfo(IDirectFB *fb, IDirectFBSurface *primarySurface) static inline bool setIntOption(const QStringList &arguments, const QString &variable, int *value) { Q_ASSERT(value); - QRegExp rx(QString("%1=?(\\d+)").arg(variable)); + QRegExp rx(QString::fromLatin1("%1=?(\\d+)").arg(variable)); rx.setCaseSensitivity(Qt::CaseInsensitive); if (arguments.indexOf(rx) != -1) { *value = rx.cap(1).toInt(); @@ -865,6 +1061,26 @@ static inline bool setIntOption(const QStringList &arguments, const QString &var return false; } +static inline QColor colorFromName(const QString &name) +{ + QRegExp rx("#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])"); + rx.setCaseSensitivity(Qt::CaseInsensitive); + if (rx.exactMatch(name)) { + Q_ASSERT(rx.numCaptures() == 4); + int ints[4]; + int i; + for (i=0; i<4; ++i) { + bool ok; + ints[i] = rx.cap(i + 1).toUInt(&ok, 16); + if (!ok || ints[i] > 255) + break; + } + if (i == 4) + return QColor(ints[0], ints[1], ints[2], ints[3]); + } + return QColor(name); +} + bool QDirectFBScreen::connect(const QString &displaySpec) { DFBResult result = DFB_OK; @@ -914,7 +1130,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) #ifdef QT_DIRECTFB_IMAGECACHE int imageCacheSize = 4 * 1024 * 1024; // 4 MB - ::setIntOption(displayArgs, QLatin1String("imagecachesize"), &imageCacheSize); + setIntOption(displayArgs, QLatin1String("imagecachesize"), &imageCacheSize); QDirectFBPaintEngine::initImageCache(imageCacheSize); #endif @@ -925,7 +1141,9 @@ bool QDirectFBScreen::connect(const QString &displaySpec) DFBSurfaceDescription description; memset(&description, 0, sizeof(DFBSurfaceDescription)); + IDirectFBSurface *surface; +#ifdef QT_NO_DIRECTFB_WM description.flags = DSDESC_CAPS; if (::setIntOption(displayArgs, QLatin1String("width"), &description.width)) description.flags |= DSDESC_WIDTH; @@ -954,17 +1172,28 @@ bool QDirectFBScreen::connect(const QString &displaySpec) } // We don't track the primary surface as it's released in disconnect - d_ptr->dfbSurface = createDFBSurface(description, DontTrackSurface); - if (!d_ptr->dfbSurface) { + d_ptr->primarySurface = createDFBSurface(description, DontTrackSurface, &result); + if (!d_ptr->primarySurface) { DirectFBError("QDirectFBScreen: error creating primary surface", result); return false; } + surface = d_ptr->primarySurface; +#else + description.flags = DSDESC_WIDTH|DSDESC_HEIGHT; + description.width = description.height = 1; + surface = createDFBSurface(description, DontTrackSurface, &result); + if (!surface) { + DirectFBError("QDirectFBScreen: error creating surface", result); + return false; + } +#endif // Work out what format we're going to use for surfaces with an alpha channel - d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(d_ptr->dfbSurface); - setPixelFormat(d_ptr->alphaPixmapFormat); - switch (d_ptr->alphaPixmapFormat) { + QImage::Format pixelFormat = QDirectFBScreen::getImageFormat(surface); + d_ptr->alphaPixmapFormat = pixelFormat; + + switch (pixelFormat) { case QImage::Format_RGB666: d_ptr->alphaPixmapFormat = QImage::Format_ARGB6666_Premultiplied; break; @@ -972,9 +1201,9 @@ bool QDirectFBScreen::connect(const QString &displaySpec) d_ptr->alphaPixmapFormat = QImage::Format_ARGB4444_Premultiplied; break; case QImage::Format_RGB32: - qWarning("QDirectFBScreen::connect(). Qt/DirectFB does not work with the RGB32 pixelformat. " - "We recommmend using ARGB instead"); - return false; + pixelFormat = d_ptr->alphaPixmapFormat = QImage::Format_ARGB32_Premultiplied; + // ### Format_RGB32 doesn't work so well with Qt. Force ARGB32 for windows/pixmaps + break; case QImage::Format_Indexed8: qWarning("QDirectFBScreen::connect(). Qt/DirectFB does not work with the LUT8 pixelformat."); return false; @@ -996,31 +1225,38 @@ bool QDirectFBScreen::connect(const QString &displaySpec) // works already break; } - d_ptr->dfbSurface->GetSize(d_ptr->dfbSurface, &w, &h); - + setPixelFormat(pixelFormat); + QScreen::d = QDirectFBScreen::depth(pixelFormat); data = 0; lstep = 0; size = 0; - dw = w; - dh = h; - - DFBSurfacePixelFormat format; - result = d_ptr->dfbSurface->GetPixelFormat(d_ptr->dfbSurface, &format); - if (result == DFB_OK) - QScreen::d = depth(format); - else - DirectFBError("QDirectFBScreen: error getting surface format", result); - setPixelFormat(getImageFormat(d_ptr->dfbSurface)); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen::connect: " + "Unable to get screen!", result); + return false; + } + const QString qws_size = QString::fromLatin1(qgetenv("QWS_SIZE")); + if (!qws_size.isEmpty()) { + QRegExp rx(QLatin1String("(\\d+)x(\\d+)")); + if (!rx.exactMatch(qws_size)) { + qWarning("QDirectFBScreen::connect: Can't parse QWS_SIZE=\"%s\"", qPrintable(qws_size)); + } else { + int *ints[2] = { &w, &h }; + for (int i=0; i<2; ++i) { + *ints[i] = rx.cap(i + 1).toInt(); + if (*ints[i] <= 0) { + qWarning("QDirectFBScreen::connect: %s is not a positive integer", + qPrintable(rx.cap(i + 1))); + w = h = 0; + break; + } + } + } + } - physWidth = physHeight = -1; - ::setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth); - ::setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight); - const int dpi = 72; - if (physWidth < 0) - physWidth = qRound(dw * 25.4 / dpi); - if (physHeight < 0) - physHeight = qRound(dh * 25.4 / dpi); + setIntOption(displayArgs, QLatin1String("width"), &w); + setIntOption(displayArgs, QLatin1String("height"), &h); #ifndef QT_NO_DIRECTFB_LAYER result = d_ptr->dfb->GetDisplayLayer(d_ptr->dfb, DLID_PRIMARY, @@ -1034,34 +1270,108 @@ bool QDirectFBScreen::connect(const QString &displaySpec) #else result = d_ptr->dfb->GetScreen(d_ptr->dfb, 0, &d_ptr->dfbScreen); #endif - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen::connect: " - "Unable to get screen!", result); + + if (w <= 0 || h <= 0) { +#ifdef QT_NO_DIRECTFB_WM + result = d_ptr->primarySurface->GetSize(d_ptr->primarySurface, &w, &h); +#elif (Q_DIRECTFB_VERSION >= 0x010000) + result = d_ptr->dfbScreen->GetSize(d_ptr->dfbScreen, &w, &h); +#else + qWarning("QDirectFBScreen::connect: DirectFB versions prior to 1.0 do not offer a way\n" + "query the size of the primary surface in windowed mode. You have to specify\n" + "the size of the display using QWS_SIZE=[0-9]x[0-9] or\n" + "QWS_DISPLAY=directfb:width=[0-9]:height=[0-9]"); return false; +#endif + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen::connect: " + "Unable to get screen size!", result); + return false; + } } + + dw = w; + dh = h; + + Q_ASSERT(dw != 0 && dh != 0); + + physWidth = physHeight = -1; + setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth); + setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight); + const int dpi = 72; + if (physWidth < 0) + physWidth = qRound(dw * 25.4 / dpi); + if (physHeight < 0) + physHeight = qRound(dh * 25.4 / dpi); + setGraphicsSystem(d_ptr); #if (Q_DIRECTFB_VERSION >= 0x000923) if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive)) - printDirectFBInfo(d_ptr->dfb, d_ptr->dfbSurface); + printDirectFBInfo(d_ptr->dfb, surface); +#endif +#ifdef QT_DIRECTFB_WM + surface->Release(surface); + QColor backgroundColor; +#else + QColor &backgroundColor = d_ptr->backgroundColor; #endif - QRegExp backgroundColorRegExp("bgcolor=?(.+)"); + QRegExp backgroundColorRegExp(QLatin1String("bgcolor=(.+)")); backgroundColorRegExp.setCaseSensitivity(Qt::CaseInsensitive); if (displayArgs.indexOf(backgroundColorRegExp) != -1) { - d_ptr->backgroundColor.setNamedColor(backgroundColorRegExp.cap(1)); + backgroundColor = colorFromName(backgroundColorRegExp.cap(1)); + } +#ifdef QT_NO_DIRECTFB_WM + if (!backgroundColor.isValid()) + backgroundColor = Qt::green; + d_ptr->primarySurface->Clear(d_ptr->primarySurface, backgroundColor.red(), + backgroundColor.green(), backgroundColor.blue(), + backgroundColor.alpha()); + d_ptr->primarySurface->Flip(d_ptr->primarySurface, 0, d_ptr->flipFlags); +#else + if (backgroundColor.isValid()) { + DFBResult result = d_ptr->dfbLayer->SetCooperativeLevel(d_ptr->dfbLayer, DLSCL_ADMINISTRATIVE); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen::connect " + "Unable to set cooperative level", result); + } + result = d_ptr->dfbLayer->SetBackgroundColor(d_ptr->dfbLayer, backgroundColor.red(), backgroundColor.green(), + backgroundColor.blue(), backgroundColor.alpha()); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::connect: " + "Unable to set background color", result); + } + + result = d_ptr->dfbLayer->SetBackgroundMode(d_ptr->dfbLayer, DLBM_COLOR); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::connect: " + "Unable to set background mode", result); + } + + result = d_ptr->dfbLayer->SetCooperativeLevel(d_ptr->dfbLayer, DLSCL_SHARED); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen::connect " + "Unable to set cooperative level", result); + } + } - if (!d_ptr->backgroundColor.isValid()) - d_ptr->backgroundColor = Qt::green; +#endif return true; } void QDirectFBScreen::disconnect() { - d_ptr->dfbSurface->Release(d_ptr->dfbSurface); - d_ptr->dfbSurface = 0; +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + if (d_ptr->imageProvider) + d_ptr->imageProvider->Release(d_ptr->imageProvider); +#endif +#ifdef QT_NO_DIRECTFB_WM + d_ptr->primarySurface->Release(d_ptr->primarySurface); + d_ptr->primarySurface = 0; +#endif foreach (IDirectFBSurface *surf, d_ptr->allocatedSurfaces) surf->Release(surf); @@ -1094,12 +1404,10 @@ bool QDirectFBScreen::initDevice() } #endif -#ifndef QT_NO_QWS_CURSOR -#if defined QT_NO_DIRECTFB_WM || defined QT_NO_DIRECTFB_LAYER - QScreenCursor::initSoftwareCursor(); -#else +#ifdef QT_DIRECTFB_CURSOR qt_screencursor = new QDirectFBScreenCursor; -#endif +#elif !defined QT_NO_QWS_CURSOR + QScreenCursor::initSoftwareCursor(); #endif return true; } @@ -1153,115 +1461,168 @@ QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const return QScreen::createSurface(key); } -// Normally, when using DirectFB to compose the windows (I.e. when -// QT_NO_DIRECTFB_WM isn't set), exposeRegion will simply return. If -// QT_NO_DIRECTFB_WM is set, exposeRegion will compose only non-directFB -// window surfaces. Normal, directFB surfaces are handled by DirectFB. -static inline bool needExposeRegion() +#if defined QT_NO_DIRECTFB_WM +struct PaintCommand { + PaintCommand() : dfbSurface(0), windowOpacity(255), blittingFlags(DSBLIT_NOFX) {} + IDirectFBSurface *dfbSurface; + QImage image; + QPoint windowPosition; + QRegion source; + quint8 windowOpacity; + DFBSurfaceBlittingFlags blittingFlags; +}; + +static inline void initParameters(DFBRectangle &source, const QRect &sourceGlobal, const QPoint &pos) { -#ifdef QT_NO_DIRECTFB_WM - return true; -#endif -#ifdef QT_NO_DIRECTFB_LAYER -#ifndef QT_NO_QWS_CURSOR - return true; -#endif -#endif - return false; + source.x = sourceGlobal.x() - pos.x(); + source.y = sourceGlobal.y() - pos.y(); + source.w = sourceGlobal.width(); + source.h = sourceGlobal.height(); } +#endif -void QDirectFBScreen::exposeRegion(QRegion r, int changing) +void QDirectFBScreen::exposeRegion(QRegion r, int) { - if (!needExposeRegion()) { + Q_UNUSED(r); +#if defined QT_NO_DIRECTFB_WM + + r &= region(); + if (r.isEmpty()) { return; } + r = r.boundingRect(); + IDirectFBSurface *primary = d_ptr->primarySurface; const QList<QWSWindow*> windows = QWSServer::instance()->clientWindows(); - if (changing < 0 || changing >= windows.size()) - return; + QVarLengthArray<PaintCommand, 4> commands(windows.size()); + QRegion region = r; + int idx = 0; + for (int i=0; i<windows.size(); ++i) { + QWSWindowSurface *surface = windows.at(i)->windowSurface(); + if (!surface) + continue; + + const QRect windowGeometry = surface->geometry(); + const QRegion intersection = region & windowGeometry; + if (intersection.isEmpty()) { + continue; + } + PaintCommand &cmd = commands[idx]; - QWSWindow *win = windows.at(changing); - QWSWindowSurface *s = win->windowSurface(); - r &= region(); - if (r.isEmpty()) - return; + if (surface->key() == QLatin1String("directfb")) { + const QDirectFBWindowSurface *ws = static_cast<QDirectFBWindowSurface*>(surface); + cmd.dfbSurface = ws->directFBSurface(); + + if (!cmd.dfbSurface) { + continue; + } + } else { + cmd.image = surface->image(); + if (cmd.image.isNull()) { + continue; + } + } + ++idx; + + cmd.windowPosition = windowGeometry.topLeft(); + cmd.source = intersection; + if (windows.at(i)->isOpaque()) { + region -= intersection; + if (region.isEmpty()) + break; + } else { + cmd.windowOpacity = windows.at(i)->opacity(); + cmd.blittingFlags = cmd.windowOpacity == 255 + ? DSBLIT_BLEND_ALPHACHANNEL + : (DSBLIT_BLEND_ALPHACHANNEL|DSBLIT_BLEND_COLORALPHA); + } + } + if (!region.isEmpty()) { + solidFill(d_ptr->backgroundColor, region); + } - const QRect brect = r.boundingRect(); + while (idx > 0) { + const PaintCommand &cmd = commands[--idx]; + Q_ASSERT(cmd.dfbSurface || !cmd.image.isNull()); + IDirectFBSurface *surface; + if (cmd.dfbSurface) { + surface = cmd.dfbSurface; + } else { + Q_ASSERT(!cmd.image.isNull()); + DFBResult result; + surface = createDFBSurface(cmd.image, cmd.image.format(), DontTrackSurface, &result); + Q_ASSERT((result != DFB_OK) == !surface); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen::exposeRegion: Can't create surface from image", result); + continue; + } + } - if (!s) { - solidFill(d_ptr->backgroundColor, r); - } else { - const QRect windowGeometry = s->geometry(); - const QRegion outsideWindow = r.subtracted(windowGeometry); - if (!outsideWindow.isEmpty()) { - solidFill(d_ptr->backgroundColor, outsideWindow); + primary->SetBlittingFlags(primary, cmd.blittingFlags); + if (cmd.blittingFlags & DSBLIT_BLEND_COLORALPHA) { + primary->SetColor(primary, 0xff, 0xff, 0xff, cmd.windowOpacity); } - const QRegion insideWindow = r.intersected(windowGeometry); - if (!insideWindow.isEmpty()) { - QDirectFBWindowSurface *dfbWindowSurface = (s->key() == QLatin1String("directfb")) - ? static_cast<QDirectFBWindowSurface*>(s) : 0; - if (dfbWindowSurface) { - IDirectFBSurface *surface = dfbWindowSurface->directFBSurface(); - const int n = insideWindow.numRects(); - if (n == 1 || d_ptr->directFBFlags & BoundingRectFlip) { - const QRect source = (insideWindow.boundingRect().intersected(windowGeometry)).translated(-windowGeometry.topLeft()); - const DFBRectangle rect = { - source.x(), source.y(), source.width(), source.height() - }; - d_ptr->dfbSurface->Blit(d_ptr->dfbSurface, surface, &rect, - windowGeometry.x() + source.x(), - windowGeometry.y() + source.y()); - } else { - const QVector<QRect> rects = insideWindow.rects(); - QVarLengthArray<DFBRectangle, 16> dfbRectangles(n); - QVarLengthArray<DFBPoint, 16> dfbPoints(n); - - for (int i=0; i<n; ++i) { - const QRect source = (rects.at(i).intersected(windowGeometry)).translated(-windowGeometry.topLeft()); - DFBRectangle &rect = dfbRectangles[i]; - rect.x = source.x(); - rect.y = source.y(); - rect.w = source.width(); - rect.h = source.height(); - dfbPoints[i].x = (windowGeometry.x() + source.x()); - dfbPoints[i].y = (windowGeometry.y() + source.y()); - } - d_ptr->dfbSurface->BatchBlit(d_ptr->dfbSurface, surface, dfbRectangles.constData(), - dfbPoints.constData(), n); - } + const QRegion ®ion = cmd.source; + const int rectCount = region.numRects(); + DFBRectangle source; + if (rectCount == 1) { + ::initParameters(source, region.boundingRect(), cmd.windowPosition); + primary->Blit(primary, surface, &source, cmd.windowPosition.x() + source.x, cmd.windowPosition.y() + source.y); + } else { + const QVector<QRect> rects = region.rects(); + for (int i=0; i<rectCount; ++i) { + ::initParameters(source, rects.at(i), cmd.windowPosition); + primary->Blit(primary, surface, &source, cmd.windowPosition.x() + source.x, cmd.windowPosition.y() + source.y); } } + if (surface != cmd.dfbSurface) { + surface->Release(surface); + } } + primary->SetColor(primary, 0xff, 0xff, 0xff, 0xff); + +#if defined QT_NO_DIRECTFB_CURSOR and !defined QT_NO_QWS_CURSOR if (QScreenCursor *cursor = QScreenCursor::instance()) { const QRect cursorRectangle = cursor->boundingRect(); - if (cursor->isVisible() && !cursor->isAccelerated() && cursorRectangle.intersects(brect)) { + if (cursor->isVisible() && !cursor->isAccelerated() && r.intersects(cursorRectangle)) { const QImage image = cursor->image(); - IDirectFBSurface *surface = createDFBSurface(image, QDirectFBScreen::DontTrackSurface); - d_ptr->dfbSurface->SetBlittingFlags(d_ptr->dfbSurface, DSBLIT_BLEND_ALPHACHANNEL); - d_ptr->dfbSurface->Blit(d_ptr->dfbSurface, surface, 0, cursorRectangle.x(), cursorRectangle.y()); - surface->Release(surface); -#if (Q_DIRECTFB_VERSION >= 0x010000) - d_ptr->dfbSurface->ReleaseSource(d_ptr->dfbSurface); -#endif + if (image.cacheKey() != d_ptr->cursorImageKey) { + if (d_ptr->cursorSurface) { + releaseDFBSurface(d_ptr->cursorSurface); + } + d_ptr->cursorSurface = createDFBSurface(image, image.format(), QDirectFBScreen::TrackSurface); + d_ptr->cursorImageKey = image.cacheKey(); + } + + Q_ASSERT(d_ptr->cursorSurface); + primary->SetBlittingFlags(primary, DSBLIT_BLEND_ALPHACHANNEL); + primary->Blit(primary, d_ptr->cursorSurface, 0, cursorRectangle.x(), cursorRectangle.y()); } } - flipSurface(d_ptr->dfbSurface, d_ptr->flipFlags, r, QPoint()); +#endif + flipSurface(primary, d_ptr->flipFlags, r, QPoint()); + primary->SetBlittingFlags(primary, DSBLIT_NOFX); +#endif } void QDirectFBScreen::solidFill(const QColor &color, const QRegion ®ion) { +#ifdef QT_DIRECTFB_WM + Q_UNUSED(color); + Q_UNUSED(region); +#else if (region.isEmpty()) return; - d_ptr->dfbSurface->SetColor(d_ptr->dfbSurface, - color.red(), color.green(), color.blue(), - color.alpha()); + d_ptr->primarySurface->SetColor(d_ptr->primarySurface, + color.red(), color.green(), color.blue(), + color.alpha()); const int n = region.numRects(); - if (n > 1) { + if (n == 1) { const QRect r = region.boundingRect(); - d_ptr->dfbSurface->FillRectangle(d_ptr->dfbSurface, r.x(), r.y(), r.width(), r.height()); + d_ptr->primarySurface->FillRectangle(d_ptr->primarySurface, r.x(), r.y(), r.width(), r.height()); } else { const QVector<QRect> rects = region.rects(); QVarLengthArray<DFBRectangle, 32> rectArray(n); @@ -1272,13 +1633,9 @@ void QDirectFBScreen::solidFill(const QColor &color, const QRegion ®ion) rectArray[i].w = r.width(); rectArray[i].h = r.height(); } - d_ptr->dfbSurface->FillRectangles(d_ptr->dfbSurface, rectArray.constData(), n); + d_ptr->primarySurface->FillRectangles(d_ptr->primarySurface, rectArray.constData(), n); } -} - -void QDirectFBScreen::erase(const QRegion ®ion) -{ - solidFill(d_ptr->backgroundColor, region); +#endif } QImage::Format QDirectFBScreen::alphaPixmapFormat() const @@ -1305,10 +1662,10 @@ bool QDirectFBScreen::initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *d return true; } -uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, uint flags, int *bpl) +uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl) { void *mem; - const DFBResult result = surface->Lock(surface, static_cast<DFBSurfaceLockFlags>(flags), static_cast<void**>(&mem), bpl); + const DFBResult result = surface->Lock(surface, flags, &mem, bpl); if (result != DFB_OK) { DirectFBError("QDirectFBScreen::lockSurface()", result); } @@ -1343,4 +1700,91 @@ void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags } } +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE +void QDirectFBScreen::setDirectFBImageProvider(IDirectFBImageProvider *provider) +{ + Q_ASSERT(provider); + if (d_ptr->imageProvider) + d_ptr->imageProvider->Release(d_ptr->imageProvider); + d_ptr->imageProvider = provider; +} +#endif + +void QDirectFBScreen::waitIdle() +{ + d_ptr->dfb->WaitIdle(d_ptr->dfb); +} + +#ifdef QT_DIRECTFB_WM +IDirectFBWindow *QDirectFBScreen::windowForWidget(const QWidget *widget) const +{ + if (widget) { + const QWSWindowSurface *surface = static_cast<const QWSWindowSurface*>(widget->windowSurface()); + if (surface && surface->key() == QLatin1String("directfb")) { + return static_cast<const QDirectFBWindowSurface*>(surface)->directFBWindow(); + } + } + return 0; +} +#endif + +IDirectFBSurface * QDirectFBScreen::surfaceForWidget(const QWidget *widget, QRect *rect) const +{ + Q_ASSERT(widget); + if (!widget->isVisible() || widget->size().isNull()) + return 0; + + const QWSWindowSurface *surface = static_cast<const QWSWindowSurface*>(widget->windowSurface()); + if (surface && surface->key() == QLatin1String("directfb")) { + return static_cast<const QDirectFBWindowSurface*>(surface)->surfaceForWidget(widget, rect); + } + return 0; +} + +#ifdef QT_DIRECTFB_SUBSURFACE +IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, const QRect &area) const +{ + Q_ASSERT(widget); + QRect rect; + IDirectFBSurface *surface = surfaceForWidget(widget, &rect); + IDirectFBSurface *subSurface = 0; + if (surface) { + if (!area.isNull()) + rect &= area.translated(widget->mapTo(widget->window(), QPoint(0, 0))); + if (!rect.isNull()) { + const DFBRectangle subRect = { rect.x(), rect.y(), rect.width(), rect.height() }; + const DFBResult result = surface->GetSubSurface(surface, &subRect, &subSurface); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen::subSurface(): Can't get sub surface", result); + } + } + } + return subSurface; +} +#endif + +#ifndef QT_DIRECTFB_PLUGIN +Q_GUI_EXPORT IDirectFBSurface *qt_directfb_surface_for_widget(const QWidget *widget, QRect *rect) +{ + return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->surfaceForWidget(widget, rect) : 0; +} +#ifdef QT_DIRECTFB_SUBSURFACE +Q_GUI_EXPORT IDirectFBSurface *qt_directfb_subsurface_for_widget(const QWidget *widget, const QRect &area) +{ + return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->subSurfaceForWidget(widget, area) : 0; +} +#endif +#ifdef QT_DIRECTFB_WM +Q_GUI_EXPORT IDirectFBWindow *qt_directfb_window_for_widget(const QWidget *widget) +{ + return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->windowForWidget(widget) : 0; +} + +#endif +#endif + +QT_END_NAMESPACE + +#include "qdirectfbscreen.moc" +#endif // QT_NO_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index c1f15b6..6330582 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -42,15 +42,75 @@ #ifndef QDIRECTFBSCREEN_H #define QDIRECTFBSCREEN_H +#include <qglobal.h> +#ifndef QT_NO_QWS_DIRECTFB #include <QtGui/qscreen_qws.h> #include <directfb.h> #include <directfb_version.h> QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) -#define Q_DIRECTFB_VERSION ((DIRECTFB_MAJOR_VERSION << 16) | (DIRECTFB_MINOR_VERION << 8) | DIRECTFB_MICRO_VERSION) +#if !defined QT_DIRECTFB_SUBSURFACE && !defined QT_NO_DIRECTFB_SUBSURFACE +#define QT_NO_DIRECTFB_SUBSURFACE +#endif +#if !defined QT_NO_DIRECTFB_LAYER && !defined QT_DIRECTFB_LAYER +#define QT_DIRECTFB_LAYER +#endif +#if !defined QT_NO_DIRECTFB_WM && !defined QT_DIRECTFB_WM +#define QT_DIRECTFB_WM +#endif +#if !defined QT_DIRECTFB_IMAGECACHE && !defined QT_NO_DIRECTFB_IMAGECACHE +#define QT_NO_DIRECTFB_IMAGECACHE +#endif +#if !defined QT_NO_DIRECTFB_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER +#define QT_DIRECTFB_IMAGEPROVIDER +#endif +#if !defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && !defined QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE +#define QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE +#endif +#if !defined QT_DIRECTFB_WINDOW_AS_CURSOR && !defined QT_NO_DIRECTFB_WINDOW_AS_CURSOR +#define QT_NO_DIRECTFB_WINDOW_AS_CURSOR +#endif +#if !defined QT_DIRECTFB_PALETTE && !defined QT_NO_DIRECTFB_PALETTE +#define QT_NO_DIRECTFB_PALETTE +#endif +#if !defined QT_NO_DIRECTFB_PREALLOCATED && !defined QT_DIRECTFB_PREALLOCATED +#define QT_DIRECTFB_PREALLOCATED +#endif +#if !defined QT_NO_DIRECTFB_MOUSE && !defined QT_DIRECTFB_MOUSE +#define QT_DIRECTFB_MOUSE +#endif +#if !defined QT_NO_DIRECTFB_KEYBOARD && !defined QT_DIRECTFB_KEYBOARD +#define QT_DIRECTFB_KEYBOARD +#endif +#if !defined QT_NO_DIRECTFB_OPAQUE_DETECTION && !defined QT_DIRECTFB_OPAQUE_DETECTION +#define QT_DIRECTFB_OPAQUE_DETECTION +#endif +#ifndef QT_NO_QWS_CURSOR +#if defined QT_DIRECTFB_WM && defined QT_DIRECTFB_WINDOW_AS_CURSOR +#define QT_DIRECTFB_CURSOR +#elif defined QT_DIRECTFB_LAYER +#define QT_DIRECTFB_CURSOR +#endif +#endif +#ifndef QT_DIRECTFB_CURSOR +#define QT_NO_DIRECTFB_CURSOR +#endif +#if defined QT_NO_DIRECTFB_LAYER && defined QT_DIRECTFB_WM +#error QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM +#endif +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && defined QT_NO_DIRECTFB_IMAGEPROVIDER +#error QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE requires QT_DIRECTFB_IMAGEPROVIDER to be defined +#endif +#if defined QT_DIRECTFB_WINDOW_AS_CURSOR && defined QT_NO_DIRECTFB_WM +#error QT_DIRECTFB_WINDOW_AS_CURSOR requires QT_DIRECTFB_WM to be defined +#endif + +#define Q_DIRECTFB_VERSION ((DIRECTFB_MAJOR_VERSION << 16) | (DIRECTFB_MINOR_VERSION << 8) | DIRECTFB_MICRO_VERSION) #define DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(F) \ static inline F operator~(F f) { return F(~int(f)); } \ @@ -61,6 +121,8 @@ QT_MODULE(Gui) DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBInputDeviceCapabilities); DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowDescriptionFlags); +DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowCapabilities); +DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowOptions); DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDescriptionFlags); DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceCapabilities); DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceLockFlags); @@ -92,7 +154,6 @@ public: void shutdownDevice(); void exposeRegion(QRegion r, int changing); - void scroll(const QRegion ®ion, const QPoint &offset); void solidFill(const QColor &color, const QRegion ®ion); void setMode(int width, int height, int depth); @@ -101,51 +162,67 @@ public: QWSWindowSurface *createSurface(QWidget *widget) const; QWSWindowSurface *createSurface(const QString &key) const; - static inline QDirectFBScreen *instance() { - QScreen *inst = QScreen::instance(); - Q_ASSERT(!inst || inst->classId() == QScreen::DirectFBClass); - return static_cast<QDirectFBScreen*>(inst); - } - + static QDirectFBScreen *instance(); + void waitIdle(); + IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const; +#ifdef QT_DIRECTFB_SUBSURFACE + IDirectFBSurface *subSurfaceForWidget(const QWidget *widget, const QRect &area = QRect()) const; +#endif IDirectFB *dfb(); - IDirectFBSurface *dfbSurface(); +#ifdef QT_DIRECTFB_WM + IDirectFBWindow *windowForWidget(const QWidget *widget) const; +#else + IDirectFBSurface *primarySurface(); +#endif #ifndef QT_NO_DIRECTFB_LAYER IDirectFBDisplayLayer *dfbDisplayLayer(); #endif // Track surface creation/release so we can release all on exit enum SurfaceCreationOption { - DontTrackSurface = 0, - TrackSurface = 1 + DontTrackSurface = 0x1, + TrackSurface = 0x2, + NoPreallocated = 0x4 }; Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption); IDirectFBSurface *createDFBSurface(const QImage &image, - SurfaceCreationOptions options); + QImage::Format format, + SurfaceCreationOptions options, + DFBResult *result = 0); IDirectFBSurface *createDFBSurface(const QSize &size, QImage::Format format, - SurfaceCreationOptions options); + SurfaceCreationOptions options, + DFBResult *result = 0); IDirectFBSurface *copyDFBSurface(IDirectFBSurface *src, QImage::Format format, - SurfaceCreationOptions options); - IDirectFBSurface *copyToDFBSurface(const QImage &image, - QImage::Format format, - SurfaceCreationOptions options); + SurfaceCreationOptions options, + DFBResult *result = 0); + IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc, + SurfaceCreationOptions options, + DFBResult *result); +#ifdef QT_DIRECTFB_SUBSURFACE + IDirectFBSurface *getSubSurface(IDirectFBSurface *surface, + const QRect &rect, + SurfaceCreationOptions options, + DFBResult *result); +#endif + void flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags, const QRegion ®ion, const QPoint &offset); void releaseDFBSurface(IDirectFBSurface *surface); - void erase(const QRegion ®ion); + using QScreen::depth; static int depth(DFBSurfacePixelFormat format); + static int depth(QImage::Format format); static DFBSurfacePixelFormat getSurfacePixelFormat(QImage::Format format); - static DFBSurfaceDescription getSurfaceDescription(const QImage &image); static DFBSurfaceDescription getSurfaceDescription(const uint *buffer, int length); static QImage::Format getImageFormat(IDirectFBSurface *surface); static bool initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description, QImage::Format format); static inline bool isPremultiplied(QImage::Format format); - static inline bool hasAlpha(DFBSurfacePixelFormat format); - static inline bool hasAlpha(IDirectFBSurface *surface); + static inline bool hasAlphaChannel(DFBSurfacePixelFormat format); + static inline bool hasAlphaChannel(IDirectFBSurface *surface); QImage::Format alphaPixmapFormat() const; #ifndef QT_NO_DIRECTFB_PALETTE @@ -153,12 +230,12 @@ public: const QImage &image); #endif - static uchar *lockSurface(IDirectFBSurface *surface, uint flags, int *bpl = 0); + static uchar *lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl = 0); +#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + void setDirectFBImageProvider(IDirectFBImageProvider *provider); +#endif private: - IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc, - SurfaceCreationOptions options); QDirectFBScreenPrivate *d_ptr; - friend class SurfaceCache; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions); @@ -179,7 +256,7 @@ inline bool QDirectFBScreen::isPremultiplied(QImage::Format format) return false; } -inline bool QDirectFBScreen::hasAlpha(DFBSurfacePixelFormat format) +inline bool QDirectFBScreen::hasAlphaChannel(DFBSurfacePixelFormat format) { switch (format) { case DSPF_ARGB1555: @@ -204,14 +281,18 @@ inline bool QDirectFBScreen::hasAlpha(DFBSurfacePixelFormat format) } } -inline bool QDirectFBScreen::hasAlpha(IDirectFBSurface *surface) +inline bool QDirectFBScreen::hasAlphaChannel(IDirectFBSurface *surface) { Q_ASSERT(surface); DFBSurfacePixelFormat format; surface->GetPixelFormat(surface, &format); - return QDirectFBScreen::hasAlpha(format); + return QDirectFBScreen::hasAlphaChannel(format); } +QT_END_NAMESPACE + QT_END_HEADER +#endif // QT_NO_QWS_DIRECTFB #endif // QDIRECTFBSCREEN_H + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp index 5cf6125..24e4599 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp @@ -43,6 +43,7 @@ #include <QtGui/qscreendriverplugin_qws.h> #include <QtCore/qstringlist.h> +#ifndef QT_NO_QWS_DIRECTFB class DirectFBScreenDriverPlugin : public QScreenDriverPlugin { @@ -73,3 +74,5 @@ QScreen* DirectFBScreenDriverPlugin::create(const QString& driver, } Q_EXPORT_PLUGIN2(qdirectfbscreen, DirectFBScreenDriverPlugin) + +#endif diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 046d481..3fbefc3 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -43,26 +43,27 @@ #include "qdirectfbscreen.h" #include "qdirectfbpaintengine.h" +#include <private/qwidget_p.h> #include <qwidget.h> #include <qwindowsystem_qws.h> #include <qpaintdevice.h> #include <qvarlengtharray.h> -//#define QT_DIRECTFB_DEBUG_SURFACES 1 +#ifndef QT_NO_QWS_DIRECTFB + +QT_BEGIN_NAMESPACE QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr) : QDirectFBPaintDevice(scr) + , sibling(0) #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) #endif - , engineHeight(-1) , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { #ifdef QT_NO_DIRECTFB_WM mode = Offscreen; -#else - mode = Window; #endif setSurfaceFlags(Opaque | Buffered); #ifdef QT_DIRECTFB_TIMING @@ -73,24 +74,30 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr, QWidget *widget) : QWSWindowSurface(widget), QDirectFBPaintDevice(scr) + , sibling(0) #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) #endif - , engineHeight(-1) , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { + SurfaceFlags flags = 0; + if (!widget || widget->window()->windowOpacity() == 0xff) + flags |= Opaque; +#ifdef QT_NO_DIRECTFB_WM if (widget && widget->testAttribute(Qt::WA_PaintOnScreen)) { - setSurfaceFlags(Opaque | RegionReserved); + flags = RegionReserved; mode = Primary; } else { -#ifdef QT_NO_DIRECTFB_WM mode = Offscreen; + flags = Buffered; + } #else - mode = Window; + noSystemBackground = widget && widget->testAttribute(Qt::WA_NoSystemBackground); + if (noSystemBackground) + flags &= ~Opaque; #endif - setSurfaceFlags(Opaque | Buffered); - } + setSurfaceFlags(flags); #ifdef QT_DIRECTFB_TIMING frames = 0; timer.start(); @@ -99,6 +106,8 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect QDirectFBWindowSurface::~QDirectFBWindowSurface() { + releaseSurface(); + // these are not tracked by QDirectFBScreen so we don't want QDirectFBPaintDevice to release it } bool QDirectFBWindowSurface::isValid() const @@ -106,42 +115,75 @@ bool QDirectFBWindowSurface::isValid() const return true; } -#ifndef QT_NO_DIRECTFB_WM -void QDirectFBWindowSurface::createWindow() +#ifdef QT_DIRECTFB_WM +void QDirectFBWindowSurface::raise() +{ + if (IDirectFBWindow *window = directFBWindow()) { + window->RaiseToTop(window); + } +} + +IDirectFBWindow *QDirectFBWindowSurface::directFBWindow() const +{ + return (dfbWindow ? dfbWindow : (sibling ? sibling->dfbWindow : 0)); +} + + +void QDirectFBWindowSurface::createWindow(const QRect &rect) { -#ifdef QT_NO_DIRECTFB_LAYER -#error QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM -#else IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer(); if (!layer) qFatal("QDirectFBWindowSurface: Unable to get primary display layer!"); DFBWindowDescription description; - description.caps = DWCAPS_NODECORATION; - description.flags = DWDESC_CAPS|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT; + memset(&description, 0, sizeof(DFBWindowDescription)); + + description.caps = DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER; + description.flags = DWDESC_CAPS|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY; +#if (Q_DIRECTFB_VERSION >= 0x010200) + description.flags |= DWDESC_OPTIONS; +#endif + + if (noSystemBackground) { + description.caps |= DWCAPS_ALPHACHANNEL; +#if (Q_DIRECTFB_VERSION >= 0x010200) + description.options |= DWOP_ALPHACHANNEL; +#endif + } + description.posx = rect.x(); + description.posy = rect.y(); + description.width = rect.width(); + description.height = rect.height(); description.surface_caps = DSCAPS_NONE; if (screen->directFBFlags() & QDirectFBScreen::VideoOnly) description.surface_caps |= DSCAPS_VIDEOONLY; - const QImage::Format format = screen->pixelFormat(); + const QImage::Format format = (noSystemBackground ? screen->alphaPixmapFormat() : screen->pixelFormat()); description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format); if (QDirectFBScreen::isPremultiplied(format)) description.surface_caps = DSCAPS_PREMULTIPLIED; DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow); + if (result != DFB_OK) DirectFBErrorFatal("QDirectFBWindowSurface::createWindow", result); - if (dfbSurface) - dfbSurface->Release(dfbSurface); + if (window()) { + DFBWindowID winid; + result = dfbWindow->GetID(dfbWindow, &winid); + if (result != DFB_OK) { + DirectFBError("QDirectFBWindowSurface::createWindow. Can't get ID", result); + } else { + window()->setProperty("_q_DirectFBWindowID", winid); + } + } + Q_ASSERT(!dfbSurface); dfbWindow->GetSurface(dfbWindow, &dfbSurface); -#endif + updateFormat(); } -#endif // QT_NO_DIRECTFB_WM -#ifndef QT_NO_DIRECTFB_WM -static DFBResult setGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const QRect &rect) +static DFBResult setWindowGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const QRect &rect) { DFBResult result = DFB_OK; const bool isMove = old.isEmpty() || rect.topLeft() != old.topLeft(); @@ -168,34 +210,52 @@ static DFBResult setGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const #endif return result; } -#endif +#endif // QT_NO_DIRECTFB_WM void QDirectFBWindowSurface::setGeometry(const QRect &rect) { - IDirectFBSurface *primarySurface = screen->dfbSurface(); - Q_ASSERT(primarySurface); + const QRect oldRect = geometry(); + if (oldRect == rect) + return; + + IDirectFBSurface *oldSurface = dfbSurface; + const bool sizeChanged = oldRect.size() != rect.size(); + if (sizeChanged) { + delete engine; + engine = 0; + releaseSurface(); + Q_ASSERT(!dfbSurface); + } + if (rect.isNull()) { #ifndef QT_NO_DIRECTFB_WM if (dfbWindow) { + if (window()) + window()->setProperty("_q_DirectFBWindowID", QVariant()); + dfbWindow->Release(dfbWindow); dfbWindow = 0; } #endif - if (dfbSurface) { - if (dfbSurface != primarySurface) { - dfbSurface->Release(dfbSurface); - } - dfbSurface = 0; + Q_ASSERT(!dfbSurface); +#ifdef QT_DIRECTFB_SUBSURFACE + Q_ASSERT(!subSurface); +#endif + } else { +#ifdef QT_DIRECTFB_WM + if (!dfbWindow) { + createWindow(rect); + } else { + setWindowGeometry(dfbWindow, oldRect, rect); + Q_ASSERT(!sizeChanged || !dfbSurface); + if (sizeChanged) + dfbWindow->GetSurface(dfbWindow, &dfbSurface); } - } else if (rect != geometry()) { - const QRect oldRect = geometry(); +#else + IDirectFBSurface *primarySurface = screen->primarySurface(); DFBResult result = DFB_OK; - // If we're in a resize, the surface shouldn't be locked - Q_ASSERT((lockedImage == 0) || (rect.size() == geometry().size())); - switch (mode) { - case Primary: - if (dfbSurface && dfbSurface != primarySurface) - dfbSurface->Release(dfbSurface); + if (mode == Primary) { + Q_ASSERT(primarySurface); if (rect == screen->region().boundingRect()) { dfbSurface = primarySurface; } else { @@ -203,71 +263,47 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) rect.width(), rect.height() }; result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface); } - break; - case Window: -#ifndef QT_NO_DIRECTFB_WM - if (!dfbWindow) - createWindow(); - ::setGeometry(dfbWindow, oldRect, rect); - // ### do I need to release and get the surface again here? -#endif - break; - case Offscreen: { - if (!dfbSurface || oldRect.size() != rect.size()) { - if (dfbSurface) - dfbSurface->Release(dfbSurface); + } else { // mode == Offscreen + if (!dfbSurface) { dfbSurface = screen->createDFBSurface(rect.size(), screen->pixelFormat(), QDirectFBScreen::DontTrackSurface); } - const QRegion region = QRegion(oldRect.isEmpty() ? screen->region() : QRegion(oldRect)).subtracted(rect); - screen->erase(region); - screen->flipSurface(primarySurface, flipFlags, region, QPoint()); - break; } } - if (result != DFB_OK) DirectFBErrorFatal("QDirectFBWindowSurface::setGeometry()", result); +#endif } + if (oldSurface != dfbSurface) + updateFormat(); - QWSWindowSurface::setGeometry(rect); + if (oldRect.size() != rect.size()) { + QWSWindowSurface::setGeometry(rect); + } else { + QWindowSurface::setGeometry(rect); + } } QByteArray QDirectFBWindowSurface::permanentState() const { - QByteArray array; -#ifdef QT_NO_DIRECTFB_WM - array.resize(sizeof(SurfaceFlags) + sizeof(IDirectFBSurface*)); -#else - array.resize(sizeof(SurfaceFlags)); -#endif - char *ptr = array.data(); - - *reinterpret_cast<SurfaceFlags*>(ptr) = surfaceFlags(); - ptr += sizeof(SurfaceFlags); - -#ifdef QT_NO_DIRECTFB_WM - *reinterpret_cast<IDirectFBSurface**>(ptr) = dfbSurface; -#endif - return array; + QByteArray state(sizeof(this), 0); + *reinterpret_cast<const QDirectFBWindowSurface**>(state.data()) = this; + return state; } void QDirectFBWindowSurface::setPermanentState(const QByteArray &state) { - SurfaceFlags flags; - const char *ptr = state.constData(); - - flags = *reinterpret_cast<const SurfaceFlags*>(ptr); - setSurfaceFlags(flags); - -#ifdef QT_NO_DIRECTFB_WM - ptr += sizeof(SurfaceFlags); - dfbSurface = *reinterpret_cast<IDirectFBSurface* const*>(ptr); -#endif + if (state.size() == sizeof(this)) { + sibling = *reinterpret_cast<QDirectFBWindowSurface *const*>(state.constData()); + Q_ASSERT(sibling); + sibling->setSurfaceFlags(surfaceFlags()); + } } static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) { const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); + const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; + surface->Flip(surface, ®ion, DSFLIP_BLIT); } bool QDirectFBWindowSurface::scroll(const QRegion ®ion, int dx, int dy) @@ -276,12 +312,12 @@ bool QDirectFBWindowSurface::scroll(const QRegion ®ion, int dx, int dy) return false; dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); if (region.numRects() == 1) { - ::scrollSurface(dfbSurface, region.boundingRect(), dx, dy); + scrollSurface(dfbSurface, region.boundingRect(), dx, dy); } else { const QVector<QRect> rects = region.rects(); const int n = rects.size(); for (int i=0; i<n; ++i) { - ::scrollSurface(dfbSurface, rects.at(i), dx, dy); + scrollSurface(dfbSurface, rects.at(i), dx, dy); } } return true; @@ -293,115 +329,64 @@ bool QDirectFBWindowSurface::move(const QPoint &moveBy) return true; } -// hw: XXX: copied from QWidgetPrivate::isOpaque() -inline bool isWidgetOpaque(const QWidget *w) +void QDirectFBWindowSurface::setOpaque(bool opaque) { - if (w->testAttribute(Qt::WA_OpaquePaintEvent) - || w->testAttribute(Qt::WA_PaintOnScreen)) - return true; - - const QPalette &pal = w->palette(); - - if (w->autoFillBackground()) { - const QBrush &autoFillBrush = pal.brush(w->backgroundRole()); - if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) - return true; - } - - if (!w->testAttribute(Qt::WA_NoSystemBackground)) { - const QBrush &windowBrush = w->palette().brush(QPalette::Window); - if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) - return true; + SurfaceFlags flags = surfaceFlags(); + if (opaque != (flags & Opaque)) { + if (opaque) { + flags |= Opaque; + } else { + flags &= ~Opaque; + } + setSurfaceFlags(flags); } - - return false; } -void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, + +void QDirectFBWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { - // hw: make sure opacity information is updated before compositing - if (QWidget *win = window()) { - - const bool opaque = isWidgetOpaque(win); - if (opaque != isOpaque()) { - SurfaceFlags flags = surfaceFlags(); - if (opaque) { - flags |= Opaque; - } else { - flags &= ~Opaque; - } - setSurfaceFlags(flags); - } - -#ifndef QT_NO_DIRECTFB_WM - const quint8 winOpacity = quint8(win->windowOpacity() * 255); - quint8 opacity; - - if (dfbWindow) { - dfbWindow->GetOpacity(dfbWindow, &opacity); - if (winOpacity != opacity) - dfbWindow->SetOpacity(dfbWindow, winOpacity); - } -#endif + QWidget *win = window(); + if (!win) + return; + + QWExtra *extra = qt_widget_private(widget)->extraData(); + if (extra && extra->proxyWidget) + return; + + const quint8 windowOpacity = quint8(win->windowOpacity() * 0xff); + const QRect windowGeometry = geometry(); +#ifdef QT_DIRECTFB_WM + const bool wasNoSystemBackground = noSystemBackground; + noSystemBackground = win->testAttribute(Qt::WA_NoSystemBackground); + quint8 currentOpacity; + Q_ASSERT(dfbWindow); + dfbWindow->GetOpacity(dfbWindow, ¤tOpacity); + if (currentOpacity != windowOpacity) { + dfbWindow->SetOpacity(dfbWindow, windowOpacity); } - const QRect windowGeometry = QDirectFBWindowSurface::geometry(); - IDirectFBSurface *primarySurface = screen->dfbSurface(); - if (mode == Offscreen) { - primarySurface->SetBlittingFlags(primarySurface, DSBLIT_NOFX); - const QRect windowRect(0, 0, windowGeometry.width(), windowGeometry.height()); - const int n = region.numRects(); - if (n == 1 || boundingRectFlip ) { - const QRect regionBoundingRect = region.boundingRect().translated(offset); - const QRect source = windowRect & regionBoundingRect; - const DFBRectangle rect = { - source.x(), source.y(), source.width(), source.height() - }; - primarySurface->Blit(primarySurface, dfbSurface, &rect, - windowGeometry.x() + source.x(), - windowGeometry.y() + source.y()); - } else { - const QVector<QRect> rects = region.rects(); - QVarLengthArray<DFBRectangle, 16> dfbRectangles(n); - QVarLengthArray<DFBPoint, 16> dfbPoints(n); - - for (int i=0; i<n; ++i) { - const QRect &r = rects.at(i).translated(offset); - const QRect source = windowRect & r; - DFBRectangle &rect = dfbRectangles[i]; - rect.x = source.x(); - rect.y = source.y(); - rect.w = source.width(); - rect.h = source.height(); - dfbPoints[i].x = (windowGeometry.x() + source.x()); - dfbPoints[i].y = (windowGeometry.y() + source.y()); - } - primarySurface->BatchBlit(primarySurface, dfbSurface, dfbRectangles.constData(), - dfbPoints.constData(), n); - } + setOpaque(noSystemBackground || windowOpacity != 0xff); + if (wasNoSystemBackground != noSystemBackground) { + releaseSurface(); + dfbWindow->Release(dfbWindow); + dfbWindow = 0; + createWindow(windowGeometry); + win->update(); + return; } - - if (QScreenCursor *cursor = QScreenCursor::instance()) { - const QRect cursorRectangle = cursor->boundingRect(); - if (cursor->isVisible() && !cursor->isAccelerated() - && region.intersects(cursorRectangle.translated(-(offset + windowGeometry.topLeft())))) { - const QImage image = cursor->image(); - - IDirectFBSurface *surface = screen->createDFBSurface(image, QDirectFBScreen::DontTrackSurface); - primarySurface->SetBlittingFlags(primarySurface, DSBLIT_BLEND_ALPHACHANNEL); - primarySurface->Blit(primarySurface, surface, 0, cursorRectangle.x(), cursorRectangle.y()); - surface->Release(surface); -#if (Q_DIRECTFB_VERSION >= 0x010000) - primarySurface->ReleaseSource(primarySurface); -#endif - } + screen->flipSurface(dfbSurface, flipFlags, region, offset); + if (noSystemBackground) { + dfbSurface->Clear(dfbSurface, 0, 0, 0, 0); } +#else + setOpaque(windowOpacity != 0xff); if (mode == Offscreen) { - screen->flipSurface(primarySurface, flipFlags, region, offset + windowGeometry.topLeft()); + screen->exposeRegion(region.translated(offset + geometry().topLeft()), 0); } else { screen->flipSurface(dfbSurface, flipFlags, region, offset); } +#endif #ifdef QT_DIRECTFB_TIMING enum { Secs = 3 }; @@ -414,55 +399,76 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, #endif } - void QDirectFBWindowSurface::beginPaint(const QRegion &) { - const int h = height(); - if (h > engineHeight) { - engineHeight = h; - delete engine; + if (!engine) { engine = new QDirectFBPaintEngine(this); } } void QDirectFBWindowSurface::endPaint(const QRegion &) { -#ifdef QT_DIRECTFB_DEBUG_SURFACES - if (bufferImages.count()) { - qDebug("QDirectFBWindowSurface::endPaint() this=%p", this); - - foreach(QImage* bufferImg, bufferImages) - qDebug(" Deleting buffer image %p", bufferImg); - } +#ifdef QT_NO_DIRECTFB_SUBSURFACE + unlockSurface(); #endif +} - qDeleteAll(bufferImages); - bufferImages.clear(); - unlockDirectFB(); +IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const +{ + if (!dfbSurface && sibling && sibling->dfbSurface) + return sibling->dfbSurface; + return dfbSurface; } -QImage *QDirectFBWindowSurface::buffer(const QWidget *widget) +IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget, QRect *rect) const { - if (!lockedImage) + Q_ASSERT(widget); + if (!dfbSurface) { + if (sibling && (!sibling->sibling || sibling->dfbSurface)) + return sibling->surfaceForWidget(widget, rect); return 0; + } + QWidget *win = window(); + Q_ASSERT(win); + if (rect) { + if (win == widget) { + *rect = widget->rect(); + } else { + *rect = QRect(widget->mapTo(win, QPoint(0, 0)), widget->size()); + } + } - const QRect rect = QRect(offset(widget), widget->size()) - & lockedImage->rect(); - if (rect.isEmpty()) - return 0; + Q_ASSERT(win == widget || win->isAncestorOf(widget)); + return dfbSurface; +} - QImage *img = new QImage(lockedImage->scanLine(rect.y()) - + rect.x() * (lockedImage->depth() / 8), - rect.width(), rect.height(), - lockedImage->bytesPerLine(), - lockedImage->format()); - bufferImages.append(img); +void QDirectFBWindowSurface::updateFormat() +{ + imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid; +} -#ifdef QT_DIRECTFB_DEBUG_SURFACES - qDebug("QDirectFBWindowSurface::buffer() Created & returned %p", img); +void QDirectFBWindowSurface::releaseSurface() +{ + if (dfbSurface) { +#ifdef QT_DIRECTFB_SUBSURFACE + releaseSubSurface(); +#else + unlockSurface(); +#endif +#ifdef QT_NO_DIRECTFB_WM + Q_ASSERT(screen->primarySurface()); + if (dfbSurface != screen->primarySurface()) #endif - return img; + dfbSurface->Release(dfbSurface); + dfbSurface = 0; + } } + +QT_END_NAMESPACE + +#endif // QT_NO_QWS_DIRECTFB + + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index 81f93c7..2f78179 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -46,9 +46,10 @@ #include "qdirectfbpaintdevice.h" #include "qdirectfbscreen.h" +#ifndef QT_NO_QWS_DIRECTFB + #include <private/qpaintengine_raster_p.h> #include <private/qwindowsurface_qws_p.h> -#include <directfb.h> #ifdef QT_DIRECTFB_TIMING #include <qdatetime.h> @@ -56,6 +57,8 @@ QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + QT_MODULE(Gui) class QDirectFBWindowSurface : public QWSWindowSurface, public QDirectFBPaintDevice @@ -65,6 +68,9 @@ public: QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr, QWidget *widget); ~QDirectFBWindowSurface(); +#ifdef QT_DIRECTFB_WM + void raise(); +#endif bool isValid() const; void setGeometry(const QRect &rect); @@ -85,22 +91,29 @@ public: void beginPaint(const QRegion &); void endPaint(const QRegion &); - QImage *buffer(const QWidget *widget); -private: -#ifndef QT_NO_DIRECTFB_WM - void createWindow(); - IDirectFBWindow *dfbWindow; + IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const; + IDirectFBSurface *directFBSurface() const; +#ifdef QT_DIRECTFB_WM + IDirectFBWindow *directFBWindow() const; #endif - int engineHeight; +private: + void setOpaque(bool opaque); + void updateFormat(); + void releaseSurface(); + QDirectFBWindowSurface *sibling; +#ifdef QT_DIRECTFB_WM + void createWindow(const QRect &rect); + IDirectFBWindow *dfbWindow; +#else enum Mode { Primary, - Offscreen, - Window + Offscreen } mode; +#endif - QList<QImage*> bufferImages; DFBSurfaceFlipFlags flipFlags; + bool noSystemBackground; bool boundingRectFlip; #ifdef QT_DIRECTFB_TIMING int frames; @@ -108,6 +121,10 @@ private: #endif }; +QT_END_NAMESPACE + QT_END_HEADER +#endif // QT_NO_QWS_DIRECTFB + #endif // QDIRECFBWINDOWSURFACE_H diff --git a/src/plugins/gfxdrivers/gfxdrivers.pro b/src/plugins/gfxdrivers/gfxdrivers.pro index 21aaf0f..d1ee3f2 100644 --- a/src/plugins/gfxdrivers/gfxdrivers.pro +++ b/src/plugins/gfxdrivers/gfxdrivers.pro @@ -5,6 +5,5 @@ contains(gfx-plugins, linuxfb) :SUBDIRS += linuxfb contains(gfx-plugins, qvfb) :SUBDIRS += qvfb contains(gfx-plugins, vnc) :SUBDIRS += vnc contains(gfx-plugins, transformed) :SUBDIRS += transformed -contains(gfx-plugins, hybrid) :SUBDIRS += hybrid contains(gfx-plugins, svgalib) :SUBDIRS += svgalib contains(gfx-plugins, powervr) :SUBDIRS += powervr diff --git a/src/plugins/gfxdrivers/hybrid/hybrid.pro b/src/plugins/gfxdrivers/hybrid/hybrid.pro deleted file mode 100644 index 8b8e9ef..0000000 --- a/src/plugins/gfxdrivers/hybrid/hybrid.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin -QT += opengl - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers - -TARGET = hybridscreen -target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers -INSTALLS += target - -HEADERS = hybridscreen.h \ - hybridsurface.h -SOURCES = hybridscreen.cpp \ - hybridsurface.cpp \ - hybridplugin.cpp - diff --git a/src/plugins/gfxdrivers/hybrid/hybridscreen.cpp b/src/plugins/gfxdrivers/hybrid/hybridscreen.cpp deleted file mode 100644 index 157ff14..0000000 --- a/src/plugins/gfxdrivers/hybrid/hybridscreen.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 "hybridscreen.h" -#include "hybridsurface.h" - -#include <QVector> -#include <QVarLengthArray> -#include <QApplication> -#include <QColor> -#include <QWidget> - -#include <GLES/egl.h> - -class HybridScreenPrivate -{ -public: - HybridScreenPrivate(HybridScreen *owner); - - bool verbose; - EGLDisplay display; - EGLint majorEGLVersion; - EGLint minorEGLVersion; - - QScreen *screen; - -private: - HybridScreen *q_ptr; -}; - -HybridScreenPrivate::HybridScreenPrivate(HybridScreen *owner) - : display(EGL_NO_DISPLAY), majorEGLVersion(0), minorEGLVersion(0), - screen(0), q_ptr(owner) -{ -} - -HybridScreen::HybridScreen(int displayId) - : QGLScreen(displayId) -{ - d_ptr = new HybridScreenPrivate(this); -} - -HybridScreen::~HybridScreen() -{ - delete d_ptr; -} - -static void error(const char *message) -{ - const EGLint error = eglGetError(); - qWarning("HybridScreen error: %s: 0x%x", message, error); -} - -static int getDisplayId(const QString &spec) -{ - QRegExp regexp(QLatin1String(":(\\d+)\\b")); - if (regexp.lastIndexIn(spec) != -1) { - const QString capture = regexp.cap(1); - return capture.toInt(); - } - return 0; -} - -bool HybridScreen::connect(const QString &displaySpec) -{ - QString dspec = displaySpec; - if (dspec.startsWith(QLatin1String("hybrid:"), Qt::CaseInsensitive)) - dspec = dspec.mid(QString(QLatin1String("hybrid:")).size()); - else if (dspec.compare(QLatin1String("hybrid"), Qt::CaseInsensitive) == 0) - dspec = QString(); - - const QString displayIdSpec = QString(QLatin1String(" :%1")).arg(displayId); - if (dspec.endsWith(displayIdSpec)) - dspec = dspec.left(dspec.size() - displayIdSpec.size()); - - const QStringList args = dspec.split(QLatin1Char(':'), - QString::SkipEmptyParts); - const int id = getDisplayId(dspec); - d_ptr->screen = qt_get_screen(id, dspec.toLatin1().constData()); - - const QScreen *screen = d_ptr->screen; - d = screen->depth(); - w = screen->width(); - h = screen->height(); - dw = screen->deviceWidth(); - dh = screen->deviceHeight(); - lstep = screen->linestep(); - data = screen->base(); - physWidth = screen->physicalWidth(); - physHeight = screen->physicalHeight(); - setPixelFormat(screen->pixelFormat()); - setOffset(screen->offset()); - - d_ptr->verbose = args.contains(QLatin1String("verbose")); - - d_ptr->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (d_ptr->display == EGL_NO_DISPLAY) { - error("getting display"); - return false; - } - - EGLBoolean status; - status = eglInitialize(d_ptr->display, - &d_ptr->majorEGLVersion, &d_ptr->minorEGLVersion); - if (!status) { - error("eglInitialize"); - return false; - } - if (d_ptr->verbose) { - qDebug("Detected EGL version %d.%d", - d_ptr->majorEGLVersion, d_ptr->minorEGLVersion); - - EGLint numConfigs = 0; - eglGetConfigs(d_ptr->display, 0, 0, &numConfigs); - qDebug("%d available configurations", numConfigs); - } - - // XXX: hw: use eglQueryString to find supported APIs - - qt_screen = this; // XXX - - return true; -} - -bool HybridScreen::initDevice() -{ - if (d_ptr->screen) - return d_ptr->screen->initDevice(); - return false; -} - -void HybridScreen::shutdownDevice() -{ - if (d_ptr->screen) - d_ptr->screen->shutdownDevice(); -} - -void HybridScreen::disconnect() -{ - if (!eglTerminate(d_ptr->display)) - error("disconnecting"); - if (d_ptr->screen) { - d_ptr->screen->disconnect(); - delete d_ptr->screen; - d_ptr->screen = 0; - } - -} - -bool HybridScreen::hasOpenGLOverlays() const -{ - return true; -} - -bool HybridScreen::chooseContext(QGLContext *context, - const QGLContext *shareContext) -{ -#if 0 - // hw: update the glFormat variable. Probably needs a setter in the - // QGLWindowSurface class which can be a friend of whatever it wants. - - GLint res; - eglGetConfigAttrib(d_ptr->display, d_ptr->config, EGL_LEVEL, &res); - d_ptr->glFormat.setPlane(res); - QT_EGL_ERR("eglGetConfigAttrib"); - - /* - if(deviceIsPixmap()) - res = 0; - else - eglDescribePixelFormat(fmt, EGL_DOUBLEBUFFER, &res); - d_ptr->glFormat.setDoubleBuffer(res); - */ - - eglGetConfigAttrib(d_ptr->display, d_ptr->config, EGL_DEPTH_SIZE, &res); - d_ptr->glFormat.setDepth(res); - if (d_ptr->glFormat.depth()) - d_ptr->glFormat.setDepthBufferSize(res); - - //eglGetConfigAttrib(d_ptr->display,d_ptr->config, EGL_RGBA, &res); - //d_ptr->glFormat.setRgba(res); - - eglGetConfigAttrib(d_ptr->display, d_ptr->config, EGL_ALPHA_SIZE, &res); - d_ptr->glFormat.setAlpha(res); - if (d_ptr->glFormat.alpha()) - d_ptr->glFormat.setAlphaBufferSize(res); - - //eglGetConfigAttrib(d_ptr->display,d_ptr->config, EGL_ACCUM_RED_SIZE, &res); - //d_ptr->glFormat.setAccum(res); - //if (d_ptr->glFormat.accum()) - // d_ptr->glFormat.setAccumBufferSize(res); - - eglGetConfigAttrib(d_ptr->display, d_ptr->config, EGL_STENCIL_SIZE, &res); - d_ptr->glFormat.setStencil(res); - if (d_ptr->glFormat.stencil()) - d_ptr->glFormat.setStencilBufferSize(res); - - //eglGetConfigAttrib(d_ptr->display, d_ptr->config, EGL_STEREO, &res); - //d_ptr->glFormat.setStereo(res); - - eglGetConfigAttrib(d_ptr->display, d_ptr->config, EGL_SAMPLE_BUFFERS, &res); - d_ptr->glFormat.setSampleBuffers(res); - - if (d_ptr->glFormat.sampleBuffers()) { - eglGetConfigAttrib(d_ptr->display, d_ptr->config, EGL_SAMPLES, &res); - d_ptr->glFormat.setSamples(res); - } -#endif - - // hw: TODO: implement sharing of contexts - -#if 0 - if(shareContext && - (!shareContext->isValid() || !shareContext->d_func()->cx)) { - qWarning("QGLContext::chooseContext(): Cannot share with invalid context"); - shareContext = 0; - } -#endif - -#if 0 - d_ptr->cx = ctx; - if (shareContext && shareContext->d_func()->cx) { - QGLContext *share = const_cast<QGLContext *>(shareContext); - d_ptr->sharing = true; - share->d_func()->sharing = true; - } -#endif - -#if 0 - // vblank syncing - GLint interval = d_ptr->reqFormat.swapInterval(); - if (interval != -1) { - if (interval != 0) - eglSwapInterval(d_ptr->display, interval); - } -#endif - - return QGLScreen::chooseContext(context, shareContext); -} - -void HybridScreen::setDirty(const QRect& rect) -{ - d_ptr->screen->setDirty(rect); -} - -void HybridScreen::setMode(int w, int h, int d) -{ - d_ptr->screen->setMode(w, h, d); - setDirty(region().boundingRect()); -} - -bool HybridScreen::supportsDepth(int depth) const -{ - return d_ptr->screen->supportsDepth(depth); -} - -void HybridScreen::save() -{ - d_ptr->screen->save(); -} - -void HybridScreen::restore() -{ - d_ptr->screen->restore(); -} - -void HybridScreen::blank(bool on) -{ - d_ptr->screen->blank(on); -} - -bool HybridScreen::onCard(const unsigned char *ptr) const -{ - return d_ptr->screen->onCard(ptr); -} - -bool HybridScreen::onCard(const unsigned char *ptr, ulong &offset) const -{ - return d_ptr->screen->onCard(ptr, offset); -} - -bool HybridScreen::isInterlaced() const -{ - return d_ptr->screen->isInterlaced(); -} - -int HybridScreen::memoryNeeded(const QString &str) -{ - return d_ptr->screen->memoryNeeded(str); -} - -int HybridScreen::sharedRamSize(void *ptr) -{ - return d_ptr->screen->sharedRamSize(ptr); -} - -void HybridScreen::haltUpdates() -{ - d_ptr->screen->haltUpdates(); -} - -void HybridScreen::resumeUpdates() -{ - d_ptr->screen->resumeUpdates(); -} - -void HybridScreen::exposeRegion(QRegion r, int changing) -{ - d_ptr->screen->exposeRegion(r, changing); -} - -void HybridScreen::blit(const QImage &img, const QPoint &topLeft, const QRegion ®ion) -{ - d_ptr->screen->blit(img, topLeft, region); -} - -void HybridScreen::solidFill(const QColor &color, const QRegion ®ion) -{ - d_ptr->screen->solidFill(color, region); -} - -QWSWindowSurface* HybridScreen::createSurface(QWidget *widget) const -{ - if (qobject_cast<QGLWidget*>(widget)) - return new HybridSurface(widget, d_ptr->display); - return d_ptr->screen->createSurface(widget); -} - -QWSWindowSurface* HybridScreen::createSurface(const QString &key) const -{ - if (key == QLatin1String("hybrid")) - return new HybridSurface; - return d_ptr->screen->createSurface(key); -} - -QList<QScreen*> HybridScreen::subScreens() const -{ - return d_ptr->screen->subScreens(); -} - -QRegion HybridScreen::region() const -{ - return d_ptr->screen->region(); -} diff --git a/src/plugins/gfxdrivers/hybrid/hybridscreen.h b/src/plugins/gfxdrivers/hybrid/hybridscreen.h deleted file mode 100644 index b7888d5..0000000 --- a/src/plugins/gfxdrivers/hybrid/hybridscreen.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 HYBRIDSCREEN_H -#define HYBRIDSCREEN_H - -#include <QtOpenGL/QGLScreen> - -class HybridScreenPrivate; - -class HybridScreen : public QGLScreen -{ -public: - HybridScreen(int displayId); - ~HybridScreen(); - - bool hasOpenGLOverlays() const; - - bool chooseContext(QGLContext *context, const QGLContext *shareContext); - bool hasOpenGL() { return true; } - - bool initDevice(); - bool connect(const QString &displaySpec); - void disconnect(); - void shutdownDevice(); - void setMode(int,int,int); - bool supportsDepth(int) const; - - void save(); - void restore(); - void blank(bool on); - - bool onCard(const unsigned char *) const; - bool onCard(const unsigned char *, ulong& out_offset) const; - - bool isInterlaced() const; - - int memoryNeeded(const QString&); - int sharedRamSize(void *); - - void haltUpdates(); - void resumeUpdates(); - - void exposeRegion(QRegion r, int changing); - - void blit(const QImage &img, const QPoint &topLeft, const QRegion ®ion); - void solidFill(const QColor &color, const QRegion ®ion); - void setDirty(const QRect&); - - QWSWindowSurface* createSurface(QWidget *widget) const; - QWSWindowSurface* createSurface(const QString &key) const; - - QList<QScreen*> subScreens() const; - QRegion region() const; -private: - HybridScreenPrivate *d_ptr; -}; - -#endif // HYBRIDSCREEN_H diff --git a/src/plugins/gfxdrivers/hybrid/hybridsurface.cpp b/src/plugins/gfxdrivers/hybrid/hybridsurface.cpp deleted file mode 100644 index df183e2..0000000 --- a/src/plugins/gfxdrivers/hybrid/hybridsurface.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 "hybridsurface.h" - -#include <private/qwindowsurface_qws_p.h> -#include <private/qwslock_p.h> -#include <qscreen_qws.h> -#include <qvarlengtharray.h> - -static void error(const char *message) -{ - const EGLint error = eglGetError(); - qWarning("HybridSurface error: %s: 0x%x", message, error); -} - -static void imgToVanilla(const QImage *img, VanillaPixmap *pix) -{ - pix->width = img->width(); - pix->height = img->height(); - pix->stride = img->bytesPerLine(); - - if (img->depth() == 32) { - pix->rSize = pix->gSize = pix->bSize = pix->aSize = 8; - pix->lSize = 0; - pix->rOffset = 16; - pix->gOffset = 8; - pix->bOffset = 0; - pix->aOffset = 24; - } else if (img->format() == QImage::Format_RGB16) { - pix->rSize = 5; - pix->gSize = 6; - pix->bSize = 5; - pix->aSize = 0; - pix->lSize = 0; - pix->rOffset = 11; - pix->gOffset = 5; - pix->bOffset = 0; - pix->aOffset = 0; - } - - pix->padding = pix->padding2 = 0; - pix->pixels = const_cast<uchar*>(img->bits()); -} - -HybridSurface::HybridSurface() - : QWSGLWindowSurface(), memlock(0) -{ - setSurfaceFlags(Buffered | Opaque); -} - -HybridSurface::HybridSurface(QWidget *w, EGLDisplay disp) - : QWSGLWindowSurface(w), memlock(0), display(disp), config(0), - surface(EGL_NO_SURFACE), context(EGL_NO_CONTEXT), - pdevice(new QWSGLPaintDevice(w)) -{ - setSurfaceFlags(Buffered | Opaque); - - EGLint configAttribs[] = { - EGL_RED_SIZE, 0, - EGL_GREEN_SIZE, 0, - EGL_BLUE_SIZE, 0, - EGL_ALPHA_SIZE, 0, - EGL_DEPTH_SIZE, 0, - EGL_STENCIL_SIZE, EGL_DONT_CARE, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_NONE, EGL_NONE - }; - - - EGLBoolean status; - EGLint numConfigs; - status = eglChooseConfig(display, configAttribs, 0, 0, &numConfigs); - if (!status) { - error("chooseConfig"); - return; - } - - //If there isn't any configuration good enough - if (numConfigs < 1) { - error("chooseConfig, no matching configurations found"); - return; - } - - QVarLengthArray<EGLConfig> configs(numConfigs); - - status = eglChooseConfig(display, configAttribs, configs.data(), - numConfigs, &numConfigs); - if (!status) { - error("chooseConfig"); - return; - } - - // hw: if used on an image buffer we need to check whether the resulting - // configuration matches our requirements exactly! - config = configs[0]; - - context = eglCreateContext(display, config, 0, 0); - //(shareContext ? shareContext->d_func()->cx : 0), - //configAttribs); - if (context == EGL_NO_CONTEXT) - error("eglCreateContext"); - -} - -HybridSurface::~HybridSurface() -{ -} - -bool HybridSurface::isValid() const -{ - return true; -} - -void HybridSurface::setGeometry(const QRect &rect, const QRegion &mask) -{ - const QSize size = rect.size(); - if (img.size() != size) { -// QWidget *win = window(); - QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied; - const int bytesPerPixel = 4; - - const int bpl = (size.width() * bytesPerPixel + 3) & ~3; - const int imagesize = bpl * size.height(); - - if (imagesize == 0) { - eglDestroySurface(display, surface); - mem.detach(); - img = QImage(); - } else { - mem.detach(); - if (!mem.create(imagesize)) { - perror("HybridSurface::setGeometry allocating shared memory"); - qFatal("Error creating shared memory of size %d", imagesize); - } - uchar *base = static_cast<uchar*>(mem.address()); - img = QImage(base, size.width(), size.height(), imageFormat); -// setImageMetrics(img, win); - - imgToVanilla(&img, &vanillaPix); - surface = eglCreatePixmapSurface(display, config, &vanillaPix, 0); - if (surface == EGL_NO_SURFACE) - error("setGeometry:eglCreatePixmapSurface"); - - } - } - QWSWindowSurface::setGeometry(rect, mask); -} - -QByteArray HybridSurface::permanentState() const -{ - QByteArray array; - array.resize(4 * sizeof(int) + sizeof(QImage::Format) + - sizeof(SurfaceFlags)); - - char *ptr = array.data(); - - reinterpret_cast<int*>(ptr)[0] = mem.id(); - reinterpret_cast<int*>(ptr)[1] = img.width(); - reinterpret_cast<int*>(ptr)[2] = img.height(); - reinterpret_cast<int*>(ptr)[3] = (memlock ? memlock->id() : -1); - ptr += 4 * sizeof(int); - - *reinterpret_cast<QImage::Format*>(ptr) = img.format(); - ptr += sizeof(QImage::Format); - - *reinterpret_cast<SurfaceFlags*>(ptr) = surfaceFlags(); - - return array; -} - -void HybridSurface::setPermanentState(const QByteArray &data) -{ - int memId; - int width; - int height; - int lockId; - QImage::Format format; - SurfaceFlags flags; - - const char *ptr = data.constData(); - - memId = reinterpret_cast<const int*>(ptr)[0]; - width = reinterpret_cast<const int*>(ptr)[1]; - height = reinterpret_cast<const int*>(ptr)[2]; - lockId = reinterpret_cast<const int*>(ptr)[3]; - ptr += 4 * sizeof(int); - - format = *reinterpret_cast<const QImage::Format*>(ptr); - ptr += sizeof(QImage::Format); - flags = *reinterpret_cast<const SurfaceFlags*>(ptr); - - setSurfaceFlags(flags); - -// setMemory(memId); - if (mem.id() != memId) { - mem.detach(); - if (!mem.attach(memId)) { - perror("QWSSharedMemSurface: attaching to shared memory"); - qCritical("QWSSharedMemSurface: Error attaching to" - " shared memory 0x%x", memId); - } - } - -// setLock(lockId); - if (!memlock || memlock->id() == lockId) { - delete memlock; - memlock = (lockId == -1 ? 0 : new QWSLock(lockId)); - } - - uchar *base = static_cast<uchar*>(mem.address()); - img = QImage(base, width, height, format); -} - -QImage HybridSurface::image() const -{ - return img; -} - -QPaintDevice* HybridSurface::paintDevice() -{ - return pdevice; -} - -void HybridSurface::beginPaint(const QRegion ®ion) -{ - QWSGLWindowSurface::beginPaint(region); - eglBindAPI(EGL_OPENGL_ES_API); - - EGLBoolean ok = eglMakeCurrent(display, surface, surface, context); - if (!ok) - error("qglMakeCurrent"); -} - -bool HybridSurface::lock(int timeout) -{ - Q_UNUSED(timeout); - if (!memlock) - return true; - return memlock->lock(QWSLock::BackingStore); -} - -void HybridSurface::unlock() -{ - if (memlock) - memlock->unlock(QWSLock::BackingStore); -} - -QPoint HybridSurface::painterOffset() const -{ - const QWidget *w = window(); - if (!w) - return QPoint(); - - if (w->mask().isEmpty()) - return QWSWindowSurface::painterOffset(); - - const QRegion region = w->mask() - & w->frameGeometry().translated(-w->geometry().topLeft()); - return -region.boundingRect().topLeft(); -} - diff --git a/src/plugins/gfxdrivers/hybrid/hybridsurface.h b/src/plugins/gfxdrivers/hybrid/hybridsurface.h deleted file mode 100644 index 1fba95b..0000000 --- a/src/plugins/gfxdrivers/hybrid/hybridsurface.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 HYBRIDSURFACE_H -#define HYBRIDSURFACE_H - -#include <private/qglwindowsurface_qws_p.h> -#include <private/qglpaintdevice_qws_p.h> -#include <GLES/egl.h> -#include <vanilla/eglVanilla.h> -#include <private/qwssharedmemory_p.h> - -class HybridPaintDevice; -class HybridSurfacePrivate; -class QWSLock; - -class HybridSurface : public QWSGLWindowSurface -{ -public: - HybridSurface(); - HybridSurface(QWidget *w, EGLDisplay display); - ~HybridSurface(); - - void beginPaint(const QRegion ®ion); - bool lock(int timeout); - void unlock(); - - bool isValid() const; - void setGeometry(const QRect &rect, const QRegion &mask); - QString key() const { return QLatin1String("hybrid"); } - - QByteArray permanentState() const; - void setPermanentState(const QByteArray &state); - - QImage image() const; - QPaintDevice *paintDevice(); - QPoint painterOffset() const; - -private: - QWSSharedMemory mem; - QImage img; - QWSLock *memlock; - EGLDisplay display; - EGLConfig config; - EGLSurface surface; - EGLContext context; - QWSGLPaintDevice *pdevice; - - VanillaPixmap vanillaPix; -}; - -#endif // HYBRIDSURFACE_H diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro b/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro index 9331d0a..595cf45 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro @@ -11,9 +11,9 @@ SOURCES+=\ pvrqwsdrawable.c \ pvrqwswsegl.c -INCLUDEPATH += $$QMAKE_INCDIR_OPENGL +INCLUDEPATH += $$QMAKE_INCDIR_EGL -for(p, QMAKE_LIBDIR_OPENGL) { +for(p, QMAKE_LIBDIR_EGL) { exists($$p):LIBS += -L$$p } diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp index 2e4c6d1..c1410a6 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp @@ -53,12 +53,14 @@ #include <fcntl.h> #include <unistd.h> +//![0] PvrEglScreen::PvrEglScreen(int displayId) : QGLScreen(displayId) { setOptions(NativeWindows); setSupportsBlitInClients(true); setSurfaceFunctions(new PvrEglScreenSurfaceFunctions(this, displayId)); +//![0] fd = -1; ttyfd = -1; doGraphicsMode = true; @@ -190,6 +192,7 @@ bool PvrEglScreen::hasOpenGL() return true; } +//![1] QWSWindowSurface* PvrEglScreen::createSurface(QWidget *widget) const { if (qobject_cast<QGLWidget*>(widget)) @@ -205,6 +208,68 @@ QWSWindowSurface* PvrEglScreen::createSurface(const QString &key) const return QScreen::createSurface(key); } +//![1] + +#ifndef QT_NO_QWS_TRANSFORMED + +static const QScreen *parentScreen + (const QScreen *current, const QScreen *lookingFor) +{ + if (!current) + return 0; + switch (current->classId()) { + case QScreen::ProxyClass: + case QScreen::TransformedClass: { + const QScreen *child = + static_cast<const QProxyScreen *>(current)->screen(); + if (child == lookingFor) + return current; + else + return parentScreen(child, lookingFor); + } + // Not reached. + + case QScreen::MultiClass: { + QList<QScreen *> screens = current->subScreens(); + foreach (QScreen *screen, screens) { + if (screen == lookingFor) + return current; + const QScreen *parent = parentScreen(screen, lookingFor); + if (parent) + return parent; + } + } + break; + + default: break; + } + return 0; +} + +int PvrEglScreen::transformation() const +{ + // We need to search for our parent screen, which is assumed to be + // "Transformed". If it isn't, then there is no transformation. + // There is no direct method to get the parent screen so we need + // to search every screen until we find ourselves. + if (!parent && qt_screen != this) + parent = parentScreen(qt_screen, this); + if (!parent) + return 0; + if (parent->classId() != QScreen::TransformedClass) + return 0; + return 90 * static_cast<const QTransformedScreen *>(parent) + ->transformation(); +} + +#else + +int PvrEglScreen::transformation() const +{ + return 0; +} + +#endif #ifndef QT_NO_QWS_TRANSFORMED @@ -321,8 +386,10 @@ void PvrEglScreen::closeTty() ttyfd = -1; } +//![2] bool PvrEglScreenSurfaceFunctions::createNativeWindow(QWidget *widget, EGLNativeWindowType *native) { +//![2] QWSWindowSurface *surface = static_cast<QWSWindowSurface *>(widget->windowSurface()); if (!surface) { diff --git a/src/plugins/gfxdrivers/qvfb/main.cpp b/src/plugins/gfxdrivers/qvfb/main.cpp index bcaecab..beca37e 100644 --- a/src/plugins/gfxdrivers/qvfb/main.cpp +++ b/src/plugins/gfxdrivers/qvfb/main.cpp @@ -43,6 +43,7 @@ #include <qscreenvfb_qws.h> #include <qstringlist.h> +#ifndef QT_NO_LIBRARY QT_BEGIN_NAMESPACE class ScreenVfbDriver : public QScreenDriverPlugin @@ -78,3 +79,4 @@ Q_EXPORT_STATIC_PLUGIN(ScreenVfbDriver) Q_EXPORT_PLUGIN2(qscreenvfb, ScreenVfbDriver) QT_END_NAMESPACE +#endif //QT_NO_LIBRARY diff --git a/src/plugins/gfxdrivers/transformed/main.cpp b/src/plugins/gfxdrivers/transformed/main.cpp index 982882e..a9ff97d 100644 --- a/src/plugins/gfxdrivers/transformed/main.cpp +++ b/src/plugins/gfxdrivers/transformed/main.cpp @@ -42,7 +42,7 @@ #include <qscreendriverplugin_qws.h> #include <qscreentransformed_qws.h> #include <qstringlist.h> - +#ifndef QT_NO_LIBRARY QT_BEGIN_NAMESPACE class GfxTransformedDriver : public QScreenDriverPlugin @@ -68,9 +68,12 @@ QStringList GfxTransformedDriver::keys() const QScreen* GfxTransformedDriver::create(const QString& driver, int displayId) { +#ifndef QT_NO_QWS_TRANSFORMED if (driver.toLower() == "transformed") return new QTransformedScreen(displayId); - +#else //QT_NO_QWS_TRANSFORMED + printf("QT buildt with QT_NO_QWS_TRANSFORMED. No screen driver returned\n"); +#endif //QT_NO_QWS_TRANSFORMED return 0; } @@ -78,3 +81,4 @@ Q_EXPORT_STATIC_PLUGIN(GfxTransformedDriver) Q_EXPORT_PLUGIN2(qgfxtransformed, GfxTransformedDriver) QT_END_NAMESPACE +#endif //QT_NO_LIBRARY diff --git a/src/plugins/gfxdrivers/vnc/main.cpp b/src/plugins/gfxdrivers/vnc/main.cpp index aa20d11..58c8c25 100644 --- a/src/plugins/gfxdrivers/vnc/main.cpp +++ b/src/plugins/gfxdrivers/vnc/main.cpp @@ -43,6 +43,7 @@ #include <qscreenvnc_qws.h> #include <qstringlist.h> +#ifndef QT_NO_LIBRARY QT_BEGIN_NAMESPACE class GfxVncDriver : public QScreenDriverPlugin @@ -68,9 +69,12 @@ QStringList GfxVncDriver::keys() const QScreen* GfxVncDriver::create(const QString& driver, int displayId) { +#ifndef QT_NO_QWS_VNC if (driver.toLower() == "vnc") return new QVNCScreen(displayId); - +#else //QT_NO_QWS_VNC + printf("QT buildt with QT_NO_QWS_VNC. No screen driver returned\n"); +#endif //QT_NO_QWS_VNC return 0; } @@ -78,3 +82,5 @@ Q_EXPORT_STATIC_PLUGIN(GfxVncDriver) Q_EXPORT_PLUGIN2(qgfxvnc, GfxVncDriver) QT_END_NAMESPACE + +#endif //QT_NO_LIBRARY diff --git a/src/plugins/gfxdrivers/vnc/qscreenvnc_p.h b/src/plugins/gfxdrivers/vnc/qscreenvnc_p.h index 9aad8f7..d7466d2 100644 --- a/src/plugins/gfxdrivers/vnc/qscreenvnc_p.h +++ b/src/plugins/gfxdrivers/vnc/qscreenvnc_p.h @@ -259,6 +259,8 @@ public: #endif QVNCScreen *q_ptr; + + bool noDisablePainting; }; class QRfbEncoder diff --git a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp b/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp index c4fa80a..f44fe0d 100644 --- a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp +++ b/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp @@ -195,8 +195,11 @@ void QVNCClientCursor::write() const QVNCScreenPrivate::QVNCScreenPrivate(QVNCScreen *parent) : dpiX(72), dpiY(72), doOnScreenSurface(false), refreshRate(25), - vncServer(0), q_ptr(parent) + vncServer(0), q_ptr(parent), noDisablePainting(false) { +#ifdef QT_BUILD_INTERNAL + noDisablePainting = (qgetenv("QT_VNC_NO_DISABLEPAINTING").toInt() > 0); +#endif #ifndef QT_NO_QWS_SIGNALHANDLER QWSSignalHandler::instance()->addObject(this); #endif @@ -615,7 +618,7 @@ void QVNCServer::newConnection() client->write(proto, 12); state = Protocol; - if (!qvnc_screen->screen()) + if (!qvnc_screen->screen() && !qvnc_screen->d_ptr->noDisablePainting) QWSServer::instance()->enablePainting(true); } @@ -2001,7 +2004,7 @@ void QVNCServer::discardClient() delete qvnc_cursor; qvnc_cursor = 0; #endif - if (!qvnc_screen->screen()) + if (!qvnc_screen->screen() && !qvnc_screen->d_ptr->noDisablePainting) QWSServer::instance()->enablePainting(false); } @@ -2100,11 +2103,11 @@ bool QVNCScreen::connect(const QString &displaySpec) { QString dspec = displaySpec; if (dspec.startsWith(QLatin1String("vnc:"), Qt::CaseInsensitive)) - dspec = dspec.mid(QString(QLatin1String("vnc:")).size()); + dspec = dspec.mid(QString::fromLatin1("vnc:").size()); else if (dspec.compare(QLatin1String("vnc"), Qt::CaseInsensitive) == 0) dspec = QString(); - const QString displayIdSpec = QString(QLatin1String(" :%1")).arg(displayId); + const QString displayIdSpec = QString::fromLatin1(" :%1").arg(displayId); if (dspec.endsWith(displayIdSpec)) dspec = dspec.left(dspec.size() - displayIdSpec.size()); @@ -2184,6 +2187,9 @@ bool QVNCScreen::connect(const QString &displaySpec) d_ptr->dpiY = (dpiY > 0 ? dpiY : dpiX); } + if (args.contains(QLatin1String("noDisablePainting"))) + d_ptr->noDisablePainting = true; + QWSServer::setDefaultMouse("None"); QWSServer::setDefaultKeyboard("None"); @@ -2273,11 +2279,9 @@ bool QVNCScreen::initDevice() if (QProxyScreen::screen()) return ok; -#ifdef QT_BUILD_INTERNAL - if (qgetenv("QT_VNC_NO_DISABLEPAINTING").toInt() <= 0) -#endif - // No need to do painting while there's no clients attached - QWSServer::instance()->enablePainting(false); + // Disable painting if there is only 1 display and nothing is attached to the VNC server + if (!d_ptr->noDisablePainting) + QWSServer::instance()->enablePainting(false); return true; } diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro index b8216ff..0788933 100644 --- a/src/plugins/graphicssystems/graphicssystems.pro +++ b/src/plugins/graphicssystems/graphicssystems.pro @@ -1,2 +1,9 @@ TEMPLATE = subdirs -contains(QT_CONFIG, opengl):SUBDIRS += opengl +SUBDIRS += trace +!wince*:contains(QT_CONFIG, opengl):SUBDIRS += opengl +contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl):SUBDIRS += openvg + +contains(QT_CONFIG, shivavg) { + # Only works under X11 at present + !win32:!embedded:!mac:SUBDIRS += shivavg +} diff --git a/src/plugins/graphicssystems/opengl/main.cpp b/src/plugins/graphicssystems/opengl/main.cpp index 0562132..6216ada 100644 --- a/src/plugins/graphicssystems/opengl/main.cpp +++ b/src/plugins/graphicssystems/opengl/main.cpp @@ -41,6 +41,7 @@ #include <private/qgraphicssystemplugin_p.h> #include <private/qgraphicssystem_gl_p.h> +#include <qgl.h> QT_BEGIN_NAMESPACE @@ -53,11 +54,28 @@ public: QStringList QGLGraphicsSystemPlugin::keys() const { - return QStringList(QLatin1String("OpenGL")); + QStringList list; + list << QLatin1String("OpenGL") << QLatin1String("OpenGL1"); +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + list << QLatin1String("OpenGL2"); +#endif + return list; } QGraphicsSystem* QGLGraphicsSystemPlugin::create(const QString& system) { + if (system.toLower() == QLatin1String("opengl1")) { + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); + return new QGLGraphicsSystem; + } + +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) + if (system.toLower() == QLatin1String("opengl2")) { + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL2); + return new QGLGraphicsSystem; + } +#endif + if (system.toLower() == QLatin1String("opengl")) return new QGLGraphicsSystem; diff --git a/src/plugins/kbddrivers/usb/main.cpp b/src/plugins/graphicssystems/openvg/main.cpp index 2465fcd..61e93c0 100644 --- a/src/plugins/kbddrivers/usb/main.cpp +++ b/src/plugins/graphicssystems/openvg/main.cpp @@ -39,38 +39,33 @@ ** ****************************************************************************/ -#include <qkbddriverplugin_qws.h> -#include <qkbdusb_qws.h> +#include <private/qgraphicssystemplugin_p.h> +#include "qgraphicssystem_vg_p.h" QT_BEGIN_NAMESPACE -class QUsbKbdDriver : public QKbdDriverPlugin +class QVGGraphicsSystemPlugin : public QGraphicsSystemPlugin { public: - QUsbKbdDriver(); - QStringList keys() const; - QWSKeyboardHandler* create(const QString &driver, const QString &device); + QGraphicsSystem *create(const QString&); }; -QUsbKbdDriver::QUsbKbdDriver() - : QKbdDriverPlugin() +QStringList QVGGraphicsSystemPlugin::keys() const { + QStringList list; + list << "OpenVG"; + return list; } -QStringList QUsbKbdDriver::keys() const +QGraphicsSystem* QVGGraphicsSystemPlugin::create(const QString& system) { - return (QStringList() << QLatin1String("Usb")); -} + if (system.toLower() == "openvg") + return new QVGGraphicsSystem; -QWSKeyboardHandler* QUsbKbdDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("Usb"), Qt::CaseInsensitive)) - return 0; - return new QWSUsbKeyboardHandler(device); + return 0; } -Q_EXPORT_PLUGIN2(qwsusbkbddriver, QUsbKbdDriver) +Q_EXPORT_PLUGIN2(openvg, QVGGraphicsSystemPlugin) QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openvg/openvg.pro b/src/plugins/graphicssystems/openvg/openvg.pro new file mode 100644 index 0000000..d36570c --- /dev/null +++ b/src/plugins/graphicssystems/openvg/openvg.pro @@ -0,0 +1,12 @@ +TARGET = qvggraphicssystem +include(../../qpluginbase.pri) + +QT += openvg + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_vg.cpp +HEADERS = qgraphicssystem_vg_p.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/mousedrivers/bus/main.cpp b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp index f135f4a..921ed0d 100644 --- a/src/plugins/mousedrivers/bus/main.cpp +++ b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp @@ -39,38 +39,32 @@ ** ****************************************************************************/ -#include <qmousedriverplugin_qws.h> -#include <qmousebus_qws.h> +#include "qgraphicssystem_vg_p.h" +#include <QtOpenVG/private/qpixmapdata_vg_p.h> +#include <QtOpenVG/private/qwindowsurface_vg_p.h> QT_BEGIN_NAMESPACE -class QBusMouseDriver : public QMouseDriverPlugin -{ -public: - QBusMouseDriver(); - - QStringList keys() const; - QWSMouseHandler* create(const QString &driver, const QString &device); -}; - -QBusMouseDriver::QBusMouseDriver() - : QMouseDriverPlugin() +QVGGraphicsSystem::QVGGraphicsSystem() { } -QStringList QBusMouseDriver::keys() const +QPixmapData *QVGGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { - return (QStringList() << "Bus"); +#if !defined(QVG_NO_SINGLE_CONTEXT) && !defined(QVG_NO_PIXMAP_DATA) + // Pixmaps can use QVGPixmapData; bitmaps must use raster. + if (type == QPixmapData::PixmapType) + return new QVGPixmapData(type); + else + return new QRasterPixmapData(type); +#else + return new QRasterPixmapData(type); +#endif } -QWSMouseHandler* QBusMouseDriver::create(const QString &driver, - const QString &device) +QWindowSurface *QVGGraphicsSystem::createWindowSurface(QWidget *widget) const { - if (driver.compare(QLatin1String("Bus"), Qt::CaseInsensitive)) - return 0; - return new QWSBusMouseHandler(driver, device); + return new QVGWindowSurface(widget); } -Q_EXPORT_PLUGIN2(qwsbusmousehandler, QBusMouseDriver) - QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h new file mode 100644 index 0000000..5765597 --- /dev/null +++ b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 QGRAPHICSSYSTEM_VG_P_H +#define QGRAPHICSSYSTEM_VG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qgraphicssystem_p.h> + +QT_BEGIN_NAMESPACE + +class QVGGraphicsSystem : public QGraphicsSystem +{ +public: + QVGGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/shivavg/README b/src/plugins/graphicssystems/shivavg/README new file mode 100644 index 0000000..15ee710 --- /dev/null +++ b/src/plugins/graphicssystems/shivavg/README @@ -0,0 +1,8 @@ + +This graphics system uses ShivaVG (http://sourceforge.net/projects/shivavg) +to perform OpenVG rendering on X11 systems. The graphics system name for +the "-graphicssystem" command-line option is "ShivaVG". + +ShivaVG support is experimental, mostly to demonstrate how to integrate +non-EGL OpenVG engines into the system. It will probably not produce +good output. diff --git a/src/plugins/gfxdrivers/hybrid/hybridplugin.cpp b/src/plugins/graphicssystems/shivavg/main.cpp index 17be760..f9150ac 100644 --- a/src/plugins/gfxdrivers/hybrid/hybridplugin.cpp +++ b/src/plugins/graphicssystems/shivavg/main.cpp @@ -39,37 +39,33 @@ ** ****************************************************************************/ -#include "hybridscreen.h" +#include <private/qgraphicssystemplugin_p.h> +#include "shivavggraphicssystem.h" -#include <QScreenDriverPlugin> -#include <QStringList> +QT_BEGIN_NAMESPACE -class HybridPlugin : public QScreenDriverPlugin +class ShivaVGGraphicsSystemPlugin : public QGraphicsSystemPlugin { public: - HybridPlugin(); - QStringList keys() const; - QScreen *create(const QString&, int displayId); + QGraphicsSystem *create(const QString&); }; -HybridPlugin::HybridPlugin() - : QScreenDriverPlugin() +QStringList ShivaVGGraphicsSystemPlugin::keys() const { + QStringList list; + list << "ShivaVG"; + return list; } -QStringList HybridPlugin::keys() const +QGraphicsSystem* ShivaVGGraphicsSystemPlugin::create(const QString& system) { - return (QStringList() << "hybrid"); -} + if (system.toLower() == "shivavg") + return new ShivaVGGraphicsSystem; -QScreen* HybridPlugin::create(const QString &driver, int displayId) -{ - if (driver.toLower() != "hybrid") - return 0; - - return new HybridScreen(displayId); + return 0; } -Q_EXPORT_STATIC_PLUGIN(Hybrid) -Q_EXPORT_PLUGIN2(hybridscreendriver, HybridPlugin) +Q_EXPORT_PLUGIN2(shivavg, ShivaVGGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/shivavg/shivavg.pro b/src/plugins/graphicssystems/shivavg/shivavg.pro new file mode 100644 index 0000000..b8ea12a --- /dev/null +++ b/src/plugins/graphicssystems/shivavg/shivavg.pro @@ -0,0 +1,12 @@ +TARGET = qshivavggraphicssystem +include(../../qpluginbase.pri) + +QT += openvg + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp shivavggraphicssystem.cpp shivavgwindowsurface.cpp +HEADERS = shivavggraphicssystem.h shivavgwindowsurface.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/mousedrivers/linuxis/linuxismousedriverplugin.h b/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp index d0245f55..51b3b5f 100644 --- a/src/plugins/mousedrivers/linuxis/linuxismousedriverplugin.h +++ b/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp @@ -39,20 +39,24 @@ ** ****************************************************************************/ -#ifndef LINUXISMOUSEDRIVERPLUGIN_H -#define LINUXISMOUSEDRIVERPLUGIN_H +#include "shivavggraphicssystem.h" +#include "shivavgwindowsurface.h" +#include <QtGui/private/qpixmap_raster_p.h> -#include <QtGui/QWSMouseHandlerFactoryInterface> +QT_BEGIN_NAMESPACE -class LinuxInputSubsystemMouseDriverPlugin : public QMouseDriverPlugin { - Q_OBJECT -public: - LinuxInputSubsystemMouseDriverPlugin( QObject *parent = 0 ); - ~LinuxInputSubsystemMouseDriverPlugin(); +ShivaVGGraphicsSystem::ShivaVGGraphicsSystem() +{ +} - QWSMouseHandler* create(const QString& driver); - QWSMouseHandler* create(const QString& driver, const QString& device); - QStringList keys()const; -}; +QPixmapData *ShivaVGGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} -#endif // LINUXISMOUSEDRIVERPLUGIN_H +QWindowSurface *ShivaVGGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + return new ShivaVGWindowSurface(widget); +} + +QT_END_NAMESPACE diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.h b/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.h index e588883..da8ca2e 100644 --- a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.h +++ b/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.h @@ -39,20 +39,22 @@ ** ****************************************************************************/ -#ifndef LINUXISKBDDRIVERPLUGIN_H -#define LINUXISKBDDRIVERPLUGIN_H +#ifndef SHIVAVGGRAPHICSSYSTEM_H +#define SHIVAVGGRAPHICSSYSTEM_H -#include <QtGui/QWSKeyboardHandlerFactoryInterface> +#include <QtGui/private/qgraphicssystem_p.h> -class LinuxInputSubsystemKbdDriverPlugin : public QKbdDriverPlugin { - Q_OBJECT +QT_BEGIN_NAMESPACE + +class ShivaVGGraphicsSystem : public QGraphicsSystem +{ public: - LinuxInputSubsystemKbdDriverPlugin( QObject *parent = 0 ); - ~LinuxInputSubsystemKbdDriverPlugin(); + ShivaVGGraphicsSystem(); - QWSKeyboardHandler* create(const QString& driver, const QString& device); - QWSKeyboardHandler* create(const QString& driver); - QStringList keys()const; + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; }; -#endif // LINUXISKBDDRIVERPLUGIN_H +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp b/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp new file mode 100644 index 0000000..955aa55 --- /dev/null +++ b/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp @@ -0,0 +1,358 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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$ +** +****************************************************************************/ + +#define GL_GLEXT_PROTOTYPES +#include "shivavgwindowsurface.h" +#include <QtOpenVG/private/qpaintengine_vg_p.h> +#if defined(Q_WS_X11) +#include "private/qt_x11_p.h" +#include "qx11info_x11.h" +#include <GL/glx.h> + +extern QX11Info *qt_x11Info(const QPaintDevice *pd); +#endif + +// Define this to use framebuffer objects. +//#define QVG_USE_FBO 1 + +#include <vg/openvg.h> + +QT_BEGIN_NAMESPACE + +class QShivaContext +{ +public: + QShivaContext(); + ~QShivaContext(); + + bool makeCurrent(ShivaVGWindowSurfacePrivate *surface); + void doneCurrent(); + + bool initialized; + QSize currentSize; + ShivaVGWindowSurfacePrivate *currentSurface; +}; + +Q_GLOBAL_STATIC(QShivaContext, shivaContext); + +class ShivaVGWindowSurfacePrivate +{ +public: + ShivaVGWindowSurfacePrivate() + : isCurrent(false) + , needsResize(true) + , engine(0) +#if defined(QVG_USE_FBO) + , fbo(0) + , texture(0) +#endif +#if defined(Q_WS_X11) + , drawable(0) + , context(0) +#endif + { + } + ~ShivaVGWindowSurfacePrivate(); + + void ensureContext(QWidget *widget); + + QSize size; + bool isCurrent; + bool needsResize; + QVGPaintEngine *engine; +#if defined(QVG_USE_FBO) + GLuint fbo; + GLuint texture; +#endif +#if defined(Q_WS_X11) + GLXDrawable drawable; + GLXContext context; +#endif +}; + +QShivaContext::QShivaContext() + : initialized(false) + , currentSurface(0) +{ +} + +QShivaContext::~QShivaContext() +{ + if (initialized) + vgDestroyContextSH(); +} + +bool QShivaContext::makeCurrent(ShivaVGWindowSurfacePrivate *surface) +{ + if (currentSurface) + currentSurface->isCurrent = false; + surface->isCurrent = true; + currentSurface = surface; + currentSize = surface->size; +#if defined(Q_WS_X11) + glXMakeCurrent(X11->display, surface->drawable, surface->context); +#endif + if (!initialized) { + if (!vgCreateContextSH(currentSize.width(), currentSize.height())) { + qWarning("vgCreateContextSH(%d, %d): could not create context", currentSize.width(), currentSize.height()); + return false; + } + initialized = true; + } else { + vgResizeSurfaceSH(currentSize.width(), currentSize.height()); + } +#if defined(QVG_USE_FBO) + if (surface->fbo) + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface->fbo); + else + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); +#endif + return true; +} + +void QShivaContext::doneCurrent() +{ + if (currentSurface) { + currentSurface->isCurrent = false; + currentSurface = 0; + } +#if defined(Q_WS_X11) + glXMakeCurrent(X11->display, 0, 0); +#endif +} + +ShivaVGWindowSurfacePrivate::~ShivaVGWindowSurfacePrivate() +{ +#if defined(QVG_USE_FBO) + if (fbo) { + glDeleteTextures(1, &texture); + glDeleteFramebuffersEXT(1, &fbo); + } +#endif +} + +void ShivaVGWindowSurfacePrivate::ensureContext(QWidget *widget) +{ +#if defined(Q_WS_X11) + Window win = widget->winId(); + if (win != drawable) { + if (context) + glXDestroyContext(X11->display, context); + drawable = win; + } + if (context == 0) { + const QX11Info *xinfo = qt_x11Info(widget); + int spec[64]; + int i = 0; + spec[i++] = GLX_DOUBLEBUFFER; + spec[i++] = GLX_DEPTH_SIZE; + spec[i++] = 1; + spec[i++] = GLX_STENCIL_SIZE; + spec[i++] = 1; + spec[i++] = GLX_RGBA; + spec[i++] = GLX_RED_SIZE; + spec[i++] = 1; + spec[i++] = GLX_GREEN_SIZE; + spec[i++] = 1; + spec[i++] = GLX_BLUE_SIZE; + spec[i++] = 1; + spec[i++] = GLX_SAMPLE_BUFFERS_ARB; + spec[i++] = 1; + spec[i++] = GLX_SAMPLES_ARB; + spec[i++] = 4; + spec[i] = XNone; + XVisualInfo *visual = glXChooseVisual + (xinfo->display(), xinfo->screen(), spec); + context = glXCreateContext(X11->display, visual, 0, True); + if (!context) + qWarning("glXCreateContext: could not create GL context for VG rendering"); + } +#else + Q_UNUSED(widget); +#endif +#if defined(QVG_USE_FBO) + if (needsResize && fbo) { +#if defined(Q_WS_X11) + glXMakeCurrent(X11->display, drawable, context); +#endif + glDeleteTextures(1, &texture); + glDeleteFramebuffersEXT(1, &fbo); +#if defined(Q_WS_X11) + glXMakeCurrent(X11->display, 0, 0); +#endif + fbo = 0; + texture = 0; + } + if (!fbo) { +#if defined(Q_WS_X11) + glXMakeCurrent(X11->display, drawable, context); +#endif + glGenFramebuffersEXT(1, &fbo); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); + + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, size.width(), size.height(), 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glFramebufferTexture2DEXT + (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, + texture, 0); + + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); +#if defined(Q_WS_X11) + glXMakeCurrent(X11->display, 0, 0); +#endif + } +#endif + needsResize = false; +} + +ShivaVGWindowSurface::ShivaVGWindowSurface(QWidget *window) + : QWindowSurface(window), d_ptr(new ShivaVGWindowSurfacePrivate) +{ +} + +ShivaVGWindowSurface::~ShivaVGWindowSurface() +{ + if (d_ptr->isCurrent) { + shivaContext()->doneCurrent(); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } +#if defined(Q_WS_X11) + if (d_ptr->context) + glXDestroyContext(X11->display, d_ptr->context); +#endif + delete d_ptr; +} + +QPaintDevice *ShivaVGWindowSurface::paintDevice() +{ + d_ptr->ensureContext(window()); + shivaContext()->makeCurrent(d_ptr); + glClearDepth(0.0f); + glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + return this; +} + +void ShivaVGWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(region); + Q_UNUSED(offset); + QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget(); + d_ptr->ensureContext(parent); + QShivaContext *context = shivaContext(); + if (!d_ptr->isCurrent) + context->makeCurrent(d_ptr); +#if defined(QVG_USE_FBO) + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + if (d_ptr->fbo) { + static GLfloat const vertices[][2] = { + {-1, -1}, {1, -1}, {1, 1}, {-1, 1} + }; + static GLfloat const texCoords[][2] = { + {0, 0}, {1, 0}, {1, 1}, {0, 1} + }; + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glVertexPointer(2, GL_FLOAT, 0, vertices); + glTexCoordPointer(2, GL_FLOAT, 0, texCoords); + glBindTexture(GL_TEXTURE_2D, d_ptr->texture); + glEnable(GL_TEXTURE_2D); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + glDisable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, 0); + } +#endif +#if defined(Q_WS_X11) + glXSwapBuffers(X11->display, d_ptr->drawable); +#endif + context->doneCurrent(); +} + +void ShivaVGWindowSurface::setGeometry(const QRect &rect) +{ + QWindowSurface::setGeometry(rect); + d_ptr->needsResize = true; + d_ptr->size = rect.size(); +} + +bool ShivaVGWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void ShivaVGWindowSurface::beginPaint(const QRegion ®ion) +{ + // Nothing to do here. + Q_UNUSED(region); +} + +void ShivaVGWindowSurface::endPaint(const QRegion ®ion) +{ + // Nothing to do here. + Q_UNUSED(region); +} + +Q_GLOBAL_STATIC(QVGPaintEngine, sharedPaintEngine); + +QPaintEngine *ShivaVGWindowSurface::paintEngine() const +{ + if (!d_ptr->engine) + d_ptr->engine = sharedPaintEngine(); + return d_ptr->engine; +} + +int ShivaVGWindowSurface::metric(PaintDeviceMetric met) const +{ + return qt_paint_device_metric(window(), met); +} + +QT_END_NAMESPACE diff --git a/src/plugins/mousedrivers/yopy/main.cpp b/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h index bf40f3f..aab7209 100644 --- a/src/plugins/mousedrivers/yopy/main.cpp +++ b/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h @@ -39,38 +39,38 @@ ** ****************************************************************************/ -#include <qmousedriverplugin_qws.h> -#include <qmouseyopy_qws.h> +#ifndef SHIVAVGWINDOWSURFACE_H +#define SHIVAVGWINDOWSURFACE_H + +#include <QtGui/private/qwindowsurface_p.h> QT_BEGIN_NAMESPACE -class QYopyMouseDriver : public QMouseDriverPlugin +class ShivaVGWindowSurfacePrivate; + +class ShivaVGWindowSurface : public QWindowSurface, public QPaintDevice { public: - QYopyMouseDriver(); + ShivaVGWindowSurface(QWidget *window); + virtual ~ShivaVGWindowSurface(); - QStringList keys() const; - QWSMouseHandler* create(const QString &driver, const QString &device); -}; + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); -QYopyMouseDriver::QYopyMouseDriver() - : QMouseDriverPlugin() -{ -} + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); -QStringList QYopyMouseDriver::keys() const -{ - return (QStringList() << QLatin1String("Yopy")); -} + QPaintEngine *paintEngine() const; -QWSMouseHandler* QYopyMouseDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("yopy"), Qt::CaseInsensitive)) - return 0; - return new QWSYopyMouseHandler(driver, device); -} +protected: + int metric(PaintDeviceMetric metric) const; -Q_EXPORT_PLUGIN2(qwsyopymousehandler, QYopyMouseDriver) +private: + ShivaVGWindowSurfacePrivate *d_ptr; +}; QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/trace/main.cpp b/src/plugins/graphicssystems/trace/main.cpp new file mode 100644 index 0000000..ae1f3c5 --- /dev/null +++ b/src/plugins/graphicssystems/trace/main.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 <private/qgraphicssystemplugin_p.h> +#include "qgraphicssystem_trace_p.h" + +QT_BEGIN_NAMESPACE + +class QTraceGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QTraceGraphicsSystemPlugin::keys() const +{ + return QStringList(QLatin1String("Trace")); +} + +QGraphicsSystem* QTraceGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == QLatin1String("trace")) + return new QTraceGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(trace, QTraceGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp new file mode 100644 index 0000000..8756ecb --- /dev/null +++ b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 "qgraphicssystem_trace_p.h" +#include <private/qpixmap_raster_p.h> +#include <private/qpaintbuffer_p.h> +#include <private/qwindowsurface_raster_p.h> + +#include <QFile> +#include <QPainter> +#include <QtDebug> + +QT_BEGIN_NAMESPACE + +class QTraceWindowSurface : public QRasterWindowSurface +{ +public: + QTraceWindowSurface(QWidget *widget); + ~QTraceWindowSurface(); + + QPaintDevice *paintDevice(); + void beginPaint(const QRegion &rgn); + void endPaint(const QRegion &rgn); + + bool scroll(const QRegion &area, int dx, int dy); + +private: + QPaintBuffer *buffer; + QList<QRegion> updates; + + qulonglong winId; +}; + +QTraceWindowSurface::QTraceWindowSurface(QWidget *widget) + : QRasterWindowSurface(widget) + , buffer(0) + , winId(0) +{ +} + +QTraceWindowSurface::~QTraceWindowSurface() +{ + if (buffer) { + QFile outputFile(QString(QLatin1String("qtgraphics-%0.trace")).arg(winId)); + if (outputFile.open(QIODevice::WriteOnly)) { + QDataStream out(&outputFile); + out << *buffer << updates; + } + delete buffer; + } +} + +QPaintDevice *QTraceWindowSurface::paintDevice() +{ + if (!buffer) { + buffer = new QPaintBuffer; + buffer->setBoundingRect(geometry()); + } + return buffer; +} + +void QTraceWindowSurface::beginPaint(const QRegion &rgn) +{ + // ensure paint buffer is created + paintDevice(); + buffer->beginNewFrame(); + + QRasterWindowSurface::beginPaint(rgn); +} + +void QTraceWindowSurface::endPaint(const QRegion &rgn) +{ + QPainter p(QRasterWindowSurface::paintDevice()); + buffer->draw(&p, buffer->numFrames()-1); + p.end(); + + winId = (qulonglong)window()->winId(); + + updates << rgn; + + QRasterWindowSurface::endPaint(rgn); +} + +bool QTraceWindowSurface::scroll(const QRegion &, int, int) +{ + // TODO: scrolling should also be streamed and replayed + // to test scrolling performance + return false; +} + +QTraceGraphicsSystem::QTraceGraphicsSystem() +{ +} + +QPixmapData *QTraceGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QTraceGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + return new QTraceWindowSurface(widget); +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h b/src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h new file mode 100644 index 0000000..4493aa7 --- /dev/null +++ b/src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 QGRAPHICSSYSTEM_TRACE_P_H +#define QGRAPHICSSYSTEM_TRACE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qgraphicssystem_p.h> + +QT_BEGIN_NAMESPACE + +class QTraceGraphicsSystem : public QGraphicsSystem +{ +public: + QTraceGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/trace/trace.pro b/src/plugins/graphicssystems/trace/trace.pro new file mode 100644 index 0000000..d548a6c --- /dev/null +++ b/src/plugins/graphicssystems/trace/trace.pro @@ -0,0 +1,12 @@ +TARGET = qtracegraphicssystem +include(../../qpluginbase.pri) + +QT += network + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_trace.cpp + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target +INCLUDEPATH += ../../../3rdparty/harfbuzz/src diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp index 1cbc1d7..a86a3a4 100644 --- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp +++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp @@ -74,7 +74,7 @@ public: + QString::number((((((size.width()<<11)|size.height())<<11)|mode)<<4)|state, 16); } void stepSerialNum() - { serialNum = lastSerialNum.fetchAndAddRelaxed(1); }; + { serialNum = lastSerialNum.fetchAndAddRelaxed(1); } void loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state); diff --git a/src/plugins/iconengines/svgiconengine/svgiconengine.pro b/src/plugins/iconengines/svgiconengine/svgiconengine.pro index 2e105ee..5c5a31e 100644 --- a/src/plugins/iconengines/svgiconengine/svgiconengine.pro +++ b/src/plugins/iconengines/svgiconengine/svgiconengine.pro @@ -9,3 +9,5 @@ QT += xml svg QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/iconengines target.path += $$[QT_INSTALL_PLUGINS]/iconengines INSTALLS += target + +symbian:TARGET.UID3=0x2001B2E3 diff --git a/src/plugins/imageformats/gif/gif.pro b/src/plugins/imageformats/gif/gif.pro index 74586b2..8a5c51a 100644 --- a/src/plugins/imageformats/gif/gif.pro +++ b/src/plugins/imageformats/gif/gif.pro @@ -8,3 +8,5 @@ SOURCES += main.cpp \ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/imageformats target.path += $$[QT_INSTALL_PLUGINS]/imageformats INSTALLS += target + +symbian:TARGET.UID3=0x2001E61A diff --git a/src/plugins/imageformats/ico/ico.pro b/src/plugins/imageformats/ico/ico.pro index 73665cd..eadff41 100644 --- a/src/plugins/imageformats/ico/ico.pro +++ b/src/plugins/imageformats/ico/ico.pro @@ -10,3 +10,5 @@ SOURCES += main.cpp \ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/imageformats target.path += $$[QT_INSTALL_PLUGINS]/imageformats INSTALLS += target + +symbian:TARGET.UID3=0x2001E616 diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 0d3a78a..e01b33a 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -57,38 +57,38 @@ // in an ICO file. typedef struct { - quint8 bWidth; // Width of the image - quint8 bHeight; // Height of the image (times 2) - quint8 bColorCount; // Number of colors in image (0 if >=8bpp) [ not ture ] - quint8 bReserved; // Reserved - quint16 wPlanes; // Color Planes - quint16 wBitCount; // Bits per pixel - quint32 dwBytesInRes; // how many bytes in this resource? - quint32 dwImageOffset; // where in the file is this image + quint8 bWidth; // Width of the image + quint8 bHeight; // Height of the image (times 2) + quint8 bColorCount; // Number of colors in image (0 if >=8bpp) [ not ture ] + quint8 bReserved; // Reserved + quint16 wPlanes; // Color Planes + quint16 wBitCount; // Bits per pixel + quint32 dwBytesInRes; // how many bytes in this resource? + quint32 dwImageOffset; // where in the file is this image } ICONDIRENTRY, *LPICONDIRENTRY; #define ICONDIRENTRY_SIZE 16 typedef struct { - quint16 idReserved; // Reserved - quint16 idType; // resource type (1 for icons) - quint16 idCount; // how many images? - ICONDIRENTRY idEntries[1]; // the entries for each image + quint16 idReserved; // Reserved + quint16 idType; // resource type (1 for icons) + quint16 idCount; // how many images? + ICONDIRENTRY idEntries[1]; // the entries for each image } ICONDIR, *LPICONDIR; #define ICONDIR_SIZE 6 // Exclude the idEntries field -typedef struct { // BMP information header - quint32 biSize; // size of this struct - quint32 biWidth; // pixmap width - quint32 biHeight; // pixmap height - quint16 biPlanes; // should be 1 - quint16 biBitCount; // number of bits per pixel - quint32 biCompression; // compression method - quint32 biSizeImage; // size of image - quint32 biXPelsPerMeter; // horizontal resolution - quint32 biYPelsPerMeter; // vertical resolution - quint32 biClrUsed; // number of colors used - quint32 biClrImportant; // number of important colors +typedef struct { // BMP information header + quint32 biSize; // size of this struct + quint32 biWidth; // pixmap width + quint32 biHeight; // pixmap height (specifies the combined height of the XOR and AND masks) + quint16 biPlanes; // should be 1 + quint16 biBitCount; // number of bits per pixel + quint32 biCompression; // compression method + quint32 biSizeImage; // size of image + quint32 biXPelsPerMeter; // horizontal resolution + quint32 biYPelsPerMeter; // vertical resolution + quint32 biClrUsed; // number of colors used + quint32 biClrImportant; // number of important colors } BMP_INFOHDR ,*LPBMP_INFOHDR; #define BMP_INFOHDR_SIZE 40 @@ -108,7 +108,7 @@ private: bool readHeader(); bool readIconEntry(int index, ICONDIRENTRY * iconEntry); - bool readBMPHeader(ICONDIRENTRY & iconEntry, BMP_INFOHDR * header); + bool readBMPHeader(quint32 imageOffset, BMP_INFOHDR * header); void findColorInfo(QImage & image); void readColorTable(QImage & image); @@ -254,7 +254,7 @@ ICOReader::ICOReader(QIODevice * iodevice) int ICOReader::count() { if (readHeader()) - return iconDir.idCount; + return iconDir.idCount; return 0; } @@ -268,17 +268,17 @@ bool ICOReader::canRead(QIODevice *iodev) if (readIconDir(iodev, &ikonDir)) { qint64 readBytes = ICONDIR_SIZE; if (readIconDirEntry(iodev, &ikonDir.idEntries[0])) { - readBytes += ICONDIRENTRY_SIZE; - // ICO format does not have a magic identifier, so we read 6 different values, which will hopefully be enough to identify the file. - if ( ikonDir.idReserved == 0 - && ikonDir.idType == 1 - && ikonDir.idEntries[0].bReserved == 0 - && ikonDir.idEntries[0].wPlanes <= 1 - && ikonDir.idEntries[0].wBitCount <= 32 // Bits per pixel - && ikonDir.idEntries[0].dwBytesInRes >= 40 // Must be over 40, since sizeof (infoheader) == 40 - ) { - isProbablyICO = true; - } + readBytes += ICONDIRENTRY_SIZE; + // ICO format does not have a magic identifier, so we read 6 different values, which will hopefully be enough to identify the file. + if ( ikonDir.idReserved == 0 + && ikonDir.idType == 1 + && ikonDir.idEntries[0].bReserved == 0 + && ikonDir.idEntries[0].wPlanes <= 1 + && ikonDir.idEntries[0].wBitCount <= 32 // Bits per pixel + && ikonDir.idEntries[0].dwBytesInRes >= 40 // Must be over 40, since sizeof (infoheader) == 40 + ) { + isProbablyICO = true; + } if (iodev->isSequential()) { // Our structs might be padded due to alignment, so we need to fetch each member before we ungetChar() ! @@ -323,8 +323,7 @@ bool ICOReader::canRead(QIODevice *iodev) iodev->ungetChar((tmp >> 8) & 0xff); iodev->ungetChar(tmp & 0xff); } - - } + } if (!iodev->isSequential()) iodev->seek(oldPos); } @@ -334,21 +333,21 @@ bool ICOReader::canRead(QIODevice *iodev) bool ICOReader::readHeader() { if (iod && !headerRead) { - startpos = iod->pos(); - if (readIconDir(iod, &iconDir)) { - if (iconDir.idReserved == 0 || iconDir.idType == 1) - headerRead = true; - } + startpos = iod->pos(); + if (readIconDir(iod, &iconDir)) { + if (iconDir.idReserved == 0 || iconDir.idType == 1) + headerRead = true; + } } return headerRead; } -bool ICOReader::readIconEntry(int index, ICONDIRENTRY * iconEntry) +bool ICOReader::readIconEntry(int index, ICONDIRENTRY *iconEntry) { if (iod) { - if (iod->seek(startpos + ICONDIR_SIZE + (index * ICONDIRENTRY_SIZE))) { - return readIconDirEntry(iod, iconEntry); + if (iod->seek(startpos + ICONDIR_SIZE + (index * ICONDIRENTRY_SIZE))) { + return readIconDirEntry(iod, iconEntry); } } return false; @@ -356,49 +355,24 @@ bool ICOReader::readIconEntry(int index, ICONDIRENTRY * iconEntry) -bool ICOReader::readBMPHeader(ICONDIRENTRY & iconEntry, BMP_INFOHDR * header) +bool ICOReader::readBMPHeader(quint32 imageOffset, BMP_INFOHDR * header) { - memset(&icoAttrib, 0, sizeof(IcoAttrib)); if (iod) { - if (iod->seek(startpos + iconEntry.dwImageOffset)) { - if (readBMPInfoHeader(iod, header)) { - - icoAttrib.nbits = header->biBitCount ? header->biBitCount : iconEntry.wBitCount; - icoAttrib.h = header->biHeight / 2; // this height is always double the iconEntry height (for the mask) - icoAttrib.w = header->biWidth; - - switch (icoAttrib.nbits) { - case 32: - case 24: - case 16: - icoAttrib.depth = 32; - break; - case 8: - case 4: - icoAttrib.depth = 8; - break; - default: - icoAttrib.depth = 1; - } - - if ( icoAttrib.depth == 32 ) // there's no colormap - icoAttrib.ncolors = 0; - else // # colors used - icoAttrib.ncolors = header->biClrUsed ? header->biClrUsed : 1 << icoAttrib.nbits; - //qDebug() << "Bits:" << icoAttrib.nbits << "Depth:" << icoAttrib.depth << "Ncols:" << icoAttrib.ncolors; - return TRUE; - } - } + if (iod->seek(startpos + imageOffset)) { + if (readBMPInfoHeader(iod, header)) { + return TRUE; + } + } } return FALSE; } void ICOReader::findColorInfo(QImage & image) { - if (icoAttrib.ncolors > 0) { // set color table - readColorTable(image); + if (icoAttrib.ncolors > 0) { // set color table + readColorTable(image); } else if (icoAttrib.nbits == 16) { // don't support RGB values for 15/16 bpp - image = QImage(); + image = QImage(); } } @@ -406,29 +380,29 @@ void ICOReader::readColorTable(QImage & image) { if (iod) { image.setNumColors(icoAttrib.ncolors); - uchar rgb[4]; - for (int i=0; i<icoAttrib.ncolors; i++) { - if (iod->read((char*)rgb, 4) != 4) { - image = QImage(); - break; - } - image.setColor(i, qRgb(rgb[2],rgb[1],rgb[0])); - } + uchar rgb[4]; + for (int i=0; i<icoAttrib.ncolors; i++) { + if (iod->read((char*)rgb, 4) != 4) { + image = QImage(); + break; + } + image.setColor(i, qRgb(rgb[2],rgb[1],rgb[0])); + } } else { - image = QImage(); + image = QImage(); } } void ICOReader::readBMP(QImage & image) { - if (icoAttrib.nbits == 1) { // 1 bit BMP image - read1BitBMP(image); - } else if (icoAttrib.nbits == 4) { // 4 bit BMP image - read4BitBMP(image); + if (icoAttrib.nbits == 1) { // 1 bit BMP image + read1BitBMP(image); + } else if (icoAttrib.nbits == 4) { // 4 bit BMP image + read4BitBMP(image); } else if (icoAttrib.nbits == 8) { - read8BitBMP(image); + read8BitBMP(image); } else if (icoAttrib.nbits == 16 || icoAttrib.nbits == 24 || icoAttrib.nbits == 32 ) { // 16,24,32 bit BMP image - read16_24_32BMP(image); + read16_24_32BMP(image); } } @@ -442,17 +416,17 @@ void ICOReader::read1BitBMP(QImage & image) { if (iod) { - int h = image.height(); - int bpl = image.bytesPerLine(); + int h = image.height(); + int bpl = image.bytesPerLine(); - while (--h >= 0) { - if (iod->read((char*)image.scanLine(h),bpl) != bpl) { - image = QImage(); - break; - } - } + while (--h >= 0) { + if (iod->read((char*)image.scanLine(h),bpl) != bpl) { + image = QImage(); + break; + } + } } else { - image = QImage(); + image = QImage(); } } @@ -460,30 +434,30 @@ void ICOReader::read4BitBMP(QImage & image) { if (iod) { - int h = icoAttrib.h; - int buflen = ((icoAttrib.w+7)/8)*4; - uchar *buf = new uchar[buflen]; - Q_CHECK_PTR(buf); - - while (--h >= 0) { - if (iod->read((char*)buf,buflen) != buflen) { - image = QImage(); - break; - } - register uchar *p = image.scanLine(h); - uchar *b = buf; - for (int i=0; i<icoAttrib.w/2; i++) { // convert nibbles to bytes - *p++ = *b >> 4; - *p++ = *b++ & 0x0f; - } - if (icoAttrib.w & 1) // the last nibble - *p = *b >> 4; - } - - delete [] buf; + int h = icoAttrib.h; + int buflen = ((icoAttrib.w+7)/8)*4; + uchar *buf = new uchar[buflen]; + Q_CHECK_PTR(buf); + + while (--h >= 0) { + if (iod->read((char*)buf,buflen) != buflen) { + image = QImage(); + break; + } + register uchar *p = image.scanLine(h); + uchar *b = buf; + for (int i=0; i<icoAttrib.w/2; i++) { // convert nibbles to bytes + *p++ = *b >> 4; + *p++ = *b++ & 0x0f; + } + if (icoAttrib.w & 1) // the last nibble + *p = *b >> 4; + } + + delete [] buf; } else { - image = QImage(); + image = QImage(); } } @@ -491,52 +465,51 @@ void ICOReader::read8BitBMP(QImage & image) { if (iod) { - int h = icoAttrib.h; - int bpl = image.bytesPerLine(); + int h = icoAttrib.h; + int bpl = image.bytesPerLine(); - while (--h >= 0) { - if (iod->read((char *)image.scanLine(h), bpl) != bpl) { - image = QImage(); - break; - } - } + while (--h >= 0) { + if (iod->read((char *)image.scanLine(h), bpl) != bpl) { + image = QImage(); + break; + } + } } else { - image = QImage(); + image = QImage(); } } void ICOReader::read16_24_32BMP(QImage & image) { if (iod) { - - int h = icoAttrib.h; - register QRgb *p; - QRgb *end; - uchar *buf = new uchar[image.bytesPerLine()]; - int bpl = ((icoAttrib.w*icoAttrib.nbits+31)/32)*4; - uchar *b; - - while (--h >= 0) { - p = (QRgb *)image.scanLine(h); - end = p + icoAttrib.w; - if (iod->read((char *)buf, bpl) != bpl) { - image = QImage(); - break; - } - b = buf; - while (p < end) { + int h = icoAttrib.h; + register QRgb *p; + QRgb *end; + uchar *buf = new uchar[image.bytesPerLine()]; + int bpl = ((icoAttrib.w*icoAttrib.nbits+31)/32)*4; + uchar *b; + + while (--h >= 0) { + p = (QRgb *)image.scanLine(h); + end = p + icoAttrib.w; + if (iod->read((char *)buf, bpl) != bpl) { + image = QImage(); + break; + } + b = buf; + while (p < end) { if (icoAttrib.nbits == 24) *p++ = qRgb(*(b+2), *(b+1), *b); else if (icoAttrib.nbits == 32) *p++ = qRgba(*(b+2), *(b+1), *b, *(b+3)); - b += icoAttrib.nbits/8; - } - } + b += icoAttrib.nbits/8; + } + } - delete[] buf; + delete[] buf; } else { - image = QImage(); + image = QImage(); } } @@ -549,8 +522,41 @@ QImage ICOReader::iconAt(int index) ICONDIRENTRY iconEntry; if (readIconEntry(index, &iconEntry)) { + static const uchar pngMagicData[] = { 137, 80, 78, 71, 13, 10, 26, 10 }; + + iod->seek(iconEntry.dwImageOffset); + + const QByteArray pngMagic = QByteArray::fromRawData((char*)pngMagicData, sizeof(pngMagicData)); + const bool isPngImage = (iod->read(pngMagic.size()) == pngMagic); + + if (isPngImage) { + iod->seek(iconEntry.dwImageOffset); + return QImage::fromData(iod->read(iconEntry.dwBytesInRes), "png"); + } + BMP_INFOHDR header; - if (readBMPHeader(iconEntry, &header)) { + if (readBMPHeader(iconEntry.dwImageOffset, &header)) { + icoAttrib.nbits = header.biBitCount ? header.biBitCount : iconEntry.wBitCount; + + switch (icoAttrib.nbits) { + case 32: + case 24: + case 16: + icoAttrib.depth = 32; + break; + case 8: + case 4: + icoAttrib.depth = 8; + break; + default: + icoAttrib.depth = 1; + } + if (icoAttrib.depth == 32) // there's no colormap + icoAttrib.ncolors = 0; + else // # colors used + icoAttrib.ncolors = header.biClrUsed ? header.biClrUsed : 1 << icoAttrib.nbits; + icoAttrib.w = iconEntry.bWidth; + icoAttrib.h = iconEntry.bHeight; QImage::Format format = QImage::Format_ARGB32; if (icoAttrib.nbits == 24) @@ -605,8 +611,8 @@ QList<QImage> ICOReader::read(QIODevice * device) QList<QImage> images; ICOReader reader(device); - for (int i=0; i<reader.count(); i++) - images += reader.iconAt(i); + for (int i = 0; i < reader.count(); i++) + images += reader.iconAt(i); return images; } @@ -659,8 +665,8 @@ bool ICOReader::write(QIODevice * device, const QList<QImage> & images) } maskImage = maskImage.convertToFormat(QImage::Format_Mono); - int nbits = 32; - int bpl_bmp = ((image.width()*nbits+31)/32)*4; + int nbits = 32; + int bpl_bmp = ((image.width()*nbits+31)/32)*4; entries[i].bColorCount = 0; entries[i].bReserved = 0; @@ -670,7 +676,7 @@ bool ICOReader::write(QIODevice * device, const QList<QImage> & images) entries[i].dwBytesInRes = BMP_INFOHDR_SIZE + (bpl_bmp * image.height()) + (maskImage.bytesPerLine() * maskImage.height()); entries[i].wPlanes = 1; - if (i==0) + if (i == 0) entries[i].dwImageOffset = origOffset + ICONDIR_SIZE + (id.idCount * ICONDIRENTRY_SIZE); else @@ -695,7 +701,7 @@ bool ICOReader::write(QIODevice * device, const QList<QImage> & images) uchar *b; memset( buf, 0, bpl_bmp ); int y; - for (y=image.height()-1; y>=0; y--) { // write the image bits + for (y = image.height() - 1; y >= 0; y--) { // write the image bits // 32 bits QRgb *p = (QRgb *)image.scanLine(y); QRgb *end = p + image.width(); @@ -717,13 +723,10 @@ bool ICOReader::write(QIODevice * device, const QList<QImage> & images) maskImage.invertPixels(); // seems as though it needs this // NOTE! !! The mask is only flipped vertically - not horizontally !! - for (y=maskImage.height()-1; y>=0; y--) + for (y = maskImage.height() - 1; y >= 0; y--) buffer.write((char*)maskImage.scanLine(y), maskImage.bytesPerLine()); - } - - if (writeIconDir(device, id)) { int i; bool bOK = true; @@ -731,7 +734,7 @@ bool ICOReader::write(QIODevice * device, const QList<QImage> & images) bOK = writeIconDirEntry(device, entries[i]); } if (bOK) { - for (i=0; i<id.idCount && bOK; i++) { + for (i = 0; i < id.idCount && bOK; i++) { bOK = writeBMPInfoHeader(device, bmpHeaders[i]); bOK &= (device->write(imageData[i]) == (int) imageData[i].size()); } diff --git a/src/plugins/imageformats/jpeg/jpeg.pro b/src/plugins/imageformats/jpeg/jpeg.pro index f310902..ebc79cc 100644 --- a/src/plugins/imageformats/jpeg/jpeg.pro +++ b/src/plugins/imageformats/jpeg/jpeg.pro @@ -13,6 +13,12 @@ wince*: { contains(CE_ARCH,x86):CONFIG += exceptions_off } +symbian: { + #Disable warnings in 3rdparty code due to unused arguments + QMAKE_CXXFLAGS.CW += -W nounusedarg + TARGET.UID3=0x2001E61B +} + contains(QT_CONFIG, system-jpeg) { unix:LIBS += -ljpeg win32:LIBS += libjpeg.lib @@ -71,3 +77,4 @@ contains(QT_CONFIG, system-jpeg) { QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/imageformats target.path += $$[QT_INSTALL_PLUGINS]/imageformats INSTALLS += target + diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index ce437e3..3b23e56 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -790,7 +790,8 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage, #ifndef QT_NO_IMAGE_SMOOTHSCALE // If high quality not required, shrink image during decompression - if (scaledSize.isValid() && quality < HIGH_QUALITY_THRESHOLD && !params.contains(QLatin1String("GetHeaderInformation")) ) { + if (scaledSize.isValid() && !scaledSize.isEmpty() && quality < HIGH_QUALITY_THRESHOLD + && !params.contains(QLatin1String("GetHeaderInformation")) ) { cinfo.scale_denom = qMin(cinfo.image_width / scaledSize.width(), cinfo.image_width / scaledSize.height()); if (cinfo.scale_denom < 2) { @@ -894,7 +895,8 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage, (void) jpeg_finish_decompress(&cinfo); } #ifndef QT_NO_IMAGE_SMOOTHSCALE - } else if (scaledSize.isValid()) { + } else if (scaledSize.isValid() && scaledSize != QSize(cinfo.output_width, cinfo.output_height) + && quality >= HIGH_QUALITY_THRESHOLD) { jpegSmoothScaler scaler(&cinfo, QString().sprintf("Scale( %d, %d, ScaleFree )", scaledSize.width(), @@ -945,6 +947,9 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage, outImage->setDotsPerMeterX(int(100. * cinfo.X_density)); outImage->setDotsPerMeterY(int(100. * cinfo.Y_density)); } + + if (scaledSize.isValid() && scaledSize != QSize(cinfo.output_width, cinfo.output_height)) + *outImage = outImage->scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::FastTransformation); } } diff --git a/src/plugins/imageformats/mng/mng.pro b/src/plugins/imageformats/mng/mng.pro index f0943f5..de7dfa7 100644 --- a/src/plugins/imageformats/mng/mng.pro +++ b/src/plugins/imageformats/mng/mng.pro @@ -7,6 +7,12 @@ HEADERS += qmnghandler.h SOURCES += main.cpp \ qmnghandler.cpp +symbian: { + #Disable warnings in 3rdparty code due to unused variables and arguments + QMAKE_CXXFLAGS.CW += -W nounused + TARGET.UID3=0x2001E619 +} + contains(QT_CONFIG, system-mng) { unix:LIBS += -lmng win32:LIBS += libmng.lib @@ -47,3 +53,4 @@ contains(QT_CONFIG, system-zlib) { QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/imageformats target.path += $$[QT_INSTALL_PLUGINS]/imageformats INSTALLS += target + diff --git a/src/plugins/imageformats/mng/qmnghandler.cpp b/src/plugins/imageformats/mng/qmnghandler.cpp index dd62e74..b235749 100644 --- a/src/plugins/imageformats/mng/qmnghandler.cpp +++ b/src/plugins/imageformats/mng/qmnghandler.cpp @@ -375,8 +375,6 @@ QMngHandler::QMngHandler() QMngHandler::~QMngHandler() { - Q_D(QMngHandler); - delete d; } /*! \reimp */ diff --git a/src/plugins/imageformats/mng/qmnghandler.h b/src/plugins/imageformats/mng/qmnghandler.h index 6dfc42d..2f72543 100644 --- a/src/plugins/imageformats/mng/qmnghandler.h +++ b/src/plugins/imageformats/mng/qmnghandler.h @@ -42,6 +42,7 @@ #ifndef QMNGHANDLER_H #define QMNGHANDLER_H +#include <QtCore/qscopedpointer.h> #include <QtGui/qimageiohandler.h> QT_BEGIN_NAMESPACE @@ -74,7 +75,7 @@ class QMngHandler : public QImageIOHandler private: Q_DECLARE_PRIVATE(QMngHandler) - QMngHandlerPrivate *d_ptr; + QScopedPointer<QMngHandlerPrivate> d_ptr; }; QT_END_NAMESPACE diff --git a/src/plugins/imageformats/svg/svg.pro b/src/plugins/imageformats/svg/svg.pro index 747d556..bcf4c21 100644 --- a/src/plugins/imageformats/svg/svg.pro +++ b/src/plugins/imageformats/svg/svg.pro @@ -9,3 +9,5 @@ QT += xml svg QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/imageformats target.path += $$[QT_INSTALL_PLUGINS]/imageformats INSTALLS += target + +symbian:TARGET.UID3=0x2001E618 diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index d3b9386..3669be7 100644 --- a/src/plugins/imageformats/tiff/qtiffhandler.cpp +++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp @@ -98,6 +98,43 @@ void qtiffUnmapProc(thandle_t /*fd*/, tdata_t /*base*/, toff_t /*size*/) { } +// for 32 bits images +inline void rotate_right_mirror_horizontal(QImage *const image)// rotate right->mirrored horizontal +{ + const int height = image->height(); + const int width = image->width(); + QImage generated(/* width = */ height, /* height = */ width, image->format()); + const uint32 *originalPixel = reinterpret_cast<const uint32*>(image->bits()); + uint32 *const generatedPixels = reinterpret_cast<uint32*>(generated.bits()); + for (int row=0; row < height; ++row) { + for (int col=0; col < width; ++col) { + int idx = col * height + row; + generatedPixels[idx] = *originalPixel; + ++originalPixel; + } + } + *image = generated; +} + +inline void rotate_right_mirror_vertical(QImage *const image) // rotate right->mirrored vertical +{ + const int height = image->height(); + const int width = image->width(); + QImage generated(/* width = */ height, /* height = */ width, image->format()); + const int lastCol = width - 1; + const int lastRow = height - 1; + const uint32 *pixel = reinterpret_cast<const uint32*>(image->bits()); + uint32 *const generatedBits = reinterpret_cast<uint32*>(generated.bits()); + for (int row=0; row < height; ++row) { + for (int col=0; col < width; ++col) { + int idx = (lastCol - col) * height + (lastRow - row); + generatedBits[idx] = *pixel; + ++pixel; + } + } + *image = generated; +} + QTiffHandler::QTiffHandler() : QImageIOHandler() { compression = NoCompression; @@ -131,58 +168,206 @@ bool QTiffHandler::read(QImage *image) if (!canRead()) return false; - TIFF *tiff = TIFFClientOpen("foo", - "r", - this, - qtiffReadProc, - qtiffWriteProc, - qtiffSeekProc, - qtiffCloseProc, - qtiffSizeProc, - qtiffMapProc, - qtiffUnmapProc); - - if (tiff) { - uint32 width = 0; - uint32 height = 0; - TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &width); - TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &height); - if (image->size() != QSize(width, height) || image->format() != QImage::Format_ARGB32) - *image = QImage(width, height, QImage::Format_ARGB32); + TIFF *const tiff = TIFFClientOpen("foo", + "r", + this, + qtiffReadProc, + qtiffWriteProc, + qtiffSeekProc, + qtiffCloseProc, + qtiffSizeProc, + qtiffMapProc, + qtiffUnmapProc); + + if (!tiff) { + return false; + } + uint32 width; + uint32 height; + uint16 photometric; + if (!TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &width) + || !TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &height) + || !TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric)) { + TIFFClose(tiff); + return false; + } + + if (photometric == PHOTOMETRIC_MINISBLACK || photometric == PHOTOMETRIC_MINISWHITE) { + if (image->size() != QSize(width, height) || image->format() != QImage::Format_Mono) + *image = QImage(width, height, QImage::Format_Mono); + QVector<QRgb> colortable(2); + if (photometric == PHOTOMETRIC_MINISBLACK) { + colortable[0] = 0xff000000; + colortable[1] = 0xffffffff; + } else { + colortable[0] = 0xffffffff; + colortable[1] = 0xff000000; + } + image->setColorTable(colortable); + if (!image->isNull()) { - if (TIFFReadRGBAImageOriented(tiff, width, height, reinterpret_cast<uint32 *>(image->bits()), ORIENTATION_TOPLEFT, 0)) { - uint16 resUnit = RESUNIT_NONE; - float resX = 0; - float resY = 0; - TIFFGetField(tiff, TIFFTAG_RESOLUTIONUNIT, &resUnit); - TIFFGetField(tiff, TIFFTAG_XRESOLUTION, &resX); - TIFFGetField(tiff, TIFFTAG_YRESOLUTION, &resY); - switch(resUnit) { - case RESUNIT_CENTIMETER: - image->setDotsPerMeterX(qRound(resX * 100)); - image->setDotsPerMeterY(qRound(resY * 100)); - break; - case RESUNIT_INCH: - image->setDotsPerMeterX(qRound(resX * (100 / 2.54))); - image->setDotsPerMeterY(qRound(resY * (100 / 2.54))); - break; - default: - // do nothing as defaults have already - // been set within the QImage class - break; + for (uint32 y=0; y<height; ++y) { + if (TIFFReadScanline(tiff, image->scanLine(y), y, 0) < 0) { + TIFFClose(tiff); + return false; + } + } + } + } else { + uint16 bitPerSample; + if (!TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitPerSample)) { + TIFFClose(tiff); + return false; + } + if (photometric == PHOTOMETRIC_PALETTE && bitPerSample == 8) { + if (image->size() != QSize(width, height) || image->format() != QImage::Format_Indexed8) + *image = QImage(width, height, QImage::Format_Indexed8); + if (!image->isNull()) { + // create the color table + const uint16 tableSize = 256; + uint16 *redTable = static_cast<uint16 *>(qMalloc(tableSize * sizeof(uint16))); + uint16 *greenTable = static_cast<uint16 *>(qMalloc(tableSize * sizeof(uint16))); + uint16 *blueTable = static_cast<uint16 *>(qMalloc(tableSize * sizeof(uint16))); + if (!redTable || !greenTable || !blueTable) { + TIFFClose(tiff); + return false; + } + if (!TIFFGetField(tiff, TIFFTAG_COLORMAP, &redTable, &greenTable, &blueTable)) { + TIFFClose(tiff); + return false; + } + + QVector<QRgb> qtColorTable(tableSize); + for (int i = 0; i<tableSize ;++i) { + const int red = redTable[i] / 257; + const int green = greenTable[i] / 257; + const int blue = blueTable[i] / 257; + qtColorTable[i] = qRgb(red, green, blue); + + } + + image->setColorTable(qtColorTable); + for (uint32 y=0; y<height; ++y) { + if (TIFFReadScanline(tiff, image->scanLine(y), y, 0) < 0) { + TIFFClose(tiff); + return false; + } + } + + // free redTable, greenTable and greenTable done by libtiff + } + } else { + if (image->size() != QSize(width, height) || image->format() != QImage::Format_ARGB32) + *image = QImage(width, height, QImage::Format_ARGB32); + if (!image->isNull()) { + const int stopOnError = 1; + if (TIFFReadRGBAImageOriented(tiff, width, height, reinterpret_cast<uint32 *>(image->bits()), ORIENTATION_TOPLEFT, stopOnError)) { + for (uint32 y=0; y<height; ++y) + convert32BitOrder(image->scanLine(y), width); + } else { + TIFFClose(tiff); + return false; } - for (uint32 y=0; y<height; ++y) - convert32BitOrder(image->scanLine(y), width); - } else { - *image = QImage(); } } - TIFFClose(tiff); } - if (image->isNull()) + if (image->isNull()) { + TIFFClose(tiff); return false; + } + + float resX = 0; + float resY = 0; + uint16 resUnit = RESUNIT_NONE; + if (TIFFGetField(tiff, TIFFTAG_RESOLUTIONUNIT, &resUnit) + && TIFFGetField(tiff, TIFFTAG_XRESOLUTION, &resX) + && TIFFGetField(tiff, TIFFTAG_YRESOLUTION, &resY)) { + + switch(resUnit) { + case RESUNIT_CENTIMETER: + image->setDotsPerMeterX(qRound(resX * 100)); + image->setDotsPerMeterY(qRound(resY * 100)); + break; + case RESUNIT_INCH: + image->setDotsPerMeterX(qRound(resX * (100 / 2.54))); + image->setDotsPerMeterY(qRound(resY * (100 / 2.54))); + break; + default: + // do nothing as defaults have already + // been set within the QImage class + break; + } + } + // rotate the image if the orientation is defined in the file + uint16 orientationTag; + if (TIFFGetField(tiff, TIFFTAG_ORIENTATION, &orientationTag)) { + if (image->format() == QImage::Format_ARGB32) { + // TIFFReadRGBAImageOriented() flip the image but does not rotate them + switch (orientationTag) { + case 5: + rotate_right_mirror_horizontal(image); + break; + case 6: + rotate_right_mirror_vertical(image); + break; + case 7: + rotate_right_mirror_horizontal(image); + break; + case 8: + rotate_right_mirror_vertical(image); + break; + } + } else { + switch (orientationTag) { + case 1: // default orientation + break; + case 2: // mirror horizontal + *image = image->mirrored(true, false); + break; + case 3: // mirror both + *image = image->mirrored(true, true); + break; + case 4: // mirror vertical + *image = image->mirrored(false, true); + break; + case 5: // rotate right mirror horizontal + { + QMatrix transformation; + transformation.rotate(90); + *image = image->transformed(transformation); + *image = image->mirrored(true, false); + break; + } + case 6: // rotate right + { + QMatrix transformation; + transformation.rotate(90); + *image = image->transformed(transformation); + break; + } + case 7: // rotate right, mirror vertical + { + QMatrix transformation; + transformation.rotate(90); + *image = image->transformed(transformation); + *image = image->mirrored(false, true); + break; + } + case 8: // rotate left + { + QMatrix transformation; + transformation.rotate(270); + *image = image->transformed(transformation); + break; + } + } + } + } + + + TIFFClose(tiff); return true; } @@ -191,33 +376,148 @@ bool QTiffHandler::write(const QImage &image) if (!device()->isWritable()) return false; - TIFF *tiff = TIFFClientOpen("foo", - "w", - this, - qtiffReadProc, - qtiffWriteProc, - qtiffSeekProc, - qtiffCloseProc, - qtiffSizeProc, - qtiffMapProc, - qtiffUnmapProc); - - if (tiff) { - int width = image.width(); - int height = image.height(); - int depth = 32; - - if (!TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, width) - || !TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, height) - || !TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB) - || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW) - || !TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, depth/8) - || !TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG) - || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)) { + TIFF *const tiff = TIFFClientOpen("foo", + "w", + this, + qtiffReadProc, + qtiffWriteProc, + qtiffSeekProc, + qtiffCloseProc, + qtiffSizeProc, + qtiffMapProc, + qtiffUnmapProc); + if (!tiff) + return false; + + const int width = image.width(); + const int height = image.height(); + + if (!TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, width) + || !TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, height) + || !TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) { + TIFFClose(tiff); + return false; + } + + // set the resolution + bool resolutionSet = false; + const int dotPerMeterX = image.dotsPerMeterX(); + const int dotPerMeterY = image.dotsPerMeterY(); + if ((dotPerMeterX % 100) == 0 + && (dotPerMeterY % 100) == 0) { + resolutionSet = TIFFSetField(tiff, TIFFTAG_RESOLUTIONUNIT, RESUNIT_CENTIMETER) + && TIFFSetField(tiff, TIFFTAG_XRESOLUTION, dotPerMeterX/100.0) + && TIFFSetField(tiff, TIFFTAG_YRESOLUTION, dotPerMeterY/100.0); + } else { + resolutionSet = TIFFSetField(tiff, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH) + && TIFFSetField(tiff, TIFFTAG_XRESOLUTION, static_cast<float>(image.logicalDpiX())) + && TIFFSetField(tiff, TIFFTAG_YRESOLUTION, static_cast<float>(image.logicalDpiY())); + } + if (!resolutionSet) { + TIFFClose(tiff); + return false; + } + + // configure image depth + const QImage::Format format = image.format(); + if (format == QImage::Format_Mono || format == QImage::Format_MonoLSB) { + uint16 photometric = PHOTOMETRIC_MINISBLACK; + if (image.colorTable().at(0) == 0xffffffff) + photometric = PHOTOMETRIC_MINISWHITE; + if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, photometric) + || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_CCITTRLE)) { + TIFFClose(tiff); + return false; + } + + // try to do the conversion in chunks no greater than 16 MB + int chunks = (width * height / (1024 * 1024 * 16)) + 1; + int chunkHeight = qMax(height / chunks, 1); + + int y = 0; + while (y < height) { + QImage chunk = image.copy(0, y, width, qMin(chunkHeight, height - y)).convertToFormat(QImage::Format_Mono); + + int chunkStart = y; + int chunkEnd = y + chunk.height(); + while (y < chunkEnd) { + if (TIFFWriteScanline(tiff, reinterpret_cast<uint32 *>(chunk.scanLine(y - chunkStart)), y) != 1) { + TIFFClose(tiff); + return false; + } + ++y; + } + } + TIFFClose(tiff); + } else if (format == QImage::Format_Indexed8) { + if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE) + || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_PACKBITS) + || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)) { + TIFFClose(tiff); + return false; + } + //// write the color table + // allocate the color tables + uint16 *redTable = static_cast<uint16 *>(qMalloc(256 * sizeof(uint16))); + uint16 *greenTable = static_cast<uint16 *>(qMalloc(256 * sizeof(uint16))); + uint16 *blueTable = static_cast<uint16 *>(qMalloc(256 * sizeof(uint16))); + if (!redTable || !greenTable || !blueTable) { + TIFFClose(tiff); + return false; + } + + // set the color table + const QVector<QRgb> colorTable = image.colorTable(); + + const int tableSize = colorTable.size(); + Q_ASSERT(tableSize <= 256); + for (int i = 0; i<tableSize; ++i) { + const QRgb color = colorTable.at(i); + redTable[i] = qRed(color) * 257; + greenTable[i] = qGreen(color) * 257; + blueTable[i] = qBlue(color) * 257; + } + + const bool setColorTableSuccess = TIFFSetField(tiff, TIFFTAG_COLORMAP, redTable, greenTable, blueTable); + + qFree(redTable); + qFree(greenTable); + qFree(blueTable); + + if (!setColorTableSuccess) { TIFFClose(tiff); return false; } + //// write the data + // try to do the conversion in chunks no greater than 16 MB + int chunks = (width * height/ (1024 * 1024 * 16)) + 1; + int chunkHeight = qMax(height / chunks, 1); + + int y = 0; + while (y < height) { + QImage chunk = image.copy(0, y, width, qMin(chunkHeight, height - y)); + + int chunkStart = y; + int chunkEnd = y + chunk.height(); + while (y < chunkEnd) { + if (TIFFWriteScanline(tiff, reinterpret_cast<uint32 *>(chunk.scanLine(y - chunkStart)), y) != 1) { + TIFFClose(tiff); + return false; + } + ++y; + } + } + TIFFClose(tiff); + + } else { + if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB) + || !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW) + || !TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 4) + || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)) { + TIFFClose(tiff); + return false; + } // try to do the ARGB32 conversion in chunks no greater than 16 MB int chunks = (width * height * 4 / (1024 * 1024 * 16)) + 1; int chunkHeight = qMax(height / chunks, 1); @@ -242,9 +542,8 @@ bool QTiffHandler::write(const QImage &image) } } TIFFClose(tiff); - } else { - return false; } + return true; } diff --git a/src/plugins/imageformats/tiff/tiff.pro b/src/plugins/imageformats/tiff/tiff.pro index 8930cf3..312f99c 100644 --- a/src/plugins/imageformats/tiff/tiff.pro +++ b/src/plugins/imageformats/tiff/tiff.pro @@ -56,6 +56,9 @@ contains(QT_CONFIG, system-tiff) { wince*: { SOURCES += ../../../corelib/kernel/qfunctions_wince.cpp } + symbian*: { + SOURCES += ../../../3rdparty/libtiff/port/lfind.c + } } contains(QT_CONFIG, system-zlib) { @@ -68,3 +71,5 @@ contains(QT_CONFIG, system-zlib) { QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/imageformats target.path += $$[QT_INSTALL_PLUGINS]/imageformats INSTALLS += target + +symbian:TARGET.UID3=0x2001E617 diff --git a/src/plugins/kbddrivers/kbddrivers.pro b/src/plugins/kbddrivers/kbddrivers.pro index 6605972..dbab47b 100644 --- a/src/plugins/kbddrivers/kbddrivers.pro +++ b/src/plugins/kbddrivers/kbddrivers.pro @@ -1,6 +1,2 @@ TEMPLATE = subdirs -contains(kbd-plugins, usb): SUBDIRS += usb -contains(kbd-plugins, sl5000): SUBDIRS += sl5000 -contains(kbd-plugins, vr41xx): SUBDIRS += vr41xx -contains(kbd-plugins, yopy): SUBDIRS += yopy -contains(kbd-plugins, linuxis): SUBDIRS += linuxis +contains(kbd-plugins, linuxinput): SUBDIRS += linuxinput diff --git a/src/plugins/kbddrivers/linuxinput/linuxinput.pro b/src/plugins/kbddrivers/linuxinput/linuxinput.pro new file mode 100644 index 0000000..862a220 --- /dev/null +++ b/src/plugins/kbddrivers/linuxinput/linuxinput.pro @@ -0,0 +1,14 @@ +TARGET = qlinuxinputkbddriver +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers +target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers +INSTALLS += target + +DEFINES += QT_QWS_KBD_LINUXINPUT + +HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdlinuxinput_qws.h + +SOURCES = main.cpp \ + $$QT_SOURCE_TREE/src/gui/embedded/qkbdlinuxinput_qws.cpp + diff --git a/src/plugins/kbddrivers/sl5000/main.cpp b/src/plugins/kbddrivers/linuxinput/main.cpp index 04e1142..a923882 100644 --- a/src/plugins/kbddrivers/sl5000/main.cpp +++ b/src/plugins/kbddrivers/linuxinput/main.cpp @@ -40,37 +40,38 @@ ****************************************************************************/ #include <qkbddriverplugin_qws.h> -#include <qkbdsl5000_qws.h> +#include <qkbdlinuxinput_qws.h> QT_BEGIN_NAMESPACE -class QSL5000KbdDriver : public QKbdDriverPlugin +class QLinuxInputKbdDriver : public QKbdDriverPlugin { public: - QSL5000KbdDriver(); + QLinuxInputKbdDriver(); QStringList keys() const; QWSKeyboardHandler* create(const QString &driver, const QString &device); }; -QSL5000KbdDriver::QSL5000KbdDriver() +QLinuxInputKbdDriver::QLinuxInputKbdDriver() : QKbdDriverPlugin() { } -QStringList QSL5000KbdDriver::keys() const +QStringList QLinuxInputKbdDriver::keys() const { - return (QStringList() << QLatin1String("SL5000")); + return (QStringList() << QLatin1String("LinuxInput")); } -QWSKeyboardHandler* QSL5000KbdDriver::create(const QString &driver, - const QString &device) +QWSKeyboardHandler* QLinuxInputKbdDriver::create(const QString &driver, + const QString &device) { - if (driver.compare(QLatin1String("SL5000"), Qt::CaseInsensitive)) + Q_UNUSED(device); + if (driver.compare(QLatin1String("LinuxInput"), Qt::CaseInsensitive)) return 0; - return new QWSSL5000KeyboardHandler(device); + return new QWSLinuxInputKeyboardHandler(driver, device); } -Q_EXPORT_PLUGIN2(qwssl5000kbddriver, QSL5000KbdDriver) +Q_EXPORT_PLUGIN2(qwslinuxinputkbddriver, QLinuxInputKbdDriver) QT_END_NAMESPACE diff --git a/src/plugins/kbddrivers/linuxis/README b/src/plugins/kbddrivers/linuxis/README deleted file mode 100644 index 37a9a89..0000000 --- a/src/plugins/kbddrivers/linuxis/README +++ /dev/null @@ -1 +0,0 @@ -This is a keypad/only keyboard driver based on the Linux input subsystem. diff --git a/src/plugins/kbddrivers/linuxis/linuxis.pro b/src/plugins/kbddrivers/linuxis/linuxis.pro deleted file mode 100644 index 5e652b5..0000000 --- a/src/plugins/kbddrivers/linuxis/linuxis.pro +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = linuxiskbdhandler -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers -target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers -INSTALLS += target - -CONFIG+=no_tr - -HEADERS = linuxiskbddriverplugin.h linuxiskbdhandler.h -SOURCES = linuxiskbddriverplugin.cpp linuxiskbdhandler.cpp diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp b/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp deleted file mode 100644 index 17cc074..0000000 --- a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 "linuxiskbddriverplugin.h" -#include "linuxiskbdhandler.h" - -#include <qdebug.h> -#if 1 -#define qLog(x) qDebug() -#else -#define qLog(x) while (0) qDebug() -#endif - -LinuxInputSubsystemKbdDriverPlugin::LinuxInputSubsystemKbdDriverPlugin( QObject *parent ) - : QKbdDriverPlugin( parent ) -{ -} - -LinuxInputSubsystemKbdDriverPlugin::~LinuxInputSubsystemKbdDriverPlugin() -{ -} - -QWSKeyboardHandler* LinuxInputSubsystemKbdDriverPlugin::create(const QString &driver, const QString &device) -{ - if (device.isEmpty()) { - return create( driver ); - } - if( driver.toLower() == "linuxis" || driver.toLower() == "linuxiskbdhandler" ) { - qLog(Input) << "Before call LinuxInputSubsystemKbdHandler(" << device << ")"; - return new LinuxInputSubsystemKbdHandler(device); - } - return 0; -} - -QWSKeyboardHandler* LinuxInputSubsystemKbdDriverPlugin::create( const QString &driver) -{ - if( driver.toLower() == "linuxis" || driver.toLower() == "linuxiskbdhandler" ) { - qLog(Input) << "Before call LinuxInputSubsystemKbdHandler()"; - return new LinuxInputSubsystemKbdHandler(); - } - return 0; -} - -QStringList LinuxInputSubsystemKbdDriverPlugin::keys() const -{ - return QStringList() << "linuxis" << "linuxiskbdhandler"; -} - -Q_EXPORT_PLUGIN2(qwslinuxiskbdhandler, LinuxInputSubsystemKbdDriverPlugin) diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp b/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp deleted file mode 100644 index 2f8728e..0000000 --- a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 "linuxiskbdhandler.h" - -#include <QSocketNotifier> - -#include <stdlib.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#include <string.h> - -#include <linux/input.h> -#include <linux/kd.h> - -#include <qdebug.h> -#if 1 -#define qLog(x) qDebug() -#else -#define qLog(x) while (0) qDebug() -#endif - -struct LinuxInputSubsystemKbdHandler::keytable_s LinuxInputSubsystemKbdHandler::keytable[] = { - { KEY_PAGEDOWN, 0xffff, Qt::Key_Context1 }, - { KEY_END, 0xffff, Qt::Key_Back }, - { KEY_RIGHTCTRL, 0xffff, Qt::Key_Home }, - { KEY_SPACE, 0xffff, Qt::Key_Menu }, - { KEY_ENTER, 0xffff, Qt::Key_Select }, - { KEY_UP, 0xffff, Qt::Key_Up }, - { KEY_LEFT, 0xffff, Qt::Key_Left }, - { KEY_RIGHT, 0xffff, Qt::Key_Right }, - { KEY_DOWN, 0xffff, Qt::Key_Down }, - { KEY_POWER, 0xffff, Qt::Key_Call }, - { KEY_BACKSPACE, 0xffff, Qt::Key_Backspace }, - { KEY_F1, 0xffff, Qt::Key_Hangup }, - { KEY_KP1, '1', Qt::Key_1 }, - { KEY_KP2, '2', Qt::Key_2 }, - { KEY_KP3, '3', Qt::Key_3 }, - { KEY_KP4, '4', Qt::Key_4 }, - { KEY_KP5, '5', Qt::Key_5 }, - { KEY_KP6, '6', Qt::Key_6 }, - { KEY_KP7, '7', Qt::Key_7 }, - { KEY_KP8, '8', Qt::Key_8 }, - { KEY_KP9, '9', Qt::Key_9 }, - { KEY_KP0, '0', Qt::Key_0 }, - { KEY_APOSTROPHE, '*', Qt::Key_Asterisk }, - { KEY_3, '#', Qt::Key_NumberSign }, - { KEY_F2, 0xffff, Qt::Key_F2 }, - { KEY_F3, 0xffff, Qt::Key_F3 }, - { KEY_F4, 0xffff, Qt::Key_F4 }, - { KEY_F5, 0xffff, Qt::Key_F5 }, - { KEY_F6, 0xffff, Qt::Key_F6 }, - { KEY_F7, 0xffff, Qt::Key_VolumeUp }, - { KEY_F8, 0xffff, Qt::Key_VolumeDown }, - { KEY_F9, 0xffff, Qt::Key_F9 }, - { 0, 0, Qt::Key_unknown }, -}; - -struct LinuxInputSubsystemKbdHandler::keymap_s LinuxInputSubsystemKbdHandler::keymap[KEY_MAX]; - -LinuxInputSubsystemKbdHandler::LinuxInputSubsystemKbdHandler(const QString &device) -{ - qLog(Input) << "Loaded LinuxInputSubsystem keypad plugin!"; - setObjectName( "LinuxInputSubsystem Keypad Handler" ); - kbdFD = ::open(device.toLocal8Bit().constData(), O_RDONLY, 0); - if (kbdFD >= 0) { - qLog(Input) << "Opened" << device << "as keypad input"; -#if 0 - struct kbd_repeat kbdrep; - kbdrep.delay = 500; /* ms */ - kbdrep.period = 250; /* ms */ - ioctl(kbdFD, KDKBDREP, &kbdrep); -#endif - m_notify = new QSocketNotifier( kbdFD, QSocketNotifier::Read, this ); - connect( m_notify, SIGNAL(activated(int)), this, SLOT(readKbdData())); - } else { - qWarning("Cannot open '%s' for keypad (%s)", - device.toLocal8Bit().constData(), strerror(errno)); - return; - } - shift = false; - - initmap(); -} - -LinuxInputSubsystemKbdHandler::~LinuxInputSubsystemKbdHandler() -{ -} - -void LinuxInputSubsystemKbdHandler::initmap() -{ - for (int i = 0; i < KEY_MAX; i++) { - keymap[i].unicode = 0xffff; - keymap[i].keycode = Qt::Key_unknown; - } - for (int i = 0; keytable[i].unicode; i++) { - int idx = keytable[i].code; - keymap[idx].unicode = keytable[i].unicode; - keymap[idx].keycode = keytable[i].keycode; - } -} - -void LinuxInputSubsystemKbdHandler::readKbdData() -{ - struct input_event *ie; - struct input_event iebuf[32]; - - uint n = ::read(kbdFD, iebuf, sizeof(iebuf)); - - bool pressed; - bool autorepeat; - int modifiers = 0; - int unicode, keycode; - - n /= sizeof(struct input_event); - ie = iebuf; - for (uint i = 0; i < n; i++) { - - pressed = ie->value != 0; - autorepeat = ie->value == 2; - qLog() << "keyEvent" << hex << ie->type << ie->code << ie->value; - unicode = keymap[ie->code].unicode; - keycode = keymap[ie->code].keycode; - - processKeyEvent(unicode, keycode, (Qt::KeyboardModifiers)modifiers, - pressed, autorepeat); - - ie++; - } - -} - diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h b/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h deleted file mode 100644 index 100d7fc..0000000 --- a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 LINUXISKBDHANDLER_H -#define LINUXISKBDHANDLER_H - -#include <QObject> -#include <QWSKeyboardHandler> - -class QSocketNotifier; -class LinuxInputSubsystemKbdHandler : public QObject, public QWSKeyboardHandler { - Q_OBJECT -public: - LinuxInputSubsystemKbdHandler(const QString &device = QString("/dev/input/event0")); - ~LinuxInputSubsystemKbdHandler(); - - struct keytable_s { - int code; - int unicode; - int keycode; - }; - - struct keymap_s { - int unicode; - int keycode; - }; - -private: - void initmap(); - - QSocketNotifier *m_notify; - int kbdFD; - bool shift; - - static struct keytable_s keytable[]; - static struct keymap_s keymap[]; - -private Q_SLOTS: - void readKbdData(); -}; - -#endif // LINUXISKBDHANDLER_H diff --git a/src/plugins/kbddrivers/sl5000/sl5000.pro b/src/plugins/kbddrivers/sl5000/sl5000.pro deleted file mode 100644 index e52cf0d..0000000 --- a/src/plugins/kbddrivers/sl5000/sl5000.pro +++ /dev/null @@ -1,16 +0,0 @@ -TARGET = qsl5000kbddriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers -target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers -INSTALLS += target - -DEFINES += QT_QWS_KBD_SL5000 QT_QWS_KBD_TTY - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdsl5000_qws.h \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdtty_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdsl5000_qws.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdtty_qws.cpp - diff --git a/src/plugins/kbddrivers/usb/usb.pro b/src/plugins/kbddrivers/usb/usb.pro deleted file mode 100644 index 4187255..0000000 --- a/src/plugins/kbddrivers/usb/usb.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qusbkbddriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers -target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers -INSTALLS += target - -DEFINES += QT_QWS_KBD_USB - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdusb_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdusb_qws.cpp - diff --git a/src/plugins/kbddrivers/vr41xx/main.cpp b/src/plugins/kbddrivers/vr41xx/main.cpp deleted file mode 100644 index 05e0008..0000000 --- a/src/plugins/kbddrivers/vr41xx/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 <qkbddriverplugin_qws.h> -#include <qkbdvr41xx_qws.h> - -QT_BEGIN_NAMESPACE - -class QVr41xxKbdDriver : public QKbdDriverPlugin -{ -public: - QVr41xxKbdDriver(); - - QStringList keys() const; - QWSKeyboardHandler* create(const QString &driver, const QString &device); -}; - -QVr41xxKbdDriver::QVr41xxKbdDriver() - : QKbdDriverPlugin() -{ -} - -QStringList QVr41xxKbdDriver::keys() const -{ - return (QStringList() << QLatin1String("VR41xx")); -} - -QWSKeyboardHandler* QVr41xxKbdDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("VR41xx"), Qt::CaseInsensitive)) - return 0; - return new QWSVr41xxKeyboardHandler(device); -} - -Q_EXPORT_PLUGIN2(qwsvr41xxkbddriver, QVr41xxKbdDriver) - -QT_END_NAMESPACE diff --git a/src/plugins/kbddrivers/vr41xx/vr41xx.pro b/src/plugins/kbddrivers/vr41xx/vr41xx.pro deleted file mode 100644 index f9f103f..0000000 --- a/src/plugins/kbddrivers/vr41xx/vr41xx.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qvr41xxkbddriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers -target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers -INSTALLS += target - -DEFINES += QT_QWS_KBD_VR41XX - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdvr41xx_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdvr41xx_qws.cpp - diff --git a/src/plugins/kbddrivers/yopy/main.cpp b/src/plugins/kbddrivers/yopy/main.cpp deleted file mode 100644 index 5ce5243..0000000 --- a/src/plugins/kbddrivers/yopy/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 <qkbddriverplugin_qws.h> -#include <qkbdyopy_qws.h> - -QT_BEGIN_NAMESPACE - -class QYopyKbdDriver : public QKbdDriverPlugin -{ -public: - QYopyKbdDriver(); - - QStringList keys() const; - QWSKeyboardHandler* create(const QString &driver, const QString &device); -}; - -QYopyKbdDriver::QYopyKbdDriver() - : QKbdDriverPlugin() -{ -} - -QStringList QYopyKbdDriver::keys() const -{ - return (QStringList() << QLatin1String("Yopy")); -} - -QWSKeyboardHandler* QYopyKbdDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("Yopy"), Qt::CaseInsensitive)) - return 0; - return new QWSYopyKeyboardHandler(device); -} - -Q_EXPORT_PLUGIN2(qwsyopykbddriver, QYopyKbdDriver) - -QT_END_NAMESPACE diff --git a/src/plugins/kbddrivers/yopy/yopy.pro b/src/plugins/kbddrivers/yopy/yopy.pro deleted file mode 100644 index 66a663c..0000000 --- a/src/plugins/kbddrivers/yopy/yopy.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qyopykbddriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers -target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers -INSTALLS += target - -DEFINES += QT_QWS_KBD_YOPY - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdyopy_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdyopy_qws.cpp - diff --git a/src/plugins/mousedrivers/bus/bus.pro b/src/plugins/mousedrivers/bus/bus.pro deleted file mode 100644 index cdb0332..0000000 --- a/src/plugins/mousedrivers/bus/bus.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qbusmousedriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mousedrivers -target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers -INSTALLS += target - -DEFINES += QT_QWS_MOUSE_BUS - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qmousebus_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qmousebus_qws.cpp - diff --git a/src/plugins/mousedrivers/linuxis/linuxis.pro b/src/plugins/mousedrivers/linuxis/linuxis.pro deleted file mode 100644 index bcc209b..0000000 --- a/src/plugins/mousedrivers/linuxis/linuxis.pro +++ /dev/null @@ -1,10 +0,0 @@ -TARGET = linuxismousehandler -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mousedrivers -target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers -INSTALLS += target - -HEADERS = linuxismousedriverplugin.h linuxismousehandler.h -SOURCES = linuxismousedriverplugin.cpp linuxismousehandler.cpp - diff --git a/src/plugins/mousedrivers/linuxis/linuxismousehandler.cpp b/src/plugins/mousedrivers/linuxis/linuxismousehandler.cpp deleted file mode 100644 index 87e8d97..0000000 --- a/src/plugins/mousedrivers/linuxis/linuxismousehandler.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 "linuxismousehandler.h" - -#include <QFile> -#include <QTextStream> -#include <QScreen> -#include <QSocketNotifier> -#include <QDebug> - -#include <qdebug.h> - -#include <string.h> -#include <errno.h> -#include <stdlib.h> -#include <fcntl.h> -#include <unistd.h> -#include <limits.h> - -#include <linux/input.h> - - -#if 1 -#define qLog(x) qDebug() -#else -#define qLog(x) while (0) qDebug() -#endif - - -// sanity check values of the range of possible mouse positions -#define MOUSE_SAMPLE_MIN 0 -#define MOUSE_SAMPLE_MAX 2000 - -LinuxInputSubsystemMouseHandler::LinuxInputSubsystemMouseHandler(const QString &device) - : mouseX(0), mouseY(0), mouseBtn(0), mouseIdx(0) -{ - qLog(Input) << "Loaded LinuxInputSubsystem touchscreen plugin!"; - setObjectName("LinuxInputSubsystem Mouse Handler"); - mouseFd = ::open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY); - // mouseFd = ::open(device.toLocal8Bit().constData(), O_RDONLY); - if (mouseFd >= 0) { - qLog(Input) << "Opened" << device << "as touchscreen input"; - m_notify = new QSocketNotifier(mouseFd, QSocketNotifier::Read, this); - connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData())); - } else { - qWarning("Cannot open %s for touchscreen input (%s)", - device.toLocal8Bit().constData(), strerror(errno)); - return; - } -} - -LinuxInputSubsystemMouseHandler::~LinuxInputSubsystemMouseHandler() -{ - if (mouseFd >= 0) - ::close(mouseFd); -} - -void LinuxInputSubsystemMouseHandler::suspend() -{ - m_notify->setEnabled( false ); -} - -void LinuxInputSubsystemMouseHandler::resume() -{ - m_notify->setEnabled( true ); -} - -void LinuxInputSubsystemMouseHandler::readMouseData() -{ - if (!qt_screen) - return; - - int n; - - do { - n = read(mouseFd, mouseBuf + mouseIdx, mouseBufSize - mouseIdx); - if (n > 0) - mouseIdx += n; - - struct input_event *data; - int idx = 0; - - while (mouseIdx-idx >= (int)sizeof(struct input_event)) { - uchar *mb = mouseBuf + idx; - data = (struct input_event *) mb; - // qLog(Input) << "mouse event type =" << data->type << "code =" << data->code << "value =" << data->value; - bool unknown = false; - if (data->type == EV_ABS) { - if (data->code == ABS_X) { - //qLog(Input) << "\tABS_X" << data->value; - mouseX = data->value; - } else if (data->code == ABS_Y) { - //qLog(Input) << "\tABS_Y" << data->value; - mouseY = data->value; - } else { - unknown = true; - } - } else if (data->type == EV_REL) { - //qLog(Input) << "\tEV_REL" << hex << data->code << dec << data->value; - if (data->code == REL_X) { - mouseX += data->value; - } else if (data->code == REL_Y) { - mouseY += data->value; - } else { - unknown = true; - } - } else if (data->type == EV_KEY && data->code == BTN_TOUCH) { - qLog(Input) << "\tBTN_TOUCH" << data->value; - mouseBtn = data->value ? Qt::LeftButton : 0; - } else if (data->type == EV_KEY) { - int button = 0; - switch (data->code) { - case BTN_LEFT: button = Qt::LeftButton; break; - case BTN_MIDDLE: button = Qt::MidButton; break; - case BTN_RIGHT: button = Qt::RightButton; break; - } - if (data->value) - mouseBtn |= button; - else - mouseBtn &= ~button; - } else if (data->type == EV_SYN && data->code == SYN_REPORT) { - QPoint pos( mouseX, mouseY ); - oldmouse = transform( pos ); - //qLog(Input) << "\tSYN_REPORT" << mouseBtn << pos << oldmouse; - emit mouseChanged(oldmouse, mouseBtn); - - } else { - unknown = true; - } - if (unknown) { - qWarning("unknown mouse event type=%x, code=%x, value=%x", data->type, data->code, data->value); - } - idx += sizeof(struct input_event); - } - int surplus = mouseIdx - idx; - for (int i = 0; i < surplus; i++) - mouseBuf[i] = mouseBuf[idx+i]; - mouseIdx = surplus; - } while (n > 0); -} - diff --git a/src/plugins/mousedrivers/mousedrivers.pro b/src/plugins/mousedrivers/mousedrivers.pro index e644361..f89682b 100644 --- a/src/plugins/mousedrivers/mousedrivers.pro +++ b/src/plugins/mousedrivers/mousedrivers.pro @@ -1,8 +1,5 @@ TEMPLATE = subdirs -contains(mouse-plugins, bus): SUBDIRS += bus contains(mouse-plugins, linuxtp): SUBDIRS += linuxtp contains(mouse-plugins, pc): SUBDIRS += pc contains(mouse-plugins, tslib): SUBDIRS += tslib -contains(mouse-plugins, vr41xx): SUBDIRS += vr41xx -contains(mouse-plugins, yopy): SUBDIRS += yopy -contains(mouse-plugins, linuxis): SUBDIRS += linuxis +contains(mouse-plugins, linuxinput): SUBDIRS += linuxinput diff --git a/src/plugins/mousedrivers/vr41xx/main.cpp b/src/plugins/mousedrivers/vr41xx/main.cpp deleted file mode 100644 index ed68518..0000000 --- a/src/plugins/mousedrivers/vr41xx/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 <qmousedriverplugin_qws.h> -#include <qmousevr41xx_qws.h> - -QT_BEGIN_NAMESPACE - -class QVr41xxMouseDriver : public QMouseDriverPlugin -{ -public: - QVr41xxMouseDriver(); - - QStringList keys() const; - QWSMouseHandler* create(const QString &driver, const QString &device); -}; - -QVr41xxMouseDriver::QVr41xxMouseDriver() - : QMouseDriverPlugin() -{ -} - -QStringList QVr41xxMouseDriver::keys() const -{ - return (QStringList() << QLatin1String("VR41xx")); -} - -QWSMouseHandler* QVr41xxMouseDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("VR41xx"), Qt::CaseInsensitive)) - return 0; - return new QWSVr41xxMouseHandler(driver, device); -} - -Q_EXPORT_PLUGIN2(qwsvr41xxmousehandler, QVr41xxMouseDriver) - -QT_END_NAMESPACE diff --git a/src/plugins/mousedrivers/vr41xx/vr41xx.pro b/src/plugins/mousedrivers/vr41xx/vr41xx.pro deleted file mode 100644 index 1c22d04..0000000 --- a/src/plugins/mousedrivers/vr41xx/vr41xx.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qvr41xxmousedriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mousedrivers -target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers -INSTALLS += target - -DEFINES += QT_QWS_MOUSE_VR41XX - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qmousevr41xx_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qmousevr41xx_qws.cpp - diff --git a/src/plugins/mousedrivers/yopy/yopy.pro b/src/plugins/mousedrivers/yopy/yopy.pro deleted file mode 100644 index 3045430..0000000 --- a/src/plugins/mousedrivers/yopy/yopy.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qyopymousedriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mousedrivers -target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers -INSTALLS += target - -DEFINES += QT_QWS_MOUSE_YOPY - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qmouseyopy_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qmouseyopy_qws.cpp - diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro new file mode 100644 index 0000000..ff27ea1 --- /dev/null +++ b/src/plugins/phonon/mmf/mmf.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = mmfphonondebug plugin + +plugin.depends = mmfphonondebug diff --git a/src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro b/src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro new file mode 100644 index 0000000..2cfec15 --- /dev/null +++ b/src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro @@ -0,0 +1,31 @@ +TEMPLATE = lib +TARGET = phonon_mmf_debug +OBJECTDUMP_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf/mmfphonondebug + +CONFIG += staticlib + +DEFINES += OBJECTDUMP_LIBRARY + +HEADERS += \ + $$OBJECTDUMP_DIR/objectdump_global.h \ + $$OBJECTDUMP_DIR/objectdump.h \ + $$OBJECTDUMP_DIR/objecttree.h + +SOURCES += \ + $$OBJECTDUMP_DIR/objectdump.cpp \ + $$OBJECTDUMP_DIR/objecttree.cpp + +symbian { + HEADERS += $$OBJECTDUMP_DIR/objectdump_symbian.h + SOURCES += $$OBJECTDUMP_DIR/objectdump_symbian.cpp + + LIBS += -lcone + LIBS += -lws32 + + TARGET.CAPABILITY = all -tcb + +} else { + SOURCES += $$OBJECTDUMP_DIR/objectdump_stub.cpp +} + +TARGET.UID3=0x2001E62A diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro new file mode 100644 index 0000000..eb7fd27 --- /dev/null +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -0,0 +1,88 @@ +# MMF Phonon backend + +QT += phonon +TARGET = phonon_mmf +PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf + +# Uncomment the following line in order to use the CDrmPlayerUtility client +# API for audio playback, rather than CMdaAudioPlayerUtility. +#CONFIG += phonon_mmf_audio_drm + +phonon_mmf_audio_drm { + LIBS += -lDrmAudioPlayUtility + DEFINES += QT_PHONON_MMF_AUDIO_DRM +} else { + LIBS += -lmediaclientaudio +} + +# This is necessary because both epoc32/include and Phonon contain videoplayer.h. +# By making /epoc32/include the first SYSTEMINCLUDE, we ensure that +# '#include <videoplayer.h>' picks up the Symbian header, as intended. +PREPEND_INCLUDEPATH = /epoc32/include + +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + +HEADERS += \ + $$PHONON_MMF_DIR/abstractaudioeffect.h \ + $$PHONON_MMF_DIR/abstractmediaplayer.h \ + $$PHONON_MMF_DIR/abstractplayer.h \ + $$PHONON_MMF_DIR/audiooutput.h \ + $$PHONON_MMF_DIR/audioequalizer.h \ + $$PHONON_MMF_DIR/audioplayer.h \ + $$PHONON_MMF_DIR/backend.h \ + $$PHONON_MMF_DIR/bassboost.h \ + $$PHONON_MMF_DIR/defs.h \ + $$PHONON_MMF_DIR/dummyplayer.h \ + $$PHONON_MMF_DIR/effectfactory.h \ + $$PHONON_MMF_DIR/mmf_medianode.h \ + $$PHONON_MMF_DIR/mediaobject.h \ + $$PHONON_MMF_DIR/utils.h \ + $$PHONON_MMF_DIR/videooutput.h \ + $$PHONON_MMF_DIR/videooutputobserver.h \ + $$PHONON_MMF_DIR/mmf_videoplayer.h \ + $$PHONON_MMF_DIR/videowidget.h \ + $$PHONON_MMF_DIR/volumeobserver.h + +SOURCES += \ + $$PHONON_MMF_DIR/abstractaudioeffect.cpp \ + $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ + $$PHONON_MMF_DIR/abstractplayer.cpp \ + $$PHONON_MMF_DIR/audiooutput.cpp \ + $$PHONON_MMF_DIR/audioequalizer.cpp \ + $$PHONON_MMF_DIR/audioplayer.cpp \ + $$PHONON_MMF_DIR/backend.cpp \ + $$PHONON_MMF_DIR/bassboost.cpp \ + $$PHONON_MMF_DIR/dummyplayer.cpp \ + $$PHONON_MMF_DIR/effectfactory.cpp \ + $$PHONON_MMF_DIR/mmf_medianode.cpp \ + $$PHONON_MMF_DIR/mediaobject.cpp \ + $$PHONON_MMF_DIR/utils.cpp \ + $$PHONON_MMF_DIR/videooutput.cpp \ + $$PHONON_MMF_DIR/mmf_videoplayer.cpp \ + $$PHONON_MMF_DIR/videowidget.cpp + +debug { + INCLUDEPATH += $$PHONON_MMF_DIR/mmfphonondebug + LIBS += -lphonon_mmf_debug.lib + LIBS += -lhal +} + +LIBS += -lmediaclientvideo # For CVideoPlayerUtility +LIBS += -lcone # For CCoeEnv +LIBS += -lws32 # For RWindow +LIBS += -lefsrv # For file server +LIBS += -lapgrfx -lapmime # For recognizer + +# These are for effects. +LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect + +# This is needed for having the .qtplugin file properly created on Symbian. +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend + +target.path = $$[QT_INSTALL_PLUGINS]/phonon_backend +INSTALLS += target + +include(../../../qpluginbase.pri) + +TARGET.UID3=0x2001E629 + diff --git a/src/plugins/phonon/phonon.pro b/src/plugins/phonon/phonon.pro index e43a4c2..814a062 100644 --- a/src/plugins/phonon/phonon.pro +++ b/src/plugins/phonon/phonon.pro @@ -7,3 +7,4 @@ mac:contains(QT_CONFIG, phonon-backend): SUBDIRS *= qt7 win32:!wince*:contains(QT_CONFIG, phonon-backend): SUBDIRS *= ds9 wince*:contains(QT_CONFIG, phonon-backend): SUBDIRS *= waveout wince*:contains(QT_CONFIG, directshow): SUBDIRS *= ds9 +symbian:contains(QT_CONFIG, phonon-backend): SUBDIRS *= mmf diff --git a/src/plugins/phonon/qt7/qt7.pro b/src/plugins/phonon/qt7/qt7.pro index 665baee..53407db 100644 --- a/src/plugins/phonon/qt7/qt7.pro +++ b/src/plugins/phonon/qt7/qt7.pro @@ -12,7 +12,7 @@ contains(QMAKE_MAC_XARCH, no) { LIBS += -Xarch_i386 -framework QuickTime -Xarch_ppc -framework QuickTime } -LIBS += -framework AudioUnit \ +LIBS += -framework AppKit -framework AudioUnit \ -framework AudioToolbox -framework CoreAudio \ -framework QuartzCore -framework QTKit diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index cf4edf1..004b816 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -1,12 +1,14 @@ TEMPLATE = subdirs SUBDIRS *= accessible imageformats sqldrivers iconengines script -unix { +unix:!symbian { contains(QT_CONFIG,iconv)|contains(QT_CONFIG,gnu-libiconv):SUBDIRS *= codecs } else { SUBDIRS *= codecs } !embedded:SUBDIRS *= graphicssystems embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers -!win32:!embedded:!mac:SUBDIRS *= inputmethods +!win32:!embedded:!mac:!symbian:SUBDIRS *= inputmethods +symbian:SUBDIRS += s60 contains(QT_CONFIG, phonon): SUBDIRS *= phonon +contains(QT_CONFIG, multimedia): SUBDIRS *= audio diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri index 5664f81..a3abc98 100644 --- a/src/plugins/qpluginbase.pri +++ b/src/plugins/qpluginbase.pri @@ -1,6 +1,6 @@ TEMPLATE = lib isEmpty(QT_MAJOR_VERSION) { - VERSION=4.5.4 + VERSION=4.6.0 } else { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } @@ -13,3 +13,9 @@ contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols include(../qt_targets.pri) wince*:LIBS += $$QMAKE_LIBS_GUI + +symbian: { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY = All -Tcb + load(armcc_warnings) +} diff --git a/src/plugins/s60/3_1/3_1.pro b/src/plugins/s60/3_1/3_1.pro new file mode 100644 index 0000000..58ff5ce --- /dev/null +++ b/src/plugins/s60/3_1/3_1.pro @@ -0,0 +1,9 @@ +include(../s60pluginbase.pri) + +TARGET = qts60plugin_3_1 + +SOURCES += ../src/qlocale_3_1.cpp \ + ../src/qdesktopservices_3_1.cpp \ + ../src/qcoreapplication_3_1.cpp + +TARGET.UID3=0x2001E620 diff --git a/src/plugins/s60/3_2/3_2.pro b/src/plugins/s60/3_2/3_2.pro new file mode 100644 index 0000000..4b28eb9 --- /dev/null +++ b/src/plugins/s60/3_2/3_2.pro @@ -0,0 +1,17 @@ +include(../s60pluginbase.pri) + +TARGET = qts60plugin_3_2 + +contains(S60_VERSION, 3.1) { + SOURCES += ../src/qlocale_3_1.cpp \ + ../src/qdesktopservices_3_1.cpp \ + ../src/qcoreapplication_3_1.cpp +} else { + SOURCES += ../src/qlocale_3_2.cpp \ + ../src/qdesktopservices_3_2.cpp \ + ../src/qcoreapplication_3_2.cpp + LIBS += -ldirectorylocalizer -lefsrv + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE +} + +TARGET.UID3=0x2001E621 diff --git a/src/plugins/s60/5_0/5_0.pro b/src/plugins/s60/5_0/5_0.pro new file mode 100644 index 0000000..4cdce12 --- /dev/null +++ b/src/plugins/s60/5_0/5_0.pro @@ -0,0 +1,17 @@ +include(../s60pluginbase.pri) + +TARGET = qts60plugin_5_0 + +contains(S60_VERSION, 3.1) { + SOURCES += ../src/qlocale_3_1.cpp \ + ../src/qdesktopservices_3_1.cpp \ + ../src/qcoreapplication_3_1.cpp +} else { + SOURCES += ../src/qlocale_3_2.cpp \ + ../src/qdesktopservices_3_2.cpp \ + ../src/qcoreapplication_3_2.cpp + LIBS += -ldirectorylocalizer -lefsrv + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE +} + +TARGET.UID3=0x2001E622 diff --git a/src/plugins/s60/bwins/qts60pluginu.def b/src/plugins/s60/bwins/qts60pluginu.def new file mode 100644 index 0000000..b4110a9 --- /dev/null +++ b/src/plugins/s60/bwins/qts60pluginu.def @@ -0,0 +1,8 @@ +EXPORTS + ?defaultFormatL@@YAXAAVTTime@@AAVTDes16@@ABVTDesC16@@ABVTLocale@@@Z @ 1 NONAME ; void defaultFormatL(class TTime &, class TDes16 &, class TDesC16 const &, class TLocale const &) + ?defaultGetTimeFormatSpec@@YA?AVTPtrC16@@AAVTExtendedLocale@@@Z @ 2 NONAME ; class TPtrC16 defaultGetTimeFormatSpec(class TExtendedLocale &) + ?defaultGetLongDateFormatSpec@@YA?AVTPtrC16@@AAVTExtendedLocale@@@Z @ 3 NONAME ; class TPtrC16 defaultGetLongDateFormatSpec(class TExtendedLocale &) + ?defaultGetShortDateFormatSpec@@YA?AVTPtrC16@@AAVTExtendedLocale@@@Z @ 4 NONAME ; class TPtrC16 defaultGetShortDateFormatSpec(class TExtendedLocale &) + ?localizedDirectoryName@@YA?AVQString@@AAV1@@Z @ 5 NONAME ; class QString localizedDirectoryName(class QString &) + ?systemDrive@@YA?AW4TDriveNumber@@AAVRFs@@@Z @ 6 NONAME ; enum TDriveNumber systemDrive(class RFs &) + diff --git a/src/plugins/s60/eabi/qts60pluginu.def b/src/plugins/s60/eabi/qts60pluginu.def new file mode 100644 index 0000000..df7895c --- /dev/null +++ b/src/plugins/s60/eabi/qts60pluginu.def @@ -0,0 +1,8 @@ +EXPORTS + _Z14defaultFormatLR5TTimeR6TDes16RK7TDesC16RK7TLocale @ 1 NONAME + _Z24defaultGetTimeFormatSpecR15TExtendedLocale @ 2 NONAME + _Z28defaultGetLongDateFormatSpecR15TExtendedLocale @ 3 NONAME + _Z29defaultGetShortDateFormatSpecR15TExtendedLocale @ 4 NONAME + _Z22localizedDirectoryNameR7QString @ 5 NONAME + _Z11systemDriveR3RFs @ 6 NONAME + diff --git a/src/plugins/s60/s60.pro b/src/plugins/s60/s60.pro new file mode 100644 index 0000000..8ae639c --- /dev/null +++ b/src/plugins/s60/s60.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +symbian:SUBDIRS = 3_1 3_2 5_0 diff --git a/src/plugins/s60/s60pluginbase.pri b/src/plugins/s60/s60pluginbase.pri new file mode 100644 index 0000000..c1aa4ef --- /dev/null +++ b/src/plugins/s60/s60pluginbase.pri @@ -0,0 +1,16 @@ +# Note: These version based 'plugins' are not an actual Qt plugins, +# they are just regular runtime loaded libraries +include(../qpluginbase.pri) + +CONFIG -= plugin + +MMP_RULES += NOEXPORTLIBRARY + +defBlock = \ + "$${LITERAL_HASH}ifdef WINSCW" \ + "DEFFILE ../bwins/qts60plugin.def" \ + "$${LITERAL_HASH}else" \ + "DEFFILE ../eabi/qts60plugin.def" \ + "$${LITERAL_HASH}endif" + +MMP_RULES += defBlock
\ No newline at end of file diff --git a/src/plugins/s60/src/qcoreapplication_3_1.cpp b/src/plugins/s60/src/qcoreapplication_3_1.cpp new file mode 100644 index 0000000..c7627ce --- /dev/null +++ b/src/plugins/s60/src/qcoreapplication_3_1.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 <qglobal.h> +#include <f32file.h> + +EXPORT_C TDriveNumber systemDrive(RFs&) +{ + return EDriveC; +} diff --git a/src/plugins/s60/src/qcoreapplication_3_2.cpp b/src/plugins/s60/src/qcoreapplication_3_2.cpp new file mode 100644 index 0000000..8d2794e --- /dev/null +++ b/src/plugins/s60/src/qcoreapplication_3_2.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 <qglobal.h> +#include <f32file.h> + +EXPORT_C TDriveNumber systemDrive(RFs& fs) +{ + return fs.GetSystemDrive(); +} diff --git a/src/plugins/s60/src/qdesktopservices_3_1.cpp b/src/plugins/s60/src/qdesktopservices_3_1.cpp new file mode 100644 index 0000000..a7ab2a0 --- /dev/null +++ b/src/plugins/s60/src/qdesktopservices_3_1.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 <qglobal.h> +#include <qstring.h> + +EXPORT_C QString localizedDirectoryName(QString&) +{ + qWarning("QDesktopServices::displayName() not implemented for this platform version"); + return QString(); +} diff --git a/src/plugins/mousedrivers/linuxis/linuxismousedriverplugin.cpp b/src/plugins/s60/src/qdesktopservices_3_2.cpp index 2dca243..aec9170 100644 --- a/src/plugins/mousedrivers/linuxis/linuxismousedriverplugin.cpp +++ b/src/plugins/s60/src/qdesktopservices_3_2.cpp @@ -39,45 +39,42 @@ ** ****************************************************************************/ -#include "linuxismousedriverplugin.h" -#include "linuxismousehandler.h" +#include <private/qcore_symbian_p.h> +#include <qstring.h> +#include <qdir.h> -#include <qdebug.h> -#if 1 -#define qLog(x) qDebug() -#else -#define qLog(x) while (0) qDebug() -#endif -LinuxInputSubsystemMouseDriverPlugin::LinuxInputSubsystemMouseDriverPlugin( QObject *parent ) - : QMouseDriverPlugin( parent ) -{ -} +#ifdef Q_WS_S60 +#include <e32base.h> // CBase -> Required by cdirectorylocalizer.h +#include <cdirectorylocalizer.h> // CDirectoryLocalizer -LinuxInputSubsystemMouseDriverPlugin::~LinuxInputSubsystemMouseDriverPlugin() +EXPORT_C QString localizedDirectoryName(QString& rawPath) { -} + QString ret; + std::exception dummy; // voodoo fix for "Undefined symbol typeinfo for std::exception" in armv5 build -QWSMouseHandler* LinuxInputSubsystemMouseDriverPlugin::create(const QString& driver, const QString& device) -{ - if ( driver.toLower() == "linuxis" ) { - qLog(Input) << "Before call LinuxInputSubsystemMouseHandler()"; - return new LinuxInputSubsystemMouseHandler(device); - } - return 0; -} + TRAPD(err, + QT_TRYCATCH_LEAVING( + CDirectoryLocalizer* localizer = CDirectoryLocalizer::NewL(); + CleanupStack::PushL(localizer); + localizer->SetFullPath(qt_QString2TPtrC(QDir::toNativeSeparators(rawPath))); + if(localizer->IsLocalized()){ + TPtrC locName(localizer->LocalizedName()); + ret = qt_TDesC2QString(locName); + } + CleanupStack::PopAndDestroy(localizer); + ) + ) -QWSMouseHandler* LinuxInputSubsystemMouseDriverPlugin::create(const QString& driver) -{ - if( driver.toLower() == "linuxis" ) { - qLog(Input) << "Before call LinuxInputSubsystemMouseHandler()"; - return new LinuxInputSubsystemMouseHandler(); - } - return 0; + if (err != KErrNone) + ret = QString(); + + return ret; } +#else -QStringList LinuxInputSubsystemMouseDriverPlugin::keys() const +EXPORT_C QString localizedDirectoryName(QString& /* rawPath */) { - return QStringList() << "linuxis"; + qWarning("QDesktopServices::displayName() not implemented for this platform version"); + return QString(); } - -Q_EXPORT_PLUGIN2(qwslinuxismousehandler, LinuxInputSubsystemMouseDriverPlugin) +#endif diff --git a/src/plugins/s60/src/qlocale_3_1.cpp b/src/plugins/s60/src/qlocale_3_1.cpp new file mode 100644 index 0000000..beeee7f --- /dev/null +++ b/src/plugins/s60/src/qlocale_3_1.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $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 <e32std.h> +#include <e32const.h> +#include <e32debug.h> + +_LIT(KYear, "%Y"); +_LIT(KMonth, "%M"); +_LIT(KDay, "%D"); +_LIT(KLocaleIndependent, "%F"); +static TBuf<10> dateFormat; +static TBuf<10> timeFormat; + +static void initialiseDateFormat() +{ + if(dateFormat.Length()) + return; + + TLocale locale; + + //Separator 1 is used between 1st and 2nd components of the date + //Separator 2 is used between 2nd and 3rd components of the date + //Usually they are the same, but they are allowed to be different + TChar s1 = locale.DateSeparator(1); + TChar s2 = locale.DateSeparator(2); + dateFormat=KLocaleIndependent; + switch(locale.DateFormat()) { + case EDateAmerican: + dateFormat.Append(KMonth); + dateFormat.Append(s1); + dateFormat.Append(KDay); + dateFormat.Append(s2); + dateFormat.Append(KYear); + break; + case EDateEuropean: + dateFormat.Append(KDay); + dateFormat.Append(s1); + dateFormat.Append(KMonth); + dateFormat.Append(s2); + dateFormat.Append(KYear); + break; + case EDateJapanese: + default: //it's closest to ISO format + dateFormat.Append(KYear); + dateFormat.Append(s1); + dateFormat.Append(KMonth); + dateFormat.Append(s2); + dateFormat.Append(KDay); + break; + } +#ifdef _DEBUG + RDebug::Print(_L("Date Format \"%S\""), &dateFormat); +#endif +} + +static void initialiseTimeFormat() +{ + if(timeFormat.Length()) + return; + + TLocale locale; + //Separator 1 is used between 1st and 2nd components of the time + //Separator 2 is used between 2nd and 3rd components of the time + //Usually they are the same, but they are allowed to be different + TChar s1 = locale.TimeSeparator(1); + TChar s2 = locale.TimeSeparator(2); + switch(locale.TimeFormat()) { + case ETime12: + timeFormat.Append(_L("%I")); + break; + case ETime24: + default: + timeFormat.Append(_L("%H")); + break; + } + timeFormat.Append(s1); + timeFormat.Append(_L("%T")); + timeFormat.Append(s2); + timeFormat.Append(_L("%S")); + +#ifdef _DEBUG + RDebug::Print(_L("Time Format \"%S\""), &timeFormat); +#endif +} + +EXPORT_C void defaultFormatL(TTime& time, TDes& des, const TDesC& fmt, const TLocale&) +{ + //S60 3.1 does not support format for a specific locale, so use default locale + time.FormatL(des, fmt); +} + +//S60 3.1 doesn't support extended locale date&time formats, so use default locale +EXPORT_C TPtrC defaultGetTimeFormatSpec(TExtendedLocale&) +{ + initialiseTimeFormat(); + return TPtrC(timeFormat); +} + +EXPORT_C TPtrC defaultGetLongDateFormatSpec(TExtendedLocale&) +{ + initialiseDateFormat(); + return TPtrC(dateFormat); +} + +EXPORT_C TPtrC defaultGetShortDateFormatSpec(TExtendedLocale&) +{ + initialiseDateFormat(); + return TPtrC(dateFormat); +} diff --git a/src/plugins/mousedrivers/linuxis/linuxismousehandler.h b/src/plugins/s60/src/qlocale_3_2.cpp index b5878aa..1ff25de 100644 --- a/src/plugins/mousedrivers/linuxis/linuxismousehandler.h +++ b/src/plugins/s60/src/qlocale_3_2.cpp @@ -39,34 +39,26 @@ ** ****************************************************************************/ -#ifndef LINUXISMOUSEHANDLER_H -#define LINUXISMOUSEHANDLER_H +#include <exception> +#include <e32std.h> +#include <e32base.h> -#include <QtGui/QWSCalibratedMouseHandler> +EXPORT_C TPtrC defaultGetLongDateFormatSpec(TExtendedLocale& locale) +{ + return locale.GetLongDateFormatSpec(); +} -class QSocketNotifier; -class LinuxInputSubsystemMouseHandler : public QObject, public QWSCalibratedMouseHandler { - Q_OBJECT -public: - LinuxInputSubsystemMouseHandler(const QString &device = QString("/dev/input/event0")); - ~LinuxInputSubsystemMouseHandler(); +EXPORT_C TPtrC defaultGetShortDateFormatSpec(TExtendedLocale& locale) +{ + return locale.GetShortDateFormatSpec(); +} - void suspend(); - void resume(); +EXPORT_C TPtrC defaultGetTimeFormatSpec(TExtendedLocale& locale) +{ + return locale.GetTimeFormatSpec(); +} -private: - int mouseX, mouseY; - int mouseBtn; - static const int mouseBufSize = 2048; - uchar mouseBuf[mouseBufSize]; - int mouseIdx; - QPoint oldmouse; - - QSocketNotifier *m_notify; - int mouseFd; - -private Q_SLOTS: - void readMouseData(); -}; - -#endif // LINUXISMOUSEHANDLER_H +EXPORT_C void defaultFormatL(TTime& time, TDes& des, const TDesC& format, const TLocale& locale) +{ + time.FormatL(des, format, locale); +} diff --git a/src/plugins/script/script.pro b/src/plugins/script/script.pro index dbcecea..eaae56b 100644 --- a/src/plugins/script/script.pro +++ b/src/plugins/script/script.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -contains(QT_CONFIG, dbus):SUBDIRS += qtdbus +contains(QT_CONFIG, script):contains(QT_CONFIG, dbus):SUBDIRS += qtdbus diff --git a/src/plugins/sqldrivers/odbc/odbc.pro b/src/plugins/sqldrivers/odbc/odbc.pro index 0835ce1..3de8ab2 100644 --- a/src/plugins/sqldrivers/odbc/odbc.pro +++ b/src/plugins/sqldrivers/odbc/odbc.pro @@ -4,15 +4,9 @@ HEADERS = ../../../sql/drivers/odbc/qsql_odbc.h SOURCES = main.cpp \ ../../../sql/drivers/odbc/qsql_odbc.cpp -mac { - !contains( LIBS, .*odbc.* ) { - LIBS *= -liodbc - } -} - unix { !contains( LIBS, .*odbc.* ) { - LIBS *= -lodbc + LIBS *= $$QT_LFLAGS_ODBC } } diff --git a/src/plugins/sqldrivers/sqldrivers.pro b/src/plugins/sqldrivers/sqldrivers.pro index 39c58d4..2bd5f2c 100644 --- a/src/plugins/sqldrivers/sqldrivers.pro +++ b/src/plugins/sqldrivers/sqldrivers.pro @@ -9,3 +9,7 @@ contains(sql-plugins, db2) : SUBDIRS += db2 contains(sql-plugins, sqlite) : SUBDIRS += sqlite contains(sql-plugins, sqlite2) : SUBDIRS += sqlite2 contains(sql-plugins, ibase) : SUBDIRS += ibase + +contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + symbian:contains(CONFIG, system-sqlite): SUBDIRS += sqlite_symbian + } diff --git a/src/plugins/sqldrivers/sqlite_symbian/SQLite3_v9.2.zip b/src/plugins/sqldrivers/sqlite_symbian/SQLite3_v9.2.zip Binary files differnew file mode 100644 index 0000000..923cca4 --- /dev/null +++ b/src/plugins/sqldrivers/sqlite_symbian/SQLite3_v9.2.zip diff --git a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro new file mode 100644 index 0000000..158633d --- /dev/null +++ b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro @@ -0,0 +1,7 @@ +# Use subdirs template to suppress generation of unnecessary files +TEMPLATE = subdirs + +# We just want to export the sqlite3 binaries for Symbian for platforms that do not have them. +!exists($${EPOCROOT}epoc32/release/armv5/lib/sqlite3.dso) { + BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip" +} |