From 980bceb279e0948ad33ccecd6e1601e428d01866 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 16 Jun 2011 11:22:51 +0200 Subject: Proper naming for raster pixmap and paintengine on Symbian. As QTBUG-19880 highlighted, the old S60 naming is not suitable for these classes anymore. Task-number: QTBUG-19913 Reviewed-by: Jani Hautakangas --- src/gui/image/image.pri | 4 +- src/gui/image/qimage.cpp | 4 +- src/gui/image/qpixmap.h | 2 +- src/gui/image/qpixmap_raster_symbian.cpp | 1042 ++++++++++++++++++++++ src/gui/image/qpixmap_raster_symbian_p.h | 140 +++ src/gui/image/qpixmap_s60.cpp | 1042 ---------------------- src/gui/image/qpixmap_s60_p.h | 141 --- src/gui/image/qpixmapdata_p.h | 2 +- src/gui/image/qpixmapdatafactory.cpp | 4 +- src/gui/kernel/qapplication_s60.cpp | 2 +- src/gui/painting/painting.pri | 4 +- src/gui/painting/qgraphicssystem.cpp | 4 +- src/gui/painting/qgraphicssystem_raster.cpp | 4 +- src/gui/painting/qpaintengine_raster_symbian.cpp | 147 +++ src/gui/painting/qpaintengine_raster_symbian_p.h | 84 ++ src/gui/painting/qpaintengine_s60.cpp | 145 --- src/gui/painting/qpaintengine_s60_p.h | 84 -- src/gui/painting/qwindowsurface_s60.cpp | 14 +- src/gui/styles/qs60style_s60.cpp | 2 +- src/gui/text/qfont_s60.cpp | 2 +- src/gui/text/qfontdatabase_s60.cpp | 2 +- src/gui/text/qfontengine_s60.cpp | 2 +- src/opengl/qgl_symbian.cpp | 3 +- 23 files changed, 1440 insertions(+), 1440 deletions(-) create mode 100644 src/gui/image/qpixmap_raster_symbian.cpp create mode 100644 src/gui/image/qpixmap_raster_symbian_p.h delete mode 100644 src/gui/image/qpixmap_s60.cpp delete mode 100644 src/gui/image/qpixmap_s60_p.h create mode 100644 src/gui/painting/qpaintengine_raster_symbian.cpp create mode 100644 src/gui/painting/qpaintengine_raster_symbian_p.h delete mode 100644 src/gui/painting/qpaintengine_s60.cpp delete mode 100644 src/gui/painting/qpaintengine_s60_p.h (limited to 'src') diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 00dccbe299..d02d050bb0 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -72,8 +72,8 @@ else:mac { SOURCES += image/qpixmap_mac.cpp } else:symbian { - HEADERS += image/qpixmap_s60_p.h - SOURCES += image/qpixmap_s60.cpp + HEADERS += image/qpixmap_raster_symbian_p.h + SOURCES += image/qpixmap_raster_symbian.cpp } !symbian|contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2) { diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d7156a7970..5c83cf6acb 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -63,7 +63,7 @@ #include #if defined(Q_OS_SYMBIAN) -#include +#include #else #include #endif @@ -5711,7 +5711,7 @@ QPaintEngine *QImage::paintEngine() const if (!d->paintEngine) { #ifdef Q_OS_SYMBIAN - d->paintEngine = new QS60PaintEngine(const_cast(this)); + d->paintEngine = new QSymbianRasterPaintEngine(const_cast(this)); #else d->paintEngine = new QRasterPaintEngine(const_cast(this)); #endif diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 23b37f460d..c25f3c1c10 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -265,7 +265,7 @@ private: friend class QPixmapData; friend class QX11PixmapData; friend class QMacPixmapData; - friend class QS60PixmapData; + friend class QSymbianRasterPixmapData; friend class QBitmap; friend class QPaintDevice; friend class QPainter; diff --git a/src/gui/image/qpixmap_raster_symbian.cpp b/src/gui/image/qpixmap_raster_symbian.cpp new file mode 100644 index 0000000000..7eb6ecabaa --- /dev/null +++ b/src/gui/image/qpixmap_raster_symbian.cpp @@ -0,0 +1,1042 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include + +#include "qpixmap.h" +#include "qpixmap_raster_p.h" +#include +#include "qpixmap_raster_symbian_p.h" +#include "qnativeimage_p.h" +#include "qbitmap.h" +#include "qimage.h" +#include "qimage_p.h" + +#include + +QT_BEGIN_NAMESPACE + +const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, + 0x10, 0x20, 0x40, 0x80 }; + +static bool cleanup_function_registered = false; +static QSymbianRasterPixmapData *firstPixmap = 0; + +// static +void QSymbianRasterPixmapData::qt_symbian_register_pixmap(QSymbianRasterPixmapData *pd) +{ + if (!cleanup_function_registered) { + qAddPostRoutine(qt_symbian_release_pixmaps); + cleanup_function_registered = true; + } + + pd->next = firstPixmap; + pd->prev = 0; + if (firstPixmap) + firstPixmap->prev = pd; + firstPixmap = pd; +} + +// static +void QSymbianRasterPixmapData::qt_symbian_unregister_pixmap(QSymbianRasterPixmapData *pd) +{ + if (pd->next) + pd->next->prev = pd->prev; + if (pd->prev) + pd->prev->next = pd->next; + else + firstPixmap = pd->next; +} + +// static +void QSymbianRasterPixmapData::qt_symbian_release_pixmaps() +{ + // Scan all QSymbianRasterPixmapData objects in the system and destroy them. + QSymbianRasterPixmapData *pd = firstPixmap; + while (pd != 0) { + pd->release(); + pd = pd->next; + } +} + +/* + \class QSymbianFbsClient + \since 4.6 + \internal + + Symbian Font And Bitmap server client that is + used to lock the global bitmap heap. Only used in + S60 v3.1 and S60 v3.2. +*/ +_LIT(KFBSERVLargeBitmapAccessName,"FbsLargeBitmapAccess"); +class QSymbianFbsClient +{ +public: + + QSymbianFbsClient() : heapLocked(false) + { + heapLock.OpenGlobal(KFBSERVLargeBitmapAccessName); + } + + ~QSymbianFbsClient() + { + heapLock.Close(); + } + + bool lockHeap() + { + bool wasLocked = heapLocked; + + if (heapLock.Handle() && !heapLocked) { + heapLock.Wait(); + heapLocked = true; + } + + return wasLocked; + } + + bool unlockHeap() + { + bool wasLocked = heapLocked; + + if (heapLock.Handle() && heapLocked) { + heapLock.Signal(); + heapLocked = false; + } + + return wasLocked; + } + + +private: + + RMutex heapLock; + bool heapLocked; +}; + +Q_GLOBAL_STATIC(QSymbianFbsClient, qt_symbianFbsClient); + + + +// QSymbianFbsHeapLock + +QSymbianFbsHeapLock::QSymbianFbsHeapLock(LockAction a) +: action(a), wasLocked(false) +{ + QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); + if (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3) + wasLocked = qt_symbianFbsClient()->unlockHeap(); +} + +QSymbianFbsHeapLock::~QSymbianFbsHeapLock() +{ + // Do nothing +} + +void QSymbianFbsHeapLock::relock() +{ + QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); + if (wasLocked && (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3)) + qt_symbianFbsClient()->lockHeap(); +} + +/* + \class QSymbianBitmapDataAccess + \since 4.6 + \internal + + Data access class that is used to locks/unlocks pixel data + when drawing or modifying CFbsBitmap pixel data. +*/ +class QSymbianBitmapDataAccess +{ +public: + + static int heapRefCount; + QSysInfo::SymbianVersion symbianVersion; + + explicit QSymbianBitmapDataAccess() + { + symbianVersion = QSysInfo::symbianVersion(); + }; + + ~QSymbianBitmapDataAccess() {}; + + inline void beginDataAccess(CFbsBitmap *bitmap) + { + if (symbianVersion == QSysInfo::SV_9_2) { + if (heapRefCount == 0) + qt_symbianFbsClient()->lockHeap(); + } else { + bitmap->LockHeap(ETrue); + } + + heapRefCount++; + } + + inline void endDataAccess(CFbsBitmap *bitmap) + { + heapRefCount--; + + if (symbianVersion == QSysInfo::SV_9_2) { + if (heapRefCount == 0) + qt_symbianFbsClient()->unlockHeap(); + } else { + bitmap->UnlockHeap(ETrue); + } + } +}; + +int QSymbianBitmapDataAccess::heapRefCount = 0; + + +#define UPDATE_BUFFER() \ + { \ + beginDataAccess(); \ + endDataAccess(); \ +} + + +static CFbsBitmap* createSymbianCFbsBitmap(const TSize& size, TDisplayMode mode) +{ + QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); + + CFbsBitmap* bitmap = 0; + QT_TRAP_THROWING(bitmap = new (ELeave) CFbsBitmap); + + if (bitmap->Create(size, mode) != KErrNone) { + delete bitmap; + bitmap = 0; + } + + lock.relock(); + + return bitmap; +} + +static CFbsBitmap* uncompress(CFbsBitmap* bitmap) +{ + if(bitmap->IsCompressedInRAM()) { + QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); + + CFbsBitmap *uncompressed = 0; + QT_TRAP_THROWING(uncompressed = new (ELeave) CFbsBitmap); + + if (uncompressed->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) { + delete bitmap; + bitmap = 0; + lock.relock(); + + return bitmap; + } + + lock.relock(); + + CFbsBitmapDevice* bitmapDevice = 0; + CFbsBitGc *bitmapGc = 0; + QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(uncompressed)); + QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL()); + bitmapGc->Activate(bitmapDevice); + + bitmapGc->BitBlt(TPoint(), bitmap); + + delete bitmapGc; + delete bitmapDevice; + + return uncompressed; + } else { + return bitmap; + } +} + +QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h) +{ + CWsScreenDevice* screenDevice = S60->screenDevice(); + TSize screenSize = screenDevice->SizeInPixels(); + + TSize srcSize; + // Find out if this is one of our windows. + QSymbianControl *sControl; + sControl = winId->MopGetObject(sControl); + if (sControl && sControl->widget()->windowType() == Qt::Desktop) { + // Grabbing desktop widget + srcSize = screenSize; + } else { + TPoint relativePos = winId->PositionRelativeToScreen(); + x += relativePos.iX; + y += relativePos.iY; + srcSize = winId->Size(); + } + + TRect srcRect(TPoint(x, y), srcSize); + // Clip to the screen + srcRect.Intersection(TRect(screenSize)); + + if (w > 0 && h > 0) { + TRect subRect(TPoint(x, y), TSize(w, h)); + // Clip to the subRect + srcRect.Intersection(subRect); + } + + if (srcRect.IsEmpty()) + return QPixmap(); + + CFbsBitmap* temporary = createSymbianCFbsBitmap(srcRect.Size(), screenDevice->DisplayMode()); + + QPixmap pix; + + if (temporary && screenDevice->CopyScreenToBitmap(temporary, srcRect) == KErrNone) { + pix = QPixmap::fromSymbianCFbsBitmap(temporary); + } + + delete temporary; + return pix; +} + +/*! + \fn CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const + \since 4.6 + + Creates a \c CFbsBitmap that is equivalent to the QPixmap. Internally this + function will try to duplicate the handle instead of copying the data, + however in scenarios where this is not possible the data will be copied. + If the creation fails or the pixmap is null, then this function returns 0. + + It is the caller's responsibility to release the \c CFbsBitmap data + after use either by deleting the bitmap or calling \c Reset(). + + \warning On S60 3.1 and S60 3.2, semi-transparent pixmaps are always copied + and not duplicated. + \warning This function is only available on Symbian OS. + + \sa fromSymbianCFbsBitmap() +*/ +CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const +{ + QPixmapData *data = pixmapData(); + if (!data || data->isNull()) + return 0; + + return reinterpret_cast(data->toNativeType(QPixmapData::FbsBitmap)); +} + +/*! + \fn QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) + \since 4.6 + + Creates a QPixmap from a \c CFbsBitmap \a bitmap. Internally this function + will try to duplicate the bitmap handle instead of copying the data, however + in scenarios where this is not possible the data will be copied. + To be sure that QPixmap does not modify your original instance, you should + make a copy of your \c CFbsBitmap before calling this function. + If the CFbsBitmap is not valid this function will return a null QPixmap. + For performance reasons it is recommended to use a \a bitmap with a display + mode of EColor16MAP or EColor16MU whenever possible. + + \warning This function is only available on Symbian OS. + + \sa toSymbianCFbsBitmap(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} +*/ +QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) +{ + if (!bitmap) + return QPixmap(); + + QScopedPointer data(QPixmapData::create(0,0, QPixmapData::PixmapType)); + data->fromNativeType(reinterpret_cast(bitmap), QPixmapData::FbsBitmap); + QPixmap pixmap(data.take()); + return pixmap; +} + +QSymbianRasterPixmapData::QSymbianRasterPixmapData(PixelType type) : QRasterPixmapData(type), + symbianBitmapDataAccess(new QSymbianBitmapDataAccess), + cfbsBitmap(0), + pengine(0), + bytes(0), + formatLocked(false), + next(0), + prev(0) +{ + qt_symbian_register_pixmap(this); +} + +QSymbianRasterPixmapData::~QSymbianRasterPixmapData() +{ + release(); + delete symbianBitmapDataAccess; + qt_symbian_unregister_pixmap(this); +} + +void QSymbianRasterPixmapData::resize(int width, int height) +{ + if (width <= 0 || height <= 0) { + w = width; + h = height; + is_null = true; + + release(); + return; + } else if (!cfbsBitmap) { + TDisplayMode mode; + if (pixelType() == BitmapType) + mode = EGray2; + else + mode = EColor16MU; + + CFbsBitmap* bitmap = createSymbianCFbsBitmap(TSize(width, height), mode); + fromSymbianBitmap(bitmap); + } else { + + TSize newSize(width, height); + + if(cfbsBitmap->SizeInPixels() != newSize) { + cfbsBitmap->Resize(TSize(width, height)); + if(pengine) { + delete pengine; + pengine = 0; + } + } + + UPDATE_BUFFER(); + } +} + +void QSymbianRasterPixmapData::release() +{ + if (cfbsBitmap) { + QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); + delete cfbsBitmap; + lock.relock(); + } + + delete pengine; + image = QImage(); + cfbsBitmap = 0; + pengine = 0; + bytes = 0; +} + +/*! + * Takes ownership of bitmap. Used by window surface + */ +void QSymbianRasterPixmapData::fromSymbianBitmap(CFbsBitmap* bitmap, bool lockFormat) +{ + Q_ASSERT(bitmap); + + release(); + + cfbsBitmap = bitmap; + formatLocked = lockFormat; + + setSerialNumber(cfbsBitmap->Handle()); + + UPDATE_BUFFER(); + + // Create default palette if needed + if (cfbsBitmap->DisplayMode() == EGray2) { + image.setColorCount(2); + image.setColor(0, QColor(Qt::color0).rgba()); + image.setColor(1, QColor(Qt::color1).rgba()); + + //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid + //So invert mono bitmaps so that masks work correctly. + image.invertPixels(); + } else if (cfbsBitmap->DisplayMode() == EGray256) { + for (int i=0; i < 256; ++i) + image.setColor(i, qRgb(i, i, i)); + } else if (cfbsBitmap->DisplayMode() == EColor256) { + const TColor256Util *palette = TColor256Util::Default(); + for (int i=0; i < 256; ++i) + image.setColor(i, (QRgb)(palette->Color256(i).Value())); + } +} + +QImage QSymbianRasterPixmapData::toImage(const QRect &r) const +{ + QSymbianRasterPixmapData *that = const_cast(this); + that->beginDataAccess(); + QImage copy = that->image.copy(r); + that->endDataAccess(); + + return copy; +} + +void QSymbianRasterPixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags) +{ + release(); + + QImage sourceImage; + + if (pixelType() == BitmapType) { + sourceImage = img.convertToFormat(QImage::Format_MonoLSB); + } else { + if (img.depth() == 1) { + sourceImage = img.hasAlphaChannel() + ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied) + : img.convertToFormat(QImage::Format_RGB32); + } else { + + QImage::Format opaqueFormat = QNativeImage::systemFormat(); + QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied; + + if (!img.hasAlphaChannel() + || ((flags & Qt::NoOpaqueDetection) == 0 + && !const_cast(img).data_ptr()->checkForAlphaPixels())) { + sourceImage = img.convertToFormat(opaqueFormat); + } else { + sourceImage = img.convertToFormat(alphaFormat); + } + } + } + + + QImage::Format destFormat = sourceImage.format(); + TDisplayMode mode; + switch (destFormat) { + case QImage::Format_MonoLSB: + mode = EGray2; + break; + case QImage::Format_RGB32: + mode = EColor16MU; + break; + case QImage::Format_ARGB32_Premultiplied: + if (S60->supportsPremultipliedAlpha) { + mode = Q_SYMBIAN_ECOLOR16MAP; + break; + } else { + destFormat = QImage::Format_ARGB32; + } + // Fall through intended + case QImage::Format_ARGB32: + mode = EColor16MA; + break; + case QImage::Format_Invalid: + return; + default: + qWarning("Image format not supported: %d", image.format()); + return; + } + + cfbsBitmap = createSymbianCFbsBitmap(TSize(sourceImage.width(), sourceImage.height()), mode); + if (!cfbsBitmap) { + qWarning("Could not create CFbsBitmap"); + release(); + return; + } + + setSerialNumber(cfbsBitmap->Handle()); + + const uchar *sptr = const_cast(sourceImage).bits(); + symbianBitmapDataAccess->beginDataAccess(cfbsBitmap); + uchar *dptr = (uchar*)cfbsBitmap->DataAddress(); + Mem::Copy(dptr, sptr, sourceImage.byteCount()); + symbianBitmapDataAccess->endDataAccess(cfbsBitmap); + + UPDATE_BUFFER(); + + if (destFormat == QImage::Format_MonoLSB) { + image.setColorCount(2); + image.setColor(0, QColor(Qt::color0).rgba()); + image.setColor(1, QColor(Qt::color1).rgba()); + } else { + image.setColorTable(sourceImage.colorTable()); + } +} + +void QSymbianRasterPixmapData::copy(const QPixmapData *data, const QRect &rect) +{ + const QSymbianRasterPixmapData *s60Data = static_cast(data); + fromImage(s60Data->toImage(rect), Qt::AutoColor | Qt::OrderedAlphaDither); +} + +bool QSymbianRasterPixmapData::scroll(int dx, int dy, const QRect &rect) +{ + beginDataAccess(); + bool res = QRasterPixmapData::scroll(dx, dy, rect); + endDataAccess(); + return res; +} + +Q_GUI_EXPORT int qt_defaultDpiX(); +Q_GUI_EXPORT int qt_defaultDpiY(); + +int QSymbianRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const +{ + if (!cfbsBitmap) + return 0; + + switch (metric) { + case QPaintDevice::PdmWidth: + return cfbsBitmap->SizeInPixels().iWidth; + case QPaintDevice::PdmHeight: + return cfbsBitmap->SizeInPixels().iHeight; + case QPaintDevice::PdmWidthMM: + return qRound(cfbsBitmap->SizeInPixels().iWidth * 25.4 / qt_defaultDpiX()); + case QPaintDevice::PdmHeightMM: + return qRound(cfbsBitmap->SizeInPixels().iHeight * 25.4 / qt_defaultDpiY()); + case QPaintDevice::PdmNumColors: + return TDisplayModeUtils::NumDisplayModeColors(cfbsBitmap->DisplayMode()); + case QPaintDevice::PdmDpiX: + case QPaintDevice::PdmPhysicalDpiX: + return qt_defaultDpiX(); + case QPaintDevice::PdmDpiY: + case QPaintDevice::PdmPhysicalDpiY: + return qt_defaultDpiY(); + case QPaintDevice::PdmDepth: + return TDisplayModeUtils::NumDisplayModeBitsPerPixel(cfbsBitmap->DisplayMode()); + default: + qWarning("QPixmap::metric: Invalid metric command"); + } + return 0; + +} + +void QSymbianRasterPixmapData::fill(const QColor &color) +{ + if (color.alpha() != 255) { + QImage im(width(), height(), QImage::Format_ARGB32_Premultiplied); + im.fill(PREMUL(color.rgba())); + release(); + fromImage(im, Qt::AutoColor | Qt::OrderedAlphaDither); + } else { + beginDataAccess(); + QRasterPixmapData::fill(color); + endDataAccess(); + } +} + +void QSymbianRasterPixmapData::setMask(const QBitmap &mask) +{ + if (mask.size().isEmpty()) { + if (image.depth() != 1) { + QImage newImage = image.convertToFormat(QImage::Format_RGB32); + release(); + fromImage(newImage, Qt::AutoColor | Qt::OrderedAlphaDither); + } + } else if (image.depth() == 1) { + beginDataAccess(); + QRasterPixmapData::setMask(mask); + endDataAccess(); + } else { + const int w = image.width(); + const int h = image.height(); + + const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB); + QImage newImage = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); + for (int y = 0; y < h; ++y) { + const uchar *mscan = imageMask.scanLine(y); + QRgb *tscan = (QRgb *)newImage.scanLine(y); + for (int x = 0; x < w; ++x) { + if (!(mscan[x>>3] & qt_pixmap_bit_mask[x&7])) + tscan[x] = 0; + } + } + release(); + fromImage(newImage, Qt::AutoColor | Qt::OrderedAlphaDither); + } +} + +void QSymbianRasterPixmapData::setAlphaChannel(const QPixmap &alphaChannel) +{ + QImage img(toImage()); + img.setAlphaChannel(alphaChannel.toImage()); + release(); + fromImage(img, Qt::OrderedDither | Qt::OrderedAlphaDither); +} + +QImage QSymbianRasterPixmapData::toImage() const +{ + return toImage(QRect()); +} + +QPaintEngine* QSymbianRasterPixmapData::paintEngine() const +{ + if (!pengine) { + QSymbianRasterPixmapData *that = const_cast(this); + that->pengine = new QSymbianRasterPaintEngine(&that->image, that); + } + return pengine; +} + +void QSymbianRasterPixmapData::beginDataAccess() +{ + if(!cfbsBitmap) + return; + + symbianBitmapDataAccess->beginDataAccess(cfbsBitmap); + + uchar* newBytes = (uchar*)cfbsBitmap->DataAddress(); + + TSize size = cfbsBitmap->SizeInPixels(); + + if (newBytes == bytes && image.width() == size.iWidth && image.height() == size.iHeight) + return; + + bytes = newBytes; + TDisplayMode mode = cfbsBitmap->DisplayMode(); + QImage::Format format = qt_TDisplayMode2Format(mode); + // On S60 3.1, premultiplied alpha pixels are stored in a bitmap with 16MA type. + // S60 window surface needs backing store pixmap for transparent window in ARGB32 format. + // In that case formatLocked is true. + if (!formatLocked && format == QImage::Format_ARGB32) + format = QImage::Format_ARGB32_Premultiplied; // pixel data is actually in premultiplied format + + QVector savedColorTable; + if (!image.isNull()) + savedColorTable = image.colorTable(); + + image = QImage(bytes, size.iWidth, size.iHeight, format); + + // Restore the palette or create a default + if (!savedColorTable.isEmpty()) { + image.setColorTable(savedColorTable); + } + + w = size.iWidth; + h = size.iHeight; + d = image.depth(); + is_null = (w <= 0 || h <= 0); + + if (pengine) { + QSymbianRasterPaintEngine *engine = static_cast(pengine); + engine->prepare(&image); + } +} + +void QSymbianRasterPixmapData::endDataAccess(bool readOnly) const +{ + Q_UNUSED(readOnly); + + if(!cfbsBitmap) + return; + + symbianBitmapDataAccess->endDataAccess(cfbsBitmap); +} + +/*! + \since 4.6 + + Returns a QPixmap that wraps given \a sgImage graphics resource. + The data should be valid even when original RSgImage handle has been + closed. + + \warning This function is only available on Symbian OS. + + \sa toSymbianRSgImage(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} +*/ + +QPixmap QPixmap::fromSymbianRSgImage(RSgImage *sgImage) +{ + // It is expected that RSgImage will + // CURRENTLY be used in conjuction with + // OpenVG graphics system + // + // Surely things might change in future + + if (!sgImage) + return QPixmap(); + + QScopedPointer data(QPixmapData::create(0,0, QPixmapData::PixmapType)); + data->fromNativeType(reinterpret_cast(sgImage), QPixmapData::SgImage); + QPixmap pixmap(data.take()); + return pixmap; +} + +/*! +\since 4.6 + +Returns a \c RSgImage that is equivalent to the QPixmap by copying the data. + +It is the caller's responsibility to close/delete the \c RSgImage after use. + +\warning This function is only available on Symbian OS. + +\sa fromSymbianRSgImage() +*/ + +RSgImage *QPixmap::toSymbianRSgImage() const +{ + // It is expected that RSgImage will + // CURRENTLY be used in conjuction with + // OpenVG graphics system + // + // Surely things might change in future + + if (isNull()) + return 0; + + RSgImage *sgImage = reinterpret_cast(pixmapData()->toNativeType(QPixmapData::SgImage)); + + return sgImage; +} + +void* QSymbianRasterPixmapData::toNativeType(NativeType type) +{ + if (type == QPixmapData::SgImage) { + return 0; + } else if (type == QPixmapData::FbsBitmap) { + + if (isNull() || !cfbsBitmap) + return 0; + + bool convertToArgb32 = false; + bool needsCopy = false; + + if (!(S60->supportsPremultipliedAlpha)) { + // Convert argb32_premultiplied to argb32 since Symbian 9.2 does + // not support premultipied format. + + if (image.format() == QImage::Format_ARGB32_Premultiplied) { + needsCopy = true; + convertToArgb32 = true; + } + } + + CFbsBitmap *bitmap = 0; + + TDisplayMode displayMode = cfbsBitmap->DisplayMode(); + + if(displayMode == EGray2) { + //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid + //So invert mono bitmaps so that masks work correctly. + beginDataAccess(); + image.invertPixels(); + endDataAccess(); + needsCopy = true; + } + + if (needsCopy) { + QImage source; + + if (convertToArgb32) { + beginDataAccess(); + source = image.convertToFormat(QImage::Format_ARGB32); + endDataAccess(); + displayMode = EColor16MA; + } else { + source = image; + } + + CFbsBitmap *newBitmap = createSymbianCFbsBitmap(TSize(source.width(), source.height()), displayMode); + const uchar *sptr = source.bits(); + symbianBitmapDataAccess->beginDataAccess(newBitmap); + + uchar *dptr = (uchar*)newBitmap->DataAddress(); + Mem::Copy(dptr, sptr, source.byteCount()); + + symbianBitmapDataAccess->endDataAccess(newBitmap); + + bitmap = newBitmap; + } else { + + QT_TRAP_THROWING(bitmap = new (ELeave) CFbsBitmap); + + TInt err = bitmap->Duplicate(cfbsBitmap->Handle()); + if (err != KErrNone) { + qWarning("Could not duplicate CFbsBitmap"); + delete bitmap; + bitmap = 0; + } + } + + if(displayMode == EGray2) { + // restore pixels + beginDataAccess(); + image.invertPixels(); + endDataAccess(); + } + + return reinterpret_cast(bitmap); + + } + + return 0; +} + +void QSymbianRasterPixmapData::fromNativeType(void* pixmap, NativeType nativeType) +{ + if (nativeType == QPixmapData::SgImage) { + return; + } else if (nativeType == QPixmapData::FbsBitmap && pixmap) { + + CFbsBitmap *bitmap = reinterpret_cast(pixmap); + + bool deleteSourceBitmap = false; + bool needsCopy = false; + +#ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE + + // Rasterize extended bitmaps + + TUid extendedBitmapType = bitmap->ExtendedBitmapType(); + if (extendedBitmapType != KNullUid) { + CFbsBitmap *rasterBitmap = createSymbianCFbsBitmap(bitmap->SizeInPixels(), EColor16MA); + + CFbsBitmapDevice *rasterBitmapDev = 0; + QT_TRAP_THROWING(rasterBitmapDev = CFbsBitmapDevice::NewL(rasterBitmap)); + + CFbsBitGc *rasterBitmapGc = 0; + TInt err = rasterBitmapDev->CreateContext(rasterBitmapGc); + if (err != KErrNone) { + delete rasterBitmap; + delete rasterBitmapDev; + rasterBitmapDev = 0; + return; + } + + rasterBitmapGc->BitBlt(TPoint( 0, 0), bitmap); + + bitmap = rasterBitmap; + + delete rasterBitmapDev; + delete rasterBitmapGc; + + rasterBitmapDev = 0; + rasterBitmapGc = 0; + + deleteSourceBitmap = true; + } +#endif + + + deleteSourceBitmap = bitmap->IsCompressedInRAM(); + CFbsBitmap *sourceBitmap = uncompress(bitmap); + + TDisplayMode displayMode = sourceBitmap->DisplayMode(); + QImage::Format format = qt_TDisplayMode2Format(displayMode); + + QImage::Format opaqueFormat = QNativeImage::systemFormat(); + QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied; + + if (format != opaqueFormat && format != alphaFormat && format != QImage::Format_MonoLSB) + needsCopy = true; + + + type = (format != QImage::Format_MonoLSB) + ? QPixmapData::PixmapType + : QPixmapData::BitmapType; + + if (needsCopy) { + + TSize size = sourceBitmap->SizeInPixels(); + int bytesPerLine = sourceBitmap->ScanLineLength(size.iWidth, displayMode); + + QSymbianBitmapDataAccess da; + da.beginDataAccess(sourceBitmap); + uchar *bytes = (uchar*)sourceBitmap->DataAddress(); + QImage img = QImage(bytes, size.iWidth, size.iHeight, bytesPerLine, format); + img = img.copy(); + da.endDataAccess(sourceBitmap); + + if(displayMode == EGray2) { + //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid + //So invert mono bitmaps so that masks work correctly. + img.invertPixels(); + } else if(displayMode == EColor16M) { + img = img.rgbSwapped(); // EColor16M is BGR + } + + fromImage(img, Qt::AutoColor); + + if(deleteSourceBitmap) + delete sourceBitmap; + } else { + CFbsBitmap* duplicate = 0; + QT_TRAP_THROWING(duplicate = new (ELeave) CFbsBitmap); + + TInt err = duplicate->Duplicate(sourceBitmap->Handle()); + if (err != KErrNone) { + qWarning("Could not duplicate CFbsBitmap"); + + if(deleteSourceBitmap) + delete sourceBitmap; + + delete duplicate; + return; + } + + fromSymbianBitmap(duplicate); + + if(deleteSourceBitmap) + delete sourceBitmap; + } + } +} + +void QSymbianRasterPixmapData::convertToDisplayMode(int mode) +{ + const TDisplayMode displayMode = static_cast(mode); + if (!cfbsBitmap || cfbsBitmap->DisplayMode() == displayMode) + return; + if (image.depth() != TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode)) { + qWarning("Cannot convert display mode due to depth mismatch"); + return; + } + + const TSize size = cfbsBitmap->SizeInPixels(); + QScopedPointer newBitmap(createSymbianCFbsBitmap(size, displayMode)); + + const uchar *sptr = const_cast(image).bits(); + symbianBitmapDataAccess->beginDataAccess(newBitmap.data()); + uchar *dptr = (uchar*)newBitmap->DataAddress(); + Mem::Copy(dptr, sptr, image.byteCount()); + symbianBitmapDataAccess->endDataAccess(newBitmap.data()); + + QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); + delete cfbsBitmap; + lock.relock(); + cfbsBitmap = newBitmap.take(); + setSerialNumber(cfbsBitmap->Handle()); + UPDATE_BUFFER(); +} + +QPixmapData *QSymbianRasterPixmapData::createCompatiblePixmapData() const +{ + return new QSymbianRasterPixmapData(pixelType()); +} + +QT_END_NAMESPACE diff --git a/src/gui/image/qpixmap_raster_symbian_p.h b/src/gui/image/qpixmap_raster_symbian_p.h new file mode 100644 index 0000000000..7f4e53a15b --- /dev/null +++ b/src/gui/image/qpixmap_raster_symbian_p.h @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPIXMAP_RASTER_SYMBIAN_P_H +#define QPIXMAP_RASTER_SYMBIAN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class CFbsBitmap; +class CFbsBitmapDevice; +class CFbsBitGc; + +class QSymbianBitmapDataAccess; + +class QSymbianFbsHeapLock +{ +public: + + enum LockAction { + Unlock + }; + + explicit QSymbianFbsHeapLock(LockAction a); + ~QSymbianFbsHeapLock(); + void relock(); + +private: + + LockAction action; + bool wasLocked; +}; + +class QSymbianRasterPixmapData : public QRasterPixmapData +{ +public: + QSymbianRasterPixmapData(PixelType type); + ~QSymbianRasterPixmapData(); + + QPixmapData *createCompatiblePixmapData() const; + + void resize(int width, int height); + void fromImage(const QImage &image, Qt::ImageConversionFlags flags); + void copy(const QPixmapData *data, const QRect &rect); + bool scroll(int dx, int dy, const QRect &rect); + + int metric(QPaintDevice::PaintDeviceMetric metric) const; + void fill(const QColor &color); + void setMask(const QBitmap &mask); + void setAlphaChannel(const QPixmap &alphaChannel); + QImage toImage() const; + QPaintEngine* paintEngine() const; + + void beginDataAccess(); + void endDataAccess(bool readOnly=false) const; + + void* toNativeType(NativeType type); + void fromNativeType(void* pixmap, NativeType type); + + void convertToDisplayMode(int mode); + +private: + void release(); + void fromSymbianBitmap(CFbsBitmap* bitmap, bool lockFormat=false); + QImage toImage(const QRect &r) const; + + QSymbianBitmapDataAccess *symbianBitmapDataAccess; + + CFbsBitmap *cfbsBitmap; + QPaintEngine *pengine; + uchar* bytes; + + bool formatLocked; + + QSymbianRasterPixmapData *next; + QSymbianRasterPixmapData *prev; + + static void qt_symbian_register_pixmap(QSymbianRasterPixmapData *pd); + static void qt_symbian_unregister_pixmap(QSymbianRasterPixmapData *pd); + static void qt_symbian_release_pixmaps(); + + friend class QPixmap; + friend class QS60WindowSurface; + friend class QSymbianRasterPaintEngine; + friend class QS60Data; +}; + +QT_END_NAMESPACE + +#endif // QPIXMAP_RASTER_SYMBIAN_P_H diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp deleted file mode 100644 index b55c5997ee..0000000000 --- a/src/gui/image/qpixmap_s60.cpp +++ /dev/null @@ -1,1042 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include - -#include -#include -#include -#include - -#include "qpixmap.h" -#include "qpixmap_raster_p.h" -#include -#include "qpixmap_s60_p.h" -#include "qnativeimage_p.h" -#include "qbitmap.h" -#include "qimage.h" -#include "qimage_p.h" - -#include - -QT_BEGIN_NAMESPACE - -const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, - 0x10, 0x20, 0x40, 0x80 }; - -static bool cleanup_function_registered = false; -static QS60PixmapData *firstPixmap = 0; - -// static -void QS60PixmapData::qt_symbian_register_pixmap(QS60PixmapData *pd) -{ - if (!cleanup_function_registered) { - qAddPostRoutine(qt_symbian_release_pixmaps); - cleanup_function_registered = true; - } - - pd->next = firstPixmap; - pd->prev = 0; - if (firstPixmap) - firstPixmap->prev = pd; - firstPixmap = pd; -} - -// static -void QS60PixmapData::qt_symbian_unregister_pixmap(QS60PixmapData *pd) -{ - if (pd->next) - pd->next->prev = pd->prev; - if (pd->prev) - pd->prev->next = pd->next; - else - firstPixmap = pd->next; -} - -// static -void QS60PixmapData::qt_symbian_release_pixmaps() -{ - // Scan all QS60PixmapData objects in the system and destroy them. - QS60PixmapData *pd = firstPixmap; - while (pd != 0) { - pd->release(); - pd = pd->next; - } -} - -/* - \class QSymbianFbsClient - \since 4.6 - \internal - - Symbian Font And Bitmap server client that is - used to lock the global bitmap heap. Only used in - S60 v3.1 and S60 v3.2. -*/ -_LIT(KFBSERVLargeBitmapAccessName,"FbsLargeBitmapAccess"); -class QSymbianFbsClient -{ -public: - - QSymbianFbsClient() : heapLocked(false) - { - heapLock.OpenGlobal(KFBSERVLargeBitmapAccessName); - } - - ~QSymbianFbsClient() - { - heapLock.Close(); - } - - bool lockHeap() - { - bool wasLocked = heapLocked; - - if (heapLock.Handle() && !heapLocked) { - heapLock.Wait(); - heapLocked = true; - } - - return wasLocked; - } - - bool unlockHeap() - { - bool wasLocked = heapLocked; - - if (heapLock.Handle() && heapLocked) { - heapLock.Signal(); - heapLocked = false; - } - - return wasLocked; - } - - -private: - - RMutex heapLock; - bool heapLocked; -}; - -Q_GLOBAL_STATIC(QSymbianFbsClient, qt_symbianFbsClient); - - - -// QSymbianFbsHeapLock - -QSymbianFbsHeapLock::QSymbianFbsHeapLock(LockAction a) -: action(a), wasLocked(false) -{ - QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); - if (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3) - wasLocked = qt_symbianFbsClient()->unlockHeap(); -} - -QSymbianFbsHeapLock::~QSymbianFbsHeapLock() -{ - // Do nothing -} - -void QSymbianFbsHeapLock::relock() -{ - QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); - if (wasLocked && (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3)) - qt_symbianFbsClient()->lockHeap(); -} - -/* - \class QSymbianBitmapDataAccess - \since 4.6 - \internal - - Data access class that is used to locks/unlocks pixel data - when drawing or modifying CFbsBitmap pixel data. -*/ -class QSymbianBitmapDataAccess -{ -public: - - static int heapRefCount; - QSysInfo::SymbianVersion symbianVersion; - - explicit QSymbianBitmapDataAccess() - { - symbianVersion = QSysInfo::symbianVersion(); - }; - - ~QSymbianBitmapDataAccess() {}; - - inline void beginDataAccess(CFbsBitmap *bitmap) - { - if (symbianVersion == QSysInfo::SV_9_2) { - if (heapRefCount == 0) - qt_symbianFbsClient()->lockHeap(); - } else { - bitmap->LockHeap(ETrue); - } - - heapRefCount++; - } - - inline void endDataAccess(CFbsBitmap *bitmap) - { - heapRefCount--; - - if (symbianVersion == QSysInfo::SV_9_2) { - if (heapRefCount == 0) - qt_symbianFbsClient()->unlockHeap(); - } else { - bitmap->UnlockHeap(ETrue); - } - } -}; - -int QSymbianBitmapDataAccess::heapRefCount = 0; - - -#define UPDATE_BUFFER() \ - { \ - beginDataAccess(); \ - endDataAccess(); \ -} - - -static CFbsBitmap* createSymbianCFbsBitmap(const TSize& size, TDisplayMode mode) -{ - QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); - - CFbsBitmap* bitmap = 0; - QT_TRAP_THROWING(bitmap = new (ELeave) CFbsBitmap); - - if (bitmap->Create(size, mode) != KErrNone) { - delete bitmap; - bitmap = 0; - } - - lock.relock(); - - return bitmap; -} - -static CFbsBitmap* uncompress(CFbsBitmap* bitmap) -{ - if(bitmap->IsCompressedInRAM()) { - QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); - - CFbsBitmap *uncompressed = 0; - QT_TRAP_THROWING(uncompressed = new (ELeave) CFbsBitmap); - - if (uncompressed->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) { - delete bitmap; - bitmap = 0; - lock.relock(); - - return bitmap; - } - - lock.relock(); - - CFbsBitmapDevice* bitmapDevice = 0; - CFbsBitGc *bitmapGc = 0; - QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(uncompressed)); - QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL()); - bitmapGc->Activate(bitmapDevice); - - bitmapGc->BitBlt(TPoint(), bitmap); - - delete bitmapGc; - delete bitmapDevice; - - return uncompressed; - } else { - return bitmap; - } -} - -QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h) -{ - CWsScreenDevice* screenDevice = S60->screenDevice(); - TSize screenSize = screenDevice->SizeInPixels(); - - TSize srcSize; - // Find out if this is one of our windows. - QSymbianControl *sControl; - sControl = winId->MopGetObject(sControl); - if (sControl && sControl->widget()->windowType() == Qt::Desktop) { - // Grabbing desktop widget - srcSize = screenSize; - } else { - TPoint relativePos = winId->PositionRelativeToScreen(); - x += relativePos.iX; - y += relativePos.iY; - srcSize = winId->Size(); - } - - TRect srcRect(TPoint(x, y), srcSize); - // Clip to the screen - srcRect.Intersection(TRect(screenSize)); - - if (w > 0 && h > 0) { - TRect subRect(TPoint(x, y), TSize(w, h)); - // Clip to the subRect - srcRect.Intersection(subRect); - } - - if (srcRect.IsEmpty()) - return QPixmap(); - - CFbsBitmap* temporary = createSymbianCFbsBitmap(srcRect.Size(), screenDevice->DisplayMode()); - - QPixmap pix; - - if (temporary && screenDevice->CopyScreenToBitmap(temporary, srcRect) == KErrNone) { - pix = QPixmap::fromSymbianCFbsBitmap(temporary); - } - - delete temporary; - return pix; -} - -/*! - \fn CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const - \since 4.6 - - Creates a \c CFbsBitmap that is equivalent to the QPixmap. Internally this - function will try to duplicate the handle instead of copying the data, - however in scenarios where this is not possible the data will be copied. - If the creation fails or the pixmap is null, then this function returns 0. - - It is the caller's responsibility to release the \c CFbsBitmap data - after use either by deleting the bitmap or calling \c Reset(). - - \warning On S60 3.1 and S60 3.2, semi-transparent pixmaps are always copied - and not duplicated. - \warning This function is only available on Symbian OS. - - \sa fromSymbianCFbsBitmap() -*/ -CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const -{ - QPixmapData *data = pixmapData(); - if (!data || data->isNull()) - return 0; - - return reinterpret_cast(data->toNativeType(QPixmapData::FbsBitmap)); -} - -/*! - \fn QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) - \since 4.6 - - Creates a QPixmap from a \c CFbsBitmap \a bitmap. Internally this function - will try to duplicate the bitmap handle instead of copying the data, however - in scenarios where this is not possible the data will be copied. - To be sure that QPixmap does not modify your original instance, you should - make a copy of your \c CFbsBitmap before calling this function. - If the CFbsBitmap is not valid this function will return a null QPixmap. - For performance reasons it is recommended to use a \a bitmap with a display - mode of EColor16MAP or EColor16MU whenever possible. - - \warning This function is only available on Symbian OS. - - \sa toSymbianCFbsBitmap(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} -*/ -QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) -{ - if (!bitmap) - return QPixmap(); - - QScopedPointer data(QPixmapData::create(0,0, QPixmapData::PixmapType)); - data->fromNativeType(reinterpret_cast(bitmap), QPixmapData::FbsBitmap); - QPixmap pixmap(data.take()); - return pixmap; -} - -QS60PixmapData::QS60PixmapData(PixelType type) : QRasterPixmapData(type), - symbianBitmapDataAccess(new QSymbianBitmapDataAccess), - cfbsBitmap(0), - pengine(0), - bytes(0), - formatLocked(false), - next(0), - prev(0) -{ - qt_symbian_register_pixmap(this); -} - -QS60PixmapData::~QS60PixmapData() -{ - release(); - delete symbianBitmapDataAccess; - qt_symbian_unregister_pixmap(this); -} - -void QS60PixmapData::resize(int width, int height) -{ - if (width <= 0 || height <= 0) { - w = width; - h = height; - is_null = true; - - release(); - return; - } else if (!cfbsBitmap) { - TDisplayMode mode; - if (pixelType() == BitmapType) - mode = EGray2; - else - mode = EColor16MU; - - CFbsBitmap* bitmap = createSymbianCFbsBitmap(TSize(width, height), mode); - fromSymbianBitmap(bitmap); - } else { - - TSize newSize(width, height); - - if(cfbsBitmap->SizeInPixels() != newSize) { - cfbsBitmap->Resize(TSize(width, height)); - if(pengine) { - delete pengine; - pengine = 0; - } - } - - UPDATE_BUFFER(); - } -} - -void QS60PixmapData::release() -{ - if (cfbsBitmap) { - QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); - delete cfbsBitmap; - lock.relock(); - } - - delete pengine; - image = QImage(); - cfbsBitmap = 0; - pengine = 0; - bytes = 0; -} - -/*! - * Takes ownership of bitmap. Used by window surface - */ -void QS60PixmapData::fromSymbianBitmap(CFbsBitmap* bitmap, bool lockFormat) -{ - Q_ASSERT(bitmap); - - release(); - - cfbsBitmap = bitmap; - formatLocked = lockFormat; - - setSerialNumber(cfbsBitmap->Handle()); - - UPDATE_BUFFER(); - - // Create default palette if needed - if (cfbsBitmap->DisplayMode() == EGray2) { - image.setColorCount(2); - image.setColor(0, QColor(Qt::color0).rgba()); - image.setColor(1, QColor(Qt::color1).rgba()); - - //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid - //So invert mono bitmaps so that masks work correctly. - image.invertPixels(); - } else if (cfbsBitmap->DisplayMode() == EGray256) { - for (int i=0; i < 256; ++i) - image.setColor(i, qRgb(i, i, i)); - } else if (cfbsBitmap->DisplayMode() == EColor256) { - const TColor256Util *palette = TColor256Util::Default(); - for (int i=0; i < 256; ++i) - image.setColor(i, (QRgb)(palette->Color256(i).Value())); - } -} - -QImage QS60PixmapData::toImage(const QRect &r) const -{ - QS60PixmapData *that = const_cast(this); - that->beginDataAccess(); - QImage copy = that->image.copy(r); - that->endDataAccess(); - - return copy; -} - -void QS60PixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags) -{ - release(); - - QImage sourceImage; - - if (pixelType() == BitmapType) { - sourceImage = img.convertToFormat(QImage::Format_MonoLSB); - } else { - if (img.depth() == 1) { - sourceImage = img.hasAlphaChannel() - ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied) - : img.convertToFormat(QImage::Format_RGB32); - } else { - - QImage::Format opaqueFormat = QNativeImage::systemFormat(); - QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied; - - if (!img.hasAlphaChannel() - || ((flags & Qt::NoOpaqueDetection) == 0 - && !const_cast(img).data_ptr()->checkForAlphaPixels())) { - sourceImage = img.convertToFormat(opaqueFormat); - } else { - sourceImage = img.convertToFormat(alphaFormat); - } - } - } - - - QImage::Format destFormat = sourceImage.format(); - TDisplayMode mode; - switch (destFormat) { - case QImage::Format_MonoLSB: - mode = EGray2; - break; - case QImage::Format_RGB32: - mode = EColor16MU; - break; - case QImage::Format_ARGB32_Premultiplied: - if (S60->supportsPremultipliedAlpha) { - mode = Q_SYMBIAN_ECOLOR16MAP; - break; - } else { - destFormat = QImage::Format_ARGB32; - } - // Fall through intended - case QImage::Format_ARGB32: - mode = EColor16MA; - break; - case QImage::Format_Invalid: - return; - default: - qWarning("Image format not supported: %d", image.format()); - return; - } - - cfbsBitmap = createSymbianCFbsBitmap(TSize(sourceImage.width(), sourceImage.height()), mode); - if (!cfbsBitmap) { - qWarning("Could not create CFbsBitmap"); - release(); - return; - } - - setSerialNumber(cfbsBitmap->Handle()); - - const uchar *sptr = const_cast(sourceImage).bits(); - symbianBitmapDataAccess->beginDataAccess(cfbsBitmap); - uchar *dptr = (uchar*)cfbsBitmap->DataAddress(); - Mem::Copy(dptr, sptr, sourceImage.byteCount()); - symbianBitmapDataAccess->endDataAccess(cfbsBitmap); - - UPDATE_BUFFER(); - - if (destFormat == QImage::Format_MonoLSB) { - image.setColorCount(2); - image.setColor(0, QColor(Qt::color0).rgba()); - image.setColor(1, QColor(Qt::color1).rgba()); - } else { - image.setColorTable(sourceImage.colorTable()); - } -} - -void QS60PixmapData::copy(const QPixmapData *data, const QRect &rect) -{ - const QS60PixmapData *s60Data = static_cast(data); - fromImage(s60Data->toImage(rect), Qt::AutoColor | Qt::OrderedAlphaDither); -} - -bool QS60PixmapData::scroll(int dx, int dy, const QRect &rect) -{ - beginDataAccess(); - bool res = QRasterPixmapData::scroll(dx, dy, rect); - endDataAccess(); - return res; -} - -Q_GUI_EXPORT int qt_defaultDpiX(); -Q_GUI_EXPORT int qt_defaultDpiY(); - -int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const -{ - if (!cfbsBitmap) - return 0; - - switch (metric) { - case QPaintDevice::PdmWidth: - return cfbsBitmap->SizeInPixels().iWidth; - case QPaintDevice::PdmHeight: - return cfbsBitmap->SizeInPixels().iHeight; - case QPaintDevice::PdmWidthMM: - return qRound(cfbsBitmap->SizeInPixels().iWidth * 25.4 / qt_defaultDpiX()); - case QPaintDevice::PdmHeightMM: - return qRound(cfbsBitmap->SizeInPixels().iHeight * 25.4 / qt_defaultDpiY()); - case QPaintDevice::PdmNumColors: - return TDisplayModeUtils::NumDisplayModeColors(cfbsBitmap->DisplayMode()); - case QPaintDevice::PdmDpiX: - case QPaintDevice::PdmPhysicalDpiX: - return qt_defaultDpiX(); - case QPaintDevice::PdmDpiY: - case QPaintDevice::PdmPhysicalDpiY: - return qt_defaultDpiY(); - case QPaintDevice::PdmDepth: - return TDisplayModeUtils::NumDisplayModeBitsPerPixel(cfbsBitmap->DisplayMode()); - default: - qWarning("QPixmap::metric: Invalid metric command"); - } - return 0; - -} - -void QS60PixmapData::fill(const QColor &color) -{ - if (color.alpha() != 255) { - QImage im(width(), height(), QImage::Format_ARGB32_Premultiplied); - im.fill(PREMUL(color.rgba())); - release(); - fromImage(im, Qt::AutoColor | Qt::OrderedAlphaDither); - } else { - beginDataAccess(); - QRasterPixmapData::fill(color); - endDataAccess(); - } -} - -void QS60PixmapData::setMask(const QBitmap &mask) -{ - if (mask.size().isEmpty()) { - if (image.depth() != 1) { - QImage newImage = image.convertToFormat(QImage::Format_RGB32); - release(); - fromImage(newImage, Qt::AutoColor | Qt::OrderedAlphaDither); - } - } else if (image.depth() == 1) { - beginDataAccess(); - QRasterPixmapData::setMask(mask); - endDataAccess(); - } else { - const int w = image.width(); - const int h = image.height(); - - const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB); - QImage newImage = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); - for (int y = 0; y < h; ++y) { - const uchar *mscan = imageMask.scanLine(y); - QRgb *tscan = (QRgb *)newImage.scanLine(y); - for (int x = 0; x < w; ++x) { - if (!(mscan[x>>3] & qt_pixmap_bit_mask[x&7])) - tscan[x] = 0; - } - } - release(); - fromImage(newImage, Qt::AutoColor | Qt::OrderedAlphaDither); - } -} - -void QS60PixmapData::setAlphaChannel(const QPixmap &alphaChannel) -{ - QImage img(toImage()); - img.setAlphaChannel(alphaChannel.toImage()); - release(); - fromImage(img, Qt::OrderedDither | Qt::OrderedAlphaDither); -} - -QImage QS60PixmapData::toImage() const -{ - return toImage(QRect()); -} - -QPaintEngine* QS60PixmapData::paintEngine() const -{ - if (!pengine) { - QS60PixmapData *that = const_cast(this); - that->pengine = new QS60PaintEngine(&that->image, that); - } - return pengine; -} - -void QS60PixmapData::beginDataAccess() -{ - if(!cfbsBitmap) - return; - - symbianBitmapDataAccess->beginDataAccess(cfbsBitmap); - - uchar* newBytes = (uchar*)cfbsBitmap->DataAddress(); - - TSize size = cfbsBitmap->SizeInPixels(); - - if (newBytes == bytes && image.width() == size.iWidth && image.height() == size.iHeight) - return; - - bytes = newBytes; - TDisplayMode mode = cfbsBitmap->DisplayMode(); - QImage::Format format = qt_TDisplayMode2Format(mode); - // On S60 3.1, premultiplied alpha pixels are stored in a bitmap with 16MA type. - // S60 window surface needs backing store pixmap for transparent window in ARGB32 format. - // In that case formatLocked is true. - if (!formatLocked && format == QImage::Format_ARGB32) - format = QImage::Format_ARGB32_Premultiplied; // pixel data is actually in premultiplied format - - QVector savedColorTable; - if (!image.isNull()) - savedColorTable = image.colorTable(); - - image = QImage(bytes, size.iWidth, size.iHeight, format); - - // Restore the palette or create a default - if (!savedColorTable.isEmpty()) { - image.setColorTable(savedColorTable); - } - - w = size.iWidth; - h = size.iHeight; - d = image.depth(); - is_null = (w <= 0 || h <= 0); - - if (pengine) { - QS60PaintEngine *engine = static_cast(pengine); - engine->prepare(&image); - } -} - -void QS60PixmapData::endDataAccess(bool readOnly) const -{ - Q_UNUSED(readOnly); - - if(!cfbsBitmap) - return; - - symbianBitmapDataAccess->endDataAccess(cfbsBitmap); -} - -/*! - \since 4.6 - - Returns a QPixmap that wraps given \a sgImage graphics resource. - The data should be valid even when original RSgImage handle has been - closed. - - \warning This function is only available on Symbian OS. - - \sa toSymbianRSgImage(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} -*/ - -QPixmap QPixmap::fromSymbianRSgImage(RSgImage *sgImage) -{ - // It is expected that RSgImage will - // CURRENTLY be used in conjuction with - // OpenVG graphics system - // - // Surely things might change in future - - if (!sgImage) - return QPixmap(); - - QScopedPointer data(QPixmapData::create(0,0, QPixmapData::PixmapType)); - data->fromNativeType(reinterpret_cast(sgImage), QPixmapData::SgImage); - QPixmap pixmap(data.take()); - return pixmap; -} - -/*! -\since 4.6 - -Returns a \c RSgImage that is equivalent to the QPixmap by copying the data. - -It is the caller's responsibility to close/delete the \c RSgImage after use. - -\warning This function is only available on Symbian OS. - -\sa fromSymbianRSgImage() -*/ - -RSgImage *QPixmap::toSymbianRSgImage() const -{ - // It is expected that RSgImage will - // CURRENTLY be used in conjuction with - // OpenVG graphics system - // - // Surely things might change in future - - if (isNull()) - return 0; - - RSgImage *sgImage = reinterpret_cast(pixmapData()->toNativeType(QPixmapData::SgImage)); - - return sgImage; -} - -void* QS60PixmapData::toNativeType(NativeType type) -{ - if (type == QPixmapData::SgImage) { - return 0; - } else if (type == QPixmapData::FbsBitmap) { - - if (isNull() || !cfbsBitmap) - return 0; - - bool convertToArgb32 = false; - bool needsCopy = false; - - if (!(S60->supportsPremultipliedAlpha)) { - // Convert argb32_premultiplied to argb32 since Symbian 9.2 does - // not support premultipied format. - - if (image.format() == QImage::Format_ARGB32_Premultiplied) { - needsCopy = true; - convertToArgb32 = true; - } - } - - CFbsBitmap *bitmap = 0; - - TDisplayMode displayMode = cfbsBitmap->DisplayMode(); - - if(displayMode == EGray2) { - //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid - //So invert mono bitmaps so that masks work correctly. - beginDataAccess(); - image.invertPixels(); - endDataAccess(); - needsCopy = true; - } - - if (needsCopy) { - QImage source; - - if (convertToArgb32) { - beginDataAccess(); - source = image.convertToFormat(QImage::Format_ARGB32); - endDataAccess(); - displayMode = EColor16MA; - } else { - source = image; - } - - CFbsBitmap *newBitmap = createSymbianCFbsBitmap(TSize(source.width(), source.height()), displayMode); - const uchar *sptr = source.bits(); - symbianBitmapDataAccess->beginDataAccess(newBitmap); - - uchar *dptr = (uchar*)newBitmap->DataAddress(); - Mem::Copy(dptr, sptr, source.byteCount()); - - symbianBitmapDataAccess->endDataAccess(newBitmap); - - bitmap = newBitmap; - } else { - - QT_TRAP_THROWING(bitmap = new (ELeave) CFbsBitmap); - - TInt err = bitmap->Duplicate(cfbsBitmap->Handle()); - if (err != KErrNone) { - qWarning("Could not duplicate CFbsBitmap"); - delete bitmap; - bitmap = 0; - } - } - - if(displayMode == EGray2) { - // restore pixels - beginDataAccess(); - image.invertPixels(); - endDataAccess(); - } - - return reinterpret_cast(bitmap); - - } - - return 0; -} - -void QS60PixmapData::fromNativeType(void* pixmap, NativeType nativeType) -{ - if (nativeType == QPixmapData::SgImage) { - return; - } else if (nativeType == QPixmapData::FbsBitmap && pixmap) { - - CFbsBitmap *bitmap = reinterpret_cast(pixmap); - - bool deleteSourceBitmap = false; - bool needsCopy = false; - -#ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE - - // Rasterize extended bitmaps - - TUid extendedBitmapType = bitmap->ExtendedBitmapType(); - if (extendedBitmapType != KNullUid) { - CFbsBitmap *rasterBitmap = createSymbianCFbsBitmap(bitmap->SizeInPixels(), EColor16MA); - - CFbsBitmapDevice *rasterBitmapDev = 0; - QT_TRAP_THROWING(rasterBitmapDev = CFbsBitmapDevice::NewL(rasterBitmap)); - - CFbsBitGc *rasterBitmapGc = 0; - TInt err = rasterBitmapDev->CreateContext(rasterBitmapGc); - if (err != KErrNone) { - delete rasterBitmap; - delete rasterBitmapDev; - rasterBitmapDev = 0; - return; - } - - rasterBitmapGc->BitBlt(TPoint( 0, 0), bitmap); - - bitmap = rasterBitmap; - - delete rasterBitmapDev; - delete rasterBitmapGc; - - rasterBitmapDev = 0; - rasterBitmapGc = 0; - - deleteSourceBitmap = true; - } -#endif - - - deleteSourceBitmap = bitmap->IsCompressedInRAM(); - CFbsBitmap *sourceBitmap = uncompress(bitmap); - - TDisplayMode displayMode = sourceBitmap->DisplayMode(); - QImage::Format format = qt_TDisplayMode2Format(displayMode); - - QImage::Format opaqueFormat = QNativeImage::systemFormat(); - QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied; - - if (format != opaqueFormat && format != alphaFormat && format != QImage::Format_MonoLSB) - needsCopy = true; - - - type = (format != QImage::Format_MonoLSB) - ? QPixmapData::PixmapType - : QPixmapData::BitmapType; - - if (needsCopy) { - - TSize size = sourceBitmap->SizeInPixels(); - int bytesPerLine = sourceBitmap->ScanLineLength(size.iWidth, displayMode); - - QSymbianBitmapDataAccess da; - da.beginDataAccess(sourceBitmap); - uchar *bytes = (uchar*)sourceBitmap->DataAddress(); - QImage img = QImage(bytes, size.iWidth, size.iHeight, bytesPerLine, format); - img = img.copy(); - da.endDataAccess(sourceBitmap); - - if(displayMode == EGray2) { - //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid - //So invert mono bitmaps so that masks work correctly. - img.invertPixels(); - } else if(displayMode == EColor16M) { - img = img.rgbSwapped(); // EColor16M is BGR - } - - fromImage(img, Qt::AutoColor); - - if(deleteSourceBitmap) - delete sourceBitmap; - } else { - CFbsBitmap* duplicate = 0; - QT_TRAP_THROWING(duplicate = new (ELeave) CFbsBitmap); - - TInt err = duplicate->Duplicate(sourceBitmap->Handle()); - if (err != KErrNone) { - qWarning("Could not duplicate CFbsBitmap"); - - if(deleteSourceBitmap) - delete sourceBitmap; - - delete duplicate; - return; - } - - fromSymbianBitmap(duplicate); - - if(deleteSourceBitmap) - delete sourceBitmap; - } - } -} - -void QS60PixmapData::convertToDisplayMode(int mode) -{ - const TDisplayMode displayMode = static_cast(mode); - if (!cfbsBitmap || cfbsBitmap->DisplayMode() == displayMode) - return; - if (image.depth() != TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode)) { - qWarning("Cannot convert display mode due to depth mismatch"); - return; - } - - const TSize size = cfbsBitmap->SizeInPixels(); - QScopedPointer newBitmap(createSymbianCFbsBitmap(size, displayMode)); - - const uchar *sptr = const_cast(image).bits(); - symbianBitmapDataAccess->beginDataAccess(newBitmap.data()); - uchar *dptr = (uchar*)newBitmap->DataAddress(); - Mem::Copy(dptr, sptr, image.byteCount()); - symbianBitmapDataAccess->endDataAccess(newBitmap.data()); - - QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); - delete cfbsBitmap; - lock.relock(); - cfbsBitmap = newBitmap.take(); - setSerialNumber(cfbsBitmap->Handle()); - UPDATE_BUFFER(); -} - -QPixmapData *QS60PixmapData::createCompatiblePixmapData() const -{ - return new QS60PixmapData(pixelType()); -} - -QT_END_NAMESPACE diff --git a/src/gui/image/qpixmap_s60_p.h b/src/gui/image/qpixmap_s60_p.h deleted file mode 100644 index e48154963b..0000000000 --- a/src/gui/image/qpixmap_s60_p.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPIXMAPDATA_S60_P_H -#define QPIXMAPDATA_S60_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class CFbsBitmap; -class CFbsBitmapDevice; -class CFbsBitGc; - -class QSymbianBitmapDataAccess; - -class QSymbianFbsHeapLock -{ -public: - - enum LockAction { - Unlock - }; - - explicit QSymbianFbsHeapLock(LockAction a); - ~QSymbianFbsHeapLock(); - void relock(); - -private: - - LockAction action; - bool wasLocked; -}; - -class QS60PixmapData : public QRasterPixmapData -{ -public: - QS60PixmapData(PixelType type); - ~QS60PixmapData(); - - QPixmapData *createCompatiblePixmapData() const; - - void resize(int width, int height); - void fromImage(const QImage &image, Qt::ImageConversionFlags flags); - void copy(const QPixmapData *data, const QRect &rect); - bool scroll(int dx, int dy, const QRect &rect); - - int metric(QPaintDevice::PaintDeviceMetric metric) const; - void fill(const QColor &color); - void setMask(const QBitmap &mask); - void setAlphaChannel(const QPixmap &alphaChannel); - QImage toImage() const; - QPaintEngine* paintEngine() const; - - void beginDataAccess(); - void endDataAccess(bool readOnly=false) const; - - void* toNativeType(NativeType type); - void fromNativeType(void* pixmap, NativeType type); - - void convertToDisplayMode(int mode); - -private: - void release(); - void fromSymbianBitmap(CFbsBitmap* bitmap, bool lockFormat=false); - QImage toImage(const QRect &r) const; - - QSymbianBitmapDataAccess *symbianBitmapDataAccess; - - CFbsBitmap *cfbsBitmap; - QPaintEngine *pengine; - uchar* bytes; - - bool formatLocked; - - QS60PixmapData *next; - QS60PixmapData *prev; - - static void qt_symbian_register_pixmap(QS60PixmapData *pd); - static void qt_symbian_unregister_pixmap(QS60PixmapData *pd); - static void qt_symbian_release_pixmaps(); - - friend class QPixmap; - friend class QS60WindowSurface; - friend class QS60PaintEngine; - friend class QS60Data; -}; - -QT_END_NAMESPACE - -#endif // QPIXMAPDATA_S60_P_H - diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index cf089fbbcf..f868badd16 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -158,7 +158,7 @@ protected: private: friend class QPixmap; friend class QX11PixmapData; - friend class QS60PixmapData; + friend class QSymbianRasterPixmapData; friend class QImagePixmapCleanupHooks; // Needs to set is_cached friend class QGLTextureCache; //Needs to check the reference count friend class QExplicitlySharedDataPointer; diff --git a/src/gui/image/qpixmapdatafactory.cpp b/src/gui/image/qpixmapdatafactory.cpp index c74cb7c278..060f7fd97d 100644 --- a/src/gui/image/qpixmapdatafactory.cpp +++ b/src/gui/image/qpixmapdatafactory.cpp @@ -54,7 +54,7 @@ # include #endif #ifdef Q_OS_SYMBIAN -# include +# include #endif #include "private/qapplication_p.h" @@ -83,7 +83,7 @@ QPixmapData* QSimplePixmapDataFactory::create(QPixmapData::PixelType type) #elif defined(Q_WS_MAC) return new QMacPixmapData(type); #elif defined(Q_OS_SYMBIAN) - return new QS60PixmapData(type); + return new QSymbianRasterPixmapData(type); #else #error QSimplePixmapDataFactory::create() not implemented #endif diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 6896b7d85b..96b82da9c1 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1917,7 +1917,7 @@ void qt_cleanup() qt_S60Beep = 0; } QFontCache::cleanup(); // Has to happen now, since QFontEngineS60 has FBS handles - QPixmapCache::clear(); // Has to happen now, since QS60PixmapData has FBS handles + QPixmapCache::clear(); // Has to happen now, since QSymbianRasterPixmapData has FBS handles qt_cleanup_symbianFontDatabase(); // S60 structure and window server session are freed in eventdispatcher destructor as they are needed there diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index b3b647a85a..8ee65b510b 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -184,12 +184,12 @@ embedded { symbian { SOURCES += \ - painting/qpaintengine_s60.cpp \ + painting/qpaintengine_raster_symbian.cpp \ painting/qregion_s60.cpp \ painting/qcolormap_s60.cpp HEADERS += \ - painting/qpaintengine_s60_p.h + painting/qpaintengine_raster_symbian_p.h } x11|embedded { diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index 22bf193c00..455f07b77c 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -51,7 +51,7 @@ # include #endif #ifdef Q_OS_SYMBIAN -# include +# include # include #else # include @@ -75,7 +75,7 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ #elif defined(Q_WS_MAC) return new QMacPixmapData(type); #elif defined(Q_OS_SYMBIAN) - return new QS60PixmapData(type); + return new QSymbianRasterPixmapData(type); #elif !defined(Q_WS_QWS) #error QGraphicsSystem::createDefaultPixmapData() not implemented #endif diff --git a/src/gui/painting/qgraphicssystem_raster.cpp b/src/gui/painting/qgraphicssystem_raster.cpp index 0edbe9f5a3..addfff7619 100644 --- a/src/gui/painting/qgraphicssystem_raster.cpp +++ b/src/gui/painting/qgraphicssystem_raster.cpp @@ -42,7 +42,7 @@ #include "qgraphicssystem_raster_p.h" #ifdef Q_OS_SYMBIAN -#include "private/qpixmap_s60_p.h" +#include "private/qpixmap_raster_symbian_p.h" #include "private/qwindowsurface_s60_p.h" #else #include "private/qpixmap_raster_p.h" @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE QPixmapData *QRasterGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { #ifdef Q_OS_SYMBIAN - return new QS60PixmapData(type); + return new QSymbianRasterPixmapData(type); #else return new QRasterPixmapData(type); #endif diff --git a/src/gui/painting/qpaintengine_raster_symbian.cpp b/src/gui/painting/qpaintengine_raster_symbian.cpp new file mode 100644 index 0000000000..3b2707702f --- /dev/null +++ b/src/gui/painting/qpaintengine_raster_symbian.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QSymbianRasterPaintEnginePrivate : public QRasterPaintEnginePrivate +{ +public: + QSymbianRasterPaintEnginePrivate() {} +}; + +QSymbianRasterPaintEngine::QSymbianRasterPaintEngine(QPaintDevice *device, QSymbianRasterPixmapData *data) + : QRasterPaintEngine(*(new QSymbianRasterPaintEnginePrivate), device), pixmapData(data) +{ +} + +bool QSymbianRasterPaintEngine::begin(QPaintDevice *device) +{ + Q_D(QSymbianRasterPaintEngine); + + if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { + pixmapData->beginDataAccess(); + bool ret = QRasterPaintEngine::begin(device); + // Make sure QPaintEngine::paintDevice() returns the proper device. + // QRasterPaintEngine changes pdev to QImage in case of RasterClass QPixmapData + // which is incorrect in Symbian. + d->pdev = device; + return ret; + } + return QRasterPaintEngine::begin(device); +} + +bool QSymbianRasterPaintEngine::end() +{ + if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { + bool ret = QRasterPaintEngine::end(); + pixmapData->endDataAccess(); + return ret; + } + return QRasterPaintEngine::end(); +} + +void QSymbianRasterPaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) +{ + if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { + QSymbianRasterPixmapData *srcData = static_cast(pm.pixmapData()); + srcData->beginDataAccess(); + QRasterPaintEngine::drawPixmap(p, pm); + srcData->endDataAccess(); + } else { + QVolatileImage img = pm.pixmapData()->toVolatileImage(); + if (!img.isNull()) { + img.beginDataAccess(); + // imageRef() would detach and since we received the QVolatileImage + // from toVolatileImage() by value, it would cause a copy which + // would ruin our goal. So use constImageRef() instead. + QRasterPaintEngine::drawImage(p, img.constImageRef()); + img.endDataAccess(true); + } else { + QRasterPaintEngine::drawPixmap(p, pm); + } + } +} + +void QSymbianRasterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) +{ + if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { + QSymbianRasterPixmapData *srcData = static_cast(pm.pixmapData()); + srcData->beginDataAccess(); + QRasterPaintEngine::drawPixmap(r, pm, sr); + srcData->endDataAccess(); + } else { + QVolatileImage img = pm.pixmapData()->toVolatileImage(); + if (!img.isNull()) { + img.beginDataAccess(); + QRasterPaintEngine::drawImage(r, img.constImageRef(), sr); + img.endDataAccess(true); + } else { + QRasterPaintEngine::drawPixmap(r, pm, sr); + } + } +} + +void QSymbianRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr) +{ + if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { + QSymbianRasterPixmapData *srcData = static_cast(pm.pixmapData()); + srcData->beginDataAccess(); + QRasterPaintEngine::drawTiledPixmap(r, pm, sr); + srcData->endDataAccess(); + } else { + QRasterPaintEngine::drawTiledPixmap(r, pm, sr); + } +} + +// used by QSymbianRasterPixmapData::beginDataAccess() +void QSymbianRasterPaintEngine::prepare(QImage *image) +{ + QRasterBuffer *buffer = d_func()->rasterBuffer.data(); + if (buffer) + buffer->prepare(image); +} + +QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintengine_raster_symbian_p.h b/src/gui/painting/qpaintengine_raster_symbian_p.h new file mode 100644 index 0000000000..cb51ecb48e --- /dev/null +++ b/src/gui/painting/qpaintengine_raster_symbian_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPAINTENGINE_RASTER_SYMBIAN_P_H +#define QPAINTENGINE_RASTER_SYMBIAN_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 "private/qpaintengine_raster_p.h" + +QT_BEGIN_NAMESPACE + +class QSymbianRasterPaintEnginePrivate; +class QSymbianRasterPixmapData; + +class QSymbianRasterPaintEngine : public QRasterPaintEngine +{ + Q_DECLARE_PRIVATE(QSymbianRasterPaintEngine) + +public: + QSymbianRasterPaintEngine(QPaintDevice *device, QSymbianRasterPixmapData *data = 0); + bool begin(QPaintDevice *device); + bool end(); + + void drawPixmap(const QPointF &p, const QPixmap &pm); + void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); + void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr); + + void prepare(QImage* image); + +private: + QSymbianRasterPixmapData *pixmapData; +}; + +QT_END_NAMESPACE + +#endif // QPAINTENGINE_RASTER_SYMBIAN_P_H diff --git a/src/gui/painting/qpaintengine_s60.cpp b/src/gui/painting/qpaintengine_s60.cpp deleted file mode 100644 index fd7bea2f5e..0000000000 --- a/src/gui/painting/qpaintengine_s60.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QS60PaintEnginePrivate : public QRasterPaintEnginePrivate -{ -public: - QS60PaintEnginePrivate() {} -}; - -QS60PaintEngine::QS60PaintEngine(QPaintDevice *device, QS60PixmapData *data) - : QRasterPaintEngine(*(new QS60PaintEnginePrivate), device), pixmapData(data) -{ -} - -bool QS60PaintEngine::begin(QPaintDevice *device) -{ - Q_D(QS60PaintEngine); - - if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { - pixmapData->beginDataAccess(); - bool ret = QRasterPaintEngine::begin(device); - // Make sure QPaintEngine::paintDevice() returns the proper device. - // QRasterPaintEngine changes pdev to QImage in case of RasterClass QPixmapData - // which is incorrect in Symbian. - d->pdev = device; - return ret; - } - return QRasterPaintEngine::begin(device); -} - -bool QS60PaintEngine::end() -{ - if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { - bool ret = QRasterPaintEngine::end(); - pixmapData->endDataAccess(); - return ret; - } - return QRasterPaintEngine::end(); -} - -void QS60PaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) -{ - if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { - QS60PixmapData *srcData = static_cast(pm.pixmapData()); - srcData->beginDataAccess(); - QRasterPaintEngine::drawPixmap(p, pm); - srcData->endDataAccess(); - } else { - QVolatileImage img = pm.pixmapData()->toVolatileImage(); - if (!img.isNull()) { - img.beginDataAccess(); - // imageRef() would detach and since we received the QVolatileImage - // from toVolatileImage() by value, it would cause a copy which - // would ruin our goal. So use constImageRef() instead. - QRasterPaintEngine::drawImage(p, img.constImageRef()); - img.endDataAccess(true); - } else { - QRasterPaintEngine::drawPixmap(p, pm); - } - } -} - -void QS60PaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) -{ - if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { - QS60PixmapData *srcData = static_cast(pm.pixmapData()); - srcData->beginDataAccess(); - QRasterPaintEngine::drawPixmap(r, pm, sr); - srcData->endDataAccess(); - } else { - QVolatileImage img = pm.pixmapData()->toVolatileImage(); - if (!img.isNull()) { - img.beginDataAccess(); - QRasterPaintEngine::drawImage(r, img.constImageRef(), sr); - img.endDataAccess(true); - } else { - QRasterPaintEngine::drawPixmap(r, pm, sr); - } - } -} - -void QS60PaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr) -{ - if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { - QS60PixmapData *srcData = static_cast(pm.pixmapData()); - srcData->beginDataAccess(); - QRasterPaintEngine::drawTiledPixmap(r, pm, sr); - srcData->endDataAccess(); - } else { - QRasterPaintEngine::drawTiledPixmap(r, pm, sr); - } -} - -void QS60PaintEngine::prepare(QImage *image) -{ - QRasterBuffer *buffer = d_func()->rasterBuffer.data(); - if (buffer) - buffer->prepare(image); -} - -QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintengine_s60_p.h b/src/gui/painting/qpaintengine_s60_p.h deleted file mode 100644 index 5535c24ce6..0000000000 --- a/src/gui/painting/qpaintengine_s60_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPAINTENGINE_S60_P_H -#define QPAINTENGINE_S60_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 "private/qpaintengine_raster_p.h" - -QT_BEGIN_NAMESPACE - -class QS60PaintEnginePrivate; -class QS60PixmapData; - -class QS60PaintEngine : public QRasterPaintEngine -{ - Q_DECLARE_PRIVATE(QS60PaintEngine) - -public: - QS60PaintEngine(QPaintDevice *device, QS60PixmapData *data = 0); - bool begin(QPaintDevice *device); - bool end(); - - void drawPixmap(const QPointF &p, const QPixmap &pm); - void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); - void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr); - - void prepare(QImage* image); - -private: - QS60PixmapData *pixmapData; -}; - -QT_END_NAMESPACE - -#endif // QPAINTENGINE_S60_P_H diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index 5b280adeba..116962f5dc 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -91,7 +91,7 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget) CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); // CBase derived object needs check on new qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) ); - QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType); + QSymbianRasterPixmapData *data = new QSymbianRasterPixmapData(QPixmapData::PixmapType); if (data) { data->fromSymbianBitmap(bitmap, true); d_ptr->device = QPixmap(data); @@ -132,7 +132,7 @@ void QS60WindowSurface::beginPaint(const QRegion &rgn) QWidgetPrivate *windowPrivate = qt_widget_private(window()); if (!windowPrivate->isOpaque || blitWriteAlpha(windowPrivate)) { - QS60PixmapData *pixmapData = static_cast(d_ptr->device.data_ptr().data()); + QSymbianRasterPixmapData *pixmapData = static_cast(d_ptr->device.data_ptr().data()); TDisplayMode mode = displayMode(false); if (pixmapData->cfbsBitmap->DisplayMode() != mode) @@ -170,7 +170,7 @@ QImage* QS60WindowSurface::buffer(const QWidget *widget) return 0; const QPoint off = offset(widget); - QImage *img = &(static_cast(d_ptr->device.data_ptr().data())->image); + QImage *img = &(static_cast(d_ptr->device.data_ptr().data())->image); QRect rect(off, widget->size()); rect &= QRect(QPoint(), img->size()); @@ -218,7 +218,7 @@ bool QS60WindowSurface::scroll(const QRegion &area, int dx, int dy) if (d_ptr->device.isNull()) return false; - QS60PixmapData *data = static_cast(d_ptr->device.data_ptr().data()); + QSymbianRasterPixmapData *data = static_cast(d_ptr->device.data_ptr().data()); data->scroll(dx, dy, rect); return true; @@ -234,7 +234,7 @@ void QS60WindowSurface::setGeometry(const QRect& rect) if (rect == geometry()) return; - QS60PixmapData *data = static_cast(d_ptr->device.data_ptr().data()); + QSymbianRasterPixmapData *data = static_cast(d_ptr->device.data_ptr().data()); data->resize(rect.width(), rect.height()); QWindowSurface::setGeometry(rect); @@ -242,7 +242,7 @@ void QS60WindowSurface::setGeometry(const QRect& rect) CFbsBitmap* QS60WindowSurface::symbianBitmap() const { - QS60PixmapData *data = static_cast(d_ptr->device.data_ptr().data()); + QSymbianRasterPixmapData *data = static_cast(d_ptr->device.data_ptr().data()); return data->cfbsBitmap; } diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 4018702b1b..5699dbb88e 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -45,7 +45,7 @@ #include "qstyleoption.h" #include "qstyle.h" #include "private/qt_s60_p.h" -#include "private/qpixmap_s60_p.h" +#include "private/qpixmap_raster_symbian_p.h" #include "private/qcore_symbian_p.h" #include "private/qvolatileimage_p.h" #include "qapplication.h" diff --git a/src/gui/text/qfont_s60.cpp b/src/gui/text/qfont_s60.cpp index 8d0ed75f9d..a7a2547a8a 100644 --- a/src/gui/text/qfont_s60.cpp +++ b/src/gui/text/qfont_s60.cpp @@ -42,7 +42,7 @@ #include "qfont.h" #include "qfont_p.h" #include -#include +#include #include "qmutex.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 3514fd334b..6ede1f1553 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -47,7 +47,7 @@ #include "qdesktopservices.h" #include "qtemporaryfile.h" #include "qtextcodec.h" -#include +#include #include #include "qendian.h" #include diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 8c60709836..6b93efa589 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -46,7 +46,7 @@ #include #include "qimage.h" #include -#include +#include #include #include diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp index 20c21700e2..21671a6716 100644 --- a/src/opengl/qgl_symbian.cpp +++ b/src/opengl/qgl_symbian.cpp @@ -39,11 +39,10 @@ ** ****************************************************************************/ - #include "qgl.h" #include #include -#include +#include #include #include #include -- cgit v1.2.3