summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-05-04 14:37:50 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-05-04 14:39:19 +0200
commitbd8d12b7f68ea8aa05a86cc9ed65dd660a6b075d (patch)
treea2da73cfac60aa2b86fee223b5c28d813dcc69cd /src/gui/image
parentdc0f9f02a5c390f4a7919db4c32d22cebaf71d1c (diff)
move platform specific files out of the way
Keep the files as reference to implement the lighthouse plugins, but move them away from the main directory hierachy as they won't be part of Qt5 in any case.
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qpixmap_mac.cpp1195
-rw-r--r--src/gui/image/qpixmap_mac_p.h134
-rw-r--r--src/gui/image/qpixmap_s60.cpp1040
-rw-r--r--src/gui/image/qpixmap_s60_p.h141
-rw-r--r--src/gui/image/qpixmap_win.cpp477
-rw-r--r--src/gui/image/qpixmap_x11.cpp2419
-rw-r--r--src/gui/image/qpixmap_x11_p.h156
7 files changed, 0 insertions, 5562 deletions
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
deleted file mode 100644
index 72e2aa6e04..0000000000
--- a/src/gui/image/qpixmap_mac.cpp
+++ /dev/null
@@ -1,1195 +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$
-** 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 "qpixmap.h"
-#include "qimage.h"
-#include "qapplication.h"
-#include "qbitmap.h"
-#include "qmatrix.h"
-#include "qtransform.h"
-#include "qlibrary.h"
-#include "qvarlengtharray.h"
-#include "qdebug.h"
-#include <private/qdrawhelper_p.h>
-#include <private/qpixmap_mac_p.h>
-#include <private/qpixmap_raster_p.h>
-#include <private/qpaintengine_mac_p.h>
-#include <private/qt_mac_p.h>
-#include <private/qt_cocoa_helpers_mac_p.h>
-
-#include <limits.h>
-#include <string.h>
-
-QT_BEGIN_NAMESPACE
-
-/*****************************************************************************
- Externals
- *****************************************************************************/
-extern const uchar *qt_get_bitflip_array(); //qimage.cpp
-extern CGContextRef qt_mac_cg_context(const QPaintDevice *pdev); //qpaintdevice_mac.cpp
-extern RgnHandle qt_mac_get_rgn(); //qregion_mac.cpp
-extern void qt_mac_dispose_rgn(RgnHandle r); //qregion_mac.cpp
-extern QRegion qt_mac_convert_mac_region(RgnHandle rgn); //qregion_mac.cpp
-
-static int qt_pixmap_serial = 0;
-
-Q_GUI_EXPORT quint32 *qt_mac_pixmap_get_base(const QPixmap *pix)
-{
- return static_cast<QMacPixmapData*>(pix->data.data())->pixels;
-}
-
-Q_GUI_EXPORT int qt_mac_pixmap_get_bytes_per_line(const QPixmap *pix)
-{
- return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow;
-}
-
-void qt_mac_cgimage_data_free(void *info, const void *memoryToFree, size_t)
-{
- QMacPixmapData *pmdata = static_cast<QMacPixmapData *>(info);
- if (!pmdata) {
- free(const_cast<void *>(memoryToFree));
- } else {
- if (QMacPixmapData::validDataPointers.contains(pmdata) == false) {
- free(const_cast<void *>(memoryToFree));
- return;
- }
- if (pmdata->pixels == pmdata->pixelsToFree) {
- // something we aren't expecting, just free it.
- Q_ASSERT(memoryToFree != pmdata->pixelsToFree);
- free(const_cast<void *>(memoryToFree));
- } else {
- free(pmdata->pixelsToFree);
- pmdata->pixelsToFree = static_cast<quint32 *>(const_cast<void *>(memoryToFree));
- }
- pmdata->cg_dataBeingReleased = 0;
- }
-}
-
-CGImageRef qt_mac_image_to_cgimage(const QImage &image)
-{
- int bitsPerColor = 8;
- int bitsPerPixel = 32;
- if (image.depth() == 1) {
- bitsPerColor = 1;
- bitsPerPixel = 1;
- }
- QCFType<CGDataProviderRef> provider =
- CGDataProviderCreateWithData(0, image.bits(), image.bytesPerLine() * image.height(),
- 0);
-
- uint cgflags = kCGImageAlphaPremultipliedFirst;
-#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
- cgflags |= kCGBitmapByteOrder32Host;
-#endif
-
- CGImageRef cgImage = CGImageCreate(image.width(), image.height(), bitsPerColor, bitsPerPixel,
- image.bytesPerLine(),
- QCoreGraphicsPaintEngine::macGenericColorSpace(),
- cgflags, provider,
- 0,
- 0,
- kCGRenderingIntentDefault);
-
- return cgImage;
-}
-
-/*****************************************************************************
- QPixmap member functions
- *****************************************************************************/
-
-static inline QRgb qt_conv16ToRgb(ushort c) {
- static const int qt_rbits = (565/100);
- static const int qt_gbits = (565/10%10);
- static const int qt_bbits = (565%10);
- static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
- static const int qt_green_shift = qt_bbits-(8-qt_gbits);
- static const int qt_neg_blue_shift = 8-qt_bbits;
- static const int qt_blue_mask = (1<<qt_bbits)-1;
- static const int qt_green_mask = (1<<(qt_gbits+qt_bbits))-((1<<qt_bbits)-1);
- static const int qt_red_mask = (1<<(qt_rbits+qt_gbits+qt_bbits))-(1<<(qt_gbits+qt_bbits));
-
- const int r=(c & qt_red_mask);
- const int g=(c & qt_green_mask);
- const int b=(c & qt_blue_mask);
- const int tr = r >> qt_red_shift;
- const int tg = g >> qt_green_shift;
- const int tb = b << qt_neg_blue_shift;
-
- return qRgb(tr,tg,tb);
-}
-
-QSet<QMacPixmapData*> QMacPixmapData::validDataPointers;
-
-QMacPixmapData::QMacPixmapData(PixelType type)
- : QPixmapData(type, MacClass), has_alpha(0), has_mask(0),
- uninit(true), pixels(0), pixelsSize(0), pixelsToFree(0),
- bytesPerRow(0), cg_data(0), cg_dataBeingReleased(0), cg_mask(0),
- pengine(0)
-{
-}
-
-QPixmapData *QMacPixmapData::createCompatiblePixmapData() const
-{
- return new QMacPixmapData(pixelType());
-}
-
-#define BEST_BYTE_ALIGNMENT 16
-#define COMPTUE_BEST_BYTES_PER_ROW(bpr) \
- (((bpr) + (BEST_BYTE_ALIGNMENT - 1)) & ~(BEST_BYTE_ALIGNMENT - 1))
-
-void QMacPixmapData::resize(int width, int height)
-{
- setSerialNumber(++qt_pixmap_serial);
-
- w = width;
- h = height;
- is_null = (w <= 0 || h <= 0);
- d = (pixelType() == BitmapType ? 1 : 32);
- bool make_null = w <= 0 || h <= 0; // create null pixmap
- if (make_null || d == 0) {
- w = 0;
- h = 0;
- is_null = true;
- d = 0;
- if (!make_null)
- qWarning("Qt: QPixmap: Invalid pixmap parameters");
- return;
- }
-
- if (w < 1 || h < 1)
- return;
-
- //create the pixels
- bytesPerRow = w * sizeof(quint32); // Minimum bytes per row.
-
- // Quartz2D likes things as a multple of 16 (for now).
- bytesPerRow = COMPTUE_BEST_BYTES_PER_ROW(bytesPerRow);
- macCreatePixels();
-}
-
-#undef COMPUTE_BEST_BYTES_PER_ROW
-
-void QMacPixmapData::fromImage(const QImage &img,
- Qt::ImageConversionFlags flags)
-{
- setSerialNumber(++qt_pixmap_serial);
-
- // the conversion code only handles format >=
- // Format_ARGB32_Premultiplied at the moment..
- if (img.format() > QImage::Format_ARGB32_Premultiplied) {
- QImage image;
- if (img.hasAlphaChannel())
- image = img.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- else
- image = img.convertToFormat(QImage::Format_RGB32);
- fromImage(image, flags);
- return;
- }
-
- w = img.width();
- h = img.height();
- is_null = (w <= 0 || h <= 0);
- d = (pixelType() == BitmapType ? 1 : img.depth());
-
- QImage image = img;
- int dd = QPixmap::defaultDepth();
- bool force_mono = (dd == 1 ||
- (flags & Qt::ColorMode_Mask)==Qt::MonoOnly);
- if (force_mono) { // must be monochrome
- if (d != 1) {
- image = image.convertToFormat(QImage::Format_MonoLSB, flags); // dither
- d = 1;
- }
- } else { // can be both
- bool conv8 = false;
- if(d > 8 && dd <= 8) { // convert to 8 bit
- if ((flags & Qt::DitherMode_Mask) == Qt::AutoDither)
- flags = (flags & ~Qt::DitherMode_Mask)
- | Qt::PreferDither;
- conv8 = true;
- } else if ((flags & Qt::ColorMode_Mask) == Qt::ColorOnly) {
- conv8 = d == 1; // native depth wanted
- } else if (d == 1) {
- if (image.colorCount() == 2) {
- QRgb c0 = image.color(0); // Auto: convert to best
- QRgb c1 = image.color(1);
- conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255);
- } else {
- // eg. 1-color monochrome images (they do exist).
- conv8 = true;
- }
- }
- if (conv8) {
- image = image.convertToFormat(QImage::Format_Indexed8, flags);
- d = 8;
- }
- }
-
- if (image.depth()==1) {
- image.setColor(0, QColor(Qt::color0).rgba());
- image.setColor(1, QColor(Qt::color1).rgba());
- }
-
- if (d == 16 || d == 24) {
- image = image.convertToFormat(QImage::Format_RGB32, flags);
- fromImage(image, flags);
- return;
- }
-
- // different size or depth, make a new pixmap
- resize(w, h);
-
- quint32 *dptr = pixels, *drow;
- const uint dbpr = bytesPerRow;
-
- const QImage::Format sfmt = image.format();
- const unsigned short sbpr = image.bytesPerLine();
-
- // use const_cast to prevent a detach
- const uchar *sptr = const_cast<const QImage &>(image).bits(), *srow;
-
- for (int y = 0; y < h; ++y) {
- drow = dptr + (y * (dbpr / 4));
- srow = sptr + (y * sbpr);
- switch(sfmt) {
- case QImage::Format_MonoLSB:
- case QImage::Format_Mono:{
- for (int x = 0; x < w; ++x) {
- char one_bit = *(srow + (x / 8));
- if (sfmt == QImage::Format_Mono)
- one_bit = one_bit >> (7 - (x % 8));
- else
- one_bit = one_bit >> (x % 8);
- if ((one_bit & 0x01))
- *(drow+x) = 0xFF000000;
- else
- *(drow+x) = 0xFFFFFFFF;
- }
- break;
- }
- case QImage::Format_Indexed8: {
- int numColors = image.numColors();
- if (numColors > 0) {
- for (int x = 0; x < w; ++x) {
- int index = *(srow + x);
- *(drow+x) = PREMUL(image.color(qMin(index, numColors)));
- }
- }
- } break;
- case QImage::Format_RGB32:
- for (int x = 0; x < w; ++x)
- *(drow+x) = *(((quint32*)srow) + x) | 0xFF000000;
- break;
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- for (int x = 0; x < w; ++x) {
- if(sfmt == QImage::Format_RGB32)
- *(drow+x) = 0xFF000000 | (*(((quint32*)srow) + x) & 0x00FFFFFF);
- else if(sfmt == QImage::Format_ARGB32_Premultiplied)
- *(drow+x) = *(((quint32*)srow) + x);
- else
- *(drow+x) = PREMUL(*(((quint32*)srow) + x));
- }
- break;
- default:
- qWarning("Qt: internal: Oops: Forgot a format [%d] %s:%d", sfmt,
- __FILE__, __LINE__);
- break;
- }
- }
- if (sfmt != QImage::Format_RGB32) { //setup the alpha
- bool alphamap = image.depth() == 32;
- if (sfmt == QImage::Format_Indexed8) {
- const QVector<QRgb> rgb = image.colorTable();
- for (int i = 0, count = image.colorCount(); i < count; ++i) {
- const int alpha = qAlpha(rgb[i]);
- if (alpha != 0xff) {
- alphamap = true;
- break;
- }
- }
- }
- macSetHasAlpha(alphamap);
- }
- uninit = false;
-}
-
-int get_index(QImage * qi,QRgb mycol)
-{
- int loopc;
- for(loopc=0;loopc<qi->colorCount();loopc++) {
- if(qi->color(loopc)==mycol)
- return loopc;
- }
- qi->setColorCount(qi->colorCount()+1);
- qi->setColor(qi->colorCount(),mycol);
- return qi->colorCount();
-}
-
-QImage QMacPixmapData::toImage() const
-{
- QImage::Format format = QImage::Format_MonoLSB;
- if (d != 1) //Doesn't support index color modes
- format = (has_alpha ? QImage::Format_ARGB32_Premultiplied :
- QImage::Format_RGB32);
-
- QImage image(w, h, format);
- quint32 *sptr = pixels, *srow;
- const uint sbpr = bytesPerRow;
- if (format == QImage::Format_MonoLSB) {
- image.fill(0);
- image.setColorCount(2);
- image.setColor(0, QColor(Qt::color0).rgba());
- image.setColor(1, QColor(Qt::color1).rgba());
- for (int y = 0; y < h; ++y) {
- uchar *scanLine = image.scanLine(y);
- srow = sptr + (y * (sbpr/4));
- for (int x = 0; x < w; ++x) {
- if (!(*(srow + x) & RGB_MASK))
- scanLine[x >> 3] |= (1 << (x & 7));
- }
- }
- } else {
- for (int y = 0; y < h; ++y) {
- srow = sptr + (y * (sbpr / 4));
- memcpy(image.scanLine(y), srow, w * 4);
- }
-
- }
-
- return image;
-}
-
-void QMacPixmapData::fill(const QColor &fillColor)
-
-{
- { //we don't know what backend to use so we cannot paint here
- quint32 *dptr = pixels;
- Q_ASSERT_X(dptr, "QPixmap::fill", "No dptr");
- const quint32 colr = PREMUL(fillColor.rgba());
- const int nbytes = bytesPerRow * h;
- if (!colr) {
- memset(dptr, 0, nbytes);
- } else {
- for (uint i = 0; i < nbytes / sizeof(quint32); ++i)
- *(dptr + i) = colr;
- }
- }
-
- // If we had an alpha channel from before, don't
- // switch it off. Only go from no alpha to alpha:
- if (fillColor.alpha() != 255)
- macSetHasAlpha(true);
-}
-
-QPixmap QMacPixmapData::alphaChannel() const
-{
- if (!has_alpha)
- return QPixmap();
-
- QMacPixmapData *alpha = new QMacPixmapData(PixmapType);
- alpha->resize(w, h);
- macGetAlphaChannel(alpha, false);
- return QPixmap(alpha);
-}
-
-void QMacPixmapData::setAlphaChannel(const QPixmap &alpha)
-{
- has_mask = true;
- QMacPixmapData *alphaData = static_cast<QMacPixmapData*>(alpha.data.data());
- macSetAlphaChannel(alphaData, false);
-}
-
-QBitmap QMacPixmapData::mask() const
-{
- if (!has_mask && !has_alpha)
- return QBitmap();
-
- QMacPixmapData *mask = new QMacPixmapData(BitmapType);
- mask->resize(w, h);
- macGetAlphaChannel(mask, true);
- return QPixmap(mask);
-}
-
-void QMacPixmapData::setMask(const QBitmap &mask)
-{
- if (mask.isNull()) {
- QMacPixmapData opaque(PixmapType);
- opaque.resize(w, h);
- opaque.fill(QColor(255, 255, 255, 255));
- macSetAlphaChannel(&opaque, true);
- has_alpha = has_mask = false;
- return;
- }
-
- has_alpha = false;
- has_mask = true;
- QMacPixmapData *maskData = static_cast<QMacPixmapData*>(mask.data.data());
- macSetAlphaChannel(maskData, true);
-}
-
-int QMacPixmapData::metric(QPaintDevice::PaintDeviceMetric theMetric) const
-{
- switch (theMetric) {
- case QPaintDevice::PdmWidth:
- return w;
- case QPaintDevice::PdmHeight:
- return h;
- case QPaintDevice::PdmWidthMM:
- return qRound(metric(QPaintDevice::PdmWidth) * 25.4 / qreal(metric(QPaintDevice::PdmDpiX)));
- case QPaintDevice::PdmHeightMM:
- return qRound(metric(QPaintDevice::PdmHeight) * 25.4 / qreal(metric(QPaintDevice::PdmDpiY)));
- case QPaintDevice::PdmNumColors:
- return 1 << d;
- case QPaintDevice::PdmDpiX:
- case QPaintDevice::PdmPhysicalDpiX: {
- extern float qt_mac_defaultDpi_x(); //qpaintdevice_mac.cpp
- return int(qt_mac_defaultDpi_x());
- }
- case QPaintDevice::PdmDpiY:
- case QPaintDevice::PdmPhysicalDpiY: {
- extern float qt_mac_defaultDpi_y(); //qpaintdevice_mac.cpp
- return int(qt_mac_defaultDpi_y());
- }
- case QPaintDevice::PdmDepth:
- return d;
- default:
- qWarning("QPixmap::metric: Invalid metric command");
- }
- return 0;
-}
-
-QMacPixmapData::~QMacPixmapData()
-{
- validDataPointers.remove(this);
- if (cg_mask) {
- CGImageRelease(cg_mask);
- cg_mask = 0;
- }
-
- delete pengine; // Make sure we aren't drawing on the context anymore.
- if (cg_data) {
- CGImageRelease(cg_data);
- } else if (!cg_dataBeingReleased && pixels != pixelsToFree) {
- free(pixels);
- }
- free(pixelsToFree);
-}
-
-void QMacPixmapData::macSetAlphaChannel(const QMacPixmapData *pix, bool asMask)
-{
- if (!pixels || !h || !w || pix->w != w || pix->h != h)
- return;
-
- quint32 *dptr = pixels, *drow;
- const uint dbpr = bytesPerRow;
- const unsigned short sbpr = pix->bytesPerRow;
- quint32 *sptr = pix->pixels, *srow;
- for (int y=0; y < h; ++y) {
- drow = dptr + (y * (dbpr/4));
- srow = sptr + (y * (sbpr/4));
- if(d == 1) {
- for (int x=0; x < w; ++x) {
- if((*(srow+x) & RGB_MASK))
- *(drow+x) = 0xFFFFFFFF;
- }
- } else if(d == 8) {
- for (int x=0; x < w; ++x)
- *(drow+x) = (*(drow+x) & RGB_MASK) | (*(srow+x) << 24);
- } else if(asMask) {
- for (int x=0; x < w; ++x) {
- if(*(srow+x) & RGB_MASK)
- *(drow+x) = (*(drow+x) & RGB_MASK);
- else
- *(drow+x) = (*(drow+x) & RGB_MASK) | 0xFF000000;
- *(drow+x) = PREMUL(*(drow+x));
- }
- } else {
- for (int x=0; x < w; ++x) {
- const uchar alpha = qGray(qRed(*(srow+x)), qGreen(*(srow+x)), qBlue(*(srow+x)));
- const uchar destAlpha = qt_div_255(alpha * qAlpha(*(drow+x)));
-#if 1
- *(drow+x) = (*(drow+x) & RGB_MASK) | (destAlpha << 24);
-#else
- *(drow+x) = qRgba(qt_div_255(qRed(*(drow+x) * alpha)),
- qt_div_255(qGreen(*(drow+x) * alpha)),
- qt_div_255(qBlue(*(drow+x) * alpha)), destAlpha);
-#endif
- *(drow+x) = PREMUL(*(drow+x));
- }
- }
- }
- macSetHasAlpha(true);
-}
-
-void QMacPixmapData::macGetAlphaChannel(QMacPixmapData *pix, bool asMask) const
-{
- quint32 *dptr = pix->pixels, *drow;
- const uint dbpr = pix->bytesPerRow;
- const unsigned short sbpr = bytesPerRow;
- quint32 *sptr = pixels, *srow;
- for(int y=0; y < h; ++y) {
- drow = dptr + (y * (dbpr/4));
- srow = sptr + (y * (sbpr/4));
- if(asMask) {
- for (int x = 0; x < w; ++x) {
- if (*(srow + x) & qRgba(0, 0, 0, 255))
- *(drow + x) = 0x00000000;
- else
- *(drow + x) = 0xFFFFFFFF;
- }
- } else {
- for (int x = 0; x < w; ++x) {
- const int alpha = qAlpha(*(srow + x));
- *(drow + x) = qRgb(alpha, alpha, alpha);
- }
- }
- }
-}
-
-void QMacPixmapData::macSetHasAlpha(bool b)
-{
- has_alpha = b;
- macReleaseCGImageRef();
-}
-
-void QMacPixmapData::macCreateCGImageRef()
-{
- Q_ASSERT(cg_data == 0);
- //create the cg data
- CGColorSpaceRef colorspace = QCoreGraphicsPaintEngine::macDisplayColorSpace();
- QCFType<CGDataProviderRef> provider = CGDataProviderCreateWithData(this,
- pixels, bytesPerRow * h,
- qt_mac_cgimage_data_free);
- validDataPointers.insert(this);
- uint cgflags = kCGImageAlphaPremultipliedFirst;
-#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
- cgflags |= kCGBitmapByteOrder32Host;
-#endif
- cg_data = CGImageCreate(w, h, 8, 32, bytesPerRow, colorspace,
- cgflags, provider, 0, 0, kCGRenderingIntentDefault);
-}
-
-void QMacPixmapData::macReleaseCGImageRef()
-{
- if (!cg_data)
- return; // There's nothing we need to do
-
- cg_dataBeingReleased = cg_data;
- CGImageRelease(cg_data);
- cg_data = 0;
-
- if (pixels != pixelsToFree) {
- macCreatePixels();
- } else {
- pixelsToFree = 0;
- }
-}
-
-
-// We create our space in memory to paint on here. If we already have existing pixels
-// copy them over. This is to preserve the fact that CGImageRef's are immutable.
-void QMacPixmapData::macCreatePixels()
-{
- const int numBytes = bytesPerRow * h;
- quint32 *base_pixels;
- if (pixelsToFree && pixelsToFree != pixels) {
- // Reuse unused block of memory lying around from a previous callback.
- base_pixels = pixelsToFree;
- pixelsToFree = 0;
- } else {
- // We need a block of memory to do stuff with.
- base_pixels = static_cast<quint32 *>(malloc(numBytes));
- }
-
- if (pixels)
- memcpy(base_pixels, pixels, pixelsSize);
- pixels = base_pixels;
- pixelsSize = numBytes;
-}
-
-#if 0
-QPixmap QMacPixmapData::transformed(const QTransform &transform,
- Qt::TransformationMode mode) const
-{
- int w, h; // size of target pixmap
- const int ws = width();
- const int hs = height();
-
- QTransform mat(transform.m11(), transform.m12(),
- transform.m21(), transform.m22(), 0., 0.);
- if (transform.m12() == 0.0F && transform.m21() == 0.0F &&
- transform.m11() >= 0.0F && transform.m22() >= 0.0F)
- {
- h = int(qAbs(mat.m22()) * hs + 0.9999);
- w = int(qAbs(mat.m11()) * ws + 0.9999);
- h = qAbs(h);
- w = qAbs(w);
- } else { // rotation or shearing
- QPolygonF a(QRectF(0,0,ws+1,hs+1));
- a = mat.map(a);
- QRectF r = a.boundingRect().normalized();
- w = int(r.width() + 0.9999);
- h = int(r.height() + 0.9999);
- }
- mat = QPixmap::trueMatrix(mat, ws, hs);
- if (!h || !w)
- return QPixmap();
-
- // create destination
- QMacPixmapData *pm = new QMacPixmapData(pixelType(), w, h);
- const quint32 *sptr = pixels;
- quint32 *dptr = pm->pixels;
- memset(dptr, 0, (pm->bytesPerRow * pm->h));
-
- // do the transform
- if (mode == Qt::SmoothTransformation) {
-#warning QMacPixmapData::transformed not properly implemented
- qWarning("QMacPixmapData::transformed not properly implemented");
-#if 0
- QPainter p(&pm);
- p.setRenderHint(QPainter::Antialiasing);
- p.setRenderHint(QPainter::SmoothPixmapTransform);
- p.setTransform(mat);
- p.drawPixmap(0, 0, *this);
-#endif
- } else {
- bool invertible;
- mat = mat.inverted(&invertible);
- if (!invertible)
- return QPixmap();
-
- const int bpp = 32;
- const int xbpl = (w * bpp) / 8;
- if (!qt_xForm_helper(mat, 0, QT_XFORM_TYPE_MSBFIRST, bpp,
- (uchar*)dptr, xbpl, (pm->bytesPerRow) - xbpl,
- h, (uchar*)sptr, (bytesPerRow), ws, hs)) {
- qWarning("QMacPixmapData::transform(): failure");
- return QPixmap();
- }
- }
-
- // update the alpha
- pm->macSetHasAlpha(true);
- return QPixmap(pm);
-}
-#endif
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <OpenGL/OpenGL.h>
-#include <OpenGL/gl.h>
-QT_END_INCLUDE_NAMESPACE
-
-// Load and resolve the symbols we need from OpenGL manually so QtGui doesn't have to link against the OpenGL framework.
-typedef CGLError (*PtrCGLChoosePixelFormat)(const CGLPixelFormatAttribute *, CGLPixelFormatObj *, long *);
-typedef CGLError (*PtrCGLClearDrawable)(CGLContextObj);
-typedef CGLError (*PtrCGLCreateContext)(CGLPixelFormatObj, CGLContextObj, CGLContextObj *);
-typedef CGLError (*PtrCGLDestroyContext)(CGLContextObj);
-typedef CGLError (*PtrCGLDestroyPixelFormat)(CGLPixelFormatObj);
-typedef CGLError (*PtrCGLSetCurrentContext)(CGLContextObj);
-typedef CGLError (*PtrCGLSetFullScreen)(CGLContextObj);
-typedef void (*PtrglFinish)();
-typedef void (*PtrglPixelStorei)(GLenum, GLint);
-typedef void (*PtrglReadBuffer)(GLenum);
-typedef void (*PtrglReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);
-
-static PtrCGLChoosePixelFormat ptrCGLChoosePixelFormat = 0;
-static PtrCGLClearDrawable ptrCGLClearDrawable = 0;
-static PtrCGLCreateContext ptrCGLCreateContext = 0;
-static PtrCGLDestroyContext ptrCGLDestroyContext = 0;
-static PtrCGLDestroyPixelFormat ptrCGLDestroyPixelFormat = 0;
-static PtrCGLSetCurrentContext ptrCGLSetCurrentContext = 0;
-static PtrCGLSetFullScreen ptrCGLSetFullScreen = 0;
-static PtrglFinish ptrglFinish = 0;
-static PtrglPixelStorei ptrglPixelStorei = 0;
-static PtrglReadBuffer ptrglReadBuffer = 0;
-static PtrglReadPixels ptrglReadPixels = 0;
-
-static bool resolveOpenGLSymbols()
-{
- if (ptrCGLChoosePixelFormat == 0) {
- QLibrary library(QLatin1String("/System/Library/Frameworks/OpenGL.framework/OpenGL"));
- ptrCGLChoosePixelFormat = (PtrCGLChoosePixelFormat)(library.resolve("CGLChoosePixelFormat"));
- ptrCGLClearDrawable = (PtrCGLClearDrawable)(library.resolve("CGLClearDrawable"));
- ptrCGLCreateContext = (PtrCGLCreateContext)(library.resolve("CGLCreateContext"));
- ptrCGLDestroyContext = (PtrCGLDestroyContext)(library.resolve("CGLDestroyContext"));
- ptrCGLDestroyPixelFormat = (PtrCGLDestroyPixelFormat)(library.resolve("CGLDestroyPixelFormat"));
- ptrCGLSetCurrentContext = (PtrCGLSetCurrentContext)(library.resolve("CGLSetCurrentContext"));
- ptrCGLSetFullScreen = (PtrCGLSetFullScreen)(library.resolve("CGLSetFullScreen"));
- ptrglFinish = (PtrglFinish)(library.resolve("glFinish"));
- ptrglPixelStorei = (PtrglPixelStorei)(library.resolve("glPixelStorei"));
- ptrglReadBuffer = (PtrglReadBuffer)(library.resolve("glReadBuffer"));
- ptrglReadPixels = (PtrglReadPixels)(library.resolve("glReadPixels"));
- }
- return ptrCGLChoosePixelFormat && ptrCGLClearDrawable && ptrCGLCreateContext
- && ptrCGLDestroyContext && ptrCGLDestroyPixelFormat && ptrCGLSetCurrentContext
- && ptrCGLSetFullScreen && ptrglFinish && ptrglPixelStorei
- && ptrglReadBuffer && ptrglReadPixels;
-}
-
-// Inverts the given pixmap in the y direction.
-static void qt_mac_flipPixmap(void *data, int rowBytes, int height)
-{
- int bottom = height - 1;
- void *base = data;
- void *buffer = malloc(rowBytes);
-
- int top = 0;
- while ( top < bottom )
- {
- void *topP = (void *)((top * rowBytes) + (intptr_t)base);
- void *bottomP = (void *)((bottom * rowBytes) + (intptr_t)base);
-
- bcopy( topP, buffer, rowBytes );
- bcopy( bottomP, topP, rowBytes );
- bcopy( buffer, bottomP, rowBytes );
-
- ++top;
- --bottom;
- }
- free(buffer);
-}
-
-// Grabs displayRect from display and places it into buffer.
-static void qt_mac_grabDisplayRect(CGDirectDisplayID display, const QRect &displayRect, void *buffer)
-{
- if (display == kCGNullDirectDisplay)
- return;
-
- CGLPixelFormatAttribute attribs[] = {
- kCGLPFAFullScreen,
- kCGLPFADisplayMask,
- (CGLPixelFormatAttribute)0, /* Display mask bit goes here */
- (CGLPixelFormatAttribute)0
- };
-
- attribs[2] = (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display);
-
- // Build a full-screen GL context
- CGLPixelFormatObj pixelFormatObj;
- long numPixelFormats;
-
- ptrCGLChoosePixelFormat( attribs, &pixelFormatObj, &numPixelFormats );
-
- if (!pixelFormatObj) // No full screen context support
- return;
-
- CGLContextObj glContextObj;
- ptrCGLCreateContext(pixelFormatObj, 0, &glContextObj);
- ptrCGLDestroyPixelFormat(pixelFormatObj) ;
- if (!glContextObj)
- return;
-
- ptrCGLSetCurrentContext(glContextObj);
- ptrCGLSetFullScreen(glContextObj) ;
-
- ptrglReadBuffer(GL_FRONT);
-
- ptrglFinish(); // Finish all OpenGL commands
- ptrglPixelStorei(GL_PACK_ALIGNMENT, 4); // Force 4-byte alignment
- ptrglPixelStorei(GL_PACK_ROW_LENGTH, 0);
- ptrglPixelStorei(GL_PACK_SKIP_ROWS, 0);
- ptrglPixelStorei(GL_PACK_SKIP_PIXELS, 0);
-
- // Fetch the data in XRGB format, matching the bitmap context.
- ptrglReadPixels(GLint(displayRect.x()), GLint(displayRect.y()),
- GLint(displayRect.width()), GLint(displayRect.height()),
-#ifdef __BIG_ENDIAN__
- GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer
-#else
- GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, buffer
-#endif
- );
-
- ptrCGLSetCurrentContext(0);
- ptrCGLClearDrawable(glContextObj); // disassociate from full screen
- ptrCGLDestroyContext(glContextObj); // and destroy the context
-}
-
-// Returns a pixmap containing the screen contents at rect.
-static QPixmap qt_mac_grabScreenRect(const QRect &rect)
-{
- if (!resolveOpenGLSymbols())
- return QPixmap();
-
- const int maxDisplays = 128; // 128 displays should be enough for everyone.
- CGDirectDisplayID displays[maxDisplays];
- CGDisplayCount displayCount;
- const CGRect cgRect = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
- const CGDisplayErr err = CGGetDisplaysWithRect(cgRect, maxDisplays, displays, &displayCount);
-
- if (err && displayCount == 0)
- return QPixmap();
-
- long bytewidth = rect.width() * 4; // Assume 4 bytes/pixel for now
- bytewidth = (bytewidth + 3) & ~3; // Align to 4 bytes
- QVarLengthArray<char> buffer(rect.height() * bytewidth);
-
- for (uint i = 0; i < displayCount; ++i) {
- const CGRect bounds = CGDisplayBounds(displays[i]);
- // Translate to display-local coordinates
- QRect displayRect = rect.translated(qRound(-bounds.origin.x), qRound(-bounds.origin.y));
- // Adjust for inverted y axis.
- displayRect.moveTop(qRound(bounds.size.height) - displayRect.y() - rect.height());
- qt_mac_grabDisplayRect(displays[i], displayRect, buffer.data());
- }
-
- qt_mac_flipPixmap(buffer.data(), bytewidth, rect.height());
- QCFType<CGContextRef> bitmap = CGBitmapContextCreate(buffer.data(), rect.width(),
- rect.height(), 8, bytewidth,
- QCoreGraphicsPaintEngine::macGenericColorSpace(),
- kCGImageAlphaNoneSkipFirst);
- QCFType<CGImageRef> image = CGBitmapContextCreateImage(bitmap);
- return QPixmap::fromMacCGImageRef(image);
-}
-
-#ifndef QT_MAC_USE_COCOA // no QuickDraw in 64-bit mode
-static QPixmap qt_mac_grabScreenRect_10_3(int x, int y, int w, int h, QWidget *widget)
-{
- QPixmap pm = QPixmap(w, h);
- extern WindowPtr qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
- const BitMap *windowPort = 0;
- if((widget->windowType() == Qt::Desktop)) {
- GDHandle gdh;
- if(!(gdh=GetMainDevice()))
- qDebug("Qt: internal: Unexpected condition reached: %s:%d", __FILE__, __LINE__);
- windowPort = (BitMap*)(*(*gdh)->gdPMap);
- } else {
- windowPort = GetPortBitMapForCopyBits(GetWindowPort(qt_mac_window_for(widget)));
- }
- const BitMap *pixmapPort = GetPortBitMapForCopyBits(static_cast<GWorldPtr>(pm.macQDHandle()));
- Rect macSrcRect, macDstRect;
- SetRect(&macSrcRect, x, y, x + w, y + h);
- SetRect(&macDstRect, 0, 0, w, h);
- CopyBits(windowPort, pixmapPort, &macSrcRect, &macDstRect, srcCopy, 0);
- return pm;
-}
-#endif
-
-QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
-{
- QWidget *widget = QWidget::find(window);
- if (widget == 0)
- return QPixmap();
-
- if(w == -1)
- w = widget->width() - x;
- if(h == -1)
- h = widget->height() - y;
-
- QPoint globalCoord(0, 0);
- globalCoord = widget->mapToGlobal(globalCoord);
- QRect rect(globalCoord.x() + x, globalCoord.y() + y, w, h);
-
-#ifdef QT_MAC_USE_COCOA
- return qt_mac_grabScreenRect(rect);
-#else
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
- return qt_mac_grabScreenRect(rect);
- } else
-#endif
- {
- return qt_mac_grabScreenRect_10_3(x, y, w, h, widget);
- }
-#endif // ifdef Q_WS_MAC64
-}
-
-/*! \internal
-
- Returns the QuickDraw CGrafPtr of the pixmap. 0 is returned if it can't
- be obtained. Do not hold the pointer around for long as it can be
- relocated.
-
- \warning This function is only available on Mac OS X.
- \warning As of Qt 4.6, this function \e{always} returns zero.
-*/
-
-Qt::HANDLE QPixmap::macQDHandle() const
-{
- return 0;
-}
-
-/*! \internal
-
- Returns the QuickDraw CGrafPtr of the pixmap's alpha channel. 0 is
- returned if it can't be obtained. Do not hold the pointer around for
- long as it can be relocated.
-
- \warning This function is only available on Mac OS X.
- \warning As of Qt 4.6, this function \e{always} returns zero.
-*/
-
-Qt::HANDLE QPixmap::macQDAlphaHandle() const
-{
- return 0;
-}
-
-/*! \internal
-
- Returns the CoreGraphics CGContextRef of the pixmap. 0 is returned if
- it can't be obtained. It is the caller's responsiblity to
- CGContextRelease the context when finished using it.
-
- \warning This function is only available on Mac OS X.
-*/
-
-Qt::HANDLE QPixmap::macCGHandle() const
-{
- if (isNull())
- return 0;
-
- if (data->classId() == QPixmapData::MacClass) {
- QMacPixmapData *d = static_cast<QMacPixmapData *>(data.data());
- if (!d->cg_data)
- d->macCreateCGImageRef();
- CGImageRef ret = d->cg_data;
- CGImageRetain(ret);
- return ret;
- } else if (data->classId() == QPixmapData::RasterClass) {
- return qt_mac_image_to_cgimage(static_cast<QRasterPixmapData *>(data.data())->image);
- }
- return 0;
-}
-
-bool QMacPixmapData::hasAlphaChannel() const
-{
- return has_alpha;
-}
-
-CGImageRef qt_mac_create_imagemask(const QPixmap &pixmap, const QRectF &sr)
-{
- QMacPixmapData *px = static_cast<QMacPixmapData*>(pixmap.data.data());
- if (px->cg_mask) {
- if (px->cg_mask_rect == sr) {
- CGImageRetain(px->cg_mask); //reference for the caller
- return px->cg_mask;
- }
- CGImageRelease(px->cg_mask);
- px->cg_mask = 0;
- }
-
- const int sx = qRound(sr.x()), sy = qRound(sr.y()), sw = qRound(sr.width()), sh = qRound(sr.height());
- const int sbpr = px->bytesPerRow;
- const uint nbytes = sw * sh;
- // alpha is always 255 for bitmaps, ignore it in this case.
- const quint32 mask = px->depth() == 1 ? 0x00ffffff : 0xffffffff;
- quint8 *dptr = static_cast<quint8 *>(malloc(nbytes));
- quint32 *sptr = px->pixels, *srow;
- for(int y = sy, offset=0; y < sh; ++y) {
- srow = sptr + (y * (sbpr / 4));
- for(int x = sx; x < sw; ++x)
- *(dptr+(offset++)) = (*(srow+x) & mask) ? 255 : 0;
- }
- QCFType<CGDataProviderRef> provider = CGDataProviderCreateWithData(0, dptr, nbytes, qt_mac_cgimage_data_free);
- px->cg_mask = CGImageMaskCreate(sw, sh, 8, 8, nbytes / sh, provider, 0, 0);
- px->cg_mask_rect = sr;
- CGImageRetain(px->cg_mask); //reference for the caller
- return px->cg_mask;
-}
-
-#ifndef QT_MAC_USE_COCOA
-IconRef qt_mac_create_iconref(const QPixmap &px)
-{
- if (px.isNull())
- return 0;
-
- //create icon
- IconFamilyHandle iconFamily = reinterpret_cast<IconFamilyHandle>(NewHandle(0));
- //create data
- {
- struct {
- OSType mac_type;
- int width, height, depth;
- bool mask;
- } images[] = {
- { kThumbnail32BitData, 128, 128, 32, false },
- { kThumbnail8BitMask, 128, 128, 8, true },
- { 0, 0, 0, 0, false } //end marker
- };
- for(int i = 0; images[i].mac_type; i++) {
- //get QPixmap data
- QImage scaled_px = px.toImage().scaled(images[i].width, images[i].height);
-
- quint32 *sptr = (quint32 *) scaled_px.bits();
- quint32 *srow;
- uint sbpr = scaled_px.bytesPerLine();
-
- //get Handle data
- const int dbpr = images[i].width * (images[i].depth/8);
- Handle hdl = NewHandle(dbpr*images[i].height);
- if(!sptr) { //handle null pixmap
- memset((*hdl), '\0', dbpr*images[i].height);
- } else if(images[i].mask) {
- if(images[i].mac_type == kThumbnail8BitMask) {
- for(int y = 0, hindex = 0; y < images[i].height; ++y) {
- srow = sptr + (y * (sbpr/4));
- for(int x = 0; x < images[i].width; ++x)
- *((*hdl)+(hindex++)) = qAlpha(*(srow+x));
- }
- }
- } else {
- char *dest = (*hdl);
-#if defined(__i386__)
- if(images[i].depth == 32) {
- for(int y = 0; y < images[i].height; ++y) {
- uint *source = (uint*)((const uchar*)sptr+(sbpr*y));
- for(int x = 0; x < images[i].width; ++x, dest += 4)
- *((uint*)dest) = CFSwapInt32(*(source + x));
- }
- } else
-#endif
- {
- for(int y = 0; y < images[i].height; ++y)
- memcpy(dest+(y*dbpr), ((const uchar*)sptr+(sbpr*y)), dbpr);
- }
- }
-
- //set the family data to the Handle
- OSStatus set = SetIconFamilyData(iconFamily, images[i].mac_type, hdl);
- if(set != noErr)
- qWarning("%s: %d -- Unable to create icon data[%d]!! %ld",
- __FILE__, __LINE__, i, long(set));
- DisposeHandle(hdl);
- }
- }
-
- //acquire and cleanup
- IconRef ret;
- static int counter = 0;
- const OSType kQtCreator = 'CUTE';
- RegisterIconRefFromIconFamily(kQtCreator, (OSType)counter, iconFamily, &ret);
- AcquireIconRef(ret);
- UnregisterIconRef(kQtCreator, (OSType)counter);
- DisposeHandle(reinterpret_cast<Handle>(iconFamily));
- counter++;
- return ret;
-
-}
-#endif
-
-/*! \internal */
-QPaintEngine* QMacPixmapData::paintEngine() const
-{
- if (!pengine) {
- QMacPixmapData *that = const_cast<QMacPixmapData*>(this);
- that->pengine = new QCoreGraphicsPaintEngine();
- }
- return pengine;
-}
-
-void QMacPixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- if (data->pixelType() == BitmapType) {
- QBitmap::fromImage(toImage().copy(rect));
- return;
- }
-
- const QMacPixmapData *macData = static_cast<const QMacPixmapData*>(data);
-
- resize(rect.width(), rect.height());
-
- has_alpha = macData->has_alpha;
- has_mask = macData->has_mask;
- uninit = false;
-
- const int x = rect.x();
- const int y = rect.y();
- char *dest = reinterpret_cast<char*>(pixels);
- const char *src = reinterpret_cast<const char*>(macData->pixels + x) + y * macData->bytesPerRow;
- for (int i = 0; i < h; ++i) {
- memcpy(dest, src, w * 4);
- dest += bytesPerRow;
- src += macData->bytesPerRow;
- }
-
- has_alpha = macData->has_alpha;
- has_mask = macData->has_mask;
-}
-
-bool QMacPixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- Q_UNUSED(dx);
- Q_UNUSED(dy);
- Q_UNUSED(rect);
- return false;
-}
-
-/*!
- \since 4.2
-
- Creates a \c CGImageRef equivalent to the QPixmap. Returns the \c CGImageRef handle.
-
- It is the caller's responsibility to release the \c CGImageRef data
- after use.
-
- \warning This function is only available on Mac OS X.
-
- \sa fromMacCGImageRef()
-*/
-CGImageRef QPixmap::toMacCGImageRef() const
-{
- return (CGImageRef)macCGHandle();
-}
-
-/*!
- \since 4.2
-
- Returns a QPixmap that is equivalent to the given \a image.
-
- \warning This function is only available on Mac OS X.
-
- \sa toMacCGImageRef(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
-*/
-QPixmap QPixmap::fromMacCGImageRef(CGImageRef image)
-{
- const size_t w = CGImageGetWidth(image),
- h = CGImageGetHeight(image);
- QPixmap ret(w, h);
- ret.fill(Qt::transparent);
- CGRect rect = CGRectMake(0, 0, w, h);
- CGContextRef ctx = qt_mac_cg_context(&ret);
- qt_mac_drawCGImage(ctx, &rect, image);
- CGContextRelease(ctx);
- return ret;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap_mac_p.h b/src/gui/image/qpixmap_mac_p.h
deleted file mode 100644
index 307e38aceb..0000000000
--- a/src/gui/image/qpixmap_mac_p.h
+++ /dev/null
@@ -1,134 +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$
-** 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 QPIXMAP_MAC_P_H
-#define QPIXMAP_MAC_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 <QtGui/private/qpixmapdata_p.h>
-#include <QtGui/private/qpixmapdatafactory_p.h>
-#include <QtGui/private/qt_mac_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QMacPixmapData : public QPixmapData
-{
-public:
- QMacPixmapData(PixelType type);
- ~QMacPixmapData();
-
- 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);
- QBitmap mask() const;
- void setMask(const QBitmap &mask);
- bool hasAlphaChannel() const;
-// QPixmap transformed(const QTransform &matrix,
-// Qt::TransformationMode mode) const;
- void setAlphaChannel(const QPixmap &alphaChannel);
- QPixmap alphaChannel() const;
- QImage toImage() const;
- QPaintEngine* paintEngine() const;
-
-private:
-
- uint has_alpha : 1, has_mask : 1, uninit : 1;
-
- void macSetHasAlpha(bool b);
- void macGetAlphaChannel(QMacPixmapData *, bool asMask) const;
- void macSetAlphaChannel(const QMacPixmapData *, bool asMask);
- void macCreateCGImageRef();
- void macCreatePixels();
- void macReleaseCGImageRef();
- /*
- pixels stores the pixmap data. pixelsToFree is either 0 or some memory
- block that was bound to a CGImageRef and released, and for which the
- release callback has been called. There are two uses to pixelsToFree:
-
- 1. If pixels == pixelsToFree, then we know that the CGImageRef is done\
- with the data and we can modify pixels without breaking CGImageRef's
- mutability invariant.
-
- 2. If pixels != pixelsToFree and pixelsToFree != 0, then we can reuse
- pixelsToFree later on instead of malloc'ing memory.
- */
- quint32 *pixels;
- uint pixelsSize;
- quint32 *pixelsToFree;
- uint bytesPerRow;
- QRectF cg_mask_rect;
- CGImageRef cg_data, cg_dataBeingReleased, cg_mask;
- static QSet<QMacPixmapData*> validDataPointers;
-
- QPaintEngine *pengine;
-
- friend class QPixmap;
- friend class QRasterBuffer;
- friend class QRasterPaintEngine;
- friend class QCoreGraphicsPaintEngine;
- friend CGImageRef qt_mac_create_imagemask(const QPixmap&, const QRectF&);
- friend quint32 *qt_mac_pixmap_get_base(const QPixmap*);
- friend int qt_mac_pixmap_get_bytes_per_line(const QPixmap*);
- friend void qt_mac_cgimage_data_free(void *, const void*, size_t);
- friend IconRef qt_mac_create_iconref(const QPixmap&);
- friend CGContextRef qt_mac_cg_context(const QPaintDevice*);
- friend QColor qcolorForThemeTextColor(ThemeTextColor themeColor);
-};
-
-QT_END_NAMESPACE
-
-#endif // QPIXMAP_MAC_P_H
diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp
deleted file mode 100644
index c8aa003ffa..0000000000
--- a/src/gui/image/qpixmap_s60.cpp
+++ /dev/null
@@ -1,1040 +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$
-** 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 <exception>
-#include <w32std.h>
-#include <fbs.h>
-
-#include <private/qapplication_p.h>
-#include <private/qgraphicssystem_p.h>
-#include <private/qt_s60_p.h>
-#include <private/qpaintengine_s60_p.h>
-#include <private/qfont_p.h>
-
-#include "qpixmap.h"
-#include "qpixmap_raster_p.h"
-#include <qwidget.h>
-#include "qpixmap_s60_p.h"
-#include "qnativeimage_p.h"
-#include "qbitmap.h"
-#include "qimage.h"
-#include "qimage_p.h"
-
-#include <fbs.h>
-
-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<CFbsBitmap*>(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<QPixmapData> data(QPixmapData::create(0,0, QPixmapData::PixmapType));
- data->fromNativeType(reinterpret_cast<void*>(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<QS60PixmapData*>(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<QImage &>(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<const QImage &>(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<const QS60PixmapData*>(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;
-}
-
-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<QS60PixmapData*>(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<QRgb> 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<QS60PaintEngine *>(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<QPixmapData> data(QPixmapData::create(0,0, QPixmapData::PixmapType));
- data->fromNativeType(reinterpret_cast<void*>(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<RSgImage*>(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<void*>(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<CFbsBitmap*>(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<TDisplayMode>(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<CFbsBitmap> newBitmap(createSymbianCFbsBitmap(size, displayMode));
-
- const uchar *sptr = const_cast<const QImage &>(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 c440bbc33a..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$
-** 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 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 <QtGui/private/qpixmap_raster_p.h>
-
-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/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
deleted file mode 100644
index 9c14ac7726..0000000000
--- a/src/gui/image/qpixmap_win.cpp
+++ /dev/null
@@ -1,477 +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$
-** 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 "qpixmap.h"
-#include "qpixmap_raster_p.h"
-
-#include "qbitmap.h"
-#include "qimage.h"
-#include "qwidget.h"
-#include "qpainter.h"
-#include "qdatastream.h"
-#include "qbuffer.h"
-#include "qapplication.h"
-#include "qevent.h"
-#include "qfile.h"
-#include "qfileinfo.h"
-#include "qdatetime.h"
-#include "qpixmapcache.h"
-#include "qimagereader.h"
-#include "qimagewriter.h"
-#include "qdebug.h"
-#include "qt_windows.h"
-
-#if defined(Q_WS_WINCE)
-#include <winbase.h>
-#include "qguifunctions_wince.h"
-extern bool qt_wince_is_high_dpi();
-extern bool qt_wince_is_pocket_pc();
-#endif
-
-#ifndef CAPTUREBLT
-#define CAPTUREBLT ((DWORD)0x40000000)
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h )
-{
- RECT r;
- GetClientRect(winId, &r);
-
- if (w < 0) w = r.right - r.left;
- if (h < 0) h = r.bottom - r.top;
-
-#ifdef Q_WS_WINCE_WM
- if (qt_wince_is_pocket_pc()) {
- QWidget *widget = QWidget::find(winId);
- if (qobject_cast<QDesktopWidget *>(widget)) {
- RECT rect = {0,0,0,0};
- AdjustWindowRectEx(&rect, WS_BORDER | WS_CAPTION, FALSE, 0);
- int magicNumber = qt_wince_is_high_dpi() ? 4 : 2;
- y += rect.top - magicNumber;
- }
- }
-#endif
-
- // Create and setup bitmap
- HDC display_dc = GetDC(0);
- HDC bitmap_dc = CreateCompatibleDC(display_dc);
- HBITMAP bitmap = CreateCompatibleBitmap(display_dc, w, h);
- HGDIOBJ null_bitmap = SelectObject(bitmap_dc, bitmap);
-
- // copy data
- HDC window_dc = GetDC(winId);
- BitBlt(bitmap_dc, 0, 0, w, h, window_dc, x, y, SRCCOPY
-#ifndef Q_WS_WINCE
- | CAPTUREBLT
-#endif
- );
-
- // clean up all but bitmap
- ReleaseDC(winId, window_dc);
- SelectObject(bitmap_dc, null_bitmap);
- DeleteDC(bitmap_dc);
-
- QPixmap pixmap = QPixmap::fromWinHBITMAP(bitmap);
-
- DeleteObject(bitmap);
- ReleaseDC(0, display_dc);
-
- return pixmap;
-}
-
-HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const
-{
- if (isNull())
- return 0;
-
- HBITMAP bitmap = 0;
- if (data->classId() == QPixmapData::RasterClass) {
- QRasterPixmapData* d = static_cast<QRasterPixmapData*>(data.data());
- int w = d->image.width();
- int h = d->image.height();
-
- HDC display_dc = GetDC(0);
-
- // Define the header
- BITMAPINFO bmi;
- memset(&bmi, 0, sizeof(bmi));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = w;
- bmi.bmiHeader.biHeight = -h;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = w * h * 4;
-
- // Create the pixmap
- uchar *pixels = 0;
- bitmap = CreateDIBSection(display_dc, &bmi, DIB_RGB_COLORS, (void **) &pixels, 0, 0);
- ReleaseDC(0, display_dc);
- if (!bitmap) {
- qErrnoWarning("QPixmap::toWinHBITMAP(), failed to create dibsection");
- return 0;
- }
- if (!pixels) {
- qErrnoWarning("QPixmap::toWinHBITMAP(), did not allocate pixel data");
- return 0;
- }
-
- // Copy over the data
- QImage::Format imageFormat = QImage::Format_ARGB32;
- if (format == NoAlpha)
- imageFormat = QImage::Format_RGB32;
- else if (format == PremultipliedAlpha)
- imageFormat = QImage::Format_ARGB32_Premultiplied;
- const QImage image = d->image.convertToFormat(imageFormat);
- int bytes_per_line = w * 4;
- for (int y=0; y<h; ++y)
- memcpy(pixels + y * bytes_per_line, image.scanLine(y), bytes_per_line);
-
- } else {
- QPixmapData *data = new QRasterPixmapData(depth() == 1 ?
- QPixmapData::BitmapType : QPixmapData::PixmapType);
- data->fromImage(toImage(), Qt::AutoColor);
- return QPixmap(data).toWinHBITMAP(format);
- }
- return bitmap;
-}
-
-QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
-{
- // Verify size
- BITMAP bitmap_info;
- memset(&bitmap_info, 0, sizeof(BITMAP));
-
- int res = GetObject(bitmap, sizeof(BITMAP), &bitmap_info);
- if (!res) {
- qErrnoWarning("QPixmap::fromWinHBITMAP(), failed to get bitmap info");
- return QPixmap();
- }
- int w = bitmap_info.bmWidth;
- int h = bitmap_info.bmHeight;
-
- BITMAPINFO bmi;
- memset(&bmi, 0, sizeof(bmi));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = w;
- bmi.bmiHeader.biHeight = -h;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = w * h * 4;
-
- QImage result;
- // Get bitmap bits
- uchar *data = (uchar *) qMalloc(bmi.bmiHeader.biSizeImage);
-
- HDC display_dc = GetDC(0);
- if (GetDIBits(display_dc, bitmap, 0, h, data, &bmi, DIB_RGB_COLORS)) {
-
- QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied;
- uint mask = 0;
- if (format == NoAlpha) {
- imageFormat = QImage::Format_RGB32;
- mask = 0xff000000;
- }
-
- // Create image and copy data into image.
- QImage image(w, h, imageFormat);
- if (!image.isNull()) { // failed to alloc?
- int bytes_per_line = w * sizeof(QRgb);
- for (int y=0; y<h; ++y) {
- QRgb *dest = (QRgb *) image.scanLine(y);
- const QRgb *src = (const QRgb *) (data + y * bytes_per_line);
- for (int x=0; x<w; ++x) {
- const uint pixel = src[x];
- if ((pixel & 0xff000000) == 0 && (pixel & 0x00ffffff) != 0)
- dest[x] = pixel | 0xff000000;
- else
- dest[x] = pixel | mask;
- }
- }
- }
- result = image;
- } else {
- qWarning("QPixmap::fromWinHBITMAP(), failed to get bitmap bits");
- }
- ReleaseDC(0, display_dc);
- qFree(data);
- return fromImage(result);
-}
-
-HBITMAP qt_createIconMask(const QBitmap &bitmap)
-{
- QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono);
- int w = bm.width();
- int h = bm.height();
- int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment
- uchar *bits = new uchar[bpl*h];
- bm.invertPixels();
- for (int y=0; y<h; y++)
- memcpy(bits+y*bpl, bm.scanLine(y), bpl);
- HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits);
- delete [] bits;
- return hbm;
-}
-
-HICON QPixmap::toWinHICON() const
-{
- QBitmap maskBitmap = mask();
- if (maskBitmap.isNull()) {
- maskBitmap= QBitmap(size());
- maskBitmap.fill(Qt::color1);
- }
-
- ICONINFO ii;
- ii.fIcon = true;
- ii.hbmMask = qt_createIconMask(maskBitmap);
- ii.hbmColor = toWinHBITMAP(QPixmap::Alpha);
- ii.xHotspot = 0;
- ii.yHotspot = 0;
-
- HICON hIcon = CreateIconIndirect(&ii);
-
- DeleteObject(ii.hbmColor);
- DeleteObject(ii.hbmMask);
-
- return hIcon;
-}
-
-#ifdef Q_WS_WIN
-#ifndef Q_WS_WINCE
-
-static QImage qt_fromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
-{
- BITMAPINFO bmi;
- memset(&bmi, 0, sizeof(bmi));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = w;
- bmi.bmiHeader.biHeight = -h;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = w * h * 4;
-
- QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
- if (image.isNull())
- return image;
-
- // Get bitmap bits
- uchar *data = (uchar *) qMalloc(bmi.bmiHeader.biSizeImage);
-
- if (GetDIBits(hdc, bitmap, 0, h, data, &bmi, DIB_RGB_COLORS)) {
- // Create image and copy data into image.
- for (int y=0; y<h; ++y) {
- void *dest = (void *) image.scanLine(y);
- void *src = data + y * image.bytesPerLine();
- memcpy(dest, src, image.bytesPerLine());
- }
- } else {
- qWarning("qt_fromWinHBITMAP(), failed to get bitmap bits");
- }
- qFree(data);
-
- return image;
-}
-
-QPixmap QPixmap::fromWinHICON(HICON icon)
-{
- bool foundAlpha = false;
- HDC screenDevice = GetDC(0);
- HDC hdc = CreateCompatibleDC(screenDevice);
- ReleaseDC(0, screenDevice);
-
- ICONINFO iconinfo;
- bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center
- if (!result)
- qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
-
- int w = iconinfo.xHotspot * 2;
- int h = iconinfo.yHotspot * 2;
-
- BITMAPINFOHEADER bitmapInfo;
- bitmapInfo.biSize = sizeof(BITMAPINFOHEADER);
- bitmapInfo.biWidth = w;
- bitmapInfo.biHeight = h;
- bitmapInfo.biPlanes = 1;
- bitmapInfo.biBitCount = 32;
- bitmapInfo.biCompression = BI_RGB;
- bitmapInfo.biSizeImage = 0;
- bitmapInfo.biXPelsPerMeter = 0;
- bitmapInfo.biYPelsPerMeter = 0;
- bitmapInfo.biClrUsed = 0;
- bitmapInfo.biClrImportant = 0;
- DWORD* bits;
-
- HBITMAP winBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bitmapInfo, DIB_RGB_COLORS, (VOID**)&bits, NULL, 0);
- HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap);
- DrawIconEx( hdc, 0, 0, icon, iconinfo.xHotspot * 2, iconinfo.yHotspot * 2, 0, 0, DI_NORMAL);
- QImage image = qt_fromWinHBITMAP(hdc, winBitmap, w, h);
-
- for (int y = 0 ; y < h && !foundAlpha ; y++) {
- QRgb *scanLine= reinterpret_cast<QRgb *>(image.scanLine(y));
- for (int x = 0; x < w ; x++) {
- if (qAlpha(scanLine[x]) != 0) {
- foundAlpha = true;
- break;
- }
- }
- }
- if (!foundAlpha) {
- //If no alpha was found, we use the mask to set alpha values
- DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_MASK);
- QImage mask = qt_fromWinHBITMAP(hdc, winBitmap, w, h);
-
- for (int y = 0 ; y < h ; y++){
- QRgb *scanlineImage = reinterpret_cast<QRgb *>(image.scanLine(y));
- QRgb *scanlineMask = mask.isNull() ? 0 : reinterpret_cast<QRgb *>(mask.scanLine(y));
- for (int x = 0; x < w ; x++){
- if (scanlineMask && qRed(scanlineMask[x]) != 0)
- scanlineImage[x] = 0; //mask out this pixel
- else
- scanlineImage[x] |= 0xff000000; // set the alpha channel to 255
- }
- }
- }
- //dispose resources created by iconinfo call
- DeleteObject(iconinfo.hbmMask);
- DeleteObject(iconinfo.hbmColor);
-
- SelectObject(hdc, oldhdc); //restore state
- DeleteObject(winBitmap);
- DeleteDC(hdc);
- return QPixmap::fromImage(image);
-}
-#else //ifndef Q_WS_WINCE
-QPixmap QPixmap::fromWinHICON(HICON icon)
-{
- HDC screenDevice = GetDC(0);
- HDC hdc = CreateCompatibleDC(screenDevice);
- ReleaseDC(0, screenDevice);
-
- ICONINFO iconinfo;
- bool result = GetIconInfo(icon, &iconinfo);
- if (!result)
- qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
-
- int w = 0;
- int h = 0;
- if (!iconinfo.xHotspot || !iconinfo.yHotspot) {
- // We could not retrieve the icon size via GetIconInfo,
- // so we try again using the icon bitmap.
- BITMAP bm;
- int result = GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bm);
- if (!result) result = GetObject(iconinfo.hbmMask, sizeof(BITMAP), &bm);
- if (!result) {
- qWarning("QPixmap::fromWinHICON(), failed to retrieve icon size");
- return QPixmap();
- }
- w = bm.bmWidth;
- h = bm.bmHeight;
- } else {
- // x and y Hotspot describes the icon center
- w = iconinfo.xHotspot * 2;
- h = iconinfo.yHotspot * 2;
- }
- const DWORD dwImageSize = w * h * 4;
-
- BITMAPINFO bmi;
- memset(&bmi, 0, sizeof(bmi));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
- bmi.bmiHeader.biWidth = w;
- bmi.bmiHeader.biHeight = -h;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = dwImageSize;
-
- uchar* bits;
-
- HBITMAP winBitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &bits, 0, 0);
- if (winBitmap )
- memset(bits, 0xff, dwImageSize);
- if (!winBitmap) {
- qWarning("QPixmap::fromWinHICON(), failed to CreateDIBSection()");
- return QPixmap();
- }
-
- HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap);
- if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_NORMAL))
- qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
-
- uint mask = 0xff000000;
- // Create image and copy data into image.
- QImage image(w, h, QImage::Format_ARGB32);
-
- if (!image.isNull()) { // failed to alloc?
- int bytes_per_line = w * sizeof(QRgb);
- for (int y=0; y < h; ++y) {
- QRgb *dest = (QRgb *) image.scanLine(y);
- const QRgb *src = (const QRgb *) (bits + y * bytes_per_line);
- for (int x=0; x < w; ++x) {
- dest[x] = src[x];
- }
- }
- }
- if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_MASK))
- qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
- if (!image.isNull()) { // failed to alloc?
- int bytes_per_line = w * sizeof(QRgb);
- for (int y=0; y < h; ++y) {
- QRgb *dest = (QRgb *) image.scanLine(y);
- const QRgb *src = (const QRgb *) (bits + y * bytes_per_line);
- for (int x=0; x < w; ++x) {
- if (!src[x])
- dest[x] = dest[x] | mask;
- }
- }
- }
- SelectObject(hdc, oldhdc); //restore state
- DeleteObject(winBitmap);
- DeleteDC(hdc);
- return QPixmap::fromImage(image);
-}
-#endif //ifndef Q_WS_WINCE
-#endif //ifdef Q_WS_WIN
-
-QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
deleted file mode 100644
index bc468cb7ec..0000000000
--- a/src/gui/image/qpixmap_x11.cpp
+++ /dev/null
@@ -1,2419 +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$
-** 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$
-**
-****************************************************************************/
-
-// Uncomment the next line to enable the MIT Shared Memory extension
-//
-// WARNING: This has some problems:
-//
-// 1. Consumes a 800x600 pixmap
-// 2. Qt does not handle the ShmCompletion message, so you will
-// get strange effects if you xForm() repeatedly.
-//
-// #define QT_MITSHM
-
-#if defined(Q_OS_WIN32) && defined(QT_MITSHM)
-#undef QT_MITSHM
-#endif
-
-#include "qplatformdefs.h"
-
-#include "qdebug.h"
-#include "qiodevice.h"
-#include "qpixmap_x11_p.h"
-#include "qbitmap.h"
-#include "qcolormap.h"
-#include "qimage.h"
-#include "qmatrix.h"
-#include "qapplication.h"
-#include <private/qpaintengine_x11_p.h>
-#include <private/qt_x11_p.h>
-#include "qx11info_x11.h"
-#include <private/qdrawhelper_p.h>
-#include <private/qimage_p.h>
-#include <private/qimagepixmapcleanuphooks_p.h>
-
-#include <stdlib.h>
-
-#if defined(Q_CC_MIPS)
-# define for if(0){}else for
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QPixmap qt_toX11Pixmap(const QImage &image)
-{
- QPixmapData *data =
- new QX11PixmapData(image.depth() == 1
- ? QPixmapData::BitmapType
- : QPixmapData::PixmapType);
-
- data->fromImage(image, Qt::AutoColor);
-
- return QPixmap(data);
-}
-
-QPixmap qt_toX11Pixmap(const QPixmap &pixmap)
-{
- if (pixmap.isNull())
- return QPixmap();
-
- if (QPixmap(pixmap).data_ptr()->classId() == QPixmapData::X11Class)
- return pixmap;
-
- return qt_toX11Pixmap(pixmap.toImage());
-}
-
-// For thread-safety:
-// image->data does not belong to X11, so we must free it ourselves.
-
-inline static void qSafeXDestroyImage(XImage *x)
-{
- if (x->data) {
- free(x->data);
- x->data = 0;
- }
- XDestroyImage(x);
-}
-
-QBitmap QX11PixmapData::mask_to_bitmap(int screen) const
-{
- if (!x11_mask)
- return QBitmap();
- QPixmap::x11SetDefaultScreen(screen);
- QBitmap bm(w, h);
- GC gc = XCreateGC(X11->display, bm.handle(), 0, 0);
- XCopyArea(X11->display, x11_mask, bm.handle(), gc, 0, 0,
- bm.data->width(), bm.data->height(), 0, 0);
- XFreeGC(X11->display, gc);
- return bm;
-}
-
-Qt::HANDLE QX11PixmapData::bitmap_to_mask(const QBitmap &bitmap, int screen)
-{
- if (bitmap.isNull())
- return 0;
- QBitmap bm = bitmap;
- bm.x11SetScreen(screen);
-
- Pixmap mask = XCreatePixmap(X11->display, RootWindow(X11->display, screen),
- bm.data->width(), bm.data->height(), 1);
- GC gc = XCreateGC(X11->display, mask, 0, 0);
- XCopyArea(X11->display, bm.handle(), mask, gc, 0, 0,
- bm.data->width(), bm.data->height(), 0, 0);
- XFreeGC(X11->display, gc);
- return mask;
-}
-
-
-/*****************************************************************************
- MIT Shared Memory Extension support: makes xForm noticeably (~20%) faster.
- *****************************************************************************/
-
-#if defined(QT_MITSHM)
-
-static bool xshminit = false;
-static XShmSegmentInfo xshminfo;
-static XImage *xshmimg = 0;
-static Pixmap xshmpm = 0;
-
-static void qt_cleanup_mitshm()
-{
- if (xshmimg == 0)
- return;
- Display *dpy = QX11Info::appDisplay();
- if (xshmpm) {
- XFreePixmap(dpy, xshmpm);
- xshmpm = 0;
- }
- XShmDetach(dpy, &xshminfo); xshmimg->data = 0;
- qSafeXDestroyImage(xshmimg); xshmimg = 0;
- shmdt(xshminfo.shmaddr);
- shmctl(xshminfo.shmid, IPC_RMID, 0);
-}
-
-static bool qt_create_mitshm_buffer(const QPaintDevice* dev, int w, int h)
-{
- static int major, minor;
- static Bool pixmaps_ok;
- Display *dpy = dev->data->xinfo->display();
- int dd = dev->x11Depth();
- Visual *vis = (Visual*)dev->x11Visual();
-
- if (xshminit) {
- qt_cleanup_mitshm();
- } else {
- if (!XShmQueryVersion(dpy, &major, &minor, &pixmaps_ok))
- return false; // MIT Shm not supported
- qAddPostRoutine(qt_cleanup_mitshm);
- xshminit = true;
- }
-
- xshmimg = XShmCreateImage(dpy, vis, dd, ZPixmap, 0, &xshminfo, w, h);
- if (!xshmimg)
- return false;
-
- bool ok;
- xshminfo.shmid = shmget(IPC_PRIVATE,
- xshmimg->bytes_per_line * xshmimg->height,
- IPC_CREAT | 0777);
- ok = xshminfo.shmid != -1;
- if (ok) {
- xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0);
- xshminfo.shmaddr = xshmimg->data;
- ok = (xshminfo.shmaddr != (char*)-1);
- }
- xshminfo.readOnly = false;
- if (ok)
- ok = XShmAttach(dpy, &xshminfo);
- if (!ok) {
- qSafeXDestroyImage(xshmimg);
- xshmimg = 0;
- if (xshminfo.shmaddr)
- shmdt(xshminfo.shmaddr);
- if (xshminfo.shmid != -1)
- shmctl(xshminfo.shmid, IPC_RMID, 0);
- return false;
- }
- if (pixmaps_ok)
- xshmpm = XShmCreatePixmap(dpy, DefaultRootWindow(dpy), xshmimg->data,
- &xshminfo, w, h, dd);
-
- return true;
-}
-
-#else
-
-// If extern, need a dummy.
-//
-// static bool qt_create_mitshm_buffer(QPaintDevice*, int, int)
-// {
-// return false;
-// }
-
-#endif // QT_MITSHM
-
-
-/*****************************************************************************
- Internal functions
- *****************************************************************************/
-
-extern const uchar *qt_get_bitflip_array(); // defined in qimage.cpp
-
-// Returns position of highest bit set or -1 if none
-static int highest_bit(uint v)
-{
- int i;
- uint b = (uint)1 << 31;
- for (i=31; ((b & v) == 0) && i>=0; i--)
- b >>= 1;
- return i;
-}
-
-// Returns position of lowest set bit in 'v' as an integer (0-31), or -1
-static int lowest_bit(uint v)
-{
- int i;
- ulong lb;
- lb = 1;
- for (i=0; ((v & lb) == 0) && i<32; i++, lb<<=1) {}
- return i==32 ? -1 : i;
-}
-
-// Counts the number of bits set in 'v'
-static uint n_bits(uint v)
-{
- int i = 0;
- while (v) {
- v = v & (v - 1);
- i++;
- }
- return i;
-}
-
-static uint *red_scale_table = 0;
-static uint *green_scale_table = 0;
-static uint *blue_scale_table = 0;
-
-static void cleanup_scale_tables()
-{
- delete[] red_scale_table;
- delete[] green_scale_table;
- delete[] blue_scale_table;
-}
-
-/*
- Could do smart bitshifting, but the "obvious" algorithm only works for
- nBits >= 4. This is more robust.
-*/
-static void build_scale_table(uint **table, uint nBits)
-{
- if (nBits > 7) {
- qWarning("build_scale_table: internal error, nBits = %i", nBits);
- return;
- }
- if (!*table) {
- static bool firstTable = true;
- if (firstTable) {
- qAddPostRoutine(cleanup_scale_tables);
- firstTable = false;
- }
- *table = new uint[256];
- }
- int maxVal = (1 << nBits) - 1;
- int valShift = 8 - nBits;
- int i;
- for(i = 0 ; i < maxVal + 1 ; i++)
- (*table)[i << valShift] = i*255/maxVal;
-}
-
-static int defaultScreen = -1;
-
-/*****************************************************************************
- QPixmap member functions
- *****************************************************************************/
-
-QBasicAtomicInt qt_pixmap_serial = Q_BASIC_ATOMIC_INITIALIZER(0);
-int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0;
-
-QX11PixmapData::QX11PixmapData(PixelType type)
- : QPixmapData(type, X11Class), gl_surface(0), hd(0),
- flags(Uninitialized), x11_mask(0), picture(0), mask_picture(0), hd2(0),
- share_mode(QPixmap::ImplicitlyShared), pengine(0)
-{
-}
-
-QPixmapData *QX11PixmapData::createCompatiblePixmapData() const
-{
- return new QX11PixmapData(pixelType());
-}
-
-void QX11PixmapData::resize(int width, int height)
-{
- setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
-
- w = width;
- h = height;
- is_null = (w <= 0 || h <= 0);
-
- if (defaultScreen >= 0 && defaultScreen != xinfo.screen()) {
- QX11InfoData* xd = xinfo.getX11Data(true);
- xd->screen = defaultScreen;
- xd->depth = QX11Info::appDepth(xd->screen);
- xd->cells = QX11Info::appCells(xd->screen);
- xd->colormap = QX11Info::appColormap(xd->screen);
- xd->defaultColormap = QX11Info::appDefaultColormap(xd->screen);
- xd->visual = (Visual *)QX11Info::appVisual(xd->screen);
- xd->defaultVisual = QX11Info::appDefaultVisual(xd->screen);
- xinfo.setX11Data(xd);
- }
-
- int dd = xinfo.depth();
-
- if (qt_x11_preferred_pixmap_depth)
- dd = qt_x11_preferred_pixmap_depth;
-
- bool make_null = w <= 0 || h <= 0; // create null pixmap
- d = (pixelType() == BitmapType ? 1 : dd);
- if (make_null || d == 0) {
- w = 0;
- h = 0;
- is_null = true;
- hd = 0;
- picture = 0;
- d = 0;
- if (!make_null)
- qWarning("QPixmap: Invalid pixmap parameters");
- return;
- }
- hd = (Qt::HANDLE)XCreatePixmap(X11->display,
- RootWindow(X11->display, xinfo.screen()),
- w, h, d);
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender) {
- XRenderPictFormat *format = d == 1
- ? XRenderFindStandardFormat(X11->display, PictStandardA1)
- : XRenderFindVisualFormat(X11->display, (Visual *)xinfo.visual());
- picture = XRenderCreatePicture(X11->display, hd, format, 0, 0);
- }
-#endif // QT_NO_XRENDER
-}
-
-struct QX11AlphaDetector
-{
- bool hasAlpha() const {
- if (checked)
- return has;
- // Will implicitly also check format and return quickly for opaque types...
- checked = true;
- has = image->isNull() ? false : const_cast<QImage *>(image)->data_ptr()->checkForAlphaPixels();
- return has;
- }
-
- bool hasXRenderAndAlpha() const {
- if (!X11->use_xrender)
- return false;
- return hasAlpha();
- }
-
- QX11AlphaDetector(const QImage *i, Qt::ImageConversionFlags flags)
- : image(i), checked(false), has(false)
- {
- if (flags & Qt::NoOpaqueDetection) {
- checked = true;
- has = image->hasAlphaChannel();
- }
- }
-
- const QImage *image;
- mutable bool checked;
- mutable bool has;
-};
-
-void QX11PixmapData::fromImage(const QImage &img,
- Qt::ImageConversionFlags flags)
-{
- setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
-
- w = img.width();
- h = img.height();
- d = img.depth();
- is_null = (w <= 0 || h <= 0);
-
- if (is_null) {
- w = h = 0;
- return;
- }
-
- if (defaultScreen >= 0 && defaultScreen != xinfo.screen()) {
- QX11InfoData* xd = xinfo.getX11Data(true);
- xd->screen = defaultScreen;
- xd->depth = QX11Info::appDepth(xd->screen);
- xd->cells = QX11Info::appCells(xd->screen);
- xd->colormap = QX11Info::appColormap(xd->screen);
- xd->defaultColormap = QX11Info::appDefaultColormap(xd->screen);
- xd->visual = (Visual *)QX11Info::appVisual(xd->screen);
- xd->defaultVisual = QX11Info::appDefaultVisual(xd->screen);
- xinfo.setX11Data(xd);
- }
-
- if (pixelType() == BitmapType) {
- bitmapFromImage(img);
- return;
- }
-
- if (uint(w) >= 32768 || uint(h) >= 32768) {
- w = h = 0;
- is_null = true;
- return;
- }
-
- QX11AlphaDetector alphaCheck(&img, flags);
- int dd = alphaCheck.hasXRenderAndAlpha() ? 32 : xinfo.depth();
-
- if (qt_x11_preferred_pixmap_depth)
- dd = qt_x11_preferred_pixmap_depth;
-
- QImage image = img;
-
- // must be monochrome
- if (dd == 1 || (flags & Qt::ColorMode_Mask) == Qt::MonoOnly) {
- if (d != 1) {
- // dither
- image = image.convertToFormat(QImage::Format_MonoLSB, flags);
- d = 1;
- }
- } else { // can be both
- bool conv8 = false;
- if (d > 8 && dd <= 8) { // convert to 8 bit
- if ((flags & Qt::DitherMode_Mask) == Qt::AutoDither)
- flags = (flags & ~Qt::DitherMode_Mask)
- | Qt::PreferDither;
- conv8 = true;
- } else if ((flags & Qt::ColorMode_Mask) == Qt::ColorOnly) {
- conv8 = (d == 1); // native depth wanted
- } else if (d == 1) {
- if (image.colorCount() == 2) {
- QRgb c0 = image.color(0); // Auto: convert to best
- QRgb c1 = image.color(1);
- conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255);
- } else {
- // eg. 1-color monochrome images (they do exist).
- conv8 = true;
- }
- }
- if (conv8) {
- image = image.convertToFormat(QImage::Format_Indexed8, flags);
- d = 8;
- }
- }
-
- if (d == 1 || d == 16 || d == 24) {
- image = image.convertToFormat(QImage::Format_RGB32, flags);
- fromImage(image, Qt::AutoColor);
- return;
- }
-
- Display *dpy = X11->display;
- Visual *visual = (Visual *)xinfo.visual();
- XImage *xi = 0;
- bool trucol = (visual->c_class >= TrueColor);
- int nbytes = image.byteCount();
- uchar *newbits= 0;
-
-#ifndef QT_NO_XRENDER
- if (alphaCheck.hasXRenderAndAlpha()) {
- const QImage &cimage = image;
-
- d = 32;
-
- if (QX11Info::appDepth() != d) {
- if (xinfo.x11data) {
- xinfo.x11data->depth = d;
- } else {
- QX11InfoData *xd = xinfo.getX11Data(true);
- xd->screen = QX11Info::appScreen();
- xd->depth = d;
- xd->cells = QX11Info::appCells();
- xd->colormap = QX11Info::appColormap();
- xd->defaultColormap = QX11Info::appDefaultColormap();
- xd->visual = (Visual *)QX11Info::appVisual();
- xd->defaultVisual = QX11Info::appDefaultVisual();
- xinfo.setX11Data(xd);
- }
- }
-
- hd = (Qt::HANDLE)XCreatePixmap(dpy, RootWindow(dpy, xinfo.screen()),
- w, h, d);
- picture = XRenderCreatePicture(X11->display, hd,
- XRenderFindStandardFormat(X11->display, PictStandardARGB32), 0, 0);
-
- xi = XCreateImage(dpy, visual, d, ZPixmap, 0, 0, w, h, 32, 0);
- Q_CHECK_PTR(xi);
- newbits = (uchar *)malloc(xi->bytes_per_line*h);
- Q_CHECK_PTR(newbits);
- xi->data = (char *)newbits;
-
- switch(cimage.format()) {
- case QImage::Format_Indexed8: {
- QVector<QRgb> colorTable = cimage.colorTable();
- uint *xidata = (uint *)xi->data;
- for (int y = 0; y < h; ++y) {
- const uchar *p = cimage.scanLine(y);
- for (int x = 0; x < w; ++x) {
- const QRgb rgb = colorTable[p[x]];
- const int a = qAlpha(rgb);
- if (a == 0xff)
- *xidata = rgb;
- else
- // RENDER expects premultiplied alpha
- *xidata = qRgba(qt_div_255(qRed(rgb) * a),
- qt_div_255(qGreen(rgb) * a),
- qt_div_255(qBlue(rgb) * a),
- a);
- ++xidata;
- }
- }
- }
- break;
- case QImage::Format_RGB32: {
- uint *xidata = (uint *)xi->data;
- for (int y = 0; y < h; ++y) {
- const QRgb *p = (const QRgb *) cimage.scanLine(y);
- for (int x = 0; x < w; ++x)
- *xidata++ = p[x] | 0xff000000;
- }
- }
- break;
- case QImage::Format_ARGB32: {
- uint *xidata = (uint *)xi->data;
- for (int y = 0; y < h; ++y) {
- const QRgb *p = (const QRgb *) cimage.scanLine(y);
- for (int x = 0; x < w; ++x) {
- const QRgb rgb = p[x];
- const int a = qAlpha(rgb);
- if (a == 0xff)
- *xidata = rgb;
- else
- // RENDER expects premultiplied alpha
- *xidata = qRgba(qt_div_255(qRed(rgb) * a),
- qt_div_255(qGreen(rgb) * a),
- qt_div_255(qBlue(rgb) * a),
- a);
- ++xidata;
- }
- }
-
- }
- break;
- case QImage::Format_ARGB32_Premultiplied: {
- uint *xidata = (uint *)xi->data;
- for (int y = 0; y < h; ++y) {
- const QRgb *p = (const QRgb *) cimage.scanLine(y);
- memcpy(xidata, p, w*sizeof(QRgb));
- xidata += w;
- }
- }
- break;
- default:
- Q_ASSERT(false);
- }
-
- if ((xi->byte_order == MSBFirst) != (QSysInfo::ByteOrder == QSysInfo::BigEndian)) {
- uint *xidata = (uint *)xi->data;
- uint *xiend = xidata + w*h;
- while (xidata < xiend) {
- *xidata = (*xidata >> 24)
- | ((*xidata >> 8) & 0xff00)
- | ((*xidata << 8) & 0xff0000)
- | (*xidata << 24);
- ++xidata;
- }
- }
-
- GC gc = XCreateGC(dpy, hd, 0, 0);
- XPutImage(dpy, hd, gc, xi, 0, 0, 0, 0, w, h);
- XFreeGC(dpy, gc);
-
- qSafeXDestroyImage(xi);
-
- return;
- }
-#endif // QT_NO_XRENDER
-
- if (trucol) { // truecolor display
- if (image.format() == QImage::Format_ARGB32_Premultiplied)
- image = image.convertToFormat(QImage::Format_ARGB32);
-
- const QImage &cimage = image;
- QRgb pix[256]; // pixel translation table
- const bool d8 = (d == 8);
- const uint red_mask = (uint)visual->red_mask;
- const uint green_mask = (uint)visual->green_mask;
- const uint blue_mask = (uint)visual->blue_mask;
- const int red_shift = highest_bit(red_mask) - 7;
- const int green_shift = highest_bit(green_mask) - 7;
- const int blue_shift = highest_bit(blue_mask) - 7;
- const uint rbits = highest_bit(red_mask) - lowest_bit(red_mask) + 1;
- const uint gbits = highest_bit(green_mask) - lowest_bit(green_mask) + 1;
- const uint bbits = highest_bit(blue_mask) - lowest_bit(blue_mask) + 1;
-
- if (d8) { // setup pixel translation
- QVector<QRgb> ctable = cimage.colorTable();
- for (int i=0; i < cimage.colorCount(); i++) {
- int r = qRed (ctable[i]);
- int g = qGreen(ctable[i]);
- int b = qBlue (ctable[i]);
- r = red_shift > 0 ? r << red_shift : r >> -red_shift;
- g = green_shift > 0 ? g << green_shift : g >> -green_shift;
- b = blue_shift > 0 ? b << blue_shift : b >> -blue_shift;
- pix[i] = (b & blue_mask) | (g & green_mask) | (r & red_mask)
- | ~(blue_mask | green_mask | red_mask);
- }
- }
-
- xi = XCreateImage(dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0);
- Q_CHECK_PTR(xi);
- newbits = (uchar *)malloc(xi->bytes_per_line*h);
- Q_CHECK_PTR(newbits);
- if (!newbits) // no memory
- return;
- int bppc = xi->bits_per_pixel;
-
- bool contig_bits = n_bits(red_mask) == rbits &&
- n_bits(green_mask) == gbits &&
- n_bits(blue_mask) == bbits;
- bool dither_tc =
- // Want it?
- (flags & Qt::Dither_Mask) != Qt::ThresholdDither &&
- (flags & Qt::DitherMode_Mask) != Qt::AvoidDither &&
- // Need it?
- bppc < 24 && !d8 &&
- // Can do it? (Contiguous bits?)
- contig_bits;
-
- static bool init=false;
- static int D[16][16];
- if (dither_tc && !init) {
- // I also contributed this code to XV - WWA.
- /*
- The dither matrix, D, is obtained with this formula:
-
- D2 = [0 2]
- [3 1]
-
-
- D2*n = [4*Dn 4*Dn+2*Un]
- [4*Dn+3*Un 4*Dn+1*Un]
- */
- int n,i,j;
- init=1;
-
- /* Set D2 */
- D[0][0]=0;
- D[1][0]=2;
- D[0][1]=3;
- D[1][1]=1;
-
- /* Expand using recursive definition given above */
- for (n=2; n<16; n*=2) {
- for (i=0; i<n; i++) {
- for (j=0; j<n; j++) {
- D[i][j]*=4;
- D[i+n][j]=D[i][j]+2;
- D[i][j+n]=D[i][j]+3;
- D[i+n][j+n]=D[i][j]+1;
- }
- }
- }
- init=true;
- }
-
- enum { BPP8,
- BPP16_565, BPP16_555,
- BPP16_MSB, BPP16_LSB,
- BPP24_888,
- BPP24_MSB, BPP24_LSB,
- BPP32_8888,
- BPP32_MSB, BPP32_LSB
- } mode = BPP8;
-
- bool same_msb_lsb = (xi->byte_order == MSBFirst) == (QSysInfo::ByteOrder == QSysInfo::BigEndian);
-
- if(bppc == 8) // 8 bit
- mode = BPP8;
- else if(bppc == 16) { // 16 bit MSB/LSB
- if(red_shift == 8 && green_shift == 3 && blue_shift == -3 && !d8 && same_msb_lsb)
- mode = BPP16_565;
- else if(red_shift == 7 && green_shift == 2 && blue_shift == -3 && !d8 && same_msb_lsb)
- mode = BPP16_555;
- else
- mode = (xi->byte_order == LSBFirst) ? BPP16_LSB : BPP16_MSB;
- } else if(bppc == 24) { // 24 bit MSB/LSB
- if (red_shift == 16 && green_shift == 8 && blue_shift == 0 && !d8 && same_msb_lsb)
- mode = BPP24_888;
- else
- mode = (xi->byte_order == LSBFirst) ? BPP24_LSB : BPP24_MSB;
- } else if(bppc == 32) { // 32 bit MSB/LSB
- if(red_shift == 16 && green_shift == 8 && blue_shift == 0 && !d8 && same_msb_lsb)
- mode = BPP32_8888;
- else
- mode = (xi->byte_order == LSBFirst) ? BPP32_LSB : BPP32_MSB;
- } else
- qFatal("Logic error 3");
-
-#define GET_PIXEL \
- uint pixel; \
- if (d8) pixel = pix[*src++]; \
- else { \
- int r = qRed (*p); \
- int g = qGreen(*p); \
- int b = qBlue (*p++); \
- r = red_shift > 0 \
- ? r << red_shift : r >> -red_shift; \
- g = green_shift > 0 \
- ? g << green_shift : g >> -green_shift; \
- b = blue_shift > 0 \
- ? b << blue_shift : b >> -blue_shift; \
- pixel = (r & red_mask)|(g & green_mask) | (b & blue_mask) \
- | ~(blue_mask | green_mask | red_mask); \
- }
-
-#define GET_PIXEL_DITHER_TC \
- int r = qRed (*p); \
- int g = qGreen(*p); \
- int b = qBlue (*p++); \
- const int thres = D[x%16][y%16]; \
- if (r <= (255-(1<<(8-rbits))) && ((r<<rbits) & 255) \
- > thres) \
- r += (1<<(8-rbits)); \
- if (g <= (255-(1<<(8-gbits))) && ((g<<gbits) & 255) \
- > thres) \
- g += (1<<(8-gbits)); \
- if (b <= (255-(1<<(8-bbits))) && ((b<<bbits) & 255) \
- > thres) \
- b += (1<<(8-bbits)); \
- r = red_shift > 0 \
- ? r << red_shift : r >> -red_shift; \
- g = green_shift > 0 \
- ? g << green_shift : g >> -green_shift; \
- b = blue_shift > 0 \
- ? b << blue_shift : b >> -blue_shift; \
- uint pixel = (r & red_mask)|(g & green_mask) | (b & blue_mask);
-
-// again, optimized case
-// can't be optimized that much :(
-#define GET_PIXEL_DITHER_TC_OPT(red_shift,green_shift,blue_shift,red_mask,green_mask,blue_mask, \
- rbits,gbits,bbits) \
- const int thres = D[x%16][y%16]; \
- int r = qRed (*p); \
- if (r <= (255-(1<<(8-rbits))) && ((r<<rbits) & 255) \
- > thres) \
- r += (1<<(8-rbits)); \
- int g = qGreen(*p); \
- if (g <= (255-(1<<(8-gbits))) && ((g<<gbits) & 255) \
- > thres) \
- g += (1<<(8-gbits)); \
- int b = qBlue (*p++); \
- if (b <= (255-(1<<(8-bbits))) && ((b<<bbits) & 255) \
- > thres) \
- b += (1<<(8-bbits)); \
- uint pixel = ((r red_shift) & red_mask) \
- | ((g green_shift) & green_mask) \
- | ((b blue_shift) & blue_mask);
-
-#define CYCLE(body) \
- for (int y=0; y<h; y++) { \
- const uchar* src = cimage.scanLine(y); \
- uchar* dst = newbits + xi->bytes_per_line*y; \
- const QRgb* p = (const QRgb *)src; \
- body \
- }
-
- if (dither_tc) {
- switch (mode) {
- case BPP16_565:
- CYCLE(
- quint16* dst16 = (quint16*)dst;
- for (int x=0; x<w; x++) {
- GET_PIXEL_DITHER_TC_OPT(<<8,<<3,>>3,0xf800,0x7e0,0x1f,5,6,5)
- *dst16++ = pixel;
- }
- )
- break;
- case BPP16_555:
- CYCLE(
- quint16* dst16 = (quint16*)dst;
- for (int x=0; x<w; x++) {
- GET_PIXEL_DITHER_TC_OPT(<<7,<<2,>>3,0x7c00,0x3e0,0x1f,5,5,5)
- *dst16++ = pixel;
- }
- )
- break;
- case BPP16_MSB: // 16 bit MSB
- CYCLE(
- for (int x=0; x<w; x++) {
- GET_PIXEL_DITHER_TC
- *dst++ = (pixel >> 8);
- *dst++ = pixel;
- }
- )
- break;
- case BPP16_LSB: // 16 bit LSB
- CYCLE(
- for (int x=0; x<w; x++) {
- GET_PIXEL_DITHER_TC
- *dst++ = pixel;
- *dst++ = pixel >> 8;
- }
- )
- break;
- default:
- qFatal("Logic error");
- }
- } else {
- switch (mode) {
- case BPP8: // 8 bit
- CYCLE(
- Q_UNUSED(p);
- for (int x=0; x<w; x++)
- *dst++ = pix[*src++];
- )
- break;
- case BPP16_565:
- CYCLE(
- quint16* dst16 = (quint16*)dst;
- for (int x = 0; x < w; x++) {
- *dst16++ = ((*p >> 8) & 0xf800)
- | ((*p >> 5) & 0x7e0)
- | ((*p >> 3) & 0x1f);
- ++p;
- }
- )
- break;
- case BPP16_555:
- CYCLE(
- quint16* dst16 = (quint16*)dst;
- for (int x=0; x<w; x++) {
- *dst16++ = ((*p >> 9) & 0x7c00)
- | ((*p >> 6) & 0x3e0)
- | ((*p >> 3) & 0x1f);
- ++p;
- }
- )
- break;
- case BPP16_MSB: // 16 bit MSB
- CYCLE(
- for (int x=0; x<w; x++) {
- GET_PIXEL
- *dst++ = (pixel >> 8);
- *dst++ = pixel;
- }
- )
- break;
- case BPP16_LSB: // 16 bit LSB
- CYCLE(
- for (int x=0; x<w; x++) {
- GET_PIXEL
- *dst++ = pixel;
- *dst++ = pixel >> 8;
- }
- )
- break;
- case BPP24_888: // 24 bit MSB
- CYCLE(
- for (int x=0; x<w; x++) {
- *dst++ = qRed (*p);
- *dst++ = qGreen(*p);
- *dst++ = qBlue (*p++);
- }
- )
- break;
- case BPP24_MSB: // 24 bit MSB
- CYCLE(
- for (int x=0; x<w; x++) {
- GET_PIXEL
- *dst++ = pixel >> 16;
- *dst++ = pixel >> 8;
- *dst++ = pixel;
- }
- )
- break;
- case BPP24_LSB: // 24 bit LSB
- CYCLE(
- for (int x=0; x<w; x++) {
- GET_PIXEL
- *dst++ = pixel;
- *dst++ = pixel >> 8;
- *dst++ = pixel >> 16;
- }
- )
- break;
- case BPP32_8888:
- CYCLE(
- memcpy(dst, p, w * 4);
- )
- break;
- case BPP32_MSB: // 32 bit MSB
- CYCLE(
- for (int x=0; x<w; x++) {
- GET_PIXEL
- *dst++ = pixel >> 24;
- *dst++ = pixel >> 16;
- *dst++ = pixel >> 8;
- *dst++ = pixel;
- }
- )
- break;
- case BPP32_LSB: // 32 bit LSB
- CYCLE(
- for (int x=0; x<w; x++) {
- GET_PIXEL
- *dst++ = pixel;
- *dst++ = pixel >> 8;
- *dst++ = pixel >> 16;
- *dst++ = pixel >> 24;
- }
- )
- break;
- default:
- qFatal("Logic error 2");
- }
- }
- xi->data = (char *)newbits;
- }
-
- if (d == 8 && !trucol) { // 8 bit pixmap
- int pop[256]; // pixel popularity
-
- if (image.colorCount() == 0)
- image.setColorCount(1);
-
- const QImage &cimage = image;
- memset(pop, 0, sizeof(int)*256); // reset popularity array
- for (int i = 0; i < h; i++) { // for each scanline...
- const uchar* p = cimage.scanLine(i);
- const uchar *end = p + w;
- while (p < end) // compute popularity
- pop[*p++]++;
- }
-
- newbits = (uchar *)malloc(nbytes); // copy image into newbits
- Q_CHECK_PTR(newbits);
- if (!newbits) // no memory
- return;
- uchar* p = newbits;
- memcpy(p, cimage.bits(), nbytes); // copy image data into newbits
-
- /*
- * The code below picks the most important colors. It is based on the
- * diversity algorithm, implemented in XV 3.10. XV is (C) by John Bradley.
- */
-
- struct PIX { // pixel sort element
- uchar r,g,b,n; // color + pad
- int use; // popularity
- int index; // index in colormap
- int mindist;
- };
- int ncols = 0;
- for (int i=0; i< cimage.colorCount(); i++) { // compute number of colors
- if (pop[i] > 0)
- ncols++;
- }
- for (int i = cimage.colorCount(); i < 256; i++) // ignore out-of-range pixels
- pop[i] = 0;
-
- // works since we make sure above to have at least
- // one color in the image
- if (ncols == 0)
- ncols = 1;
-
- PIX pixarr[256]; // pixel array
- PIX pixarr_sorted[256]; // pixel array (sorted)
- memset(pixarr, 0, ncols*sizeof(PIX));
- PIX *px = &pixarr[0];
- int maxpop = 0;
- int maxpix = 0;
- uint j = 0;
- QVector<QRgb> ctable = cimage.colorTable();
- for (int i = 0; i < 256; i++) { // init pixel array
- if (pop[i] > 0) {
- px->r = qRed (ctable[i]);
- px->g = qGreen(ctable[i]);
- px->b = qBlue (ctable[i]);
- px->n = 0;
- px->use = pop[i];
- if (pop[i] > maxpop) { // select most popular entry
- maxpop = pop[i];
- maxpix = j;
- }
- px->index = i;
- px->mindist = 1000000;
- px++;
- j++;
- }
- }
- pixarr_sorted[0] = pixarr[maxpix];
- pixarr[maxpix].use = 0;
-
- for (int i = 1; i < ncols; i++) { // sort pixels
- int minpix = -1, mindist = -1;
- px = &pixarr_sorted[i-1];
- int r = px->r;
- int g = px->g;
- int b = px->b;
- int dist;
- if ((i & 1) || i<10) { // sort on max distance
- for (int j=0; j<ncols; j++) {
- px = &pixarr[j];
- if (px->use) {
- dist = (px->r - r)*(px->r - r) +
- (px->g - g)*(px->g - g) +
- (px->b - b)*(px->b - b);
- if (px->mindist > dist)
- px->mindist = dist;
- if (px->mindist > mindist) {
- mindist = px->mindist;
- minpix = j;
- }
- }
- }
- } else { // sort on max popularity
- for (int j=0; j<ncols; j++) {
- px = &pixarr[j];
- if (px->use) {
- dist = (px->r - r)*(px->r - r) +
- (px->g - g)*(px->g - g) +
- (px->b - b)*(px->b - b);
- if (px->mindist > dist)
- px->mindist = dist;
- if (px->use > mindist) {
- mindist = px->use;
- minpix = j;
- }
- }
- }
- }
- pixarr_sorted[i] = pixarr[minpix];
- pixarr[minpix].use = 0;
- }
-
- QColormap cmap = QColormap::instance(xinfo.screen());
- uint pix[256]; // pixel translation table
- px = &pixarr_sorted[0];
- for (int i = 0; i < ncols; i++) { // allocate colors
- QColor c(px->r, px->g, px->b);
- pix[px->index] = cmap.pixel(c);
- px++;
- }
-
- p = newbits;
- for (int i = 0; i < nbytes; i++) { // translate pixels
- *p = pix[*p];
- p++;
- }
- }
-
- if (!xi) { // X image not created
- xi = XCreateImage(dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0);
- if (xi->bits_per_pixel == 16) { // convert 8 bpp ==> 16 bpp
- ushort *p2;
- int p2inc = xi->bytes_per_line/sizeof(ushort);
- ushort *newerbits = (ushort *)malloc(xi->bytes_per_line * h);
- Q_CHECK_PTR(newerbits);
- if (!newerbits) // no memory
- return;
- uchar* p = newbits;
- for (int y = 0; y < h; y++) { // OOPS: Do right byte order!!
- p2 = newerbits + p2inc*y;
- for (int x = 0; x < w; x++)
- *p2++ = *p++;
- }
- free(newbits);
- newbits = (uchar *)newerbits;
- } else if (xi->bits_per_pixel != 8) {
- qWarning("QPixmap::fromImage: Display not supported "
- "(bpp=%d)", xi->bits_per_pixel);
- }
- xi->data = (char *)newbits;
- }
-
- hd = (Qt::HANDLE)XCreatePixmap(X11->display,
- RootWindow(X11->display, xinfo.screen()),
- w, h, dd);
-
- GC gc = XCreateGC(dpy, hd, 0, 0);
- XPutImage(dpy, hd, gc, xi, 0, 0, 0, 0, w, h);
- XFreeGC(dpy, gc);
-
- qSafeXDestroyImage(xi);
- d = dd;
-
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender) {
- XRenderPictFormat *format = d == 1
- ? XRenderFindStandardFormat(X11->display, PictStandardA1)
- : XRenderFindVisualFormat(X11->display, (Visual *)xinfo.visual());
- picture = XRenderCreatePicture(X11->display, hd, format, 0, 0);
- }
-#endif
-
- if (alphaCheck.hasAlpha()) {
- QBitmap m = QBitmap::fromImage(image.createAlphaMask(flags));
- setMask(m);
- }
-}
-
-Qt::HANDLE QX11PixmapData::createBitmapFromImage(const QImage &image)
-{
- QImage img = image.convertToFormat(QImage::Format_MonoLSB);
- const QRgb c0 = QColor(Qt::black).rgb();
- const QRgb c1 = QColor(Qt::white).rgb();
- if (img.color(0) == c0 && img.color(1) == c1) {
- img.invertPixels();
- img.setColor(0, c1);
- img.setColor(1, c0);
- }
-
- char *bits;
- uchar *tmp_bits;
- int w = img.width();
- int h = img.height();
- int bpl = (w + 7) / 8;
- int ibpl = img.bytesPerLine();
- if (bpl != ibpl) {
- tmp_bits = new uchar[bpl*h];
- bits = (char *)tmp_bits;
- uchar *p, *b;
- int y;
- b = tmp_bits;
- p = img.scanLine(0);
- for (y = 0; y < h; y++) {
- memcpy(b, p, bpl);
- b += bpl;
- p += ibpl;
- }
- } else {
- bits = (char *)img.bits();
- tmp_bits = 0;
- }
- Qt::HANDLE hd = (Qt::HANDLE)XCreateBitmapFromData(X11->display,
- QX11Info::appRootWindow(),
- bits, w, h);
- if (tmp_bits) // Avoid purify complaint
- delete [] tmp_bits;
- return hd;
-}
-
-void QX11PixmapData::bitmapFromImage(const QImage &image)
-{
- w = image.width();
- h = image.height();
- d = 1;
- is_null = (w <= 0 || h <= 0);
- hd = createBitmapFromImage(image);
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender)
- picture = XRenderCreatePicture(X11->display, hd,
- XRenderFindStandardFormat(X11->display, PictStandardA1), 0, 0);
-#endif // QT_NO_XRENDER
-}
-
-void QX11PixmapData::fill(const QColor &fillColor)
-{
- if (fillColor.alpha() != 255) {
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender) {
- if (!picture || d != 32)
- convertToARGB32(/*preserveContents = */false);
-
- ::Picture src = X11->getSolidFill(xinfo.screen(), fillColor);
- XRenderComposite(X11->display, PictOpSrc, src, 0, picture,
- 0, 0, width(), height(),
- 0, 0, width(), height());
- } else
-#endif
- {
- QImage im(width(), height(), QImage::Format_ARGB32_Premultiplied);
- im.fill(PREMUL(fillColor.rgba()));
- release();
- fromImage(im, Qt::AutoColor | Qt::OrderedAlphaDither);
- }
- return;
- }
-
- GC gc = XCreateGC(X11->display, hd, 0, 0);
- if (depth() == 1) {
- XSetForeground(X11->display, gc, qGray(fillColor.rgb()) > 127 ? 0 : 1);
- } else if (X11->use_xrender && d >= 24) {
- XSetForeground(X11->display, gc, fillColor.rgba());
- } else {
- XSetForeground(X11->display, gc,
- QColormap::instance(xinfo.screen()).pixel(fillColor));
- }
- XFillRectangle(X11->display, hd, gc, 0, 0, width(), height());
- XFreeGC(X11->display, gc);
-}
-
-QX11PixmapData::~QX11PixmapData()
-{
- // Cleanup hooks have to be called before the handles are freed
- if (is_cached) {
- QImagePixmapCleanupHooks::executePixmapDataDestructionHooks(this);
- is_cached = false;
- }
-
- release();
-}
-
-void QX11PixmapData::release()
-{
- delete pengine;
- pengine = 0;
-
- if (!X11) {
- // At this point, the X server will already have freed our resources,
- // so there is nothing to do.
- return;
- }
-
- if (x11_mask) {
-#ifndef QT_NO_XRENDER
- if (mask_picture)
- XRenderFreePicture(X11->display, mask_picture);
- mask_picture = 0;
-#endif
- XFreePixmap(X11->display, x11_mask);
- x11_mask = 0;
- }
-
- if (hd) {
-#ifndef QT_NO_XRENDER
- if (picture) {
- XRenderFreePicture(X11->display, picture);
- picture = 0;
- }
-#endif // QT_NO_XRENDER
-
- if (hd2) {
- XFreePixmap(xinfo.display(), hd2);
- hd2 = 0;
- }
- if (!(flags & Readonly))
- XFreePixmap(xinfo.display(), hd);
- hd = 0;
- }
-}
-
-QPixmap QX11PixmapData::alphaChannel() const
-{
- if (!hasAlphaChannel()) {
- QPixmap pm(w, h);
- pm.fill(Qt::white);
- return pm;
- }
- QImage im(toImage());
- return QPixmap::fromImage(im.alphaChannel(), Qt::OrderedDither);
-}
-
-void QX11PixmapData::setAlphaChannel(const QPixmap &alpha)
-{
- QImage image(toImage());
- image.setAlphaChannel(alpha.toImage());
- release();
- fromImage(image, Qt::OrderedDither | Qt::OrderedAlphaDither);
-}
-
-
-QBitmap QX11PixmapData::mask() const
-{
- QBitmap mask;
-#ifndef QT_NO_XRENDER
- if (picture && d == 32) {
- // #### slow - there must be a better way..
- mask = QBitmap::fromImage(toImage().createAlphaMask());
- } else
-#endif
- if (d == 1) {
- QX11PixmapData *that = const_cast<QX11PixmapData*>(this);
- mask = QPixmap(that);
- } else {
- mask = mask_to_bitmap(xinfo.screen());
- }
- return mask;
-}
-
-/*!
- Sets a mask bitmap.
-
- The \a newmask bitmap defines the clip mask for this pixmap. Every
- pixel in \a newmask corresponds to a pixel in this pixmap. Pixel
- value 1 means opaque and pixel value 0 means transparent. The mask
- must have the same size as this pixmap.
-
- \warning Setting the mask on a pixmap will cause any alpha channel
- data to be cleared. For example:
- \snippet doc/src/snippets/image/image.cpp 2
- Now, alpha and alphacopy are visually different.
-
- Setting a null mask resets the mask.
-
- The effect of this function is undefined when the pixmap is being
- painted on.
-
- \sa mask(), {QPixmap#Pixmap Transformations}{Pixmap
- Transformations}, QBitmap
-*/
-void QX11PixmapData::setMask(const QBitmap &newmask)
-{
- if (newmask.isNull()) { // clear mask
-#ifndef QT_NO_XRENDER
- if (picture && d == 32) {
- QX11PixmapData newData(pixelType());
- newData.resize(w, h);
- newData.fill(Qt::black);
- XRenderComposite(X11->display, PictOpOver,
- picture, 0, newData.picture,
- 0, 0, 0, 0, 0, 0, w, h);
- release();
- *this = newData;
- // the new QX11PixmapData object isn't referenced yet, so
- // ref it
- ref.ref();
-
- // the below is to make sure the QX11PixmapData destructor
- // doesn't delete our newly created render picture
- newData.hd = 0;
- newData.x11_mask = 0;
- newData.picture = 0;
- newData.mask_picture = 0;
- newData.hd2 = 0;
- } else
-#endif
- if (x11_mask) {
-#ifndef QT_NO_XRENDER
- if (picture) {
- XRenderPictureAttributes attrs;
- attrs.alpha_map = 0;
- XRenderChangePicture(X11->display, picture, CPAlphaMap,
- &attrs);
- }
- if (mask_picture)
- XRenderFreePicture(X11->display, mask_picture);
- mask_picture = 0;
-#endif
- XFreePixmap(X11->display, x11_mask);
- x11_mask = 0;
- }
- return;
- }
-
-#ifndef QT_NO_XRENDER
- if (picture && d == 32) {
- XRenderComposite(X11->display, PictOpSrc,
- picture, newmask.x11PictureHandle(),
- picture, 0, 0, 0, 0, 0, 0, w, h);
- } else
-#endif
- if (depth() == 1) {
- XGCValues vals;
- vals.function = GXand;
- GC gc = XCreateGC(X11->display, hd, GCFunction, &vals);
- XCopyArea(X11->display, newmask.handle(), hd, gc, 0, 0,
- width(), height(), 0, 0);
- XFreeGC(X11->display, gc);
- } else {
- // ##### should or the masks together
- if (x11_mask) {
- XFreePixmap(X11->display, x11_mask);
-#ifndef QT_NO_XRENDER
- if (mask_picture)
- XRenderFreePicture(X11->display, mask_picture);
-#endif
- }
- x11_mask = QX11PixmapData::bitmap_to_mask(newmask, xinfo.screen());
-#ifndef QT_NO_XRENDER
- if (picture) {
- mask_picture = XRenderCreatePicture(X11->display, x11_mask,
- XRenderFindStandardFormat(X11->display, PictStandardA1), 0, 0);
- XRenderPictureAttributes attrs;
- attrs.alpha_map = mask_picture;
- XRenderChangePicture(X11->display, picture, CPAlphaMap, &attrs);
- }
-#endif
- }
-}
-
-int QX11PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
-{
- switch (metric) {
- case QPaintDevice::PdmWidth:
- return w;
- case QPaintDevice::PdmHeight:
- return h;
- case QPaintDevice::PdmNumColors:
- return 1 << d;
- case QPaintDevice::PdmDepth:
- return d;
- case QPaintDevice::PdmWidthMM: {
- const int screen = xinfo.screen();
- const int mm = DisplayWidthMM(X11->display, screen) * w
- / DisplayWidth(X11->display, screen);
- return mm;
- }
- case QPaintDevice::PdmHeightMM: {
- const int screen = xinfo.screen();
- const int mm = (DisplayHeightMM(X11->display, screen) * h)
- / DisplayHeight(X11->display, screen);
- return mm;
- }
- case QPaintDevice::PdmDpiX:
- case QPaintDevice::PdmPhysicalDpiX:
- return QX11Info::appDpiX(xinfo.screen());
- case QPaintDevice::PdmDpiY:
- case QPaintDevice::PdmPhysicalDpiY:
- return QX11Info::appDpiY(xinfo.screen());
- default:
- qWarning("QX11PixmapData::metric(): Invalid metric");
- return 0;
- }
-}
-
-struct QXImageWrapper
-{
- XImage *xi;
-};
-
-bool QX11PixmapData::canTakeQImageFromXImage(const QXImageWrapper &xiWrapper) const
-{
- XImage *xi = xiWrapper.xi;
-
- // ARGB32_Premultiplied
- if (picture && depth() == 32)
- return true;
-
- Visual *visual = (Visual *)xinfo.visual();
-
- // RGB32
- if (depth() == 24 && xi->bits_per_pixel == 32 && visual->red_mask == 0xff0000
- && visual->green_mask == 0xff00 && visual->blue_mask == 0xff)
- return true;
-
- // RGB16
- if (depth() == 16 && xi->bits_per_pixel == 16 && visual->red_mask == 0xf800
- && visual->green_mask == 0x7e0 && visual->blue_mask == 0x1f)
- return true;
-
- return false;
-}
-
-QImage QX11PixmapData::takeQImageFromXImage(const QXImageWrapper &xiWrapper) const
-{
- XImage *xi = xiWrapper.xi;
-
- QImage::Format format = QImage::Format_ARGB32_Premultiplied;
- if (depth() == 24)
- format = QImage::Format_RGB32;
- else if (depth() == 16)
- format = QImage::Format_RGB16;
-
- QImage image((uchar *)xi->data, xi->width, xi->height, xi->bytes_per_line, format);
- // take ownership
- image.data_ptr()->own_data = true;
- xi->data = 0;
-
- // we may have to swap the byte order
- if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst)
- || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst))
- {
- for (int i=0; i < image.height(); i++) {
- if (depth() == 16) {
- ushort *p = (ushort*)image.scanLine(i);
- ushort *end = p + image.width();
- while (p < end) {
- *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff);
- p++;
- }
- } else {
- uint *p = (uint*)image.scanLine(i);
- uint *end = p + image.width();
- while (p < end) {
- *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
- | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
- p++;
- }
- }
- }
- }
-
- // fix-up alpha channel
- if (format == QImage::Format_RGB32) {
- QRgb *p = (QRgb *)image.bits();
- for (int y = 0; y < xi->height; ++y) {
- for (int x = 0; x < xi->width; ++x)
- p[x] |= 0xff000000;
- p += xi->bytes_per_line / 4;
- }
- }
-
- XDestroyImage(xi);
- return image;
-}
-
-QImage QX11PixmapData::toImage(const QRect &rect) const
-{
- QXImageWrapper xiWrapper;
- xiWrapper.xi = XGetImage(X11->display, hd, rect.x(), rect.y(), rect.width(), rect.height(),
- AllPlanes, (depth() == 1) ? XYPixmap : ZPixmap);
-
- Q_CHECK_PTR(xiWrapper.xi);
- if (!xiWrapper.xi)
- return QImage();
-
- if (!x11_mask && canTakeQImageFromXImage(xiWrapper))
- return takeQImageFromXImage(xiWrapper);
-
- QImage image = toImage(xiWrapper, rect);
- qSafeXDestroyImage(xiWrapper.xi);
- return image;
-}
-
-/*!
- Converts the pixmap to a QImage. Returns a null image if the
- conversion fails.
-
- If the pixmap has 1-bit depth, the returned image will also be 1
- bit deep. If the pixmap has 2- to 8-bit depth, the returned image
- has 8-bit depth. If the pixmap has greater than 8-bit depth, the
- returned image has 32-bit depth.
-
- Note that for the moment, alpha masks on monochrome images are
- ignored.
-
- \sa fromImage(), {QImage#Image Formats}{Image Formats}
-*/
-
-QImage QX11PixmapData::toImage() const
-{
- return toImage(QRect(0, 0, w, h));
-}
-
-QImage QX11PixmapData::toImage(const QXImageWrapper &xiWrapper, const QRect &rect) const
-{
- XImage *xi = xiWrapper.xi;
-
- int d = depth();
- Visual *visual = (Visual *)xinfo.visual();
- bool trucol = (visual->c_class >= TrueColor) && d > 1;
-
- QImage::Format format = QImage::Format_Mono;
- if (d > 1 && d <= 8) {
- d = 8;
- format = QImage::Format_Indexed8;
- }
- // we could run into the situation where d == 8 AND trucol is true, which can
- // cause problems when converting to and from images. in this case, always treat
- // the depth as 32...
- if (d > 8 || trucol) {
- d = 32;
- format = QImage::Format_RGB32;
- }
-
- if (d == 1 && xi->bitmap_bit_order == LSBFirst)
- format = QImage::Format_MonoLSB;
- if (x11_mask && format == QImage::Format_RGB32)
- format = QImage::Format_ARGB32;
-
- QImage image(xi->width, xi->height, format);
- if (image.isNull()) // could not create image
- return image;
-
- QImage alpha;
- if (x11_mask) {
- if (rect.contains(QRect(0, 0, w, h)))
- alpha = mask().toImage();
- else
- alpha = mask().toImage().copy(rect);
- }
- bool ale = alpha.format() == QImage::Format_MonoLSB;
-
- if (trucol) { // truecolor
- const uint red_mask = (uint)visual->red_mask;
- const uint green_mask = (uint)visual->green_mask;
- const uint blue_mask = (uint)visual->blue_mask;
- const int red_shift = highest_bit(red_mask) - 7;
- const int green_shift = highest_bit(green_mask) - 7;
- const int blue_shift = highest_bit(blue_mask) - 7;
-
- const uint red_bits = n_bits(red_mask);
- const uint green_bits = n_bits(green_mask);
- const uint blue_bits = n_bits(blue_mask);
-
- static uint red_table_bits = 0;
- static uint green_table_bits = 0;
- static uint blue_table_bits = 0;
-
- if (red_bits < 8 && red_table_bits != red_bits) {
- build_scale_table(&red_scale_table, red_bits);
- red_table_bits = red_bits;
- }
- if (blue_bits < 8 && blue_table_bits != blue_bits) {
- build_scale_table(&blue_scale_table, blue_bits);
- blue_table_bits = blue_bits;
- }
- if (green_bits < 8 && green_table_bits != green_bits) {
- build_scale_table(&green_scale_table, green_bits);
- green_table_bits = green_bits;
- }
-
- int r, g, b;
-
- QRgb *dst;
- uchar *src;
- uint pixel;
- int bppc = xi->bits_per_pixel;
-
- if (bppc > 8 && xi->byte_order == LSBFirst)
- bppc++;
-
- for (int y = 0; y < xi->height; ++y) {
- uchar* asrc = x11_mask ? alpha.scanLine(y) : 0;
- dst = (QRgb *)image.scanLine(y);
- src = (uchar *)xi->data + xi->bytes_per_line*y;
- for (int x = 0; x < xi->width; x++) {
- switch (bppc) {
- case 8:
- pixel = *src++;
- break;
- case 16: // 16 bit MSB
- pixel = src[1] | (uint)src[0] << 8;
- src += 2;
- break;
- case 17: // 16 bit LSB
- pixel = src[0] | (uint)src[1] << 8;
- src += 2;
- break;
- case 24: // 24 bit MSB
- pixel = src[2] | (uint)src[1] << 8 | (uint)src[0] << 16;
- src += 3;
- break;
- case 25: // 24 bit LSB
- pixel = src[0] | (uint)src[1] << 8 | (uint)src[2] << 16;
- src += 3;
- break;
- case 32: // 32 bit MSB
- pixel = src[3] | (uint)src[2] << 8 | (uint)src[1] << 16 | (uint)src[0] << 24;
- src += 4;
- break;
- case 33: // 32 bit LSB
- pixel = src[0] | (uint)src[1] << 8 | (uint)src[2] << 16 | (uint)src[3] << 24;
- src += 4;
- break;
- default: // should not really happen
- x = xi->width; // leave loop
- y = xi->height;
- pixel = 0; // eliminate compiler warning
- qWarning("QPixmap::convertToImage: Invalid depth %d", bppc);
- }
- if (red_shift > 0)
- r = (pixel & red_mask) >> red_shift;
- else
- r = (pixel & red_mask) << -red_shift;
- if (green_shift > 0)
- g = (pixel & green_mask) >> green_shift;
- else
- g = (pixel & green_mask) << -green_shift;
- if (blue_shift > 0)
- b = (pixel & blue_mask) >> blue_shift;
- else
- b = (pixel & blue_mask) << -blue_shift;
-
- if (red_bits < 8)
- r = red_scale_table[r];
- if (green_bits < 8)
- g = green_scale_table[g];
- if (blue_bits < 8)
- b = blue_scale_table[b];
-
- if (x11_mask) {
- if (ale) {
- *dst++ = (asrc[x >> 3] & (1 << (x & 7))) ? qRgba(r, g, b, 0xff) : 0;
- } else {
- *dst++ = (asrc[x >> 3] & (0x80 >> (x & 7))) ? qRgba(r, g, b, 0xff) : 0;
- }
- } else {
- *dst++ = qRgb(r, g, b);
- }
- }
- }
- } else if (xi->bits_per_pixel == d) { // compatible depth
- char *xidata = xi->data; // copy each scanline
- int bpl = qMin(image.bytesPerLine(),xi->bytes_per_line);
- for (int y=0; y<xi->height; y++) {
- memcpy(image.scanLine(y), xidata, bpl);
- xidata += xi->bytes_per_line;
- }
- } else {
- /* Typically 2 or 4 bits display depth */
- qWarning("QPixmap::convertToImage: Display not supported (bpp=%d)",
- xi->bits_per_pixel);
- return QImage();
- }
-
- if (d == 1) { // bitmap
- image.setColorCount(2);
- image.setColor(0, qRgb(255,255,255));
- image.setColor(1, qRgb(0,0,0));
- } else if (!trucol) { // pixmap with colormap
- register uchar *p;
- uchar *end;
- uchar use[256]; // pixel-in-use table
- uchar pix[256]; // pixel translation table
- int ncols, bpl;
- memset(use, 0, 256);
- memset(pix, 0, 256);
- bpl = image.bytesPerLine();
-
- if (x11_mask) { // which pixels are used?
- for (int i = 0; i < xi->height; i++) {
- uchar* asrc = alpha.scanLine(i);
- p = image.scanLine(i);
- if (ale) {
- for (int x = 0; x < xi->width; x++) {
- if (asrc[x >> 3] & (1 << (x & 7)))
- use[*p] = 1;
- ++p;
- }
- } else {
- for (int x = 0; x < xi->width; x++) {
- if (asrc[x >> 3] & (0x80 >> (x & 7)))
- use[*p] = 1;
- ++p;
- }
- }
- }
- } else {
- for (int i = 0; i < xi->height; i++) {
- p = image.scanLine(i);
- end = p + bpl;
- while (p < end)
- use[*p++] = 1;
- }
- }
- ncols = 0;
- for (int i = 0; i < 256; i++) { // build translation table
- if (use[i])
- pix[i] = ncols++;
- }
- for (int i = 0; i < xi->height; i++) { // translate pixels
- p = image.scanLine(i);
- end = p + bpl;
- while (p < end) {
- *p = pix[*p];
- p++;
- }
- }
- if (x11_mask) {
- int trans;
- if (ncols < 256) {
- trans = ncols++;
- image.setColorCount(ncols); // create color table
- image.setColor(trans, 0x00000000);
- } else {
- image.setColorCount(ncols); // create color table
- // oh dear... no spare "transparent" pixel.
- // use first pixel in image (as good as any).
- trans = image.scanLine(0)[0];
- }
- for (int i = 0; i < xi->height; i++) {
- uchar* asrc = alpha.scanLine(i);
- p = image.scanLine(i);
- if (ale) {
- for (int x = 0; x < xi->width; x++) {
- if (!(asrc[x >> 3] & (1 << (x & 7))))
- *p = trans;
- ++p;
- }
- } else {
- for (int x = 0; x < xi->width; x++) {
- if (!(asrc[x >> 3] & (1 << (7 -(x & 7)))))
- *p = trans;
- ++p;
- }
- }
- }
- } else {
- image.setColorCount(ncols); // create color table
- }
- QVector<QColor> colors = QColormap::instance(xinfo.screen()).colormap();
- int j = 0;
- for (int i=0; i<colors.size(); i++) { // translate pixels
- if (use[i])
- image.setColor(j++, 0xff000000 | colors.at(i).rgb());
- }
- }
-
- return image;
-}
-
-/*!
- Returns a copy of the pixmap that is transformed using the given
- transformation \a matrix and transformation \a mode. The original
- pixmap is not changed.
-
- The transformation \a matrix is internally adjusted to compensate
- for unwanted translation; i.e. the pixmap produced is the smallest
- pixmap that contains all the transformed points of the original
- pixmap. Use the trueMatrix() function to retrieve the actual
- matrix used for transforming the pixmap.
-
- This function is slow because it involves transformation to a
- QImage, non-trivial computations and a transformation back to a
- QPixmap.
-
- \sa trueMatrix(), {QPixmap#Pixmap Transformations}{Pixmap
- Transformations}
-*/
-QPixmap QX11PixmapData::transformed(const QTransform &transform,
- Qt::TransformationMode mode ) const
-{
- if (mode == Qt::SmoothTransformation || transform.type() >= QTransform::TxProject) {
- QImage image = toImage();
- return QPixmap::fromImage(image.transformed(transform, mode));
- }
-
- uint w = 0;
- uint h = 0; // size of target pixmap
- uint ws, hs; // size of source pixmap
- uchar *dptr; // data in target pixmap
- uint dbpl, dbytes; // bytes per line/bytes total
- uchar *sptr; // data in original pixmap
- int sbpl; // bytes per line in original
- int bpp; // bits per pixel
- bool depth1 = depth() == 1;
- Display *dpy = X11->display;
-
- ws = width();
- hs = height();
-
- QTransform mat(transform.m11(), transform.m12(), transform.m13(),
- transform.m21(), transform.m22(), transform.m23(),
- 0., 0., 1);
- bool complex_xform = false;
- qreal scaledWidth;
- qreal scaledHeight;
-
- if (mat.type() <= QTransform::TxScale) {
- scaledHeight = qAbs(mat.m22()) * hs + 0.9999;
- scaledWidth = qAbs(mat.m11()) * ws + 0.9999;
- h = qAbs(int(scaledHeight));
- w = qAbs(int(scaledWidth));
- } else { // rotation or shearing
- QPolygonF a(QRectF(0, 0, ws, hs));
- a = mat.map(a);
- QRect r = a.boundingRect().toAlignedRect();
- w = r.width();
- h = r.height();
- scaledWidth = w;
- scaledHeight = h;
- complex_xform = true;
- }
- mat = QPixmap::trueMatrix(mat, ws, hs); // true matrix
-
- bool invertible;
- mat = mat.inverted(&invertible); // invert matrix
-
- if (h == 0 || w == 0 || !invertible
- || qAbs(scaledWidth) >= 32768 || qAbs(scaledHeight) >= 32768 )
- // error, return null pixmap
- return QPixmap();
-
-#if defined(QT_MITSHM)
- static bool try_once = true;
- if (try_once) {
- try_once = false;
- if (!xshminit)
- qt_create_mitshm_buffer(this, 800, 600);
- }
-
- bool use_mitshm = xshmimg && !depth1 &&
- xshmimg->width >= w && xshmimg->height >= h;
-#endif
- XImage *xi = XGetImage(X11->display, handle(), 0, 0, ws, hs, AllPlanes,
- depth1 ? XYPixmap : ZPixmap);
-
- if (!xi)
- return QPixmap();
-
- sbpl = xi->bytes_per_line;
- sptr = (uchar *)xi->data;
- bpp = xi->bits_per_pixel;
-
- if (depth1)
- dbpl = (w+7)/8;
- else
- dbpl = ((w*bpp+31)/32)*4;
- dbytes = dbpl*h;
-
-#if defined(QT_MITSHM)
- if (use_mitshm) {
- dptr = (uchar *)xshmimg->data;
- uchar fillbyte = bpp == 8 ? white.pixel() : 0xff;
- for (int y=0; y<h; y++)
- memset(dptr + y*xshmimg->bytes_per_line, fillbyte, dbpl);
- } else {
-#endif
- dptr = (uchar *)malloc(dbytes); // create buffer for bits
- Q_CHECK_PTR(dptr);
- if (depth1) // fill with zeros
- memset(dptr, 0, dbytes);
- else if (bpp == 8) // fill with background color
- memset(dptr, WhitePixel(X11->display, xinfo.screen()), dbytes);
- else
- memset(dptr, 0, dbytes);
-#if defined(QT_MITSHM)
- }
-#endif
-
- // #define QT_DEBUG_XIMAGE
-#if defined(QT_DEBUG_XIMAGE)
- qDebug("----IMAGE--INFO--------------");
- qDebug("width............. %d", xi->width);
- qDebug("height............ %d", xi->height);
- qDebug("xoffset........... %d", xi->xoffset);
- qDebug("format............ %d", xi->format);
- qDebug("byte order........ %d", xi->byte_order);
- qDebug("bitmap unit....... %d", xi->bitmap_unit);
- qDebug("bitmap bit order.. %d", xi->bitmap_bit_order);
- qDebug("depth............. %d", xi->depth);
- qDebug("bytes per line.... %d", xi->bytes_per_line);
- qDebug("bits per pixel.... %d", xi->bits_per_pixel);
-#endif
-
- int type;
- if (xi->bitmap_bit_order == MSBFirst)
- type = QT_XFORM_TYPE_MSBFIRST;
- else
- type = QT_XFORM_TYPE_LSBFIRST;
- int xbpl, p_inc;
- if (depth1) {
- xbpl = (w+7)/8;
- p_inc = dbpl - xbpl;
- } else {
- xbpl = (w*bpp)/8;
- p_inc = dbpl - xbpl;
-#if defined(QT_MITSHM)
- if (use_mitshm)
- p_inc = xshmimg->bytes_per_line - xbpl;
-#endif
- }
-
- if (!qt_xForm_helper(mat, xi->xoffset, type, bpp, dptr, xbpl, p_inc, h, sptr, sbpl, ws, hs)){
- qWarning("QPixmap::transform: display not supported (bpp=%d)",bpp);
- QPixmap pm;
- return pm;
- }
-
- qSafeXDestroyImage(xi);
-
- if (depth1) { // mono bitmap
- QBitmap bm = QBitmap::fromData(QSize(w, h), dptr,
- BitmapBitOrder(X11->display) == MSBFirst
- ? QImage::Format_Mono
- : QImage::Format_MonoLSB);
- free(dptr);
- return bm;
- } else { // color pixmap
- QX11PixmapData *x11Data = new QX11PixmapData(QPixmapData::PixmapType);
- QPixmap pm(x11Data);
- x11Data->flags &= ~QX11PixmapData::Uninitialized;
- x11Data->xinfo = xinfo;
- x11Data->d = d;
- x11Data->w = w;
- x11Data->h = h;
- x11Data->is_null = (w <= 0 || h <= 0);
- x11Data->hd = (Qt::HANDLE)XCreatePixmap(X11->display,
- RootWindow(X11->display, xinfo.screen()),
- w, h, d);
- x11Data->setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
-
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender) {
- XRenderPictFormat *format = x11Data->d == 32
- ? XRenderFindStandardFormat(X11->display, PictStandardARGB32)
- : XRenderFindVisualFormat(X11->display, (Visual *) x11Data->xinfo.visual());
- x11Data->picture = XRenderCreatePicture(X11->display, x11Data->hd, format, 0, 0);
- }
-#endif // QT_NO_XRENDER
-
- GC gc = XCreateGC(X11->display, x11Data->hd, 0, 0);
-#if defined(QT_MITSHM)
- if (use_mitshm) {
- XCopyArea(dpy, xshmpm, x11Data->hd, gc, 0, 0, w, h, 0, 0);
- } else
-#endif
- {
- xi = XCreateImage(dpy, (Visual*)x11Data->xinfo.visual(),
- x11Data->d,
- ZPixmap, 0, (char *)dptr, w, h, 32, 0);
- XPutImage(dpy, pm.handle(), gc, xi, 0, 0, 0, 0, w, h);
- qSafeXDestroyImage(xi);
- }
- XFreeGC(X11->display, gc);
-
- if (x11_mask) { // xform mask, too
- pm.setMask(mask_to_bitmap(xinfo.screen()).transformed(transform));
- } else if (d != 32 && complex_xform) { // need a mask!
- QBitmap mask(ws, hs);
- mask.fill(Qt::color1);
- pm.setMask(mask.transformed(transform));
- }
- return pm;
- }
-}
-
-int QPixmap::x11SetDefaultScreen(int screen)
-{
- int old = defaultScreen;
- defaultScreen = screen;
- return old;
-}
-
-void QPixmap::x11SetScreen(int screen)
-{
- if (paintingActive()) {
- qWarning("QPixmap::x11SetScreen(): Cannot change screens during painting");
- return;
- }
-
- if (isNull())
- return;
-
- if (data->classId() != QPixmapData::X11Class)
- return;
-
- if (screen < 0)
- screen = QX11Info::appScreen();
-
- QX11PixmapData *x11Data = static_cast<QX11PixmapData*>(data.data());
- if (screen == x11Data->xinfo.screen())
- return; // nothing to do
-
- if (isNull()) {
- QX11InfoData* xd = x11Data->xinfo.getX11Data(true);
- xd->screen = screen;
- xd->depth = QX11Info::appDepth(screen);
- xd->cells = QX11Info::appCells(screen);
- xd->colormap = QX11Info::appColormap(screen);
- xd->defaultColormap = QX11Info::appDefaultColormap(screen);
- xd->visual = (Visual *)QX11Info::appVisual(screen);
- xd->defaultVisual = QX11Info::appDefaultVisual(screen);
- x11Data->xinfo.setX11Data(xd);
- return;
- }
-#if 0
- qDebug("QPixmap::x11SetScreen for %p from %d to %d. Size is %d/%d", x11Data, x11Data->xinfo.screen(), screen, width(), height());
-#endif
-
- x11SetDefaultScreen(screen);
- *this = qt_toX11Pixmap(toImage());
-}
-
-QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
-{
- if (w == 0 || h == 0)
- return QPixmap();
-
- Display *dpy = X11->display;
- XWindowAttributes window_attr;
- if (!XGetWindowAttributes(dpy, window, &window_attr))
- return QPixmap();
-
- if (w < 0)
- w = window_attr.width - x;
- if (h < 0)
- h = window_attr.height - y;
-
- // determine the screen
- int scr;
- for (scr = 0; scr < ScreenCount(dpy); ++scr) {
- if (window_attr.root == RootWindow(dpy, scr)) // found it
- break;
- }
- if (scr >= ScreenCount(dpy)) // sanity check
- return QPixmap();
-
-
- // get the depth of the root window
- XWindowAttributes root_attr;
- if (!XGetWindowAttributes(dpy, window_attr.root, &root_attr))
- return QPixmap();
-
- if (window_attr.depth == root_attr.depth) {
- // if the depth of the specified window and the root window are the
- // same, grab pixels from the root window (so that we get the any
- // overlapping windows and window manager frames)
-
- // map x and y to the root window
- WId unused;
- if (!XTranslateCoordinates(dpy, window, window_attr.root, x, y,
- &x, &y, &unused))
- return QPixmap();
-
- window = window_attr.root;
- window_attr = root_attr;
- }
-
- QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
-
- void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const XWindowAttributes &a);
- qt_x11_getX11InfoForWindow(&data->xinfo,window_attr);
-
- data->resize(w, h);
-
- QPixmap pm(data);
-
- data->flags &= ~QX11PixmapData::Uninitialized;
- pm.x11SetScreen(scr);
-
- GC gc = XCreateGC(dpy, pm.handle(), 0, 0);
- XSetSubwindowMode(dpy, gc, IncludeInferiors);
- XCopyArea(dpy, window, pm.handle(), gc, x, y, w, h, 0, 0);
- XFreeGC(dpy, gc);
-
- return pm;
-}
-
-bool QX11PixmapData::hasAlphaChannel() const
-{
- return d == 32;
-}
-
-const QX11Info &QPixmap::x11Info() const
-{
- if (data && data->classId() == QPixmapData::X11Class)
- return static_cast<QX11PixmapData*>(data.data())->xinfo;
- else {
- static QX11Info nullX11Info;
- return nullX11Info;
- }
-}
-
-#if !defined(QT_NO_XRENDER)
-static XRenderPictFormat *qt_renderformat_for_depth(const QX11Info &xinfo, int depth)
-{
- if (depth == 1)
- return XRenderFindStandardFormat(X11->display, PictStandardA1);
- else if (depth == 32)
- return XRenderFindStandardFormat(X11->display, PictStandardARGB32);
- else
- return XRenderFindVisualFormat(X11->display, (Visual *)xinfo.visual());
-}
-#endif
-
-QPaintEngine* QX11PixmapData::paintEngine() const
-{
- QX11PixmapData *that = const_cast<QX11PixmapData*>(this);
-
- if ((flags & Readonly) && share_mode == QPixmap::ImplicitlyShared) {
- // if someone wants to draw onto us, copy the shared contents
- // and turn it into a fully fledged QPixmap
- ::Pixmap hd_copy = XCreatePixmap(X11->display, RootWindow(X11->display, xinfo.screen()),
- w, h, d);
-#if !defined(QT_NO_XRENDER)
- XRenderPictFormat *format = qt_renderformat_for_depth(xinfo, d);
- ::Picture picture_copy = XRenderCreatePicture(X11->display, hd_copy, format, 0, 0);
-
- if (picture && d == 32) {
- XRenderComposite(X11->display, PictOpSrc, picture, 0, picture_copy,
- 0, 0, 0, 0, 0, 0, w, h);
- XRenderFreePicture(X11->display, picture);
- that->picture = picture_copy;
- } else
-#endif
- {
- GC gc = XCreateGC(X11->display, hd_copy, 0, 0);
- XCopyArea(X11->display, hd, hd_copy, gc, 0, 0, w, h, 0, 0);
- XFreeGC(X11->display, gc);
- }
- that->hd = hd_copy;
- that->flags &= ~QX11PixmapData::Readonly;
- }
-
- if (!that->pengine)
- that->pengine = new QX11PaintEngine;
- return that->pengine;
-}
-
-Qt::HANDLE QPixmap::x11PictureHandle() const
-{
-#ifndef QT_NO_XRENDER
- if (data && data->classId() == QPixmapData::X11Class)
- return static_cast<const QX11PixmapData*>(data.data())->picture;
- else
- return 0;
-#else
- return 0;
-#endif // QT_NO_XRENDER
-}
-
-Qt::HANDLE QX11PixmapData::x11ConvertToDefaultDepth()
-{
-#ifndef QT_NO_XRENDER
- if (d == QX11Info::appDepth() || !X11->use_xrender)
- return hd;
- if (!hd2) {
- hd2 = XCreatePixmap(xinfo.display(), hd, w, h, QX11Info::appDepth());
- XRenderPictFormat *format = XRenderFindVisualFormat(xinfo.display(),
- (Visual*) xinfo.visual());
- Picture pic = XRenderCreatePicture(xinfo.display(), hd2, format, 0, 0);
- XRenderComposite(xinfo.display(), PictOpSrc, picture,
- XNone, pic, 0, 0, 0, 0, 0, 0, w, h);
- XRenderFreePicture(xinfo.display(), pic);
- }
- return hd2;
-#else
- return hd;
-#endif
-}
-
-void QX11PixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- if (data->pixelType() == BitmapType) {
- fromImage(data->toImage().copy(rect), Qt::AutoColor);
- return;
- }
-
- const QX11PixmapData *x11Data = static_cast<const QX11PixmapData*>(data);
-
- setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
-
- flags &= ~Uninitialized;
- xinfo = x11Data->xinfo;
- d = x11Data->d;
- w = rect.width();
- h = rect.height();
- is_null = (w <= 0 || h <= 0);
- hd = (Qt::HANDLE)XCreatePixmap(X11->display,
- RootWindow(X11->display, x11Data->xinfo.screen()),
- w, h, d);
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender) {
- XRenderPictFormat *format = d == 32
- ? XRenderFindStandardFormat(X11->display, PictStandardARGB32)
- : XRenderFindVisualFormat(X11->display, (Visual *)xinfo.visual());
- picture = XRenderCreatePicture(X11->display, hd, format, 0, 0);
- }
-#endif // QT_NO_XRENDER
- if (x11Data->x11_mask) {
- x11_mask = XCreatePixmap(X11->display, hd, w, h, 1);
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender) {
- mask_picture = XRenderCreatePicture(X11->display, x11_mask,
- XRenderFindStandardFormat(X11->display, PictStandardA1), 0, 0);
- XRenderPictureAttributes attrs;
- attrs.alpha_map = x11Data->mask_picture;
- XRenderChangePicture(X11->display, x11Data->picture, CPAlphaMap, &attrs);
- }
-#endif
- }
-
-#if !defined(QT_NO_XRENDER)
- if (x11Data->picture && x11Data->d == 32) {
- XRenderComposite(X11->display, PictOpSrc,
- x11Data->picture, 0, picture,
- rect.x(), rect.y(), 0, 0, 0, 0, w, h);
- } else
-#endif
- {
- GC gc = XCreateGC(X11->display, hd, 0, 0);
- XCopyArea(X11->display, x11Data->hd, hd, gc,
- rect.x(), rect.y(), w, h, 0, 0);
- if (x11Data->x11_mask) {
- GC monogc = XCreateGC(X11->display, x11_mask, 0, 0);
- XCopyArea(X11->display, x11Data->x11_mask, x11_mask, monogc,
- rect.x(), rect.y(), w, h, 0, 0);
- XFreeGC(X11->display, monogc);
- }
- XFreeGC(X11->display, gc);
- }
-}
-
-bool QX11PixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- GC gc = XCreateGC(X11->display, hd, 0, 0);
- XCopyArea(X11->display, hd, hd, gc,
- rect.left(), rect.top(), rect.width(), rect.height(),
- rect.left() + dx, rect.top() + dy);
- XFreeGC(X11->display, gc);
- return true;
-}
-
-#if !defined(QT_NO_XRENDER)
-void QX11PixmapData::convertToARGB32(bool preserveContents)
-{
- if (!X11->use_xrender)
- return;
-
- // Q_ASSERT(count == 1);
- if ((flags & Readonly) && share_mode == QPixmap::ExplicitlyShared)
- return;
-
- Pixmap pm = XCreatePixmap(X11->display, RootWindow(X11->display, xinfo.screen()),
- w, h, 32);
- Picture p = XRenderCreatePicture(X11->display, pm,
- XRenderFindStandardFormat(X11->display, PictStandardARGB32), 0, 0);
- if (picture) {
- if (preserveContents)
- XRenderComposite(X11->display, PictOpSrc, picture, 0, p, 0, 0, 0, 0, 0, 0, w, h);
- if (!(flags & Readonly))
- XRenderFreePicture(X11->display, picture);
- }
- if (hd && !(flags & Readonly))
- XFreePixmap(X11->display, hd);
- if (x11_mask) {
- XFreePixmap(X11->display, x11_mask);
- if (mask_picture)
- XRenderFreePicture(X11->display, mask_picture);
- x11_mask = 0;
- mask_picture = 0;
- }
- hd = pm;
- picture = p;
- d = 32;
-}
-#endif
-
-QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap, QPixmap::ShareMode mode)
-{
- Window root;
- int x;
- int y;
- uint width;
- uint height;
- uint border_width;
- uint depth;
- XWindowAttributes win_attribs;
- int num_screens = ScreenCount(X11->display);
- int screen = 0;
-
- XGetGeometry(X11->display, pixmap, &root, &x, &y, &width, &height, &border_width, &depth);
- XGetWindowAttributes(X11->display, root, &win_attribs);
-
- for (; screen < num_screens; ++screen) {
- if (win_attribs.screen == ScreenOfDisplay(X11->display, screen))
- break;
- }
-
- QX11PixmapData *data = new QX11PixmapData(depth == 1 ? QPixmapData::BitmapType : QPixmapData::PixmapType);
- data->setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
- data->flags = QX11PixmapData::Readonly;
- data->share_mode = mode;
- data->w = width;
- data->h = height;
- data->is_null = (width <= 0 || height <= 0);
- data->d = depth;
- data->hd = pixmap;
-
- if (defaultScreen >= 0 && defaultScreen != screen) {
- QX11InfoData* xd = data->xinfo.getX11Data(true);
- xd->screen = defaultScreen;
- xd->depth = QX11Info::appDepth(xd->screen);
- xd->cells = QX11Info::appCells(xd->screen);
- xd->colormap = QX11Info::appColormap(xd->screen);
- xd->defaultColormap = QX11Info::appDefaultColormap(xd->screen);
- xd->visual = (Visual *)QX11Info::appVisual(xd->screen);
- xd->defaultVisual = QX11Info::appDefaultVisual(xd->screen);
- data->xinfo.setX11Data(xd);
- }
-
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender) {
- XRenderPictFormat *format = qt_renderformat_for_depth(data->xinfo, depth);
- data->picture = XRenderCreatePicture(X11->display, data->hd, format, 0, 0);
- }
-#endif // QT_NO_XRENDER
-
- return QPixmap(data);
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h
deleted file mode 100644
index eb8e5819ad..0000000000
--- a/src/gui/image/qpixmap_x11_p.h
+++ /dev/null
@@ -1,156 +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$
-** 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 QPIXMAPDATA_X11_P_H
-#define QPIXMAPDATA_X11_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 <QtGui/private/qpixmapdata_p.h>
-#include <QtGui/private/qpixmapdatafactory_p.h>
-
-#include "QtGui/qx11info_x11.h"
-
-QT_BEGIN_NAMESPACE
-
-class QX11PaintEngine;
-
-struct QXImageWrapper;
-
-class Q_GUI_EXPORT QX11PixmapData : public QPixmapData
-{
-public:
- QX11PixmapData(PixelType type);
-// QX11PixmapData(PixelType type, int width, int height);
-// QX11PixmapData(PixelType type, const QImage &image,
-// Qt::ImageConversionFlags flags);
- ~QX11PixmapData();
-
- 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);
-
- void fill(const QColor &color);
- QBitmap mask() const;
- void setMask(const QBitmap &mask);
- bool hasAlphaChannel() const;
- void setAlphaChannel(const QPixmap &alphaChannel);
- QPixmap alphaChannel() const;
- QPixmap transformed(const QTransform &transform,
- Qt::TransformationMode mode) const;
- QImage toImage() const;
- QImage toImage(const QRect &rect) const;
- QPaintEngine* paintEngine() const;
-
- Qt::HANDLE handle() const { return hd; }
- Qt::HANDLE x11ConvertToDefaultDepth();
-
- static Qt::HANDLE createBitmapFromImage(const QImage &image);
-
- void* gl_surface;
-#ifndef QT_NO_XRENDER
- void convertToARGB32(bool preserveContents = true);
-#endif
-
-protected:
- int metric(QPaintDevice::PaintDeviceMetric metric) const;
-
-private:
- friend class QPixmap;
- friend class QBitmap;
- friend class QX11PaintEngine;
- friend class QX11WindowSurface;
- friend class QRasterWindowSurface;
- friend class QGLContextPrivate; // Needs to access xinfo, gl_surface & flags
- friend class QEglContext; // Needs gl_surface
- friend class QGLContext; // Needs gl_surface
- friend class QX11GLPixmapData; // Needs gl_surface
- friend class QMeeGoLivePixmapData; // Needs gl_surface and flags
- friend bool qt_createEGLSurfaceForPixmap(QPixmapData*, bool); // Needs gl_surface
-
- void release();
-
- QImage toImage(const QXImageWrapper &xi, const QRect &rect) const;
-
- QBitmap mask_to_bitmap(int screen) const;
- static Qt::HANDLE bitmap_to_mask(const QBitmap &, int screen);
- void bitmapFromImage(const QImage &image);
-
- bool canTakeQImageFromXImage(const QXImageWrapper &xi) const;
- QImage takeQImageFromXImage(const QXImageWrapper &xi) const;
-
- Qt::HANDLE hd;
-
- enum Flag {
- NoFlags = 0x0,
- Uninitialized = 0x1,
- Readonly = 0x2,
- InvertedWhenBoundToTexture = 0x4,
- GlSurfaceCreatedWithAlpha = 0x8
- };
- uint flags;
-
- QX11Info xinfo;
- Qt::HANDLE x11_mask;
- Qt::HANDLE picture;
- Qt::HANDLE mask_picture;
- Qt::HANDLE hd2; // sorted in the default display depth
- QPixmap::ShareMode share_mode;
-
- QX11PaintEngine *pengine;
-};
-
-QT_END_NAMESPACE
-
-#endif // QPIXMAPDATA_X11_P_H
-