summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/painting.pri78
-rw-r--r--src/gui/painting/qbackingstore.cpp1668
-rw-r--r--src/gui/painting/qbackingstore_p.h278
-rw-r--r--src/gui/painting/qbrush.cpp32
-rw-r--r--src/gui/painting/qbrush.h10
-rw-r--r--src/gui/painting/qcolor.cpp24
-rw-r--r--src/gui/painting/qcolor.h21
-rw-r--r--src/gui/painting/qcolormap_mac.cpp111
-rw-r--r--src/gui/painting/qcolormap_qpa.cpp5
-rw-r--r--src/gui/painting/qcolormap_qws.cpp185
-rw-r--r--src/gui/painting/qcolormap_s60.cpp107
-rw-r--r--src/gui/painting/qcolormap_win.cpp201
-rw-r--r--src/gui/painting/qcolormap_x11.cpp670
-rw-r--r--src/gui/painting/qcssutil_p.h4
-rw-r--r--src/gui/painting/qcups_p.h2
-rw-r--r--src/gui/painting/qdrawhelper.cpp744
-rw-r--r--src/gui/painting/qdrawhelper_p.h145
-rw-r--r--src/gui/painting/qdrawutil.cpp1360
-rw-r--r--src/gui/painting/qdrawutil.h195
-rw-r--r--src/gui/painting/qgraphicssystem.cpp97
-rw-r--r--src/gui/painting/qgraphicssystem_mac.cpp59
-rw-r--r--src/gui/painting/qgraphicssystem_mac_p.h69
-rw-r--r--src/gui/painting/qgraphicssystem_p.h85
-rw-r--r--src/gui/painting/qgraphicssystem_qws.cpp62
-rw-r--r--src/gui/painting/qgraphicssystem_qws_p.h79
-rw-r--r--src/gui/painting/qgraphicssystem_raster.cpp72
-rw-r--r--src/gui/painting/qgraphicssystem_raster_p.h69
-rw-r--r--src/gui/painting/qgraphicssystem_runtime.cpp426
-rw-r--r--src/gui/painting/qgraphicssystem_runtime_p.h187
-rw-r--r--src/gui/painting/qgraphicssystemfactory.cpp123
-rw-r--r--src/gui/painting/qgraphicssystemfactory_p.h78
-rw-r--r--src/gui/painting/qgraphicssystemplugin.cpp56
-rw-r--r--src/gui/painting/qgraphicssystemplugin_p.h92
-rw-r--r--src/gui/painting/qmatrix.cpp36
-rw-r--r--src/gui/painting/qmatrix.h12
-rw-r--r--src/gui/painting/qmemrotate.cpp12
-rw-r--r--src/gui/painting/qpaintdevice.cpp17
-rw-r--r--src/gui/painting/qpaintdevice.h47
-rw-r--r--src/gui/painting/qpaintdevice_mac.cpp152
-rw-r--r--src/gui/painting/qpaintdevice_qpa.cpp5
-rw-r--r--src/gui/painting/qpaintdevice_qws.cpp56
-rw-r--r--src/gui/painting/qpaintdevice_win.cpp62
-rw-r--r--src/gui/painting/qpaintdevice_x11.cpp198
-rw-r--r--src/gui/painting/qpaintengine.cpp4
-rw-r--r--src/gui/painting/qpaintengine_blitter.cpp1
-rw-r--r--src/gui/painting/qpaintengine_mac.cpp1752
-rw-r--r--src/gui/painting/qpaintengine_mac_p.h254
-rw-r--r--src/gui/painting/qpaintengine_p.h4
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp231
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h65
-rw-r--r--src/gui/painting/qpaintengine_s60.cpp145
-rw-r--r--src/gui/painting/qpaintengine_s60_p.h84
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp2504
-rw-r--r--src/gui/painting/qpaintengine_x11_p.h246
-rw-r--r--src/gui/painting/qpaintengineex_p.h2
-rw-r--r--src/gui/painting/qpainter.cpp645
-rw-r--r--src/gui/painting/qpainter.h77
-rw-r--r--src/gui/painting/qpdf_p.h4
-rw-r--r--src/gui/painting/qprintengine_mac.mm911
-rw-r--r--src/gui/painting/qprintengine_mac_p.h166
-rw-r--r--src/gui/painting/qprintengine_ps.cpp972
-rw-r--r--src/gui/painting/qprintengine_ps_p.h137
-rw-r--r--src/gui/painting/qprintengine_qws.cpp886
-rw-r--r--src/gui/painting/qprintengine_qws_p.h213
-rw-r--r--src/gui/painting/qprintengine_win.cpp1776
-rw-r--r--src/gui/painting/qprintengine_win_p.h261
-rw-r--r--src/gui/painting/qprinter.cpp225
-rw-r--r--src/gui/painting/qprinter.h58
-rw-r--r--src/gui/painting/qprinter_p.h10
-rw-r--r--src/gui/painting/qprinterinfo_mac.cpp120
-rw-r--r--src/gui/painting/qprinterinfo_unix.cpp26
-rw-r--r--src/gui/painting/qprinterinfo_win.cpp122
-rw-r--r--src/gui/painting/qregion.cpp11
-rw-r--r--src/gui/painting/qregion.h6
-rw-r--r--src/gui/painting/qregion_mac.cpp286
-rw-r--r--src/gui/painting/qregion_qws.cpp3183
-rw-r--r--src/gui/painting/qregion_s60.cpp52
-rw-r--r--src/gui/painting/qregion_win.cpp149
-rw-r--r--src/gui/painting/qregion_x11.cpp92
-rw-r--r--src/gui/painting/qstylepainter.cpp176
-rw-r--r--src/gui/painting/qstylepainter.h112
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac.cpp265
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac_p.h140
-rw-r--r--src/gui/painting/qwindowsurface.cpp102
-rw-r--r--src/gui/painting/qwindowsurface_mac.cpp139
-rw-r--r--src/gui/painting/qwindowsurface_mac_p.h84
-rw-r--r--src/gui/painting/qwindowsurface_p.h25
-rw-r--r--src/gui/painting/qwindowsurface_qws.cpp1433
-rw-r--r--src/gui/painting/qwindowsurface_qws_p.h355
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp487
-rw-r--r--src/gui/painting/qwindowsurface_raster_p.h132
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp254
-rw-r--r--src/gui/painting/qwindowsurface_s60_p.h93
-rw-r--r--src/gui/painting/qwindowsurface_x11.cpp265
-rw-r--r--src/gui/painting/qwindowsurface_x11_p.h92
-rw-r--r--src/gui/painting/qwmatrix.h61
96 files changed, 197 insertions, 27689 deletions
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 13a9ba1c73..5379b6545e 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -7,9 +7,7 @@ HEADERS += \
painting/qcolor_p.h \
painting/qcolormap.h \
painting/qcosmeticstroker_p.h \
- painting/qdrawutil.h \
painting/qemulationpaintengine_p.h \
- painting/qgraphicssystem_p.h \
painting/qmatrix.h \
painting/qmemrotate_p.h \
painting/qoutlinemapper_p.h \
@@ -30,8 +28,6 @@ HEADERS += \
painting/qpolygon.h \
painting/qpolygonclipper_p.h \
painting/qprintengine.h \
- painting/qprintengine_pdf_p.h \
- painting/qprintengine_ps_p.h \
painting/qprinter.h \
painting/qprinter_p.h \
painting/qprinterinfo.h \
@@ -39,12 +35,10 @@ HEADERS += \
painting/qrasterizer_p.h \
painting/qregion.h \
painting/qstroker_p.h \
- painting/qstylepainter.h \
painting/qtessellator_p.h \
painting/qtextureglyphcache_p.h \
painting/qtransform.h \
painting/qwindowsurface_p.h \
- painting/qwmatrix.h \
painting/qpaintbuffer_p.h
@@ -56,9 +50,7 @@ SOURCES += \
painting/qcolor_p.cpp \
painting/qcosmeticstroker.cpp \
painting/qcssutil.cpp \
- painting/qdrawutil.cpp \
painting/qemulationpaintengine.cpp \
- painting/qgraphicssystem.cpp \
painting/qmatrix.cpp \
painting/qmemrotate.cpp \
painting/qoutlinemapper.cpp \
@@ -74,13 +66,11 @@ SOURCES += \
painting/qpen.cpp \
painting/qpolygon.cpp \
painting/qprintengine_pdf.cpp \
- painting/qprintengine_ps.cpp \
painting/qprinter.cpp \
painting/qprinterinfo.cpp \
painting/qrasterizer.cpp \
painting/qregion.cpp \
painting/qstroker.cpp \
- painting/qstylepainter.cpp \
painting/qtessellator.cpp \
painting/qtextureglyphcache.cpp \
painting/qtransform.cpp \
@@ -116,28 +106,6 @@ win32 {
!win32-borland:!wince*:LIBS += -lmsimg32
}
-embedded {
- HEADERS += \
- painting/qgraphicssystem_qws_p.h \
-
- SOURCES += \
- painting/qgraphicssystem_qws.cpp \
-
-} else: if(!qpa) {
- HEADERS += \
- painting/qgraphicssystem_raster_p.h \
- painting/qgraphicssystem_runtime_p.h \
- painting/qgraphicssystemfactory_p.h \
- painting/qgraphicssystemplugin_p.h \
- painting/qwindowsurface_raster_p.h
-
- SOURCES += \
- painting/qgraphicssystem_raster.cpp \
- painting/qgraphicssystem_runtime.cpp \
- painting/qgraphicssystemfactory.cpp \
- painting/qgraphicssystemplugin.cpp \
- painting/qwindowsurface_raster.cpp
-}
unix:x11 {
HEADERS += \
@@ -149,17 +117,15 @@ unix:x11 {
painting/qpaintengine_x11.cpp
}
-!embedded:!qpa:!x11:mac {
+!qpa:!x11:mac {
HEADERS += \
painting/qpaintengine_mac_p.h \
- painting/qgraphicssystem_mac_p.h \
painting/qprintengine_mac_p.h
SOURCES += \
painting/qcolormap_mac.cpp \
painting/qpaintdevice_mac.cpp \
painting/qpaintengine_mac.cpp \
- painting/qgraphicssystem_mac.cpp \
painting/qprinterinfo_mac.cpp
OBJECTIVE_SOURCES += \
painting/qprintengine_mac.mm \
@@ -172,23 +138,6 @@ unix:!mac:!symbian|qpa {
painting/qprinterinfo_unix.cpp
}
-win32|x11|mac|embedded|qpa|symbian {
- SOURCES += painting/qbackingstore.cpp
- HEADERS += painting/qbackingstore_p.h
-}
-
-embedded {
- contains(QT_CONFIG,qtopia) {
- DEFINES += QTOPIA_PRINTENGINE
- HEADERS += painting/qprintengine_qws_p.h
- SOURCES += painting/qprintengine_qws.cpp
- }
-
- SOURCES += \
- painting/qcolormap_qws.cpp \
- painting/qpaintdevice_qws.cpp
-}
-
qpa {
SOURCES += \
painting/qcolormap_qpa.cpp \
@@ -205,7 +154,7 @@ symbian {
painting/qpaintengine_s60_p.h
}
-x11|embedded|qpa {
+x11|qpa {
contains(QT_CONFIG,qtopia) {
DEFINES += QT_NO_CUPS QT_NO_LPR
} else {
@@ -230,29 +179,8 @@ if(mmx|3dnow|sse|sse2|iwmmxt) {
IWMMXT_SOURCES += painting/qdrawhelper_iwmmxt.cpp
}
-x11 {
- HEADERS += painting/qwindowsurface_x11_p.h
- SOURCES += painting/qwindowsurface_x11.cpp
-}
-
-!embedded:!qpa:mac {
- HEADERS += painting/qwindowsurface_mac_p.h \
- painting/qunifiedtoolbarsurface_mac_p.h
- SOURCES += painting/qwindowsurface_mac.cpp \
- painting/qunifiedtoolbarsurface_mac.cpp
-}
-
-embedded {
- HEADERS += painting/qwindowsurface_qws_p.h
- SOURCES += painting/qwindowsurface_qws.cpp
-}
-
-
-
symbian {
- HEADERS += painting/qwindowsurface_s60_p.h \
- painting/qdrawhelper_arm_simd_p.h
- SOURCES += painting/qwindowsurface_s60.cpp
+ HEADERS += painting/qdrawhelper_arm_simd_p.h
armccIfdefBlock = \
"$${LITERAL_HASH}if defined(ARMV6)" \
"MACRO QT_HAVE_ARM_SIMD" \
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
deleted file mode 100644
index 6fbb59fc89..0000000000
--- a/src/gui/painting/qbackingstore.cpp
+++ /dev/null
@@ -1,1668 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "qplatformdefs.h"
-
-#include "qbackingstore_p.h"
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qpaintengine.h>
-#include <QtGui/qgraphicsproxywidget.h>
-
-#include <private/qwidget_p.h>
-#include <private/qwindowsurface_raster_p.h>
-#include <private/qapplication_p.h>
-#include <private/qpaintengine_raster_p.h>
-#include <private/qgraphicseffect_p.h>
-
-#include "qgraphicssystem_p.h"
-
-#ifdef Q_WS_QWS
-#include <QtGui/qwsmanager_qws.h>
-#include <private/qwsmanager_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-extern QRegion qt_dirtyRegion(QWidget *);
-
-/*
- A version of QRect::intersects() that does not normalize the rects.
-*/
-static inline bool qRectIntersects(const QRect &r1, const QRect &r2)
-{
- return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right())
- && qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom()));
-}
-
-/**
- * Flushes the contents of the \a windowSurface into the screen area of \a widget.
- * \a tlwOffset is the position of the top level widget relative to the window surface.
- * \a region is the region to be updated in \a widget coordinates.
- */
-static inline void qt_flush(QWidget *widget, const QRegion &region, QWindowSurface *windowSurface,
- QWidget *tlw, const QPoint &tlwOffset)
-{
- Q_ASSERT(widget);
- Q_ASSERT(!region.isEmpty());
- Q_ASSERT(windowSurface);
- Q_ASSERT(tlw);
-
-#if !defined(QT_NO_PAINT_DEBUG) && !defined(Q_WS_QWS)
- // QWS does flush update in QWindowSurface::flush (because it needs to lock the surface etc).
- static int flushUpdate = qgetenv("QT_FLUSH_UPDATE").toInt();
- if (flushUpdate > 0)
- QWidgetBackingStore::showYellowThing(widget, region, flushUpdate * 10, false);
-#endif
-
- //The performance hit by doing this should be negligible. However, be aware that
- //using this FPS when you have > 1 windowsurface can give you inaccurate FPS
- static bool fpsDebug = qgetenv("QT_DEBUG_FPS").toInt();
- if (fpsDebug) {
- static QTime time = QTime::currentTime();
- static int frames = 0;
-
- frames++;
-
- if(time.elapsed() > 5000) {
- double fps = double(frames * 1000) /time.restart();
- fprintf(stderr,"FPS: %.1f\n",fps);
- frames = 0;
- }
- }
- if (widget != tlw)
- windowSurface->flush(widget, region, tlwOffset + widget->mapTo(tlw, QPoint()));
- else
- windowSurface->flush(widget, region, tlwOffset);
-}
-
-#ifndef QT_NO_PAINT_DEBUG
-#ifdef Q_WS_WIN
-static void showYellowThing_win(QWidget *widget, const QRegion &region, int msec)
-{
- HBRUSH brush;
- static int i = 0;
- switch (i) {
- case 0:
- brush = CreateSolidBrush(RGB(255, 255, 0));
- break;
- case 1:
- brush = CreateSolidBrush(RGB(255, 200, 55));
- break;
- case 2:
- brush = CreateSolidBrush(RGB(200, 255, 55));
- break;
- case 3:
- brush = CreateSolidBrush(RGB(200, 200, 0));
- break;
- }
- i = (i + 1) & 3;
-
- HDC hdc = widget->getDC();
-
- const QVector<QRect> &rects = region.rects();
- foreach (QRect rect, rects) {
- RECT winRect;
- SetRect(&winRect, rect.left(), rect.top(), rect.right(), rect.bottom());
- FillRect(hdc, &winRect, brush);
- }
-
- widget->releaseDC(hdc);
- ::Sleep(msec);
-}
-#endif
-
-void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePainted, int msec, bool unclipped)
-{
-#ifdef Q_WS_QWS
- Q_UNUSED(widget);
- Q_UNUSED(unclipped);
- static QWSYellowSurface surface(true);
- surface.setDelay(msec);
- surface.flush(widget, toBePainted, QPoint());
-#else
- QRegion paintRegion = toBePainted;
- QRect widgetRect = widget->rect();
-
- if (!widget->internalWinId()) {
- QWidget *nativeParent = widget->nativeParentWidget();
- const QPoint offset = widget->mapTo(nativeParent, QPoint(0, 0));
- paintRegion.translate(offset);
- widgetRect.translate(offset);
- widget = nativeParent;
- }
-
-#ifdef Q_WS_WIN
- Q_UNUSED(unclipped);
- showYellowThing_win(widget, paintRegion, msec);
-#else
- //flags to fool painter
- bool paintUnclipped = widget->testAttribute(Qt::WA_PaintUnclipped);
- if (unclipped && !widget->d_func()->paintOnScreen())
- widget->setAttribute(Qt::WA_PaintUnclipped);
-
- const bool setFlag = !widget->testAttribute(Qt::WA_WState_InPaintEvent);
- if (setFlag)
- widget->setAttribute(Qt::WA_WState_InPaintEvent);
-
- //setup the engine
- QPaintEngine *pe = widget->paintEngine();
- if (pe) {
- pe->setSystemClip(paintRegion);
- {
- QPainter p(widget);
- p.setClipRegion(paintRegion);
- static int i = 0;
- switch (i) {
- case 0:
- p.fillRect(widgetRect, QColor(255,255,0));
- break;
- case 1:
- p.fillRect(widgetRect, QColor(255,200,55));
- break;
- case 2:
- p.fillRect(widgetRect, QColor(200,255,55));
- break;
- case 3:
- p.fillRect(widgetRect, QColor(200,200,0));
- break;
- }
- i = (i+1) & 3;
- p.end();
- }
- }
-
- if (setFlag)
- widget->setAttribute(Qt::WA_WState_InPaintEvent, false);
-
- //restore
- widget->setAttribute(Qt::WA_PaintUnclipped, paintUnclipped);
-
- if (pe)
- pe->setSystemClip(QRegion());
-
- QApplication::syncX();
-
-#if defined(Q_OS_UNIX)
- ::usleep(1000 * msec);
-#endif
-#endif // Q_WS_WIN
-#endif // Q_WS_QWS
-}
-
-bool QWidgetBackingStore::flushPaint(QWidget *widget, const QRegion &rgn)
-{
- if (!widget)
- return false;
-
- int delay = 0;
- if (widget->testAttribute(Qt::WA_WState_InPaintEvent)) {
- static int flushPaintEvent = qgetenv("QT_FLUSH_PAINT_EVENT").toInt();
- if (!flushPaintEvent)
- return false;
- delay = flushPaintEvent;
- } else {
- static int flushPaint = qgetenv("QT_FLUSH_PAINT").toInt();
- if (!flushPaint)
- return false;
- delay = flushPaint;
- }
-
- QWidgetBackingStore::showYellowThing(widget, rgn, delay * 10, true);
- return true;
-}
-
-void QWidgetBackingStore::unflushPaint(QWidget *widget, const QRegion &rgn)
-{
- if (widget->d_func()->paintOnScreen() || rgn.isEmpty())
- return;
-
- QWidget *tlw = widget->window();
- QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
- if (!tlwExtra)
- return;
-
- const QPoint offset = widget->mapTo(tlw, QPoint());
- qt_flush(widget, rgn, tlwExtra->backingStore->windowSurface, tlw, offset);
-}
-#endif // QT_NO_PAINT_DEBUG
-
-/*
- Moves the whole rect by (dx, dy) in widget's coordinate system.
- Doesn't generate any updates.
-*/
-bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *widget)
-{
- const QPoint pos(tlwOffset + widget->mapTo(tlw, rect.topLeft()));
- const QRect tlwRect(QRect(pos, rect.size()));
- if (fullUpdatePending || dirty.intersects(tlwRect))
- return false; // We don't want to scroll junk.
- return windowSurface->scroll(tlwRect, dx, dy);
-}
-
-void QWidgetBackingStore::releaseBuffer()
-{
- if (windowSurface)
-#if defined(Q_WS_QPA)
- windowSurface->resize(QSize());
-#else
- windowSurface->setGeometry(QRect());
-#endif
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- for (int i = 0; i < subSurfaces.size(); ++i)
- subSurfaces.at(i)->setGeometry(QRect());
-#endif
-}
-
-/*!
- Prepares the window surface to paint a\ toClean region of the \a widget and
- updates the BeginPaintInfo struct accordingly.
-
- The \a toClean region might be clipped by the window surface.
-*/
-void QWidgetBackingStore::beginPaint(QRegion &toClean, QWidget *widget, QWindowSurface *windowSurface,
- BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates)
-{
-#ifdef Q_WS_QWS
- QWSWindowSurface *surface = static_cast<QWSWindowSurface *>(windowSurface);
- QWidget *surfaceWidget = surface->window();
-
- if (!surface->isValid()) {
- // this looks strange but it really just releases the surface
- surface->releaseSurface();
- // the old window surface is deleted in setWindowSurface, which is
- // called from QWindowSurface constructor.
- windowSurface = tlw->d_func()->createDefaultWindowSurface();
- surface = static_cast<QWSWindowSurface *>(windowSurface);
- // createDefaultWindowSurface() will set topdata->windowSurface on the
- // widget to zero. However, if this is a sub-surface, it should point
- // to the widget's sub windowSurface, so we set that here:
- if (!surfaceWidget->isWindow())
- surfaceWidget->d_func()->topData()->windowSurface = windowSurface;
- surface->setGeometry(topLevelRect());
- returnInfo->windowSurfaceRecreated = true;
- }
-
- const QRegion toCleanUnclipped(toClean);
-
- if (surfaceWidget->isWindow())
- tlwOffset = surface->painterOffset();
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- else if (toCleanIsInTopLevelCoordinates)
- toClean &= surface->clipRegion().translated(surfaceWidget->mapTo(tlw, QPoint()));
- if (!toCleanIsInTopLevelCoordinates && windowSurface == this->windowSurface)
- toClean &= surface->clipRegion().translated(-widget->mapTo(surfaceWidget, QPoint()));
-#else
- toClean &= surface->clipRegion();
-#endif
-
- if (toClean.isEmpty()) {
- if (surfaceWidget->isWindow()) {
- dirtyFromPreviousSync += toCleanUnclipped;
- hasDirtyFromPreviousSync = true;
- }
-
- returnInfo->nothingToPaint = true;
- // Nothing to repaint. However, we might have newly exposed areas on the
- // screen, so we have to make sure those are flushed.
- flush();
- return;
- }
-
- if (surfaceWidget->isWindow()) {
- if (toCleanUnclipped != toClean) {
- dirtyFromPreviousSync += (toCleanUnclipped - surface->clipRegion());
- hasDirtyFromPreviousSync = true;
- }
- if (hasDirtyFromPreviousSync) {
- dirtyFromPreviousSync -= toClean;
- hasDirtyFromPreviousSync = !dirtyFromPreviousSync.isEmpty();
- }
- }
-
-#endif // Q_WS_QWS
-
- Q_UNUSED(widget);
- Q_UNUSED(toCleanIsInTopLevelCoordinates);
-
- // Always flush repainted areas.
- dirtyOnScreen += toClean;
-
-#if defined(Q_WS_QWS) && !defined(Q_BACKINGSTORE_SUBSURFACES)
- toClean.translate(tlwOffset);
-#endif
-
-#ifdef QT_NO_PAINT_DEBUG
- windowSurface->beginPaint(toClean);
-#else
- returnInfo->wasFlushed = QWidgetBackingStore::flushPaint(tlw, toClean);
- // Avoid deadlock with QT_FLUSH_PAINT: the server will wait for
- // the BackingStore lock, so if we hold that, the server will
- // never release the Communication lock that we are waiting for in
- // sendSynchronousCommand
- if (!returnInfo->wasFlushed)
- windowSurface->beginPaint(toClean);
-#endif
-
- Q_UNUSED(returnInfo);
-}
-
-void QWidgetBackingStore::endPaint(const QRegion &cleaned, QWindowSurface *windowSurface,
- BeginPaintInfo *beginPaintInfo)
-{
-#ifndef QT_NO_PAINT_DEBUG
- if (!beginPaintInfo->wasFlushed)
- windowSurface->endPaint(cleaned);
- else
- QWidgetBackingStore::unflushPaint(tlw, cleaned);
-#else
- Q_UNUSED(beginPaintInfo);
- windowSurface->endPaint(cleaned);
-#endif
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- flush(static_cast<QWSWindowSurface *>(windowSurface)->window(), windowSurface);
-#else
- flush();
-#endif
-}
-
-/*!
- Returns the region (in top-level coordinates) that needs repaint and/or flush.
-
- If the widget is non-zero, only the dirty region for the widget is returned
- and the region will be in widget coordinates.
-*/
-QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const
-{
- const bool widgetDirty = widget && widget != tlw;
- const QRect tlwRect(topLevelRect());
-#if defined(Q_WS_QPA)
- const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size());
-#else
- const QRect surfaceGeometry(windowSurface->geometry());
-#endif
- if (fullUpdatePending || (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size())) {
- if (widgetDirty) {
- const QRect dirtyTlwRect = QRect(QPoint(), tlwRect.size());
- const QPoint offset(widget->mapTo(tlw, QPoint()));
- const QRect dirtyWidgetRect(dirtyTlwRect & widget->rect().translated(offset));
- return dirtyWidgetRect.translated(-offset);
- }
- return QRect(QPoint(), tlwRect.size());
- }
-
- // Calculate the region that needs repaint.
- QRegion r(dirty);
- for (int i = 0; i < dirtyWidgets.size(); ++i) {
- QWidget *w = dirtyWidgets.at(i);
- if (widgetDirty && w != widget && !widget->isAncestorOf(w))
- continue;
- r += w->d_func()->dirty.translated(w->mapTo(tlw, QPoint()));
- }
-
- // Append the region that needs flush.
- r += dirtyOnScreen;
-
- if (dirtyOnScreenWidgets) { // Only in use with native child widgets.
- for (int i = 0; i < dirtyOnScreenWidgets->size(); ++i) {
- QWidget *w = dirtyOnScreenWidgets->at(i);
- if (widgetDirty && w != widget && !widget->isAncestorOf(w))
- continue;
- QWidgetPrivate *wd = w->d_func();
- Q_ASSERT(wd->needsFlush);
- r += wd->needsFlush->translated(w->mapTo(tlw, QPoint()));
- }
- }
-
- if (widgetDirty) {
- // Intersect with the widget geometry and translate to its coordinates.
- const QPoint offset(widget->mapTo(tlw, QPoint()));
- r &= widget->rect().translated(offset);
- r.translate(-offset);
- }
- return r;
-}
-
-/*!
- Returns the static content inside the \a parent if non-zero; otherwise the static content
- for the entire backing store is returned. The content will be clipped to \a withinClipRect
- if non-empty.
-*/
-QRegion QWidgetBackingStore::staticContents(QWidget *parent, const QRect &withinClipRect) const
-{
- if (!parent && tlw->testAttribute(Qt::WA_StaticContents)) {
-#if defined(Q_WS_QPA)
- const QSize surfaceGeometry(windowSurface->size());
-#else
- const QRect surfaceGeometry(windowSurface->geometry());
-#endif
- QRect surfaceRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
- if (!withinClipRect.isEmpty())
- surfaceRect &= withinClipRect;
- return QRegion(surfaceRect);
- }
-
- QRegion region;
- if (parent && parent->d_func()->children.isEmpty())
- return region;
-
- const bool clipToRect = !withinClipRect.isEmpty();
- const int count = staticWidgets.count();
- for (int i = 0; i < count; ++i) {
- QWidget *w = staticWidgets.at(i);
- QWidgetPrivate *wd = w->d_func();
- if (!wd->isOpaque || !wd->extra || wd->extra->staticContentsSize.isEmpty()
- || !w->isVisible() || (parent && !parent->isAncestorOf(w))) {
- continue;
- }
-
- QRect rect(0, 0, wd->extra->staticContentsSize.width(), wd->extra->staticContentsSize.height());
- const QPoint offset = w->mapTo(parent ? parent : tlw, QPoint());
- if (clipToRect)
- rect &= withinClipRect.translated(-offset);
- if (rect.isEmpty())
- continue;
-
- rect &= wd->clipRect();
- if (rect.isEmpty())
- continue;
-
- QRegion visible(rect);
- wd->clipToEffectiveMask(visible);
- if (visible.isEmpty())
- continue;
- wd->subtractOpaqueSiblings(visible, 0, /*alsoNonOpaque=*/true);
-
- visible.translate(offset);
- region += visible;
- }
-
- return region;
-}
-
-static inline void sendUpdateRequest(QWidget *widget, bool updateImmediately)
-{
- if (!widget)
- return;
-
- if (updateImmediately) {
- QEvent event(QEvent::UpdateRequest);
- QApplication::sendEvent(widget, &event);
- } else {
- QApplication::postEvent(widget, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
- }
-}
-
-/*!
- Marks the region of the widget as dirty (if not already marked as dirty) and
- posts an UpdateRequest event to the top-level widget (if not already posted).
-
- If updateImmediately is true, the event is sent immediately instead of posted.
-
- If invalidateBuffer is true, all widgets intersecting with the region will be dirty.
-
- If the widget paints directly on screen, the event is sent to the widget
- instead of the top-level widget, and invalidateBuffer is completely ignored.
-
- ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
-*/
-void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately,
- bool invalidateBuffer)
-{
- Q_ASSERT(tlw->d_func()->extra);
- Q_ASSERT(tlw->d_func()->extra->topextra);
- Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
- Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
- Q_ASSERT(widget->window() == tlw);
- Q_ASSERT(!rgn.isEmpty());
-
-#ifndef QT_NO_GRAPHICSEFFECT
- widget->d_func()->invalidateGraphicsEffectsRecursively();
-#endif //QT_NO_GRAPHICSEFFECT
-
- if (widget->d_func()->paintOnScreen()) {
- if (widget->d_func()->dirty.isEmpty()) {
- widget->d_func()->dirty = rgn;
- sendUpdateRequest(widget, updateImmediately);
- return;
- } else if (qt_region_strictContains(widget->d_func()->dirty, widget->rect())) {
- if (updateImmediately)
- sendUpdateRequest(widget, updateImmediately);
- return; // Already dirty.
- }
-
- const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty();
- widget->d_func()->dirty += rgn;
- if (!eventAlreadyPosted || updateImmediately)
- sendUpdateRequest(widget, updateImmediately);
- return;
- }
-
- if (fullUpdatePending) {
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (!windowSurface->hasFeature(QWindowSurface::PartialUpdates)) {
- fullUpdatePending = true;
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- const QPoint offset = widget->mapTo(tlw, QPoint());
- const QRect widgetRect = widget->d_func()->effectiveRectFor(widget->rect());
- if (qt_region_strictContains(dirty, widgetRect.translated(offset))) {
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return; // Already dirty.
- }
-
- if (invalidateBuffer) {
- const bool eventAlreadyPosted = !dirty.isEmpty();
-#ifndef QT_NO_GRAPHICSEFFECT
- if (widget->d_func()->graphicsEffect)
- dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect()).translated(offset);
- else
-#endif //QT_NO_GRAPHICSEFFECT
- dirty += rgn.translated(offset);
- if (!eventAlreadyPosted || updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (dirtyWidgets.isEmpty()) {
- addDirtyWidget(widget, rgn);
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (widget->d_func()->inDirtyList) {
- if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect)) {
-#ifndef QT_NO_GRAPHICSEFFECT
- if (widget->d_func()->graphicsEffect)
- widget->d_func()->dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect());
- else
-#endif //QT_NO_GRAPHICSEFFECT
- widget->d_func()->dirty += rgn;
- }
- } else {
- addDirtyWidget(widget, rgn);
- }
-
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
-}
-
-/*!
- This function is equivalent to calling markDirty(QRegion(rect), ...), but
- is more efficient as it eliminates QRegion operations/allocations and can
- use the rect more precisely for additional cut-offs.
-
- ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
-*/
-void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, bool updateImmediately,
- bool invalidateBuffer)
-{
- Q_ASSERT(tlw->d_func()->extra);
- Q_ASSERT(tlw->d_func()->extra->topextra);
- Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
- Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
- Q_ASSERT(widget->window() == tlw);
- Q_ASSERT(!rect.isEmpty());
-
-#ifndef QT_NO_GRAPHICSEFFECT
- widget->d_func()->invalidateGraphicsEffectsRecursively();
-#endif //QT_NO_GRAPHICSEFFECT
-
- if (widget->d_func()->paintOnScreen()) {
- if (widget->d_func()->dirty.isEmpty()) {
- widget->d_func()->dirty = QRegion(rect);
- sendUpdateRequest(widget, updateImmediately);
- return;
- } else if (qt_region_strictContains(widget->d_func()->dirty, rect)) {
- if (updateImmediately)
- sendUpdateRequest(widget, updateImmediately);
- return; // Already dirty.
- }
-
- const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty();
- widget->d_func()->dirty += rect;
- if (!eventAlreadyPosted || updateImmediately)
- sendUpdateRequest(widget, updateImmediately);
- return;
- }
-
- if (fullUpdatePending) {
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (!windowSurface->hasFeature(QWindowSurface::PartialUpdates)) {
- fullUpdatePending = true;
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- const QRect widgetRect = widget->d_func()->effectiveRectFor(rect);
- const QRect translatedRect(widgetRect.translated(widget->mapTo(tlw, QPoint())));
- if (qt_region_strictContains(dirty, translatedRect)) {
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return; // Already dirty
- }
-
- if (invalidateBuffer) {
- const bool eventAlreadyPosted = !dirty.isEmpty();
- dirty += translatedRect;
- if (!eventAlreadyPosted || updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (dirtyWidgets.isEmpty()) {
- addDirtyWidget(widget, rect);
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (widget->d_func()->inDirtyList) {
- if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect))
- widget->d_func()->dirty += widgetRect;
- } else {
- addDirtyWidget(widget, rect);
- }
-
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
-}
-
-/*!
- Marks the \a region of the \a widget as dirty on screen. The \a region will be copied from
- the backing store to the \a widget's native parent next time flush() is called.
-
- Paint on screen widgets are ignored.
-*/
-void QWidgetBackingStore::markDirtyOnScreen(const QRegion &region, QWidget *widget, const QPoint &topLevelOffset)
-{
- if (!widget || widget->d_func()->paintOnScreen() || region.isEmpty())
- return;
-
-#if defined(Q_WS_QWS) || defined(Q_WS_MAC)
- if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
- dirtyOnScreen += region.translated(topLevelOffset);
- return;
-#endif
-
- // Top-level.
- if (widget == tlw) {
- if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
- dirtyOnScreen += region;
- return;
- }
-
- // Alien widgets.
- if (!widget->internalWinId() && !widget->isWindow()) {
- QWidget *nativeParent = widget->nativeParentWidget(); // Alien widgets with the top-level as the native parent (common case).
- if (nativeParent == tlw) {
- if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
- dirtyOnScreen += region.translated(topLevelOffset);
- return;
- }
-
- // Alien widgets with native parent != tlw.
- QWidgetPrivate *nativeParentPrivate = nativeParent->d_func();
- if (!nativeParentPrivate->needsFlush)
- nativeParentPrivate->needsFlush = new QRegion;
- const QPoint nativeParentOffset = widget->mapTo(nativeParent, QPoint());
- *nativeParentPrivate->needsFlush += region.translated(nativeParentOffset);
- appendDirtyOnScreenWidget(nativeParent);
- return;
- }
-
- // Native child widgets.
- QWidgetPrivate *widgetPrivate = widget->d_func();
- if (!widgetPrivate->needsFlush)
- widgetPrivate->needsFlush = new QRegion;
- *widgetPrivate->needsFlush += region;
- appendDirtyOnScreenWidget(widget);
-}
-
-void QWidgetBackingStore::removeDirtyWidget(QWidget *w)
-{
- if (!w)
- return;
-
- dirtyWidgetsRemoveAll(w);
- dirtyOnScreenWidgetsRemoveAll(w);
- resetWidget(w);
-
- QWidgetPrivate *wd = w->d_func();
- const int n = wd->children.count();
- for (int i = 0; i < n; ++i) {
- if (QWidget *child = qobject_cast<QWidget*>(wd->children.at(i)))
- removeDirtyWidget(child);
- }
-}
-
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
-bool QWidgetBackingStore::hasDirtyWindowDecoration() const
-{
- QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
- if (tlwExtra && tlwExtra->qwsManager)
- return !tlwExtra->qwsManager->d_func()->dirtyRegions.isEmpty();
- return false;
-}
-
-void QWidgetBackingStore::paintWindowDecoration()
-{
- if (!hasDirtyWindowDecoration())
- return;
-
- QDecoration &decoration = QApplication::qwsDecoration();
- const QRect decorationRect = tlw->rect();
- QRegion decorationRegion = decoration.region(tlw, decorationRect);
-
- QWSManagerPrivate *managerPrivate = tlw->d_func()->topData()->qwsManager->d_func();
- const bool doClipping = !managerPrivate->entireDecorationNeedsRepaint
- && !managerPrivate->dirtyClip.isEmpty();
-
- if (doClipping) {
- decorationRegion &= static_cast<QWSWindowSurface *>(windowSurface)->clipRegion();
- decorationRegion &= managerPrivate->dirtyClip;
- }
-
- if (decorationRegion.isEmpty())
- return;
-
- //### The QWS decorations do not always paint the pixels they promise to paint.
- // This causes painting problems with QWSMemorySurface. Since none of the other
- // window surfaces actually use the region, passing an empty region is a safe
- // workaround.
-
- windowSurface->beginPaint(QRegion());
-
- QPaintEngine *engine = windowSurface->paintDevice()->paintEngine();
- Q_ASSERT(engine);
- const QRegion oldSystemClip(engine->systemClip());
- engine->setSystemClip(decorationRegion.translated(tlwOffset));
-
- QPainter painter(windowSurface->paintDevice());
- painter.setFont(QApplication::font());
- painter.translate(tlwOffset);
-
- const int numDirty = managerPrivate->dirtyRegions.size();
- for (int i = 0; i < numDirty; ++i) {
- const int area = managerPrivate->dirtyRegions.at(i);
-
- QRegion clipRegion = decoration.region(tlw, decorationRect, area);
- if (!clipRegion.isEmpty()) {
- // Decoration styles changes the clip and assumes the old clip is non-empty,
- // so we have to set it, but in theory it shouldn't be required.
- painter.setClipRegion(clipRegion);
- decoration.paint(&painter, tlw, area, managerPrivate->dirtyStates.at(i));
- }
- }
- markDirtyOnScreen(decorationRegion, tlw, QPoint());
-
- painter.end();
- windowSurface->endPaint(decorationRegion);
- managerPrivate->clearDirtyRegions();
- engine->setSystemClip(oldSystemClip);
-}
-#endif
-
-void QWidgetBackingStore::updateLists(QWidget *cur)
-{
- if (!cur)
- return;
-
- QList<QObject*> children = cur->children();
- for (int i = 0; i < children.size(); ++i) {
- QWidget *child = qobject_cast<QWidget*>(children.at(i));
- if (!child)
- continue;
-
- updateLists(child);
- }
-
- if (cur->testAttribute(Qt::WA_StaticContents))
- addStaticWidget(cur);
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- QTLWExtra *extra = cur->d_func()->maybeTopData();
- if (extra && extra->windowSurface && cur != tlw)
- subSurfaces.append(extra->windowSurface);
-#endif
-}
-
-QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel)
- : tlw(topLevel), dirtyOnScreenWidgets(0), hasDirtyFromPreviousSync(false)
- , fullUpdatePending(0)
-{
- windowSurface = tlw->windowSurface();
- if (!windowSurface)
- windowSurface = topLevel->d_func()->createDefaultWindowSurface();
-
- // The QWindowSurface constructor will call QWidget::setWindowSurface(),
- // but automatically created surfaces should not be added to the topdata.
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- Q_ASSERT(topLevel->d_func()->topData()->windowSurface == windowSurface);
-#endif
- topLevel->d_func()->topData()->windowSurface = 0;
-
- // Ensure all existing subsurfaces and static widgets are added to their respective lists.
- updateLists(topLevel);
-}
-
-QWidgetBackingStore::~QWidgetBackingStore()
-{
- for (int c = 0; c < dirtyWidgets.size(); ++c) {
- resetWidget(dirtyWidgets.at(c));
- }
-
- delete windowSurface;
- windowSurface = 0;
- delete dirtyOnScreenWidgets;
- dirtyOnScreenWidgets = 0;
-}
-
-//parent's coordinates; move whole rect; update parent and widget
-//assume the screen blt has already been done, so we don't need to refresh that part
-void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy)
-{
- Q_Q(QWidget);
- if (!q->isVisible() || (dx == 0 && dy == 0))
- return;
-
- QWidget *tlw = q->window();
- QTLWExtra* x = tlw->d_func()->topData();
- if (x->inTopLevelResize)
- return;
-
- static int accelEnv = -1;
- if (accelEnv == -1) {
- accelEnv = qgetenv("QT_NO_FAST_MOVE").toInt() == 0;
- }
-
- QWidget *pw = q->parentWidget();
- QPoint toplevelOffset = pw->mapTo(tlw, QPoint());
- QWidgetPrivate *pd = pw->d_func();
- QRect clipR(pd->clipRect());
-#ifdef Q_WS_QWS
- QWidgetBackingStore *wbs = x->backingStore.data();
- QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(wbs->windowSurface);
- clipR = clipR.intersected(surface->clipRegion().translated(-toplevelOffset).boundingRect());
-#endif
- const QRect newRect(rect.translated(dx, dy));
- QRect destRect = rect.intersected(clipR);
- if (destRect.isValid())
- destRect = destRect.translated(dx, dy).intersected(clipR);
- const QRect sourceRect(destRect.translated(-dx, -dy));
- const QRect parentRect(rect & clipR);
-
- bool accelerateMove = accelEnv && isOpaque
-#ifndef QT_NO_GRAPHICSVIEW
- // No accelerate move for proxy widgets.
- && !tlw->d_func()->extra->proxyWidget
-#endif
- && !isOverlapped(sourceRect) && !isOverlapped(destRect);
-
- if (!accelerateMove) {
- QRegion parentR(effectiveRectFor(parentRect));
- if (!extra || !extra->hasMask) {
- parentR -= newRect;
- } else {
- // invalidateBuffer() excludes anything outside the mask
- parentR += newRect & clipR;
- }
- pd->invalidateBuffer(parentR);
- invalidateBuffer((newRect & clipR).translated(-data.crect.topLeft()));
- } else {
-
- QWidgetBackingStore *wbs = x->backingStore.data();
- QRegion childExpose(newRect & clipR);
-
- if (sourceRect.isValid() && wbs->bltRect(sourceRect, dx, dy, pw))
- childExpose -= destRect;
-
- if (!pw->updatesEnabled())
- return;
-
- const bool childUpdatesEnabled = q->updatesEnabled();
- if (childUpdatesEnabled && !childExpose.isEmpty()) {
- childExpose.translate(-data.crect.topLeft());
- wbs->markDirty(childExpose, q);
- isMoved = true;
- }
-
- QRegion parentExpose(parentRect);
- parentExpose -= newRect;
- if (extra && extra->hasMask)
- parentExpose += QRegion(newRect) - extra->mask.translated(data.crect.topLeft());
-
- if (!parentExpose.isEmpty()) {
- wbs->markDirty(parentExpose, pw);
- pd->isMoved = true;
- }
-
- if (childUpdatesEnabled) {
- QRegion needsFlush(sourceRect);
- needsFlush += destRect;
- wbs->markDirtyOnScreen(needsFlush, pw, toplevelOffset);
- }
- }
-}
-
-//widget's coordinates; scroll within rect; only update widget
-void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy)
-{
- Q_Q(QWidget);
- QWidget *tlw = q->window();
- QTLWExtra* x = tlw->d_func()->topData();
- if (x->inTopLevelResize)
- return;
-
- QWidgetBackingStore *wbs = x->backingStore.data();
- if (!wbs)
- return;
-
- static int accelEnv = -1;
- if (accelEnv == -1) {
- accelEnv = qgetenv("QT_NO_FAST_SCROLL").toInt() == 0;
- }
-
- QRect scrollRect = rect & clipRect();
- bool overlapped = false;
- bool accelerateScroll = accelEnv && isOpaque
- && !(overlapped = isOverlapped(scrollRect.translated(data.crect.topLeft())));
-
-#if defined(Q_WS_QWS)
- QWSWindowSurface *surface;
- surface = static_cast<QWSWindowSurface*>(wbs->windowSurface);
-
- if (accelerateScroll && !surface->isBuffered()) {
- const QRegion surfaceClip = surface->clipRegion();
- const QRegion outsideClip = QRegion(rect) - surfaceClip;
- if (!outsideClip.isEmpty()) {
- const QVector<QRect> clipped = (surfaceClip & rect).rects();
- if (clipped.size() < 8) {
- for (int i = 0; i < clipped.size(); ++i)
- this->scrollRect(clipped.at(i), dx, dy);
- return;
- } else {
- accelerateScroll = false;
- }
- }
- }
-#endif // Q_WS_QWS
-
- if (!accelerateScroll) {
- if (overlapped) {
- QRegion region(scrollRect);
- subtractOpaqueSiblings(region);
- invalidateBuffer(region);
- }else {
- invalidateBuffer(scrollRect);
- }
- } else {
- const QPoint toplevelOffset = q->mapTo(tlw, QPoint());
-#ifdef Q_WS_QWS
- QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(wbs->windowSurface);
- const QRegion clip = surface->clipRegion().translated(-toplevelOffset) & scrollRect;
- const QRect clipBoundingRect = clip.boundingRect();
- scrollRect &= clipBoundingRect;
-#endif
- const QRect destRect = scrollRect.translated(dx, dy) & scrollRect;
- const QRect sourceRect = destRect.translated(-dx, -dy);
-
- QRegion childExpose(scrollRect);
- if (sourceRect.isValid()) {
- if (wbs->bltRect(sourceRect, dx, dy, q))
- childExpose -= destRect;
- }
-
- if (inDirtyList) {
- if (rect == q->rect()) {
- dirty.translate(dx, dy);
- } else {
- QRegion dirtyScrollRegion = dirty.intersected(scrollRect);
- if (!dirtyScrollRegion.isEmpty()) {
- dirty -= dirtyScrollRegion;
- dirtyScrollRegion.translate(dx, dy);
- dirty += dirtyScrollRegion;
- }
- }
- }
-
- if (!q->updatesEnabled())
- return;
-
- if (!childExpose.isEmpty()) {
- wbs->markDirty(childExpose, q);
- isScrolled = true;
- }
-
- // Instead of using native scroll-on-screen, we copy from
- // backingstore, giving only one screen update for each
- // scroll, and a solid appearance
- wbs->markDirtyOnScreen(destRect, q, toplevelOffset);
- }
-}
-
-static inline bool discardSyncRequest(QWidget *tlw, QTLWExtra *tlwExtra)
-{
- if (!tlw || !tlwExtra)
- return true;
-
-#ifdef Q_WS_X11
- // Delay the sync until we get an Expose event from X11 (initial show).
- // Qt::WA_Mapped is set to true, but the actual mapping has not yet occurred.
- // However, we must repaint immediately regardless of the state if someone calls repaint().
- if (tlwExtra->waitingForMapNotify && !tlwExtra->inRepaint)
- return true;
-#endif
-
- if (!tlw->testAttribute(Qt::WA_Mapped))
- return true;
-
- if (!tlw->isVisible()
-#ifndef Q_WS_X11
- // If we're minimized on X11, WA_Mapped will be false and we
- // will return in the case above. Some window managers on X11
- // sends us the PropertyNotify to change the minimized state
- // *AFTER* we've received the expose event, which is baaad.
- || tlw->isMinimized()
-#endif
- )
- return true;
-
- return false;
-}
-
-/*!
- Synchronizes the \a exposedRegion of the \a exposedWidget with the backing store.
-
- If there's nothing to repaint, the area is flushed and painting does not occur;
- otherwise the area is marked as dirty on screen and will be flushed right after
- we are done with all painting.
-*/
-void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedRegion)
-{
- QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
- if (discardSyncRequest(tlw, tlwExtra) || tlwExtra->inTopLevelResize)
- return;
-
- if (!exposedWidget || !exposedWidget->internalWinId() || !exposedWidget->isVisible()
- || !exposedWidget->updatesEnabled() || exposedRegion.isEmpty()) {
- return;
- }
-
- // If there's no preserved contents support we always need
- // to do a full repaint before flushing
- if (!windowSurface->hasFeature(QWindowSurface::PreservedContents))
- fullUpdatePending = true;
-
- // Nothing to repaint.
- if (!isDirty()) {
- qt_flush(exposedWidget, exposedRegion, windowSurface, tlw, tlwOffset);
- return;
- }
-
- if (exposedWidget != tlw)
- markDirtyOnScreen(exposedRegion, exposedWidget, exposedWidget->mapTo(tlw, QPoint()));
- else
- markDirtyOnScreen(exposedRegion, exposedWidget, QPoint());
- sync();
-}
-
-/*!
- Synchronizes the backing store, i.e. dirty areas are repainted and flushed.
-*/
-void QWidgetBackingStore::sync()
-{
- QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
- if (discardSyncRequest(tlw, tlwExtra)) {
- // If the top-level is minimized, it's not visible on the screen so we can delay the
- // update until it's shown again. In order to do that we must keep the dirty states.
- // These will be cleared when we receive the first expose after showNormal().
- // However, if the widget is not visible (isVisible() returns false), everything will
- // be invalidated once the widget is shown again, so clear all dirty states.
- if (!tlw->isVisible()) {
- dirty = QRegion();
- for (int i = 0; i < dirtyWidgets.size(); ++i)
- resetWidget(dirtyWidgets.at(i));
- dirtyWidgets.clear();
- fullUpdatePending = false;
- }
- return;
- }
-
- const bool updatesDisabled = !tlw->updatesEnabled();
- bool repaintAllWidgets = false;
-
- const bool inTopLevelResize = tlwExtra->inTopLevelResize;
- const QRect tlwRect(topLevelRect());
-#ifdef Q_WS_QPA
- const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size());
-#else
- const QRect surfaceGeometry(windowSurface->geometry());
-#endif
- if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) {
- if (hasStaticContents()) {
- // Repaint existing dirty area and newly visible area.
- const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
- const QRegion staticRegion(staticContents(0, clipRect));
- QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height());
- newVisible -= staticRegion;
- dirty += newVisible;
- windowSurface->setStaticContents(staticRegion);
- } else {
- // Repaint everything.
- dirty = QRegion(0, 0, tlwRect.width(), tlwRect.height());
- for (int i = 0; i < dirtyWidgets.size(); ++i)
- resetWidget(dirtyWidgets.at(i));
- dirtyWidgets.clear();
- repaintAllWidgets = true;
- }
- }
-
-#ifdef Q_WS_QPA
- if (inTopLevelResize || surfaceGeometry.size() != tlwRect.size())
- windowSurface->resize(tlwRect.size());
-#else
- if (inTopLevelResize || surfaceGeometry != tlwRect)
- windowSurface->setGeometry(tlwRect);
-#endif
-
- if (updatesDisabled)
- return;
-
- if (hasDirtyFromPreviousSync)
- dirty += dirtyFromPreviousSync;
-
- // Contains everything that needs repaint.
- QRegion toClean(dirty);
-
- // Loop through all update() widgets and remove them from the list before they are
- // painted (in case someone calls update() in paintEvent). If the widget is opaque
- // and does not have transparent overlapping siblings, append it to the
- // opaqueNonOverlappedWidgets list and paint it directly without composition.
- QVarLengthArray<QWidget *, 32> opaqueNonOverlappedWidgets;
- for (int i = 0; i < dirtyWidgets.size(); ++i) {
- QWidget *w = dirtyWidgets.at(i);
- QWidgetPrivate *wd = w->d_func();
- if (wd->data.in_destructor)
- continue;
-
- // Clip with mask() and clipRect().
- wd->dirty &= wd->clipRect();
- wd->clipToEffectiveMask(wd->dirty);
-
- // Subtract opaque siblings and children.
- bool hasDirtySiblingsAbove = false;
- // We know for sure that the widget isn't overlapped if 'isMoved' is true.
- if (!wd->isMoved)
- wd->subtractOpaqueSiblings(wd->dirty, &hasDirtySiblingsAbove);
- // Scrolled and moved widgets must draw all children.
- if (!wd->isScrolled && !wd->isMoved)
- wd->subtractOpaqueChildren(wd->dirty, w->rect());
-
- if (wd->dirty.isEmpty()) {
- resetWidget(w);
- continue;
- }
-
- const QRegion widgetDirty(w != tlw ? wd->dirty.translated(w->mapTo(tlw, QPoint()))
- : wd->dirty);
- toClean += widgetDirty;
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (tlw->d_func()->extra->proxyWidget) {
- resetWidget(w);
- continue;
- }
-#endif
-
- if (!hasDirtySiblingsAbove && wd->isOpaque && !dirty.intersects(widgetDirty.boundingRect())) {
- opaqueNonOverlappedWidgets.append(w);
- } else {
- resetWidget(w);
- dirty += widgetDirty;
- }
- }
- dirtyWidgets.clear();
-
- fullUpdatePending = false;
-
- if (toClean.isEmpty()) {
- // Nothing to repaint. However, we might have newly exposed areas on the
- // screen if this function was called from sync(QWidget *, QRegion)), so
- // we have to make sure those are flushed.
- flush();
- return;
- }
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (tlw->d_func()->extra->proxyWidget) {
- updateStaticContentsSize();
- dirty = QRegion();
- const QVector<QRect> rects(toClean.rects());
- for (int i = 0; i < rects.size(); ++i)
- tlw->d_func()->extra->proxyWidget->update(rects.at(i));
- return;
- }
-#endif
-
-#ifndef Q_BACKINGSTORE_SUBSURFACES
- BeginPaintInfo beginPaintInfo;
- beginPaint(toClean, tlw, windowSurface, &beginPaintInfo);
- if (beginPaintInfo.nothingToPaint) {
- for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i)
- resetWidget(opaqueNonOverlappedWidgets[i]);
- dirty = QRegion();
- return;
- }
-#endif
-
- // Must do this before sending any paint events because
- // the size may change in the paint event.
- updateStaticContentsSize();
- const QRegion dirtyCopy(dirty);
- dirty = QRegion();
-
- // Paint opaque non overlapped widgets.
- for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i) {
- QWidget *w = opaqueNonOverlappedWidgets[i];
- QWidgetPrivate *wd = w->d_func();
-
- int flags = QWidgetPrivate::DrawRecursive;
- // Scrolled and moved widgets must draw all children.
- if (!wd->isScrolled && !wd->isMoved)
- flags |= QWidgetPrivate::DontDrawOpaqueChildren;
- if (w == tlw)
- flags |= QWidgetPrivate::DrawAsRoot;
-
- QRegion toBePainted(wd->dirty);
- resetWidget(w);
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- QWindowSurface *subSurface = w->windowSurface();
- BeginPaintInfo beginPaintInfo;
-
- QPoint off = w->mapTo(tlw, QPoint());
- toBePainted.translate(off);
- beginPaint(toBePainted, w, subSurface, &beginPaintInfo, true);
- toBePainted.translate(-off);
-
- if (beginPaintInfo.nothingToPaint)
- continue;
-
- if (beginPaintInfo.windowSurfaceRecreated) {
- // Eep the window surface has changed. The old one may have been
- // deleted, in which case we will segfault on the call to
- // painterOffset() below. Use the new window surface instead.
- subSurface = w->windowSurface();
- }
-
- QPoint offset(tlwOffset);
- if (subSurface == windowSurface)
- offset += w->mapTo(tlw, QPoint());
- else
- offset = static_cast<QWSWindowSurface*>(subSurface)->painterOffset();
- wd->drawWidget(subSurface->paintDevice(), toBePainted, offset, flags, 0, this);
-
- endPaint(toBePainted, subSurface, &beginPaintInfo);
-#else
- QPoint offset(tlwOffset);
- if (w != tlw)
- offset += w->mapTo(tlw, QPoint());
- wd->drawWidget(windowSurface->paintDevice(), toBePainted, offset, flags, 0, this);
-#endif
- }
-
- // Paint the rest with composition.
-#ifndef Q_BACKINGSTORE_SUBSURFACES
- if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
- const int flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
- tlw->d_func()->drawWidget(windowSurface->paintDevice(), dirtyCopy, tlwOffset, flags, 0, this);
- }
-
- endPaint(toClean, windowSurface, &beginPaintInfo);
-#else
- if (!repaintAllWidgets && dirtyCopy.isEmpty())
- return; // Nothing more to paint.
-
- QList<QWindowSurface *> surfaceList(subSurfaces);
- surfaceList.prepend(windowSurface);
- const QRect dirtyBoundingRect(dirtyCopy.boundingRect());
-
- // Loop through all window surfaces (incl. the top-level surface) and
- // repaint those intersecting with the bounding rect of the dirty region.
- for (int i = 0; i < surfaceList.size(); ++i) {
- QWindowSurface *subSurface = surfaceList.at(i);
- QWidget *w = subSurface->window();
- QWidgetPrivate *wd = w->d_func();
-
- const QRect clipRect = wd->clipRect().translated(w->mapTo(tlw, QPoint()));
- if (!qRectIntersects(dirtyBoundingRect, clipRect))
- continue;
-
- toClean = dirtyCopy;
- BeginPaintInfo beginPaintInfo;
- beginPaint(toClean, w, subSurface, &beginPaintInfo);
- if (beginPaintInfo.nothingToPaint)
- continue;
-
- if (beginPaintInfo.windowSurfaceRecreated) {
- // Eep the window surface has changed. The old one may have been
- // deleted, in which case we will segfault on the call to
- // painterOffset() below. Use the new window surface instead.
- subSurface = w->windowSurface();
- }
-
- int flags = QWidgetPrivate::DrawRecursive;
- if (w == tlw)
- flags |= QWidgetPrivate::DrawAsRoot;
- const QPoint painterOffset = static_cast<QWSWindowSurface*>(subSurface)->painterOffset();
- wd->drawWidget(subSurface->paintDevice(), toClean, painterOffset, flags, 0, this);
-
- endPaint(toClean, subSurface, &beginPaintInfo);
- }
-#endif
-}
-
-/*!
- Flushes the contents of the backing store into the top-level widget.
- If the \a widget is non-zero, the content is flushed to the \a widget.
- If the \a surface is non-zero, the content of the \a surface is flushed.
-*/
-void QWidgetBackingStore::flush(QWidget *widget, QWindowSurface *surface)
-{
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
- paintWindowDecoration();
-#endif
-
- if (!dirtyOnScreen.isEmpty()) {
- QWidget *target = widget ? widget : tlw;
- QWindowSurface *source = surface ? surface : windowSurface;
- qt_flush(target, dirtyOnScreen, source, tlw, tlwOffset);
- dirtyOnScreen = QRegion();
- }
-
- if (!dirtyOnScreenWidgets || dirtyOnScreenWidgets->isEmpty())
- return;
-
- for (int i = 0; i < dirtyOnScreenWidgets->size(); ++i) {
- QWidget *w = dirtyOnScreenWidgets->at(i);
- QWidgetPrivate *wd = w->d_func();
- Q_ASSERT(wd->needsFlush);
- qt_flush(w, *wd->needsFlush, windowSurface, tlw, tlwOffset);
- *wd->needsFlush = QRegion();
- }
- dirtyOnScreenWidgets->clear();
-}
-
-static inline bool discardInvalidateBufferRequest(QWidget *widget, QTLWExtra *tlwExtra)
-{
- Q_ASSERT(widget);
- if (QApplication::closingDown())
- return true;
-
- if (!tlwExtra || tlwExtra->inTopLevelResize || !tlwExtra->backingStore)
- return true;
-
- if (!widget->isVisible() || !widget->updatesEnabled())
- return true;
-
- return false;
-}
-
-/*!
- Invalidates the buffer when the widget is resized.
- Static areas are never invalidated unless absolutely needed.
-*/
-void QWidgetPrivate::invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize)
-{
- Q_Q(QWidget);
- Q_ASSERT(!q->isWindow());
- Q_ASSERT(q->parentWidget());
-
- const bool staticContents = q->testAttribute(Qt::WA_StaticContents);
- const bool sizeDecreased = (data.crect.width() < oldSize.width())
- || (data.crect.height() < oldSize.height());
-
- const QPoint offset(data.crect.x() - oldPos.x(), data.crect.y() - oldPos.y());
- const bool parentAreaExposed = !offset.isNull() || sizeDecreased;
- const QRect newWidgetRect(q->rect());
- const QRect oldWidgetRect(0, 0, oldSize.width(), oldSize.height());
-
- if (!staticContents || graphicsEffect) {
- QRegion staticChildren;
- QWidgetBackingStore *bs = 0;
- if (offset.isNull() && (bs = maybeBackingStore()))
- staticChildren = bs->staticContents(q, oldWidgetRect);
- const bool hasStaticChildren = !staticChildren.isEmpty();
-
- if (hasStaticChildren) {
- QRegion dirty(newWidgetRect);
- dirty -= staticChildren;
- invalidateBuffer(dirty);
- } else {
- // Entire widget needs repaint.
- invalidateBuffer(newWidgetRect);
- }
-
- if (!parentAreaExposed)
- return;
-
- // Invalidate newly exposed area of the parent.
- if (!graphicsEffect && extra && extra->hasMask) {
- QRegion parentExpose(extra->mask.translated(oldPos));
- parentExpose &= QRect(oldPos, oldSize);
- if (hasStaticChildren)
- parentExpose -= data.crect; // Offset is unchanged, safe to do this.
- q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
- } else {
- if (hasStaticChildren && !graphicsEffect) {
- QRegion parentExpose(QRect(oldPos, oldSize));
- parentExpose -= data.crect; // Offset is unchanged, safe to do this.
- q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
- } else {
- q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(QRect(oldPos, oldSize)));
- }
- }
- return;
- }
-
- // Move static content to its new position.
- if (!offset.isNull()) {
- if (sizeDecreased) {
- const QSize minSize(qMin(oldSize.width(), data.crect.width()),
- qMin(oldSize.height(), data.crect.height()));
- moveRect(QRect(oldPos, minSize), offset.x(), offset.y());
- } else {
- moveRect(QRect(oldPos, oldSize), offset.x(), offset.y());
- }
- }
-
- // Invalidate newly visible area of the widget.
- if (!sizeDecreased || !oldWidgetRect.contains(newWidgetRect)) {
- QRegion newVisible(newWidgetRect);
- newVisible -= oldWidgetRect;
- invalidateBuffer(newVisible);
- }
-
- if (!parentAreaExposed)
- return;
-
- // Invalidate newly exposed area of the parent.
- const QRect oldRect(oldPos, oldSize);
- if (extra && extra->hasMask) {
- QRegion parentExpose(oldRect);
- parentExpose &= extra->mask.translated(oldPos);
- parentExpose -= (extra->mask.translated(data.crect.topLeft()) & data.crect);
- q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
- } else {
- QRegion parentExpose(oldRect);
- parentExpose -= data.crect;
- q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
- }
-}
-
-/*!
- Invalidates the \a rgn (in widget's coordinates) of the backing store, i.e.
- all widgets intersecting with the region will be repainted when the backing store
- is synced.
-
- ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
-*/
-void QWidgetPrivate::invalidateBuffer(const QRegion &rgn)
-{
- Q_Q(QWidget);
-
- QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData();
- if (discardInvalidateBufferRequest(q, tlwExtra) || rgn.isEmpty())
- return;
-
- QRegion wrgn(rgn);
- wrgn &= clipRect();
- if (!graphicsEffect && extra && extra->hasMask)
- wrgn &= extra->mask;
- if (wrgn.isEmpty())
- return;
-
- tlwExtra->backingStore->markDirty(wrgn, q, false, true);
-}
-
-/*!
- This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but
- is more efficient as it eliminates QRegion operations/allocations and can
- use the rect more precisely for additional cut-offs.
-
- ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
-*/
-void QWidgetPrivate::invalidateBuffer(const QRect &rect)
-{
- Q_Q(QWidget);
-
- QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData();
- if (discardInvalidateBufferRequest(q, tlwExtra) || rect.isEmpty())
- return;
-
- QRect wRect(rect);
- wRect &= clipRect();
- if (wRect.isEmpty())
- return;
-
- if (graphicsEffect || !extra || !extra->hasMask) {
- tlwExtra->backingStore->markDirty(wRect, q, false, true);
- return;
- }
-
- QRegion wRgn(extra->mask);
- wRgn &= wRect;
- if (wRgn.isEmpty())
- return;
-
- tlwExtra->backingStore->markDirty(wRgn, q, false, true);
-}
-
-void QWidgetPrivate::repaint_sys(const QRegion &rgn)
-{
- if (data.in_destructor)
- return;
-
- Q_Q(QWidget);
- if (q->testAttribute(Qt::WA_StaticContents)) {
- if (!extra)
- createExtra();
- extra->staticContentsSize = data.crect.size();
- }
-
-#ifdef Q_WS_QPA //Dont even call q->p
- QPaintEngine *engine = 0;
-#else
- QPaintEngine *engine = q->paintEngine();
-#endif
- // QGLWidget does not support partial updates if:
- // 1) The context is double buffered
- // 2) The context is single buffered and auto-fill background is enabled.
- const bool noPartialUpdateSupport = (engine && (engine->type() == QPaintEngine::OpenGL
- || engine->type() == QPaintEngine::OpenGL2))
- && (usesDoubleBufferedGLContext || q->autoFillBackground());
- QRegion toBePainted(noPartialUpdateSupport ? q->rect() : rgn);
-
-#ifdef Q_WS_MAC
- // No difference between update() and repaint() on the Mac.
- update_sys(toBePainted);
- return;
-#endif
-
- toBePainted &= clipRect();
- clipToEffectiveMask(toBePainted);
- if (toBePainted.isEmpty())
- return; // Nothing to repaint.
-
-#ifndef QT_NO_PAINT_DEBUG
- bool flushed = QWidgetBackingStore::flushPaint(q, toBePainted);
-#endif
-
- drawWidget(q, toBePainted, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen, 0);
-
-#ifndef QT_NO_PAINT_DEBUG
- if (flushed)
- QWidgetBackingStore::unflushPaint(q, toBePainted);
-#endif
-
- if (!q->testAttribute(Qt::WA_PaintOutsidePaintEvent) && q->paintingActive())
- qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qbackingstore_p.h b/src/gui/painting/qbackingstore_p.h
deleted file mode 100644
index 1ef2e4e1b0..0000000000
--- a/src/gui/painting/qbackingstore_p.h
+++ /dev/null
@@ -1,278 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QBACKINGSTORE_P_H
-#define QBACKINGSTORE_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 <QDebug>
-#include <QtGui/qwidget.h>
-#include <private/qwidget_p.h>
-#include <private/qwindowsurface_p.h>
-#ifdef Q_WS_QWS
-#include <private/qwindowsurface_qws_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QWindowSurface;
-
-struct BeginPaintInfo {
- inline BeginPaintInfo() : wasFlushed(0), nothingToPaint(0), windowSurfaceRecreated(0) {}
- uint wasFlushed : 1;
- uint nothingToPaint : 1;
- uint windowSurfaceRecreated : 1;
-};
-
-class Q_AUTOTEST_EXPORT QWidgetBackingStore
-{
-public:
- QWidgetBackingStore(QWidget *t);
- ~QWidgetBackingStore();
-
- static void showYellowThing(QWidget *widget, const QRegion &rgn, int msec, bool);
-
- void sync(QWidget *exposedWidget, const QRegion &exposedRegion);
- void sync();
- void flush(QWidget *widget = 0, QWindowSurface *surface = 0);
-
- inline QPoint topLevelOffset() const { return tlwOffset; }
-
- QWindowSurface *surface() const { return windowSurface; }
-
- inline bool isDirty() const
- {
- return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !hasDirtyFromPreviousSync
- && !fullUpdatePending
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
- && !hasDirtyWindowDecoration()
-#endif
- );
- }
-
- // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
- void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately = false,
- bool invalidateBuffer = false);
- void markDirty(const QRect &rect, QWidget *widget, bool updateImmediately = false,
- bool invalidateBuffer = false);
-
-private:
- QWidget *tlw;
- QRegion dirtyOnScreen; // needsFlush
- QRegion dirty; // needsRepaint
- QRegion dirtyFromPreviousSync;
- QVector<QWidget *> dirtyWidgets;
- QVector<QWidget *> *dirtyOnScreenWidgets;
- QList<QWidget *> staticWidgets;
- QWindowSurface *windowSurface;
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- QList<QWindowSurface*> subSurfaces;
-#endif
- uint hasDirtyFromPreviousSync : 1;
- uint fullUpdatePending : 1;
-
- QPoint tlwOffset;
-
- static bool flushPaint(QWidget *widget, const QRegion &rgn);
- static void unflushPaint(QWidget *widget, const QRegion &rgn);
-
- bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget);
- void releaseBuffer();
-
- void beginPaint(QRegion &toClean, QWidget *widget, QWindowSurface *windowSurface,
- BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates = true);
- void endPaint(const QRegion &cleaned, QWindowSurface *windowSurface, BeginPaintInfo *beginPaintInfo);
-
- QRegion dirtyRegion(QWidget *widget = 0) const;
- QRegion staticContents(QWidget *widget = 0, const QRect &withinClipRect = QRect()) const;
-
- void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset);
-
- void removeDirtyWidget(QWidget *w);
-
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
- bool hasDirtyWindowDecoration() const;
- void paintWindowDecoration();
-#endif
- void updateLists(QWidget *widget);
-
- inline void addDirtyWidget(QWidget *widget, const QRegion &rgn)
- {
- if (widget && !widget->d_func()->inDirtyList && !widget->data->in_destructor) {
- QWidgetPrivate *widgetPrivate = widget->d_func();
-#ifndef QT_NO_GRAPHICSEFFECT
- if (widgetPrivate->graphicsEffect)
- widgetPrivate->dirty = widgetPrivate->effectiveRectFor(rgn.boundingRect());
- else
-#endif //QT_NO_GRAPHICSEFFECT
- widgetPrivate->dirty = rgn;
- dirtyWidgets.append(widget);
- widgetPrivate->inDirtyList = true;
- }
- }
-
- inline void dirtyWidgetsRemoveAll(QWidget *widget)
- {
- int i = 0;
- while (i < dirtyWidgets.size()) {
- if (dirtyWidgets.at(i) == widget)
- dirtyWidgets.remove(i);
- else
- ++i;
- }
- }
-
- inline void addStaticWidget(QWidget *widget)
- {
- if (!widget)
- return;
-
- Q_ASSERT(widget->testAttribute(Qt::WA_StaticContents));
- if (!staticWidgets.contains(widget))
- staticWidgets.append(widget);
- }
-
- inline void removeStaticWidget(QWidget *widget)
- { staticWidgets.removeAll(widget); }
-
- // Move the reparented widget and all its static children from this backing store
- // to the new backing store if reparented into another top-level / backing store.
- inline void moveStaticWidgets(QWidget *reparented)
- {
- Q_ASSERT(reparented);
- QWidgetBackingStore *newBs = reparented->d_func()->maybeBackingStore();
- if (newBs == this)
- return;
-
- int i = 0;
- while (i < staticWidgets.size()) {
- QWidget *w = staticWidgets.at(i);
- if (reparented == w || reparented->isAncestorOf(w)) {
- staticWidgets.removeAt(i);
- if (newBs)
- newBs->addStaticWidget(w);
- } else {
- ++i;
- }
- }
- }
-
- inline QRect topLevelRect() const
- {
-#ifdef Q_WS_QWS
- return tlw->frameGeometry();
-#else
- return tlw->data->crect;
-#endif
- }
-
- inline void appendDirtyOnScreenWidget(QWidget *widget)
- {
- if (!widget)
- return;
-
- if (!dirtyOnScreenWidgets) {
- dirtyOnScreenWidgets = new QVector<QWidget *>;
- dirtyOnScreenWidgets->append(widget);
- } else if (!dirtyOnScreenWidgets->contains(widget)) {
- dirtyOnScreenWidgets->append(widget);
- }
- }
-
- inline void dirtyOnScreenWidgetsRemoveAll(QWidget *widget)
- {
- if (!widget || !dirtyOnScreenWidgets)
- return;
-
- int i = 0;
- while (i < dirtyOnScreenWidgets->size()) {
- if (dirtyOnScreenWidgets->at(i) == widget)
- dirtyOnScreenWidgets->remove(i);
- else
- ++i;
- }
- }
-
- inline void resetWidget(QWidget *widget)
- {
- if (widget) {
- widget->d_func()->inDirtyList = false;
- widget->d_func()->isScrolled = false;
- widget->d_func()->isMoved = false;
- widget->d_func()->dirty = QRegion();
- }
- }
-
- inline void updateStaticContentsSize()
- {
- for (int i = 0; i < staticWidgets.size(); ++i) {
- QWidgetPrivate *wd = staticWidgets.at(i)->d_func();
- if (!wd->extra)
- wd->createExtra();
- wd->extra->staticContentsSize = wd->data.crect.size();
- }
- }
-
- inline bool hasStaticContents() const
- { return !staticWidgets.isEmpty() && windowSurface->hasFeature(QWindowSurface::StaticContents); }
-
- friend QRegion qt_dirtyRegion(QWidget *);
- friend class QWidgetPrivate;
- friend class QWidget;
- friend class QWSManagerPrivate;
- friend class QETWidget;
- friend class QWindowSurface;
- friend class QWSWindowSurface;
-};
-
-QT_END_NAMESPACE
-
-#endif // QBACKINGSTORE_P_H
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 79c4c4e4e4..98ed02879a 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -48,7 +48,7 @@
#include "qline.h"
#include "qdebug.h"
#include <QtCore/qcoreapplication.h>
-#include "private/qstylehelper_p.h"
+#include "private/qhexstring_p.h"
#include <QtCore/qnumeric.h>
QT_BEGIN_NAMESPACE
@@ -712,36 +712,6 @@ void QBrush::setColor(const QColor &c)
Sets the brush color to the given \a color.
*/
-
-#ifdef QT3_SUPPORT
-
-/*!
- \fn void QBrush::setPixmap(const QPixmap &pixmap)
-
- \compat
-
- Sets a custom pattern for this brush.
-
- Use setTexture() instead.
-*/
-
-/*!
- \fn QPixmap *QBrush::pixmap() const
-
- Returns a pointer to the custom brush pattern.
-
- Use texture() instead.
-*/
-QPixmap *QBrush::pixmap() const
-{
- if (d->style != Qt::TexturePattern)
- return 0;
- QTexturedBrushData *data = static_cast<QTexturedBrushData*>(d.data());
- QPixmap &pixmap = data->pixmap();
- return pixmap.isNull() ? 0 : &pixmap;
-}
-#endif
-
/*!
\fn QPixmap QBrush::texture() const
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index 4a0bfcc8e4..00c0ebfa3a 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -126,12 +126,6 @@ public:
bool operator==(const QBrush &b) const;
inline bool operator!=(const QBrush &b) const { return !(operator==(b)); }
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT operator const QColor&() const;
- QT3_SUPPORT QPixmap *pixmap() const;
- inline QT3_SUPPORT void setPixmap(const QPixmap &pixmap) { setTexture(pixmap); }
-#endif
-
private:
#if defined(Q_WS_X11)
friend class QX11PaintEngine;
@@ -185,10 +179,6 @@ inline const QMatrix &QBrush::matrix() const { return d->transform.toAffine(); }
inline QTransform QBrush::transform() const { return d->transform; }
inline bool QBrush::isDetached() const { return d->ref == 1; }
-#ifdef QT3_SUPPORT
-inline QBrush::operator const QColor&() const { return d->color; }
-#endif
-
/*******************************************************************************
* QGradients
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 3d895b7753..5235cb9013 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -2462,30 +2462,6 @@ void QColor::invalidate()
ct.argb.pad = 0;
}
-#ifdef QT3_SUPPORT
-
-/*!
- Returns the pixel value used by the underlying window system to refer to a
- color.
-
- Use QColormap::pixel() instead.
-
- \oldcode
- QColor myColor;
- uint pixel = myColor.pixel(screen);
- \newcode
- QColormap cmap = QColormap::instance(screen);
- uint pixel = cmap.pixel(*this);
- \endcode
-*/
-uint QColor::pixel(int screen) const
-{
- QColormap cmap = QColormap::instance(screen);
- return cmap.pixel(*this);
-}
-
-#endif // QT3_SUPPORT
-
/*****************************************************************************
QColor stream functions
*****************************************************************************/
diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h
index 533f6fe315..1dd6c2a099 100644
--- a/src/gui/painting/qcolor.h
+++ b/src/gui/painting/qcolor.h
@@ -208,30 +208,9 @@ public:
static void setAllowX11ColorNames(bool enabled);
#endif
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT_CONSTRUCTOR QColor(int x, int y, int z, Spec colorSpec)
- { if (colorSpec == Hsv) setHsv(x, y, z); else setRgb(x, y, z); }
-
- inline QT3_SUPPORT void rgb(int *r, int *g, int *b) const
- { getRgb(r, g, b); }
- inline QT3_SUPPORT void hsv(int *h, int *s, int *v) const
- { getHsv(h, s, v); }
-
- inline QT3_SUPPORT void setRgba(int r, int g, int b, int a)
- { setRgb(r, g, b, a); }
- inline QT3_SUPPORT void getRgba(int *r, int *g, int *b, int *a) const
- { getRgb(r, g, b, a); }
-
- QT3_SUPPORT uint pixel(int screen = -1) const;
-#endif
-
static bool isValidColor(const QString &name);
private:
-#ifndef QT3_SUPPORT
- // do not allow a spec to be used as an alpha value
- QColor(int, int, int, Spec);
-#endif
void invalidate();
bool setColorFromString(const QString &name);
diff --git a/src/gui/painting/qcolormap_mac.cpp b/src/gui/painting/qcolormap_mac.cpp
deleted file mode 100644
index 0c3fd70468..0000000000
--- a/src/gui/painting/qcolormap_mac.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcolormap.h"
-#include "qcolor.h"
-
-QT_BEGIN_NAMESPACE
-
-class QColormapPrivate
-{
-public:
- inline QColormapPrivate()
- : ref(1)
- { }
-
- QAtomicInt ref;
-};
-static QColormap *qt_mac_global_map = 0;
-
-void QColormap::initialize()
-{
- qt_mac_global_map = new QColormap;
-}
-
-void QColormap::cleanup()
-{
- delete qt_mac_global_map;
- qt_mac_global_map = 0;
-}
-
-QColormap QColormap::instance(int)
-{
- return *qt_mac_global_map;
-}
-
-QColormap::QColormap() : d(new QColormapPrivate)
-{}
-
-QColormap::QColormap(const QColormap &colormap) :d (colormap.d)
-{ d->ref.ref(); }
-
-QColormap::~QColormap()
-{
- if (!d->ref.deref())
- delete d;
-}
-
-QColormap::Mode QColormap::mode() const
-{ return QColormap::Direct; }
-
-int QColormap::depth() const
-{
- return 32;
-}
-
-int QColormap::size() const
-{
- return -1;
-}
-
-uint QColormap::pixel(const QColor &color) const
-{ return color.rgba(); }
-
-const QColor QColormap::colorAt(uint pixel) const
-{ return QColor(pixel); }
-
-const QVector<QColor> QColormap::colormap() const
-{ return QVector<QColor>(); }
-
-QColormap &QColormap::operator=(const QColormap &colormap)
-{ qAtomicAssign(d, colormap.d); return *this; }
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qcolormap_qpa.cpp b/src/gui/painting/qcolormap_qpa.cpp
index 40bf364c5a..31fc41b94d 100644
--- a/src/gui/painting/qcolormap_qpa.cpp
+++ b/src/gui/painting/qcolormap_qpa.cpp
@@ -42,8 +42,7 @@
#include "qcolormap.h"
#include "qcolor.h"
#include "qpaintdevice.h"
-#include "private/qapplication_p.h"
-#include "private/qgraphicssystem_p.h"
+#include "private/qguiapplication_p.h"
QT_BEGIN_NAMESPACE
@@ -67,7 +66,7 @@ void QColormap::initialize()
{
screenMap = new QColormapPrivate;
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
QList<QPlatformScreen*> screens = pi->screens();
screenMap->depth = screens.at(0)->depth();
diff --git a/src/gui/painting/qcolormap_qws.cpp b/src/gui/painting/qcolormap_qws.cpp
deleted file mode 100644
index 00d3a43e4f..0000000000
--- a/src/gui/painting/qcolormap_qws.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcolormap.h"
-#include "qcolor.h"
-#include "qpaintdevice.h"
-#include "qscreen_qws.h"
-#include "qwsdisplay_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-class QColormapPrivate
-{
-public:
- inline QColormapPrivate()
- : ref(1), mode(QColormap::Direct), depth(0), numcolors(0)
- { }
-
- QAtomicInt ref;
-
- QColormap::Mode mode;
- int depth;
- int numcolors;
-};
-
-static QColormapPrivate *screenMap = 0;
-
-void QColormap::initialize()
-{
- screenMap = new QColormapPrivate;
-
- screenMap->depth = QPaintDevice::qwsDisplay()->depth();
- if (screenMap->depth < 8) {
- screenMap->mode = QColormap::Indexed;
- screenMap->numcolors = 256;
- } else {
- screenMap->mode = QColormap::Direct;
- screenMap->numcolors = -1;
- }
-}
-
-void QColormap::cleanup()
-{
- delete screenMap;
- screenMap = 0;
-}
-
-QColormap QColormap::instance(int /*screen*/)
-{
- return QColormap();
-}
-
-QColormap::QColormap()
- : d(screenMap)
-{ d->ref.ref(); }
-
-QColormap::QColormap(const QColormap &colormap)
- :d (colormap.d)
-{ d->ref.ref(); }
-
-QColormap::~QColormap()
-{
- if (!d->ref.deref())
- delete d;
-}
-
-QColormap::Mode QColormap::mode() const
-{ return d->mode; }
-
-
-int QColormap::depth() const
-{ return d->depth; }
-
-
-int QColormap::size() const
-{
- return d->numcolors;
-}
-
-uint QColormap::pixel(const QColor &color) const
-{
- QRgb rgb = color.rgba();
- if (d->mode == QColormap::Direct) {
- switch(d->depth) {
- case 16:
- return qt_convRgbTo16(rgb);
- case 24:
- case 32:
- {
- const int r = qRed(rgb);
- const int g = qGreen(rgb);
- const int b = qBlue(rgb);
- const int red_shift = 16;
- const int green_shift = 8;
- const int red_mask = 0xff0000;
- const int green_mask = 0x00ff00;
- const int blue_mask = 0x0000ff;
- const int tg = g << green_shift;
-#ifdef QT_QWS_DEPTH_32_BGR
- if (qt_screen->pixelType() == QScreen::BGRPixel) {
- const int tb = b << red_shift;
- return 0xff000000 | (r & blue_mask) | (tg & green_mask) | (tb & red_mask);
- }
-#endif
- const int tr = r << red_shift;
- return 0xff000000 | (b & blue_mask) | (tg & green_mask) | (tr & red_mask);
- }
- }
- }
- return qt_screen->alloc(qRed(rgb), qGreen(rgb), qBlue(rgb));
-}
-
-const QColor QColormap::colorAt(uint pixel) const
-{
- if (d->mode == Direct) {
- if (d->depth == 16) {
- pixel = qt_conv16ToRgb(pixel);
- }
- const int red_shift = 16;
- const int green_shift = 8;
- const int red_mask = 0xff0000;
- const int green_mask = 0x00ff00;
- const int blue_mask = 0x0000ff;
-#ifdef QT_QWS_DEPTH_32_BGR
- if (qt_screen->pixelType() == QScreen::BGRPixel) {
- return QColor((pixel & blue_mask),
- (pixel & green_mask) >> green_shift,
- (pixel & red_mask) >> red_shift);
- }
-#endif
- return QColor((pixel & red_mask) >> red_shift,
- (pixel & green_mask) >> green_shift,
- (pixel & blue_mask));
- }
- Q_ASSERT_X(int(pixel) < qt_screen->colorCount(), "QColormap::colorAt", "pixel out of bounds of palette");
- return QColor(qt_screen->clut()[pixel]);
-}
-
-const QVector<QColor> QColormap::colormap() const
-{
- return QVector<QColor>();
-}
-
-QColormap &QColormap::operator=(const QColormap &colormap)
-{ qAtomicAssign(d, colormap.d); return *this; }
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qcolormap_s60.cpp b/src/gui/painting/qcolormap_s60.cpp
deleted file mode 100644
index 9dd5135d29..0000000000
--- a/src/gui/painting/qcolormap_s60.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcolormap.h"
-#include "qcolor.h"
-
-QT_BEGIN_NAMESPACE
-
-class QColormapPrivate
-{
-public:
- inline QColormapPrivate()
- : ref(1)
- { }
-
- QAtomicInt ref;
-};
-
-void QColormap::initialize()
-{
-}
-
-void QColormap::cleanup()
-{
-}
-
-QColormap QColormap::instance(int)
-{
- return QColormap();
-}
-
-QColormap::QColormap() : d(new QColormapPrivate)
-{}
-
-QColormap::QColormap(const QColormap &colormap) :d (colormap.d)
-{ d->ref.ref(); }
-
-QColormap::~QColormap()
-{
- if (!d->ref.deref())
- delete d;
-}
-
-QColormap::Mode QColormap::mode() const
-{ return QColormap::Direct; }
-
-int QColormap::depth() const
-{
- return 32;
-}
-
-int QColormap::size() const
-{
- return -1;
-}
-
-uint QColormap::pixel(const QColor &color) const
-{ return color.rgba(); }
-
-const QColor QColormap::colorAt(uint pixel) const
-{ return QColor(pixel); }
-
-const QVector<QColor> QColormap::colormap() const
-{ return QVector<QColor>(); }
-
-QColormap &QColormap::operator=(const QColormap &colormap)
-{ qAtomicAssign(d, colormap.d); return *this; }
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qcolormap_win.cpp b/src/gui/painting/qcolormap_win.cpp
deleted file mode 100644
index 4a95977438..0000000000
--- a/src/gui/painting/qcolormap_win.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcolor.h"
-#include "qcolormap.h"
-#include "qvector.h"
-#include "qt_windows.h"
-
-#if defined(Q_WS_WINCE)
-#include "qguifunctions_wince.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QColormapPrivate
-{
-public:
- inline QColormapPrivate()
- : ref(1), mode(QColormap::Direct), depth(0), hpal(0)
- { }
-
- QAtomicInt ref;
-
- QColormap::Mode mode;
- int depth;
- int numcolors;
-
- HPALETTE hpal;
- QVector<QColor> palette;
-};
-
-static QColormapPrivate *screenMap = 0;
-
-void QColormap::initialize()
-{
- HDC dc = qt_win_display_dc();
-
- screenMap = new QColormapPrivate;
- screenMap->depth = GetDeviceCaps(dc, BITSPIXEL);
-
- screenMap->numcolors = -1;
- if (GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE)
- screenMap->numcolors = GetDeviceCaps(dc, SIZEPALETTE);
-
- if (screenMap->numcolors <= 16 || screenMap->numcolors > 256) // no need to create palette
- return;
-
- LOGPALETTE* pal = 0;
- int numPalEntries = 6*6*6; // color cube
-
- pal = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) + numPalEntries * sizeof(PALETTEENTRY));
- // Make 6x6x6 color cube
- int idx = 0;
- for(int ir = 0x0; ir <= 0xff; ir+=0x33) {
- for(int ig = 0x0; ig <= 0xff; ig+=0x33) {
- for(int ib = 0x0; ib <= 0xff; ib+=0x33) {
- pal->palPalEntry[idx].peRed = ir;
- pal->palPalEntry[idx].peGreen = ig;
- pal->palPalEntry[idx].peBlue = ib;
- pal->palPalEntry[idx].peFlags = 0;
- idx++;
- }
- }
- }
-
- pal->palVersion = 0x300;
- pal->palNumEntries = numPalEntries;
-
- screenMap->hpal = CreatePalette(pal);
- if (!screenMap->hpal)
- qErrnoWarning("QColor::initialize: Failed to create logical palette");
- free (pal);
-
- SelectPalette(dc, screenMap->hpal, FALSE);
- RealizePalette(dc);
-
- PALETTEENTRY paletteEntries[256];
- screenMap->numcolors = GetPaletteEntries(screenMap->hpal, 0, 255, paletteEntries);
-
- screenMap->palette.resize(screenMap->numcolors);
- for (int i = 0; i < screenMap->numcolors; i++) {
- screenMap->palette[i] = qRgb(paletteEntries[i].peRed,
- paletteEntries[i].peGreen,
- paletteEntries[i].peBlue);
- }
-}
-
-void QColormap::cleanup()
-{
- if (!screenMap)
- return;
-
- if (screenMap->hpal) { // delete application global
- DeleteObject(screenMap->hpal); // palette
- screenMap->hpal = 0;
- }
-
- delete screenMap;
- screenMap = 0;
-}
-
-QColormap QColormap::instance(int)
-{
- Q_ASSERT_X(screenMap, "QColormap",
- "A QApplication object needs to be constructed before QColormap is used.");
- return QColormap();
-}
-
-QColormap::QColormap()
- : d(screenMap)
-{ d->ref.ref(); }
-
-QColormap::QColormap(const QColormap &colormap)
- :d (colormap.d)
-{ d->ref.ref(); }
-
-QColormap::~QColormap()
-{
- if (!d->ref.deref())
- delete d;
-}
-
-QColormap::Mode QColormap::mode() const
-{ return d->mode; }
-
-int QColormap::depth() const
-{ return d->depth; }
-
-int QColormap::size() const
-{ return d->numcolors; }
-
-uint QColormap::pixel(const QColor &color) const
-{
- const QColor c = color.toRgb();
- COLORREF rgb = RGB(c.red(), c.green(), c.blue());
- if (d->hpal)
- return PALETTEINDEX(GetNearestPaletteIndex(d->hpal, rgb));
- return rgb;
-}
-
-const QColor QColormap::colorAt(uint pixel) const
-{
- if (d->hpal) {
- if (pixel < uint(d->numcolors))
- return d->palette.at(pixel);
- return QColor();
- }
- return QColor(GetRValue(pixel), GetGValue(pixel), GetBValue(pixel));
-}
-
-
-HPALETTE QColormap::hPal()
-{ return screenMap ? screenMap->hpal : 0; }
-
-
-const QVector<QColor> QColormap::colormap() const
-{ return d->palette; }
-
-QColormap &QColormap::operator=(const QColormap &colormap)
-{ qAtomicAssign(d, colormap.d); return *this; }
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qcolormap_x11.cpp b/src/gui/painting/qcolormap_x11.cpp
deleted file mode 100644
index 1d6d7b8adb..0000000000
--- a/src/gui/painting/qcolormap_x11.cpp
+++ /dev/null
@@ -1,670 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcolormap.h"
-
-#include "qapplication.h"
-#include "qdebug.h"
-#include "qdesktopwidget.h"
-#include "qvarlengtharray.h"
-
-#include "qx11info_x11.h"
-#include <private/qt_x11_p.h>
-#include <limits.h>
-
-QT_BEGIN_NAMESPACE
-
-class QColormapPrivate
-{
-public:
- QColormapPrivate()
- : ref(1), mode(QColormap::Direct), depth(0),
- colormap(0), defaultColormap(true),
- visual(0), defaultVisual(true),
- r_max(0), g_max(0), b_max(0),
- r_shift(0), g_shift(0), b_shift(0)
- {}
-
- QAtomicInt ref;
-
- QColormap::Mode mode;
- int depth;
-
- Colormap colormap;
- bool defaultColormap;
-
- Visual *visual;
- bool defaultVisual;
-
- int r_max;
- int g_max;
- int b_max;
-
- uint r_shift;
- uint g_shift;
- uint b_shift;
-
- QVector<QColor> colors;
- QVector<int> pixels;
-};
-
-
-static uint right_align(uint v)
-{
- while (!(v & 0x1))
- v >>= 1;
- return v;
-}
-
-static int lowest_bit(uint v)
-{
- int i;
- uint b = 1u;
- for (i = 0; ((v & b) == 0u) && i < 32; ++i)
- b <<= 1u;
- return i == 32 ? -1 : i;
-}
-
-static int cube_root(int v)
-{
- if (v == 1)
- return 1;
- // brute force algorithm
- int i = 1;
- for (;;) {
- const int b = i * i * i;
- if (b <= v) {
- ++i;
- } else {
- --i;
- break;
- }
- }
- return i;
-}
-
-static Visual *find_visual(Display *display,
- int screen,
- int visual_class,
- int visual_id,
- int *depth,
- bool *defaultVisual)
-{
- XVisualInfo *vi, rvi;
- int count;
-
- uint mask = VisualScreenMask;
- rvi.screen = screen;
-
- if (visual_class != -1) {
- rvi.c_class = visual_class;
- mask |= VisualClassMask;
- }
- if (visual_id != -1) {
- rvi.visualid = visual_id;
- mask |= VisualIDMask;
- }
-
- Visual *visual = DefaultVisual(display, screen);
- *defaultVisual = true;
- *depth = DefaultDepth(display, screen);
-
- vi = XGetVisualInfo(display, mask, &rvi, &count);
- if (vi) {
- int best = 0;
- for (int x = 0; x < count; ++x) {
- if (vi[x].depth > vi[best].depth)
- best = x;
- }
- if (best >= 0 && best <= count && vi[best].visualid != XVisualIDFromVisual(visual)) {
- visual = vi[best].visual;
- *defaultVisual = (visual == DefaultVisual(display, screen));
- *depth = vi[best].depth;
- }
- }
- if (vi)
- XFree((char *)vi);
- return visual;
-}
-
-static void query_colormap(QColormapPrivate *d, int screen)
-{
- Display *display = QX11Info::display();
-
- // query existing colormap
- int q_colors = (((1u << d->depth) > 256u) ? 256u : (1u << d->depth));
- XColor queried[256];
- memset(queried, 0, sizeof(queried));
- for (int x = 0; x < q_colors; ++x)
- queried[x].pixel = x;
- XQueryColors(display, d->colormap, queried, q_colors);
-
- d->colors.resize(q_colors);
- for (int x = 0; x < q_colors; ++x) {
- if (queried[x].red == 0
- && queried[x].green == 0
- && queried[x].blue == 0
- && queried[x].pixel != BlackPixel(display, screen)) {
- // unallocated color cell, skip it
- continue;
- }
-
- d->colors[x] = QColor::fromRgbF(queried[x].red / float(USHRT_MAX),
- queried[x].green / float(USHRT_MAX),
- queried[x].blue / float(USHRT_MAX));
- }
-
- // for missing colors, find the closest color in the existing colormap
- Q_ASSERT(d->pixels.size());
- for (int x = 0; x < d->pixels.size(); ++x) {
- if (d->pixels.at(x) != -1)
- continue;
-
- QRgb rgb;
- if (d->mode == QColormap::Indexed) {
- const int r = (x / (d->g_max * d->b_max)) % d->r_max;
- const int g = (x / d->b_max) % d->g_max;
- const int b = x % d->b_max;
- rgb = qRgb((r * 0xff + (d->r_max - 1) / 2) / (d->r_max - 1),
- (g * 0xff + (d->g_max - 1) / 2) / (d->g_max - 1),
- (b * 0xff + (d->b_max - 1) / 2) / (d->b_max - 1));
- } else {
- rgb = qRgb(x, x, x);
- }
-
- // find closest color
- int mindist = INT_MAX, best = -1;
- for (int y = 0; y < q_colors; ++y) {
- int r = qRed(rgb) - (queried[y].red >> 8);
- int g = qGreen(rgb) - (queried[y].green >> 8);
- int b = qBlue(rgb) - (queried[y].blue >> 8);
- int dist = (r * r) + (g * g) + (b * b);
- if (dist < mindist) {
- mindist = dist;
- best = y;
- }
- }
-
- Q_ASSERT(best >= 0 && best < q_colors);
- if (d->visual->c_class & 1) {
- XColor xcolor;
- xcolor.red = queried[best].red;
- xcolor.green = queried[best].green;
- xcolor.blue = queried[best].blue;
- xcolor.pixel = queried[best].pixel;
-
- if (XAllocColor(display, d->colormap, &xcolor)) {
- d->pixels[x] = xcolor.pixel;
- } else {
- // some weird stuff is going on...
- d->pixels[x] = (qGray(rgb) < 127
- ? BlackPixel(display, screen)
- : WhitePixel(display, screen));
- }
- } else {
- d->pixels[x] = best;
- }
- }
-}
-
-static void init_gray(QColormapPrivate *d, int screen)
-{
- d->pixels.resize(d->r_max);
-
- for (int g = 0; g < d->g_max; ++g) {
- const int gray = (g * 0xff + (d->r_max - 1) / 2) / (d->r_max - 1);
- const QRgb rgb = qRgb(gray, gray, gray);
-
- d->pixels[g] = -1;
-
- if (d->visual->c_class & 1) {
- XColor xcolor;
- xcolor.red = qRed(rgb) * 0x101;
- xcolor.green = qGreen(rgb) * 0x101;
- xcolor.blue = qBlue(rgb) * 0x101;
- xcolor.pixel = 0ul;
-
- if (XAllocColor(QX11Info::display(), d->colormap, &xcolor))
- d->pixels[g] = xcolor.pixel;
- }
- }
-
- query_colormap(d, screen);
-}
-
-static void init_indexed(QColormapPrivate *d, int screen)
-{
- d->pixels.resize(d->r_max * d->g_max * d->b_max);
-
- // create color cube
- for (int x = 0, r = 0; r < d->r_max; ++r) {
- for (int g = 0; g < d->g_max; ++g) {
- for (int b = 0; b < d->b_max; ++b, ++x) {
- const QRgb rgb = qRgb((r * 0xff + (d->r_max - 1) / 2) / (d->r_max - 1),
- (g * 0xff + (d->g_max - 1) / 2) / (d->g_max - 1),
- (b * 0xff + (d->b_max - 1) / 2) / (d->b_max - 1));
-
- d->pixels[x] = -1;
-
- if (d->visual->c_class & 1) {
- XColor xcolor;
- xcolor.red = qRed(rgb) * 0x101;
- xcolor.green = qGreen(rgb) * 0x101;
- xcolor.blue = qBlue(rgb) * 0x101;
- xcolor.pixel = 0ul;
-
- if (XAllocColor(QX11Info::display(), d->colormap, &xcolor))
- d->pixels[x] = xcolor.pixel;
- }
- }
- }
- }
-
- query_colormap(d, screen);
-}
-
-static void init_direct(QColormapPrivate *d, bool ownColormap)
-{
- if (d->visual->c_class != DirectColor || !ownColormap)
- return;
-
- // preallocate 768 on the stack, so that we don't have to malloc
- // for the common case (<= 24 bpp)
- QVarLengthArray<XColor, 768> colorTable(d->r_max + d->g_max + d->b_max);
- int i = 0;
-
- for (int r = 0; r < d->r_max; ++r) {
- colorTable[i].red = r << 8 | r;
- colorTable[i].pixel = r << d->r_shift;
- colorTable[i].flags = DoRed;
- ++i;
- }
-
- for (int g = 0; g < d->g_max; ++g) {
- colorTable[i].green = g << 8 | g;
- colorTable[i].pixel = g << d->g_shift;
- colorTable[i].flags = DoGreen;
- ++i;
- }
-
- for (int b = 0; b < d->b_max; ++b) {
- colorTable[i].blue = (b << 8 | b);
- colorTable[i].pixel = b << d->b_shift;
- colorTable[i].flags = DoBlue;
- ++i;
- }
-
- XStoreColors(X11->display, d->colormap, colorTable.data(), colorTable.count());
-}
-
-static QColormap **cmaps = 0;
-
-void QColormap::initialize()
-{
- Display *display = QX11Info::display();
- const int screens = ScreenCount(display);
-
- cmaps = new QColormap*[screens];
-
- for (int i = 0; i < screens; ++i) {
- cmaps[i] = new QColormap;
- QColormapPrivate * const d = cmaps[i]->d;
-
- bool use_stdcmap = false;
- int color_count = X11->color_count;
-
- // defaults
- d->depth = DefaultDepth(display, i);
- d->colormap = DefaultColormap(display, i);
- d->defaultColormap = true;
- d->visual = DefaultVisual(display, i);
- d->defaultVisual = true;
-
- Visual *argbVisual = 0;
-
- if (X11->visual && i == DefaultScreen(display)) {
- // only use the outside colormap on the default screen
- d->visual = find_visual(display, i, X11->visual->c_class,
- XVisualIDFromVisual(X11->visual),
- &d->depth, &d->defaultVisual);
- } else if ((X11->visual_class != -1 && X11->visual_class >= 0 && X11->visual_class < 6)
- || (X11->visual_id != -1)) {
- // look for a specific visual or type of visual
- d->visual = find_visual(display, i, X11->visual_class, X11->visual_id,
- &d->depth, &d->defaultVisual);
- } else if (QApplication::colorSpec() == QApplication::ManyColor) {
- // look for a TrueColor w/ a depth higher than 8bpp
- d->visual = find_visual(display, i, TrueColor, -1, &d->depth, &d->defaultVisual);
- if (d->depth <= 8) {
- d->visual = DefaultVisual(display, i);
- d->defaultVisual = true;
- color_count = 216;
- }
- } else if (!X11->custom_cmap) {
- XStandardColormap *stdcmap = 0;
- int ncmaps = 0;
-
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender) {
- int nvi;
- XVisualInfo templ;
- templ.screen = i;
- templ.depth = 32;
- templ.c_class = TrueColor;
- XVisualInfo *xvi = XGetVisualInfo(X11->display, VisualScreenMask |
- VisualDepthMask |
- VisualClassMask, &templ, &nvi);
- for (int idx = 0; idx < nvi; ++idx) {
- XRenderPictFormat *format = XRenderFindVisualFormat(X11->display,
- xvi[idx].visual);
- if (format->type == PictTypeDirect && format->direct.alphaMask) {
- argbVisual = xvi[idx].visual;
- break;
- }
- }
- XFree(xvi);
- }
-#endif
- if (XGetRGBColormaps(display, RootWindow(display, i),
- &stdcmap, &ncmaps, XA_RGB_DEFAULT_MAP)) {
- if (stdcmap) {
- for (int c = 0; c < ncmaps; ++c) {
- if (!stdcmap[c].red_max ||
- !stdcmap[c].green_max ||
- !stdcmap[c].blue_max ||
- !stdcmap[c].red_mult ||
- !stdcmap[c].green_mult ||
- !stdcmap[c].blue_mult)
- continue; // invalid stdcmap
-
- XVisualInfo proto;
- proto.visualid = stdcmap[c].visualid;
- proto.screen = i;
-
- int nvisuals = 0;
- XVisualInfo *vi = XGetVisualInfo(display, VisualIDMask | VisualScreenMask,
- &proto, &nvisuals);
- if (vi) {
- if (nvisuals > 0) {
- use_stdcmap = true;
-
- d->mode = ((vi[0].visual->c_class < StaticColor)
- ? Gray
- : ((vi[0].visual->c_class < TrueColor)
- ? Indexed
- : Direct));
-
- d->depth = vi[0].depth;
- d->colormap = stdcmap[c].colormap;
- d->defaultColormap = true;
- d->visual = vi[0].visual;
- d->defaultVisual = (d->visual == DefaultVisual(display, i));
-
- d->r_max = stdcmap[c].red_max + 1;
- d->g_max = stdcmap[c].green_max + 1;
- d->b_max = stdcmap[c].blue_max + 1;
-
- if (d->mode == Direct) {
- // calculate offsets
- d->r_shift = lowest_bit(d->visual->red_mask);
- d->g_shift = lowest_bit(d->visual->green_mask);
- d->b_shift = lowest_bit(d->visual->blue_mask);
- } else {
- d->r_shift = 0;
- d->g_shift = 0;
- d->b_shift = 0;
- }
- }
- XFree(vi);
- }
- break;
- }
- XFree(stdcmap);
- }
- }
- }
- if (!use_stdcmap) {
- switch (d->visual->c_class) {
- case StaticGray:
- d->mode = Gray;
-
- d->r_max = d->g_max = d->b_max = d->visual->map_entries;
- break;
-
- case XGrayScale:
- d->mode = Gray;
-
- // follow precedent set in libXmu...
- if (color_count != 0)
- d->r_max = d->g_max = d->b_max = color_count;
- else if (d->visual->map_entries > 65000)
- d->r_max = d->g_max = d->b_max = 4096;
- else if (d->visual->map_entries > 4000)
- d->r_max = d->g_max = d->b_max = 512;
- else if (d->visual->map_entries > 250)
- d->r_max = d->g_max = d->b_max = 12;
- else
- d->r_max = d->g_max = d->b_max = 4;
- break;
-
- case StaticColor:
- d->mode = Indexed;
-
- d->r_max = right_align(d->visual->red_mask) + 1;
- d->g_max = right_align(d->visual->green_mask) + 1;
- d->b_max = right_align(d->visual->blue_mask) + 1;
- break;
-
- case PseudoColor:
- d->mode = Indexed;
-
- // follow precedent set in libXmu...
- if (color_count != 0)
- d->r_max = d->g_max = d->b_max = cube_root(color_count);
- else if (d->visual->map_entries > 65000)
- d->r_max = d->g_max = d->b_max = 27;
- else if (d->visual->map_entries > 4000)
- d->r_max = d->g_max = d->b_max = 12;
- else if (d->visual->map_entries > 250)
- d->r_max = d->g_max = d->b_max = cube_root(d->visual->map_entries - 125);
- else
- d->r_max = d->g_max = d->b_max = cube_root(d->visual->map_entries);
- break;
-
- case TrueColor:
- case DirectColor:
- d->mode = Direct;
-
- d->r_max = right_align(d->visual->red_mask) + 1;
- d->g_max = right_align(d->visual->green_mask) + 1;
- d->b_max = right_align(d->visual->blue_mask) + 1;
-
- d->r_shift = lowest_bit(d->visual->red_mask);
- d->g_shift = lowest_bit(d->visual->green_mask);
- d->b_shift = lowest_bit(d->visual->blue_mask);
- break;
- }
- }
-
- bool ownColormap = false;
- if (X11->colormap && i == DefaultScreen(display)) {
- // only use the outside colormap on the default screen
- d->colormap = X11->colormap;
- d->defaultColormap = (d->colormap == DefaultColormap(display, i));
- } else if ((!use_stdcmap
- && (((d->visual->c_class & 1) && X11->custom_cmap)
- || d->visual != DefaultVisual(display, i)))
- || d->visual->c_class == DirectColor) {
- // allocate custom colormap (we always do this when using DirectColor visuals)
- d->colormap =
- XCreateColormap(display, RootWindow(display, i), d->visual,
- d->visual->c_class == DirectColor ? AllocAll : AllocNone);
- d->defaultColormap = false;
- ownColormap = true;
- }
-
- switch (d->mode) {
- case Gray:
- init_gray(d, i);
- break;
- case Indexed:
- init_indexed(d, i);
- break;
- case Direct:
- init_direct(d, ownColormap);
- break;
- }
-
- QX11InfoData *screen = X11->screens + i;
- screen->depth = d->depth;
- screen->visual = d->visual;
- screen->defaultVisual = d->defaultVisual;
- screen->colormap = d->colormap;
- screen->defaultColormap = d->defaultColormap;
- screen->cells = screen->visual->map_entries;
-
- if (argbVisual) {
- X11->argbVisuals[i] = argbVisual;
- X11->argbColormaps[i] = XCreateColormap(display, RootWindow(display, i), argbVisual, AllocNone);
- }
-
- // ###
- // We assume that 8bpp == pseudocolor, but this is not
- // always the case (according to the X server), so we need
- // to make sure that our internal data is setup in a way
- // that is compatible with our assumptions
- if (screen->visual->c_class == TrueColor && screen->depth == 8 && screen->cells == 8)
- screen->cells = 256;
- }
-}
-
-void QColormap::cleanup()
-{
- Display *display = QX11Info::display();
- const int screens = ScreenCount(display);
-
- for (int i = 0; i < screens; ++i)
- delete cmaps[i];
-
- delete [] cmaps;
- cmaps = 0;
-}
-
-
-QColormap QColormap::instance(int screen)
-{
- if (screen == -1)
- screen = QX11Info::appScreen();
- return *cmaps[screen];
-}
-
-/*! \internal
- Constructs a new colormap.
-*/
-QColormap::QColormap()
- : d(new QColormapPrivate)
-{}
-
-QColormap::QColormap(const QColormap &colormap)
- :d (colormap.d)
-{ d->ref.ref(); }
-
-QColormap::~QColormap()
-{
- if (!d->ref.deref()) {
- if (!d->defaultColormap)
- XFreeColormap(QX11Info::display(), d->colormap);
- delete d;
- }
-}
-
-QColormap::Mode QColormap::mode() const
-{ return d->mode; }
-
-int QColormap::depth() const
-{ return d->depth; }
-
-int QColormap::size() const
-{
- return (d->mode == Gray
- ? d->r_max
- : (d->mode == Indexed
- ? d->r_max * d->g_max * d->b_max
- : -1));
-}
-
-uint QColormap::pixel(const QColor &color) const
-{
- const QColor c = color.toRgb();
- const uint r = (c.ct.argb.red * d->r_max) >> 16;
- const uint g = (c.ct.argb.green * d->g_max) >> 16;
- const uint b = (c.ct.argb.blue * d->b_max) >> 16;
- if (d->mode != Direct) {
- if (d->mode == Gray)
- return d->pixels.at((r * 30 + g * 59 + b * 11) / 100);
- return d->pixels.at(r * d->g_max * d->b_max + g * d->b_max + b);
- }
- return (r << d->r_shift) + (g << d->g_shift) + (b << d->b_shift);
-}
-
-const QColor QColormap::colorAt(uint pixel) const
-{
- if (d->mode != Direct) {
- Q_ASSERT(pixel <= (uint)d->colors.size());
- return d->colors.at(pixel);
- }
-
- const int r = (((pixel & d->visual->red_mask) >> d->r_shift) << 8) / d->r_max;
- const int g = (((pixel & d->visual->green_mask) >> d->g_shift) << 8) / d->g_max;
- const int b = (((pixel & d->visual->blue_mask) >> d->b_shift) << 8) / d->b_max;
- return QColor(r, g, b);
-}
-
-const QVector<QColor> QColormap::colormap() const
-{ return d->colors; }
-
-QColormap &QColormap::operator=(const QColormap &colormap)
-{
- qAtomicAssign(d, colormap.d);
- return *this;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qcssutil_p.h b/src/gui/painting/qcssutil_p.h
index be206f35b8..fe5b7057b9 100644
--- a/src/gui/painting/qcssutil_p.h
+++ b/src/gui/painting/qcssutil_p.h
@@ -71,10 +71,10 @@ extern void qDrawRoundedCorners(QPainter *p, qreal x1, qreal y1, qreal x2, qreal
const QSizeF& r1, const QSizeF& r2,
QCss::Edge edge, QCss::BorderStyle s, QBrush c);
-extern void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles,
+extern void Q_GUI_EXPORT qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles,
const int *borders, const QBrush *colors, const QSize *radii);
-extern void qNormalizeRadii(const QRect &br, const QSize *radii,
+extern void Q_GUI_EXPORT qNormalizeRadii(const QRect &br, const QSize *radii,
QSize *tlr, QSize *trr, QSize *blr, QSize *brr);
QT_END_NAMESPACE
diff --git a/src/gui/painting/qcups_p.h b/src/gui/painting/qcups_p.h
index 47ed7e14ef..e6c53111a5 100644
--- a/src/gui/painting/qcups_p.h
+++ b/src/gui/painting/qcups_p.h
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(cups_option_t, Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE);
-class QCUPSSupport
+class Q_GUI_EXPORT QCUPSSupport
{
public:
QCUPSSupport();
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index c97ef24622..cfd9934e9b 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -3285,9 +3285,6 @@ static
void drawBufferSpan(QSpanData *data, const uint *buffer, int bufsize,
int x, int y, int length, uint const_alpha)
{
-#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
- data->rasterEngine->drawBufferSpan(buffer, bufsize, x, y, length, const_alpha);
-#else
Q_UNUSED(data);
Q_UNUSED(buffer);
Q_UNUSED(bufsize);
@@ -3295,7 +3292,6 @@ void drawBufferSpan(QSpanData *data, const uint *buffer, int bufsize,
Q_UNUSED(y);
Q_UNUSED(length);
Q_UNUSED(const_alpha);
-#endif
}
#if !defined(Q_CC_SUN)
@@ -3323,18 +3319,6 @@ void blend_color_generic(int count, const QSpan *spans, void *userData)
}
}
-#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-static void blend_color_generic_callback(int count, const QSpan *spans, void *userData)
-{
- // ### Falcon
- Q_UNUSED(count);
- Q_UNUSED(spans);
- Q_UNUSED(userData);
-// QSpanData *data = reinterpret_cast<QSpanData*>(userData);
-// data->rasterEngine->drawColorSpans(spans, count, data->solid.color);
-}
-#endif // QT_NO_RASTERCALLBACKS
-
static void blend_color_argb(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
@@ -4957,65 +4941,30 @@ void QT_FASTCALL blendUntransformed(int count, const QSpan *spans, void *userDat
static void blend_untransformed_rgb888(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_24)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_RGB888)
- blendUntransformed<qrgb888, qrgb888>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb6666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendUntransformed<qargb6666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendUntransformed<qargb6666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendUntransformed<qrgb666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendUntransformed<qrgb666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb8565(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
- blendUntransformed<qargb8565, qargb8565>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB16)
- blendUntransformed<qargb8565, qrgb565>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -5023,68 +4972,31 @@ static void blend_untransformed_rgb565(int count, const QSpan *spans,
else if (data->texture.format == QImage::Format_RGB16)
blendUntransformed<qrgb565, qrgb565>(count, spans, userData);
else
-#endif
blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb8555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendUntransformed<qargb8555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendUntransformed<qargb8555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendUntransformed<qrgb555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendUntransformed<qrgb555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb4444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendUntransformed<qargb4444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendUntransformed<qargb4444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendUntransformed<qrgb444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendUntransformed<qrgb444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
template <SpanMethod spanMethod>
@@ -5300,61 +5212,26 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void *
static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_24)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_RGB888)
- blendTiled<qrgb888, qrgb888>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTiled<qargb6666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTiled<qargb6666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTiled<qrgb666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTiled<qrgb666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
- blendTiled<qargb8565, qargb8565>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB16)
- blendTiled<qargb8565, qrgb565>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -5362,64 +5239,27 @@ static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
else if (data->texture.format == QImage::Format_RGB16)
blendTiled<qrgb565, qrgb565>(count, spans, userData);
else
-#endif
blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTiled<qargb8555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTiled<qargb8555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTiled<qrgb555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTiled<qrgb555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTiled<qargb4444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTiled<qargb4444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTiled<qrgb444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTiled<qrgb444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
template <class DST, class SRC>
@@ -5647,62 +5487,27 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan
static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_24)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_RGB888)
- blendTransformedBilinear<qrgb888, qrgb888>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformedBilinear<qargb6666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformedBilinear<qargb6666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformedBilinear<qrgb666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformedBilinear<qrgb666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
- blendTransformedBilinear<qargb8565, qargb8565>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB16)
- blendTransformedBilinear<qargb8565, qrgb565>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_RGB16)
@@ -5710,64 +5515,27 @@ static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans,
else if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
blendTransformedBilinear<qrgb565, qargb8565>(count, spans, userData);
else
-#endif
blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformedBilinear<qargb8555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformedBilinear<qargb8555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformedBilinear<qrgb555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformedBilinear<qrgb555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformedBilinear<qargb4444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformedBilinear<qargb4444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformedBilinear<qrgb444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformedBilinear<qrgb444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
template <SpanMethod spanMethod>
@@ -6040,65 +5808,30 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformed(int count, const QSpan *spans,
static void blend_transformed_rgb888(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_24)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_RGB888)
- blendTransformed<qrgb888, qrgb888>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb6666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformed<qargb6666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformed<qargb6666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformed<qrgb666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformed<qrgb666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb8565(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
- blendTransformed<qargb8565, qargb8565>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB16)
- blendTransformed<qargb8565, qrgb565>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -6106,68 +5839,31 @@ static void blend_transformed_rgb565(int count, const QSpan *spans,
else if (data->texture.format == QImage::Format_RGB16)
blendTransformed<qrgb565, qrgb565>(count, spans, userData);
else
-#endif
blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb8555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformed<qargb8555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformed<qargb8555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformed<qrgb555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformed<qrgb555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb4444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformed<qargb4444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformed<qargb4444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformed<qrgb444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformed<qrgb444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
template <SpanMethod spanMethod>
@@ -6455,65 +6151,30 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedTiled(int count, const QSpan *sp
static void blend_transformed_tiled_rgb888(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_24)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_RGB888)
- blendTransformedTiled<qrgb888, qrgb888>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb6666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformedTiled<qargb6666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformedTiled<qargb6666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformedTiled<qrgb666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformedTiled<qrgb666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb8565(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
- blendTransformedTiled<qargb8565, qargb8565>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB16)
- blendTransformedTiled<qargb8565, qrgb565>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -6521,68 +6182,31 @@ static void blend_transformed_tiled_rgb565(int count, const QSpan *spans,
else if (data->texture.format == QImage::Format_RGB16)
blendTransformedTiled<qrgb565, qrgb565>(count, spans, userData);
else
-#endif
blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb8555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformedTiled<qargb8555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformedTiled<qargb8555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformedTiled<qrgb555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformedTiled<qrgb555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb4444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformedTiled<qargb4444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformedTiled<qargb4444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformedTiled<qrgb444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformedTiled<qrgb444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
# define SPANFUNC_POINTER(Name, Arg) Name<Arg>
@@ -6706,125 +6330,6 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
}
};
-#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-static const ProcessSpans processTextureSpansCallback[NBlendTypes][QImage::NImageFormats] = {
- // Untransformed
- {
- 0, // Invalid
- blend_untransformed_generic<CallbackSpans>, // Mono
- blend_untransformed_generic<CallbackSpans>, // MonoLsb
- blend_untransformed_generic<CallbackSpans>, // Indexed8
- blend_untransformed_generic<CallbackSpans>, // RGB32
- blend_untransformed_generic<CallbackSpans>, // ARGB32
- blend_untransformed_argb<CallbackSpans>, // ARGB32_Premultiplied
- blend_untransformed_generic<CallbackSpans>, // RGB16
- blend_untransformed_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_untransformed_generic<CallbackSpans>, // RGB666
- blend_untransformed_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_untransformed_generic<CallbackSpans>, // RGB555
- blend_untransformed_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_untransformed_generic<CallbackSpans>, // RGB888
- blend_untransformed_generic<CallbackSpans>, // RGB444
- blend_untransformed_generic<CallbackSpans> // ARGB4444_Premultiplied
- },
- // Tiled
- {
- 0, // Invalid
- blend_tiled_generic<CallbackSpans>, // Mono
- blend_tiled_generic<CallbackSpans>, // MonoLsb
- blend_tiled_generic<CallbackSpans>, // Indexed8
- blend_tiled_generic<CallbackSpans>, // RGB32
- blend_tiled_generic<CallbackSpans>, // ARGB32
- blend_tiled_argb<CallbackSpans>, // ARGB32_Premultiplied
- blend_tiled_generic<CallbackSpans>, // RGB16
- blend_tiled_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_tiled_generic<CallbackSpans>, // RGB666
- blend_tiled_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_tiled_generic<CallbackSpans>, // RGB555
- blend_tiled_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_tiled_generic<CallbackSpans>, // RGB888
- blend_tiled_generic<CallbackSpans>, // RGB444
- blend_tiled_generic<CallbackSpans> // ARGB4444_Premultiplied
- },
- // Transformed
- {
- 0, // Invalid
- blend_src_generic<CallbackSpans>, // Mono
- blend_src_generic<CallbackSpans>, // MonoLsb
- blend_src_generic<CallbackSpans>, // Indexed8
- blend_src_generic<CallbackSpans>, // RGB32
- blend_src_generic<CallbackSpans>, // ARGB32
- blend_transformed_argb<CallbackSpans>, // ARGB32_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB16
- blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB666
- blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB555
- blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB888
- blend_src_generic<CallbackSpans>, // RGB444
- blend_src_generic<CallbackSpans>, // ARGB4444_Premultiplied
- },
- // TransformedTiled
- {
- 0,
- blend_src_generic<CallbackSpans>, // Mono
- blend_src_generic<CallbackSpans>, // MonoLsb
- blend_src_generic<CallbackSpans>, // Indexed8
- blend_src_generic<CallbackSpans>, // RGB32
- blend_src_generic<CallbackSpans>, // ARGB32
- blend_transformed_tiled_argb<CallbackSpans>, // ARGB32_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB16
- blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB666
- blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB555
- blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB888
- blend_src_generic<CallbackSpans>, // RGB444
- blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied
- },
- // Bilinear
- {
- 0,
- blend_src_generic<CallbackSpans>, // Mono
- blend_src_generic<CallbackSpans>, // MonoLsb
- blend_src_generic<CallbackSpans>, // Indexed8
- blend_src_generic<CallbackSpans>, // RGB32
- blend_src_generic<CallbackSpans>, // ARGB32
- blend_src_generic<CallbackSpans>, // ARGB32_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB16
- blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB666
- blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB555
- blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB888
- blend_src_generic<CallbackSpans>, // RGB444
- blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied
- },
- // BilinearTiled
- {
- 0,
- blend_src_generic<CallbackSpans>, // Mono
- blend_src_generic<CallbackSpans>, // MonoLsb
- blend_src_generic<CallbackSpans>, // Indexed8
- blend_src_generic<CallbackSpans>, // RGB32
- blend_src_generic<CallbackSpans>, // ARGB32
- blend_src_generic<CallbackSpans>, // ARGB32_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB16
- blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB666
- blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB555
- blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB888
- blend_src_generic<CallbackSpans>, // RGB444
- blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied
- }
-};
-#endif // QT_NO_RASTERCALLBACKS
-
void qBlendTexture(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
@@ -6832,15 +6337,6 @@ void qBlendTexture(int count, const QSpan *spans, void *userData)
proc(count, spans, userData);
}
-#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-void qBlendTextureCallback(int count, const QSpan *spans, void *userData)
-{
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
- ProcessSpans proc = processTextureSpansCallback[getBlendType(data)][data->rasterBuffer->format];
- proc(count, spans, userData);
-}
-#endif // QT_NO_RASTERCALLBACKS
-
template <class DST>
inline void qt_bitmapblit_template(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
@@ -7490,106 +6986,6 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
}
};
-#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-DrawHelper qDrawHelperCallback[QImage::NImageFormats] =
-{
- // Format_Invalid,
- { 0, 0, 0, 0, 0, 0 },
- // Format_Mono,
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_MonoLSB,
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_Indexed8,
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB32,
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB32,
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB32_Premultiplied
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB16
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB8565_Premultiplied
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB666
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB6666_Premultiplied
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB555
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB8555_Premultiplied
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB888
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB444
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB4444_Premultiplied
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- }
-};
-#endif
-
-
-
#if defined(Q_CC_MSVC) && !defined(_MIPS_)
template <class DST, class SRC>
inline void qt_memfill_template(DST *dest, SRC color, int count)
@@ -7889,64 +7285,4 @@ static void qt_memfill16_setup(quint16 *dest, quint16 value, int count)
qt_memfill16(dest, value, count);
}
-#ifdef QT_QWS_DEPTH_GENERIC
-
-int qrgb::bpp = 0;
-int qrgb::len_red = 0;
-int qrgb::len_green = 0;
-int qrgb::len_blue = 0;
-int qrgb::len_alpha = 0;
-int qrgb::off_red = 0;
-int qrgb::off_green = 0;
-int qrgb::off_blue = 0;
-int qrgb::off_alpha = 0;
-
-template <typename SRC>
-Q_STATIC_TEMPLATE_FUNCTION inline void qt_rectconvert_rgb(qrgb *dest, const SRC *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- quint8 *dest8 = reinterpret_cast<quint8*>(dest)
- + y * dstStride + x * qrgb::bpp;
-
- srcStride = srcStride / sizeof(SRC) - width;
- dstStride -= (width * qrgb::bpp);
-
- for (int j = 0; j < height; ++j) {
- for (int i = 0; i < width; ++i) {
- const quint32 v = qt_convertToRgb<SRC>(*src++);
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- for (int j = qrgb::bpp - 1; j >= 0; --j)
- *dest8++ = (v >> (8 * j)) & 0xff;
-#else
- for (int j = 0; j < qrgb::bpp; ++j)
- *dest8++ = (v >> (8 * j)) & 0xff;
-#endif
- }
-
- dest8 += dstStride;
- src += srcStride;
- }
-}
-
-template <>
-void qt_rectconvert(qrgb *dest, const quint32 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_rgb<quint32>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-template <>
-void qt_rectconvert(qrgb *dest, const quint16 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_rgb<quint16>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-#endif // QT_QWS_DEPTH_GENERIC
-
QT_END_NAMESPACE
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index 0766f2e96b..3d83ba8587 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -65,10 +65,6 @@
#include <private/qsimd_p.h>
#include <private/qmath_p.h>
-#ifdef Q_WS_QWS
-#include "QtGui/qscreen_qws.h"
-#endif
-
QT_BEGIN_NAMESPACE
#if defined(Q_CC_MSVC) && _MSCVER <= 1300 && !defined(Q_CC_INTEL)
@@ -171,10 +167,6 @@ extern MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3];
extern DrawHelper qDrawHelper[QImage::NImageFormats];
void qBlendTexture(int count, const QSpan *spans, void *userData);
-#if defined(Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-extern DrawHelper qDrawHelperCallback[QImage::NImageFormats];
-void qBlendTextureCallback(int count, const QSpan *spans, void *userData);
-#endif
typedef void (QT_FASTCALL *CompositionFunction)(uint *dest, const uint *src, int length, uint const_alpha);
typedef void (QT_FASTCALL *CompositionFunctionSolid)(uint *dest, int length, uint color, uint const_alpha);
@@ -271,13 +263,8 @@ struct QGradientData
QConicalGradientData conical;
};
-#ifdef Q_WS_QWS
-#define GRADIENT_STOPTABLE_SIZE 256
-#define GRADIENT_STOPTABLE_SIZE_SHIFT 8
-#else
#define GRADIENT_STOPTABLE_SIZE 1024
#define GRADIENT_STOPTABLE_SIZE_SHIFT 10
-#endif
uint* colorTable; //[GRADIENT_STOPTABLE_SIZE];
@@ -314,9 +301,6 @@ struct QSpanData
~QSpanData() { delete tempImage; }
QRasterBuffer *rasterBuffer;
-#ifdef Q_WS_QWS
- QRasterPaintEngine *rasterEngine;
-#endif
ProcessSpans blend;
ProcessSpans unclipped_blend;
BitmapBlitFunc bitmapBlit;
@@ -1492,37 +1476,6 @@ inline quint32 qt_colorConvert(qrgb888 color, quint32 dummy)
return quint32(color);
}
-#ifdef QT_QWS_DEPTH_8
-template <>
-inline quint8 qt_colorConvert(quint32 color, quint8 dummy)
-{
- Q_UNUSED(dummy);
-
- uchar r = ((qRed(color) & 0xf8) + 0x19) / 0x33;
- uchar g = ((qGreen(color) &0xf8) + 0x19) / 0x33;
- uchar b = ((qBlue(color) &0xf8) + 0x19) / 0x33;
-
- return r*6*6 + g*6 + b;
-}
-
-template <>
-inline quint8 qt_colorConvert(quint16 color, quint8 dummy)
-{
- Q_UNUSED(dummy);
-
- uchar r = (color & 0xf800) >> (11-3);
- uchar g = (color & 0x07c0) >> (6-3);
- uchar b = (color & 0x001f) << 3;
-
- uchar tr = (r + 0x19) / 0x33;
- uchar tg = (g + 0x19) / 0x33;
- uchar tb = (b + 0x19) / 0x33;
-
- return tr*6*6 + tg*6 + tb;
-}
-
-#endif // QT_QWS_DEPTH_8
-
// hw: endianess??
class quint24
{
@@ -1759,84 +1712,6 @@ qrgb444 qrgb444::byte_mul(quint8 a) const
return result;
}
-#ifdef QT_QWS_DEPTH_GENERIC
-
-struct qrgb
-{
-public:
- static int bpp;
- static int len_red;
- static int len_green;
- static int len_blue;
- static int len_alpha;
- static int off_red;
- static int off_green;
- static int off_blue;
- static int off_alpha;
-} Q_PACKED;
-
-template <typename SRC>
-Q_STATIC_TEMPLATE_FUNCTION inline quint32 qt_convertToRgb(SRC color);
-
-template <>
-inline quint32 qt_convertToRgb(quint32 color)
-{
- const int r = qRed(color) >> (8 - qrgb::len_red);
- const int g = qGreen(color) >> (8 - qrgb::len_green);
- const int b = qBlue(color) >> (8 - qrgb::len_blue);
- const int a = qAlpha(color) >> (8 - qrgb::len_alpha);
- const quint32 v = (r << qrgb::off_red)
- | (g << qrgb::off_green)
- | (b << qrgb::off_blue)
- | (a << qrgb::off_alpha);
-
- return v;
-}
-
-template <>
-inline quint32 qt_convertToRgb(quint16 color)
-{
- return qt_convertToRgb(qt_colorConvert<quint32, quint16>(color, 0));
-}
-
-class qrgb_generic16
-{
-public:
- inline qrgb_generic16(quint32 color)
- {
- const int r = qRed(color) >> (8 - qrgb::len_red);
- const int g = qGreen(color) >> (8 - qrgb::len_green);
- const int b = qBlue(color) >> (8 - qrgb::len_blue);
- const int a = qAlpha(color) >> (8 - qrgb::len_alpha);
- data = (r << qrgb::off_red)
- | (g << qrgb::off_green)
- | (b << qrgb::off_blue)
- | (a << qrgb::off_alpha);
- }
-
- inline operator quint16 () { return data; }
- inline quint32 operator<<(int shift) const { return data << shift; }
-
-private:
- quint16 data;
-} Q_PACKED;
-
-template <>
-inline qrgb_generic16 qt_colorConvert(quint32 color, qrgb_generic16 dummy)
-{
- Q_UNUSED(dummy);
- return qrgb_generic16(color);
-}
-
-template <>
-inline qrgb_generic16 qt_colorConvert(quint16 color, qrgb_generic16 dummy)
-{
- Q_UNUSED(dummy);
- return qrgb_generic16(qt_colorConvert<quint32, quint16>(color, 0));
-}
-
-#endif // QT_QWS_DEPTH_GENERIC
-
template <class T>
void qt_memfill(T *dest, T value, int count);
@@ -2044,16 +1919,6 @@ QT_RECTCONVERT_TRIVIAL_IMPL(qargb4444)
QT_RECTCONVERT_TRIVIAL_IMPL(qrgb444)
#undef QT_RECTCONVERT_TRIVIAL_IMPL
-#ifdef QT_QWS_DEPTH_GENERIC
-template <> void qt_rectconvert(qrgb *dest, const quint32 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride);
-
-template <> void qt_rectconvert(qrgb *dest, const quint16 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride);
-#endif // QT_QWS_DEPTH_GENERIC
-
#define QT_MEMFILL_UINT(dest, length, color) \
qt_memfill<quint32>(dest, color, length);
@@ -2116,16 +1981,6 @@ inline ushort qConvertRgb32To16(uint c)
| (((c) >> 8) & 0xf800);
}
-#if defined(Q_WS_QWS) || (QT_VERSION >= 0x040400)
-inline quint32 qConvertRgb32To16x2(quint64 c)
-{
- c = (((c) >> 3) & Q_UINT64_C(0x001f0000001f))
- | (((c) >> 5) & Q_UINT64_C(0x07e0000007e0))
- | (((c) >> 8) & Q_UINT64_C(0xf8000000f800));
- return c | (c >> 16);
-}
-#endif
-
inline QRgb qConvertRgb16To32(uint c)
{
return 0xff000000
diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp
deleted file mode 100644
index 98294cb62d..0000000000
--- a/src/gui/painting/qdrawutil.cpp
+++ /dev/null
@@ -1,1360 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdrawutil.h"
-#include "qbitmap.h"
-#include "qpixmapcache.h"
-#include "qapplication.h"
-#include "qpainter.h"
-#include "qpalette.h"
-#include <private/qpaintengineex_p.h>
-#include <qvarlengtharray.h>
-#include <qmath.h>
-#include <private/qstylehelper_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \headerfile <qdrawutil.h>
- \title Drawing Utility Functions
-
- \sa QPainter
-*/
-
-/*!
- \fn void qDrawShadeLine(QPainter *painter, int x1, int y1, int x2, int y2,
- const QPalette &palette, bool sunken,
- int lineWidth, int midLineWidth)
- \relates <qdrawutil.h>
-
- Draws a horizontal (\a y1 == \a y2) or vertical (\a x1 == \a x2)
- shaded line using the given \a painter. Note that nothing is
- drawn if \a y1 != \a y2 and \a x1 != \a x2 (i.e. the line is
- neither horizontal nor vertical).
-
- The provided \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors). The given \a lineWidth
- specifies the line width for each of the lines; it is not the
- total line width. The given \a midLineWidth specifies the width of
- a middle line drawn in the QPalette::mid() color.
-
- The line appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to
- make widgets that follow the current GUI style.
-
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded line:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 0
-
- \sa qDrawShadeRect(), qDrawShadePanel(), QStyle
-*/
-
-void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
- const QPalette &pal, bool sunken,
- int lineWidth, int midLineWidth)
-{
- if (!(p && lineWidth >= 0 && midLineWidth >= 0)) {
- qWarning("qDrawShadeLine: Invalid parameters");
- return;
- }
- int tlw = lineWidth*2 + midLineWidth; // total line width
- QPen oldPen = p->pen(); // save pen
- if (sunken)
- p->setPen(pal.color(QPalette::Dark));
- else
- p->setPen(pal.light().color());
- QPolygon a;
- int i;
- if (y1 == y2) { // horizontal line
- int y = y1 - tlw/2;
- if (x1 > x2) { // swap x1 and x2
- int t = x1;
- x1 = x2;
- x2 = t;
- }
- x2--;
- for (i=0; i<lineWidth; i++) { // draw top shadow
- a.setPoints(3, x1+i, y+tlw-1-i,
- x1+i, y+i,
- x2-i, y+i);
- p->drawPolyline(a);
- }
- if (midLineWidth > 0) {
- p->setPen(pal.mid().color());
- for (i=0; i<midLineWidth; i++) // draw lines in the middle
- p->drawLine(x1+lineWidth, y+lineWidth+i,
- x2-lineWidth, y+lineWidth+i);
- }
- if (sunken)
- p->setPen(pal.light().color());
- else
- p->setPen(pal.dark().color());
- for (i=0; i<lineWidth; i++) { // draw bottom shadow
- a.setPoints(3, x1+i, y+tlw-i-1,
- x2-i, y+tlw-i-1,
- x2-i, y+i+1);
- p->drawPolyline(a);
- }
- }
- else if (x1 == x2) { // vertical line
- int x = x1 - tlw/2;
- if (y1 > y2) { // swap y1 and y2
- int t = y1;
- y1 = y2;
- y2 = t;
- }
- y2--;
- for (i=0; i<lineWidth; i++) { // draw left shadow
- a.setPoints(3, x+i, y2,
- x+i, y1+i,
- x+tlw-1, y1+i);
- p->drawPolyline(a);
- }
- if (midLineWidth > 0) {
- p->setPen(pal.mid().color());
- for (i=0; i<midLineWidth; i++) // draw lines in the middle
- p->drawLine(x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2);
- }
- if (sunken)
- p->setPen(pal.light().color());
- else
- p->setPen(pal.dark().color());
- for (i=0; i<lineWidth; i++) { // draw right shadow
- a.setPoints(3, x+lineWidth, y2-i,
- x+tlw-i-1, y2-i,
- x+tlw-i-1, y1+lineWidth);
- p->drawPolyline(a);
- }
- }
- p->setPen(oldPen);
-}
-
-/*!
- \fn void qDrawShadeRect(QPainter *painter, int x, int y, int width, int height,
- const QPalette &palette, bool sunken,
- int lineWidth, int midLineWidth,
- const QBrush *fill)
- \relates <qdrawutil.h>
-
- Draws the shaded rectangle beginning at (\a x, \a y) with the
- given \a width and \a height using the provided \a painter.
-
- The provide \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors. The given \a lineWidth
- specifies the line width for each of the lines; it is not the
- total line width. The \a midLineWidth specifies the width of a
- middle line drawn in the QPalette::mid() color. The rectangle's
- interior is filled with the \a fill brush unless \a fill is 0.
-
- The rectangle appears sunken if \a sunken is true, otherwise
- raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded rectangle:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 1
-
- \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle
-*/
-
-void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken,
- int lineWidth, int midLineWidth,
- const QBrush *fill)
-{
- if (w == 0 || h == 0)
- return;
- if (! (w > 0 && h > 0 && lineWidth >= 0 && midLineWidth >= 0)) {
- qWarning("qDrawShadeRect: Invalid parameters");
- return;
- }
- QPen oldPen = p->pen();
- if (sunken)
- p->setPen(pal.dark().color());
- else
- p->setPen(pal.light().color());
- int x1=x, y1=y, x2=x+w-1, y2=y+h-1;
-
- if (lineWidth == 1 && midLineWidth == 0) {// standard shade rectangle
- p->drawRect(x1, y1, w-2, h-2);
- if (sunken)
- p->setPen(pal.light().color());
- else
- p->setPen(pal.dark().color());
- QLineF lines[4] = { QLineF(x1+1, y1+1, x2-2, y1+1),
- QLineF(x1+1, y1+2, x1+1, y2-2),
- QLineF(x1, y2, x2, y2),
- QLineF(x2,y1, x2,y2-1) };
- p->drawLines(lines, 4); // draw bottom/right lines
- } else { // more complicated
- int m = lineWidth+midLineWidth;
- int i, j=0, k=m;
- for (i=0; i<lineWidth; i++) { // draw top shadow
- QLineF lines[4] = { QLineF(x1+i, y2-i, x1+i, y1+i),
- QLineF(x1+i, y1+i, x2-i, y1+i),
- QLineF(x1+k, y2-k, x2-k, y2-k),
- QLineF(x2-k, y2-k, x2-k, y1+k) };
- p->drawLines(lines, 4);
- k++;
- }
- p->setPen(pal.mid().color());
- j = lineWidth*2;
- for (i=0; i<midLineWidth; i++) { // draw lines in the middle
- p->drawRect(x1+lineWidth+i, y1+lineWidth+i, w-j-1, h-j-1);
- j += 2;
- }
- if (sunken)
- p->setPen(pal.light().color());
- else
- p->setPen(pal.dark().color());
- k = m;
- for (i=0; i<lineWidth; i++) { // draw bottom shadow
- QLineF lines[4] = { QLineF(x1+1+i, y2-i, x2-i, y2-i),
- QLineF(x2-i, y2-i, x2-i, y1+i+1),
- QLineF(x1+k, y2-k, x1+k, y1+k),
- QLineF(x1+k, y1+k, x2-k, y1+k) };
- p->drawLines(lines, 4);
- k++;
- }
- }
- if (fill) {
- QBrush oldBrush = p->brush();
- int tlw = lineWidth + midLineWidth;
- p->setPen(Qt::NoPen);
- p->setBrush(*fill);
- p->drawRect(x+tlw, y+tlw, w-2*tlw, h-2*tlw);
- p->setBrush(oldBrush);
- }
- p->setPen(oldPen); // restore pen
-}
-
-
-/*!
- \fn void qDrawShadePanel(QPainter *painter, int x, int y, int width, int height,
- const QPalette &palette, bool sunken,
- int lineWidth, const QBrush *fill)
- \relates <qdrawutil.h>
-
- Draws the shaded panel beginning at (\a x, \a y) with the given \a
- width and \a height using the provided \a painter and the given \a
- lineWidth.
-
- The given \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors). The panel's interior is filled
- with the \a fill brush unless \a fill is 0.
-
- The panel appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded panel:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 2
-
- \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle
-*/
-
-void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken,
- int lineWidth, const QBrush *fill)
-{
- if (w == 0 || h == 0)
- return;
- if (!(w > 0 && h > 0 && lineWidth >= 0)) {
- qWarning("qDrawShadePanel: Invalid parameters");
- }
- QColor shade = pal.dark().color();
- QColor light = pal.light().color();
- if (fill) {
- if (fill->color() == shade)
- shade = pal.shadow().color();
- if (fill->color() == light)
- light = pal.midlight().color();
- }
- QPen oldPen = p->pen(); // save pen
- QVector<QLineF> lines;
- lines.reserve(2*lineWidth);
-
- if (sunken)
- p->setPen(shade);
- else
- p->setPen(light);
- int x1, y1, x2, y2;
- int i;
- x1 = x;
- y1 = y2 = y;
- x2 = x+w-2;
- for (i=0; i<lineWidth; i++) { // top shadow
- lines << QLineF(x1, y1++, x2--, y2++);
- }
- x2 = x1;
- y1 = y+h-2;
- for (i=0; i<lineWidth; i++) { // left shado
- lines << QLineF(x1++, y1, x2++, y2--);
- }
- p->drawLines(lines);
- lines.clear();
- if (sunken)
- p->setPen(light);
- else
- p->setPen(shade);
- x1 = x;
- y1 = y2 = y+h-1;
- x2 = x+w-1;
- for (i=0; i<lineWidth; i++) { // bottom shadow
- lines << QLineF(x1++, y1--, x2, y2--);
- }
- x1 = x2;
- y1 = y;
- y2 = y+h-lineWidth-1;
- for (i=0; i<lineWidth; i++) { // right shadow
- lines << QLineF(x1--, y1++, x2--, y2);
- }
- p->drawLines(lines);
- if (fill) // fill with fill color
- p->fillRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2, *fill);
- p->setPen(oldPen); // restore pen
-}
-
-
-/*!
- \internal
- This function draws a rectangle with two pixel line width.
- It is called from qDrawWinButton() and qDrawWinPanel().
-
- c1..c4 and fill are used:
-
- 1 1 1 1 1 2
- 1 3 3 3 4 2
- 1 3 F F 4 2
- 1 3 F F 4 2
- 1 4 4 4 4 2
- 2 2 2 2 2 2
-*/
-
-static void qDrawWinShades(QPainter *p,
- int x, int y, int w, int h,
- const QColor &c1, const QColor &c2,
- const QColor &c3, const QColor &c4,
- const QBrush *fill)
-{
- if (w < 2 || h < 2) // can't do anything with that
- return;
- QPen oldPen = p->pen();
- QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
- p->setPen(c1);
- p->drawPolyline(a, 3);
- QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
- p->setPen(c2);
- p->drawPolyline(b, 3);
- if (w > 4 && h > 4) {
- QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
- p->setPen(c3);
- p->drawPolyline(c, 3);
- QPoint d[3] = { QPoint(x+1, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y+1) };
- p->setPen(c4);
- p->drawPolyline(d, 3);
- if (fill)
- p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
- }
- p->setPen(oldPen);
-}
-
-
-/*!
- \fn void qDrawWinButton(QPainter *painter, int x, int y, int width, int height,
- const QPalette &palette, bool sunken,
- const QBrush *fill)
- \relates <qdrawutil.h>
-
- Draws the Windows-style button specified by the given point (\a x,
- \a y}, \a width and \a height using the provided \a painter with a
- line width of 2 pixels. The button's interior is filled with the
- \a{fill} brush unless \a fill is 0.
-
- The given \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors).
-
- The button appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style()-> Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- \sa qDrawWinPanel(), QStyle
-*/
-
-void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken,
- const QBrush *fill)
-{
- if (sunken)
- qDrawWinShades(p, x, y, w, h,
- pal.shadow().color(), pal.light().color(), pal.dark().color(),
- pal.button().color(), fill);
- else
- qDrawWinShades(p, x, y, w, h,
- pal.light().color(), pal.shadow().color(), pal.button().color(),
- pal.dark().color(), fill);
-}
-
-/*!
- \fn void qDrawWinPanel(QPainter *painter, int x, int y, int width, int height,
- const QPalette &palette, bool sunken,
- const QBrush *fill)
- \relates <qdrawutil.h>
-
- Draws the Windows-style panel specified by the given point(\a x,
- \a y), \a width and \a height using the provided \a painter with a
- line width of 2 pixels. The button's interior is filled with the
- \a fill brush unless \a fill is 0.
-
- The given \a palette specifies the shading colors. The panel
- appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded panel:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 3
-
- \sa qDrawShadePanel(), qDrawWinButton(), QStyle
-*/
-
-void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken,
- const QBrush *fill)
-{
- if (sunken)
- qDrawWinShades(p, x, y, w, h,
- pal.dark().color(), pal.light().color(), pal.shadow().color(),
- pal.midlight().color(), fill);
- else
- qDrawWinShades(p, x, y, w, h,
- pal.light().color(), pal.shadow().color(), pal.midlight().color(),
- pal.dark().color(), fill);
-}
-
-/*!
- \fn void qDrawPlainRect(QPainter *painter, int x, int y, int width, int height, const QColor &lineColor,
- int lineWidth, const QBrush *fill)
- \relates <qdrawutil.h>
-
- Draws the plain rectangle beginning at (\a x, \a y) with the given
- \a width and \a height, using the specified \a painter, \a lineColor
- and \a lineWidth. The rectangle's interior is filled with the \a
- fill brush unless \a fill is 0.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a plain rectangle:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 4
-
- \sa qDrawShadeRect(), QStyle
-*/
-
-void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c,
- int lineWidth, const QBrush *fill)
-{
- if (w == 0 || h == 0)
- return;
- if (!(w > 0 && h > 0 && lineWidth >= 0)) {
- qWarning("qDrawPlainRect: Invalid parameters");
- }
- QPen oldPen = p->pen();
- QBrush oldBrush = p->brush();
- p->setPen(c);
- p->setBrush(Qt::NoBrush);
- for (int i=0; i<lineWidth; i++)
- p->drawRect(x+i, y+i, w-i*2 - 1, h-i*2 - 1);
- if (fill) { // fill with fill color
- p->setPen(Qt::NoPen);
- p->setBrush(*fill);
- p->drawRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2);
- }
- p->setPen(oldPen);
- p->setBrush(oldBrush);
-}
-
-/*****************************************************************************
- Overloaded functions.
- *****************************************************************************/
-
-/*!
- \fn void qDrawShadeLine(QPainter *painter, const QPoint &p1, const QPoint &p2,
- const QPalette &palette, bool sunken, int lineWidth, int midLineWidth)
- \relates <qdrawutil.h>
- \overload
-
- Draws a horizontal or vertical shaded line between \a p1 and \a p2
- using the given \a painter. Note that nothing is drawn if the line
- between the points would be neither horizontal nor vertical.
-
- The provided \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors). The given \a lineWidth
- specifies the line width for each of the lines; it is not the
- total line width. The given \a midLineWidth specifies the width of
- a middle line drawn in the QPalette::mid() color.
-
- The line appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to
- make widgets that follow the current GUI style.
-
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded line:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 5
-
- \sa qDrawShadeRect(), qDrawShadePanel(), QStyle
-*/
-
-void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
- const QPalette &pal, bool sunken,
- int lineWidth, int midLineWidth)
-{
- qDrawShadeLine(p, p1.x(), p1.y(), p2.x(), p2.y(), pal, sunken,
- lineWidth, midLineWidth);
-}
-
-/*!
- \fn void qDrawShadeRect(QPainter *painter, const QRect &rect, const QPalette &palette,
- bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
- \relates <qdrawutil.h>
- \overload
-
- Draws the shaded rectangle specified by \a rect using the given \a painter.
-
- The provide \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors. The given \a lineWidth
- specifies the line width for each of the lines; it is not the
- total line width. The \a midLineWidth specifies the width of a
- middle line drawn in the QPalette::mid() color. The rectangle's
- interior is filled with the \a fill brush unless \a fill is 0.
-
- The rectangle appears sunken if \a sunken is true, otherwise
- raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded rectangle:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 6
-
- \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle
-*/
-
-void qDrawShadeRect(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken,
- int lineWidth, int midLineWidth,
- const QBrush *fill)
-{
- qDrawShadeRect(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
- lineWidth, midLineWidth, fill);
-}
-
-/*!
- \fn void qDrawShadePanel(QPainter *painter, const QRect &rect, const QPalette &palette,
- bool sunken, int lineWidth, const QBrush *fill)
- \relates <qdrawutil.h>
- \overload
-
- Draws the shaded panel at the rectangle specified by \a rect using the
- given \a painter and the given \a lineWidth.
-
- The given \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors). The panel's interior is filled
- with the \a fill brush unless \a fill is 0.
-
- The panel appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded panel:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 7
-
- \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle
-*/
-
-void qDrawShadePanel(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken,
- int lineWidth, const QBrush *fill)
-{
- qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
- lineWidth, fill);
-}
-
-/*!
- \fn void qDrawWinButton(QPainter *painter, const QRect &rect, const QPalette &palette,
- bool sunken, const QBrush *fill)
- \relates <qdrawutil.h>
- \overload
-
- Draws the Windows-style button at the rectangle specified by \a rect using
- the given \a painter with a line width of 2 pixels. The button's interior
- is filled with the \a{fill} brush unless \a fill is 0.
-
- The given \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors).
-
- The button appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style()-> Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- \sa qDrawWinPanel(), QStyle
-*/
-
-void qDrawWinButton(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken, const QBrush *fill)
-{
- qDrawWinButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
-}
-
-/*!
- \fn void qDrawWinPanel(QPainter *painter, const QRect &rect, const QPalette &palette,
- bool sunken, const QBrush *fill)
- \overload
-
- Draws the Windows-style panel at the rectangle specified by \a rect using
- the given \a painter with a line width of 2 pixels. The button's interior
- is filled with the \a fill brush unless \a fill is 0.
-
- The given \a palette specifies the shading colors. The panel
- appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded panel:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 8
-
- \sa qDrawShadePanel(), qDrawWinButton(), QStyle
-*/
-
-void qDrawWinPanel(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken, const QBrush *fill)
-{
- qDrawWinPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
-}
-
-/*!
- \fn void qDrawPlainRect(QPainter *painter, const QRect &rect, const QColor &lineColor, int lineWidth, const QBrush *fill)
- \relates <qdrawutil.h>
- \overload
-
- Draws the plain rectangle specified by \a rect using the given \a painter,
- \a lineColor and \a lineWidth. The rectangle's interior is filled with the
- \a fill brush unless \a fill is 0.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a plain rectangle:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 9
-
- \sa qDrawShadeRect(), QStyle
-*/
-
-void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &c,
- int lineWidth, const QBrush *fill)
-{
- qDrawPlainRect(p, r.x(), r.y(), r.width(), r.height(), c,
- lineWidth, fill);
-}
-
-#ifdef QT3_SUPPORT
-static void qDrawWinArrow(QPainter *p, Qt::ArrowType type, bool down,
- int x, int y, int w, int h,
- const QPalette &pal, bool enabled)
-{
- QPolygon a; // arrow polygon
- switch (type) {
- case Qt::UpArrow:
- a.setPoints(7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2);
- break;
- case Qt::DownArrow:
- a.setPoints(7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2);
- break;
- case Qt::LeftArrow:
- a.setPoints(7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0);
- break;
- case Qt::RightArrow:
- a.setPoints(7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0);
- break;
- default:
- break;
- }
- if (a.isEmpty())
- return;
-
- if (down) {
- x++;
- y++;
- }
-
- QPen savePen = p->pen(); // save current pen
- if (down)
- p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
- p->fillRect(x, y, w, h, pal.brush(QPalette::Button));
- if (down)
- p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
- if (enabled) {
- a.translate(x+w/2, y+h/2);
- p->setPen(pal.foreground().color());
- p->drawLine(a.at(0), a.at(1));
- p->drawLine(a.at(2), a.at(2));
- p->drawPoint(a[6]);
- } else {
- a.translate(x+w/2+1, y+h/2+1);
- p->setPen(pal.light().color());
- p->drawLine(a.at(0), a.at(1));
- p->drawLine(a.at(2), a.at(2));
- p->drawPoint(a[6]);
- a.translate(-1, -1);
- p->setPen(pal.mid().color());
- p->drawLine(a.at(0), a.at(1));
- p->drawLine(a.at(2), a.at(2));
- p->drawPoint(a[6]);
- }
- p->setPen(savePen); // restore pen
-}
-#endif // QT3_SUPPORT
-
-#if defined(Q_CC_MSVC)
-#pragma warning(disable: 4244)
-#endif
-
-#ifdef QT3_SUPPORT
-#ifndef QT_NO_STYLE_MOTIF
-// motif arrows look the same whether they are used or not
-// is this correct?
-static void qDrawMotifArrow(QPainter *p, Qt::ArrowType type, bool down,
- int x, int y, int w, int h,
- const QPalette &pal, bool)
-{
- QPolygon bFill; // fill polygon
- QPolygon bTop; // top shadow.
- QPolygon bBot; // bottom shadow.
- QPolygon bLeft; // left shadow.
- QTransform matrix; // xform matrix
- bool vertical = type == Qt::UpArrow || type == Qt::DownArrow;
- bool horizontal = !vertical;
- int dim = w < h ? w : h;
- int colspec = 0x0000; // color specification array
-
- if (dim < 2) // too small arrow
- return;
-
- if (dim > 3) {
- if (dim > 6)
- bFill.resize(dim & 1 ? 3 : 4);
- bTop.resize((dim/2)*2);
- bBot.resize(dim & 1 ? dim + 1 : dim);
- bLeft.resize(dim > 4 ? 4 : 2);
- bLeft.putPoints(0, 2, 0,0, 0,dim-1);
- if (dim > 4)
- bLeft.putPoints(2, 2, 1,2, 1,dim-3);
- bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1);
- bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2);
-
- for(int i=0; i<dim/2-2 ; i++) {
- bTop.putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i);
- bBot.putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i);
- }
- if (dim & 1) // odd number size: extra line
- bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
- if (dim > 6) { // dim>6: must fill interior
- bFill.putPoints(0, 2, 1,dim-3, 1,2);
- if (dim & 1) // if size is an odd number
- bFill.setPoint(2, dim - 3, dim / 2);
- else
- bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
- }
- }
- else {
- if (dim == 3) { // 3x3 arrow pattern
- bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1);
- bTop .setPoints(2, 1,0, 1,0);
- bBot .setPoints(2, 1,2, 2,1);
- }
- else { // 2x2 arrow pattern
- bLeft.setPoints(2, 0,0, 0,1);
- bTop .setPoints(2, 1,0, 1,0);
- bBot .setPoints(2, 1,1, 1,1);
- }
- }
-
- if (type == Qt::UpArrow || type == Qt::LeftArrow) {
- matrix.translate(x, y);
- if (vertical) {
- matrix.translate(0, h - 1);
- matrix.rotate(-90);
- } else {
- matrix.translate(w - 1, h - 1);
- matrix.rotate(180);
- }
- if (down)
- colspec = horizontal ? 0x2334 : 0x2343;
- else
- colspec = horizontal ? 0x1443 : 0x1434;
- }
- else if (type == Qt::DownArrow || type == Qt::RightArrow) {
- matrix.translate(x, y);
- if (vertical) {
- matrix.translate(w-1, 0);
- matrix.rotate(90);
- }
- if (down)
- colspec = horizontal ? 0x2443 : 0x2434;
- else
- colspec = horizontal ? 0x1334 : 0x1343;
- }
-
- const QColor *cols[5];
- cols[0] = 0;
- cols[1] = &pal.button().color();
- cols[2] = &pal.mid().color();
- cols[3] = &pal.light().color();
- cols[4] = &pal.dark().color();
-#define CMID *cols[(colspec>>12) & 0xf]
-#define CLEFT *cols[(colspec>>8) & 0xf]
-#define CTOP *cols[(colspec>>4) & 0xf]
-#define CBOT *cols[colspec & 0xf]
-
- QPen savePen = p->pen(); // save current pen
- QBrush saveBrush = p->brush(); // save current brush
- QTransform wxm = p->transform();
- QPen pen(Qt::NoPen);
- const QBrush &brush = pal.brush(QPalette::Button);
-
- p->setPen(pen);
- p->setBrush(brush);
- p->setTransform(matrix, true); // set transformation matrix
- p->drawPolygon(bFill); // fill arrow
- p->setBrush(Qt::NoBrush); // don't fill
-
- p->setPen(CLEFT);
- p->drawLines(bLeft);
- p->setPen(CTOP);
- p->drawLines(bTop);
- p->setPen(CBOT);
- p->drawLines(bBot);
-
- p->setTransform(wxm);
- p->setBrush(saveBrush); // restore brush
- p->setPen(savePen); // restore pen
-
-#undef CMID
-#undef CLEFT
-#undef CTOP
-#undef CBOT
-}
-#endif // QT_NO_STYLE_MOTIF
-
-QRect qItemRect(QPainter *p, Qt::GUIStyle gs,
- int x, int y, int w, int h,
- int flags,
- bool enabled,
- const QPixmap *pixmap,
- const QString& text, int len)
-{
- QRect result;
-
- if (pixmap) {
- if ((flags & Qt::AlignVCenter) == Qt::AlignVCenter)
- y += h/2 - pixmap->height()/2;
- else if ((flags & Qt::AlignBottom) == Qt::AlignBottom)
- y += h - pixmap->height();
- if ((flags & Qt::AlignRight) == Qt::AlignRight)
- x += w - pixmap->width();
- else if ((flags & Qt::AlignHCenter) == Qt::AlignHCenter)
- x += w/2 - pixmap->width()/2;
- else if ((flags & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft())
- x += w - pixmap->width();
- result = QRect(x, y, pixmap->width(), pixmap->height());
- } else if (!text.isNull() && p) {
- result = p->boundingRect(QRect(x, y, w, h), flags, text.left(len));
- if (gs == Qt::WindowsStyle && !enabled) {
- result.setWidth(result.width()+1);
- result.setHeight(result.height()+1);
- }
- } else {
- result = QRect(x, y, w, h);
- }
-
- return result;
-}
-
-void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GUIStyle style, bool down,
- int x, int y, int w, int h,
- const QPalette &pal, bool enabled)
-{
- switch (style) {
- case Qt::WindowsStyle:
- qDrawWinArrow(p, type, down, x, y, w, h, pal, enabled);
- break;
-#ifndef QT_NO_STYLE_MOTIF
- case Qt::MotifStyle:
- qDrawMotifArrow(p, type, down, x, y, w, h, pal, enabled);
- break;
-#endif
- default:
- qWarning("qDrawArrow: Requested unsupported GUI style");
- }
-}
-
-void qDrawItem(QPainter *p, Qt::GUIStyle gs,
- int x, int y, int w, int h,
- int flags,
- const QPalette &pal, bool enabled,
- const QPixmap *pixmap,
- const QString& text, int len , const QColor* penColor)
-{
- p->setPen(penColor?*penColor:pal.foreground().color());
- if (pixmap) {
- QPixmap pm(*pixmap);
- bool clip = (flags & Qt::TextDontClip) == 0;
- if (clip) {
- if (pm.width() < w && pm.height() < h)
- clip = false;
- else
- p->setClipRect(x, y, w, h);
- }
- if ((flags & Qt::AlignVCenter) == Qt::AlignVCenter)
- y += h/2 - pm.height()/2;
- else if ((flags & Qt::AlignBottom) == Qt::AlignBottom)
- y += h - pm.height();
- if ((flags & Qt::AlignRight) == Qt::AlignRight)
- x += w - pm.width();
- else if ((flags & Qt::AlignHCenter) == Qt::AlignHCenter)
- x += w/2 - pm.width()/2;
- else if (((flags & Qt::AlignLeft) != Qt::AlignLeft) && QApplication::isRightToLeft()) // Qt::AlignAuto && rightToLeft
- x += w - pm.width();
-
- if (!enabled) {
- if (pm.hasAlphaChannel()) { // pixmap with a mask
- pm = pm.mask();
- } else if (pm.depth() == 1) { // monochrome pixmap, no mask
- ;
-#ifndef QT_NO_IMAGE_HEURISTIC_MASK
- } else { // color pixmap, no mask
- QString k = QLatin1Literal("$qt-drawitem")
- % HexString<qint64>(pm.cacheKey());
-
- if (!QPixmapCache::find(k, pm)) {
- pm = pm.createHeuristicMask();
- pm.setMask((QBitmap&)pm);
- QPixmapCache::insert(k, pm);
- }
-#endif
- }
- if (gs == Qt::WindowsStyle) {
- p->setPen(pal.light().color());
- p->drawPixmap(x+1, y+1, pm);
- p->setPen(pal.text().color());
- }
- }
- p->drawPixmap(x, y, pm);
- if (clip)
- p->setClipping(false);
- } else if (!text.isNull()) {
- if (gs == Qt::WindowsStyle && !enabled) {
- p->setPen(pal.light().color());
- p->drawText(x+1, y+1, w, h, flags, text.left(len));
- p->setPen(pal.text().color());
- }
- p->drawText(x, y, w, h, flags, text.left(len));
- }
-}
-
-#endif
-
-/*!
- \class QTileRules
- \since 4.6
-
- Holds the rules used to draw a pixmap or image split into nine segments,
- similar to \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}.
-
- \sa Qt::TileRule, QMargins
-*/
-
-/*! \fn QTileRules::QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
- Constructs a QTileRules with the given \a horizontalRule and
- \a verticalRule.
- */
-
-/*! \fn QTileRules::QTileRules(Qt::TileRule rule)
- Constructs a QTileRules with the given \a rule used for both
- the horizontal rule and the vertical rule.
- */
-
-/*!
- \fn void qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap)
- \relates <qdrawutil.h>
- \since 4.6
- \overload
-
- \brief The qDrawBorderPixmap function is for drawing a pixmap into
- the margins of a rectangle.
-
- Draws the given \a pixmap into the given \a target rectangle, using the
- given \a painter. The pixmap will be split into nine segments and drawn
- according to the \a margins structure.
-*/
-
-typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray;
-
-/*!
- \since 4.6
-
- Draws the indicated \a sourceRect rectangle from the given \a pixmap into
- the given \a targetRect rectangle, using the given \a painter. The pixmap
- will be split into nine segments according to the given \a targetMargins
- and \a sourceMargins structures. Finally, the pixmap will be drawn
- according to the given \a rules.
-
- This function is used to draw a scaled pixmap, similar to
- \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}
-
- \sa Qt::TileRule, QTileRules, QMargins
-*/
-
-void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins,
- const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
- const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
-{
- QPainter::PixmapFragment d;
- d.opacity = 1.0;
- d.rotation = 0.0;
-
- QPixmapFragmentsArray opaqueData;
- QPixmapFragmentsArray translucentData;
-
- // source center
- const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
- const int sourceCenterLeft = sourceRect.left() + sourceMargins.left();
- const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1;
- const int sourceCenterRight = sourceRect.right() - sourceMargins.right() + 1;
- const int sourceCenterWidth = sourceCenterRight - sourceCenterLeft;
- const int sourceCenterHeight = sourceCenterBottom - sourceCenterTop;
- // target center
- const int targetCenterTop = targetRect.top() + targetMargins.top();
- const int targetCenterLeft = targetRect.left() + targetMargins.left();
- const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1;
- const int targetCenterRight = targetRect.right() - targetMargins.right() + 1;
- const int targetCenterWidth = targetCenterRight - targetCenterLeft;
- const int targetCenterHeight = targetCenterBottom - targetCenterTop;
-
- QVarLengthArray<qreal, 16> xTarget; // x-coordinates of target rectangles
- QVarLengthArray<qreal, 16> yTarget; // y-coordinates of target rectangles
-
- int columns = 3;
- int rows = 3;
- if (rules.horizontal != Qt::StretchTile && sourceCenterWidth != 0)
- columns = qMax(3, 2 + qCeil(targetCenterWidth / qreal(sourceCenterWidth)));
- if (rules.vertical != Qt::StretchTile && sourceCenterHeight != 0)
- rows = qMax(3, 2 + qCeil(targetCenterHeight / qreal(sourceCenterHeight)));
-
- xTarget.resize(columns + 1);
- yTarget.resize(rows + 1);
-
- bool oldAA = painter->testRenderHint(QPainter::Antialiasing);
- if (painter->paintEngine()->type() != QPaintEngine::OpenGL
- && painter->paintEngine()->type() != QPaintEngine::OpenGL2
- && oldAA && painter->combinedTransform().type() != QTransform::TxNone) {
- painter->setRenderHint(QPainter::Antialiasing, false);
- }
-
- xTarget[0] = targetRect.left();
- xTarget[1] = targetCenterLeft;
- xTarget[columns - 1] = targetCenterRight;
- xTarget[columns] = targetRect.left() + targetRect.width();
-
- yTarget[0] = targetRect.top();
- yTarget[1] = targetCenterTop;
- yTarget[rows - 1] = targetCenterBottom;
- yTarget[rows] = targetRect.top() + targetRect.height();
-
- qreal dx = targetCenterWidth;
- qreal dy = targetCenterHeight;
-
- switch (rules.horizontal) {
- case Qt::StretchTile:
- dx = targetCenterWidth;
- break;
- case Qt::RepeatTile:
- dx = sourceCenterWidth;
- break;
- case Qt::RoundTile:
- dx = targetCenterWidth / qreal(columns - 2);
- break;
- }
-
- for (int i = 2; i < columns - 1; ++i)
- xTarget[i] = xTarget[i - 1] + dx;
-
- switch (rules.vertical) {
- case Qt::StretchTile:
- dy = targetCenterHeight;
- break;
- case Qt::RepeatTile:
- dy = sourceCenterHeight;
- break;
- case Qt::RoundTile:
- dy = targetCenterHeight / qreal(rows - 2);
- break;
- }
-
- for (int i = 2; i < rows - 1; ++i)
- yTarget[i] = yTarget[i - 1] + dy;
-
- // corners
- if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left
- d.x = (0.5 * (xTarget[1] + xTarget[0]));
- d.y = (0.5 * (yTarget[1] + yTarget[0]));
- d.sourceLeft = sourceRect.left();
- d.sourceTop = sourceRect.top();
- d.width = sourceMargins.left();
- d.height = sourceMargins.top();
- d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
- d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueTopLeft)
- opaqueData.append(d);
- else
- translucentData.append(d);
- }
- if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right
- d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
- d.y = (0.5 * (yTarget[1] + yTarget[0]));
- d.sourceLeft = sourceCenterRight;
- d.sourceTop = sourceRect.top();
- d.width = sourceMargins.right();
- d.height = sourceMargins.top();
- d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
- d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueTopRight)
- opaqueData.append(d);
- else
- translucentData.append(d);
- }
- if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left
- d.x = (0.5 * (xTarget[1] + xTarget[0]));
- d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1]));
- d.sourceLeft = sourceRect.left();
- d.sourceTop = sourceCenterBottom;
- d.width = sourceMargins.left();
- d.height = sourceMargins.bottom();
- d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
- d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueBottomLeft)
- opaqueData.append(d);
- else
- translucentData.append(d);
- }
- if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right
- d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
- d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
- d.sourceLeft = sourceCenterRight;
- d.sourceTop = sourceCenterBottom;
- d.width = sourceMargins.right();
- d.height = sourceMargins.bottom();
- d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
- d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueBottomRight)
- opaqueData.append(d);
- else
- translucentData.append(d);
- }
-
- // horizontal edges
- if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
- if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueTop ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterLeft;
- d.sourceTop = sourceRect.top();
- d.width = sourceCenterWidth;
- d.height = sourceMargins.top();
- d.y = (0.5 * (yTarget[1] + yTarget[0]));
- d.scaleX = dx / d.width;
- d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
- for (int i = 1; i < columns - 1; ++i) {
- d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
- data.append(d);
- }
- if (rules.horizontal == Qt::RepeatTile)
- data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
- }
- if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueBottom ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterLeft;
- d.sourceTop = sourceCenterBottom;
- d.width = sourceCenterWidth;
- d.height = sourceMargins.bottom();
- d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
- d.scaleX = dx / d.width;
- d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
- for (int i = 1; i < columns - 1; ++i) {
- d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
- data.append(d);
- }
- if (rules.horizontal == Qt::RepeatTile)
- data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
- }
- }
-
- // vertical edges
- if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
- if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueLeft ? opaqueData : translucentData;
- d.sourceLeft = sourceRect.left();
- d.sourceTop = sourceCenterTop;
- d.width = sourceMargins.left();
- d.height = sourceCenterHeight;
- d.x = (0.5 * (xTarget[1] + xTarget[0]));
- d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
- d.scaleY = dy / d.height;
- for (int i = 1; i < rows - 1; ++i) {
- d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
- data.append(d);
- }
- if (rules.vertical == Qt::RepeatTile)
- data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
- }
- if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueRight ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterRight;
- d.sourceTop = sourceCenterTop;
- d.width = sourceMargins.right();
- d.height = sourceCenterHeight;
- d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
- d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
- d.scaleY = dy / d.height;
- for (int i = 1; i < rows - 1; ++i) {
- d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
- data.append(d);
- }
- if (rules.vertical == Qt::RepeatTile)
- data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
- }
- }
-
- // center
- if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueCenter ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterLeft;
- d.sourceTop = sourceCenterTop;
- d.width = sourceCenterWidth;
- d.height = sourceCenterHeight;
- d.scaleX = dx / d.width;
- d.scaleY = dy / d.height;
-
- qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX;
- qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY;
-
- for (int j = 1; j < rows - 1; ++j) {
- d.y = (0.5 * (yTarget[j + 1] + yTarget[j]));
- for (int i = 1; i < columns - 1; ++i) {
- d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
- data.append(d);
- }
- if (rules.horizontal == Qt::RepeatTile)
- data[data.size() - 1].width = repeatWidth;
- }
- if (rules.vertical == Qt::RepeatTile) {
- for (int i = 1; i < columns - 1; ++i)
- data[data.size() - i].height = repeatHeight;
- }
- }
-
- if (opaqueData.size())
- painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint);
- if (translucentData.size())
- painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap);
-
- if (oldAA)
- painter->setRenderHint(QPainter::Antialiasing, true);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qdrawutil.h b/src/gui/painting/qdrawutil.h
deleted file mode 100644
index 0f38357841..0000000000
--- a/src/gui/painting/qdrawutil.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDRAWUTIL_H
-#define QDRAWUTIL_H
-
-#include <QtCore/qnamespace.h>
-#include <QtCore/qstring.h> // char*->QString conversion
-#include <QtCore/qmargins.h>
-#include <QtGui/qpixmap.h>
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPainter;
-#ifndef QT3_SUPPORT
-class QColorGroup;
-#endif
-class QPalette;
-class QPoint;
-class QColor;
-class QBrush;
-class QRect;
-
-//
-// Standard shade drawing
-//
-
-Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
- const QPalette &pal, bool sunken = true,
- int lineWidth = 1, int midLineWidth = 0);
-
-Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
- const QPalette &pal, bool sunken = true,
- int lineWidth = 1, int midLineWidth = 0);
-
-Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken = false,
- int lineWidth = 1, int midLineWidth = 0,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken = false,
- int lineWidth = 1, int midLineWidth = 0,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken = false,
- int lineWidth = 1, const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken = false,
- int lineWidth = 1, const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
- int lineWidth = 1, const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
- int lineWidth = 1, const QBrush *fill = 0);
-
-
-#ifdef QT3_SUPPORT
-//
-// Use QStyle::itemRect(), QStyle::drawItem() and QStyle::drawArrow() instead.
-//
-Q_GUI_EXPORT QT3_SUPPORT QRect qItemRect(QPainter *p, Qt::GUIStyle gs, int x, int y, int w, int h,
- int flags, bool enabled,
- const QPixmap *pixmap, const QString& text, int len=-1);
-
-Q_GUI_EXPORT QT3_SUPPORT void qDrawItem(QPainter *p, Qt::GUIStyle gs, int x, int y, int w, int h,
- int flags, const QPalette &pal, bool enabled,
- const QPixmap *pixmap, const QString& text,
- int len=-1, const QColor* penColor = 0);
-
-Q_GUI_EXPORT QT3_SUPPORT void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GUIStyle style, bool down,
- int x, int y, int w, int h,
- const QPalette &pal, bool enabled);
-#endif
-
-struct QTileRules
-{
- inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
- : horizontal(horizontalRule), vertical(verticalRule) {}
- inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
- : horizontal(rule), vertical(rule) {}
- Qt::TileRule horizontal;
- Qt::TileRule vertical;
-};
-
-#ifndef Q_QDOC
-// For internal use only.
-namespace QDrawBorderPixmap
-{
- enum DrawingHint
- {
- OpaqueTopLeft = 0x0001,
- OpaqueTop = 0x0002,
- OpaqueTopRight = 0x0004,
- OpaqueLeft = 0x0008,
- OpaqueCenter = 0x0010,
- OpaqueRight = 0x0020,
- OpaqueBottomLeft = 0x0040,
- OpaqueBottom = 0x0080,
- OpaqueBottomRight = 0x0100,
- OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
- OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
- OpaqueFrame = OpaqueCorners | OpaqueEdges,
- OpaqueAll = OpaqueCenter | OpaqueFrame
- };
-
- Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
-}
-#endif
-
-Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter,
- const QRect &targetRect,
- const QMargins &targetMargins,
- const QPixmap &pixmap,
- const QRect &sourceRect,
- const QMargins &sourceMargins,
- const QTileRules &rules = QTileRules()
-#ifndef Q_QDOC
- , QDrawBorderPixmap::DrawingHints hints = 0
-#endif
- );
-
-inline void qDrawBorderPixmap(QPainter *painter,
- const QRect &target,
- const QMargins &margins,
- const QPixmap &pixmap)
-{
- qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDRAWUTIL_H
diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp
deleted file mode 100644
index de0b516e79..0000000000
--- a/src/gui/painting/qgraphicssystem.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_p.h"
-
-#ifdef Q_WS_X11
-# include <private/qpixmap_x11_p.h>
-#endif
-#if defined(Q_WS_WIN)
-# include <private/qpixmap_raster_p.h>
-#endif
-#ifdef Q_WS_MAC
-# include <private/qpixmap_mac_p.h>
-#endif
-#ifdef Q_WS_QPA
-# include <QtGui/private/qapplication_p.h>
-#endif
-#ifdef Q_OS_SYMBIAN
-# include <private/qpixmap_s60_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QGraphicsSystem::~QGraphicsSystem()
-{
-}
-
-QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType type)
-{
-#ifdef Q_WS_QWS
- Q_UNUSED(type);
-#endif
-#if defined(Q_WS_X11)
- return new QX11PixmapData(type);
-#elif defined(Q_WS_WIN)
- return new QRasterPixmapData(type);
-#elif defined(Q_WS_MAC)
- return new QMacPixmapData(type);
-#elif defined(Q_WS_QPA)
- return QApplicationPrivate::platformIntegration()->createPixmapData(type);
-#elif defined(Q_OS_SYMBIAN)
- return new QS60PixmapData(type);
-#elif !defined(Q_WS_QWS)
-#error QGraphicsSystem::createDefaultPixmapData() not implemented
-#endif
- return 0;
-}
-
-QPixmapData *QGraphicsSystem::createPixmapData(QPixmapData *origin)
-{
- return createPixmapData(origin->pixelType());
-}
-
-void QGraphicsSystem::releaseCachedResources()
-{
- // Do nothing here
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_mac.cpp b/src/gui/painting/qgraphicssystem_mac.cpp
deleted file mode 100644
index bbff88b6b5..0000000000
--- a/src/gui/painting/qgraphicssystem_mac.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_mac_p.h"
-
-#include <private/qpixmap_mac_p.h>
-#include <private/qwindowsurface_mac_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QPixmapData *QCoreGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- return new QMacPixmapData(type);
-}
-
-QWindowSurface *QCoreGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- return new QMacWindowSurface(widget);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_mac_p.h b/src/gui/painting/qgraphicssystem_mac_p.h
deleted file mode 100644
index 8e15d8b236..0000000000
--- a/src/gui/painting/qgraphicssystem_mac_p.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_MAC_P_H
-#define QGRAPHICSSYSTEM_MAC_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qgraphicssystem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class Q_GUI_EXPORT QCoreGraphicsSystem : public QGraphicsSystem
-{
-public:
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h
deleted file mode 100644
index 53c05515fa..0000000000
--- a/src/gui/painting/qgraphicssystem_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_P_H
-#define QGRAPHICSSYSTEM_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 "private/qpixmapdata_p.h"
-#include "private/qwindowsurface_p.h"
-#include "private/qpaintengine_blitter_p.h"
-
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-class QPixmapFilter;
-class QBlittable;
-
-class Q_GUI_EXPORT QGraphicsSystem
-{
-public:
- virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0;
- virtual QPixmapData *createPixmapData(QPixmapData *origin);
- virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0;
-
- virtual ~QGraphicsSystem();
-
- //### Remove this & change qpixmap.cpp & qbitmap.cpp once every platform is gaurenteed
- // to have a graphics system.
- static QPixmapData *createDefaultPixmapData(QPixmapData::PixelType type);
-
- virtual void releaseCachedResources();
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/painting/qgraphicssystem_qws.cpp b/src/gui/painting/qgraphicssystem_qws.cpp
deleted file mode 100644
index 2c2b776f5d..0000000000
--- a/src/gui/painting/qgraphicssystem_qws.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreen_qws.h>
-#include "qgraphicssystem_qws_p.h"
-#include <private/qpixmap_raster_p.h>
-#include <private/qwindowsurface_qws_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QPixmapData *QWSGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- if (screen->pixmapDataFactory())
- return screen->pixmapDataFactory()->create(type); //### For 4.4 compatibility
- else
- return new QRasterPixmapData(type);
-}
-
-QWindowSurface *QWSGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- return screen->createSurface(widget);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_qws_p.h b/src/gui/painting/qgraphicssystem_qws_p.h
deleted file mode 100644
index b54aad90f9..0000000000
--- a/src/gui/painting/qgraphicssystem_qws_p.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_QWS_P_H
-#define QGRAPHICSSYSTEM_QWS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgraphicssystem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class Q_GUI_EXPORT QWSGraphicsSystem : public QGraphicsSystem
-{
-public:
-
- QWSGraphicsSystem()
- : screen(QScreen::instance()) {}
-
- QWSGraphicsSystem(QScreen* s)
- : screen(s) {}
-
- virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-
-private:
- QScreen* screen;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/painting/qgraphicssystem_raster.cpp b/src/gui/painting/qgraphicssystem_raster.cpp
deleted file mode 100644
index 0edbe9f5a3..0000000000
--- a/src/gui/painting/qgraphicssystem_raster.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_raster_p.h"
-
-#ifdef Q_OS_SYMBIAN
-#include "private/qpixmap_s60_p.h"
-#include "private/qwindowsurface_s60_p.h"
-#else
-#include "private/qpixmap_raster_p.h"
-#include "private/qwindowsurface_raster_p.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QPixmapData *QRasterGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
-#ifdef Q_OS_SYMBIAN
- return new QS60PixmapData(type);
-#else
- return new QRasterPixmapData(type);
-#endif
-}
-
-QWindowSurface *QRasterGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
-#ifdef Q_OS_SYMBIAN
- return new QS60WindowSurface(widget);
-#else
- return new QRasterWindowSurface(widget);
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_raster_p.h b/src/gui/painting/qgraphicssystem_raster_p.h
deleted file mode 100644
index e9737ce78f..0000000000
--- a/src/gui/painting/qgraphicssystem_raster_p.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_RASTER_P_H
-#define QGRAPHICSSYSTEM_RASTER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgraphicssystem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QRasterGraphicsSystem : public QGraphicsSystem
-{
-public:
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp
deleted file mode 100644
index 19b29a13b3..0000000000
--- a/src/gui/painting/qgraphicssystem_runtime.cpp
+++ /dev/null
@@ -1,426 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qgraphicssystem_runtime_p.h>
-#include <private/qgraphicssystem_raster_p.h>
-#include <private/qgraphicssystemfactory_p.h>
-#include <private/qapplication_p.h>
-#include <private/qwidget_p.h>
-#include <QtCore/QDebug>
-#include <QtCore/QTimer>
-#include <QtGui/QBitmap>
-
-QT_BEGIN_NAMESPACE
-
-static int qt_pixmap_serial = 0;
-
-#define READBACK(f) \
- f \
- readBackInfo();
-
-
-class QDeferredGraphicsSystemChange : public QObject
-{
- Q_OBJECT
-
-public:
- QDeferredGraphicsSystemChange(QRuntimeGraphicsSystem *gs, const QString& graphicsSystemName)
- : m_graphicsSystem(gs), m_graphicsSystemName(graphicsSystemName)
- {
- }
-
- void launch()
- {
- QTimer::singleShot(0, this, SLOT(doChange()));
- }
-
-private slots:
-
- void doChange()
- {
- m_graphicsSystem->setGraphicsSystem(m_graphicsSystemName);
- deleteLater();
- }
-
-private:
-
- QRuntimeGraphicsSystem *m_graphicsSystem;
- QString m_graphicsSystemName;
-};
-
-QRuntimePixmapData::QRuntimePixmapData(const QRuntimeGraphicsSystem *gs, PixelType type)
- : QPixmapData(type, RuntimeClass), m_graphicsSystem(gs)
-{
- setSerialNumber(++qt_pixmap_serial);
-}
-
-QRuntimePixmapData::~QRuntimePixmapData()
-{
- if (QApplicationPrivate::graphics_system)
- m_graphicsSystem->removePixmapData(this);
- delete m_data;
-}
-
-void QRuntimePixmapData::readBackInfo()
-{
- w = m_data->width();
- h = m_data->height();
- d = m_data->depth();
- is_null = m_data->isNull();
-}
-
-
-QPixmapData *QRuntimePixmapData::createCompatiblePixmapData() const
-{
- QRuntimePixmapData *rtData = new QRuntimePixmapData(m_graphicsSystem, pixelType());
- rtData->m_data = m_data->createCompatiblePixmapData();
- return rtData;
-}
-
-
-void QRuntimePixmapData::resize(int width, int height)
-{
- READBACK(
- m_data->resize(width, height);
- )
-}
-
-
-void QRuntimePixmapData::fromImage(const QImage &image,
- Qt::ImageConversionFlags flags)
-{
- READBACK(
- m_data->fromImage(image, flags);
- )
-}
-
-
-bool QRuntimePixmapData::fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags)
-{
- bool success(false);
- READBACK(
- success = m_data->fromFile(filename, format, flags);
- )
- return success;
-}
-
-bool QRuntimePixmapData::fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags)
-{
- bool success(false);
- READBACK(
- success = m_data->fromData(buffer, len, format, flags);
- )
- return success;
-}
-
-
-void QRuntimePixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- if (data->runtimeData()) {
- READBACK(
- m_data->copy(data->runtimeData(), rect);
- )
- } else {
- READBACK(
- m_data->copy(data, rect);
- )
- }
-}
-
-bool QRuntimePixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- return m_data->scroll(dx, dy, rect);
-}
-
-
-int QRuntimePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
-{
- return m_data->metric(metric);
-}
-
-void QRuntimePixmapData::fill(const QColor &color)
-{
- return m_data->fill(color);
-}
-
-QBitmap QRuntimePixmapData::mask() const
-{
- return m_data->mask();
-}
-
-void QRuntimePixmapData::setMask(const QBitmap &mask)
-{
- READBACK(
- m_data->setMask(mask);
- )
-}
-
-bool QRuntimePixmapData::hasAlphaChannel() const
-{
- return m_data->hasAlphaChannel();
-}
-
-QPixmap QRuntimePixmapData::transformed(const QTransform &matrix,
- Qt::TransformationMode mode) const
-{
- return m_data->transformed(matrix, mode);
-}
-
-void QRuntimePixmapData::setAlphaChannel(const QPixmap &alphaChannel)
-{
- READBACK(
- m_data->setAlphaChannel(alphaChannel);
- )
-}
-
-QPixmap QRuntimePixmapData::alphaChannel() const
-{
- return m_data->alphaChannel();
-}
-
-QImage QRuntimePixmapData::toImage() const
-{
- return m_data->toImage();
-}
-
-QPaintEngine* QRuntimePixmapData::paintEngine() const
-{
- return m_data->paintEngine();
-}
-
-QImage* QRuntimePixmapData::buffer()
-{
- return m_data->buffer();
-}
-
-#if defined(Q_OS_SYMBIAN)
-void* QRuntimePixmapData::toNativeType(NativeType type)
-{
- return m_data->toNativeType(type);
-}
-
-void QRuntimePixmapData::fromNativeType(void *pixmap, NativeType type)
-{
- m_data->fromNativeType(pixmap, type);
- readBackInfo();
-}
-#endif
-
-QPixmapData* QRuntimePixmapData::runtimeData() const
-{
- return m_data;
-}
-
-QRuntimeWindowSurface::QRuntimeWindowSurface(const QRuntimeGraphicsSystem *gs, QWidget *window)
- : QWindowSurface(window), m_graphicsSystem(gs)
-{
-
-}
-
-QRuntimeWindowSurface::~QRuntimeWindowSurface()
-{
- if (QApplicationPrivate::graphics_system)
- m_graphicsSystem->removeWindowSurface(this);
-}
-
-QPaintDevice *QRuntimeWindowSurface::paintDevice()
-{
- return m_windowSurface->paintDevice();
-}
-
-void QRuntimeWindowSurface::flush(QWidget *widget, const QRegion &region,
- const QPoint &offset)
-{
- m_windowSurface->flush(widget, region, offset);
-
- int destroyPolicy = m_graphicsSystem->windowSurfaceDestroyPolicy();
- if(m_pendingWindowSurface &&
- destroyPolicy == QRuntimeGraphicsSystem::DestroyAfterFirstFlush) {
-#ifdef QT_DEBUG
- qDebug() << "QRuntimeWindowSurface::flush() - destroy pending window surface";
-#endif
- m_pendingWindowSurface.reset();
- }
-}
-
-void QRuntimeWindowSurface::setGeometry(const QRect &rect)
-{
- QWindowSurface::setGeometry(rect);
- m_windowSurface->setGeometry(rect);
-}
-
-bool QRuntimeWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- return m_windowSurface->scroll(area, dx, dy);
-}
-
-void QRuntimeWindowSurface::beginPaint(const QRegion &rgn)
-{
- m_windowSurface->beginPaint(rgn);
-}
-
-void QRuntimeWindowSurface::endPaint(const QRegion &rgn)
-{
- m_windowSurface->endPaint(rgn);
-}
-
-QImage* QRuntimeWindowSurface::buffer(const QWidget *widget)
-{
- return m_windowSurface->buffer(widget);
-}
-
-QPixmap QRuntimeWindowSurface::grabWidget(const QWidget *widget, const QRect& rectangle) const
-{
- return m_windowSurface->grabWidget(widget, rectangle);
-}
-
-QPoint QRuntimeWindowSurface::offset(const QWidget *widget) const
-{
- return m_windowSurface->offset(widget);
-}
-
-QWindowSurface::WindowSurfaceFeatures QRuntimeWindowSurface::features() const
-{
- return m_windowSurface->features();
-}
-
-QRuntimeGraphicsSystem::QRuntimeGraphicsSystem()
- : m_windowSurfaceDestroyPolicy(DestroyImmediately),
- m_graphicsSystem(0)
-{
- QApplicationPrivate::runtime_graphics_system = true;
-
-#ifdef QT_DEFAULT_RUNTIME_SYSTEM
- m_graphicsSystemName = QLatin1String(QT_DEFAULT_RUNTIME_SYSTEM);
- if (m_graphicsSystemName.isNull())
-#endif
- m_graphicsSystemName = QLatin1String("raster");
-
-#ifdef Q_OS_SYMBIAN
- m_windowSurfaceDestroyPolicy = DestroyAfterFirstFlush;
-#endif
-
- m_graphicsSystem = QGraphicsSystemFactory::create(m_graphicsSystemName);
-
- QApplicationPrivate::graphics_system_name = QLatin1String("runtime");
-}
-
-
-QPixmapData *QRuntimeGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- Q_ASSERT(m_graphicsSystem);
- QPixmapData *data = m_graphicsSystem->createPixmapData(type);
-
- QRuntimePixmapData *rtData = new QRuntimePixmapData(this, type);
- rtData->m_data = data;
- m_pixmapDatas << rtData;
-
- return rtData;
-}
-
-QWindowSurface *QRuntimeGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- Q_ASSERT(m_graphicsSystem);
- QRuntimeWindowSurface *rtSurface = new QRuntimeWindowSurface(this, widget);
- rtSurface->m_windowSurface.reset(m_graphicsSystem->createWindowSurface(widget));
- widget->setWindowSurface(rtSurface);
- m_windowSurfaces << rtSurface;
- return rtSurface;
-}
-
-void QRuntimeGraphicsSystem::setGraphicsSystem(const QString &name)
-{
- if (m_graphicsSystemName == name)
- return;
-#ifdef QT_DEBUG
- qDebug() << "QRuntimeGraphicsSystem::setGraphicsSystem( " << name << " )";
-#endif
- QGraphicsSystem *oldSystem = m_graphicsSystem;
- m_graphicsSystem = QGraphicsSystemFactory::create(name);
- m_graphicsSystemName = name;
-
- Q_ASSERT(m_graphicsSystem);
-
- m_pendingGraphicsSystemName = QString();
-
- for (int i = 0; i < m_pixmapDatas.size(); ++i) {
- QRuntimePixmapData *proxy = m_pixmapDatas.at(i);
- QPixmapData *newData = m_graphicsSystem->createPixmapData(proxy->m_data);
- newData->fromImage(proxy->m_data->toImage(), Qt::NoOpaqueDetection);
- delete proxy->m_data;
- proxy->m_data = newData;
- proxy->readBackInfo();
- }
-
- for (int i = 0; i < m_windowSurfaces.size(); ++i) {
- QRuntimeWindowSurface *proxy = m_windowSurfaces.at(i);
- QWidget *widget = proxy->m_windowSurface->window();
-
- if(m_windowSurfaceDestroyPolicy == DestroyAfterFirstFlush)
- proxy->m_pendingWindowSurface.reset(proxy->m_windowSurface.take());
-
- QWindowSurface *newWindowSurface = m_graphicsSystem->createWindowSurface(widget);
- newWindowSurface->setGeometry(proxy->geometry());
-
- proxy->m_windowSurface.reset(newWindowSurface);
- qt_widget_private(widget)->invalidateBuffer(widget->rect());
- }
-
- delete oldSystem;
-}
-
-void QRuntimeGraphicsSystem::removePixmapData(QRuntimePixmapData *pixmapData) const
-{
- int index = m_pixmapDatas.lastIndexOf(pixmapData);
- m_pixmapDatas.removeAt(index);
-}
-
-void QRuntimeGraphicsSystem::removeWindowSurface(QRuntimeWindowSurface *windowSurface) const
-{
- int index = m_windowSurfaces.lastIndexOf(windowSurface);
- m_windowSurfaces.removeAt(index);
-}
-
-#include "qgraphicssystem_runtime.moc"
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_runtime_p.h b/src/gui/painting/qgraphicssystem_runtime_p.h
deleted file mode 100644
index a3828d44c0..0000000000
--- a/src/gui/painting/qgraphicssystem_runtime_p.h
+++ /dev/null
@@ -1,187 +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 plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_RUNTIME_P_H
-#define QGRAPHICSSYSTEM_RUNTIME_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgraphicssystem_p.h"
-
-#include <private/qpixmapdata_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QRuntimeGraphicsSystem;
-
-class Q_GUI_EXPORT QRuntimePixmapData : public QPixmapData {
-public:
- QRuntimePixmapData(const QRuntimeGraphicsSystem *gs, PixelType type);
- ~QRuntimePixmapData();
-
- virtual QPixmapData *createCompatiblePixmapData() const;
- virtual void resize(int width, int height);
- virtual void fromImage(const QImage &image,
- Qt::ImageConversionFlags flags);
-
- virtual bool fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags);
- virtual bool fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags);
-
- virtual void copy(const QPixmapData *data, const QRect &rect);
- virtual bool scroll(int dx, int dy, const QRect &rect);
-
- virtual int metric(QPaintDevice::PaintDeviceMetric metric) const;
- virtual void fill(const QColor &color);
- virtual QBitmap mask() const;
- virtual void setMask(const QBitmap &mask);
- virtual bool hasAlphaChannel() const;
- virtual QPixmap transformed(const QTransform &matrix,
- Qt::TransformationMode mode) const;
- virtual void setAlphaChannel(const QPixmap &alphaChannel);
- virtual QPixmap alphaChannel() const;
- virtual QImage toImage() const;
- virtual QPaintEngine *paintEngine() const;
-
- virtual QImage *buffer();
-
- void readBackInfo();
-
- QPixmapData *m_data;
-
-#if defined(Q_OS_SYMBIAN)
- void* toNativeType(NativeType type);
- void fromNativeType(void* pixmap, NativeType type);
-#endif
-
- virtual QPixmapData *runtimeData() const;
-
-private:
- const QRuntimeGraphicsSystem *m_graphicsSystem;
-
-};
-
-class QRuntimeWindowSurface : public QWindowSurface {
-public:
- QRuntimeWindowSurface(const QRuntimeGraphicsSystem *gs, QWidget *window);
- ~QRuntimeWindowSurface();
-
- virtual QPaintDevice *paintDevice();
- virtual void flush(QWidget *widget, const QRegion &region,
- const QPoint &offset);
- virtual void setGeometry(const QRect &rect);
-
- virtual bool scroll(const QRegion &area, int dx, int dy);
-
- virtual void beginPaint(const QRegion &);
- virtual void endPaint(const QRegion &);
-
- virtual QImage* buffer(const QWidget *widget);
- virtual QPixmap grabWidget(const QWidget *widget, const QRect& rectangle = QRect()) const;
-
- virtual QPoint offset(const QWidget *widget) const;
-
- virtual WindowSurfaceFeatures features() const;
-
- QScopedPointer<QWindowSurface> m_windowSurface;
- QScopedPointer<QWindowSurface> m_pendingWindowSurface;
-
-private:
- const QRuntimeGraphicsSystem *m_graphicsSystem;
-};
-
-class QRuntimeGraphicsSystem : public QGraphicsSystem
-{
-public:
-
- enum WindowSurfaceDestroyPolicy
- {
- DestroyImmediately,
- DestroyAfterFirstFlush
- };
-
-public:
- QRuntimeGraphicsSystem();
-
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-
- void removePixmapData(QRuntimePixmapData *pixmapData) const;
- void removeWindowSurface(QRuntimeWindowSurface *windowSurface) const;
-
- void setGraphicsSystem(const QString &name);
- QString graphicsSystemName() const { return m_graphicsSystemName; }
-
- void setWindowSurfaceDestroyPolicy(WindowSurfaceDestroyPolicy policy)
- {
- m_windowSurfaceDestroyPolicy = policy;
- }
-
- int windowSurfaceDestroyPolicy() const { return m_windowSurfaceDestroyPolicy; }
-
-
-private:
- int m_windowSurfaceDestroyPolicy;
- QGraphicsSystem *m_graphicsSystem;
- mutable QList<QRuntimePixmapData *> m_pixmapDatas;
- mutable QList<QRuntimeWindowSurface *> m_windowSurfaces;
- QString m_graphicsSystemName;
-
- QString m_pendingGraphicsSystemName;
-
- friend class QRuntimePixmapData;
- friend class QRuntimeWindowSurface;
- friend class QMeeGoGraphicsSystem;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/painting/qgraphicssystemfactory.cpp b/src/gui/painting/qgraphicssystemfactory.cpp
deleted file mode 100644
index 4309140cc4..0000000000
--- a/src/gui/painting/qgraphicssystemfactory.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystemfactory_p.h"
-#include "qgraphicssystemplugin_p.h"
-#include "private/qfactoryloader_p.h"
-#include "qmutex.h"
-
-#include "qapplication.h"
-#include <private/qapplication_p.h>
-#include "qgraphicssystem_raster_p.h"
-#include "qgraphicssystem_runtime_p.h"
-#include "qdebug.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_LIBRARY
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QGraphicsSystemFactoryInterface_iid, QLatin1String("/graphicssystems"), Qt::CaseInsensitive))
-#endif
-
-QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key)
-{
- QGraphicsSystem *ret = 0;
- QString system = key.toLower();
-
-#if defined (QT_GRAPHICSSYSTEM_OPENGL)
- if (system.isEmpty()) {
- system = QLatin1String("opengl");
- }
-#elif defined (QT_GRAPHICSSYSTEM_OPENVG)
- if (system.isEmpty()) {
- system = QLatin1String("openvg");
- }
-#elif defined (QT_GRAPHICSSYSTEM_RUNTIME)
- if (system.isEmpty()) {
- system = QLatin1String("runtime");
- }
-#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11) || (defined (Q_WS_MAC) && defined(QT_MAC_USE_COCOA))
- if (system.isEmpty()) {
- system = QLatin1String("raster");
- }
-#endif
-
- QApplicationPrivate::graphics_system_name = system;
- if (system == QLatin1String("raster"))
- return new QRasterGraphicsSystem;
- else if (system == QLatin1String("runtime"))
- return new QRuntimeGraphicsSystem;
- else if (system.isEmpty() || system == QLatin1String("native"))
- return 0;
-
-#ifndef QT_NO_LIBRARY
- if (!ret) {
- if (QGraphicsSystemFactoryInterface *factory = qobject_cast<QGraphicsSystemFactoryInterface*>(loader()->instance(system)))
- ret = factory->create(system);
- }
-#endif
-
- if (!ret)
- qWarning() << "Unable to load graphicssystem" << system;
-
- return ret;
-}
-
-/*!
- Returns the list of valid keys, i.e. the keys this factory can
- create styles for.
-
- \sa create()
-*/
-QStringList QGraphicsSystemFactory::keys()
-{
-#ifndef QT_NO_LIBRARY
- QStringList list = loader()->keys();
-#else
- QStringList list;
-#endif
- if (!list.contains(QLatin1String("Raster")))
- list << QLatin1String("raster");
- return list;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/gui/painting/qgraphicssystemfactory_p.h b/src/gui/painting/qgraphicssystemfactory_p.h
deleted file mode 100644
index c8e55e049d..0000000000
--- a/src/gui/painting/qgraphicssystemfactory_p.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEMFACTORY_H
-#define QGRAPHICSSYSTEMFACTORY_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 <QtCore/qstringlist.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QGraphicsSystem;
-
-class QGraphicsSystemFactory
-{
-public:
- static QStringList keys();
- static QGraphicsSystem *create(const QString&);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGRAPHICSSYSTEMFACTORY_H
-
diff --git a/src/gui/painting/qgraphicssystemplugin.cpp b/src/gui/painting/qgraphicssystemplugin.cpp
deleted file mode 100644
index 8153b8aa05..0000000000
--- a/src/gui/painting/qgraphicssystemplugin.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystemplugin_p.h"
-#include "qgraphicssystem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QGraphicsSystemPlugin::QGraphicsSystemPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-QGraphicsSystemPlugin::~QGraphicsSystemPlugin()
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystemplugin_p.h b/src/gui/painting/qgraphicssystemplugin_p.h
deleted file mode 100644
index 3d353abe79..0000000000
--- a/src/gui/painting/qgraphicssystemplugin_p.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEMPLUGIN_H
-#define QGRAPHICSSYSTEMPLUGIN_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 <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QGraphicsSystem;
-
-struct QGraphicsSystemFactoryInterface : public QFactoryInterface
-{
- virtual QGraphicsSystem *create(const QString &key) = 0;
-};
-
-#define QGraphicsSystemFactoryInterface_iid "com.trolltech.Qt.QGraphicsSystemFactoryInterface"
-
-Q_DECLARE_INTERFACE(QGraphicsSystemFactoryInterface, QGraphicsSystemFactoryInterface_iid)
-
-class Q_GUI_EXPORT QGraphicsSystemPlugin : public QObject, public QGraphicsSystemFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QGraphicsSystemFactoryInterface:QFactoryInterface)
-public:
- explicit QGraphicsSystemPlugin(QObject *parent = 0);
- ~QGraphicsSystemPlugin();
-
- virtual QStringList keys() const = 0;
- virtual QGraphicsSystem *create(const QString &key) = 0;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGRAPHICSSYSTEMEPLUGIN_H
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index 6209e66a7b..d2c84f0485 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -731,42 +731,6 @@ QPainterPath QMatrix::map(const QPainterPath &path) const
}
/*!
- \fn QRegion QMatrix::mapToRegion(const QRect &rectangle) const
-
- Returns the transformed rectangle \a rectangle as a QRegion
- object. A rectangle which has been rotated or sheared may result
- in a non-rectangular region being returned.
-
- Use the mapToPolygon() or map() function instead.
-*/
-#ifdef QT3_SUPPORT
-QRegion QMatrix::mapToRegion(const QRect &rect) const
-{
- QRegion result;
- if (isIdentity()) {
- result = rect;
- } else if (m12() == 0.0F && m21() == 0.0F) {
- int x = qRound(m11()*rect.x() + dx());
- int y = qRound(m22()*rect.y() + dy());
- int w = qRound(m11()*rect.width());
- int h = qRound(m22()*rect.height());
- if (w < 0) {
- w = -w;
- x -= w - 1;
- }
- if (h < 0) {
- h = -h;
- y -= h - 1;
- }
- result = QRect(x, y, w, h);
- } else {
- result = QRegion(mapToPolygon(rect));
- }
- return result;
-
-}
-#endif
-/*!
\fn QPolygon QMatrix::mapToPolygon(const QRect &rectangle) const
Creates and returns a QPolygon representation of the given \a
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index ff80704387..830a0a734f 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -118,12 +118,6 @@ public:
operator QVariant() const;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT QMatrix invert(bool *invertible=0) const { return inverted(invertible); }
- inline QT3_SUPPORT QRect map(const QRect &r) const { return mapRect(r); }
- QT3_SUPPORT QRegion mapToRegion(const QRect &r) const;
-#endif
-
private:
inline QMatrix(bool)
: _m11(1.)
@@ -193,12 +187,6 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QMatrix &);
Q_GUI_EXPORT QDebug operator<<(QDebug, const QMatrix &);
#endif
-#ifdef QT3_SUPPORT
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <QtGui/qwmatrix.h>
-QT_END_INCLUDE_NAMESPACE
-#endif
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp
index 0ab6674913..857621df6e 100644
--- a/src/gui/painting/qmemrotate.cpp
+++ b/src/gui/painting/qmemrotate.cpp
@@ -512,34 +512,34 @@ inline void qt_memrotate90_template<quint18, quint32>(const quint32 *src,
}
#define QT_IMPL_MEMROTATE(srctype, desttype) \
-void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate90_template(src, w, h, sstride, dest, dstride); \
} \
-void qt_memrotate180(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate180(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate180_template(src, w, h, sstride, dest, dstride); \
} \
-void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate270_template(src, w, h, sstride, dest, dstride); \
}
#define QT_IMPL_SIMPLE_MEMROTATE(srctype, desttype) \
-void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate90_tiled_unpacked<desttype,srctype>(src, w, h, sstride, dest, dstride); \
} \
-void qt_memrotate180(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate180(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate180_template(src, w, h, sstride, dest, dstride); \
} \
-void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate270_tiled_unpacked<desttype,srctype>(src, w, h, sstride, dest, dstride); \
diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp
index 7b3d4add49..fc5cdcdaa5 100644
--- a/src/gui/painting/qpaintdevice.cpp
+++ b/src/gui/painting/qpaintdevice.cpp
@@ -43,8 +43,6 @@
QT_BEGIN_NAMESPACE
-extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp
-
QPaintDevice::QPaintDevice()
{
painters = 0;
@@ -55,7 +53,6 @@ QPaintDevice::~QPaintDevice()
if (paintingActive())
qWarning("QPaintDevice: Cannot destroy paint device that is being "
"painted");
- qt_painter_removePaintDevice(this);
}
@@ -67,6 +64,20 @@ int QPaintDevice::metric(PaintDeviceMetric) const
}
#endif
+void QPaintDevice::init(QPainter *) const
+{
+}
+
+QPaintDevice *QPaintDevice::redirected(QPoint *) const
+{
+ return 0;
+}
+
+QPainter *QPaintDevice::sharedPainter() const
+{
+ return 0;
+}
+
Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric)
{
return device->metric(metric);
diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h
index 3ebc24ee14..0b44990c69 100644
--- a/src/gui/painting/qpaintdevice.h
+++ b/src/gui/painting/qpaintdevice.h
@@ -105,61 +105,22 @@ public:
protected:
QPaintDevice();
virtual int metric(PaintDeviceMetric metric) const;
+ virtual void init(QPainter *painter) const;
+ virtual QPaintDevice *redirected(QPoint *offset) const;
+ virtual QPainter *sharedPainter() const;
ushort painters; // refcount
private:
Q_DISABLE_COPY(QPaintDevice)
-#if defined(Q_WS_X11) && defined(QT3_SUPPORT)
-public:
- QT3_SUPPORT Display *x11Display() const;
- QT3_SUPPORT int x11Screen() const;
- QT3_SUPPORT int x11Depth() const;
- QT3_SUPPORT int x11Cells() const;
- QT3_SUPPORT Qt::HANDLE x11Colormap() const;
- QT3_SUPPORT bool x11DefaultColormap() const;
- QT3_SUPPORT void *x11Visual() const;
- QT3_SUPPORT bool x11DefaultVisual() const;
-
- static QT3_SUPPORT Display *x11AppDisplay();
- static QT3_SUPPORT int x11AppScreen();
- static QT3_SUPPORT int x11AppDepth(int screen = -1);
- static QT3_SUPPORT int x11AppCells(int screen = -1);
- static QT3_SUPPORT Qt::HANDLE x11AppRootWindow(int screen = -1);
- static QT3_SUPPORT Qt::HANDLE x11AppColormap(int screen = -1);
- static QT3_SUPPORT void *x11AppVisual(int screen = -1);
- static QT3_SUPPORT bool x11AppDefaultColormap(int screen =-1);
- static QT3_SUPPORT bool x11AppDefaultVisual(int screen =-1);
- static QT3_SUPPORT int x11AppDpiX(int screen = -1);
- static QT3_SUPPORT int x11AppDpiY(int screen = -1);
- static QT3_SUPPORT void x11SetAppDpiX(int, int);
- static QT3_SUPPORT void x11SetAppDpiY(int, int);
-#endif
-
friend class QPainter;
+ friend class QPainterPrivate;
friend class QFontEngineMac;
friend class QX11PaintEngine;
friend Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, PaintDeviceMetric metric);
};
-#ifdef QT3_SUPPORT
-QT3_SUPPORT Q_GUI_EXPORT
-void bitBlt(QPaintDevice *dst, int dx, int dy,
- const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
- bool ignoreMask=false);
-
-QT3_SUPPORT Q_GUI_EXPORT
-void bitBlt(QPaintDevice *dst, int dx, int dy,
- const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
- int conversion_flags=0);
-
-QT3_SUPPORT Q_GUI_EXPORT
-void bitBlt(QPaintDevice *dst, const QPoint &dp,
- const QPaintDevice *src, const QRect &sr=QRect(0,0,-1,-1),
- bool ignoreMask=false);
-#endif
-
/*****************************************************************************
Inline functions
*****************************************************************************/
diff --git a/src/gui/painting/qpaintdevice_mac.cpp b/src/gui/painting/qpaintdevice_mac.cpp
deleted file mode 100644
index 56cf8dc5a8..0000000000
--- a/src/gui/painting/qpaintdevice_mac.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpaintdevice.h"
-#include "qpainter.h"
-#include "qwidget.h"
-#include "qbitmap.h"
-#include "qapplication.h"
-#include "qprinter.h"
-#include <qdebug.h>
-#include <private/qt_mac_p.h>
-#include <private/qprintengine_mac_p.h>
-#include <private/qpixmap_mac_p.h>
-#include <private/qpixmap_raster_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*****************************************************************************
- Internal variables and functions
- *****************************************************************************/
-
-/*! \internal */
-float qt_mac_defaultDpi_x()
-{
- // Mac OS X currently assumes things to be 72 dpi.
- // (see http://developer.apple.com/releasenotes/GraphicsImaging/RN-ResolutionIndependentUI/)
- // This may need to be re-worked as we go further in the resolution-independence stuff.
- return 72;
-}
-
-/*! \internal */
-float qt_mac_defaultDpi_y()
-{
- // Mac OS X currently assumes things to be 72 dpi.
- // (see http://developer.apple.com/releasenotes/GraphicsImaging/RN-ResolutionIndependentUI/)
- // This may need to be re-worked as we go further in the resolution-independence stuff.
- return 72;
-}
-
-
-/*! \internal
-
- Returns the QuickDraw CGrafPtr of the paint device. 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.
-*/
-
-Q_GUI_EXPORT GrafPtr qt_mac_qd_context(const QPaintDevice *device)
-{
- if (device->devType() == QInternal::Pixmap) {
- return static_cast<GrafPtr>(static_cast<const QPixmap *>(device)->macQDHandle());
- } else if(device->devType() == QInternal::Widget) {
- return static_cast<GrafPtr>(static_cast<const QWidget *>(device)->macQDHandle());
- } else if(device->devType() == QInternal::Printer) {
- QPaintEngine *engine = static_cast<const QPrinter *>(device)->paintEngine();
- return static_cast<GrafPtr>(static_cast<const QMacPrintEngine *>(engine)->handle());
- }
- return 0;
-}
-
-extern CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *pdev);
-
-/*! \internal
-
- Returns the CoreGraphics CGContextRef of the paint device. 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.
-*/
-
-Q_GUI_EXPORT CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
-{
- if (pdev->devType() == QInternal::Pixmap) {
- const QPixmap *pm = static_cast<const QPixmap*>(pdev);
- CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pdev);
- uint flags = kCGImageAlphaPremultipliedFirst;
-#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
- flags |= kCGBitmapByteOrder32Host;
-#endif
- CGContextRef ret = 0;
-
- // It would make sense to put this into a mac #ifdef'ed
- // virtual function in the QPixmapData at some point
- if (pm->data->classId() == QPixmapData::MacClass) {
- const QMacPixmapData *pmData = static_cast<const QMacPixmapData*>(pm->data.data());
- ret = CGBitmapContextCreate(pmData->pixels, pmData->w, pmData->h,
- 8, pmData->bytesPerRow, colorspace,
- flags);
- if(!ret)
- qWarning("QPaintDevice: Unable to create context for pixmap (%d/%d/%d)",
- pmData->w, pmData->h, (pmData->bytesPerRow * pmData->h));
- } else if (pm->data->classId() == QPixmapData::RasterClass) {
- QImage *image = pm->data->buffer();
- ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(),
- 8, image->bytesPerLine(), colorspace, flags);
- }
-
- CGContextTranslateCTM(ret, 0, pm->height());
- CGContextScaleCTM(ret, 1, -1);
- return ret;
- } else if (pdev->devType() == QInternal::Widget) {
- CGContextRef ret = static_cast<CGContextRef>(static_cast<const QWidget *>(pdev)->macCGHandle());
- CGContextRetain(ret);
- return ret;
- } else if (pdev->devType() == QInternal::MacQuartz) {
- return static_cast<const QMacQuartzPaintDevice *>(pdev)->cgContext();
- }
- return 0;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintdevice_qpa.cpp b/src/gui/painting/qpaintdevice_qpa.cpp
index 813965feb1..65eeaaa7e8 100644
--- a/src/gui/painting/qpaintdevice_qpa.cpp
+++ b/src/gui/painting/qpaintdevice_qpa.cpp
@@ -41,14 +41,11 @@
#include "qpaintdevice.h"
#include "qpainter.h"
-#include "qwidget.h"
#include "qbitmap.h"
-#include "qapplication.h"
+#include "qguiapplication.h"
QT_BEGIN_NAMESPACE
-extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp
-
int QPaintDevice::metric(PaintDeviceMetric m) const
{
qWarning("QPaintDevice::metrics: Device has no metric information");
diff --git a/src/gui/painting/qpaintdevice_qws.cpp b/src/gui/painting/qpaintdevice_qws.cpp
deleted file mode 100644
index 9d5ba6e850..0000000000
--- a/src/gui/painting/qpaintdevice_qws.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpaintdevice.h"
-#include "qpainter.h"
-#include "qwidget.h"
-#include "qbitmap.h"
-#include "qapplication.h"
-#include "qwsdisplay_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-QWSDisplay *QPaintDevice::qwsDisplay()
-{
- return qt_fbdpy;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintdevice_win.cpp b/src/gui/painting/qpaintdevice_win.cpp
deleted file mode 100644
index a6d79d8341..0000000000
--- a/src/gui/painting/qpaintdevice_win.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpaintdevice.h"
-#include "qpainter.h"
-#include "qwidget.h"
-#include "qbitmap.h"
-#include "qapplication.h"
-#include <private/qapplication_p.h>
-#include "qt_windows.h"
-#include "qprinter.h"
-
-QT_BEGIN_NAMESPACE
-
-HDC QPaintDevice::getDC() const
-{
- return 0;
-}
-
-void QPaintDevice::releaseDC(HDC) const
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintdevice_x11.cpp b/src/gui/painting/qpaintdevice_x11.cpp
deleted file mode 100644
index 42e61e855b..0000000000
--- a/src/gui/painting/qpaintdevice_x11.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpaintdevice.h"
-#include "qpainter.h"
-#include "qwidget.h"
-#include "qbitmap.h"
-#include "qapplication.h"
-#include <private/qt_x11_p.h>
-#include "qx11info_x11.h"
-
-QT_BEGIN_NAMESPACE
-
-/*! \internal
-
- Returns the X11 Drawable of the paint device. 0 is returned if it
- can't be obtained.
-*/
-
-Drawable Q_GUI_EXPORT qt_x11Handle(const QPaintDevice *pd)
-{
- if (!pd) return 0;
- if (pd->devType() == QInternal::Widget)
- return static_cast<const QWidget *>(pd)->handle();
- else if (pd->devType() == QInternal::Pixmap)
- return static_cast<const QPixmap *>(pd)->handle();
- return 0;
-}
-
-/*!
- \relates QPaintDevice
-
- Returns the QX11Info structure for the \a pd paint device. 0 is
- returned if it can't be obtained.
-*/
-const Q_GUI_EXPORT QX11Info *qt_x11Info(const QPaintDevice *pd)
-{
- if (!pd) return 0;
- if (pd->devType() == QInternal::Widget)
- return &static_cast<const QWidget *>(pd)->x11Info();
- else if (pd->devType() == QInternal::Pixmap)
- return &static_cast<const QPixmap *>(pd)->x11Info();
- return 0;
-}
-
-
-
-#ifdef QT3_SUPPORT
-
-Display *QPaintDevice::x11Display() const
-{
- return X11->display;
-}
-
-int QPaintDevice::x11Screen() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->screen();
- return QX11Info::appScreen();
-}
-
-void *QPaintDevice::x11Visual() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->visual();
- return QX11Info::appVisual();
-}
-
-int QPaintDevice::x11Depth() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->depth();
- return QX11Info::appDepth();
-}
-
-int QPaintDevice::x11Cells() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->cells();
- return QX11Info::appCells();
-}
-
-Qt::HANDLE QPaintDevice::x11Colormap() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->colormap();
- return QX11Info::appColormap();
-}
-
-bool QPaintDevice::x11DefaultColormap() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->defaultColormap();
- return QX11Info::appDefaultColormap();
-}
-
-bool QPaintDevice::x11DefaultVisual() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->defaultVisual();
- return QX11Info::appDefaultVisual();
-}
-
-void *QPaintDevice::x11AppVisual(int screen)
-{ return QX11Info::appVisual(screen); }
-
-Qt::HANDLE QPaintDevice::x11AppColormap(int screen)
-{ return QX11Info::appColormap(screen); }
-
-Display *QPaintDevice::x11AppDisplay()
-{ return QX11Info::display(); }
-
-int QPaintDevice::x11AppScreen()
-{ return QX11Info::appScreen(); }
-
-int QPaintDevice::x11AppDepth(int screen)
-{ return QX11Info::appDepth(screen); }
-
-int QPaintDevice::x11AppCells(int screen)
-{ return QX11Info::appCells(screen); }
-
-Qt::HANDLE QPaintDevice::x11AppRootWindow(int screen)
-{ return QX11Info::appRootWindow(screen); }
-
-bool QPaintDevice::x11AppDefaultColormap(int screen)
-{ return QX11Info::appDefaultColormap(screen); }
-
-bool QPaintDevice::x11AppDefaultVisual(int screen)
-{ return QX11Info::appDefaultVisual(screen); }
-
-void QPaintDevice::x11SetAppDpiX(int dpi, int screen)
-{
- QX11Info::setAppDpiX(dpi, screen);
-}
-
-void QPaintDevice::x11SetAppDpiY(int dpi, int screen)
-{
- QX11Info::setAppDpiY(dpi, screen);
-}
-
-int QPaintDevice::x11AppDpiX(int screen)
-{
- return QX11Info::appDpiX(screen);
-}
-
-int QPaintDevice::x11AppDpiY(int screen)
-{
- return QX11Info::appDpiY(screen);
-}
-#endif
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp
index c46513a07c..c8870cd5d3 100644
--- a/src/gui/painting/qpaintengine.cpp
+++ b/src/gui/painting/qpaintengine.cpp
@@ -43,9 +43,9 @@
#include "qpainter_p.h"
#include "qpolygon.h"
#include "qbitmap.h"
-#include "qapplication.h"
#include <qdebug.h>
#include <qmath.h>
+#include <qguiapplication.h>
#include <private/qtextengine_p.h>
#include <qvarlengtharray.h>
#include <private/qfontengine_p.h>
@@ -139,7 +139,7 @@ QString QTextItem::text() const
QFont QTextItem::font() const
{
const QTextItemInt *ti = static_cast<const QTextItemInt *>(this);
- return ti->f ? *ti->f : QApplication::font();
+ return ti->f ? *ti->f : QGuiApplication::font();
}
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp
index 75efa20804..f8bc3f1c9e 100644
--- a/src/gui/painting/qpaintengine_blitter.cpp
+++ b/src/gui/painting/qpaintengine_blitter.cpp
@@ -44,7 +44,6 @@
#include "private/qblittable_p.h"
#include "private/qpaintengine_raster_p.h"
#include "private/qpainter_p.h"
-#include "private/qapplication_p.h"
#include "private/qpixmap_blitter_p.h"
#ifndef QT_NO_BLITTABLE
diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp
deleted file mode 100644
index 802c455ab8..0000000000
--- a/src/gui/painting/qpaintengine_mac.cpp
+++ /dev/null
@@ -1,1752 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qbitmap.h>
-#include <qpaintdevice.h>
-#include <private/qpaintengine_mac_p.h>
-#include <qpainterpath.h>
-#include <qpixmapcache.h>
-#include <private/qpaintengine_raster_p.h>
-#include <private/qprintengine_mac_p.h>
-#include <qprinter.h>
-#include <qstack.h>
-#include <qtextcodec.h>
-#include <qwidget.h>
-#include <qvarlengtharray.h>
-#include <qdebug.h>
-#include <qcoreapplication.h>
-#include <qmath.h>
-
-#include <private/qfont_p.h>
-#include <private/qfontengine_p.h>
-#include <private/qfontengine_coretext_p.h>
-#include <private/qfontengine_mac_p.h>
-#include <private/qnumeric_p.h>
-#include <private/qpainter_p.h>
-#include <private/qpainterpath_p.h>
-#include <private/qpixmap_mac_p.h>
-#include <private/qt_mac_p.h>
-#include <private/qtextengine_p.h>
-#include <private/qwidget_p.h>
-#include <private/qt_cocoa_helpers_mac_p.h>
-
-#include <string.h>
-
-QT_BEGIN_NAMESPACE
-
-extern int qt_antialiasing_threshold; // QApplication.cpp
-
-/*****************************************************************************
- External functions
- *****************************************************************************/
-extern CGImageRef qt_mac_create_imagemask(const QPixmap &px, const QRectF &sr); //qpixmap_mac.cpp
-extern QPoint qt_mac_posInWindow(const QWidget *w); //qwidget_mac.cpp
-extern OSWindowRef qt_mac_window_for(const QWidget *); //qwidget_mac.cpp
-extern CGContextRef qt_mac_cg_context(const QPaintDevice *); //qpaintdevice_mac.cpp
-extern void qt_mac_dispose_rgn(RgnHandle r); //qregion_mac.cpp
-extern QPixmap qt_pixmapForBrush(int, bool); //qbrush.cpp
-
-void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform);
-
-
-//Implemented for qt_mac_p.h
-QMacCGContext::QMacCGContext(QPainter *p)
-{
- QPaintEngine *pe = p->paintEngine();
- if (pe->type() == QPaintEngine::MacPrinter)
- pe = static_cast<QMacPrintEngine*>(pe)->paintEngine();
- pe->syncState();
- context = 0;
- if(pe->type() == QPaintEngine::CoreGraphics)
- context = static_cast<QCoreGraphicsPaintEngine*>(pe)->handle();
-
- int devType = p->device()->devType();
- if (pe->type() == QPaintEngine::Raster
- && (devType == QInternal::Widget ||
- devType == QInternal::Pixmap ||
- devType == QInternal::Image)) {
-
- extern CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice);
- CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pe->paintDevice());
- uint flags = kCGImageAlphaPremultipliedFirst;
-#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
- flags |= kCGBitmapByteOrder32Host;
-#endif
- const QImage *image = (const QImage *) pe->paintDevice();
-
- context = CGBitmapContextCreate((void *) image->bits(), image->width(), image->height(),
- 8, image->bytesPerLine(), colorspace, flags);
-
- CGContextTranslateCTM(context, 0, image->height());
- CGContextScaleCTM(context, 1, -1);
-
- if (devType == QInternal::Widget) {
- QRegion clip = p->paintEngine()->systemClip();
- QTransform native = p->deviceTransform();
- QTransform logical = p->combinedTransform();
-
- if (p->hasClipping()) {
- QRegion r = p->clipRegion();
- r.translate(native.dx(), native.dy());
- if (clip.isEmpty())
- clip = r;
- else
- clip &= r;
- }
- qt_mac_clip_cg(context, clip, 0);
-
- CGContextTranslateCTM(context, native.dx(), native.dy());
- }
- } else {
- CGContextRetain(context);
- }
-}
-
-
-/*****************************************************************************
- QCoreGraphicsPaintEngine utility functions
- *****************************************************************************/
-
-//conversion
-inline static float qt_mac_convert_color_to_cg(int c) { return ((float)c * 1000 / 255) / 1000; }
-inline static int qt_mac_convert_color_from_cg(float c) { return qRound(c * 255); }
-CGAffineTransform qt_mac_convert_transform_to_cg(const QTransform &t) {
- return CGAffineTransformMake(t.m11(), t.m12(), t.m21(), t.m22(), t.dx(), t.dy());
-}
-
-CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice)
-{
- bool isWidget = (paintDevice->devType() == QInternal::Widget);
- return QCoreGraphicsPaintEngine::macDisplayColorSpace(isWidget ? static_cast<const QWidget *>(paintDevice)
- : 0);
-}
-
-inline static QCFType<CGColorRef> cgColorForQColor(const QColor &col, QPaintDevice *pdev)
-{
- CGFloat components[] = {
- qt_mac_convert_color_to_cg(col.red()),
- qt_mac_convert_color_to_cg(col.green()),
- qt_mac_convert_color_to_cg(col.blue()),
- qt_mac_convert_color_to_cg(col.alpha())
- };
- return CGColorCreate(qt_mac_colorSpaceForDeviceType(pdev), components);
-}
-
-// There's architectural problems with using native gradients
-// on the Mac at the moment, so disable them.
-// #define QT_MAC_USE_NATIVE_GRADIENTS
-
-#ifdef QT_MAC_USE_NATIVE_GRADIENTS
-static bool drawGradientNatively(const QGradient *gradient)
-{
- return gradient->spread() == QGradient::PadSpread;
-}
-
-// gradiant callback
-static void qt_mac_color_gradient_function(void *info, const CGFloat *in, CGFloat *out)
-{
- QBrush *brush = static_cast<QBrush *>(info);
- Q_ASSERT(brush && brush->gradient());
-
- const QGradientStops stops = brush->gradient()->stops();
- const int n = stops.count();
- Q_ASSERT(n >= 1);
- const QGradientStop *begin = stops.constBegin();
- const QGradientStop *end = begin + n;
-
- qreal p = in[0];
- const QGradientStop *i = begin;
- while (i != end && i->first < p)
- ++i;
-
- QRgb c;
- if (i == begin) {
- c = begin->second.rgba();
- } else if (i == end) {
- c = (end - 1)->second.rgba();
- } else {
- const QGradientStop &s1 = *(i - 1);
- const QGradientStop &s2 = *i;
- qreal p1 = s1.first;
- qreal p2 = s2.first;
- QRgb c1 = s1.second.rgba();
- QRgb c2 = s2.second.rgba();
- int idist = 256 * (p - p1) / (p2 - p1);
- int dist = 256 - idist;
- c = qRgba(INTERPOLATE_PIXEL_256(qRed(c1), dist, qRed(c2), idist),
- INTERPOLATE_PIXEL_256(qGreen(c1), dist, qGreen(c2), idist),
- INTERPOLATE_PIXEL_256(qBlue(c1), dist, qBlue(c2), idist),
- INTERPOLATE_PIXEL_256(qAlpha(c1), dist, qAlpha(c2), idist));
- }
-
- out[0] = qt_mac_convert_color_to_cg(qRed(c));
- out[1] = qt_mac_convert_color_to_cg(qGreen(c));
- out[2] = qt_mac_convert_color_to_cg(qBlue(c));
- out[3] = qt_mac_convert_color_to_cg(qAlpha(c));
-}
-#endif
-
-//clipping handling
-void QCoreGraphicsPaintEnginePrivate::resetClip()
-{
- static bool inReset = false;
- if (inReset)
- return;
- inReset = true;
-
- CGAffineTransform old_xform = CGContextGetCTM(hd);
-
- //setup xforms
- CGContextConcatCTM(hd, CGAffineTransformInvert(old_xform));
- while (stackCount > 0) {
- restoreGraphicsState();
- }
- saveGraphicsState();
- inReset = false;
- //reset xforms
- CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd)));
- CGContextConcatCTM(hd, old_xform);
-}
-
-static CGRect qt_mac_compose_rect(const QRectF &r, float off=0)
-{
- return CGRectMake(r.x()+off, r.y()+off, r.width(), r.height());
-}
-
-static CGMutablePathRef qt_mac_compose_path(const QPainterPath &p, float off=0)
-{
- CGMutablePathRef ret = CGPathCreateMutable();
- QPointF startPt;
- for (int i=0; i<p.elementCount(); ++i) {
- const QPainterPath::Element &elm = p.elementAt(i);
- switch (elm.type) {
- case QPainterPath::MoveToElement:
- if(i > 0
- && p.elementAt(i - 1).x == startPt.x()
- && p.elementAt(i - 1).y == startPt.y())
- CGPathCloseSubpath(ret);
- startPt = QPointF(elm.x, elm.y);
- CGPathMoveToPoint(ret, 0, elm.x+off, elm.y+off);
- break;
- case QPainterPath::LineToElement:
- CGPathAddLineToPoint(ret, 0, elm.x+off, elm.y+off);
- break;
- case QPainterPath::CurveToElement:
- Q_ASSERT(p.elementAt(i+1).type == QPainterPath::CurveToDataElement);
- Q_ASSERT(p.elementAt(i+2).type == QPainterPath::CurveToDataElement);
- CGPathAddCurveToPoint(ret, 0,
- elm.x+off, elm.y+off,
- p.elementAt(i+1).x+off, p.elementAt(i+1).y+off,
- p.elementAt(i+2).x+off, p.elementAt(i+2).y+off);
- i+=2;
- break;
- default:
- qFatal("QCoreGraphicsPaintEngine::drawPath(), unhandled type: %d", elm.type);
- break;
- }
- }
- if(!p.isEmpty()
- && p.elementAt(p.elementCount() - 1).x == startPt.x()
- && p.elementAt(p.elementCount() - 1).y == startPt.y())
- CGPathCloseSubpath(ret);
- return ret;
-}
-
-CGColorSpaceRef QCoreGraphicsPaintEngine::m_genericColorSpace = 0;
-QHash<CGDirectDisplayID, CGColorSpaceRef> QCoreGraphicsPaintEngine::m_displayColorSpaceHash;
-bool QCoreGraphicsPaintEngine::m_postRoutineRegistered = false;
-
-CGColorSpaceRef QCoreGraphicsPaintEngine::macGenericColorSpace()
-{
-#if 0
- if (!m_genericColorSpace) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
- m_genericColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
- } else
-#endif
- {
- m_genericColorSpace = CGColorSpaceCreateDeviceRGB();
- }
- if (!m_postRoutineRegistered) {
- m_postRoutineRegistered = true;
- qAddPostRoutine(QCoreGraphicsPaintEngine::cleanUpMacColorSpaces);
- }
- }
- return m_genericColorSpace;
-#else
- // Just return the main display colorspace for the moment.
- return macDisplayColorSpace();
-#endif
-}
-
-/*
- Ideally, we should pass the widget in here, and use CGGetDisplaysWithRect() etc.
- to support multiple displays correctly.
-*/
-CGColorSpaceRef QCoreGraphicsPaintEngine::macDisplayColorSpace(const QWidget *widget)
-{
- CGColorSpaceRef colorSpace;
-
- CGDirectDisplayID displayID;
- CMProfileRef displayProfile = 0;
- if (widget == 0) {
- displayID = CGMainDisplayID();
- } else {
- const QRect &qrect = widget->window()->geometry();
- CGRect rect = CGRectMake(qrect.x(), qrect.y(), qrect.width(), qrect.height());
- CGDisplayCount throwAway;
- CGDisplayErr dErr = CGGetDisplaysWithRect(rect, 1, &displayID, &throwAway);
- if (dErr != kCGErrorSuccess)
- return macDisplayColorSpace(0); // fall back on main display
- }
- if ((colorSpace = m_displayColorSpaceHash.value(displayID)))
- return colorSpace;
-
- CMError err = CMGetProfileByAVID((CMDisplayIDType)displayID, &displayProfile);
- if (err == noErr) {
- colorSpace = CGColorSpaceCreateWithPlatformColorSpace(displayProfile);
- } else if (widget) {
- return macDisplayColorSpace(0); // fall back on main display
- }
-
- if (colorSpace == 0)
- colorSpace = CGColorSpaceCreateDeviceRGB();
-
- m_displayColorSpaceHash.insert(displayID, colorSpace);
- CMCloseProfile(displayProfile);
- if (!m_postRoutineRegistered) {
- m_postRoutineRegistered = true;
- qAddPostRoutine(QCoreGraphicsPaintEngine::cleanUpMacColorSpaces);
- }
- return colorSpace;
-}
-
-void QCoreGraphicsPaintEngine::cleanUpMacColorSpaces()
-{
- if (m_genericColorSpace) {
- CFRelease(m_genericColorSpace);
- m_genericColorSpace = 0;
- }
- QHash<CGDirectDisplayID, CGColorSpaceRef>::const_iterator it = m_displayColorSpaceHash.constBegin();
- while (it != m_displayColorSpaceHash.constEnd()) {
- if (it.value())
- CFRelease(it.value());
- ++it;
- }
- m_displayColorSpaceHash.clear();
-}
-
-void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform)
-{
- CGAffineTransform old_xform = CGAffineTransformIdentity;
- if(orig_xform) { //setup xforms
- old_xform = CGContextGetCTM(hd);
- CGContextConcatCTM(hd, CGAffineTransformInvert(old_xform));
- CGContextConcatCTM(hd, *orig_xform);
- }
-
- //do the clipping
- CGContextBeginPath(hd);
- if(rgn.isEmpty()) {
- CGContextAddRect(hd, CGRectMake(0, 0, 0, 0));
- } else {
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
- QCFType<HIMutableShapeRef> shape = rgn.toHIMutableShape();
- Q_ASSERT(!HIShapeIsEmpty(shape));
- HIShapeReplacePathInCGContext(shape, hd);
- } else
-#endif
- {
- QVector<QRect> rects = rgn.rects();
- const int count = rects.size();
- for(int i = 0; i < count; i++) {
- const QRect &r = rects[i];
- CGRect mac_r = CGRectMake(r.x(), r.y(), r.width(), r.height());
- CGContextAddRect(hd, mac_r);
- }
- }
-
- }
- CGContextClip(hd);
-
- if(orig_xform) {//reset xforms
- CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd)));
- CGContextConcatCTM(hd, old_xform);
- }
-}
-
-
-//pattern handling (tiling)
-#if 1
-# define QMACPATTERN_MASK_MULTIPLIER 32
-#else
-# define QMACPATTERN_MASK_MULTIPLIER 1
-#endif
-class QMacPattern
-{
-public:
- QMacPattern() : as_mask(false), pdev(0), image(0) { data.bytes = 0; }
- ~QMacPattern() { CGImageRelease(image); }
- int width() {
- if(image)
- return CGImageGetWidth(image);
- if(data.bytes)
- return 8*QMACPATTERN_MASK_MULTIPLIER;
- return data.pixmap.width();
- }
- int height() {
- if(image)
- return CGImageGetHeight(image);
- if(data.bytes)
- return 8*QMACPATTERN_MASK_MULTIPLIER;
- return data.pixmap.height();
- }
-
- //input
- QColor foreground;
- bool as_mask;
- struct {
- QPixmap pixmap;
- const uchar *bytes;
- } data;
- QPaintDevice *pdev;
- //output
- CGImageRef image;
-};
-static void qt_mac_draw_pattern(void *info, CGContextRef c)
-{
- QMacPattern *pat = (QMacPattern*)info;
- int w = 0, h = 0;
- bool isBitmap = (pat->data.pixmap.depth() == 1);
- if(!pat->image) { //lazy cache
- if(pat->as_mask) {
- Q_ASSERT(pat->data.bytes);
- w = h = 8;
-#if (QMACPATTERN_MASK_MULTIPLIER == 1)
- CGDataProviderRef provider = CGDataProviderCreateWithData(0, pat->data.bytes, w*h, 0);
- pat->image = CGImageMaskCreate(w, h, 1, 1, 1, provider, 0, false);
- CGDataProviderRelease(provider);
-#else
- const int numBytes = (w*h)/sizeof(uchar);
- uchar xor_bytes[numBytes];
- for(int i = 0; i < numBytes; ++i)
- xor_bytes[i] = pat->data.bytes[i] ^ 0xFF;
- CGDataProviderRef provider = CGDataProviderCreateWithData(0, xor_bytes, w*h, 0);
- CGImageRef swatch = CGImageMaskCreate(w, h, 1, 1, 1, provider, 0, false);
- CGDataProviderRelease(provider);
-
- const QColor c0(0, 0, 0, 0), c1(255, 255, 255, 255);
- QPixmap pm(w*QMACPATTERN_MASK_MULTIPLIER, h*QMACPATTERN_MASK_MULTIPLIER);
- pm.fill(c0);
- CGContextRef pm_ctx = qt_mac_cg_context(&pm);
- CGContextSetFillColorWithColor(c, cgColorForQColor(c1, pat->pdev));
- CGRect rect = CGRectMake(0, 0, w, h);
- for(int x = 0; x < QMACPATTERN_MASK_MULTIPLIER; ++x) {
- rect.origin.x = x * w;
- for(int y = 0; y < QMACPATTERN_MASK_MULTIPLIER; ++y) {
- rect.origin.y = y * h;
- qt_mac_drawCGImage(pm_ctx, &rect, swatch);
- }
- }
- pat->image = qt_mac_create_imagemask(pm, pm.rect());
- CGImageRelease(swatch);
- CGContextRelease(pm_ctx);
- w *= QMACPATTERN_MASK_MULTIPLIER;
- h *= QMACPATTERN_MASK_MULTIPLIER;
-#endif
- } else {
- w = pat->data.pixmap.width();
- h = pat->data.pixmap.height();
- if (isBitmap)
- pat->image = qt_mac_create_imagemask(pat->data.pixmap, pat->data.pixmap.rect());
- else
- pat->image = (CGImageRef)pat->data.pixmap.macCGHandle();
- }
- } else {
- w = CGImageGetWidth(pat->image);
- h = CGImageGetHeight(pat->image);
- }
-
- //draw
- bool needRestore = false;
- if (CGImageIsMask(pat->image)) {
- CGContextSaveGState(c);
- CGContextSetFillColorWithColor(c, cgColorForQColor(pat->foreground, pat->pdev));
- }
- CGRect rect = CGRectMake(0, 0, w, h);
- qt_mac_drawCGImage(c, &rect, pat->image);
- if(needRestore)
- CGContextRestoreGState(c);
-}
-static void qt_mac_dispose_pattern(void *info)
-{
- QMacPattern *pat = (QMacPattern*)info;
- delete pat;
-}
-
-/*****************************************************************************
- QCoreGraphicsPaintEngine member functions
- *****************************************************************************/
-
-inline static QPaintEngine::PaintEngineFeatures qt_mac_cg_features()
-{
- return QPaintEngine::PaintEngineFeatures(QPaintEngine::AllFeatures & ~QPaintEngine::PaintOutsidePaintEvent
- & ~QPaintEngine::PerspectiveTransform
- & ~QPaintEngine::ConicalGradientFill
- & ~QPaintEngine::LinearGradientFill
- & ~QPaintEngine::RadialGradientFill
- & ~QPaintEngine::BrushStroke);
-}
-
-QCoreGraphicsPaintEngine::QCoreGraphicsPaintEngine()
-: QPaintEngine(*(new QCoreGraphicsPaintEnginePrivate), qt_mac_cg_features())
-{
-}
-
-QCoreGraphicsPaintEngine::QCoreGraphicsPaintEngine(QPaintEnginePrivate &dptr)
-: QPaintEngine(dptr, qt_mac_cg_features())
-{
-}
-
-QCoreGraphicsPaintEngine::~QCoreGraphicsPaintEngine()
-{
-}
-
-bool
-QCoreGraphicsPaintEngine::begin(QPaintDevice *pdev)
-{
- Q_D(QCoreGraphicsPaintEngine);
- if(isActive()) { // already active painting
- qWarning("QCoreGraphicsPaintEngine::begin: Painter already active");
- return false;
- }
-
- //initialization
- d->pdev = pdev;
- d->complexXForm = false;
- d->cosmeticPen = QCoreGraphicsPaintEnginePrivate::CosmeticSetPenWidth;
- d->cosmeticPenSize = 1;
- d->current.clipEnabled = false;
- d->pixelSize = QPoint(1,1);
- d->hd = qt_mac_cg_context(pdev);
- if(d->hd) {
- d->saveGraphicsState();
- d->orig_xform = CGContextGetCTM(d->hd);
- if (d->shading) {
- CGShadingRelease(d->shading);
- d->shading = 0;
- }
- d->setClip(0); //clear the context's clipping
- }
-
- setActive(true);
-
- if(d->pdev->devType() == QInternal::Widget) { // device is a widget
- QWidget *w = (QWidget*)d->pdev;
- bool unclipped = w->testAttribute(Qt::WA_PaintUnclipped);
-
- if((w->windowType() == Qt::Desktop)) {
- if(!unclipped)
- qWarning("QCoreGraphicsPaintEngine::begin: Does not support clipped desktop on Mac OS X");
- // ## need to do [qt_mac_window_for(w) makeKeyAndOrderFront]; (need to rename the file)
- } else if(unclipped) {
- qWarning("QCoreGraphicsPaintEngine::begin: Does not support unclipped painting");
- }
- } else if(d->pdev->devType() == QInternal::Pixmap) { // device is a pixmap
- QPixmap *pm = (QPixmap*)d->pdev;
- if(pm->isNull()) {
- qWarning("QCoreGraphicsPaintEngine::begin: Cannot paint null pixmap");
- end();
- return false;
- }
- }
-
- setDirty(QPaintEngine::DirtyPen);
- setDirty(QPaintEngine::DirtyBrush);
- setDirty(QPaintEngine::DirtyBackground);
- setDirty(QPaintEngine::DirtyHints);
- return true;
-}
-
-bool
-QCoreGraphicsPaintEngine::end()
-{
- Q_D(QCoreGraphicsPaintEngine);
- setActive(false);
- if(d->pdev->devType() == QInternal::Widget && static_cast<QWidget*>(d->pdev)->windowType() == Qt::Desktop) {
-#ifndef QT_MAC_USE_COCOA
- HideWindow(qt_mac_window_for(static_cast<QWidget*>(d->pdev)));
-#else
-// // ### need to do [qt_mac_window_for(static_cast<QWidget *>(d->pdev)) orderOut]; (need to rename)
-#endif
-
- }
- if(d->shading) {
- CGShadingRelease(d->shading);
- d->shading = 0;
- }
- d->pdev = 0;
- if(d->hd) {
- d->restoreGraphicsState();
- CGContextSynchronize(d->hd);
- CGContextRelease(d->hd);
- d->hd = 0;
- }
- return true;
-}
-
-void
-QCoreGraphicsPaintEngine::updateState(const QPaintEngineState &state)
-{
- Q_D(QCoreGraphicsPaintEngine);
- QPaintEngine::DirtyFlags flags = state.state();
-
- if (flags & DirtyTransform)
- updateMatrix(state.transform());
-
- if (flags & DirtyClipEnabled) {
- if (state.isClipEnabled())
- updateClipPath(painter()->clipPath(), Qt::ReplaceClip);
- else
- updateClipPath(QPainterPath(), Qt::NoClip);
- }
-
- if (flags & DirtyClipPath) {
- updateClipPath(state.clipPath(), state.clipOperation());
- } else if (flags & DirtyClipRegion) {
- updateClipRegion(state.clipRegion(), state.clipOperation());
- }
-
- // If the clip has changed we need to update all other states
- // too, since they are included in the system context on OSX,
- // and changing the clip resets that context back to scratch.
- if (flags & (DirtyClipPath | DirtyClipRegion | DirtyClipEnabled))
- flags |= AllDirty;
-
- if (flags & DirtyPen)
- updatePen(state.pen());
- if (flags & (DirtyBrush|DirtyBrushOrigin))
- updateBrush(state.brush(), state.brushOrigin());
- if (flags & DirtyFont)
- updateFont(state.font());
- if (flags & DirtyOpacity)
- updateOpacity(state.opacity());
- if (flags & DirtyHints)
- updateRenderHints(state.renderHints());
- if (flags & DirtyCompositionMode)
- updateCompositionMode(state.compositionMode());
-
- if (flags & (DirtyPen | DirtyTransform)) {
- if (!d->current.pen.isCosmetic()) {
- d->cosmeticPen = QCoreGraphicsPaintEnginePrivate::CosmeticNone;
- } else if (d->current.transform.m11() < d->current.transform.m22()-1.0 ||
- d->current.transform.m11() > d->current.transform.m22()+1.0) {
- d->cosmeticPen = QCoreGraphicsPaintEnginePrivate::CosmeticTransformPath;
- d->cosmeticPenSize = d->adjustPenWidth(d->current.pen.widthF());
- if (!d->cosmeticPenSize)
- d->cosmeticPenSize = 1.0;
- } else {
- d->cosmeticPen = QCoreGraphicsPaintEnginePrivate::CosmeticSetPenWidth;
- static const float sqrt2 = sqrt(2);
- qreal width = d->current.pen.widthF();
- if (!width)
- width = 1;
- d->cosmeticPenSize = sqrt(pow(d->pixelSize.y(), 2) + pow(d->pixelSize.x(), 2)) / sqrt2 * width;
- }
- }
-}
-
-void
-QCoreGraphicsPaintEngine::updatePen(const QPen &pen)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
- d->current.pen = pen;
- d->setStrokePen(pen);
-}
-
-void
-QCoreGraphicsPaintEngine::updateBrush(const QBrush &brush, const QPointF &brushOrigin)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
- d->current.brush = brush;
-
-#ifdef QT_MAC_USE_NATIVE_GRADIENTS
- // Quartz supports only pad spread
- if (const QGradient *gradient = brush.gradient()) {
- if (drawGradientNatively(gradient)) {
- gccaps |= QPaintEngine::LinearGradientFill | QPaintEngine::RadialGradientFill;
- } else {
- gccaps &= ~(QPaintEngine::LinearGradientFill | QPaintEngine::RadialGradientFill);
- }
- }
-#endif
-
- if (d->shading) {
- CGShadingRelease(d->shading);
- d->shading = 0;
- }
- d->setFillBrush(brushOrigin);
-}
-
-void
-QCoreGraphicsPaintEngine::updateOpacity(qreal opacity)
-{
- Q_D(QCoreGraphicsPaintEngine);
- CGContextSetAlpha(d->hd, opacity);
-}
-
-void
-QCoreGraphicsPaintEngine::updateFont(const QFont &)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
- updatePen(d->current.pen);
-}
-
-void
-QCoreGraphicsPaintEngine::updateMatrix(const QTransform &transform)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
-
- if (qt_is_nan(transform.m11()) || qt_is_nan(transform.m12()) || qt_is_nan(transform.m13())
- || qt_is_nan(transform.m21()) || qt_is_nan(transform.m22()) || qt_is_nan(transform.m23())
- || qt_is_nan(transform.m31()) || qt_is_nan(transform.m32()) || qt_is_nan(transform.m33()))
- return;
-
- d->current.transform = transform;
- d->setTransform(transform.isIdentity() ? 0 : &transform);
- d->complexXForm = (transform.m11() != 1 || transform.m22() != 1
- || transform.m12() != 0 || transform.m21() != 0);
- d->pixelSize = d->devicePixelSize(d->hd);
-}
-
-void
-QCoreGraphicsPaintEngine::updateClipPath(const QPainterPath &p, Qt::ClipOperation op)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
- if(op == Qt::NoClip) {
- if(d->current.clipEnabled) {
- d->current.clipEnabled = false;
- d->current.clip = QRegion();
- d->setClip(0);
- }
- } else {
- if(!d->current.clipEnabled)
- op = Qt::ReplaceClip;
- d->current.clipEnabled = true;
- QRegion clipRegion(p.toFillPolygon().toPolygon(), p.fillRule());
- if(op == Qt::ReplaceClip) {
- d->current.clip = clipRegion;
- d->setClip(0);
- if(p.isEmpty()) {
- CGRect rect = CGRectMake(0, 0, 0, 0);
- CGContextClipToRect(d->hd, rect);
- } else {
- CGMutablePathRef path = qt_mac_compose_path(p);
- CGContextBeginPath(d->hd);
- CGContextAddPath(d->hd, path);
- if(p.fillRule() == Qt::WindingFill)
- CGContextClip(d->hd);
- else
- CGContextEOClip(d->hd);
- CGPathRelease(path);
- }
- } else if(op == Qt::IntersectClip) {
- d->current.clip = d->current.clip.intersected(clipRegion);
- d->setClip(&d->current.clip);
- } else if(op == Qt::UniteClip) {
- d->current.clip = d->current.clip.united(clipRegion);
- d->setClip(&d->current.clip);
- }
- }
-}
-
-void
-QCoreGraphicsPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOperation op)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
- if(op == Qt::NoClip) {
- d->current.clipEnabled = false;
- d->current.clip = QRegion();
- d->setClip(0);
- } else {
- if(!d->current.clipEnabled)
- op = Qt::ReplaceClip;
- d->current.clipEnabled = true;
- if(op == Qt::IntersectClip)
- d->current.clip = d->current.clip.intersected(clipRegion);
- else if(op == Qt::ReplaceClip)
- d->current.clip = clipRegion;
- else if(op == Qt::UniteClip)
- d->current.clip = d->current.clip.united(clipRegion);
- d->setClip(&d->current.clip);
- }
-}
-
-void
-QCoreGraphicsPaintEngine::drawPath(const QPainterPath &p)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
-
- if (state->compositionMode() == QPainter::CompositionMode_Destination)
- return;
-
- CGMutablePathRef path = qt_mac_compose_path(p);
- uchar ops = QCoreGraphicsPaintEnginePrivate::CGStroke;
- if(p.fillRule() == Qt::WindingFill)
- ops |= QCoreGraphicsPaintEnginePrivate::CGFill;
- else
- ops |= QCoreGraphicsPaintEnginePrivate::CGEOFill;
- CGContextBeginPath(d->hd);
- d->drawPath(ops, path);
- CGPathRelease(path);
-}
-
-void
-QCoreGraphicsPaintEngine::drawRects(const QRectF *rects, int rectCount)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
-
- if (state->compositionMode() == QPainter::CompositionMode_Destination)
- return;
-
- for (int i=0; i<rectCount; ++i) {
- QRectF r = rects[i];
-
- CGMutablePathRef path = CGPathCreateMutable();
- CGPathAddRect(path, 0, qt_mac_compose_rect(r));
- d->drawPath(QCoreGraphicsPaintEnginePrivate::CGFill|QCoreGraphicsPaintEnginePrivate::CGStroke,
- path);
- CGPathRelease(path);
- }
-}
-
-void
-QCoreGraphicsPaintEngine::drawPoints(const QPointF *points, int pointCount)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
-
- if (state->compositionMode() == QPainter::CompositionMode_Destination)
- return;
-
- if (d->current.pen.capStyle() == Qt::FlatCap)
- CGContextSetLineCap(d->hd, kCGLineCapSquare);
-
- CGMutablePathRef path = CGPathCreateMutable();
- for(int i=0; i < pointCount; i++) {
- float x = points[i].x(), y = points[i].y();
- CGPathMoveToPoint(path, 0, x, y);
- CGPathAddLineToPoint(path, 0, x+0.001, y);
- }
-
- bool doRestore = false;
- if(d->cosmeticPen == QCoreGraphicsPaintEnginePrivate::CosmeticNone && !(state->renderHints() & QPainter::Antialiasing)) {
- //we don't want adjusted pens for point rendering
- doRestore = true;
- d->saveGraphicsState();
- CGContextSetLineWidth(d->hd, d->current.pen.widthF());
- }
- d->drawPath(QCoreGraphicsPaintEnginePrivate::CGStroke, path);
- if (doRestore)
- d->restoreGraphicsState();
- CGPathRelease(path);
- if (d->current.pen.capStyle() == Qt::FlatCap)
- CGContextSetLineCap(d->hd, kCGLineCapButt);
-}
-
-void
-QCoreGraphicsPaintEngine::drawEllipse(const QRectF &r)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
-
- if (state->compositionMode() == QPainter::CompositionMode_Destination)
- return;
-
- CGMutablePathRef path = CGPathCreateMutable();
- CGAffineTransform transform = CGAffineTransformMakeScale(r.width() / r.height(), 1);
- CGPathAddArc(path, &transform,(r.x() + (r.width() / 2)) / (r.width() / r.height()),
- r.y() + (r.height() / 2), r.height() / 2, 0, (2 * M_PI), false);
- d->drawPath(QCoreGraphicsPaintEnginePrivate::CGFill | QCoreGraphicsPaintEnginePrivate::CGStroke,
- path);
- CGPathRelease(path);
-}
-
-void
-QCoreGraphicsPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
-
- if (state->compositionMode() == QPainter::CompositionMode_Destination)
- return;
-
- CGMutablePathRef path = CGPathCreateMutable();
- CGPathMoveToPoint(path, 0, points[0].x(), points[0].y());
- for(int x = 1; x < pointCount; ++x)
- CGPathAddLineToPoint(path, 0, points[x].x(), points[x].y());
- if(mode != PolylineMode && points[0] != points[pointCount-1])
- CGPathAddLineToPoint(path, 0, points[0].x(), points[0].y());
- uint op = QCoreGraphicsPaintEnginePrivate::CGStroke;
- if (mode != PolylineMode)
- op |= mode == OddEvenMode ? QCoreGraphicsPaintEnginePrivate::CGEOFill
- : QCoreGraphicsPaintEnginePrivate::CGFill;
- d->drawPath(op, path);
- CGPathRelease(path);
-}
-
-void
-QCoreGraphicsPaintEngine::drawLines(const QLineF *lines, int lineCount)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
-
- if (state->compositionMode() == QPainter::CompositionMode_Destination)
- return;
-
- CGMutablePathRef path = CGPathCreateMutable();
- for(int i = 0; i < lineCount; i++) {
- const QPointF start = lines[i].p1(), end = lines[i].p2();
- CGPathMoveToPoint(path, 0, start.x(), start.y());
- CGPathAddLineToPoint(path, 0, end.x(), end.y());
- }
- d->drawPath(QCoreGraphicsPaintEnginePrivate::CGStroke, path);
- CGPathRelease(path);
-}
-
-void QCoreGraphicsPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
-
- if (state->compositionMode() == QPainter::CompositionMode_Destination)
- return;
-
- if(pm.isNull())
- return;
-
- bool differentSize = (QRectF(0, 0, pm.width(), pm.height()) != sr), doRestore = false;
- CGRect rect = CGRectMake(r.x(), r.y(), r.width(), r.height());
- QCFType<CGImageRef> image;
- bool isBitmap = (pm.depth() == 1);
- if (isBitmap) {
- doRestore = true;
- d->saveGraphicsState();
-
- const QColor &col = d->current.pen.color();
- CGContextSetFillColorWithColor(d->hd, cgColorForQColor(col, d->pdev));
- image = qt_mac_create_imagemask(pm, sr);
- } else if (differentSize) {
- QCFType<CGImageRef> img = pm.toMacCGImageRef();
- image = CGImageCreateWithImageInRect(img, CGRectMake(qRound(sr.x()), qRound(sr.y()), qRound(sr.width()), qRound(sr.height())));
- } else {
- image = (CGImageRef)pm.macCGHandle();
- }
- qt_mac_drawCGImage(d->hd, &rect, image);
- if (doRestore)
- d->restoreGraphicsState();
-}
-
-static void drawImageReleaseData (void *info, const void *, size_t)
-{
- delete static_cast<QImage *>(info);
-}
-
-CGImageRef qt_mac_createCGImageFromQImage(const QImage &img, const QImage **imagePtr = 0)
-{
- QImage *image;
- if (img.depth() != 32)
- image = new QImage(img.convertToFormat(QImage::Format_ARGB32_Premultiplied));
- else
- image = new QImage(img);
-
- uint cgflags = kCGImageAlphaNone;
- switch (image->format()) {
- case QImage::Format_ARGB32_Premultiplied:
- cgflags = kCGImageAlphaPremultipliedFirst;
- break;
- case QImage::Format_ARGB32:
- cgflags = kCGImageAlphaFirst;
- break;
- case QImage::Format_RGB32:
- cgflags = kCGImageAlphaNoneSkipFirst;
- default:
- break;
- }
-#if defined(kCGBitmapByteOrder32Host) //only needed because CGImage.h added symbols in the minor version
- cgflags |= kCGBitmapByteOrder32Host;
-#endif
- QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(image,
- static_cast<const QImage *>(image)->bits(),
- image->byteCount(),
- drawImageReleaseData);
- if (imagePtr)
- *imagePtr = image;
- return CGImageCreate(image->width(), image->height(), 8, 32,
- image->bytesPerLine(),
- QCoreGraphicsPaintEngine::macGenericColorSpace(),
- cgflags, dataProvider, 0, false, kCGRenderingIntentDefault);
-
-}
-
-void QCoreGraphicsPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRectF &sr,
- Qt::ImageConversionFlags flags)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_UNUSED(flags);
- Q_ASSERT(isActive());
-
- if (img.isNull() || state->compositionMode() == QPainter::CompositionMode_Destination)
- return;
-
- const QImage *image;
- QCFType<CGImageRef> cgimage = qt_mac_createCGImageFromQImage(img, &image);
- CGRect rect = CGRectMake(r.x(), r.y(), r.width(), r.height());
- if (QRectF(0, 0, img.width(), img.height()) != sr)
- cgimage = CGImageCreateWithImageInRect(cgimage, CGRectMake(sr.x(), sr.y(),
- sr.width(), sr.height()));
- qt_mac_drawCGImage(d->hd, &rect, cgimage);
-}
-
-void QCoreGraphicsPaintEngine::initialize()
-{
-}
-
-void QCoreGraphicsPaintEngine::cleanup()
-{
-}
-
-CGContextRef
-QCoreGraphicsPaintEngine::handle() const
-{
- return d_func()->hd;
-}
-
-void
-QCoreGraphicsPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap,
- const QPointF &p)
-{
- Q_D(QCoreGraphicsPaintEngine);
- Q_ASSERT(isActive());
-
- if (state->compositionMode() == QPainter::CompositionMode_Destination)
- return;
-
- //save the old state
- d->saveGraphicsState();
-
- //setup the pattern
- QMacPattern *qpattern = new QMacPattern;
- qpattern->data.pixmap = pixmap;
- qpattern->foreground = d->current.pen.color();
- qpattern->pdev = d->pdev;
- CGPatternCallbacks callbks;
- callbks.version = 0;
- callbks.drawPattern = qt_mac_draw_pattern;
- callbks.releaseInfo = qt_mac_dispose_pattern;
- const int width = qpattern->width(), height = qpattern->height();
- CGAffineTransform trans = CGContextGetCTM(d->hd);
- CGPatternRef pat = CGPatternCreate(qpattern, CGRectMake(0, 0, width, height),
- trans, width, height,
- kCGPatternTilingNoDistortion, true, &callbks);
- CGColorSpaceRef cs = CGColorSpaceCreatePattern(0);
- CGContextSetFillColorSpace(d->hd, cs);
- CGFloat component = 1.0; //just one
- CGContextSetFillPattern(d->hd, pat, &component);
- CGSize phase = CGSizeApplyAffineTransform(CGSizeMake(-(p.x()-r.x()), -(p.y()-r.y())), trans);
- CGContextSetPatternPhase(d->hd, phase);
-
- //fill the rectangle
- CGRect mac_rect = CGRectMake(r.x(), r.y(), r.width(), r.height());
- CGContextFillRect(d->hd, mac_rect);
-
- //restore the state
- d->restoreGraphicsState();
- //cleanup
- CGColorSpaceRelease(cs);
- CGPatternRelease(pat);
-}
-
-void QCoreGraphicsPaintEngine::drawTextItem(const QPointF &pos, const QTextItem &item)
-{
- Q_D(QCoreGraphicsPaintEngine);
- if (d->current.transform.type() == QTransform::TxProject
-#ifndef QMAC_NATIVE_GRADIENTS
- || painter()->pen().brush().gradient() //Just let the base engine "emulate" the gradient
-#endif
- ) {
- QPaintEngine::drawTextItem(pos, item);
- return;
- }
-
- if (state->compositionMode() == QPainter::CompositionMode_Destination)
- return;
-
- const QTextItemInt &ti = static_cast<const QTextItemInt &>(item);
-
- QPen oldPen = painter()->pen();
- QBrush oldBrush = painter()->brush();
- QPointF oldBrushOrigin = painter()->brushOrigin();
- updatePen(Qt::NoPen);
- updateBrush(oldPen.brush(), QPointF(0, 0));
-
- Q_ASSERT(type() == QPaintEngine::CoreGraphics);
-
- QFontEngine *fe = ti.fontEngine;
-
- const bool textAA = state->renderHints() & QPainter::TextAntialiasing && fe->fontDef.pointSize > qt_antialiasing_threshold && !(fe->fontDef.styleStrategy & QFont::NoAntialias);
- const bool lineAA = state->renderHints() & QPainter::Antialiasing;
- if(textAA != lineAA)
- CGContextSetShouldAntialias(d->hd, textAA);
-
- if (ti.glyphs.numGlyphs) {
- switch (fe->type()) {
- case QFontEngine::Mac:
-#ifdef QT_MAC_USE_COCOA
- static_cast<QCoreTextFontEngine *>(fe)->draw(d->hd, pos.x(), pos.y(), ti, paintDevice()->height());
-#else
- static_cast<QFontEngineMac *>(fe)->draw(d->hd, pos.x(), pos.y(), ti, paintDevice()->height());
-#endif
- break;
- case QFontEngine::Box:
- d->drawBoxTextItem(pos, ti);
- break;
- default:
- break;
- }
- }
-
- if(textAA != lineAA)
- CGContextSetShouldAntialias(d->hd, !textAA);
-
- updatePen(oldPen);
- updateBrush(oldBrush, oldBrushOrigin);
-}
-
-QPainter::RenderHints
-QCoreGraphicsPaintEngine::supportedRenderHints() const
-{
- return QPainter::RenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
-}
-enum CGCompositeMode {
- kCGCompositeModeClear = 0,
- kCGCompositeModeCopy = 1,
- kCGCompositeModeSourceOver = 2,
- kCGCompositeModeSourceIn = 3,
- kCGCompositeModeSourceOut = 4,
- kCGCompositeModeSourceAtop = 5,
- kCGCompositeModeDestinationOver = 6,
- kCGCompositeModeDestinationIn = 7,
- kCGCompositeModeDestinationOut = 8,
- kCGCompositeModeDestinationAtop = 9,
- kCGCompositeModeXOR = 10,
- kCGCompositeModePlusDarker = 11, // (max (0, (1-d) + (1-s)))
- kCGCompositeModePlusLighter = 12, // (min (1, s + d))
- };
-extern "C" {
- extern void CGContextSetCompositeOperation(CGContextRef, int);
-} // private function, but is in all versions of OS X.
-void
-QCoreGraphicsPaintEngine::updateCompositionMode(QPainter::CompositionMode mode)
-{
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
- int cg_mode = kCGBlendModeNormal;
- switch(mode) {
- case QPainter::CompositionMode_Multiply:
- cg_mode = kCGBlendModeMultiply;
- break;
- case QPainter::CompositionMode_Screen:
- cg_mode = kCGBlendModeScreen;
- break;
- case QPainter::CompositionMode_Overlay:
- cg_mode = kCGBlendModeOverlay;
- break;
- case QPainter::CompositionMode_Darken:
- cg_mode = kCGBlendModeDarken;
- break;
- case QPainter::CompositionMode_Lighten:
- cg_mode = kCGBlendModeLighten;
- break;
- case QPainter::CompositionMode_ColorDodge:
- cg_mode = kCGBlendModeColorDodge;
- break;
- case QPainter::CompositionMode_ColorBurn:
- cg_mode = kCGBlendModeColorBurn;
- break;
- case QPainter::CompositionMode_HardLight:
- cg_mode = kCGBlendModeHardLight;
- break;
- case QPainter::CompositionMode_SoftLight:
- cg_mode = kCGBlendModeSoftLight;
- break;
- case QPainter::CompositionMode_Difference:
- cg_mode = kCGBlendModeDifference;
- break;
- case QPainter::CompositionMode_Exclusion:
- cg_mode = kCGBlendModeExclusion;
- break;
- case QPainter::CompositionMode_Plus:
- cg_mode = kCGBlendModePlusLighter;
- break;
- case QPainter::CompositionMode_SourceOver:
- cg_mode = kCGBlendModeNormal;
- break;
- case QPainter::CompositionMode_DestinationOver:
- cg_mode = kCGBlendModeDestinationOver;
- break;
- case QPainter::CompositionMode_Clear:
- cg_mode = kCGBlendModeClear;
- break;
- case QPainter::CompositionMode_Source:
- cg_mode = kCGBlendModeCopy;
- break;
- case QPainter::CompositionMode_Destination:
- cg_mode = -1;
- break;
- case QPainter::CompositionMode_SourceIn:
- cg_mode = kCGBlendModeSourceIn;
- break;
- case QPainter::CompositionMode_DestinationIn:
- cg_mode = kCGCompositeModeDestinationIn;
- break;
- case QPainter::CompositionMode_SourceOut:
- cg_mode = kCGBlendModeSourceOut;
- break;
- case QPainter::CompositionMode_DestinationOut:
- cg_mode = kCGBlendModeDestinationOver;
- break;
- case QPainter::CompositionMode_SourceAtop:
- cg_mode = kCGBlendModeSourceAtop;
- break;
- case QPainter::CompositionMode_DestinationAtop:
- cg_mode = kCGBlendModeDestinationAtop;
- break;
- case QPainter::CompositionMode_Xor:
- cg_mode = kCGBlendModeXOR;
- break;
- default:
- break;
- }
- if (cg_mode > -1) {
- CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
- }
- } else
-#endif
- // The standard porter duff ops.
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_3
- && mode <= QPainter::CompositionMode_Xor) {
- int cg_mode = kCGCompositeModeCopy;
- switch (mode) {
- case QPainter::CompositionMode_SourceOver:
- cg_mode = kCGCompositeModeSourceOver;
- break;
- case QPainter::CompositionMode_DestinationOver:
- cg_mode = kCGCompositeModeDestinationOver;
- break;
- case QPainter::CompositionMode_Clear:
- cg_mode = kCGCompositeModeClear;
- break;
- default:
- qWarning("QCoreGraphicsPaintEngine: Unhandled composition mode %d", (int)mode);
- break;
- case QPainter::CompositionMode_Source:
- cg_mode = kCGCompositeModeCopy;
- break;
- case QPainter::CompositionMode_Destination:
- cg_mode = CGCompositeMode(-1);
- break;
- case QPainter::CompositionMode_SourceIn:
- cg_mode = kCGCompositeModeSourceIn;
- break;
- case QPainter::CompositionMode_DestinationIn:
- cg_mode = kCGCompositeModeDestinationIn;
- break;
- case QPainter::CompositionMode_SourceOut:
- cg_mode = kCGCompositeModeSourceOut;
- break;
- case QPainter::CompositionMode_DestinationOut:
- cg_mode = kCGCompositeModeDestinationOut;
- break;
- case QPainter::CompositionMode_SourceAtop:
- cg_mode = kCGCompositeModeSourceAtop;
- break;
- case QPainter::CompositionMode_DestinationAtop:
- cg_mode = kCGCompositeModeDestinationAtop;
- break;
- case QPainter::CompositionMode_Xor:
- cg_mode = kCGCompositeModeXOR;
- break;
- }
- if (cg_mode > -1)
- CGContextSetCompositeOperation(d_func()->hd, CGCompositeMode(cg_mode));
- } else {
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
- bool needPrivateAPI = false;
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
- int cg_mode = kCGBlendModeNormal;
- switch (mode) {
- case QPainter::CompositionMode_Multiply:
- cg_mode = kCGBlendModeMultiply;
- break;
- case QPainter::CompositionMode_Screen:
- cg_mode = kCGBlendModeScreen;
- break;
- case QPainter::CompositionMode_Overlay:
- cg_mode = kCGBlendModeOverlay;
- break;
- case QPainter::CompositionMode_Darken:
- cg_mode = kCGBlendModeDarken;
- break;
- case QPainter::CompositionMode_Lighten:
- cg_mode = kCGBlendModeLighten;
- break;
- case QPainter::CompositionMode_ColorDodge:
- cg_mode = kCGBlendModeColorDodge;
- break;
- case QPainter::CompositionMode_ColorBurn:
- cg_mode = kCGBlendModeColorBurn;
- break;
- case QPainter::CompositionMode_HardLight:
- cg_mode = kCGBlendModeHardLight;
- break;
- case QPainter::CompositionMode_SoftLight:
- cg_mode = kCGBlendModeSoftLight;
- break;
- case QPainter::CompositionMode_Difference:
- cg_mode = kCGBlendModeDifference;
- break;
- case QPainter::CompositionMode_Exclusion:
- cg_mode = kCGBlendModeExclusion;
- break;
- case QPainter::CompositionMode_Plus:
- needPrivateAPI = true;
- cg_mode = kCGCompositeModePlusLighter;
- break;
- default:
- break;
- }
- if (!needPrivateAPI)
- CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
- else
- CGContextSetCompositeOperation(d_func()->hd, CGCompositeMode(cg_mode));
- }
-#endif
- }
-}
-
-void
-QCoreGraphicsPaintEngine::updateRenderHints(QPainter::RenderHints hints)
-{
- Q_D(QCoreGraphicsPaintEngine);
- CGContextSetShouldAntialias(d->hd, hints & QPainter::Antialiasing);
- static const CGFloat ScaleFactor = qt_mac_get_scalefactor();
- if (ScaleFactor > 1.) {
- CGContextSetInterpolationQuality(d->hd, kCGInterpolationHigh);
- } else {
- CGContextSetInterpolationQuality(d->hd, (hints & QPainter::SmoothPixmapTransform) ?
- kCGInterpolationHigh : kCGInterpolationNone);
- }
- bool textAntialiasing = (hints & QPainter::TextAntialiasing) == QPainter::TextAntialiasing;
- if (!textAntialiasing || d->disabledSmoothFonts) {
- d->disabledSmoothFonts = !textAntialiasing;
- CGContextSetShouldSmoothFonts(d->hd, textAntialiasing);
- }
-}
-
-/*
- Returns the size of one device pixel in user-space coordinates.
-*/
-QPointF QCoreGraphicsPaintEnginePrivate::devicePixelSize(CGContextRef)
-{
- QPointF p1 = current.transform.inverted().map(QPointF(0, 0));
- QPointF p2 = current.transform.inverted().map(QPointF(1, 1));
- return QPointF(qAbs(p2.x() - p1.x()), qAbs(p2.y() - p1.y()));
-}
-
-/*
- Adjusts the pen width so we get correct line widths in the
- non-transformed, aliased case.
-*/
-float QCoreGraphicsPaintEnginePrivate::adjustPenWidth(float penWidth)
-{
- Q_Q(QCoreGraphicsPaintEngine);
- float ret = penWidth;
- if (!complexXForm && !(q->state->renderHints() & QPainter::Antialiasing)) {
- if (penWidth < 2)
- ret = 1;
- else if (penWidth < 3)
- ret = 1.5;
- else
- ret = penWidth -1;
- }
- return ret;
-}
-
-void
-QCoreGraphicsPaintEnginePrivate::setStrokePen(const QPen &pen)
-{
- //pencap
- CGLineCap cglinecap = kCGLineCapButt;
- if(pen.capStyle() == Qt::SquareCap)
- cglinecap = kCGLineCapSquare;
- else if(pen.capStyle() == Qt::RoundCap)
- cglinecap = kCGLineCapRound;
- CGContextSetLineCap(hd, cglinecap);
- CGContextSetLineWidth(hd, adjustPenWidth(pen.widthF()));
-
- //join
- CGLineJoin cglinejoin = kCGLineJoinMiter;
- if(pen.joinStyle() == Qt::BevelJoin)
- cglinejoin = kCGLineJoinBevel;
- else if(pen.joinStyle() == Qt::RoundJoin)
- cglinejoin = kCGLineJoinRound;
- CGContextSetLineJoin(hd, cglinejoin);
-// CGContextSetMiterLimit(hd, pen.miterLimit());
-
- //pen style
- QVector<CGFloat> linedashes;
- if(pen.style() == Qt::CustomDashLine) {
- QVector<qreal> customs = pen.dashPattern();
- for(int i = 0; i < customs.size(); ++i)
- linedashes.append(customs.at(i));
- } else if(pen.style() == Qt::DashLine) {
- linedashes.append(4);
- linedashes.append(2);
- } else if(pen.style() == Qt::DotLine) {
- linedashes.append(1);
- linedashes.append(2);
- } else if(pen.style() == Qt::DashDotLine) {
- linedashes.append(4);
- linedashes.append(2);
- linedashes.append(1);
- linedashes.append(2);
- } else if(pen.style() == Qt::DashDotDotLine) {
- linedashes.append(4);
- linedashes.append(2);
- linedashes.append(1);
- linedashes.append(2);
- linedashes.append(1);
- linedashes.append(2);
- }
- const CGFloat cglinewidth = pen.widthF() <= 0.0f ? 1.0f : float(pen.widthF());
- for(int i = 0; i < linedashes.size(); ++i) {
- linedashes[i] *= cglinewidth;
- if(cglinewidth < 3 && (cglinecap == kCGLineCapSquare || cglinecap == kCGLineCapRound)) {
- if((i%2))
- linedashes[i] += cglinewidth/2;
- else
- linedashes[i] -= cglinewidth/2;
- }
- }
- CGContextSetLineDash(hd, pen.dashOffset() * cglinewidth, linedashes.data(), linedashes.size());
-
- // color
- CGContextSetStrokeColorWithColor(hd, cgColorForQColor(pen.color(), pdev));
-}
-
-// Add our own patterns here to deal with the fact that the coordinate system
-// is flipped vertically with Quartz2D.
-static const uchar *qt_mac_patternForBrush(int brushStyle)
-{
- Q_ASSERT(brushStyle > Qt::SolidPattern && brushStyle < Qt::LinearGradientPattern);
- static const uchar dense1_pat[] = { 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00 };
- static const uchar dense2_pat[] = { 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00, 0x88 };
- static const uchar dense3_pat[] = { 0x11, 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa };
- static const uchar dense4_pat[] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 };
- static const uchar dense5_pat[] = { 0xee, 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55 };
- static const uchar dense6_pat[] = { 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff, 0x77 };
- static const uchar dense7_pat[] = { 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff };
- static const uchar hor_pat[] = { 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff };
- static const uchar ver_pat[] = { 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef };
- static const uchar cross_pat[] = { 0xef, 0xef, 0xef, 0xef, 0x00, 0xef, 0xef, 0xef };
- static const uchar fdiag_pat[] = { 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe };
- static const uchar bdiag_pat[] = { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f };
- static const uchar dcross_pat[] = { 0x7e, 0xbd, 0xdb, 0xe7, 0xe7, 0xdb, 0xbd, 0x7e };
- static const uchar *const pat_tbl[] = {
- dense1_pat, dense2_pat, dense3_pat, dense4_pat, dense5_pat,
- dense6_pat, dense7_pat,
- hor_pat, ver_pat, cross_pat, bdiag_pat, fdiag_pat, dcross_pat };
- return pat_tbl[brushStyle - Qt::Dense1Pattern];
-}
-
-void QCoreGraphicsPaintEnginePrivate::setFillBrush(const QPointF &offset)
-{
- // pattern
- Qt::BrushStyle bs = current.brush.style();
-#ifdef QT_MAC_USE_NATIVE_GRADIENTS
- if (bs == Qt::LinearGradientPattern || bs == Qt::RadialGradientPattern) {
- const QGradient *grad = static_cast<const QGradient*>(current.brush.gradient());
- if (drawGradientNatively(grad)) {
- Q_ASSERT(grad->spread() == QGradient::PadSpread);
-
- static const CGFloat domain[] = { 0.0f, +1.0f };
- static const CGFunctionCallbacks callbacks = { 0, qt_mac_color_gradient_function, 0 };
- CGFunctionRef fill_func = CGFunctionCreate(reinterpret_cast<void *>(&current.brush),
- 1, domain, 4, 0, &callbacks);
-
- CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pdev);
- if (bs == Qt::LinearGradientPattern) {
- const QLinearGradient *linearGrad = static_cast<const QLinearGradient *>(grad);
- const QPointF start(linearGrad->start());
- const QPointF stop(linearGrad->finalStop());
- shading = CGShadingCreateAxial(colorspace, CGPointMake(start.x(), start.y()),
- CGPointMake(stop.x(), stop.y()), fill_func, true, true);
- } else {
- Q_ASSERT(bs == Qt::RadialGradientPattern);
- const QRadialGradient *radialGrad = static_cast<const QRadialGradient *>(grad);
- QPointF center(radialGrad->center());
- QPointF focal(radialGrad->focalPoint());
- qreal radius = radialGrad->radius();
- qreal focalRadius = radialGrad->focalRadius();
- shading = CGShadingCreateRadial(colorspace, CGPointMake(focal.x(), focal.y()),
- focalRadius, CGPointMake(center.x(), center.y()), radius, fill_func, false, true);
- }
-
- CGFunctionRelease(fill_func);
- }
- } else
-#endif
- if(bs != Qt::SolidPattern && bs != Qt::NoBrush
-#ifndef QT_MAC_USE_NATIVE_GRADIENTS
- && (bs < Qt::LinearGradientPattern || bs > Qt::ConicalGradientPattern)
-#endif
- )
- {
- QMacPattern *qpattern = new QMacPattern;
- qpattern->pdev = pdev;
- CGFloat components[4] = { 1.0, 1.0, 1.0, 1.0 };
- CGColorSpaceRef base_colorspace = 0;
- if(bs == Qt::TexturePattern) {
- qpattern->data.pixmap = current.brush.texture();
- if(qpattern->data.pixmap.isQBitmap()) {
- const QColor &col = current.brush.color();
- components[0] = qt_mac_convert_color_to_cg(col.red());
- components[1] = qt_mac_convert_color_to_cg(col.green());
- components[2] = qt_mac_convert_color_to_cg(col.blue());
- base_colorspace = QCoreGraphicsPaintEngine::macGenericColorSpace();
- }
- } else {
- qpattern->as_mask = true;
-
- qpattern->data.bytes = qt_mac_patternForBrush(bs);
- const QColor &col = current.brush.color();
- components[0] = qt_mac_convert_color_to_cg(col.red());
- components[1] = qt_mac_convert_color_to_cg(col.green());
- components[2] = qt_mac_convert_color_to_cg(col.blue());
- base_colorspace = QCoreGraphicsPaintEngine::macGenericColorSpace();
- }
- int width = qpattern->width(), height = qpattern->height();
- qpattern->foreground = current.brush.color();
-
- CGColorSpaceRef fill_colorspace = CGColorSpaceCreatePattern(base_colorspace);
- CGContextSetFillColorSpace(hd, fill_colorspace);
-
- CGAffineTransform xform = CGContextGetCTM(hd);
- xform = CGAffineTransformConcat(qt_mac_convert_transform_to_cg(current.brush.transform()), xform);
- xform = CGAffineTransformTranslate(xform, offset.x(), offset.y());
-
- CGPatternCallbacks callbks;
- callbks.version = 0;
- callbks.drawPattern = qt_mac_draw_pattern;
- callbks.releaseInfo = qt_mac_dispose_pattern;
- CGPatternRef fill_pattern = CGPatternCreate(qpattern, CGRectMake(0, 0, width, height),
- xform, width, height, kCGPatternTilingNoDistortion,
- !base_colorspace, &callbks);
- CGContextSetFillPattern(hd, fill_pattern, components);
-
- CGPatternRelease(fill_pattern);
- CGColorSpaceRelease(fill_colorspace);
- } else if(bs != Qt::NoBrush) {
- CGContextSetFillColorWithColor(hd, cgColorForQColor(current.brush.color(), pdev));
- }
-}
-
-void
-QCoreGraphicsPaintEnginePrivate::setClip(const QRegion *rgn)
-{
- Q_Q(QCoreGraphicsPaintEngine);
- if(hd) {
- resetClip();
- QRegion sysClip = q->systemClip();
- if(!sysClip.isEmpty())
- qt_mac_clip_cg(hd, sysClip, &orig_xform);
- if(rgn)
- qt_mac_clip_cg(hd, *rgn, 0);
- }
-}
-
-struct qt_mac_cg_transform_path {
- CGMutablePathRef path;
- CGAffineTransform transform;
-};
-
-void qt_mac_cg_transform_path_apply(void *info, const CGPathElement *element)
-{
- Q_ASSERT(info && element);
- qt_mac_cg_transform_path *t = (qt_mac_cg_transform_path*)info;
- switch(element->type) {
- case kCGPathElementMoveToPoint:
- CGPathMoveToPoint(t->path, &t->transform, element->points[0].x, element->points[0].y);
- break;
- case kCGPathElementAddLineToPoint:
- CGPathAddLineToPoint(t->path, &t->transform, element->points[0].x, element->points[0].y);
- break;
- case kCGPathElementAddQuadCurveToPoint:
- CGPathAddQuadCurveToPoint(t->path, &t->transform, element->points[0].x, element->points[0].y,
- element->points[1].x, element->points[1].y);
- break;
- case kCGPathElementAddCurveToPoint:
- CGPathAddCurveToPoint(t->path, &t->transform, element->points[0].x, element->points[0].y,
- element->points[1].x, element->points[1].y,
- element->points[2].x, element->points[2].y);
- break;
- case kCGPathElementCloseSubpath:
- CGPathCloseSubpath(t->path);
- break;
- default:
- qDebug() << "Unhandled path transform type: " << element->type;
- }
-}
-
-void QCoreGraphicsPaintEnginePrivate::drawPath(uchar ops, CGMutablePathRef path)
-{
- Q_Q(QCoreGraphicsPaintEngine);
- Q_ASSERT((ops & (CGFill | CGEOFill)) != (CGFill | CGEOFill)); //can't really happen
- if((ops & (CGFill | CGEOFill))) {
- if (shading) {
- Q_ASSERT(path);
- CGContextBeginPath(hd);
- CGContextAddPath(hd, path);
- saveGraphicsState();
- if (ops & CGFill)
- CGContextClip(hd);
- else if (ops & CGEOFill)
- CGContextEOClip(hd);
- if (current.brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode) {
- CGRect boundingBox = CGPathGetBoundingBox(path);
- CGContextConcatCTM(hd,
- CGAffineTransformMake(boundingBox.size.width, 0,
- 0, boundingBox.size.height,
- boundingBox.origin.x, boundingBox.origin.y));
- }
- CGContextDrawShading(hd, shading);
- restoreGraphicsState();
- ops &= ~CGFill;
- ops &= ~CGEOFill;
- } else if (current.brush.style() == Qt::NoBrush) {
- ops &= ~CGFill;
- ops &= ~CGEOFill;
- }
- }
- if((ops & CGStroke) && current.pen.style() == Qt::NoPen)
- ops &= ~CGStroke;
-
- if(ops & (CGEOFill | CGFill)) {
- CGContextBeginPath(hd);
- CGContextAddPath(hd, path);
- if (ops & CGEOFill) {
- CGContextEOFillPath(hd);
- } else {
- CGContextFillPath(hd);
- }
- }
-
- // Avoid saving and restoring the context if we can.
- const bool needContextSave = (cosmeticPen != QCoreGraphicsPaintEnginePrivate::CosmeticNone ||
- !(q->state->renderHints() & QPainter::Antialiasing));
- if(ops & CGStroke) {
- if (needContextSave)
- saveGraphicsState();
- CGContextBeginPath(hd);
-
- // Translate a fraction of a pixel size in the y direction
- // to make sure that primitives painted at pixel borders
- // fills the right pixel. This is needed since the y xais
- // in the Quartz coordinate system is inverted compared to Qt.
- if (!(q->state->renderHints() & QPainter::Antialiasing)) {
- if (current.pen.style() == Qt::SolidLine || current.pen.width() >= 3)
- CGContextTranslateCTM(hd, double(pixelSize.x()) * 0.25, double(pixelSize.y()) * 0.25);
- else if (current.pen.style() == Qt::DotLine && QSysInfo::MacintoshVersion == QSysInfo::MV_10_3)
- ; // Do nothing.
- else
- CGContextTranslateCTM(hd, 0, double(pixelSize.y()) * 0.1);
- }
-
- if (cosmeticPen != QCoreGraphicsPaintEnginePrivate::CosmeticNone) {
- // If antialiazing is enabled, use the cosmetic pen size directly.
- if (q->state->renderHints() & QPainter::Antialiasing)
- CGContextSetLineWidth(hd, cosmeticPenSize);
- else if (current.pen.widthF() <= 1)
- CGContextSetLineWidth(hd, cosmeticPenSize * 0.9f);
- else
- CGContextSetLineWidth(hd, cosmeticPenSize);
- }
- if(cosmeticPen == QCoreGraphicsPaintEnginePrivate::CosmeticTransformPath) {
- qt_mac_cg_transform_path t;
- t.transform = qt_mac_convert_transform_to_cg(current.transform);
- t.path = CGPathCreateMutable();
- CGPathApply(path, &t, qt_mac_cg_transform_path_apply); //transform the path
- setTransform(0); //unset the context transform
- CGContextSetLineWidth(hd, cosmeticPenSize);
- CGContextAddPath(hd, t.path);
- CGPathRelease(t.path);
- } else {
- CGContextAddPath(hd, path);
- }
-
- CGContextStrokePath(hd);
- if (needContextSave)
- restoreGraphicsState();
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengine_mac_p.h b/src/gui/painting/qpaintengine_mac_p.h
deleted file mode 100644
index c87501ee1a..0000000000
--- a/src/gui/painting/qpaintengine_mac_p.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPAINTENGINE_MAC_P_H
-#define QPAINTENGINE_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/qpaintengine.h"
-#include "private/qt_mac_p.h"
-#include "private/qpaintengine_p.h"
-#include "private/qpolygonclipper_p.h"
-#include "private/qfont_p.h"
-#include "QtCore/qhash.h"
-
-typedef struct CGColorSpace *CGColorSpaceRef;
-QT_BEGIN_NAMESPACE
-
-class QCoreGraphicsPaintEnginePrivate;
-class QCoreGraphicsPaintEngine : public QPaintEngine
-{
- Q_DECLARE_PRIVATE(QCoreGraphicsPaintEngine)
-
-public:
- QCoreGraphicsPaintEngine();
- ~QCoreGraphicsPaintEngine();
-
- bool begin(QPaintDevice *pdev);
- bool end();
- static CGColorSpaceRef macGenericColorSpace();
- static CGColorSpaceRef macDisplayColorSpace(const QWidget *widget = 0);
-
- void updateState(const QPaintEngineState &state);
-
- void updatePen(const QPen &pen);
- void updateBrush(const QBrush &brush, const QPointF &pt);
- void updateFont(const QFont &font);
- void updateOpacity(qreal opacity);
- void updateMatrix(const QTransform &matrix);
- void updateTransform(const QTransform &matrix);
- void updateClipRegion(const QRegion &region, Qt::ClipOperation op);
- void updateClipPath(const QPainterPath &path, Qt::ClipOperation op);
- void updateCompositionMode(QPainter::CompositionMode mode);
- void updateRenderHints(QPainter::RenderHints hints);
-
- void drawLines(const QLineF *lines, int lineCount);
- void drawRects(const QRectF *rects, int rectCount);
- void drawPoints(const QPointF *p, int pointCount);
- void drawEllipse(const QRectF &r);
- void drawPath(const QPainterPath &path);
-
- void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
- void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
- void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
-
- void drawTextItem(const QPointF &pos, const QTextItem &item);
- void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
- Qt::ImageConversionFlags flags = Qt::AutoColor);
-
- Type type() const { return QPaintEngine::CoreGraphics; }
-
- CGContextRef handle() const;
-
- static void initialize();
- static void cleanup();
-
- QPainter::RenderHints supportedRenderHints() const;
-
- //avoid partial shadowed overload warnings...
- void drawLines(const QLine *lines, int lineCount) { QPaintEngine::drawLines(lines, lineCount); }
- void drawRects(const QRect *rects, int rectCount) { QPaintEngine::drawRects(rects, rectCount); }
- void drawPoints(const QPoint *p, int pointCount) { QPaintEngine::drawPoints(p, pointCount); }
- void drawEllipse(const QRect &r) { QPaintEngine::drawEllipse(r); }
- void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
- { QPaintEngine::drawPolygon(points, pointCount, mode); }
-
-protected:
- friend class QMacPrintEngine;
- friend class QMacPrintEnginePrivate;
- friend void qt_mac_display_change_callbk(CGDirectDisplayID, CGDisplayChangeSummaryFlags, void *);
- friend void qt_color_profile_changed(CFNotificationCenterRef center, void *,
- CFStringRef , const void *, CFDictionaryRef);
- QCoreGraphicsPaintEngine(QPaintEnginePrivate &dptr);
-
-private:
- static bool m_postRoutineRegistered;
- static CGColorSpaceRef m_genericColorSpace;
- static QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash;
- static void cleanUpMacColorSpaces();
- Q_DISABLE_COPY(QCoreGraphicsPaintEngine)
-};
-
-/*****************************************************************************
- Private data
- *****************************************************************************/
-class QCoreGraphicsPaintEnginePrivate : public QPaintEnginePrivate
-{
- Q_DECLARE_PUBLIC(QCoreGraphicsPaintEngine)
-public:
- QCoreGraphicsPaintEnginePrivate()
- : hd(0), shading(0), stackCount(0), complexXForm(false), disabledSmoothFonts(false)
- {
- }
-
- struct {
- QPen pen;
- QBrush brush;
- uint clipEnabled : 1;
- QRegion clip;
- QTransform transform;
- } current;
-
- //state info (shared with QD)
- CGAffineTransform orig_xform;
-
- //cg structures
- CGContextRef hd;
- CGShadingRef shading;
- int stackCount;
- bool complexXForm;
- bool disabledSmoothFonts;
- enum { CosmeticNone, CosmeticTransformPath, CosmeticSetPenWidth } cosmeticPen;
-
- // pixel and cosmetic pen size in user coordinates.
- QPointF pixelSize;
- float cosmeticPenSize;
-
- //internal functions
- enum { CGStroke=0x01, CGEOFill=0x02, CGFill=0x04 };
- void drawPath(uchar ops, CGMutablePathRef path = 0);
- void setClip(const QRegion *rgn=0);
- void resetClip();
- void setFillBrush(const QPointF &origin=QPoint());
- void setStrokePen(const QPen &pen);
- inline void saveGraphicsState();
- inline void restoreGraphicsState();
- float penOffset();
- QPointF devicePixelSize(CGContextRef context);
- float adjustPenWidth(float penWidth);
- inline void setTransform(const QTransform *matrix=0)
- {
- CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd)));
- CGAffineTransform xform = orig_xform;
- if(matrix) {
- extern CGAffineTransform qt_mac_convert_transform_to_cg(const QTransform &);
- xform = CGAffineTransformConcat(qt_mac_convert_transform_to_cg(*matrix), xform);
- }
- CGContextConcatCTM(hd, xform);
- CGContextSetTextMatrix(hd, xform);
- }
-};
-
-inline void QCoreGraphicsPaintEnginePrivate::saveGraphicsState()
-{
- ++stackCount;
- CGContextSaveGState(hd);
-}
-
-inline void QCoreGraphicsPaintEnginePrivate::restoreGraphicsState()
-{
- --stackCount;
- Q_ASSERT(stackCount >= 0);
- CGContextRestoreGState(hd);
-}
-
-class QMacQuartzPaintDevice : public QPaintDevice
-{
-public:
- QMacQuartzPaintDevice(CGContextRef cg, int width, int height, int bytesPerLine)
- : mCG(cg), mWidth(width), mHeight(height), mBytesPerLine(bytesPerLine)
- { }
- int devType() const { return QInternal::MacQuartz; }
- CGContextRef cgContext() const { return mCG; }
- int metric(PaintDeviceMetric metric) const {
- switch (metric) {
- case PdmWidth:
- return mWidth;
- case PdmHeight:
- return mHeight;
- case PdmWidthMM:
- return (qt_defaultDpiX() * mWidth) / 2.54;
- case PdmHeightMM:
- return (qt_defaultDpiY() * mHeight) / 2.54;
- case PdmNumColors:
- return 0;
- case PdmDepth:
- return 32;
- case PdmDpiX:
- case PdmPhysicalDpiX:
- return qt_defaultDpiX();
- case PdmDpiY:
- case PdmPhysicalDpiY:
- return qt_defaultDpiY();
- }
- return 0;
- }
- QPaintEngine *paintEngine() const { qWarning("This function should never be called."); return 0; }
-private:
- CGContextRef mCG;
- int mWidth;
- int mHeight;
- int mBytesPerLine;
-};
-
-QT_END_NAMESPACE
-
-#endif // QPAINTENGINE_MAC_P_H
diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h
index 2b54e82c39..5d540bd11b 100644
--- a/src/gui/painting/qpaintengine_p.h
+++ b/src/gui/painting/qpaintengine_p.h
@@ -66,7 +66,7 @@ class QPaintEnginePrivate
{
Q_DECLARE_PUBLIC(QPaintEngine)
public:
- QPaintEnginePrivate() : pdev(0), q_ptr(0), currentClipWidget(0), hasSystemTransform(0),
+ QPaintEnginePrivate() : pdev(0), q_ptr(0), currentClipDevice(0), hasSystemTransform(0),
hasSystemViewport(0) {}
virtual ~QPaintEnginePrivate() { }
QPaintDevice *pdev;
@@ -75,7 +75,7 @@ public:
QRect systemRect;
QRegion systemViewport;
QTransform systemTransform;
- QWidget *currentClipWidget;
+ QPaintDevice *currentClipDevice;
uint hasSystemTransform : 1;
uint hasSystemViewport : 1;
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 1f7ab21ca7..61d7216230 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -51,7 +51,6 @@
#include <qpainterpath.h>
#include <qdebug.h>
#include <qhash.h>
-#include <qlabel.h>
#include <qbitmap.h>
#include <qmath.h>
@@ -87,14 +86,6 @@
# include <private/qt_mac_p.h>
# include <private/qpixmap_mac_p.h>
# include <private/qpaintengine_mac_p.h>
-#elif defined(Q_WS_QWS)
-# if !defined(QT_NO_FREETYPE)
-# include <private/qfontengine_ft_p.h>
-# endif
-# if !defined(QT_NO_QWS_QPF2)
-# include <private/qfontengine_qpf_p.h>
-# endif
-# include <private/qabstractfontengine_p.h>
#elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
# include <private/qfontengine_s60_p.h>
#elif defined(Q_WS_QPA)
@@ -371,11 +362,6 @@ void QRasterPaintEngine::init()
case QInternal::Image:
format = d->rasterBuffer->prepare(static_cast<QImage *>(d->device));
break;
-#ifdef Q_WS_QWS
- case QInternal::CustomRaster:
- d->rasterBuffer->prepare(static_cast<QCustomRasterPaintDevice*>(d->device));
- break;
-#endif
default:
qWarning("QRasterPaintEngine: unsupported target device %d\n", d->device->devType());
d->device = 0;
@@ -971,13 +957,6 @@ void QRasterPaintEngine::clipEnabledChanged()
}
}
-#ifdef Q_WS_QWS
-void QRasterPaintEnginePrivate::prepare(QCustomRasterPaintDevice *device)
-{
- rasterBuffer->prepare(device);
-}
-#endif
-
void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
const QImage &img,
SrcOverBlendFunc func,
@@ -3114,22 +3093,6 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
QFontEngine *fontEngine = ti.fontEngine;
-#if defined(Q_WS_QWS)
- if (fontEngine->type() == QFontEngine::Box) {
- fontEngine->draw(this, qFloor(p.x()), qFloor(p.y()), ti);
- return;
- }
-
- if (s->matrix.type() < QTransform::TxScale
- && (fontEngine->type() == QFontEngine::QPF1 || fontEngine->type() == QFontEngine::QPF2
- || (fontEngine->type() == QFontEngine::Proxy
- && !(static_cast<QProxyFontEngine *>(fontEngine)->drawAsOutline()))
- )) {
- fontEngine->draw(this, qFloor(p.x()), qFloor(p.y()), ti);
- return;
- }
-#endif // Q_WS_QWS
-
#ifdef Q_WS_QPA
if (s->matrix.type() < QTransform::TxScale) {
@@ -3159,14 +3122,6 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
#if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_QPF2)
- if (fontEngine->type() == QFontEngine::QPF2) {
- QFontEngine *renderingEngine = static_cast<QFontEngineQPF *>(fontEngine)->renderingEngine();
- if (renderingEngine)
- fontEngine = renderingEngine;
- }
-#endif
-
if (fontEngine->type() != QFontEngine::Freetype) {
QPaintEngineEx::drawTextItem(p, ti);
return;
@@ -3394,59 +3349,6 @@ QPoint QRasterPaintEngine::coordinateOffset() const
return QPoint(0, 0);
}
-/*!
- Draws the given color \a spans with the specified \a color. The \a
- count parameter specifies the number of spans.
-
- The default implementation does nothing; reimplement this function
- to draw the given color \a spans with the specified \a color. Note
- that this function \e must be reimplemented if the framebuffer is
- not memory-mapped.
-
- \sa drawBufferSpan()
-*/
-#if defined(Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-void QRasterPaintEngine::drawColorSpans(const QSpan *spans, int count, uint color)
-{
- Q_UNUSED(spans);
- Q_UNUSED(count);
- Q_UNUSED(color);
- qFatal("QRasterPaintEngine::drawColorSpans must be reimplemented on "
- "a non memory-mapped device");
-}
-
-/*!
- \fn void QRasterPaintEngine::drawBufferSpan(const uint *buffer, int size, int x, int y, int length, uint alpha)
-
- Draws the given \a buffer.
-
- The default implementation does nothing; reimplement this function
- to draw a buffer that contains more than one color. Note that this
- function \e must be reimplemented if the framebuffer is not
- memory-mapped.
-
- The \a size parameter specifies the total size of the given \a
- buffer, while the \a length parameter specifies the number of
- pixels to draw. The buffer's position is given by (\a x, \a
- y). The provided \a alpha value is added to each pixel in the
- buffer when drawing.
-
- \sa drawColorSpans()
-*/
-void QRasterPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
- int x, int y, int length, uint const_alpha)
-{
- Q_UNUSED(buffer);
- Q_UNUSED(bufsize);
- Q_UNUSED(x);
- Q_UNUSED(y);
- Q_UNUSED(length);
- Q_UNUSED(const_alpha);
- qFatal("QRasterPaintEngine::drawBufferSpan must be reimplemented on "
- "a non memory-mapped device");
-}
-#endif // Q_WS_QWS
-
void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fg)
{
Q_ASSERT(fg);
@@ -3894,127 +3796,6 @@ void QRasterBuffer::resetBuffer(int val)
memset(m_buffer, val, m_height*bytes_per_line);
}
-
-#if defined(Q_WS_QWS)
-void QRasterBuffer::prepare(QCustomRasterPaintDevice *device)
-{
- m_buffer = reinterpret_cast<uchar*>(device->memory());
- m_width = qMin(QT_RASTER_COORD_LIMIT, device->width());
- m_height = qMin(QT_RASTER_COORD_LIMIT, device->height());
- bytes_per_pixel = device->depth() / 8;
- bytes_per_line = device->bytesPerLine();
- format = device->format();
-#ifndef QT_NO_RASTERCALLBACKS
- if (!m_buffer)
- drawHelper = qDrawHelperCallback + format;
- else
-#endif
- drawHelper = qDrawHelper + format;
-}
-
-int QCustomRasterPaintDevice::metric(PaintDeviceMetric m) const
-{
- switch (m) {
- case PdmWidth:
- return widget->frameGeometry().width();
- case PdmHeight:
- return widget->frameGeometry().height();
- default:
- break;
- }
-
- return qt_paint_device_metric(widget, m);
-}
-
-int QCustomRasterPaintDevice::bytesPerLine() const
-{
- return (width() * depth() + 7) / 8;
-}
-
-#elif defined(Q_OS_SYMBIAN)
-
-void QRasterBuffer::prepareBuffer(int /* width */, int /* height */)
-{
-}
-
-#endif // Q_OS_SYMBIAN
-
-/*!
- \class QCustomRasterPaintDevice
- \preliminary
- \ingroup qws
- \since 4.2
-
- \brief The QCustomRasterPaintDevice class is provided to activate
- hardware accelerated paint engines in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- In \l{Qt for Embedded Linux}, painting is a pure software
- implementation. But starting with Qt 4.2, it is
- possible to add an accelerated graphics driver to take advantage
- of available hardware resources.
-
- Hardware acceleration is accomplished by creating a custom screen
- driver, accelerating the copying from memory to the screen, and
- implementing a custom paint engine accelerating the various
- painting operations. Then a custom paint device (derived from the
- QCustomRasterPaintDevice class) and a custom window surface
- (derived from QWSWindowSurface) must be implemented to make
- \l{Qt for Embedded Linux} aware of the accelerated driver.
-
- See the \l {Adding an Accelerated Graphics Driver to Qt for Embedded Linux}
- documentation for details.
-
- \sa QRasterPaintEngine, QPaintDevice
-*/
-
-/*!
- \fn QCustomRasterPaintDevice::QCustomRasterPaintDevice(QWidget *widget)
-
- Constructs a custom raster based paint device for the given
- top-level \a widget.
-*/
-
-/*!
- \fn int QCustomRasterPaintDevice::bytesPerLine() const
-
- Returns the number of bytes per line in the framebuffer. Note that
- this number might be larger than the framebuffer width.
-*/
-
-/*!
- \fn int QCustomRasterPaintDevice::devType() const
- \internal
-*/
-
-/*!
- \fn QImage::Format QCustomRasterPaintDevice::format() const
-
- Returns the format of the device's memory buffet.
-
- The default format is QImage::Format_ARGB32_Premultiplied. The
- only other valid format is QImage::Format_RGB16.
-*/
-
-/*!
- \fn void * QCustomRasterPaintDevice::memory () const
-
- Returns a pointer to the paint device's memory buffer, or 0 if no
- such buffer exists.
-*/
-
-/*!
- \fn int QCustomRasterPaintDevice::metric ( PaintDeviceMetric m ) const
- \reimp
-*/
-
-/*!
- \fn QSize QCustomRasterPaintDevice::size () const
- \internal
-*/
-
-
QClipData::QClipData(int height)
{
clipSpanHeight = height;
@@ -4739,9 +4520,6 @@ Q_GLOBAL_STATIC(QGradientCache, qt_gradient_cache)
void QSpanData::init(QRasterBuffer *rb, const QRasterPaintEngine *pe)
{
rasterBuffer = rb;
-#ifdef Q_WS_QWS
- rasterEngine = const_cast<QRasterPaintEngine *>(pe);
-#endif
type = None;
txop = 0;
bilinear = false;
@@ -4887,16 +4665,7 @@ void QSpanData::adjustSpanMethods()
unclipped_blend = rasterBuffer->drawHelper->blendGradient;
break;
case Texture:
-#ifdef Q_WS_QWS
-#ifndef QT_NO_RASTERCALLBACKS
- if (!rasterBuffer->buffer())
- unclipped_blend = qBlendTextureCallback;
- else
-#endif
- unclipped_blend = qBlendTexture;
-#else
unclipped_blend = qBlendTexture;
-#endif
if (!texture.imageData)
unclipped_blend = 0;
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index f7f605d5a1..5c3f2dfd06 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -72,7 +72,6 @@ class QOutlineMapper;
class QRasterPaintEnginePrivate;
class QRasterBuffer;
class QClipData;
-class QCustomRasterPaintDevice;
class QRasterPaintEngineState : public QPainterState
{
@@ -129,11 +128,7 @@ public:
/*******************************************************************************
* QRasterPaintEngine
*/
-class
-#ifdef Q_WS_QWS
-Q_GUI_EXPORT
-#endif
-QRasterPaintEngine : public QPaintEngineEx
+class Q_GUI_EXPORT QRasterPaintEngine : public QPaintEngineEx
{
Q_DECLARE_PRIVATE(QRasterPaintEngine)
public:
@@ -241,12 +236,6 @@ public:
QPoint coordinateOffset() const;
-#if defined(Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
- virtual void drawColorSpans(const QSpan *spans, int count, uint color);
- virtual void drawBufferSpan(const uint *buffer, int bufsize,
- int x, int y, int length, uint const_alpha);
-#endif
-
protected:
QRasterPaintEngine(QRasterPaintEnginePrivate &d, QPaintDevice *);
private:
@@ -293,11 +282,7 @@ private:
/*******************************************************************************
* QRasterPaintEnginePrivate
*/
-class
-#ifdef Q_WS_QWS
-Q_GUI_EXPORT
-#endif
-QRasterPaintEnginePrivate : public QPaintEngineExPrivate
+class QRasterPaintEnginePrivate : public QPaintEngineExPrivate
{
Q_DECLARE_PUBLIC(QRasterPaintEngine)
public:
@@ -328,10 +313,6 @@ public:
ProcessSpans getBrushFunc(const QRect &rect, const QSpanData *data) const;
ProcessSpans getBrushFunc(const QRectF &rect, const QSpanData *data) const;
-#ifdef Q_WS_QWS
- void prepare(QCustomRasterPaintDevice *);
-#endif
-
inline const QClipData *clip() const;
void initializeRasterizer(QSpanData *data);
@@ -379,11 +360,7 @@ public:
};
-class
-#ifdef Q_WS_QWS
-Q_GUI_EXPORT
-#endif
-QClipData {
+class QClipData {
public:
QClipData(int height);
~QClipData();
@@ -460,41 +437,10 @@ inline void QClipData::appendSpans(const QSpan *s, int num)
count += num;
}
-#ifdef Q_WS_QWS
-class Q_GUI_EXPORT QCustomRasterPaintDevice : public QPaintDevice
-{
-public:
- QCustomRasterPaintDevice(QWidget *w) : widget(w) {}
-
- int devType() const { return QInternal::CustomRaster; }
-
- virtual int metric(PaintDeviceMetric m) const;
-
- virtual void* memory() const { return 0; }
-
- virtual QImage::Format format() const {
- return QImage::Format_ARGB32_Premultiplied;
- }
-
- virtual int bytesPerLine() const;
-
- virtual QSize size() const {
- return static_cast<QRasterPaintEngine*>(paintEngine())->size();
- }
-
-private:
- QWidget *widget;
-};
-#endif // Q_WS_QWS
-
/*******************************************************************************
* QRasterBuffer
*/
-class
-#ifdef Q_WS_QWS
-Q_GUI_EXPORT
-#endif
-QRasterBuffer
+class QRasterBuffer
{
public:
QRasterBuffer() : m_width(0), m_height(0), m_buffer(0) { init(); }
@@ -505,9 +451,6 @@ public:
QImage::Format prepare(QImage *image);
QImage::Format prepare(QPixmap *pix);
-#ifdef Q_WS_QWS
- void prepare(QCustomRasterPaintDevice *device);
-#endif
void prepare(int w, int h);
void prepareBuffer(int w, int h);
diff --git a/src/gui/painting/qpaintengine_s60.cpp b/src/gui/painting/qpaintengine_s60.cpp
deleted file mode 100644
index 091e2e65a4..0000000000
--- a/src/gui/painting/qpaintengine_s60.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <private/qpaintengine_s60_p.h>
-#include <private/qpixmap_s60_p.h>
-#include <private/qt_s60_p.h>
-#include <private/qvolatileimage_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QS60PaintEnginePrivate : public QRasterPaintEnginePrivate
-{
-public:
- QS60PaintEnginePrivate() {}
-};
-
-QS60PaintEngine::QS60PaintEngine(QPaintDevice *device, QS60PixmapData *data)
- : QRasterPaintEngine(*(new QS60PaintEnginePrivate), device), pixmapData(data)
-{
-}
-
-bool QS60PaintEngine::begin(QPaintDevice *device)
-{
- Q_D(QS60PaintEngine);
-
- if (pixmapData->classId() == QPixmapData::RasterClass) {
- pixmapData->beginDataAccess();
- bool ret = QRasterPaintEngine::begin(device);
- // Make sure QPaintEngine::paintDevice() returns the proper device.
- // QRasterPaintEngine changes pdev to QImage in case of RasterClass QPixmapData
- // which is incorrect in Symbian.
- d->pdev = device;
- return ret;
- }
-
- return QRasterPaintEngine::begin(device);
-}
-
-bool QS60PaintEngine::end()
-{
- if (pixmapData->classId() == QPixmapData::RasterClass) {
- bool ret = QRasterPaintEngine::end();
- pixmapData->endDataAccess();
- return ret;
- }
- return QRasterPaintEngine::end();
-}
-
-void QS60PaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm)
-{
- if (pm.pixmapData()->classId() == QPixmapData::RasterClass) {
- QS60PixmapData *srcData = static_cast<QS60PixmapData *>(pm.pixmapData());
- srcData->beginDataAccess();
- QRasterPaintEngine::drawPixmap(p, pm);
- srcData->endDataAccess();
- } else {
- void *nativeData = pm.pixmapData()->toNativeType(QPixmapData::VolatileImage);
- if (nativeData) {
- QVolatileImage *img = static_cast<QVolatileImage *>(nativeData);
- img->beginDataAccess();
- QRasterPaintEngine::drawImage(p, img->imageRef());
- img->endDataAccess(true);
- } else {
- QRasterPaintEngine::drawPixmap(p, pm);
- }
- }
-}
-
-void QS60PaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
-{
- if (pm.pixmapData()->classId() == QPixmapData::RasterClass) {
- QS60PixmapData *srcData = static_cast<QS60PixmapData *>(pm.pixmapData());
- srcData->beginDataAccess();
- QRasterPaintEngine::drawPixmap(r, pm, sr);
- srcData->endDataAccess();
- } else {
- void *nativeData = pm.pixmapData()->toNativeType(QPixmapData::VolatileImage);
- if (nativeData) {
- QVolatileImage *img = static_cast<QVolatileImage *>(nativeData);
- img->beginDataAccess();
- QRasterPaintEngine::drawImage(r, img->imageRef(), sr);
- img->endDataAccess(true);
- } else {
- QRasterPaintEngine::drawPixmap(r, pm, sr);
- }
- }
-}
-
-void QS60PaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr)
-{
- if (pm.pixmapData()->classId() == QPixmapData::RasterClass) {
- QS60PixmapData *srcData = static_cast<QS60PixmapData *>(pm.pixmapData());
- srcData->beginDataAccess();
- QRasterPaintEngine::drawTiledPixmap(r, pm, sr);
- srcData->endDataAccess();
- } else {
- QRasterPaintEngine::drawTiledPixmap(r, pm, sr);
- }
-}
-
-void QS60PaintEngine::prepare(QImage *image)
-{
- QRasterBuffer *buffer = d_func()->rasterBuffer.data();
- if (buffer)
- buffer->prepare(image);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengine_s60_p.h b/src/gui/painting/qpaintengine_s60_p.h
deleted file mode 100644
index 2a3b443db3..0000000000
--- a/src/gui/painting/qpaintengine_s60_p.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPAINTENGINE_S60_P_H
-#define QPAINTENGINE_S60_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qpaintengine_raster_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QS60PaintEnginePrivate;
-class QS60PixmapData;
-
-class QS60PaintEngine : public QRasterPaintEngine
-{
- Q_DECLARE_PRIVATE(QS60PaintEngine)
-
-public:
- QS60PaintEngine(QPaintDevice *device, QS60PixmapData* data);
- bool begin(QPaintDevice *device);
- bool end();
-
- void drawPixmap(const QPointF &p, const QPixmap &pm);
- void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
- void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr);
-
- void prepare(QImage* image);
-
-private:
- QS60PixmapData *pixmapData;
-};
-
-QT_END_NAMESPACE
-
-#endif // QPAINTENGINE_S60_P_H
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
deleted file mode 100644
index 994986b0d6..0000000000
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ /dev/null
@@ -1,2504 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-
-#include "private/qpixmap_x11_p.h"
-
-#include "qapplication.h"
-#include "qdebug.h"
-#include "qfont.h"
-#include "qwidget.h"
-#include "qbitmap.h"
-#include "qpixmapcache.h"
-#include "qtextcodec.h"
-#include "qcoreevent.h"
-#include "qiodevice.h"
-#include <qmath.h>
-
-#include "qpainter_p.h"
-#include <qtextlayout.h>
-#include <qvarlengtharray.h>
-#include <private/qfont_p.h>
-#include <private/qtextengine_p.h>
-#include <private/qpaintengine_x11_p.h>
-#include <private/qfontengine_x11_p.h>
-#include <private/qwidget_p.h>
-#include <private/qpainterpath_p.h>
-
-#include "qpen.h"
-#include "qcolor.h"
-#include "qcolormap.h"
-
-#include <private/qpaintengine_p.h>
-#include "qpaintengine_x11_p.h"
-
-#include <private/qt_x11_p.h>
-#include <private/qnumeric_p.h>
-#include <limits.h>
-
-#ifndef QT_NO_XRENDER
-#include <private/qtessellator_p.h>
-#endif
-
-#include <private/qstylehelper_p.h>
-
-QT_BEGIN_NAMESPACE
-
-extern Drawable qt_x11Handle(const QPaintDevice *pd);
-extern const QX11Info *qt_x11Info(const QPaintDevice *pd);
-extern QPixmap qt_pixmapForBrush(int brushStyle, bool invert); //in qbrush.cpp
-extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap);
-
-// use the same rounding as in qrasterizer.cpp (6 bit fixed point)
-static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
-
-#undef X11 // defined in qt_x11_p.h
-/*!
- Returns the X11 specific pen GC for the painter \a p. Note that
- QPainter::begin() must be called before this function returns a
- valid GC.
-*/
-Q_GUI_EXPORT GC qt_x11_get_pen_gc(QPainter *p)
-{
- if (p && p->paintEngine()
- && p->paintEngine()->isActive()
- && p->paintEngine()->type() == QPaintEngine::X11) {
- return static_cast<QX11PaintEngine *>(p->paintEngine())->d_func()->gc;
- }
- return 0;
-}
-
-/*!
- Returns the X11 specific brush GC for the painter \a p. Note that
- QPainter::begin() must be called before this function returns a
- valid GC.
-*/
-Q_GUI_EXPORT GC qt_x11_get_brush_gc(QPainter *p)
-{
- if (p && p->paintEngine()
- && p->paintEngine()->isActive()
- && p->paintEngine()->type() == QPaintEngine::X11) {
- return static_cast<QX11PaintEngine *>(p->paintEngine())->d_func()->gc_brush;
- }
- return 0;
-}
-#define X11 qt_x11Data
-
-#ifndef QT_NO_XRENDER
-static const int compositionModeToRenderOp[QPainter::CompositionMode_Xor + 1] = {
- PictOpOver, //CompositionMode_SourceOver,
- PictOpOverReverse, //CompositionMode_DestinationOver,
- PictOpClear, //CompositionMode_Clear,
- PictOpSrc, //CompositionMode_Source,
- PictOpDst, //CompositionMode_Destination,
- PictOpIn, //CompositionMode_SourceIn,
- PictOpInReverse, //CompositionMode_DestinationIn,
- PictOpOut, //CompositionMode_SourceOut,
- PictOpOutReverse, //CompositionMode_DestinationOut,
- PictOpAtop, //CompositionMode_SourceAtop,
- PictOpAtopReverse, //CompositionMode_DestinationAtop,
- PictOpXor //CompositionMode_Xor
-};
-
-static inline int qpainterOpToXrender(QPainter::CompositionMode mode)
-{
- Q_ASSERT(mode <= QPainter::CompositionMode_Xor);
- return compositionModeToRenderOp[mode];
-}
-#endif
-
-// hack, so we don't have to make QRegion::clipRectangles() public or include
-// X11 headers in qregion.h
-Q_GUI_EXPORT void *qt_getClipRects(const QRegion &r, int &num)
-{
- return r.clipRectangles(num);
-}
-
-static inline void x11SetClipRegion(Display *dpy, GC gc, GC gc2,
-#ifndef QT_NO_XRENDER
- Picture picture,
-#else
- Qt::HANDLE picture,
-#endif
- const QRegion &r)
-{
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(r, num);
-
- if (gc)
- XSetClipRectangles( dpy, gc, 0, 0, rects, num, YXBanded );
- if (gc2)
- XSetClipRectangles( dpy, gc2, 0, 0, rects, num, YXBanded );
-
-#ifndef QT_NO_XRENDER
- if (picture)
- XRenderSetPictureClipRectangles(dpy, picture, 0, 0, rects, num);
-#else
- Q_UNUSED(picture);
-#endif // QT_NO_XRENDER
-}
-
-
-static inline void x11ClearClipRegion(Display *dpy, GC gc, GC gc2,
-#ifndef QT_NO_XRENDER
- Picture picture
-#else
- Qt::HANDLE picture
-#endif
- )
-{
- if (gc)
- XSetClipMask(dpy, gc, XNone);
- if (gc2)
- XSetClipMask(dpy, gc2, XNone);
-
-#ifndef QT_NO_XRENDER
- if (picture) {
- XRenderPictureAttributes attrs;
- attrs.clip_mask = XNone;
- XRenderChangePicture (dpy, picture, CPClipMask, &attrs);
- }
-#else
- Q_UNUSED(picture);
-#endif // QT_NO_XRENDER
-}
-
-
-#define DITHER_SIZE 16
-static const uchar base_dither_matrix[DITHER_SIZE][DITHER_SIZE] = {
- { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 },
- { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 },
- { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 },
- { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 },
- { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 },
- { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 },
- { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 },
- { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 },
- { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 },
- { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 },
- { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 },
- { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 },
- { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 },
- { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 },
- { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 },
- { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 }
-};
-
-static QPixmap qt_patternForAlpha(uchar alpha, int screen)
-{
- QPixmap pm;
- QString key = QLatin1Literal("$qt-alpha-brush$")
- % HexString<uchar>(alpha)
- % HexString<int>(screen);
-
- if (!QPixmapCache::find(key, pm)) {
- // #### why not use a mono image here????
- QImage pattern(DITHER_SIZE, DITHER_SIZE, QImage::Format_ARGB32);
- pattern.fill(0xffffffff);
- for (int y = 0; y < DITHER_SIZE; ++y) {
- for (int x = 0; x < DITHER_SIZE; ++x) {
- if (base_dither_matrix[x][y] <= alpha)
- pattern.setPixel(x, y, 0x00000000);
- }
- }
- pm = QBitmap::fromImage(pattern);
- pm.x11SetScreen(screen);
- QPixmapCache::insert(key, pm);
- }
- return pm;
-}
-
-#if !defined(QT_NO_XRENDER)
-
-class QXRenderTessellator : public QTessellator
-{
-public:
- QXRenderTessellator() : traps(0), allocated(0), size(0) {}
- ~QXRenderTessellator() { free(traps); }
- XTrapezoid *traps;
- int allocated;
- int size;
- void addTrap(const Trapezoid &trap);
- QRect tessellate(const QPointF *points, int nPoints, bool winding) {
- size = 0;
- setWinding(winding);
- return QTessellator::tessellate(points, nPoints).toRect();
- }
- void done() {
- if (allocated > 64) {
- free(traps);
- traps = 0;
- allocated = 0;
- }
- }
-};
-
-void QXRenderTessellator::addTrap(const Trapezoid &trap)
-{
- if (size == allocated) {
- allocated = qMax(2*allocated, 64);
- traps = q_check_ptr((XTrapezoid *)realloc(traps, allocated * sizeof(XTrapezoid)));
- }
- traps[size].top = Q27Dot5ToXFixed(trap.top);
- traps[size].bottom = Q27Dot5ToXFixed(trap.bottom);
- traps[size].left.p1.x = Q27Dot5ToXFixed(trap.topLeft->x);
- traps[size].left.p1.y = Q27Dot5ToXFixed(trap.topLeft->y);
- traps[size].left.p2.x = Q27Dot5ToXFixed(trap.bottomLeft->x);
- traps[size].left.p2.y = Q27Dot5ToXFixed(trap.bottomLeft->y);
- traps[size].right.p1.x = Q27Dot5ToXFixed(trap.topRight->x);
- traps[size].right.p1.y = Q27Dot5ToXFixed(trap.topRight->y);
- traps[size].right.p2.x = Q27Dot5ToXFixed(trap.bottomRight->x);
- traps[size].right.p2.y = Q27Dot5ToXFixed(trap.bottomRight->y);
- ++size;
-}
-
-#endif // !defined(QT_NO_XRENDER)
-
-
-#ifndef QT_NO_XRENDER
-static Picture getPatternFill(int screen, const QBrush &b)
-{
- if (!X11->use_xrender)
- return XNone;
-
- XRenderColor color = X11->preMultiply(b.color());
- XRenderColor bg_color;
-
- bg_color = X11->preMultiply(QColor(0, 0, 0, 0));
-
- for (int i = 0; i < X11->pattern_fill_count; ++i) {
- if (X11->pattern_fills[i].screen == screen
- && X11->pattern_fills[i].opaque == false
- && X11->pattern_fills[i].style == b.style()
- && X11->pattern_fills[i].color.alpha == color.alpha
- && X11->pattern_fills[i].color.red == color.red
- && X11->pattern_fills[i].color.green == color.green
- && X11->pattern_fills[i].color.blue == color.blue
- && X11->pattern_fills[i].bg_color.alpha == bg_color.alpha
- && X11->pattern_fills[i].bg_color.red == bg_color.red
- && X11->pattern_fills[i].bg_color.green == bg_color.green
- && X11->pattern_fills[i].bg_color.blue == bg_color.blue)
- return X11->pattern_fills[i].picture;
- }
- // none found, replace one
- int i = qrand() % 16;
-
- if (X11->pattern_fills[i].screen != screen && X11->pattern_fills[i].picture) {
- XRenderFreePicture (X11->display, X11->pattern_fills[i].picture);
- X11->pattern_fills[i].picture = 0;
- }
-
- if (!X11->pattern_fills[i].picture) {
- Pixmap pixmap = XCreatePixmap (X11->display, RootWindow (X11->display, screen), 8, 8, 32);
- XRenderPictureAttributes attrs;
- attrs.repeat = True;
- X11->pattern_fills[i].picture = XRenderCreatePicture (X11->display, pixmap,
- XRenderFindStandardFormat(X11->display, PictStandardARGB32),
- CPRepeat, &attrs);
- XFreePixmap (X11->display, pixmap);
- }
-
- X11->pattern_fills[i].screen = screen;
- X11->pattern_fills[i].color = color;
- X11->pattern_fills[i].bg_color = bg_color;
- X11->pattern_fills[i].opaque = false;
- X11->pattern_fills[i].style = b.style();
-
- XRenderFillRectangle(X11->display, PictOpSrc, X11->pattern_fills[i].picture, &bg_color, 0, 0, 8, 8);
-
- QPixmap pattern(qt_pixmapForBrush(b.style(), true));
- XRenderPictureAttributes attrs;
- attrs.repeat = true;
- XRenderChangePicture(X11->display, pattern.x11PictureHandle(), CPRepeat, &attrs);
-
- Picture fill_fg = X11->getSolidFill(screen, b.color());
- XRenderComposite(X11->display, PictOpOver, fill_fg, pattern.x11PictureHandle(),
- X11->pattern_fills[i].picture,
- 0, 0, 0, 0, 0, 0, 8, 8);
-
- return X11->pattern_fills[i].picture;
-}
-
-static void qt_render_bitmap(Display *dpy, int scrn, Picture src, Picture dst,
- int sx, int sy, int x, int y, int sw, int sh,
- const QPen &pen)
-{
- Picture fill_fg = X11->getSolidFill(scrn, pen.color());
- XRenderComposite(dpy, PictOpOver,
- fill_fg, src, dst, sx, sy, sx, sy, x, y, sw, sh);
-}
-#endif
-
-void QX11PaintEnginePrivate::init()
-{
- dpy = 0;
- scrn = 0;
- hd = 0;
- picture = 0;
- xinfo = 0;
-#ifndef QT_NO_XRENDER
- current_brush = 0;
- composition_mode = PictOpOver;
- tessellator = new QXRenderTessellator;
-#endif
-}
-
-void QX11PaintEnginePrivate::setupAdaptedOrigin(const QPoint &p)
-{
- if (adapted_pen_origin)
- XSetTSOrigin(dpy, gc, p.x(), p.y());
- if (adapted_brush_origin)
- XSetTSOrigin(dpy, gc_brush, p.x(), p.y());
-}
-
-void QX11PaintEnginePrivate::resetAdaptedOrigin()
-{
- if (adapted_pen_origin)
- XSetTSOrigin(dpy, gc, 0, 0);
- if (adapted_brush_origin)
- XSetTSOrigin(dpy, gc_brush, 0, 0);
-}
-
-void QX11PaintEnginePrivate::clipPolygon_dev(const QPolygonF &poly, QPolygonF *clipped_poly)
-{
- int clipped_count = 0;
- qt_float_point *clipped_points = 0;
- polygonClipper.clipPolygon((qt_float_point *) poly.data(), poly.size(),
- &clipped_points, &clipped_count);
- clipped_poly->resize(clipped_count);
- for (int i=0; i<clipped_count; ++i)
- (*clipped_poly)[i] = *((QPointF *)(&clipped_points[i]));
-}
-
-void QX11PaintEnginePrivate::systemStateChanged()
-{
- Q_Q(QX11PaintEngine);
- QPainter *painter = q->state ? static_cast<QPainterState *>(q->state)->painter : 0;
- if (painter && painter->hasClipping()) {
- if (q->testDirty(QPaintEngine::DirtyTransform))
- q->updateMatrix(q->state->transform());
- QPolygonF clip_poly_dev(matrix.map(painter->clipPath().toFillPolygon()));
- QPolygonF clipped_poly_dev;
- clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
- q->updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), Qt::ReplaceClip);
- } else {
- q->updateClipRegion_dev(QRegion(), Qt::NoClip);
- }
-}
-
-static QPaintEngine::PaintEngineFeatures qt_decide_features()
-{
- QPaintEngine::PaintEngineFeatures features =
- QPaintEngine::PrimitiveTransform
- | QPaintEngine::PatternBrush
- | QPaintEngine::AlphaBlend
- | QPaintEngine::PainterPaths
- | QPaintEngine::RasterOpModes;
-
- if (X11->use_xrender) {
- features |= QPaintEngine::Antialiasing;
- features |= QPaintEngine::PorterDuff;
- features |= QPaintEngine::MaskedBrush;
-#if 0
- if (X11->xrender_version > 10) {
- features |= QPaintEngine::LinearGradientFill;
- // ###
- }
-#endif
- }
-
- return features;
-}
-
-/*
- * QX11PaintEngine members
- */
-
-QX11PaintEngine::QX11PaintEngine()
- : QPaintEngine(*(new QX11PaintEnginePrivate), qt_decide_features())
-{
- d_func()->init();
-}
-
-QX11PaintEngine::QX11PaintEngine(QX11PaintEnginePrivate &dptr)
- : QPaintEngine(dptr, qt_decide_features())
-{
- d_func()->init();
-}
-
-QX11PaintEngine::~QX11PaintEngine()
-{
-#ifndef QT_NO_XRENDER
- Q_D(QX11PaintEngine);
- delete d->tessellator;
-#endif
-}
-
-bool QX11PaintEngine::begin(QPaintDevice *pdev)
-{
- Q_D(QX11PaintEngine);
- d->xinfo = qt_x11Info(pdev);
- QWidget *w = d->pdev->devType() == QInternal::Widget ? static_cast<QWidget *>(d->pdev) : 0;
- const bool isAlienWidget = w && !w->internalWinId() && w->testAttribute(Qt::WA_WState_Created);
-#ifndef QT_NO_XRENDER
- if (w) {
- if (isAlienWidget)
- d->picture = (::Picture)w->nativeParentWidget()->x11PictureHandle();
- else
- d->picture = (::Picture)w->x11PictureHandle();
- } else if (pdev->devType() == QInternal::Pixmap) {
- const QPixmap *pm = static_cast<const QPixmap *>(pdev);
- QX11PixmapData *data = static_cast<QX11PixmapData*>(pm->data.data());
- if (X11->use_xrender && data->depth() != 32 && data->x11_mask)
- data->convertToARGB32();
- d->picture = (::Picture)static_cast<const QPixmap *>(pdev)->x11PictureHandle();
- }
-#else
- d->picture = 0;
-#endif
- d->hd = !isAlienWidget ? qt_x11Handle(pdev) : qt_x11Handle(w->nativeParentWidget());
-
- Q_ASSERT(d->xinfo != 0);
- d->dpy = d->xinfo->display(); // get display variable
- d->scrn = d->xinfo->screen(); // get screen variable
-
- d->crgn = QRegion();
- d->gc = XCreateGC(d->dpy, d->hd, 0, 0);
- d->gc_brush = XCreateGC(d->dpy, d->hd, 0, 0);
- d->has_alpha_brush = false;
- d->has_alpha_pen = false;
- d->has_clipping = false;
- d->has_complex_xform = false;
- d->has_scaling_xform = false;
- d->has_non_scaling_xform = true;
- d->xform_scale = 1;
- d->has_custom_pen = false;
- d->matrix = QTransform();
- d->pdev_depth = d->pdev->depth();
- d->render_hints = 0;
- d->txop = QTransform::TxNone;
- d->use_path_fallback = false;
-#if !defined(QT_NO_XRENDER)
- d->composition_mode = PictOpOver;
-#endif
- d->xlibMaxLinePoints = 32762; // a safe number used to avoid, call to XMaxRequestSize(d->dpy) - 3;
- d->opacity = 1;
-
- // Set up the polygon clipper. Note: This will only work in
- // polyline mode as long as we have a buffer zone, since a
- // polyline may be clipped into several non-connected polylines.
- const int BUFFERZONE = 1000;
- QRect devClipRect(-BUFFERZONE, -BUFFERZONE,
- pdev->width() + 2*BUFFERZONE, pdev->height() + 2*BUFFERZONE);
- d->polygonClipper.setBoundingRect(devClipRect);
-
- if (isAlienWidget) {
- // Set system clip for alien widgets painting outside the paint event.
- // This is not a problem with native windows since the windowing system
- // will handle the clip.
- QWidgetPrivate *wd = w->d_func();
- QRegion widgetClip(wd->clipRect());
- wd->clipToEffectiveMask(widgetClip);
- wd->subtractOpaqueSiblings(widgetClip);
- widgetClip.translate(w->mapTo(w->nativeParentWidget(), QPoint()));
- setSystemClip(widgetClip);
- }
-
- QPixmap::x11SetDefaultScreen(d->xinfo->screen());
-
- if (w && w->testAttribute(Qt::WA_PaintUnclipped)) { // paint direct on device
- updatePen(QPen(Qt::black));
- updateBrush(QBrush(Qt::white), QPoint());
- XSetSubwindowMode(d->dpy, d->gc, IncludeInferiors);
- XSetSubwindowMode(d->dpy, d->gc_brush, IncludeInferiors);
-#ifndef QT_NO_XRENDER
- XRenderPictureAttributes attrs;
- attrs.subwindow_mode = IncludeInferiors;
- XRenderChangePicture(d->dpy, d->picture, CPSubwindowMode, &attrs);
-#endif
- }
-
- setDirty(QPaintEngine::DirtyClipRegion);
- setDirty(QPaintEngine::DirtyPen);
- setDirty(QPaintEngine::DirtyBrush);
- setDirty(QPaintEngine::DirtyBackground);
-
- return true;
-}
-
-bool QX11PaintEngine::end()
-{
- Q_D(QX11PaintEngine);
-
-#if !defined(QT_NO_XRENDER)
- if (d->picture) {
- // reset clipping/subwindow mode on our render picture
- XRenderPictureAttributes attrs;
- attrs.subwindow_mode = ClipByChildren;
- attrs.clip_mask = XNone;
- XRenderChangePicture(d->dpy, d->picture, CPClipMask|CPSubwindowMode, &attrs);
- }
-#endif
-
- if (d->gc_brush && d->pdev->painters < 2) {
- XFreeGC(d->dpy, d->gc_brush);
- d->gc_brush = 0;
- }
-
- if (d->gc && d->pdev->painters < 2) {
- XFreeGC(d->dpy, d->gc);
- d->gc = 0;
- }
-
- // Restore system clip for alien widgets painting outside the paint event.
- if (d->pdev->devType() == QInternal::Widget && !static_cast<QWidget *>(d->pdev)->internalWinId())
- setSystemClip(QRegion());
-
- return true;
-}
-
-static bool clipLine(QLineF *line, const QRect &rect)
-{
- qreal x1 = line->x1();
- qreal x2 = line->x2();
- qreal y1 = line->y1();
- qreal y2 = line->y2();
-
- qreal left = rect.x();
- qreal right = rect.x() + rect.width() - 1;
- qreal top = rect.y();
- qreal bottom = rect.y() + rect.height() - 1;
-
- enum { Left, Right, Top, Bottom };
- // clip the lines, after cohen-sutherland, see e.g. http://www.nondot.org/~sabre/graphpro/line6.html
- int p1 = ((x1 < left) << Left)
- | ((x1 > right) << Right)
- | ((y1 < top) << Top)
- | ((y1 > bottom) << Bottom);
- int p2 = ((x2 < left) << Left)
- | ((x2 > right) << Right)
- | ((y2 < top) << Top)
- | ((y2 > bottom) << Bottom);
-
- if (p1 & p2)
- // completely outside
- return false;
-
- if (p1 | p2) {
- qreal dx = x2 - x1;
- qreal dy = y2 - y1;
-
- // clip x coordinates
- if (x1 < left) {
- y1 += dy/dx * (left - x1);
- x1 = left;
- } else if (x1 > right) {
- y1 -= dy/dx * (x1 - right);
- x1 = right;
- }
- if (x2 < left) {
- y2 += dy/dx * (left - x2);
- x2 = left;
- } else if (x2 > right) {
- y2 -= dy/dx * (x2 - right);
- x2 = right;
- }
- p1 = ((y1 < top) << Top)
- | ((y1 > bottom) << Bottom);
- p2 = ((y2 < top) << Top)
- | ((y2 > bottom) << Bottom);
- if (p1 & p2)
- return false;
- // clip y coordinates
- if (y1 < top) {
- x1 += dx/dy * (top - y1);
- y1 = top;
- } else if (y1 > bottom) {
- x1 -= dx/dy * (y1 - bottom);
- y1 = bottom;
- }
- if (y2 < top) {
- x2 += dx/dy * (top - y2);
- y2 = top;
- } else if (y2 > bottom) {
- x2 -= dx/dy * (y2 - bottom);
- y2 = bottom;
- }
- *line = QLineF(QPointF(x1, y1), QPointF(x2, y2));
- }
- return true;
-}
-
-void QX11PaintEngine::drawLines(const QLine *lines, int lineCount)
-{
- Q_ASSERT(lines);
- Q_ASSERT(lineCount);
- Q_D(QX11PaintEngine);
- if (d->has_alpha_brush
- || d->has_alpha_pen
- || d->has_custom_pen
- || (d->cpen.widthF() > 0 && d->has_complex_xform
- && !d->has_non_scaling_xform)
- || (d->render_hints & QPainter::Antialiasing)) {
- for (int i = 0; i < lineCount; ++i) {
- QPainterPath path(lines[i].p1());
- path.lineTo(lines[i].p2());
- drawPath(path);
- }
- return;
- }
-
- if (d->has_pen) {
- for (int i = 0; i < lineCount; ++i) {
- QLineF linef;
- if (d->txop == QTransform::TxNone) {
- linef = lines[i];
- } else {
- linef = d->matrix.map(QLineF(lines[i]));
- }
- if (clipLine(&linef, d->polygonClipper.boundingRect())) {
- int x1 = qRound(linef.x1() + aliasedCoordinateDelta);
- int y1 = qRound(linef.y1() + aliasedCoordinateDelta);
- int x2 = qRound(linef.x2() + aliasedCoordinateDelta);
- int y2 = qRound(linef.y2() + aliasedCoordinateDelta);
-
- XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2);
- }
- }
- }
-}
-
-void QX11PaintEngine::drawLines(const QLineF *lines, int lineCount)
-{
- Q_ASSERT(lines);
- Q_ASSERT(lineCount);
- Q_D(QX11PaintEngine);
- if (d->has_alpha_brush
- || d->has_alpha_pen
- || d->has_custom_pen
- || (d->cpen.widthF() > 0 && d->has_complex_xform
- && !d->has_non_scaling_xform)
- || (d->render_hints & QPainter::Antialiasing)) {
- for (int i = 0; i < lineCount; ++i) {
- QPainterPath path(lines[i].p1());
- path.lineTo(lines[i].p2());
- drawPath(path);
- }
- return;
- }
-
- if (d->has_pen) {
- for (int i = 0; i < lineCount; ++i) {
- QLineF linef = d->matrix.map(lines[i]);
- if (clipLine(&linef, d->polygonClipper.boundingRect())) {
- int x1 = qRound(linef.x1() + aliasedCoordinateDelta);
- int y1 = qRound(linef.y1() + aliasedCoordinateDelta);
- int x2 = qRound(linef.x2() + aliasedCoordinateDelta);
- int y2 = qRound(linef.y2() + aliasedCoordinateDelta);
-
- XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2);
- }
- }
- }
-}
-
-static inline QLine clipStraightLine(const QRect &clip, const QLine &l)
-{
- if (l.p1().x() == l.p2().x()) {
- int x = qBound(clip.left(), l.p1().x(), clip.right());
- int y1 = qBound(clip.top(), l.p1().y(), clip.bottom());
- int y2 = qBound(clip.top(), l.p2().y(), clip.bottom());
-
- return QLine(x, y1, x, y2);
- } else {
- Q_ASSERT(l.p1().y() == l.p2().y());
-
- int x1 = qBound(clip.left(), l.p1().x(), clip.right());
- int x2 = qBound(clip.left(), l.p2().x(), clip.right());
- int y = qBound(clip.top(), l.p1().y(), clip.bottom());
-
- return QLine(x1, y, x2, y);
- }
-}
-
-void QX11PaintEngine::drawRects(const QRectF *rects, int rectCount)
-{
- Q_D(QX11PaintEngine);
- Q_ASSERT(rects);
- Q_ASSERT(rectCount);
-
- if (rectCount != 1
- || d->has_pen
- || d->has_alpha_brush
- || d->has_complex_xform
- || d->has_custom_pen
- || d->cbrush.style() != Qt::SolidPattern)
- {
- QPaintEngine::drawRects(rects, rectCount);
- return;
- }
-
- QPoint alignedOffset;
- if (d->txop == QTransform::TxTranslate) {
- QPointF offset(d->matrix.dx(), d->matrix.dy());
- alignedOffset = offset.toPoint();
- if (offset != QPointF(alignedOffset)) {
- QPaintEngine::drawRects(rects, rectCount);
- return;
- }
- }
-
- const QRectF& r = rects[0];
- QRect alignedRect = r.toAlignedRect();
- if (r != QRectF(alignedRect)) {
- QPaintEngine::drawRects(rects, rectCount);
- return;
- }
- alignedRect.translate(alignedOffset);
-
- QRect clip(d->polygonClipper.boundingRect());
- alignedRect = alignedRect.intersected(clip);
- if (alignedRect.isEmpty())
- return;
-
- // simple-case:
- // the rectangle is pixel-aligned
- // the fill brush is just a solid non-alpha color
- // the painter transform is only integer translation
- // ignore: antialiasing and just XFillRectangles directly
- XRectangle xrect;
- xrect.x = short(alignedRect.x());
- xrect.y = short(alignedRect.y());
- xrect.width = ushort(alignedRect.width());
- xrect.height = ushort(alignedRect.height());
- XFillRectangles(d->dpy, d->hd, d->gc_brush, &xrect, 1);
-}
-
-void QX11PaintEngine::drawRects(const QRect *rects, int rectCount)
-{
- Q_D(QX11PaintEngine);
- Q_ASSERT(rects);
- Q_ASSERT(rectCount);
-
- if (d->has_alpha_pen
- || d->has_complex_xform
- || d->has_custom_pen
- || (d->render_hints & QPainter::Antialiasing))
- {
- for (int i = 0; i < rectCount; ++i) {
- QPainterPath path;
- path.addRect(rects[i]);
- drawPath(path);
- }
- return;
- }
-
- QRect clip(d->polygonClipper.boundingRect());
- QPoint offset(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
-#if !defined(QT_NO_XRENDER)
- ::Picture pict = d->picture;
-
- if (X11->use_xrender && pict && d->has_brush && d->pdev_depth != 1
- && (d->has_texture || d->has_alpha_brush))
- {
- XRenderColor xc;
- if (!d->has_texture && !d->has_pattern)
- xc = X11->preMultiply(d->cbrush.color());
-
- for (int i = 0; i < rectCount; ++i) {
- QRect r(rects[i]);
- if (d->txop == QTransform::TxTranslate)
- r.translate(offset);
-
- if (r.width() == 0 || r.height() == 0) {
- if (d->has_pen) {
- const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
- XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
- }
- continue;
- }
-
- r = r.intersected(clip);
- if (r.isEmpty())
- continue;
- if (d->has_texture || d->has_pattern) {
- XRenderComposite(d->dpy, d->composition_mode, d->current_brush, 0, pict,
- qRound(r.x() - d->bg_origin.x()), qRound(r.y() - d->bg_origin.y()),
- 0, 0, r.x(), r.y(), r.width(), r.height());
- } else {
- XRenderFillRectangle(d->dpy, d->composition_mode, pict, &xc, r.x(), r.y(), r.width(), r.height());
- }
- if (d->has_pen)
- XDrawRectangle(d->dpy, d->hd, d->gc, r.x(), r.y(), r.width(), r.height());
- }
- } else
-#endif // !QT_NO_XRENDER
- {
- if (d->has_brush && d->has_pen) {
- for (int i = 0; i < rectCount; ++i) {
- QRect r(rects[i]);
- if (d->txop == QTransform::TxTranslate)
- r.translate(offset);
-
- if (r.width() == 0 || r.height() == 0) {
- const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
- XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
- continue;
- }
-
- r = r.intersected(clip);
- if (r.isEmpty())
- continue;
- d->setupAdaptedOrigin(r.topLeft());
- XFillRectangle(d->dpy, d->hd, d->gc_brush, r.x(), r.y(), r.width(), r.height());
- XDrawRectangle(d->dpy, d->hd, d->gc, r.x(), r.y(), r.width(), r.height());
- }
- d->resetAdaptedOrigin();
- } else {
- QVarLengthArray<XRectangle> xrects(rectCount);
- int numClipped = rectCount;
- for (int i = 0; i < rectCount; ++i) {
- QRect r(rects[i]);
- if (d->txop == QTransform::TxTranslate)
- r.translate(offset);
-
- if (r.width() == 0 || r.height() == 0) {
- --numClipped;
- if (d->has_pen) {
- const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
- XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
- }
- continue;
- }
-
- r = r.intersected(clip);
- if (r.isEmpty()) {
- --numClipped;
- continue;
- }
- xrects[i].x = short(r.x());
- xrects[i].y = short(r.y());
- xrects[i].width = ushort(r.width());
- xrects[i].height = ushort(r.height());
- }
- if (numClipped) {
- d->setupAdaptedOrigin(rects[0].topLeft());
- if (d->has_brush)
- XFillRectangles(d->dpy, d->hd, d->gc_brush, xrects.data(), numClipped);
- else if (d->has_pen)
- XDrawRectangles(d->dpy, d->hd, d->gc, xrects.data(), numClipped);
- d->resetAdaptedOrigin();
- }
- }
- }
-}
-
-static inline void setCapStyle(int cap_style, GC gc)
-{
- ulong mask = GCCapStyle;
- XGCValues vals;
- vals.cap_style = cap_style;
- XChangeGC(X11->display, gc, mask, &vals);
-}
-
-void QX11PaintEngine::drawPoints(const QPoint *points, int pointCount)
-{
- Q_ASSERT(points);
- Q_ASSERT(pointCount);
- Q_D(QX11PaintEngine);
-
- if (!d->has_pen)
- return;
-
- // use the same test here as in drawPath to ensure that we don't use the path fallback
- // and end up in XDrawLines for pens with width <= 1
- if (d->cpen.widthF() > 1.0f
- || (X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
- || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate))
- {
- Qt::PenCapStyle capStyle = d->cpen.capStyle();
- if (capStyle == Qt::FlatCap) {
- setCapStyle(CapProjecting, d->gc);
- d->cpen.setCapStyle(Qt::SquareCap);
- }
- const QPoint *end = points + pointCount;
- while (points < end) {
- QPainterPath path;
- path.moveTo(*points);
- path.lineTo(points->x()+.005, points->y());
- drawPath(path);
- ++points;
- }
-
- if (capStyle == Qt::FlatCap) {
- setCapStyle(CapButt, d->gc);
- d->cpen.setCapStyle(capStyle);
- }
- return;
- }
-
- static const int BUF_SIZE = 1024;
- XPoint xPoints[BUF_SIZE];
- int i = 0, j = 0;
- while (i < pointCount) {
- while (i < pointCount && j < BUF_SIZE) {
- const QPoint &xformed = d->matrix.map(points[i]);
- int x = xformed.x();
- int y = xformed.y();
- if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) {
- xPoints[j].x = x;
- xPoints[j].y = y;
- ++j;
- }
- ++i;
- }
- if (j)
- XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin);
-
- j = 0;
- }
-}
-
-void QX11PaintEngine::drawPoints(const QPointF *points, int pointCount)
-{
- Q_ASSERT(points);
- Q_ASSERT(pointCount);
- Q_D(QX11PaintEngine);
-
- if (!d->has_pen)
- return;
-
- // use the same test here as in drawPath to ensure that we don't use the path fallback
- // and end up in XDrawLines for pens with width <= 1
- if (d->cpen.widthF() > 1.0f
- || (X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
- || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate))
- {
- Qt::PenCapStyle capStyle = d->cpen.capStyle();
- if (capStyle == Qt::FlatCap) {
- setCapStyle(CapProjecting, d->gc);
- d->cpen.setCapStyle(Qt::SquareCap);
- }
-
- const QPointF *end = points + pointCount;
- while (points < end) {
- QPainterPath path;
- path.moveTo(*points);
- path.lineTo(points->x() + 0.005, points->y());
- drawPath(path);
- ++points;
- }
- if (capStyle == Qt::FlatCap) {
- setCapStyle(CapButt, d->gc);
- d->cpen.setCapStyle(capStyle);
- }
- return;
- }
-
- static const int BUF_SIZE = 1024;
- XPoint xPoints[BUF_SIZE];
- int i = 0, j = 0;
- while (i < pointCount) {
- while (i < pointCount && j < BUF_SIZE) {
- const QPointF &xformed = d->matrix.map(points[i]);
- int x = qFloor(xformed.x());
- int y = qFloor(xformed.y());
-
- if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) {
- xPoints[j].x = x;
- xPoints[j].y = y;
- ++j;
- }
- ++i;
- }
- if (j)
- XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin);
-
- j = 0;
- }
-}
-
-QPainter::RenderHints QX11PaintEngine::supportedRenderHints() const
-{
-#if !defined(QT_NO_XRENDER)
- if (X11->use_xrender)
- return QPainter::Antialiasing;
-#endif
- return QFlag(0);
-}
-
-void QX11PaintEngine::updateState(const QPaintEngineState &state)
-{
- Q_D(QX11PaintEngine);
- QPaintEngine::DirtyFlags flags = state.state();
-
-
- if (flags & DirtyOpacity) {
- d->opacity = state.opacity();
- // Force update pen/brush as to get proper alpha colors propagated
- flags |= DirtyPen;
- flags |= DirtyBrush;
- }
-
- if (flags & DirtyTransform) updateMatrix(state.transform());
- if (flags & DirtyPen) updatePen(state.pen());
- if (flags & (DirtyBrush | DirtyBrushOrigin)) updateBrush(state.brush(), state.brushOrigin());
- if (flags & DirtyFont) updateFont(state.font());
-
- if (state.state() & DirtyClipEnabled) {
- if (state.isClipEnabled()) {
- QPolygonF clip_poly_dev(d->matrix.map(painter()->clipPath().toFillPolygon()));
- QPolygonF clipped_poly_dev;
- d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
- updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), Qt::ReplaceClip);
- } else {
- updateClipRegion_dev(QRegion(), Qt::NoClip);
- }
- }
-
- if (flags & DirtyClipPath) {
- QPolygonF clip_poly_dev(d->matrix.map(state.clipPath().toFillPolygon()));
- QPolygonF clipped_poly_dev;
- d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
- updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon(), state.clipPath().fillRule()),
- state.clipOperation());
- } else if (flags & DirtyClipRegion) {
- extern QPainterPath qt_regionToPath(const QRegion &region);
- QPainterPath clip_path = qt_regionToPath(state.clipRegion());
- QPolygonF clip_poly_dev(d->matrix.map(clip_path.toFillPolygon()));
- QPolygonF clipped_poly_dev;
- d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
- updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), state.clipOperation());
- }
- if (flags & DirtyHints) updateRenderHints(state.renderHints());
- if (flags & DirtyCompositionMode) {
- int function = GXcopy;
- if (state.compositionMode() >= QPainter::RasterOp_SourceOrDestination) {
- switch (state.compositionMode()) {
- case QPainter::RasterOp_SourceOrDestination:
- function = GXor;
- break;
- case QPainter::RasterOp_SourceAndDestination:
- function = GXand;
- break;
- case QPainter::RasterOp_SourceXorDestination:
- function = GXxor;
- break;
- case QPainter::RasterOp_NotSourceAndNotDestination:
- function = GXnor;
- break;
- case QPainter::RasterOp_NotSourceOrNotDestination:
- function = GXnand;
- break;
- case QPainter::RasterOp_NotSourceXorDestination:
- function = GXequiv;
- break;
- case QPainter::RasterOp_NotSource:
- function = GXcopyInverted;
- break;
- case QPainter::RasterOp_SourceAndNotDestination:
- function = GXandReverse;
- break;
- case QPainter::RasterOp_NotSourceAndDestination:
- function = GXandInverted;
- break;
- default:
- function = GXcopy;
- }
- }
-#if !defined(QT_NO_XRENDER)
- else {
- d->composition_mode =
- qpainterOpToXrender(state.compositionMode());
- }
-#endif
- XSetFunction(X11->display, d->gc, function);
- XSetFunction(X11->display, d->gc_brush, function);
- }
- d->decidePathFallback();
- d->decideCoordAdjust();
-}
-
-void QX11PaintEngine::updateRenderHints(QPainter::RenderHints hints)
-{
- Q_D(QX11PaintEngine);
- d->render_hints = hints;
-
-#if !defined(QT_NO_XRENDER)
- if (X11->use_xrender && d->picture) {
- XRenderPictureAttributes attrs;
- attrs.poly_edge = (hints & QPainter::Antialiasing) ? PolyEdgeSmooth : PolyEdgeSharp;
- XRenderChangePicture(d->dpy, d->picture, CPPolyEdge, &attrs);
- }
-#endif
-}
-
-void QX11PaintEngine::updatePen(const QPen &pen)
-{
- Q_D(QX11PaintEngine);
- d->cpen = pen;
- int cp = CapButt;
- int jn = JoinMiter;
- int ps = pen.style();
-
- if (d->opacity < 1.0) {
- QColor c = d->cpen.color();
- c.setAlpha(qRound(c.alpha()*d->opacity));
- d->cpen.setColor(c);
- }
-
- d->has_pen = (ps != Qt::NoPen);
- d->has_alpha_pen = (pen.color().alpha() != 255);
-
- switch (pen.capStyle()) {
- case Qt::SquareCap:
- cp = CapProjecting;
- break;
- case Qt::RoundCap:
- cp = CapRound;
- break;
- case Qt::FlatCap:
- default:
- cp = CapButt;
- break;
- }
- switch (pen.joinStyle()) {
- case Qt::BevelJoin:
- jn = JoinBevel;
- break;
- case Qt::RoundJoin:
- jn = JoinRound;
- break;
- case Qt::MiterJoin:
- default:
- jn = JoinMiter;
- break;
- }
-
- d->adapted_pen_origin = false;
-
- char dashes[10]; // custom pen dashes
- int dash_len = 0; // length of dash list
- int xStyle = LineSolid;
-
- /*
- We are emulating Windows here. Windows treats cpen.width() == 1
- (or 0) as a very special case. The fudge variable unifies this
- case with the general case.
- */
- qreal pen_width = pen.widthF();
- int scale = qRound(pen_width < 1 ? 1 : pen_width);
- int space = (pen_width < 1 && pen_width > 0 ? 1 : (2 * scale));
- int dot = 1 * scale;
- int dash = 4 * scale;
-
- d->has_custom_pen = false;
-
- switch (ps) {
- case Qt::NoPen:
- case Qt::SolidLine:
- xStyle = LineSolid;
- break;
- case Qt::DashLine:
- dashes[0] = dash;
- dashes[1] = space;
- dash_len = 2;
- xStyle = LineOnOffDash;
- break;
- case Qt::DotLine:
- dashes[0] = dot;
- dashes[1] = space;
- dash_len = 2;
- xStyle = LineOnOffDash;
- break;
- case Qt::DashDotLine:
- dashes[0] = dash;
- dashes[1] = space;
- dashes[2] = dot;
- dashes[3] = space;
- dash_len = 4;
- xStyle = LineOnOffDash;
- break;
- case Qt::DashDotDotLine:
- dashes[0] = dash;
- dashes[1] = space;
- dashes[2] = dot;
- dashes[3] = space;
- dashes[4] = dot;
- dashes[5] = space;
- dash_len = 6;
- xStyle = LineOnOffDash;
- break;
- case Qt::CustomDashLine:
- d->has_custom_pen = true;
- break;
- }
-
- ulong mask = GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth
- | GCCapStyle | GCJoinStyle | GCLineStyle;
- XGCValues vals;
- vals.graphics_exposures = false;
- if (d->pdev_depth == 1) {
- vals.foreground = qGray(pen.color().rgb()) > 127 ? 0 : 1;
- vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1;
- } else if (d->pdev->devType() == QInternal::Pixmap && d->pdev_depth == 32
- && X11->use_xrender) {
- vals.foreground = pen.color().rgba();
- vals.background = QColor(Qt::transparent).rgba();
- } else {
- QColormap cmap = QColormap::instance(d->scrn);
- vals.foreground = cmap.pixel(pen.color());
- vals.background = cmap.pixel(QColor(Qt::transparent));
- }
-
-
- vals.line_width = qRound(pen.widthF());
- vals.cap_style = cp;
- vals.join_style = jn;
- vals.line_style = xStyle;
-
- XChangeGC(d->dpy, d->gc, mask, &vals);
-
- if (dash_len) { // make dash list
- XSetDashes(d->dpy, d->gc, 0, dashes, dash_len);
- }
-
- if (!d->has_clipping) { // if clipping is set the paintevent clip region is merged with the clip region
- QRegion sysClip = systemClip();
- if (!sysClip.isEmpty())
- x11SetClipRegion(d->dpy, d->gc, 0, d->picture, sysClip);
- else
- x11ClearClipRegion(d->dpy, d->gc, 0, d->picture);
- }
-}
-
-void QX11PaintEngine::updateBrush(const QBrush &brush, const QPointF &origin)
-{
- Q_D(QX11PaintEngine);
- d->cbrush = brush;
- d->bg_origin = origin;
- d->adapted_brush_origin = false;
-#if !defined(QT_NO_XRENDER)
- d->current_brush = 0;
-#endif
- if (d->opacity < 1.0) {
- QColor c = d->cbrush.color();
- c.setAlpha(qRound(c.alpha()*d->opacity));
- d->cbrush.setColor(c);
- }
-
- int s = FillSolid;
- int bs = d->cbrush.style();
- d->has_brush = (bs != Qt::NoBrush);
- d->has_pattern = bs >= Qt::Dense1Pattern && bs <= Qt::DiagCrossPattern;
- d->has_texture = bs == Qt::TexturePattern;
- d->has_alpha_brush = brush.color().alpha() != 255;
- d->has_alpha_texture = d->has_texture && d->cbrush.texture().hasAlphaChannel();
-
- ulong mask = GCForeground | GCBackground | GCGraphicsExposures
- | GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle;
- XGCValues vals;
- vals.graphics_exposures = false;
- if (d->pdev_depth == 1) {
- vals.foreground = qGray(d->cbrush.color().rgb()) > 127 ? 0 : 1;
- vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1;
- } else if (X11->use_xrender && d->pdev->devType() == QInternal::Pixmap
- && d->pdev_depth == 32) {
- vals.foreground = d->cbrush.color().rgba();
- vals.background = QColor(Qt::transparent).rgba();
- } else {
- QColormap cmap = QColormap::instance(d->scrn);
- vals.foreground = cmap.pixel(d->cbrush.color());
- vals.background = cmap.pixel(QColor(Qt::transparent));
-
- if (!X11->use_xrender && d->has_brush && !d->has_pattern && !brush.isOpaque()) {
- QPixmap pattern = qt_patternForAlpha(brush.color().alpha(), d->scrn);
- mask |= GCStipple;
- vals.stipple = pattern.handle();
- s = FillStippled;
- d->adapted_brush_origin = true;
- }
- }
- vals.cap_style = CapButt;
- vals.join_style = JoinMiter;
- vals.line_style = LineSolid;
-
- if (d->has_pattern || d->has_texture) {
- if (bs == Qt::TexturePattern) {
- d->brush_pm = qt_toX11Pixmap(d->cbrush.texture());
-#if !defined(QT_NO_XRENDER)
- if (X11->use_xrender) {
- XRenderPictureAttributes attrs;
- attrs.repeat = true;
- XRenderChangePicture(d->dpy, d->brush_pm.x11PictureHandle(), CPRepeat, &attrs);
- QX11PixmapData *data = static_cast<QX11PixmapData*>(d->brush_pm.data.data());
- if (data->mask_picture)
- XRenderChangePicture(d->dpy, data->mask_picture, CPRepeat, &attrs);
- }
-#endif
- } else {
- d->brush_pm = qt_toX11Pixmap(qt_pixmapForBrush(bs, true));
- }
- d->brush_pm.x11SetScreen(d->scrn);
- if (d->brush_pm.depth() == 1) {
- mask |= GCStipple;
- vals.stipple = d->brush_pm.handle();
- s = FillStippled;
-#if !defined(QT_NO_XRENDER)
- if (X11->use_xrender) {
- d->bitmap_texture = QPixmap(d->brush_pm.size());
- d->bitmap_texture.fill(Qt::transparent);
- d->bitmap_texture = qt_toX11Pixmap(d->bitmap_texture);
- d->bitmap_texture.x11SetScreen(d->scrn);
-
- ::Picture src = X11->getSolidFill(d->scrn, d->cbrush.color());
- XRenderComposite(d->dpy, PictOpSrc, src, d->brush_pm.x11PictureHandle(),
- d->bitmap_texture.x11PictureHandle(),
- 0, 0, d->brush_pm.width(), d->brush_pm.height(),
- 0, 0, d->brush_pm.width(), d->brush_pm.height());
-
- XRenderPictureAttributes attrs;
- attrs.repeat = true;
- XRenderChangePicture(d->dpy, d->bitmap_texture.x11PictureHandle(), CPRepeat, &attrs);
-
- d->current_brush = d->bitmap_texture.x11PictureHandle();
- }
-#endif
- } else {
- mask |= GCTile;
-#ifndef QT_NO_XRENDER
- if (d->pdev_depth == 32 && d->brush_pm.depth() != 32) {
- d->brush_pm.detach();
- QX11PixmapData *brushData = static_cast<QX11PixmapData*>(d->brush_pm.data.data());
- brushData->convertToARGB32();
- }
-#endif
- vals.tile = (d->brush_pm.depth() == d->pdev_depth
- ? d->brush_pm.handle()
- : static_cast<QX11PixmapData*>(d->brush_pm.data.data())->x11ConvertToDefaultDepth());
- s = FillTiled;
-#if !defined(QT_NO_XRENDER)
- d->current_brush = d->cbrush.texture().x11PictureHandle();
-#endif
- }
-
- mask |= GCTileStipXOrigin | GCTileStipYOrigin;
- vals.ts_x_origin = qRound(origin.x());
- vals.ts_y_origin = qRound(origin.y());
- }
-#if !defined(QT_NO_XRENDER)
- else if (d->has_alpha_brush) {
- d->current_brush = X11->getSolidFill(d->scrn, d->cbrush.color());
- }
-#endif
-
- vals.fill_style = s;
- XChangeGC(d->dpy, d->gc_brush, mask, &vals);
- if (!d->has_clipping) {
- QRegion sysClip = systemClip();
- if (!sysClip.isEmpty())
- x11SetClipRegion(d->dpy, d->gc_brush, 0, d->picture, sysClip);
- else
- x11ClearClipRegion(d->dpy, d->gc_brush, 0, d->picture);
- }
-}
-
-void QX11PaintEngine::drawEllipse(const QRectF &rect)
-{
- QRect aligned = rect.toAlignedRect();
- if (aligned == rect)
- drawEllipse(aligned);
- else
- QPaintEngine::drawEllipse(rect);
-}
-
-void QX11PaintEngine::drawEllipse(const QRect &rect)
-{
- if (rect.isEmpty()) {
- drawRects(&rect, 1);
- return;
- }
-
- Q_D(QX11PaintEngine);
- QRect devclip(SHRT_MIN, SHRT_MIN, SHRT_MAX*2 - 1, SHRT_MAX*2 - 1);
- QRect r(rect);
- if (d->txop < QTransform::TxRotate) {
- r = d->matrix.mapRect(rect);
- } else if (d->txop == QTransform::TxRotate && rect.width() == rect.height()) {
- QPainterPath path;
- path.addEllipse(rect);
- r = d->matrix.map(path).boundingRect().toRect();
- }
-
- if (d->has_alpha_brush || d->has_alpha_pen || d->has_custom_pen || (d->render_hints & QPainter::Antialiasing)
- || d->has_alpha_texture || devclip.intersected(r) != r
- || (d->has_complex_xform
- && !(d->has_non_scaling_xform && rect.width() == rect.height())))
- {
- QPainterPath path;
- path.addEllipse(rect);
- drawPath(path);
- return;
- }
-
- int x = r.x();
- int y = r.y();
- int w = r.width();
- int h = r.height();
- if (w < 1 || h < 1)
- return;
- if (w == 1 && h == 1) {
- XDrawPoint(d->dpy, d->hd, d->has_pen ? d->gc : d->gc_brush, x, y);
- return;
- }
- d->setupAdaptedOrigin(rect.topLeft());
- if (d->has_brush) { // draw filled ellipse
- XFillArc(d->dpy, d->hd, d->gc_brush, x, y, w, h, 0, 360*64);
- if (!d->has_pen) // make smoother outline
- XDrawArc(d->dpy, d->hd, d->gc_brush, x, y, w-1, h-1, 0, 360*64);
- }
- if (d->has_pen) // draw outline
- XDrawArc(d->dpy, d->hd, d->gc, x, y, w, h, 0, 360*64);
- d->resetAdaptedOrigin();
-}
-
-
-
-void QX11PaintEnginePrivate::fillPolygon_translated(const QPointF *polygonPoints, int pointCount,
- QX11PaintEnginePrivate::GCMode gcMode,
- QPaintEngine::PolygonDrawMode mode)
-{
-
- QVarLengthArray<QPointF> translated_points(pointCount);
- QPointF offset(matrix.dx(), matrix.dy());
-
- qreal offs = adjust_coords ? aliasedCoordinateDelta : 0.0;
- if (!X11->use_xrender || !(render_hints & QPainter::Antialiasing))
- offset += QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta);
-
- for (int i = 0; i < pointCount; ++i) {
- translated_points[i] = polygonPoints[i] + offset;
-
- translated_points[i].rx() = qRound(translated_points[i].x()) + offs;
- translated_points[i].ry() = qRound(translated_points[i].y()) + offs;
- }
-
- fillPolygon_dev(translated_points.data(), pointCount, gcMode, mode);
-}
-
-#ifndef QT_NO_XRENDER
-static void qt_XRenderCompositeTrapezoids(Display *dpy,
- int op,
- Picture src,
- Picture dst,
- _Xconst XRenderPictFormat *maskFormat,
- int xSrc,
- int ySrc,
- const XTrapezoid *traps, int size)
-{
- const int MAX_TRAPS = 50000;
- while (size) {
- int to_draw = size;
- if (to_draw > MAX_TRAPS)
- to_draw = MAX_TRAPS;
- XRenderCompositeTrapezoids(dpy, op, src, dst,
- maskFormat,
- xSrc, ySrc,
- traps, to_draw);
- size -= to_draw;
- traps += to_draw;
- }
-}
-#endif
-
-void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int pointCount,
- QX11PaintEnginePrivate::GCMode gcMode,
- QPaintEngine::PolygonDrawMode mode)
-{
- Q_Q(QX11PaintEngine);
-
- int clippedCount = 0;
- qt_float_point *clippedPoints = 0;
-
-#ifndef QT_NO_XRENDER
- //can change if we switch to pen if gcMode != BrushGC
- bool has_fill_texture = has_texture;
- bool has_fill_pattern = has_pattern;
- ::Picture src;
-#endif
- QBrush fill;
- GC fill_gc;
- if (gcMode == BrushGC) {
- fill = cbrush;
- fill_gc = gc_brush;
-#ifndef QT_NO_XRENDER
- if (current_brush)
- src = current_brush;
- else
- src = X11->getSolidFill(scrn, fill.color());
-#endif
- } else {
- fill = QBrush(cpen.brush());
- fill_gc = gc;
-#ifndef QT_NO_XRENDER
- //we use the pens brush
- has_fill_texture = (fill.style() == Qt::TexturePattern);
- has_fill_pattern = (fill.style() >= Qt::Dense1Pattern && fill.style() <= Qt::DiagCrossPattern);
- if (has_fill_texture)
- src = fill.texture().x11PictureHandle();
- else if (has_fill_pattern)
- src = getPatternFill(scrn, fill);
- else
- src = X11->getSolidFill(scrn, fill.color());
-#endif
- }
-
- polygonClipper.clipPolygon((qt_float_point *) polygonPoints, pointCount,
- &clippedPoints, &clippedCount);
-
-#ifndef QT_NO_XRENDER
- bool solid_fill = fill.color().alpha() == 255;
- if (has_fill_texture && fill.texture().depth() == 1 && solid_fill) {
- has_fill_texture = false;
- has_fill_pattern = true;
- }
-
- bool antialias = render_hints & QPainter::Antialiasing;
-
- if (X11->use_xrender
- && picture
- && !has_fill_pattern
- && (clippedCount > 0)
- && (fill.style() != Qt::NoBrush)
- && ((has_fill_texture && fill.texture().hasAlpha()) || antialias || !solid_fill || has_alpha_pen != has_alpha_brush))
- {
- if (tessellator->size > 0) {
- XRenderPictureAttributes attrs;
- attrs.poly_edge = antialias ? PolyEdgeSmooth : PolyEdgeSharp;
- XRenderChangePicture(dpy, picture, CPPolyEdge, &attrs);
- int x_offset = int(XFixedToDouble(tessellator->traps[0].left.p1.x) - bg_origin.x());
- int y_offset = int(XFixedToDouble(tessellator->traps[0].left.p1.y) - bg_origin.y());
- qt_XRenderCompositeTrapezoids(dpy, composition_mode, src, picture,
- antialias
- ? XRenderFindStandardFormat(dpy, PictStandardA8)
- : XRenderFindStandardFormat(dpy, PictStandardA1),
- x_offset, y_offset,
- tessellator->traps, tessellator->size);
- tessellator->done();
- }
- } else
-#endif
- if (fill.style() != Qt::NoBrush) {
- if (clippedCount > 200000) {
- QPolygon poly;
- for (int i = 0; i < clippedCount; ++i)
- poly << QPoint(qFloor(clippedPoints[i].x), qFloor(clippedPoints[i].y));
-
- const QRect bounds = poly.boundingRect();
- const QRect aligned = bounds
- & QRect(QPoint(), QSize(pdev->width(), pdev->height()));
-
- QImage img(aligned.size(), QImage::Format_ARGB32_Premultiplied);
- img.fill(0);
-
- QPainter painter(&img);
- painter.translate(-aligned.x(), -aligned.y());
- painter.setPen(Qt::NoPen);
- painter.setBrush(fill);
- if (gcMode == BrushGC)
- painter.setBrushOrigin(q->painter()->brushOrigin());
- painter.drawPolygon(poly);
- painter.end();
-
- q->drawImage(aligned, img, img.rect(), Qt::AutoColor);
- } else if (clippedCount > 0) {
- QVarLengthArray<XPoint> xpoints(clippedCount);
- for (int i = 0; i < clippedCount; ++i) {
- xpoints[i].x = qFloor(clippedPoints[i].x);
- xpoints[i].y = qFloor(clippedPoints[i].y);
- }
- if (mode == QPaintEngine::WindingMode)
- XSetFillRule(dpy, fill_gc, WindingRule);
- setupAdaptedOrigin(QPoint(xpoints[0].x, xpoints[0].y));
- XFillPolygon(dpy, hd, fill_gc,
- xpoints.data(), clippedCount,
- mode == QPaintEngine::ConvexMode ? Convex : Complex, CoordModeOrigin);
- resetAdaptedOrigin();
- if (mode == QPaintEngine::WindingMode)
- XSetFillRule(dpy, fill_gc, EvenOddRule);
- }
- }
-}
-
-void QX11PaintEnginePrivate::strokePolygon_translated(const QPointF *polygonPoints, int pointCount, bool close)
-{
- QVarLengthArray<QPointF> translated_points(pointCount);
- QPointF offset(matrix.dx(), matrix.dy());
- for (int i = 0; i < pointCount; ++i)
- translated_points[i] = polygonPoints[i] + offset;
- strokePolygon_dev(translated_points.data(), pointCount, close);
-}
-
-void QX11PaintEnginePrivate::strokePolygon_dev(const QPointF *polygonPoints, int pointCount, bool close)
-{
- int clippedCount = 0;
- qt_float_point *clippedPoints = 0;
- polygonClipper.clipPolygon((qt_float_point *) polygonPoints, pointCount,
- &clippedPoints, &clippedCount, close);
-
- if (clippedCount > 0) {
- QVarLengthArray<XPoint> xpoints(clippedCount);
- for (int i = 0; i < clippedCount; ++i) {
- xpoints[i].x = qRound(clippedPoints[i].x + aliasedCoordinateDelta);
- xpoints[i].y = qRound(clippedPoints[i].y + aliasedCoordinateDelta);
- }
- uint numberPoints = qMin(clippedCount, xlibMaxLinePoints);
- XPoint *pts = xpoints.data();
- XDrawLines(dpy, hd, gc, pts, numberPoints, CoordModeOrigin);
- pts += numberPoints;
- clippedCount -= numberPoints;
- numberPoints = qMin(clippedCount, xlibMaxLinePoints-1);
- while (clippedCount) {
- XDrawLines(dpy, hd, gc, pts-1, numberPoints+1, CoordModeOrigin);
- pts += numberPoints;
- clippedCount -= numberPoints;
- numberPoints = qMin(clippedCount, xlibMaxLinePoints-1);
- }
- }
-}
-
-void QX11PaintEngine::drawPolygon(const QPointF *polygonPoints, int pointCount, PolygonDrawMode mode)
-{
- Q_D(QX11PaintEngine);
- if (d->use_path_fallback) {
- QPainterPath path(polygonPoints[0]);
- for (int i = 1; i < pointCount; ++i)
- path.lineTo(polygonPoints[i]);
- if (mode == PolylineMode) {
- QBrush oldBrush = d->cbrush;
- d->cbrush = QBrush(Qt::NoBrush);
- path.setFillRule(Qt::WindingFill);
- drawPath(path);
- d->cbrush = oldBrush;
- } else {
- path.setFillRule(mode == OddEvenMode ? Qt::OddEvenFill : Qt::WindingFill);
- path.closeSubpath();
- drawPath(path);
- }
- return;
- }
- if (mode != PolylineMode && d->has_brush)
- d->fillPolygon_translated(polygonPoints, pointCount, QX11PaintEnginePrivate::BrushGC, mode);
-
- if (d->has_pen)
- d->strokePolygon_translated(polygonPoints, pointCount, mode != PolylineMode);
-}
-
-
-void QX11PaintEnginePrivate::fillPath(const QPainterPath &path, QX11PaintEnginePrivate::GCMode gc_mode, bool transform)
-{
- qreal offs = adjust_coords ? aliasedCoordinateDelta : 0.0;
-
- QPainterPath clippedPath;
- QPainterPath clipPath;
- clipPath.addRect(polygonClipper.boundingRect());
-
- if (transform)
- clippedPath = (path*matrix).intersected(clipPath);
- else
- clippedPath = path.intersected(clipPath);
-
- QList<QPolygonF> polys = clippedPath.toFillPolygons();
- for (int i = 0; i < polys.size(); ++i) {
- QVarLengthArray<QPointF> translated_points(polys.at(i).size());
-
- for (int j = 0; j < polys.at(i).size(); ++j) {
- translated_points[j] = polys.at(i).at(j);
- if (!X11->use_xrender || !(render_hints & QPainter::Antialiasing)) {
- translated_points[j].rx() = qRound(translated_points[j].rx() + aliasedCoordinateDelta) + offs;
- translated_points[j].ry() = qRound(translated_points[j].ry() + aliasedCoordinateDelta) + offs;
- }
- }
-
- fillPolygon_dev(translated_points.data(), polys.at(i).size(), gc_mode,
- path.fillRule() == Qt::OddEvenFill ? QPaintEngine::OddEvenMode : QPaintEngine::WindingMode);
- }
-}
-
-void QX11PaintEngine::drawPath(const QPainterPath &path)
-{
- Q_D(QX11PaintEngine);
- if (path.isEmpty())
- return;
-
- if (d->has_brush)
- d->fillPath(path, QX11PaintEnginePrivate::BrushGC, true);
- if (d->has_pen
- && ((X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
- || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate
- && !d->has_non_scaling_xform)
- || (d->cpen.style() == Qt::CustomDashLine))) {
- QPainterPathStroker stroker;
- if (d->cpen.style() == Qt::CustomDashLine) {
- stroker.setDashPattern(d->cpen.dashPattern());
- stroker.setDashOffset(d->cpen.dashOffset());
- } else {
- stroker.setDashPattern(d->cpen.style());
- }
- stroker.setCapStyle(d->cpen.capStyle());
- stroker.setJoinStyle(d->cpen.joinStyle());
- QPainterPath stroke;
- qreal width = d->cpen.widthF();
- QPolygonF poly;
- QRectF deviceRect(0, 0, d->pdev->width(), d->pdev->height());
- // necessary to get aliased alphablended primitives to be drawn correctly
- if (d->cpen.isCosmetic() || d->has_scaling_xform) {
- if (d->cpen.isCosmetic())
- stroker.setWidth(width == 0 ? 1 : width);
- else
- stroker.setWidth(width * d->xform_scale);
- stroker.d_ptr->stroker.setClipRect(deviceRect);
- stroke = stroker.createStroke(path * d->matrix);
- if (stroke.isEmpty())
- return;
- stroke.setFillRule(Qt::WindingFill);
- d->fillPath(stroke, QX11PaintEnginePrivate::PenGC, false);
- } else {
- stroker.setWidth(width);
- stroker.d_ptr->stroker.setClipRect(d->matrix.inverted().mapRect(deviceRect));
- stroke = stroker.createStroke(path);
- if (stroke.isEmpty())
- return;
- stroke.setFillRule(Qt::WindingFill);
- d->fillPath(stroke, QX11PaintEnginePrivate::PenGC, true);
- }
- } else if (d->has_pen) {
- // if we have a cosmetic pen - use XDrawLine() for speed
- QList<QPolygonF> polys = path.toSubpathPolygons(d->matrix);
- for (int i = 0; i < polys.size(); ++i)
- d->strokePolygon_dev(polys.at(i).data(), polys.at(i).size(), false);
- }
-}
-
-Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image,
- Drawable hd, GC gc, Display *dpy, Visual *visual, int depth)
-{
- Q_ASSERT(image.format() == QImage::Format_RGB32);
- Q_ASSERT(image.depth() == 32);
-
- XImage *xi;
- // Note: this code assumes either RGB or BGR, 8 bpc server layouts
- const uint red_mask = (uint) visual->red_mask;
- bool bgr_layout = (red_mask == 0xff);
-
- const int w = rect.width();
- const int h = rect.height();
-
- QImage im;
- int image_byte_order = ImageByteOrder(X11->display);
- if ((QSysInfo::ByteOrder == QSysInfo::BigEndian && ((image_byte_order == LSBFirst) || bgr_layout))
- || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)
- || (image_byte_order == LSBFirst && bgr_layout))
- {
- im = image.copy(rect);
- const int iw = im.bytesPerLine() / 4;
- uint *data = (uint *)im.bits();
- for (int i=0; i < h; i++) {
- uint *p = data;
- uint *end = p + w;
- if (bgr_layout && image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
- while (p < end) {
- *p = ((*p << 8) & 0xffffff00) | ((*p >> 24) & 0x000000ff);
- p++;
- }
- } else if ((image_byte_order == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
- || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
- while (p < end) {
- *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
- | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
- p++;
- }
- } else if ((image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
- || (image_byte_order == LSBFirst && bgr_layout))
- {
- while (p < end) {
- *p = ((*p << 16) & 0x00ff0000) | ((*p >> 16) & 0x000000ff)
- | ((*p ) & 0xff00ff00);
- p++;
- }
- }
- data += iw;
- }
- xi = XCreateImage(dpy, visual, depth, ZPixmap,
- 0, (char *) im.bits(), w, h, 32, im.bytesPerLine());
- } else {
- xi = XCreateImage(dpy, visual, depth, ZPixmap,
- 0, (char *) image.scanLine(rect.y())+rect.x()*sizeof(uint), w, h, 32, image.bytesPerLine());
- }
- XPutImage(dpy, hd, gc, xi, 0, 0, pos.x(), pos.y(), w, h);
- xi->data = 0; // QImage owns these bits
- XDestroyImage(xi);
-}
-
-void QX11PaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags flags)
-{
- Q_D(QX11PaintEngine);
-
- if (image.format() == QImage::Format_RGB32
- && d->pdev_depth >= 24 && image.depth() == 32
- && r.size() == sr.size())
- {
- int sx = qRound(sr.x());
- int sy = qRound(sr.y());
- int x = qRound(r.x());
- int y = qRound(r.y());
- int w = qRound(r.width());
- int h = qRound(r.height());
-
- qt_x11_drawImage(QRect(sx, sy, w, h), QPoint(x, y), image, d->hd, d->gc, d->dpy,
- (Visual *)d->xinfo->visual(), d->pdev_depth);
- } else {
- QPaintEngine::drawImage(r, image, sr, flags);
- }
-}
-
-void QX11PaintEngine::drawPixmap(const QRectF &r, const QPixmap &px, const QRectF &_sr)
-{
- Q_D(QX11PaintEngine);
- QRectF sr = _sr;
- int x = qRound(r.x());
- int y = qRound(r.y());
- int sx = qRound(sr.x());
- int sy = qRound(sr.y());
- int sw = qRound(sr.width());
- int sh = qRound(sr.height());
-
- QPixmap pixmap = qt_toX11Pixmap(px);
- if(pixmap.isNull())
- return;
-
- if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen())
- || (pixmap.x11Info().screen() != DefaultScreen(X11->display))) {
- QPixmap* p = const_cast<QPixmap *>(&pixmap);
- p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(X11->display));
- }
-
- QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
-
-#ifndef QT_NO_XRENDER
- ::Picture src_pict = static_cast<QX11PixmapData*>(pixmap.data.data())->picture;
- if (src_pict && d->picture) {
- const int pDepth = pixmap.depth();
- if (pDepth == 1 && (d->has_alpha_pen)) {
- qt_render_bitmap(d->dpy, d->scrn, src_pict, d->picture,
- sx, sy, x, y, sw, sh, d->cpen);
- return;
- } else if (pDepth != 1 && (pDepth == 32 || pDepth != d->pdev_depth)) {
- XRenderComposite(d->dpy, d->composition_mode,
- src_pict, 0, d->picture, sx, sy, 0, 0, x, y, sw, sh);
- return;
- }
- }
-#endif
-
- bool mono_src = pixmap.depth() == 1;
- bool mono_dst = d->pdev_depth == 1;
- bool restore_clip = false;
-
- if (static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) { // pixmap has a mask
- QBitmap comb(sw, sh);
- GC cgc = XCreateGC(d->dpy, comb.handle(), 0, 0);
- XSetForeground(d->dpy, cgc, 0);
- XFillRectangle(d->dpy, comb.handle(), cgc, 0, 0, sw, sh);
- XSetBackground(d->dpy, cgc, 0);
- XSetForeground(d->dpy, cgc, 1);
- if (!d->crgn.isEmpty()) {
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
- XSetClipRectangles(d->dpy, cgc, -x, -y, rects, num, Unsorted);
- } else if (d->has_clipping) {
- XSetClipRectangles(d->dpy, cgc, 0, 0, 0, 0, Unsorted);
- }
- XSetFillStyle(d->dpy, cgc, FillOpaqueStippled);
- XSetTSOrigin(d->dpy, cgc, -sx, -sy);
- XSetStipple(d->dpy, cgc,
- static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask);
- XFillRectangle(d->dpy, comb.handle(), cgc, 0, 0, sw, sh);
- XFreeGC(d->dpy, cgc);
-
- XSetClipOrigin(d->dpy, d->gc, x, y);
- XSetClipMask(d->dpy, d->gc, comb.handle());
- restore_clip = true;
- }
-
- if (mono_src) {
- if (!d->crgn.isEmpty()) {
- Pixmap comb = XCreatePixmap(d->dpy, d->hd, sw, sh, 1);
- GC cgc = XCreateGC(d->dpy, comb, 0, 0);
- XSetForeground(d->dpy, cgc, 0);
- XFillRectangle(d->dpy, comb, cgc, 0, 0, sw, sh);
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
- XSetClipRectangles(d->dpy, cgc, -x, -y, rects, num, Unsorted);
- XCopyArea(d->dpy, pixmap.handle(), comb, cgc, sx, sy, sw, sh, 0, 0);
- XFreeGC(d->dpy, cgc);
-
- XSetClipMask(d->dpy, d->gc, comb);
- XSetClipOrigin(d->dpy, d->gc, x, y);
- XFreePixmap(d->dpy, comb);
- } else {
- XSetClipMask(d->dpy, d->gc, pixmap.handle());
- XSetClipOrigin(d->dpy, d->gc, x - sx, y - sy);
- }
-
- if (mono_dst) {
- XSetForeground(d->dpy, d->gc, qGray(d->cpen.color().rgb()) > 127 ? 0 : 1);
- } else {
- QColormap cmap = QColormap::instance(d->scrn);
- XSetForeground(d->dpy, d->gc, cmap.pixel(d->cpen.color()));
- }
- XFillRectangle(d->dpy, d->hd, d->gc, x, y, sw, sh);
- restore_clip = true;
- } else if (mono_dst && !mono_src) {
- QBitmap bitmap(pixmap);
- XCopyArea(d->dpy, bitmap.handle(), d->hd, d->gc, sx, sy, sw, sh, x, y);
- } else {
- XCopyArea(d->dpy, pixmap.handle(), d->hd, d->gc, sx, sy, sw, sh, x, y);
- }
-
- if (d->pdev->devType() == QInternal::Pixmap) {
- const QPixmap *px = static_cast<const QPixmap*>(d->pdev);
- Pixmap src_mask = static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask;
- Pixmap dst_mask = static_cast<QX11PixmapData*>(px->data.data())->x11_mask;
- if (dst_mask) {
- GC cgc = XCreateGC(d->dpy, dst_mask, 0, 0);
- if (src_mask) { // copy src mask into dst mask
- XCopyArea(d->dpy, src_mask, dst_mask, cgc, sx, sy, sw, sh, x, y);
- } else { // no src mask, but make sure the area copied is opaque in dest
- XSetBackground(d->dpy, cgc, 0);
- XSetForeground(d->dpy, cgc, 1);
- XFillRectangle(d->dpy, dst_mask, cgc, x, y, sw, sh);
- }
- XFreeGC(d->dpy, cgc);
- }
- }
-
- if (restore_clip) {
- XSetClipOrigin(d->dpy, d->gc, 0, 0);
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
- if (num == 0)
- XSetClipMask(d->dpy, d->gc, XNone);
- else
- XSetClipRectangles(d->dpy, d->gc, 0, 0, rects, num, Unsorted);
- }
-}
-
-void QX11PaintEngine::updateMatrix(const QTransform &mtx)
-{
- Q_D(QX11PaintEngine);
- d->txop = mtx.type();
- d->matrix = mtx;
-
- d->has_complex_xform = (d->txop > QTransform::TxTranslate);
-
- extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
- bool scaling = qt_scaleForTransform(d->matrix, &d->xform_scale);
- d->has_scaling_xform = scaling && d->xform_scale != 1.0;
- d->has_non_scaling_xform = scaling && d->xform_scale == 1.0;
-}
-
-/*
- NB! the clip region is expected to be in dev coordinates
-*/
-void QX11PaintEngine::updateClipRegion_dev(const QRegion &clipRegion, Qt::ClipOperation op)
-{
- Q_D(QX11PaintEngine);
- QRegion sysClip = systemClip();
- if (op == Qt::NoClip) {
- d->has_clipping = false;
- d->crgn = sysClip;
- if (!sysClip.isEmpty()) {
- x11SetClipRegion(d->dpy, d->gc, d->gc_brush, d->picture, sysClip);
- } else {
- x11ClearClipRegion(d->dpy, d->gc, d->gc_brush, d->picture);
- }
- return;
- }
-
- switch (op) {
- case Qt::IntersectClip:
- if (d->has_clipping) {
- d->crgn &= clipRegion;
- break;
- }
- // fall through
- case Qt::ReplaceClip:
- if (!sysClip.isEmpty())
- d->crgn = clipRegion.intersected(sysClip);
- else
- d->crgn = clipRegion;
- break;
- case Qt::UniteClip:
- d->crgn |= clipRegion;
- if (!sysClip.isEmpty())
- d->crgn = d->crgn.intersected(sysClip);
- break;
- default:
- break;
- }
- d->has_clipping = true;
- x11SetClipRegion(d->dpy, d->gc, d->gc_brush, d->picture, d->crgn);
-}
-
-void QX11PaintEngine::updateFont(const QFont &)
-{
-}
-
-Qt::HANDLE QX11PaintEngine::handle() const
-{
- Q_D(const QX11PaintEngine);
- Q_ASSERT(isActive());
- Q_ASSERT(d->hd);
- return d->hd;
-}
-
-extern void qt_draw_tile(QPaintEngine *, qreal, qreal, qreal, qreal, const QPixmap &,
- qreal, qreal);
-
-void QX11PaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &p)
-{
- int x = qRound(r.x());
- int y = qRound(r.y());
- int w = qRound(r.width());
- int h = qRound(r.height());
- int sx = qRound(p.x());
- int sy = qRound(p.y());
-
- bool mono_src = pixmap.depth() == 1;
- Q_D(QX11PaintEngine);
-
- if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen())
- || (pixmap.x11Info().screen() != DefaultScreen(X11->display))) {
- QPixmap* p = const_cast<QPixmap *>(&pixmap);
- p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(X11->display));
- }
-
- QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
-
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender && d->picture && pixmap.x11PictureHandle()) {
-#if 0
- // ### Qt 5: enable this
- XRenderPictureAttributes attrs;
- attrs.repeat = true;
- XRenderChangePicture(d->dpy, pixmap.x11PictureHandle(), CPRepeat, &attrs);
-
- if (mono_src) {
- qt_render_bitmap(d->dpy, d->scrn, pixmap.x11PictureHandle(), d->picture,
- sx, sy, x, y, w, h, d->cpen);
- } else {
- XRenderComposite(d->dpy, d->composition_mode,
- pixmap.x11PictureHandle(), XNone, d->picture,
- sx, sy, 0, 0, x, y, w, h);
- }
-#else
- const int numTiles = (w / pixmap.width()) * (h / pixmap.height());
- if (numTiles < 100) {
- // this is essentially qt_draw_tile(), inlined for
- // the XRenderComposite call
- int yPos, xPos, drawH, drawW, yOff, xOff;
- yPos = y;
- yOff = sy;
- while(yPos < y + h) {
- drawH = pixmap.height() - yOff; // Cropping first row
- if (yPos + drawH > y + h) // Cropping last row
- drawH = y + h - yPos;
- xPos = x;
- xOff = sx;
- while(xPos < x + w) {
- drawW = pixmap.width() - xOff; // Cropping first column
- if (xPos + drawW > x + w) // Cropping last column
- drawW = x + w - xPos;
- if (mono_src) {
- qt_render_bitmap(d->dpy, d->scrn, pixmap.x11PictureHandle(), d->picture,
- xOff, yOff, xPos, yPos, drawW, drawH, d->cpen);
- } else {
- XRenderComposite(d->dpy, d->composition_mode,
- pixmap.x11PictureHandle(), XNone, d->picture,
- xOff, yOff, 0, 0, xPos, yPos, drawW, drawH);
- }
- xPos += drawW;
- xOff = 0;
- }
- yPos += drawH;
- yOff = 0;
- }
- } else {
- w = qMin(w, d->pdev->width() - x);
- h = qMin(h, d->pdev->height() - y);
- if (w <= 0 || h <= 0)
- return;
-
- const int pw = w + sx;
- const int ph = h + sy;
- QPixmap pm(pw, ph);
- if (pixmap.hasAlpha() || mono_src)
- pm.fill(Qt::transparent);
-
- const int mode = pixmap.hasAlpha() ? PictOpOver : PictOpSrc;
- const ::Picture pmPicture = pm.x11PictureHandle();
-
- // first tile
- XRenderComposite(d->dpy, mode,
- pixmap.x11PictureHandle(), XNone, pmPicture,
- 0, 0, 0, 0, 0, 0, qMin(pw, pixmap.width()), qMin(ph, pixmap.height()));
-
- // first row of tiles
- int xPos = pixmap.width();
- const int sh = qMin(ph, pixmap.height());
- while (xPos < pw) {
- const int sw = qMin(xPos, pw - xPos);
- XRenderComposite(d->dpy, mode,
- pmPicture, XNone, pmPicture,
- 0, 0, 0, 0, xPos, 0, sw, sh);
- xPos *= 2;
- }
-
- // remaining rows
- int yPos = pixmap.height();
- const int sw = pw;
- while (yPos < ph) {
- const int sh = qMin(yPos, ph - yPos);
- XRenderComposite(d->dpy, mode,
- pmPicture, XNone, pmPicture,
- 0, 0, 0, 0, 0, yPos, sw, sh);
- yPos *= 2;
- }
-
- // composite
- if (mono_src)
- qt_render_bitmap(d->dpy, d->scrn, pmPicture, d->picture,
- sx, sy, x, y, w, h, d->cpen);
- else
- XRenderComposite(d->dpy, d->composition_mode,
- pmPicture, XNone, d->picture,
- sx, sy, 0, 0, x, y, w, h);
- }
-#endif
- } else
-#endif // !QT_NO_XRENDER
- if (pixmap.depth() > 1 && !static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) {
- XSetTile(d->dpy, d->gc, pixmap.handle());
- XSetFillStyle(d->dpy, d->gc, FillTiled);
- XSetTSOrigin(d->dpy, d->gc, x-sx, y-sy);
- XFillRectangle(d->dpy, d->hd, d->gc, x, y, w, h);
- XSetTSOrigin(d->dpy, d->gc, 0, 0);
- XSetFillStyle(d->dpy, d->gc, FillSolid);
- } else {
- qt_draw_tile(this, x, y, w, h, pixmap, sx, sy);
- }
-}
-
-void QX11PaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
-{
- const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
-
- switch(ti.fontEngine->type()) {
- case QFontEngine::TestFontEngine:
- case QFontEngine::Box:
- d_func()->drawBoxTextItem(p, ti);
- break;
- case QFontEngine::XLFD:
- drawXLFD(p, ti);
- break;
-#ifndef QT_NO_FONTCONFIG
- case QFontEngine::Freetype:
- drawFreetype(p, ti);
- break;
-#endif
- default:
- Q_ASSERT(false);
- }
-}
-
-void QX11PaintEngine::drawXLFD(const QPointF &p, const QTextItemInt &ti)
-{
- Q_D(QX11PaintEngine);
-
- if (d->txop > QTransform::TxTranslate) {
- // XServer or font don't support server side transformations, need to do it by hand
- QPaintEngine::drawTextItem(p, ti);
- return;
- }
-
- if (!ti.glyphs.numGlyphs)
- return;
-
- QVarLengthArray<QFixedPoint> positions;
- QVarLengthArray<glyph_t> glyphs;
- QTransform matrix = d->matrix;
- matrix.translate(p.x(), p.y());
- ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
- if (glyphs.size() == 0)
- return;
-
- QFontEngineXLFD *xlfd = static_cast<QFontEngineXLFD *>(ti.fontEngine);
- Qt::HANDLE font_id = xlfd->fontStruct()->fid;
-
- XSetFont(d->dpy, d->gc, font_id);
-
- const QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
- for (int i = 0; i < glyphs.size(); i++) {
- int xp = qRound(positions[i].x + offs);
- int yp = qRound(positions[i].y + offs);
- if (xp < SHRT_MAX && xp > SHRT_MIN && yp > SHRT_MIN && yp < SHRT_MAX) {
- XChar2b ch;
- ch.byte1 = glyphs[i] >> 8;
- ch.byte2 = glyphs[i] & 0xff;
- XDrawString16(d->dpy, d->hd, d->gc, xp, yp, &ch, 1);
- }
- }
-}
-
-#ifndef QT_NO_FONTCONFIG
-static QPainterPath path_for_glyphs(const QVarLengthArray<glyph_t> &glyphs,
- const QVarLengthArray<QFixedPoint> &positions,
- const QFontEngineFT *ft)
-{
- QPainterPath path;
- path.setFillRule(Qt::WindingFill);
- ft->lockFace();
- int i = 0;
- while (i < glyphs.size()) {
- QFontEngineFT::Glyph *glyph = ft->loadGlyph(glyphs[i], QFontEngineFT::Format_Mono);
- // #### fix case where we don't get a glyph
- if (!glyph)
- break;
-
- Q_ASSERT(glyph->format == QFontEngineFT::Format_Mono);
- int n = 0;
- int h = glyph->height;
- int xp = qRound(positions[i].x);
- int yp = qRound(positions[i].y);
-
- xp += glyph->x;
- yp += -glyph->y + glyph->height;
- int pitch = ((glyph->width + 31) & ~31) >> 3;
-
- uchar *src = glyph->data;
- while (h--) {
- for (int x = 0; x < glyph->width; ++x) {
- bool set = src[x >> 3] & (0x80 >> (x & 7));
- if (set) {
- QRect r(xp + x, yp - h, 1, 1);
- while (x < glyph->width-1 && src[(x+1) >> 3] & (0x80 >> ((x+1) & 7))) {
- ++x;
- r.setRight(r.right()+1);
- }
-
- path.addRect(r);
- ++n;
- }
- }
- src += pitch;
- }
- ++i;
- }
- ft->unlockFace();
- return path;
-}
-
-void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti)
-{
- Q_D(QX11PaintEngine);
- if (!ti.glyphs.numGlyphs)
- return;
-
- QFontEngineX11FT *ft = static_cast<QFontEngineX11FT *>(ti.fontEngine);
-
- if (!d->cpen.isSolid()) {
- QPaintEngine::drawTextItem(p, ti);
- return;
- }
-
- const bool xrenderPath = (X11->use_xrender
- && !(d->pdev->devType() == QInternal::Pixmap
- && static_cast<const QPixmap *>(d->pdev)->data->pixelType() == QPixmapData::BitmapType));
-
- QVarLengthArray<QFixedPoint> positions;
- QVarLengthArray<glyph_t> glyphs;
- QTransform matrix;
-
- if (xrenderPath)
- matrix = d->matrix;
- matrix.translate(p.x(), p.y());
- ft->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
- if (glyphs.count() == 0)
- return;
-
-#ifndef QT_NO_XRENDER
- QFontEngineFT::QGlyphSet *set = ft->defaultGlyphs();
- if (d->txop >= QTransform::TxScale && xrenderPath)
- set = ft->loadTransformedGlyphSet(d->matrix);
-
- if (!set || set->outline_drawing
- || !ft->loadGlyphs(set, glyphs.constData(), glyphs.size(), positions.constData(), QFontEngineFT::Format_Render))
- {
- QPaintEngine::drawTextItem(p, ti);
- return;
- }
-
- if (xrenderPath) {
- GlyphSet glyphSet = set->id;
- const QColor &pen = d->cpen.color();
- ::Picture src = X11->getSolidFill(d->scrn, pen);
- XRenderPictFormat *maskFormat = 0;
- if (ft->xglyph_format != PictStandardA1)
- maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format);
-
- enum { t_min = SHRT_MIN, t_max = SHRT_MAX };
-
- int i = 0;
- for (; i < glyphs.size()
- && (positions[i].x < t_min || positions[i].x > t_max
- || positions[i].y < t_min || positions[i].y > t_max);
- ++i)
- ;
-
- if (i >= glyphs.size())
- return;
- ++i;
-
- QFixed xp = positions[i - 1].x;
- QFixed yp = positions[i - 1].y;
- QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
-
- XGlyphElt32 elt;
- elt.glyphset = glyphSet;
- elt.chars = &glyphs[i - 1];
- elt.nchars = 1;
- elt.xOff = qRound(xp + offs);
- elt.yOff = qRound(yp + offs);
- for (; i < glyphs.size(); ++i) {
- if (positions[i].x < t_min || positions[i].x > t_max
- || positions[i].y < t_min || positions[i].y > t_max) {
- break;
- }
- QFontEngineFT::Glyph *g = ft->cachedGlyph(glyphs[i - 1]);
- if (g
- && positions[i].x == xp + g->advance
- && positions[i].y == yp
- && elt.nchars < 253 // don't draw more than 253 characters as some X servers
- // hang with it
- ) {
- elt.nchars++;
- xp += g->advance;
- } else {
- xp = positions[i].x;
- yp = positions[i].y;
-
- XRenderCompositeText32(X11->display, PictOpOver, src, d->picture,
- maskFormat, 0, 0, 0, 0,
- &elt, 1);
- elt.chars = &glyphs[i];
- elt.nchars = 1;
- elt.xOff = qRound(xp + offs);
- elt.yOff = qRound(yp + offs);
- }
- }
- XRenderCompositeText32(X11->display, PictOpOver, src, d->picture,
- maskFormat, 0, 0, 0, 0,
- &elt, 1);
-
- return;
-
- }
-#endif
-
- QPainterPath path = path_for_glyphs(glyphs, positions, ft);
- if (path.elementCount() <= 1)
- return;
- Q_ASSERT((path.elementCount() % 5) == 0);
- if (d->txop >= QTransform::TxScale) {
- painter()->save();
- painter()->setBrush(d->cpen.brush());
- painter()->setPen(Qt::NoPen);
- painter()->drawPath(path);
- painter()->restore();
- return;
- }
-
- const int rectcount = 256;
- XRectangle rects[rectcount];
- int num_rects = 0;
-
- QPoint delta(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
- QRect clip(d->polygonClipper.boundingRect());
- for (int i=0; i < path.elementCount(); i+=5) {
- int x = qRound(path.elementAt(i).x);
- int y = qRound(path.elementAt(i).y);
- int w = qRound(path.elementAt(i+1).x) - x;
- int h = qRound(path.elementAt(i+2).y) - y;
-
- QRect rect = QRect(x + delta.x(), y + delta.y(), w, h);
- rect = rect.intersected(clip);
- if (rect.isEmpty())
- continue;
-
- rects[num_rects].x = short(rect.x());
- rects[num_rects].y = short(rect.y());
- rects[num_rects].width = ushort(rect.width());
- rects[num_rects].height = ushort(rect.height());
- ++num_rects;
- if (num_rects == rectcount) {
- XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
- num_rects = 0;
- }
- }
- if (num_rects > 0)
- XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
-
-}
-#endif // !QT_NO_XRENDER
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengine_x11_p.h b/src/gui/painting/qpaintengine_x11_p.h
deleted file mode 100644
index d8d8817993..0000000000
--- a/src/gui/painting/qpaintengine_x11_p.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPAINTENGINE_X11_P_H
-#define QPAINTENGINE_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/qpaintengine.h"
-#include "QtGui/qregion.h"
-#include "QtGui/qpen.h"
-#include "QtCore/qpoint.h"
-#include "private/qpaintengine_p.h"
-#include "private/qpainter_p.h"
-#include "private/qpolygonclipper_p.h"
-
-typedef unsigned long Picture;
-
-QT_BEGIN_NAMESPACE
-
-class QX11PaintEnginePrivate;
-class QFontEngineFT;
-class QXRenderTessellator;
-
-struct qt_float_point
-{
- qreal x, y;
-};
-
-class QX11PaintEngine : public QPaintEngine
-{
- Q_DECLARE_PRIVATE(QX11PaintEngine)
-public:
- QX11PaintEngine();
- ~QX11PaintEngine();
-
- bool begin(QPaintDevice *pdev);
- bool end();
-
- void updateState(const QPaintEngineState &state);
-
- void updatePen(const QPen &pen);
- void updateBrush(const QBrush &brush, const QPointF &pt);
- void updateRenderHints(QPainter::RenderHints hints);
- void updateFont(const QFont &font);
- void updateMatrix(const QTransform &matrix);
- void updateClipRegion_dev(const QRegion &region, Qt::ClipOperation op);
-
- void drawLines(const QLine *lines, int lineCount);
- void drawLines(const QLineF *lines, int lineCount);
-
- void drawRects(const QRect *rects, int rectCount);
- void drawRects(const QRectF *rects, int rectCount);
-
- void drawPoints(const QPoint *points, int pointCount);
- void drawPoints(const QPointF *points, int pointCount);
-
- void drawEllipse(const QRect &r);
- void drawEllipse(const QRectF &r);
-
- virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
- inline void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
- { QPaintEngine::drawPolygon(points, pointCount, mode); }
-
- void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
- void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
- void drawPath(const QPainterPath &path);
- void drawTextItem(const QPointF &p, const QTextItem &textItem);
- void drawImage(const QRectF &r, const QImage &img, const QRectF &sr,
- Qt::ImageConversionFlags flags = Qt::AutoColor);
-
- virtual Qt::HANDLE handle() const;
- inline Type type() const { return QPaintEngine::X11; }
-
- QPainter::RenderHints supportedRenderHints() const;
-
-protected:
- QX11PaintEngine(QX11PaintEnginePrivate &dptr);
-
- void drawXLFD(const QPointF &p, const QTextItemInt &si);
-#ifndef QT_NO_FONTCONFIG
- void drawFreetype(const QPointF &p, const QTextItemInt &si);
-#endif
-
- friend class QPixmap;
- friend class QFontEngineBox;
- friend Q_GUI_EXPORT GC qt_x11_get_pen_gc(QPainter *);
- friend Q_GUI_EXPORT GC qt_x11_get_brush_gc(QPainter *);
-
-private:
- Q_DISABLE_COPY(QX11PaintEngine)
-};
-
-class QX11PaintEnginePrivate : public QPaintEnginePrivate
-{
- Q_DECLARE_PUBLIC(QX11PaintEngine)
-public:
- QX11PaintEnginePrivate()
- {
- scrn = -1;
- hd = 0;
- picture = 0;
- gc = gc_brush = 0;
- dpy = 0;
- xinfo = 0;
- txop = QTransform::TxNone;
- has_clipping = false;
- render_hints = 0;
- xform_scale = 1;
-#ifndef QT_NO_XRENDER
- tessellator = 0;
-#endif
- }
- enum GCMode {
- PenGC,
- BrushGC
- };
-
- void init();
- void fillPolygon_translated(const QPointF *points, int pointCount, GCMode gcMode,
- QPaintEngine::PolygonDrawMode mode);
- void fillPolygon_dev(const QPointF *points, int pointCount, GCMode gcMode,
- QPaintEngine::PolygonDrawMode mode);
- void fillPath(const QPainterPath &path, GCMode gcmode, bool transform);
- void strokePolygon_dev(const QPointF *points, int pointCount, bool close);
- void strokePolygon_translated(const QPointF *points, int pointCount, bool close);
- void setupAdaptedOrigin(const QPoint &p);
- void resetAdaptedOrigin();
- void decidePathFallback() {
- use_path_fallback = has_alpha_brush
- || has_alpha_pen
- || has_custom_pen
- || has_complex_xform
- || (render_hints & QPainter::Antialiasing);
- }
- void decideCoordAdjust() {
- adjust_coords = !(render_hints & QPainter::Antialiasing)
- && (has_alpha_pen
- || (has_alpha_brush && has_pen && !has_alpha_pen)
- || (cpen.style() > Qt::SolidLine));
- }
- void clipPolygon_dev(const QPolygonF &poly, QPolygonF *clipped_poly);
- void systemStateChanged();
-
- Display *dpy;
- int scrn;
- int pdev_depth;
- Qt::HANDLE hd;
- QPixmap brush_pm;
-#if !defined (QT_NO_XRENDER)
- Qt::HANDLE picture;
- Qt::HANDLE current_brush;
- QPixmap bitmap_texture;
- int composition_mode;
-#else
- Qt::HANDLE picture;
-#endif
- GC gc;
- GC gc_brush;
-
- QPen cpen;
- QBrush cbrush;
- QRegion crgn;
- QTransform matrix;
- qreal opacity;
-
- uint has_complex_xform : 1;
- uint has_scaling_xform : 1;
- uint has_non_scaling_xform : 1;
- uint has_custom_pen : 1;
- uint use_path_fallback : 1;
- uint adjust_coords : 1;
- uint has_clipping : 1;
- uint adapted_brush_origin : 1;
- uint adapted_pen_origin : 1;
- uint has_pen : 1;
- uint has_brush : 1;
- uint has_texture : 1;
- uint has_alpha_texture : 1;
- uint has_pattern : 1;
- uint has_alpha_pen : 1;
- uint has_alpha_brush : 1;
- uint render_hints;
-
- const QX11Info *xinfo;
- QPointF bg_origin;
- QTransform::TransformationType txop;
- qreal xform_scale;
- QPolygonClipper<qt_float_point, qt_float_point, float> polygonClipper;
-
- int xlibMaxLinePoints;
-#ifndef QT_NO_XRENDER
- QXRenderTessellator *tessellator;
-#endif
-};
-
-QT_END_NAMESPACE
-
-#endif // QPAINTENGINE_X11_P_H
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index 3a3451567a..9e6cbfc1ea 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -54,7 +54,6 @@
//
#include <QtGui/qpaintengine.h>
-#include <QtGui/qdrawutil.h>
#include <private/qpaintengine_p.h>
#include <private/qstroker_p.h>
@@ -213,6 +212,7 @@ public:
virtual void beginNativePainting() {}
virtual void endNativePainting() {}
+ // ### Qt5: remove, once QtOpenGL is merged into QtGui and QtWidgets
// Return a pixmap filter of "type" that can render the parameters
// in "prototype". The returned filter is owned by the engine and
// will be destroyed when the engine is destroyed. The "prototype"
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 811e59b3b7..aa684864e8 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -56,9 +56,6 @@
#include "qpixmapcache.h"
#include "qpolygon.h"
#include "qtextlayout.h"
-#include "qwidget.h"
-#include "qapplication.h"
-#include "qstyle.h"
#include "qthread.h"
#include "qvarlengtharray.h"
#include "qstatictext.h"
@@ -69,12 +66,12 @@
#include <private/qemulationpaintengine_p.h>
#include <private/qpainterpath_p.h>
#include <private/qtextengine_p.h>
-#include <private/qwidget_p.h>
#include <private/qpaintengine_raster_p.h>
#include <private/qmath_p.h>
#include <private/qstatictext_p.h>
#include <private/qglyphrun_p.h>
-#include <private/qstylehelper_p.h>
+#include <private/qhexstring_p.h>
+#include <private/qguiapplication_p.h>
#include <private/qrawfont_p.h>
QT_BEGIN_NAMESPACE
@@ -250,34 +247,10 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
Q_ASSERT(q);
Q_ASSERT(pdev);
- if (pdev->devType() != QInternal::Widget)
+ QPainter *sp = pdev->sharedPainter();
+ if (!sp)
return false;
- QWidget *widget = static_cast<QWidget *>(pdev);
- Q_ASSERT(widget);
-
- // Someone either called QPainter::setRedirected in the widget's paint event
- // right before this painter was created (or begin was called) or
- // sent a paint event directly to the widget.
- if (!widget->d_func()->redirectDev)
- return false;
-
- QPainter *sp = widget->d_func()->sharedPainter();
- if (!sp || !sp->isActive())
- return false;
-
- if (sp->paintEngine()->paintDevice() != widget->d_func()->redirectDev)
- return false;
-
- // Check if we're attempting to paint outside a paint event.
- if (!sp->d_ptr->engine->hasFeature(QPaintEngine::PaintOutsidePaintEvent)
- && !widget->testAttribute(Qt::WA_PaintOutsidePaintEvent)
- && !widget->testAttribute(Qt::WA_WState_InPaintEvent)) {
-
- qWarning("QPainter::begin: Widget painting can only begin as a result of a paintEvent");
- return false;
- }
-
// Save the current state of the shared painter and assign
// the current d_ptr to the shared painter's d_ptr.
sp->save();
@@ -301,14 +274,14 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
Q_ASSERT(q->d_ptr->state);
// Now initialize the painter with correct widget properties.
- q->initFrom(widget);
+ q->initFrom(pdev);
QPoint offset;
- widget->d_func()->redirected(&offset);
+ pdev->redirected(&offset);
offset += q->d_ptr->engine->coordinateOffset();
// Update system rect.
- q->d_ptr->state->ww = q->d_ptr->state->vw = widget->width();
- q->d_ptr->state->wh = q->d_ptr->state->vh = widget->height();
+ q->d_ptr->state->ww = q->d_ptr->state->vw = pdev->width();
+ q->d_ptr->state->wh = q->d_ptr->state->vh = pdev->height();
// Update matrix.
if (q->d_ptr->state->WxF) {
@@ -322,13 +295,13 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
q->d_ptr->updateMatrix();
QPaintEnginePrivate *enginePrivate = q->d_ptr->engine->d_func();
- if (enginePrivate->currentClipWidget == widget) {
+ if (enginePrivate->currentClipDevice == pdev) {
enginePrivate->systemStateChanged();
return true;
}
// Update system transform and clip.
- enginePrivate->currentClipWidget = widget;
+ enginePrivate->currentClipDevice = pdev;
enginePrivate->setSystemTransform(q->d_ptr->state->matrix);
return true;
}
@@ -1379,10 +1352,7 @@ void QPainterPrivate::updateState(QPainterState *newState)
only use the format types QImage::Format_ARGB32_Premultiplied,
QImage::Format_RGB32 or QImage::Format_RGB16. Any other format,
including QImage::Format_ARGB32, has significantly worse
- performance. This engine is also used by default on Windows and on
- QWS. It can be used as default graphics system on any
- OS/hardware/software combination by passing \c {-graphicssystem
- raster} on the command line
+ performance. This engine is used by default for QWidget and QPixmap.
\o OpenGL 2.0 (ES) - This backend is the primary backend for
hardware accelerated graphics. It can be run on desktop machines
@@ -1550,8 +1520,8 @@ QPainter::~QPainter()
QPaintDevice *QPainter::device() const
{
Q_D(const QPainter);
- if (isActive() && d->engine->d_func()->currentClipWidget)
- return d->engine->d_func()->currentClipWidget;
+ if (isActive() && d->engine->d_func()->currentClipDevice)
+ return d->engine->d_func()->currentClipDevice;
return d->original_device;
}
@@ -1570,25 +1540,23 @@ bool QPainter::isActive() const
/*!
Initializes the painters pen, background and font to the same as
- the given \a widget. This function is called automatically when the
- painter is opened on a QWidget.
+ the given \a paint device.
+
+ \obsolete
\sa begin(), {QPainter#Settings}{Settings}
*/
-void QPainter::initFrom(const QWidget *widget)
+void QPainter::initFrom(const QPaintDevice *device)
{
- Q_ASSERT_X(widget, "QPainter::initFrom(const QWidget *widget)", "Widget cannot be 0");
+ Q_ASSERT_X(device, "QPainter::initFrom(const QPaintDevice *device)", "QPaintDevice cannot be 0");
Q_D(QPainter);
if (!d->engine) {
qWarning("QPainter::initFrom: Painter not active, aborted");
return;
}
- const QPalette &pal = widget->palette();
- d->state->pen = QPen(pal.brush(widget->foregroundRole()), 0);
- d->state->bgBrush = pal.brush(widget->backgroundRole());
- d->state->deviceFont = QFont(widget->font(), const_cast<QWidget*> (widget));
- d->state->font = d->state->deviceFont;
+ device->init(this);
+
if (d->extended) {
d->extended->penChanged();
} else if (d->engine) {
@@ -1761,22 +1729,9 @@ bool QPainter::begin(QPaintDevice *pd)
d->helper_device = pd;
d->original_device = pd;
- QPaintDevice *rpd = 0;
QPoint redirectionOffset;
- // We know for sure that redirection is broken when the widget is inside
- // its paint event, so it's safe to use our hard-coded redirection. However,
- // there IS one particular case we still need to support, and that's
- // when people call QPainter::setRedirected in the widget's paint event right
- // before any painter is created (or QPainter::begin is called). In that
- // particular case our hard-coded redirection is restored and the redirection
- // is retrieved from QPainter::redirected (as before).
- if (pd->devType() == QInternal::Widget)
- rpd = static_cast<QWidget *>(pd)->d_func()->redirected(&redirectionOffset);
-
- if (!rpd)
- rpd = redirected(pd, &redirectionOffset);
-
+ QPaintDevice *rpd = pd->redirected(&redirectionOffset);
if (rpd)
pd = rpd;
@@ -1819,6 +1774,8 @@ bool QPainter::begin(QPaintDevice *pd)
d->engine->state = d->state;
switch (pd->devType()) {
+#if 0
+ // is this needed any more??
case QInternal::Widget:
{
const QWidget *widget = static_cast<const QWidget *>(pd);
@@ -1826,13 +1783,6 @@ bool QPainter::begin(QPaintDevice *pd)
const bool paintOutsidePaintEvent = widget->testAttribute(Qt::WA_PaintOutsidePaintEvent);
const bool inPaintEvent = widget->testAttribute(Qt::WA_WState_InPaintEvent);
- if(!d->engine->hasFeature(QPaintEngine::PaintOutsidePaintEvent)
- && !paintOutsidePaintEvent && !inPaintEvent) {
- qWarning("QPainter::begin: Widget painting can only begin as a "
- "result of a paintEvent");
- qt_cleanup_painter_state(d);
- return false;
- }
// Adjust offset for alien widgets painting outside the paint event.
if (!inPaintEvent && paintOutsidePaintEvent && !widget->internalWinId()
@@ -1842,6 +1792,7 @@ bool QPainter::begin(QPaintDevice *pd)
}
break;
}
+#endif
case QInternal::Pixmap:
{
QPixmap *pm = static_cast<QPixmap *>(pd);
@@ -1902,8 +1853,7 @@ bool QPainter::begin(QPaintDevice *pd)
// Copy painter properties from original paint device,
// required for QPixmap::grabWidget()
if (d->original_device->devType() == QInternal::Widget) {
- QWidget *widget = static_cast<QWidget *>(d->original_device);
- initFrom(widget);
+ initFrom(d->original_device);
} else {
d->state->layoutDirection = Qt::LayoutDirectionAuto;
// make sure we have a font compatible with the paintdevice
@@ -4616,82 +4566,6 @@ void QPainter::drawChord(const QRectF &r, int a, int alen)
startAngle and \a spanAngle.
*/
-#ifdef QT3_SUPPORT
-/*!
- \fn void QPainter::drawLineSegments(const QPolygon &polygon, int
- index, int count)
-
- Draws \a count separate lines from points defined by the \a
- polygon, starting at \a{polygon}\e{[index]} (\a index defaults to
- 0). If \a count is -1 (the default) all points until the end of
- the array are used.
-
- Use drawLines() combined with QPolygon::constData() instead.
-
- \oldcode
- QPainter painter(this);
- painter.drawLineSegments(polygon, index, count);
- \newcode
- int lineCount = (count == -1) ? (polygon.size() - index) / 2 : count;
-
- QPainter painter(this);
- painter.drawLines(polygon.constData() + index * 2, lineCount);
- \endcode
-*/
-
-void QPainter::drawLineSegments(const QPolygon &a, int index, int nlines)
-{
-#ifdef QT_DEBUG_DRAW
- if (qt_show_painter_debug_output)
- printf("QPainter::drawLineSegments(), count=%d\n", a.size()/2);
-#endif
- Q_D(QPainter);
-
- if (!d->engine)
- return;
-
- if (nlines < 0)
- nlines = a.size()/2 - index/2;
- if (index + nlines*2 > (int)a.size())
- nlines = (a.size() - index)/2;
- if (nlines < 1 || index < 0)
- return;
-
- if (d->extended) {
- // FALCON: Use QVectorPath
- QVector<QLineF> lines;
- for (int i=index; i<index + nlines*2; i+=2)
- lines << QLineF(a.at(i), a.at(i+1));
- d->extended->drawLines(lines.data(), lines.size());
- return;
- }
-
- d->updateState(d->state);
-
- QVector<QLineF> lines;
- if (d->state->emulationSpecifier) {
- if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform
- && d->state->matrix.type() == QTransform::TxTranslate) {
- QPointF offset(d->state->matrix.dx(), d->state->matrix.dy());
- for (int i=index; i<index + nlines*2; i+=2)
- lines << QLineF(a.at(i) + offset, a.at(i+1) + offset);
- } else {
- QPainterPath linesPath;
- for (int i=index; i<index + nlines*2; i+=2) {
- linesPath.moveTo(a.at(i));
- linesPath.lineTo(a.at(i+1));
- }
- d->draw_helper(linesPath, QPainterPrivate::StrokeDraw);
- return;
- }
- } else {
- for (int i=index; i<index + nlines*2; i+=2)
- lines << QLineF(a.at(i), a.at(i+1));
- }
-
- d->engine->drawLines(lines.data(), lines.size());
-}
-#endif // QT3_SUPPORT
/*!
Draws the first \a lineCount lines in the array \a lines
@@ -6472,7 +6346,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const
const qreal underlinePos = pos.y() + qCeil(underlineOffset) - aliasedCoordinateDelta;
if (underlineStyle == QTextCharFormat::SpellCheckUnderline) {
- underlineStyle = QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle));
+ underlineStyle = QTextCharFormat::SpellCheckUnderline; // ### Qt5 QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle));
}
if (underlineStyle == QTextCharFormat::WaveUnderline) {
@@ -7511,328 +7385,6 @@ void QPainter::setViewTransformEnabled(bool enable)
d->updateMatrix();
}
-#ifdef QT3_SUPPORT
-
-/*!
- \obsolete
-
- Use the worldTransform() combined with QTransform::dx() instead.
-
- \oldcode
- QPainter painter(this);
- qreal x = painter.translationX();
- \newcode
- QPainter painter(this);
- qreal x = painter.worldTransform().dx();
- \endcode
-*/
-qreal QPainter::translationX() const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::translationX: Painter not active");
- return 0.0;
- }
- return d->state->worldMatrix.dx();
-}
-
-/*!
- \obsolete
-
- Use the worldTransform() combined with QTransform::dy() instead.
-
- \oldcode
- QPainter painter(this);
- qreal y = painter.translationY();
- \newcode
- QPainter painter(this);
- qreal y = painter.worldTransform().dy();
- \endcode
-*/
-qreal QPainter::translationY() const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::translationY: Painter not active");
- return 0.0;
- }
- return d->state->worldMatrix.dy();
-}
-
-/*!
- \fn void QPainter::map(int x, int y, int *rx, int *ry) const
-
- \internal
-
- Sets (\a{rx}, \a{ry}) to the point that results from applying the
- painter's current transformation on the point (\a{x}, \a{y}).
-*/
-void QPainter::map(int x, int y, int *rx, int *ry) const
-{
- QPoint p(x, y);
- p = p * combinedMatrix();
- *rx = p.x();
- *ry = p.y();
-}
-
-/*!
- \fn QPoint QPainter::xForm(const QPoint &point) const
-
- Use combinedTransform() instead.
-*/
-
-QPoint QPainter::xForm(const QPoint &p) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xForm: Painter not active");
- return QPoint();
- }
- if (d->state->matrix.type() == QTransform::TxNone)
- return p;
- return p * combinedMatrix();
-}
-
-
-/*!
- \fn QRect QPainter::xForm(const QRect &rectangle) const
- \overload
-
- Use combinedTransform() instead of this function and call
- mapRect() on the result to obtain a QRect.
-*/
-
-QRect QPainter::xForm(const QRect &r) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xForm: Painter not active");
- return QRect();
- }
- if (d->state->matrix.type() == QTransform::TxNone)
- return r;
- return combinedMatrix().mapRect(r);
-}
-
-/*!
- \fn QPolygon QPainter::xForm(const QPolygon &polygon) const
- \overload
-
- Use combinedTransform() instead.
-*/
-
-QPolygon QPainter::xForm(const QPolygon &a) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xForm: Painter not active");
- return QPolygon();
- }
- if (d->state->matrix.type() == QTransform::TxNone)
- return a;
- return a * combinedMatrix();
-}
-
-/*!
- \fn QPolygon QPainter::xForm(const QPolygon &polygon, int index, int count) const
- \overload
-
- Use combinedTransform() combined with QPolygon::mid() instead.
-
- \oldcode
- QPainter painter(this);
- QPolygon transformed = painter.xForm(polygon, index, count)
- \newcode
- QPainter painter(this);
- QPolygon transformed = polygon.mid(index, count) * painter.combinedTransform();
- \endcode
-*/
-
-QPolygon QPainter::xForm(const QPolygon &av, int index, int npoints) const
-{
- int lastPoint = npoints < 0 ? av.size() : index+npoints;
- QPolygon a(lastPoint-index);
- memcpy(a.data(), av.data()+index, (lastPoint-index)*sizeof(QPoint));
- return a * combinedMatrix();
-}
-
-/*!
- \fn QPoint QPainter::xFormDev(const QPoint &point) const
- \overload
- \obsolete
-
- Use combinedTransform() combined with QTransform::inverted() instead.
-
- \oldcode
- QPainter painter(this);
- QPoint transformed = painter.xFormDev(point);
- \newcode
- QPainter painter(this);
- QPoint transformed = point * painter.combinedTransform().inverted();
- \endcode
-*/
-
-QPoint QPainter::xFormDev(const QPoint &p) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xFormDev: Painter not active");
- return QPoint();
- }
- if(d->state->matrix.type() == QTransform::TxNone)
- return p;
- return p * combinedMatrix().inverted();
-}
-
-/*!
- \fn QRect QPainter::xFormDev(const QRect &rectangle) const
- \overload
- \obsolete
-
- Use combinedTransform() combined with QTransform::inverted() instead.
-
- \oldcode
- QPainter painter(this);
- QRect transformed = painter.xFormDev(rectangle);
- \newcode
- QPainter painter(this);
- QRegion region = QRegion(rectangle) * painter.combinedTransform().inverted();
- QRect transformed = region.boundingRect();
- \endcode
-*/
-
-QRect QPainter::xFormDev(const QRect &r) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xFormDev: Painter not active");
- return QRect();
- }
- if (d->state->matrix.type() == QTransform::TxNone)
- return r;
- return combinedMatrix().inverted().mapRect(r);
-}
-
-/*!
- \overload
-
- \fn QPoint QPainter::xFormDev(const QPolygon &polygon) const
- \obsolete
-
- Use combinedTransform() combined with QTransform::inverted() instead.
-
- \oldcode
- QPainter painter(this);
- QPolygon transformed = painter.xFormDev(rectangle);
- \newcode
- QPainter painter(this);
- QPolygon transformed = polygon * painter.combinedTransform().inverted();
- \endcode
-*/
-
-QPolygon QPainter::xFormDev(const QPolygon &a) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xFormDev: Painter not active");
- return QPolygon();
- }
- if (d->state->matrix.type() == QTransform::TxNone)
- return a;
- return a * combinedMatrix().inverted();
-}
-
-/*!
- \fn QPolygon QPainter::xFormDev(const QPolygon &polygon, int index, int count) const
- \overload
- \obsolete
-
- Use combinedTransform() combined with QPolygon::mid() and QTransform::inverted() instead.
-
- \oldcode
- QPainter painter(this);
- QPolygon transformed = painter.xFormDev(polygon, index, count);
- \newcode
- QPainter painter(this);
- QPolygon transformed = polygon.mid(index, count) * painter.combinedTransform().inverted();
- \endcode
-*/
-
-QPolygon QPainter::xFormDev(const QPolygon &ad, int index, int npoints) const
-{
- Q_D(const QPainter);
- int lastPoint = npoints < 0 ? ad.size() : index+npoints;
- QPolygon a(lastPoint-index);
- memcpy(a.data(), ad.data()+index, (lastPoint-index)*sizeof(QPoint));
- if (d->state->matrix.type() == QTransform::TxNone)
- return a;
- return a * combinedMatrix().inverted();
-}
-
-/*!
- \fn void QPainter::drawCubicBezier(const QPolygon &controlPoints, int index)
-
- Draws a cubic Bezier curve defined by the \a controlPoints,
- starting at \a{controlPoints}\e{[index]} (\a index defaults to 0).
- Points after \a{controlPoints}\e{[index + 3]} are ignored. Nothing
- happens if there aren't enough control points.
-
- Use strokePath() instead.
-
- \oldcode
- QPainter painter(this);
- painter.drawCubicBezier(controlPoints, index)
- \newcode
- QPainterPath path;
- path.moveTo(controlPoints.at(index));
- path.cubicTo(controlPoints.at(index+1),
- controlPoints.at(index+2),
- controlPoints.at(index+3));
-
- QPainter painter(this);
- painter.strokePath(path, painter.pen());
- \endcode
-*/
-void QPainter::drawCubicBezier(const QPolygon &a, int index)
-{
- Q_D(QPainter);
-
- if (!d->engine)
- return;
-
- if ((int)a.size() - index < 4) {
- qWarning("QPainter::drawCubicBezier: Cubic Bezier needs 4 control "
- "points");
- return;
- }
-
- QPainterPath path;
- path.moveTo(a.at(index));
- path.cubicTo(a.at(index+1), a.at(index+2), a.at(index+3));
- strokePath(path, d->state->pen);
-}
-#endif
-
-struct QPaintDeviceRedirection
-{
- QPaintDeviceRedirection() : device(0), replacement(0), internalWidgetRedirectionIndex(-1) {}
- QPaintDeviceRedirection(const QPaintDevice *device, QPaintDevice *replacement,
- const QPoint& offset, int internalWidgetRedirectionIndex)
- : device(device), replacement(replacement), offset(offset),
- internalWidgetRedirectionIndex(internalWidgetRedirectionIndex) { }
- const QPaintDevice *device;
- QPaintDevice *replacement;
- QPoint offset;
- int internalWidgetRedirectionIndex;
- bool operator==(const QPaintDevice *pdev) const { return device == pdev; }
- Q_DUMMY_COMPARISON_OPERATOR(QPaintDeviceRedirection)
-};
-
-typedef QList<QPaintDeviceRedirection> QPaintDeviceRedirectionList;
-Q_GLOBAL_STATIC(QPaintDeviceRedirectionList, globalRedirections)
-Q_GLOBAL_STATIC(QMutex, globalRedirectionsMutex)
-Q_GLOBAL_STATIC(QAtomicInt, globalRedirectionAtomic)
-
/*!
\threadsafe
@@ -7862,29 +7414,7 @@ void QPainter::setRedirected(const QPaintDevice *device,
{
Q_ASSERT(device != 0);
- bool hadInternalWidgetRedirection = false;
- if (device->devType() == QInternal::Widget) {
- const QWidgetPrivate *widgetPrivate = static_cast<const QWidget *>(device)->d_func();
- // This is the case when the widget is in a paint event.
- if (widgetPrivate->redirectDev) {
- // Remove internal redirection and put it back into the global redirection list.
- QPoint oldOffset;
- QPaintDevice *oldReplacement = widgetPrivate->redirected(&oldOffset);
- const_cast<QWidgetPrivate *>(widgetPrivate)->restoreRedirected();
- setRedirected(device, oldReplacement, oldOffset);
- hadInternalWidgetRedirection = true;
- }
- }
-
- QPoint roffset;
- QPaintDevice *rdev = redirected(replacement, &roffset);
-
- QMutexLocker locker(globalRedirectionsMutex());
- QPaintDeviceRedirectionList *redirections = globalRedirections();
- Q_ASSERT(redirections != 0);
- *redirections += QPaintDeviceRedirection(device, rdev ? rdev : replacement, offset + roffset,
- hadInternalWidgetRedirection ? redirections->size() - 1 : -1);
- globalRedirectionAtomic()->ref();
+ qWarning() << "QPainter::setRedirected(): ignoring call to deprecated function, use QWidget::render() instead";
}
/*!
@@ -7906,29 +7436,7 @@ void QPainter::setRedirected(const QPaintDevice *device,
*/
void QPainter::restoreRedirected(const QPaintDevice *device)
{
- Q_ASSERT(device != 0);
- QMutexLocker locker(globalRedirectionsMutex());
- QPaintDeviceRedirectionList *redirections = globalRedirections();
- Q_ASSERT(redirections != 0);
- for (int i = redirections->size()-1; i >= 0; --i) {
- if (redirections->at(i) == device) {
- globalRedirectionAtomic()->deref();
- const int internalWidgetRedirectionIndex = redirections->at(i).internalWidgetRedirectionIndex;
- redirections->removeAt(i);
- // Restore the internal widget redirection, i.e. remove it from the global
- // redirection list and put it back into QWidgetPrivate. The index is only set when
- // someone call QPainter::setRedirected in a widget's paint event and we internally
- // have a redirection set (typically set in QWidgetPrivate::drawWidget).
- if (internalWidgetRedirectionIndex >= 0) {
- Q_ASSERT(internalWidgetRedirectionIndex < redirections->size());
- const QPaintDeviceRedirection &redirectionDevice = redirections->at(internalWidgetRedirectionIndex);
- QWidget *widget = static_cast<QWidget *>(const_cast<QPaintDevice *>(device));
- widget->d_func()->setRedirected(redirectionDevice.replacement, redirectionDevice.offset);
- redirections->removeAt(internalWidgetRedirectionIndex);
- }
- return;
- }
- }
+ qWarning() << "QPainter::restoreRedirected(): ignoring call to deprecated function, use QWidget::render() instead";
}
/*!
@@ -7950,61 +7458,9 @@ void QPainter::restoreRedirected(const QPaintDevice *device)
*/
QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)
{
- Q_ASSERT(device != 0);
-
- if (device->devType() == QInternal::Widget) {
- const QWidgetPrivate *widgetPrivate = static_cast<const QWidget *>(device)->d_func();
- if (widgetPrivate->redirectDev)
- return widgetPrivate->redirected(offset);
- }
-
- if (!globalRedirectionAtomic() || *globalRedirectionAtomic() == 0)
- return 0;
-
- QMutexLocker locker(globalRedirectionsMutex());
- QPaintDeviceRedirectionList *redirections = globalRedirections();
- Q_ASSERT(redirections != 0);
- for (int i = redirections->size()-1; i >= 0; --i)
- if (redirections->at(i) == device) {
- if (offset)
- *offset = redirections->at(i).offset;
- return redirections->at(i).replacement;
- }
- if (offset)
- *offset = QPoint(0, 0);
return 0;
}
-
-void qt_painter_removePaintDevice(QPaintDevice *dev)
-{
- if (!globalRedirectionAtomic() || *globalRedirectionAtomic() == 0)
- return;
-
- QMutex *mutex = 0;
- QT_TRY {
- mutex = globalRedirectionsMutex();
- } QT_CATCH(...) {
- // ignore the missing mutex, since we could be called from
- // a destructor, and destructors shall not throw
- }
- QMutexLocker locker(mutex);
- QPaintDeviceRedirectionList *redirections = 0;
- QT_TRY {
- redirections = globalRedirections();
- } QT_CATCH(...) {
- // do nothing - code below is safe with redirections being 0.
- }
- if (redirections) {
- for (int i = 0; i < redirections->size(); ) {
- if(redirections->at(i) == dev || redirections->at(i).replacement == dev)
- redirections->removeAt(i);
- else
- ++i;
- }
- }
-}
-
void qt_format_text(const QFont &fnt, const QRectF &_r,
int tf, const QString& str, QRectF *brect,
int tabstops, int *ta, int tabarraylen,
@@ -8056,7 +7512,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
else
layout_direction = Qt::LeftToRight;
- tf = QStyle::visualAlignment(layout_direction, QFlag(tf));
+ tf = QGuiApplicationPrivate::visualAlignment(layout_direction, QFlag(tf));
bool isRightToLeft = layout_direction == Qt::RightToLeft;
bool expandtabs = ((tf & Qt::TextExpandTabs) &&
@@ -8316,7 +7772,7 @@ QPainterState::QPainterState()
wx(0), wy(0), ww(0), wh(0), vx(0), vy(0), vw(0), vh(0),
opacity(1), WxF(false), VxF(false), clipEnabled(true),
bgMode(Qt::TransparentMode), painter(0),
- layoutDirection(QApplication::layoutDirection()),
+ layoutDirection(QGuiApplication::layoutDirection()),
composition_mode(QPainter::CompositionMode_SourceOver),
emulationSpecifier(0), changeFlags(0)
{
@@ -8346,7 +7802,7 @@ void QPainterState::init(QPainter *p) {
clipInfo.clear();
worldMatrix.reset();
matrix.reset();
- layoutDirection = QApplication::layoutDirection();
+ layoutDirection = QGuiApplication::layoutDirection();
composition_mode = QPainter::CompositionMode_SourceOver;
emulationSpecifier = 0;
dirtyFlags = 0;
@@ -8355,45 +7811,6 @@ void QPainterState::init(QPainter *p) {
opacity = 1;
}
-#ifdef QT3_SUPPORT
-static void bitBlt_helper(QPaintDevice *dst, const QPoint &dp,
- const QPaintDevice *src, const QRect &sr, bool)
-{
- Q_ASSERT(dst);
- Q_ASSERT(src);
-
- if (src->devType() == QInternal::Pixmap) {
- const QPixmap *pixmap = static_cast<const QPixmap *>(src);
- QPainter pt(dst);
- pt.drawPixmap(dp, *pixmap, sr);
-
- } else {
- qWarning("QPainter: bitBlt only works when source is of type pixmap");
- }
-}
-
-void bitBlt(QPaintDevice *dst, int dx, int dy,
- const QPaintDevice *src, int sx, int sy, int sw, int sh,
- bool ignoreMask )
-{
- bitBlt_helper(dst, QPoint(dx, dy), src, QRect(sx, sy, sw, sh), ignoreMask);
-}
-
-void bitBlt(QPaintDevice *dst, const QPoint &dp, const QPaintDevice *src, const QRect &sr, bool ignoreMask)
-{
- bitBlt_helper(dst, dp, src, sr, ignoreMask);
-}
-
-void bitBlt(QPaintDevice *dst, int dx, int dy,
- const QImage *src, int sx, int sy, int sw, int sh, int fl)
-{
- Qt::ImageConversionFlags flags(fl);
- QPixmap srcPixmap = QPixmap::fromImage(*src, flags);
- bitBlt_helper(dst, QPoint(dx, dy), &srcPixmap, QRect(sx, sy, sw, sh), false);
-}
-
-#endif // QT3_SUPPORT
-
/*!
\fn void QPainter::setBackgroundColor(const QColor &color)
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 30f8da0928..fd40111368 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -49,7 +49,6 @@
#include <QtGui/qpixmap.h>
#include <QtGui/qimage.h>
#include <QtGui/qtextoption.h>
-#include <QtGui/qdrawutil.h>
#ifndef QT_INCLUDE_COMPAT
#include <QtGui/qpolygon.h>
@@ -133,7 +132,7 @@ public:
bool end();
bool isActive() const;
- void initFrom(const QWidget *widget);
+ void initFrom(const QPaintDevice *device);
enum CompositionMode {
CompositionMode_SourceOver,
@@ -464,85 +463,13 @@ public:
void beginNativePainting();
void endNativePainting();
-#ifdef QT3_SUPPORT
-
- inline QT3_SUPPORT void setBackgroundColor(const QColor &color) { setBackground(color); }
- inline QT3_SUPPORT const QColor &backgroundColor() const { return background().color(); }
-
- inline QT3_SUPPORT void drawText(int x, int y, const QString &s, int pos, int len)
- { drawText(x, y, s.mid(pos, len)); }
- inline QT3_SUPPORT void drawText(const QPoint &p, const QString &s, int pos, int len)
- { drawText(p, s.mid(pos, len)); }
- inline QT3_SUPPORT void drawText(int x, int y, const QString &s, int len)
- { drawText(x, y, s.left(len)); }
- inline QT3_SUPPORT void drawText(const QPoint &p, const QString &s, int len)
- { drawText(p, s.left(len)); }
- inline QT3_SUPPORT void drawText(const QRect &r, int flags, const QString &str, int len, QRect *br=0)
- { drawText(r, flags, str.left(len), br); }
- inline QT3_SUPPORT void drawText(int x, int y, int w, int h, int flags, const QString &text, int len, QRect *br=0)
- { drawText(QRect(x, y, w, h), flags, text.left(len), br); }
- inline QT3_SUPPORT QRect boundingRect(const QRect &rect, int flags, const QString &text, int len)
- { return boundingRect(rect, flags, text.left(len)); }
- inline QT3_SUPPORT QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text, int len)
- { return boundingRect(QRect(x, y, w, h), flags, text.left(len)); }
-
- inline QT3_SUPPORT bool begin(QPaintDevice *pdev, const QWidget *init)
- { bool ret = begin(pdev); initFrom(init); return ret; }
- QT3_SUPPORT void drawPoints(const QPolygon &pa, int index, int npoints = -1)
- { drawPoints(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
-
- QT3_SUPPORT void drawCubicBezier(const QPolygon &pa, int index = 0);
-
- QT3_SUPPORT void drawLineSegments(const QPolygon &points, int index = 0, int nlines = -1);
-
- inline QT3_SUPPORT void drawPolyline(const QPolygon &pa, int index, int npoints = -1)
- { drawPolyline(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
-
- inline QT3_SUPPORT void drawPolygon(const QPolygon &pa, bool winding, int index = 0, int npoints = -1)
- { drawPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints,
- winding ? Qt::WindingFill : Qt::OddEvenFill); }
-
- inline QT3_SUPPORT void drawPolygon(const QPolygonF &polygon, bool winding, int index = 0,
- int npoints = -1)
- { drawPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints,
- winding ? Qt::WindingFill : Qt::OddEvenFill); }
-
- inline QT3_SUPPORT void drawConvexPolygon(const QPolygonF &polygon, int index, int npoints = -1)
- { drawConvexPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints); }
- inline QT3_SUPPORT void drawConvexPolygon(const QPolygon &pa, int index, int npoints = -1)
- { drawConvexPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
-
- static inline QT3_SUPPORT void redirect(QPaintDevice *pdev, QPaintDevice *replacement)
- { setRedirected(pdev, replacement); }
- static inline QT3_SUPPORT QPaintDevice *redirect(QPaintDevice *pdev)
- { return const_cast<QPaintDevice*>(redirected(pdev)); }
-
- inline QT3_SUPPORT void setWorldXForm(bool enabled) { setMatrixEnabled(enabled); }
- inline QT3_SUPPORT bool hasWorldXForm() const { return matrixEnabled(); }
- inline QT3_SUPPORT void resetXForm() { resetTransform(); }
-
- inline QT3_SUPPORT void setViewXForm(bool enabled) { setViewTransformEnabled(enabled); }
- inline QT3_SUPPORT bool hasViewXForm() const { return viewTransformEnabled(); }
-
- QT3_SUPPORT void map(int x, int y, int *rx, int *ry) const;
- QT3_SUPPORT QPoint xForm(const QPoint &) const; // map virtual -> deviceb
- QT3_SUPPORT QRect xForm(const QRect &) const;
- QT3_SUPPORT QPolygon xForm(const QPolygon &) const;
- QT3_SUPPORT QPolygon xForm(const QPolygon &, int index, int npoints) const;
- QT3_SUPPORT QPoint xFormDev(const QPoint &) const; // map device -> virtual
- QT3_SUPPORT QRect xFormDev(const QRect &) const;
- QT3_SUPPORT QPolygon xFormDev(const QPolygon &) const;
- QT3_SUPPORT QPolygon xFormDev(const QPolygon &, int index, int npoints) const;
- QT3_SUPPORT qreal translationX() const;
- QT3_SUPPORT qreal translationY() const;
-#endif
-
private:
Q_DISABLE_COPY(QPainter)
friend class Q3Painter;
QScopedPointer<QPainterPrivate> d_ptr;
+ friend class QWidget;
friend class QFontEngine;
friend class QFontEngineBox;
friend class QFontEngineFT;
diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h
index 8cc56befe1..c9e14b6b7b 100644
--- a/src/gui/painting/qpdf_p.h
+++ b/src/gui/painting/qpdf_p.h
@@ -153,8 +153,8 @@ namespace QPdf {
struct PaperSize {
int width, height; // in postscript points
};
- PaperSize paperSize(QPrinter::PaperSize paperSize);
- const char *paperSizeToString(QPrinter::PaperSize paperSize);
+ Q_GUI_EXPORT PaperSize paperSize(QPrinter::PaperSize paperSize);
+ Q_GUI_EXPORT const char *paperSizeToString(QPrinter::PaperSize paperSize);
}
diff --git a/src/gui/painting/qprintengine_mac.mm b/src/gui/painting/qprintengine_mac.mm
deleted file mode 100644
index fb40677e2d..0000000000
--- a/src/gui/painting/qprintengine_mac.mm
+++ /dev/null
@@ -1,911 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qprintengine_mac_p.h>
-#include <qdebug.h>
-#include <qthread.h>
-#include <QtCore/qcoreapplication.h>
-
-#ifndef QT_NO_PRINTER
-
-QT_BEGIN_NAMESPACE
-
-extern QSizeF qt_paperSizeToQSizeF(QPrinter::PaperSize size);
-
-QMacPrintEngine::QMacPrintEngine(QPrinter::PrinterMode mode) : QPaintEngine(*(new QMacPrintEnginePrivate))
-{
- Q_D(QMacPrintEngine);
- d->mode = mode;
- d->initialize();
-}
-
-bool QMacPrintEngine::begin(QPaintDevice *dev)
-{
- Q_D(QMacPrintEngine);
-
- Q_ASSERT(dev && dev->devType() == QInternal::Printer);
- if (!static_cast<QPrinter *>(dev)->isValid())
- return false;
-
- if (d->state == QPrinter::Idle && !d->isPrintSessionInitialized()) // Need to reinitialize
- d->initialize();
-
- d->paintEngine->state = state;
- d->paintEngine->begin(dev);
- Q_ASSERT_X(d->state == QPrinter::Idle, "QMacPrintEngine", "printer already active");
-
- if (PMSessionValidatePrintSettings(d->session, d->settings, kPMDontWantBoolean) != noErr
- || PMSessionValidatePageFormat(d->session, d->format, kPMDontWantBoolean) != noErr) {
- d->state = QPrinter::Error;
- return false;
- }
-
- if (!d->outputFilename.isEmpty()) {
- QCFType<CFURLRef> outFile = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault,
- QCFString(d->outputFilename),
- kCFURLPOSIXPathStyle,
- false);
- if (PMSessionSetDestination(d->session, d->settings, kPMDestinationFile,
- kPMDocumentFormatPDF, outFile) != noErr) {
- qWarning("QMacPrintEngine::begin: Problem setting file [%s]", d->outputFilename.toUtf8().constData());
- return false;
- }
- }
- OSStatus status = noErr;
-#ifndef QT_MAC_USE_COCOA
- status = d->shouldSuppressStatus() ? PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format)
- : PMSessionBeginCGDocument(d->session, d->settings, d->format);
-#else
- status = PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format);
-#endif
-
- if (status != noErr) {
- d->state = QPrinter::Error;
- return false;
- }
-
- d->state = QPrinter::Active;
- setActive(true);
- d->newPage_helper();
- return true;
-}
-
-bool QMacPrintEngine::end()
-{
- Q_D(QMacPrintEngine);
- if (d->state == QPrinter::Aborted)
- return true; // I was just here a function call ago :)
- if(d->paintEngine->type() == QPaintEngine::CoreGraphics) {
- // We dont need the paint engine to call restoreGraphicsState()
- static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->stackCount = 0;
- static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->hd = 0;
- }
- d->paintEngine->end();
- if (d->state != QPrinter::Idle)
- d->releaseSession();
- d->state = QPrinter::Idle;
- return true;
-}
-
-QPaintEngine *
-QMacPrintEngine::paintEngine() const
-{
- return d_func()->paintEngine;
-}
-
-Qt::HANDLE QMacPrintEngine::handle() const
-{
- QCoreGraphicsPaintEngine *cgEngine = static_cast<QCoreGraphicsPaintEngine*>(paintEngine());
- return cgEngine->d_func()->hd;
-}
-
-QMacPrintEnginePrivate::~QMacPrintEnginePrivate()
-{
-#ifdef QT_MAC_USE_COCOA
- [printInfo release];
-#endif
- delete paintEngine;
-}
-
-void QMacPrintEnginePrivate::setPaperSize(QPrinter::PaperSize ps)
-{
- Q_Q(QMacPrintEngine);
- QSizeF newSize = qt_paperSizeToQSizeF(ps);
- QCFType<CFArrayRef> formats;
- PMPrinter printer;
-
- if (PMSessionGetCurrentPrinter(session, &printer) == noErr
- && PMSessionCreatePageFormatList(session, printer, &formats) == noErr) {
- CFIndex total = CFArrayGetCount(formats);
- PMPageFormat tmp;
- PMRect paper;
- for (CFIndex idx = 0; idx < total; ++idx) {
- tmp = static_cast<PMPageFormat>(
- const_cast<void *>(CFArrayGetValueAtIndex(formats, idx)));
- PMGetUnadjustedPaperRect(tmp, &paper);
- int wMM = int((paper.right - paper.left) / 72 * 25.4 + 0.5);
- int hMM = int((paper.bottom - paper.top) / 72 * 25.4 + 0.5);
- if (newSize.width() == wMM && newSize.height() == hMM) {
- PMCopyPageFormat(tmp, format);
- // reset the orientation and resolution as they are lost in the copy.
- q->setProperty(QPrintEngine::PPK_Orientation, orient);
- if (PMSessionValidatePageFormat(session, format, kPMDontWantBoolean) != noErr) {
- // Don't know, warn for the moment.
- qWarning("QMacPrintEngine, problem setting format and resolution for this page size");
- }
- break;
- }
- }
- }
-}
-
-QPrinter::PaperSize QMacPrintEnginePrivate::paperSize() const
-{
- PMRect paper;
- PMGetUnadjustedPaperRect(format, &paper);
- int wMM = int((paper.right - paper.left) / 72 * 25.4 + 0.5);
- int hMM = int((paper.bottom - paper.top) / 72 * 25.4 + 0.5);
- for (int i = QPrinter::A4; i < QPrinter::NPaperSize; ++i) {
- QSizeF s = qt_paperSizeToQSizeF(QPrinter::PaperSize(i));
- if (s.width() == wMM && s.height() == hMM)
- return (QPrinter::PaperSize)i;
- }
- return QPrinter::Custom;
-}
-
-QList<QVariant> QMacPrintEnginePrivate::supportedResolutions() const
-{
- Q_ASSERT_X(session, "QMacPrinterEngine::supportedResolutions",
- "must have a valid printer session");
- UInt32 resCount;
- QList<QVariant> resolutions;
- PMPrinter printer;
- if (PMSessionGetCurrentPrinter(session, &printer) == noErr) {
- PMResolution res;
- OSStatus status = PMPrinterGetPrinterResolutionCount(printer, &resCount);
- if (status == kPMNotImplemented) {
-#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
- // *Sigh* we have to use the non-indexed version.
- if (PMPrinterGetPrinterResolution(printer, kPMMinSquareResolution, &res) == noErr)
- resolutions.append(int(res.hRes));
- if (PMPrinterGetPrinterResolution(printer, kPMMaxSquareResolution, &res) == noErr) {
- QVariant var(int(res.hRes));
- if (!resolutions.contains(var))
- resolutions.append(var);
- }
- if (PMPrinterGetPrinterResolution(printer, kPMDefaultResolution, &res) == noErr) {
- QVariant var(int(res.hRes));
- if (!resolutions.contains(var))
- resolutions.append(var);
- }
-#endif
- } else if (status == noErr) {
- // According to the docs, index start at 1.
- for (UInt32 i = 1; i <= resCount; ++i) {
- if (PMPrinterGetIndexedPrinterResolution(printer, i, &res) == noErr)
- resolutions.append(QVariant(int(res.hRes)));
- }
- } else {
- qWarning("QMacPrintEngine::supportedResolutions: Unexpected error: %ld", long(status));
- }
- }
- return resolutions;
-}
-
-bool QMacPrintEnginePrivate::shouldSuppressStatus() const
-{
- if (suppressStatus == true)
- return true;
-
- // Supress displaying the automatic progress dialog if we are printing
- // from a non-gui thread.
- return (qApp->thread() != QThread::currentThread());
-}
-
-QPrinter::PrinterState QMacPrintEngine::printerState() const
-{
- return d_func()->state;
-}
-
-bool QMacPrintEngine::newPage()
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- OSStatus err =
-#ifndef QT_MAC_USE_COCOA
- d->shouldSuppressStatus() ? PMSessionEndPageNoDialog(d->session)
- : PMSessionEndPage(d->session);
-#else
- PMSessionEndPageNoDialog(d->session);
-#endif
- if (err != noErr) {
- if (err == kPMCancel) {
- // User canceled, we need to abort!
- abort();
- } else {
- // Not sure what the problem is...
- qWarning("QMacPrintEngine::newPage: Cannot end current page. %ld", long(err));
- d->state = QPrinter::Error;
- }
- return false;
- }
- return d->newPage_helper();
-}
-
-bool QMacPrintEngine::abort()
-{
- Q_D(QMacPrintEngine);
- if (d->state != QPrinter::Active)
- return false;
- bool ret = end();
- d->state = QPrinter::Aborted;
- return ret;
-}
-
-static inline int qt_get_PDMWidth(PMPageFormat pformat, bool fullPage,
- const PMResolution &resolution)
-{
- int val = 0;
- PMRect r;
- qreal hRatio = resolution.hRes / 72;
- if (fullPage) {
- if (PMGetAdjustedPaperRect(pformat, &r) == noErr)
- val = qRound((r.right - r.left) * hRatio);
- } else {
- if (PMGetAdjustedPageRect(pformat, &r) == noErr)
- val = qRound((r.right - r.left) * hRatio);
- }
- return val;
-}
-
-static inline int qt_get_PDMHeight(PMPageFormat pformat, bool fullPage,
- const PMResolution &resolution)
-{
- int val = 0;
- PMRect r;
- qreal vRatio = resolution.vRes / 72;
- if (fullPage) {
- if (PMGetAdjustedPaperRect(pformat, &r) == noErr)
- val = qRound((r.bottom - r.top) * vRatio);
- } else {
- if (PMGetAdjustedPageRect(pformat, &r) == noErr)
- val = qRound((r.bottom - r.top) * vRatio);
- }
- return val;
-}
-
-
-int QMacPrintEngine::metric(QPaintDevice::PaintDeviceMetric m) const
-{
- Q_D(const QMacPrintEngine);
- int val = 1;
- switch (m) {
- case QPaintDevice::PdmWidth:
- if (d->hasCustomPaperSize) {
- val = qRound(d->customSize.width());
- if (d->hasCustomPageMargins) {
- val -= qRound(d->leftMargin + d->rightMargin);
- } else {
- QList<QVariant> margins = property(QPrintEngine::PPK_PageMargins).toList();
- val -= qRound(margins.at(0).toDouble() + margins.at(2).toDouble());
- }
- } else {
- val = qt_get_PDMWidth(d->format, property(PPK_FullPage).toBool(), d->resolution);
- }
- break;
- case QPaintDevice::PdmHeight:
- if (d->hasCustomPaperSize) {
- val = qRound(d->customSize.height());
- if (d->hasCustomPageMargins) {
- val -= qRound(d->topMargin + d->bottomMargin);
- } else {
- QList<QVariant> margins = property(QPrintEngine::PPK_PageMargins).toList();
- val -= qRound(margins.at(1).toDouble() + margins.at(3).toDouble());
- }
- } else {
- val = qt_get_PDMHeight(d->format, property(PPK_FullPage).toBool(), d->resolution);
- }
- break;
- case QPaintDevice::PdmWidthMM:
- val = metric(QPaintDevice::PdmWidth);
- val = int((val * 254 + 5 * d->resolution.hRes) / (10 * d->resolution.hRes));
- break;
- case QPaintDevice::PdmHeightMM:
- val = metric(QPaintDevice::PdmHeight);
- val = int((val * 254 + 5 * d->resolution.vRes) / (10 * d->resolution.vRes));
- break;
- case QPaintDevice::PdmPhysicalDpiX:
- case QPaintDevice::PdmPhysicalDpiY: {
- PMPrinter printer;
- if(PMSessionGetCurrentPrinter(d->session, &printer) == noErr) {
- PMResolution resolution;
-#ifndef QT_MAC_USE_COCOA
-# if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
- PMPrinterGetOutputResolution(printer, d->settings, &resolution);
- } else
-# endif
- {
- PMPrinterGetPrinterResolution(printer, kPMCurrentValue, &resolution);
- }
-#else
- PMPrinterGetOutputResolution(printer, d->settings, &resolution);
-#endif
- val = (int)resolution.vRes;
- break;
- }
- //otherwise fall through
- }
- case QPaintDevice::PdmDpiY:
- val = (int)d->resolution.vRes;
- break;
- case QPaintDevice::PdmDpiX:
- val = (int)d->resolution.hRes;
- break;
- case QPaintDevice::PdmNumColors:
- val = (1 << metric(QPaintDevice::PdmDepth));
- break;
- case QPaintDevice::PdmDepth:
- val = 24;
- break;
- default:
- val = 0;
- qWarning("QPrinter::metric: Invalid metric command");
- }
- return val;
-}
-
-void QMacPrintEnginePrivate::initialize()
-{
- Q_Q(QMacPrintEngine);
-
-#ifndef QT_MAC_USE_COCOA
- Q_ASSERT(!session);
-#else
- Q_ASSERT(!printInfo);
-#endif
-
- if (!paintEngine)
- paintEngine = new QCoreGraphicsPaintEngine();
-
- q->gccaps = paintEngine->gccaps;
-
- fullPage = false;
-
-#ifndef QT_MAC_USE_COCOA
- if (PMCreateSession(&session) != 0)
- session = 0;
-#else
- QMacCocoaAutoReleasePool pool;
- printInfo = [[NSPrintInfo alloc] initWithDictionary:[NSDictionary dictionary]];
- session = static_cast<PMPrintSession>([printInfo PMPrintSession]);
-#endif
-
- PMPrinter printer;
- if (session && PMSessionGetCurrentPrinter(session, &printer) == noErr) {
- QList<QVariant> resolutions = supportedResolutions();
- if (!resolutions.isEmpty() && mode != QPrinter::ScreenResolution) {
- if (resolutions.count() > 1 && mode == QPrinter::HighResolution) {
- int max = 0;
- for (int i = 0; i < resolutions.count(); ++i) {
- int value = resolutions.at(i).toInt();
- if (value > max)
- max = value;
- }
- resolution.hRes = resolution.vRes = max;
- } else {
- resolution.hRes = resolution.vRes = resolutions.at(0).toInt();
- }
- if(resolution.hRes == 0)
- resolution.hRes = resolution.vRes = 600;
- } else {
- resolution.hRes = resolution.vRes = qt_defaultDpi();
- }
- }
-
-#ifndef QT_MAC_USE_COCOA
- bool settingsInitialized = (settings != 0);
- bool settingsOK = !settingsInitialized ? PMCreatePrintSettings(&settings) == noErr : true;
- if (settingsOK && !settingsInitialized)
- settingsOK = PMSessionDefaultPrintSettings(session, settings) == noErr;
-
-
- bool formatInitialized = (format != 0);
- bool formatOK = !formatInitialized ? PMCreatePageFormat(&format) == noErr : true;
- if (formatOK) {
- if (!formatInitialized) {
- formatOK = PMSessionDefaultPageFormat(session, format) == noErr;
- }
- formatOK = PMSessionValidatePageFormat(session, format, kPMDontWantBoolean) == noErr;
- }
-#else
- settings = static_cast<PMPrintSettings>([printInfo PMPrintSettings]);
- format = static_cast<PMPageFormat>([printInfo PMPageFormat]);
-#endif
-
-#ifndef QT_MAC_USE_COCOA
- if (!settingsOK || !formatOK) {
- qWarning("QMacPrintEngine::initialize: Unable to initialize QPainter");
- state = QPrinter::Error;
- }
-#endif
-
- QHash<QMacPrintEngine::PrintEnginePropertyKey, QVariant>::const_iterator propC;
- for (propC = valueCache.constBegin(); propC != valueCache.constEnd(); propC++) {
- q->setProperty(propC.key(), propC.value());
- }
-}
-
-void QMacPrintEnginePrivate::releaseSession()
-{
-#ifndef QT_MAC_USE_COCOA
- if (shouldSuppressStatus()) {
- PMSessionEndPageNoDialog(session);
- PMSessionEndDocumentNoDialog(session);
- } else {
- PMSessionEndPage(session);
- PMSessionEndDocument(session);
- }
- PMRelease(session);
-#else
- PMSessionEndPageNoDialog(session);
- PMSessionEndDocumentNoDialog(session);
- [printInfo release];
-#endif
- printInfo = 0;
- session = 0;
-}
-
-bool QMacPrintEnginePrivate::newPage_helper()
-{
- Q_Q(QMacPrintEngine);
- Q_ASSERT(state == QPrinter::Active);
-
- if (PMSessionError(session) != noErr) {
- q->abort();
- return false;
- }
-
- // pop the stack of saved graphic states, in case we get the same
- // context back - either way, the stack count should be 0 when we
- // get the new one
- QCoreGraphicsPaintEngine *cgEngine = static_cast<QCoreGraphicsPaintEngine*>(paintEngine);
- while (cgEngine->d_func()->stackCount > 0)
- cgEngine->d_func()->restoreGraphicsState();
-
- OSStatus status =
-#ifndef QT_MAC_USE_COCOA
- shouldSuppressStatus() ? PMSessionBeginPageNoDialog(session, format, 0)
- : PMSessionBeginPage(session, format, 0);
-#else
- PMSessionBeginPageNoDialog(session, format, 0);
-#endif
- if(status != noErr) {
- state = QPrinter::Error;
- return false;
- }
-
- QRect page = q->property(QPrintEngine::PPK_PageRect).toRect();
- QRect paper = q->property(QPrintEngine::PPK_PaperRect).toRect();
-
- CGContextRef cgContext;
- OSStatus err = noErr;
- err = PMSessionGetCGGraphicsContext(session, &cgContext);
- if(err != noErr) {
- qWarning("QMacPrintEngine::newPage: Cannot retrieve CoreGraphics context: %ld", long(err));
- state = QPrinter::Error;
- return false;
- }
- cgEngine->d_func()->hd = cgContext;
-
- // Set the resolution as a scaling ration of 72 (the default).
- CGContextScaleCTM(cgContext, 72 / resolution.hRes, 72 / resolution.vRes);
-
- CGContextScaleCTM(cgContext, 1, -1);
- CGContextTranslateCTM(cgContext, 0, -paper.height());
- if (!fullPage)
- CGContextTranslateCTM(cgContext, page.x() - paper.x(), page.y() - paper.y());
- cgEngine->d_func()->orig_xform = CGContextGetCTM(cgContext);
- cgEngine->d_func()->setClip(0);
- cgEngine->state->dirtyFlags = QPaintEngine::DirtyFlag(QPaintEngine::AllDirty
- & ~(QPaintEngine::DirtyClipEnabled
- | QPaintEngine::DirtyClipRegion
- | QPaintEngine::DirtyClipPath));
- if (cgEngine->painter()->hasClipping())
- cgEngine->state->dirtyFlags |= QPaintEngine::DirtyClipEnabled;
- cgEngine->syncState();
- return true;
-}
-
-
-void QMacPrintEngine::updateState(const QPaintEngineState &state)
-{
- d_func()->paintEngine->updateState(state);
-}
-
-void QMacPrintEngine::drawRects(const QRectF *r, int num)
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawRects(r, num);
-}
-
-void QMacPrintEngine::drawPoints(const QPointF *points, int pointCount)
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawPoints(points, pointCount);
-}
-
-void QMacPrintEngine::drawEllipse(const QRectF &r)
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawEllipse(r);
-}
-
-void QMacPrintEngine::drawLines(const QLineF *lines, int lineCount)
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawLines(lines, lineCount);
-}
-
-void QMacPrintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawPolygon(points, pointCount, mode);
-}
-
-void QMacPrintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawPixmap(r, pm, sr);
-}
-
-void QMacPrintEngine::drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags)
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawImage(r, pm, sr, flags);
-}
-
-void QMacPrintEngine::drawTextItem(const QPointF &p, const QTextItem &ti)
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawTextItem(p, ti);
-}
-
-void QMacPrintEngine::drawTiledPixmap(const QRectF &dr, const QPixmap &pixmap, const QPointF &sr)
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawTiledPixmap(dr, pixmap, sr);
-}
-
-void QMacPrintEngine::drawPath(const QPainterPath &path)
-{
- Q_D(QMacPrintEngine);
- Q_ASSERT(d->state == QPrinter::Active);
- d->paintEngine->drawPath(path);
-}
-
-
-void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)
-{
- Q_D(QMacPrintEngine);
-
- d->valueCache.insert(key, value);
- if (!d->session)
- return;
-
- switch (key) {
- case PPK_CollateCopies:
- break;
- case PPK_ColorMode:
- break;
- case PPK_Creator:
- break;
- case PPK_DocumentName:
- break;
- case PPK_PageOrder:
- break;
- case PPK_PaperSource:
- break;
- case PPK_SelectionOption:
- break;
- case PPK_Resolution: {
- PMPrinter printer;
- UInt32 count;
- if (PMSessionGetCurrentPrinter(d->session, &printer) != noErr)
- break;
- if (PMPrinterGetPrinterResolutionCount(printer, &count) != noErr)
- break;
- PMResolution resolution = { 0.0, 0.0 };
- PMResolution bestResolution = { 0.0, 0.0 };
- int dpi = value.toInt();
- int bestDistance = INT_MAX;
- for (UInt32 i = 1; i <= count; ++i) { // Yes, it starts at 1
- if (PMPrinterGetIndexedPrinterResolution(printer, i, &resolution) == noErr) {
- if (dpi == int(resolution.hRes)) {
- bestResolution = resolution;
- break;
- } else {
- int distance = qAbs(dpi - int(resolution.hRes));
- if (distance < bestDistance) {
- bestDistance = distance;
- bestResolution = resolution;
- }
- }
- }
- }
- PMSessionValidatePageFormat(d->session, d->format, kPMDontWantBoolean);
- break;
- }
-
- case PPK_FullPage:
- d->fullPage = value.toBool();
- break;
- case PPK_CopyCount: // fallthrough
- case PPK_NumberOfCopies:
- PMSetCopies(d->settings, value.toInt(), false);
- break;
- case PPK_Orientation: {
- if (d->state == QPrinter::Active) {
- qWarning("QMacPrintEngine::setOrientation: Orientation cannot be changed during a print job, ignoring change");
- } else {
- QPrinter::Orientation newOrientation = QPrinter::Orientation(value.toInt());
- if (d->hasCustomPaperSize && (d->orient != newOrientation))
- d->customSize = QSizeF(d->customSize.height(), d->customSize.width());
- d->orient = newOrientation;
- PMOrientation o = d->orient == QPrinter::Portrait ? kPMPortrait : kPMLandscape;
- PMSetOrientation(d->format, o, false);
- PMSessionValidatePageFormat(d->session, d->format, kPMDontWantBoolean);
- }
- break; }
- case PPK_OutputFileName:
- d->outputFilename = value.toString();
- break;
- case PPK_PaperSize:
- d->setPaperSize(QPrinter::PaperSize(value.toInt()));
- break;
- case PPK_PrinterName: {
- bool printerNameSet = false;
- OSStatus status = noErr;
- QCFType<CFArrayRef> printerList;
- status = PMServerCreatePrinterList(kPMServerLocal, &printerList);
- if (status == noErr) {
- CFIndex count = CFArrayGetCount(printerList);
- for (CFIndex i=0; i<count; ++i) {
- PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(printerList, i)));
- QString name = QCFString::toQString(PMPrinterGetName(printer));
- if (name == value.toString()) {
- status = PMSessionSetCurrentPMPrinter(d->session, printer);
- printerNameSet = true;
- break;
- }
- }
- }
- if (status != noErr)
- qWarning("QMacPrintEngine::setPrinterName: Error setting printer: %ld", long(status));
- if (!printerNameSet) {
- qWarning("QMacPrintEngine::setPrinterName: Failed to set printer named '%s'.", qPrintable(value.toString()));
- d->releaseSession();
- d->state = QPrinter::Idle;
- }
- break; }
- case PPK_SuppressSystemPrintStatus:
- d->suppressStatus = value.toBool();
- break;
- case PPK_CustomPaperSize:
- {
- PMOrientation orientation;
- PMGetOrientation(d->format, &orientation);
- d->hasCustomPaperSize = true;
- d->customSize = value.toSizeF();
- if (orientation != kPMPortrait)
- d->customSize = QSizeF(d->customSize.height(), d->customSize.width());
- break;
- }
- case PPK_PageMargins:
- {
- QList<QVariant> margins(value.toList());
- Q_ASSERT(margins.size() == 4);
- d->leftMargin = margins.at(0).toDouble();
- d->topMargin = margins.at(1).toDouble();
- d->rightMargin = margins.at(2).toDouble();
- d->bottomMargin = margins.at(3).toDouble();
- d->hasCustomPageMargins = true;
- break;
- }
-
- default:
- break;
- }
-}
-
-QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
-{
- Q_D(const QMacPrintEngine);
- QVariant ret;
-
- if (!d->session && d->valueCache.contains(key))
- return *d->valueCache.find(key);
-
- switch (key) {
- case PPK_CollateCopies:
- ret = false;
- break;
- case PPK_ColorMode:
- ret = QPrinter::Color;
- break;
- case PPK_Creator:
- break;
- case PPK_DocumentName:
- break;
- case PPK_FullPage:
- ret = d->fullPage;
- break;
- case PPK_NumberOfCopies:
- ret = 1;
- break;
- case PPK_CopyCount: {
- UInt32 copies = 1;
- PMGetCopies(d->settings, &copies);
- ret = (uint) copies;
- break;
- }
- case PPK_SupportsMultipleCopies:
- ret = true;
- break;
- case PPK_Orientation:
- PMOrientation orientation;
- PMGetOrientation(d->format, &orientation);
- ret = orientation == kPMPortrait ? QPrinter::Portrait : QPrinter::Landscape;
- break;
- case PPK_OutputFileName:
- ret = d->outputFilename;
- break;
- case PPK_PageOrder:
- break;
- case PPK_PaperSource:
- break;
- case PPK_PageRect: {
- // PageRect is returned in device pixels
- QRect r;
- PMRect macrect, macpaper;
- qreal hRatio = d->resolution.hRes / 72;
- qreal vRatio = d->resolution.vRes / 72;
- if (d->hasCustomPaperSize) {
- r = QRect(0, 0, qRound(d->customSize.width() * hRatio), qRound(d->customSize.height() * vRatio));
- if (d->hasCustomPageMargins) {
- r.adjust(qRound(d->leftMargin * hRatio), qRound(d->topMargin * vRatio),
- -qRound(d->rightMargin * hRatio), -qRound(d->bottomMargin * vRatio));
- } else {
- QList<QVariant> margins = property(QPrintEngine::PPK_PageMargins).toList();
- r.adjust(qRound(margins.at(0).toDouble() * hRatio),
- qRound(margins.at(1).toDouble() * vRatio),
- -qRound(margins.at(2).toDouble() * hRatio),
- -qRound(margins.at(3).toDouble()) * vRatio);
- }
- } else if (PMGetAdjustedPageRect(d->format, &macrect) == noErr
- && PMGetAdjustedPaperRect(d->format, &macpaper) == noErr)
- {
- if (d->fullPage || d->hasCustomPageMargins) {
- r.setCoords(int(macpaper.left * hRatio), int(macpaper.top * vRatio),
- int(macpaper.right * hRatio), int(macpaper.bottom * vRatio));
- r.translate(-r.x(), -r.y());
- if (d->hasCustomPageMargins) {
- r.adjust(qRound(d->leftMargin * hRatio), qRound(d->topMargin * vRatio),
- -qRound(d->rightMargin * hRatio), -qRound(d->bottomMargin * vRatio));
- }
- } else {
- r.setCoords(int(macrect.left * hRatio), int(macrect.top * vRatio),
- int(macrect.right * hRatio), int(macrect.bottom * vRatio));
- r.translate(int(-macpaper.left * hRatio), int(-macpaper.top * vRatio));
- }
- }
- ret = r;
- break; }
- case PPK_PaperSize:
- ret = d->paperSize();
- break;
- case PPK_PaperRect: {
- QRect r;
- PMRect macrect;
- if (d->hasCustomPaperSize) {
- r = QRect(0, 0, qRound(d->customSize.width()), qRound(d->customSize.height()));
- } else if (PMGetAdjustedPaperRect(d->format, &macrect) == noErr) {
- qreal hRatio = d->resolution.hRes / 72;
- qreal vRatio = d->resolution.vRes / 72;
- r.setCoords(int(macrect.left * hRatio), int(macrect.top * vRatio),
- int(macrect.right * hRatio), int(macrect.bottom * vRatio));
- r.translate(-r.x(), -r.y());
- }
- ret = r;
- break; }
- case PPK_PrinterName: {
- PMPrinter printer;
- OSStatus status = PMSessionGetCurrentPrinter(d->session, &printer);
- if (status != noErr)
- qWarning("QMacPrintEngine::printerName: Failed getting current PMPrinter: %ld", long(status));
- if (printer)
- ret = QCFString::toQString(PMPrinterGetName(printer));
- break; }
- case PPK_Resolution: {
- ret = d->resolution.hRes;
- break;
- }
- case PPK_SupportedResolutions:
- ret = d->supportedResolutions();
- break;
- case PPK_CustomPaperSize:
- ret = d->customSize;
- break;
- case PPK_PageMargins:
- {
- QList<QVariant> margins;
- if (d->hasCustomPageMargins) {
- margins << d->leftMargin << d->topMargin
- << d->rightMargin << d->bottomMargin;
- } else {
- PMPaperMargins paperMargins;
- PMPaper paper;
- PMGetPageFormatPaper(d->format, &paper);
- PMPaperGetMargins(paper, &paperMargins);
- margins << paperMargins.left << paperMargins.top
- << paperMargins.right << paperMargins.bottom;
- }
- ret = margins;
- break;
- }
- default:
- break;
- }
- return ret;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprintengine_mac_p.h b/src/gui/painting/qprintengine_mac_p.h
deleted file mode 100644
index 5c4fe944e0..0000000000
--- a/src/gui/painting/qprintengine_mac_p.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPRINTENGINE_MAC_P_H
-#define QPRINTENGINE_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.
-//
-
-#ifndef QT_NO_PRINTER
-
-#include "QtGui/qprinter.h"
-#include "QtGui/qprintengine.h"
-#include "private/qpaintengine_mac_p.h"
-#include "private/qpainter_p.h"
-
-#ifdef __OBJC__
-@class NSPrintInfo;
-#else
-typedef void NSPrintInfo;
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QPrinterPrivate;
-class QMacPrintEnginePrivate;
-class QMacPrintEngine : public QPaintEngine, public QPrintEngine
-{
- Q_DECLARE_PRIVATE(QMacPrintEngine)
-public:
- QMacPrintEngine(QPrinter::PrinterMode mode);
-
- Qt::HANDLE handle() const;
-
- bool begin(QPaintDevice *dev);
- bool end();
- virtual QPaintEngine::Type type() const { return QPaintEngine::MacPrinter; }
-
- QPaintEngine *paintEngine() const;
-
- void setProperty(PrintEnginePropertyKey key, const QVariant &value);
- QVariant property(PrintEnginePropertyKey key) const;
-
- QPrinter::PrinterState printerState() const;
-
- bool newPage();
- bool abort();
- int metric(QPaintDevice::PaintDeviceMetric) const;
-
- //forwarded functions
-
- void updateState(const QPaintEngineState &state);
-
- virtual void drawLines(const QLineF *lines, int lineCount);
- virtual void drawRects(const QRectF *r, int num);
- virtual void drawPoints(const QPointF *p, int pointCount);
- virtual void drawEllipse(const QRectF &r);
- virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
- virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
- virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags);
- virtual void drawTextItem(const QPointF &p, const QTextItem &ti);
- virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
- virtual void drawPath(const QPainterPath &);
-
-private:
- friend class QPrintDialog;
- friend class QPageSetupDialog;
-};
-
-class QMacPrintEnginePrivate : public QPaintEnginePrivate
-{
- Q_DECLARE_PUBLIC(QMacPrintEngine)
-public:
- QPrinter::PrinterMode mode;
- QPrinter::PrinterState state;
- QPrinter::Orientation orient;
- NSPrintInfo *printInfo;
- PMPageFormat format;
- PMPrintSettings settings;
- PMPrintSession session;
- PMResolution resolution;
- QString outputFilename;
- bool fullPage;
- QPaintEngine *paintEngine;
- bool suppressStatus;
- bool hasCustomPaperSize;
- QSizeF customSize;
- bool hasCustomPageMargins;
- qreal leftMargin;
- qreal topMargin;
- qreal rightMargin;
- qreal bottomMargin;
- QHash<QMacPrintEngine::PrintEnginePropertyKey, QVariant> valueCache;
- QMacPrintEnginePrivate() : mode(QPrinter::ScreenResolution), state(QPrinter::Idle),
- orient(QPrinter::Portrait), printInfo(0), format(0), settings(0),
- session(0), paintEngine(0), suppressStatus(false),
- hasCustomPaperSize(false), hasCustomPageMargins(false) {}
- ~QMacPrintEnginePrivate();
- void initialize();
- void releaseSession();
- bool newPage_helper();
- void setPaperSize(QPrinter::PaperSize ps);
- QPrinter::PaperSize paperSize() const;
- QList<QVariant> supportedResolutions() const;
- inline bool isPrintSessionInitialized() const
- {
-#ifndef QT_MAC_USE_COCOA
- return session != 0;
-#else
- return printInfo != 0;
-#endif
- }
- bool shouldSuppressStatus() const;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTER
-
-#endif // QPRINTENGINE_WIN_P_H
diff --git a/src/gui/painting/qprintengine_ps.cpp b/src/gui/painting/qprintengine_ps.cpp
deleted file mode 100644
index 89bec21f38..0000000000
--- a/src/gui/painting/qprintengine_ps.cpp
+++ /dev/null
@@ -1,972 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-
-#include <private/qprintengine_ps_p.h>
-#include <private/qpainter_p.h>
-#include <private/qfontengine_p.h>
-#include <private/qpaintengine_p.h>
-#include <private/qpdf_p.h>
-
-#ifndef QT_NO_PRINTER
-
-#include "qprinter.h"
-#include "qpainter.h"
-#include "qapplication.h"
-#include "qpixmap.h"
-#include "qimage.h"
-#include "qdatetime.h"
-#include "qstring.h"
-#include "qbytearray.h"
-#include "qhash.h"
-#include "qbuffer.h"
-#include "qsettings.h"
-#include "qmap.h"
-#include "qbitmap.h"
-#include "qregion.h"
-#include "qimagewriter.h"
-#include <private/qpainterpath_p.h>
-#include <qdebug.h>
-#include <private/qdrawhelper_p.h>
-#include <private/qmutexpool_p.h>
-
-#ifndef Q_OS_WIN
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <limits.h>
-
-QT_BEGIN_NAMESPACE
-
-static bool qt_gen_epsf = false;
-
-void qt_generate_epsf(bool b)
-{
- qt_gen_epsf = b;
-}
-
-static const char *const ps_header =
-"/BD{bind def}bind def/d2{dup dup}BD/ED{exch def}BD/D0{0 ED}BD/F{setfont}BD\n"
-"/RL{rlineto}BD/CM{currentmatrix}BD/SM{setmatrix}BD/TR{translate}BD/SD\n"
-"{setdash}BD/SC{aload pop setrgbcolor}BD/CR{currentfile read pop}BD/i{index}\n"
-"BD/scs{setcolorspace}BD/DB{dict dup begin}BD/DE{end def}BD/ie{ifelse}BD/gs\n"
-"{gsave}BD/gr{grestore}BD/w{setlinewidth}BD/d{setdash}BD/J{setlinecap}BD/j\n"
-"{setlinejoin}BD/scn{3 array astore/BCol exch def}BD/SCN{3 array astore/PCol\n"
-"exch def}BD/cm{6 array astore concat}BD/m{moveto}BD/l{lineto}BD/c{curveto}BD\n"
-"/h{closepath}BD/W{clip}BD/W*{eoclip}BD/n{newpath}BD/q{gsave 10 dict begin}BD\n"
-"/Q{end grestore}BD/re{4 2 roll m dup 0 exch RL exch 0 RL 0 exch neg RL h}BD\n"
-"/S{gs PCol SC stroke gr n}BD/BT{gsave 10 dict begin/_m matrix CM def BCol\n"
-"SC}BD/ET{end grestore}BD/Tf{/_fs ED findfont[_fs 0 0 _fs 0 0]makefont F}BD\n"
-"/Tm{6 array astore concat}BD/Td{translate}BD/Tj{0 0 m show}BD/BDC{pop pop}BD\n"
-"/EMC{}BD/BSt 0 def/WFi false def/BCol[1 1 1]def/PCol[0 0 0]def/BDArr[0.94\n"
-"0.88 0.63 0.50 0.37 0.12 0.06]def/level3{/languagelevel where{pop\n"
-"languagelevel 3 ge}{false}ie}BD/QCIgray D0/QCIcolor D0/QCIindex D0/QCI{\n"
-"/colorimage where{pop false 3 colorimage}{exec/QCIcolor ED/QCIgray QCIcolor\n"
-"length 3 idiv string def 0 1 QCIcolor length 3 idiv 1 sub{/QCIindex ED/_x\n"
-"QCIindex 3 mul def QCIgray QCIindex QCIcolor _x get 0.30 mul QCIcolor _x 1\n"
-"add get 0.59 mul QCIcolor _x 2 add get 0.11 mul add add cvi put}for QCIgray\n"
-"image}ie}BD/di{gs TR 1 i 1 eq{pop pop false 3 1 roll BCol SC imagemask}{dup\n"
-"false ne{level3}{false}ie{/_ma ED 8 eq{/_dc[0 1]def/DeviceGray}{/_dc[0 1 0 1\n"
-"0 1]def/DeviceRGB}ie scs/_im ED/_mt ED/_h ED/_w ED <</ImageType 3/DataDict\n"
-"<</ImageType 1/Width _w/Height _h/ImageMatrix _mt/DataSource _im\n"
-"/BitsPerComponent 8/Decode _dc >>/MaskDict <</ImageType 1/Width _w/Height _h\n"
-"/ImageMatrix _mt/DataSource _ma/BitsPerComponent 1/Decode[0 1]>>\n"
-"/InterleaveType 3 >> image}{pop 8 4 1 roll 8 eq{image}{QCI}ie}ie}ie gr}BD/BF\n"
-"{gs BSt 1 eq{BCol SC WFi{fill}{eofill}ie}if BSt 2 ge BSt 8 le and{BDArr BSt\n"
-"2 sub get/_sc ED BCol{1. exch sub _sc mul 1. exch sub}forall 3 array astore\n"
-"SC WFi{fill}{eofill}ie}if BSt 9 ge BSt 14 le and{WFi{W}{W*}ie pathbbox 3 i 3\n"
-"i TR 4 2 roll 3 2 roll exch sub/_h ED sub/_w ED BCol SC 0.3 w n BSt 9 eq BSt\n"
-"11 eq or{0 4 _h{dup 0 exch m _w exch l}for}if BSt 10 eq BSt 11 eq or{0 4 _w{\n"
-"dup 0 m _h l}for}if BSt 12 eq BSt 14 eq or{_w _h gt{0 6 _w _h add{dup 0 m _h\n"
-"sub _h l}for}{0 6 _w _h add{dup 0 exch m _w sub _w exch l}for}ie}if BSt 13\n"
-"eq BSt 14 eq or{_w _h gt{0 6 _w _h add{dup _h m _h sub 0 l}for}{0 6 _w _h\n"
-"add{dup _w exch m _w sub 0 exch l}for}ie}if stroke}if BSt 15 eq{}if BSt 24\n"
-"eq{}if gr}BD/f{/WFi true def BF n}BD/f*{/WFi false def BF n}BD/B{/WFi true\n"
-"def BF S n}BD/B*{/WFi false def BF S n}BD/QI{/C save def pageinit q n}BD/QP{\n"
-"Q C restore showpage}BD/SPD{/setpagedevice where{<< 3 1 roll >>\n"
-"setpagedevice}{pop pop}ie}BD/T1AddMapping{10 dict begin/glyphs ED/fnt ED\n"
-"/current fnt/NumGlyphs get def/CMap fnt/CMap get def 0 1 glyphs length 1 sub\n"
-"{glyphs exch get/gn ED current dup 256 mod/min ED 256 idiv/maj ED CMap dup\n"
-"maj get dup null eq{pop 256 array 0 1 255{1 i exch/.notdef put}for}if dup\n"
-"min gn put maj exch put/current current 1 add def}for fnt/CMap CMap put fnt\n"
-"/NumGlyphs current put end}def/T1AddGlyphs{10 dict begin/glyphs ED/fnt ED\n"
-"/current fnt/NumGlyphs get def/CMap fnt/CMap get def/CharStrings fnt\n"
-"/CharStrings get def 0 1 glyphs length 2 idiv 1 sub{2 mul dup glyphs exch\n"
-"get/gn ED 1 add glyphs exch get/cs ED current dup 256 mod/min ED 256 idiv\n"
-"/maj ED CMap dup maj get dup null eq{pop 256 array 0 1 255{1 i exch/.notdef\n"
-"put}for}if dup min gn put maj exch put CharStrings gn cs put/current current\n"
-"1 add def}for fnt/CharStrings CharStrings put fnt/CMap CMap put fnt\n"
-"/NumGlyphs current put end}def/StringAdd{1 i length 1 i length add string 3\n"
-"1 roll 2 i 0 3 i putinterval 2 i 2 i length 2 i putinterval pop pop}def\n"
-"/T1Setup{10 dict begin dup/FontName ED (-Base) StringAdd cvx cvn/Font ED\n"
-"/MaxPage Font/NumGlyphs get 1 sub 256 idiv def/FDepVector MaxPage 1 add\n"
-"array def/Encoding MaxPage 1 add array def 0 1 MaxPage{dup Encoding exch dup\n"
-"put dup/Page ED FontName (-) StringAdd exch 20 string cvs StringAdd cvn Font\n"
-"0 dict copy d2/CMap get Page get/Encoding exch put definefont FDepVector\n"
-"exch Page exch put}for FontName cvn <</FontType 0/FMapType 2/FontMatrix[1 0\n"
-"0 1 0 0]/Encoding Encoding/FDepVector FDepVector >> definefont pop end}def\n";
-
-
-
-// ------------------------------End of static data ----------------------------------
-
-// make sure DSC comments are not longer than 255 chars per line.
-static QByteArray wrapDSC(const QByteArray &str)
-{
- QByteArray dsc = str.simplified();
- const int wrapAt = 254;
- QByteArray wrapped;
- if (dsc.length() < wrapAt)
- wrapped = dsc;
- else {
- wrapped = dsc.left(wrapAt);
- QByteArray tmp = dsc.mid(wrapAt);
- while (tmp.length() > wrapAt-3) {
- wrapped += "\n%%+" + tmp.left(wrapAt-3);
- tmp = tmp.mid(wrapAt-3);
- }
- wrapped += "\n%%+" + tmp;
- }
- return wrapped + '\n';
-}
-
-// ----------------------------- Internal class declarations -----------------------------
-
-QPSPrintEnginePrivate::QPSPrintEnginePrivate(QPrinter::PrinterMode m)
- : QPdfBaseEnginePrivate(m),
- printerState(QPrinter::Idle), hugeDocument(false), headerDone(false)
-{
- useAlphaEngine = true;
- postscript = true;
-
- firstPage = true;
-
-#ifndef QT_NO_SETTINGS
- QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
- settings.beginGroup(QLatin1String("Qt"));
- embedFonts = settings.value(QLatin1String("embedFonts"), true).toBool();
-#else
- embedFonts = true;
-#endif
-}
-
-QPSPrintEnginePrivate::~QPSPrintEnginePrivate()
-{
-}
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <qdebug.h>
-QT_END_INCLUDE_NAMESPACE
-
-static void ps_r7(QPdf::ByteStream& stream, const char * s, int l)
-{
- int i = 0;
- uchar line[84];
- int col = 0;
-
- while(i < l) {
- line[col++] = s[i++];
- if (i < l - 1 && col >= 76) {
- line[col++] = '\n';
- line[col++] = '\0';
- stream << (const char *)line;
- col = 0;
- }
- }
- if (col > 0) {
- while((col&3) != 0)
- line[col++] = '%'; // use a comment as padding
- line[col++] = '\n';
- line[col++] = '\0';
- stream << (const char *)line;
- }
-}
-
-static QByteArray runlengthEncode(const QByteArray &input)
-{
- if (!input.length())
- return input;
-
- const char *data = input.constData();
-
- QByteArray out;
- int start = 0;
- char last = *data;
-
- enum State {
- Undef,
- Equal,
- Diff
- };
- State state = Undef;
-
- int i = 1;
- int written = 0;
- while (1) {
- bool flush = (i == input.size());
- if (!flush) {
- switch(state) {
- case Undef:
- state = (last == data[i]) ? Equal : Diff;
- break;
- case Equal:
- if (data[i] != last)
- flush = true;
- break;
- case Diff:
- if (data[i] == last) {
- --i;
- flush = true;
- }
- }
- }
- if (flush || i - start == 128) {
- int size = i - start;
- if (state == Equal) {
- out.append((char)(uchar)(257-size));
- out.append(last);
- written += size;
- } else {
- out.append((char)(uchar)size-1);
- while (start < i)
- out.append(data[start++]);
- written += size;
- }
- state = Undef;
- start = i;
- if (i == input.size())
- break;
- }
- last = data[i];
- ++i;
- };
- out.append((char)(uchar)128);
- return out;
-}
-
-enum format {
- Raw,
- Runlength,
- DCT
-};
-static const char *const filters[3] = {
- " ",
- "/RunLengthDecode filter ",
- "/DCTDecode filter "
-};
-
-static QByteArray compressHelper(const QImage &image, bool gray, int *format)
-{
- // we can't use premultiplied here
- QByteArray pixelData;
- int depth = image.depth();
-
- Q_ASSERT(image.format() != QImage::Format_ARGB32_Premultiplied);
-
- if (depth != 1 && !gray && QImageWriter::supportedImageFormats().contains("jpeg")) {
- QBuffer buffer(&pixelData);
- QImageWriter writer(&buffer, "jpeg");
- writer.setQuality(94);
- writer.write(image);
- *format = DCT;
- } else {
- int width = image.width();
- int height = image.height();
- int size = width*height;
-
- if (depth == 1)
- size = (width+7)/8*height;
- else if (!gray)
- size = size*3;
-
- pixelData.resize(size);
- uchar *pixel = (uchar *)pixelData.data();
- int i = 0;
- if (depth == 1) {
- QImage::Format format = image.format();
- memset(pixel, 0xff, size);
- for(int y=0; y < height; y++) {
- const uchar * s = image.scanLine(y);
- for(int x=0; x < width; x++) {
- // need to copy bit for bit...
- bool b = (format == QImage::Format_MonoLSB) ?
- (*(s + (x >> 3)) >> (x & 7)) & 1 :
- (*(s + (x >> 3)) << (x & 7)) & 0x80 ;
- if (b)
- pixel[i >> 3] ^= (0x80 >> (i & 7));
- i++;
- }
- // we need to align to 8 bit here
- i = (i+7) & 0xffffff8;
- }
- } else if (depth == 8) {
- for(int y=0; y < height; y++) {
- const uchar * s = image.scanLine(y);
- for(int x=0; x < width; x++) {
- QRgb rgb = image.color(s[x]);
- if (gray) {
- pixel[i] = (unsigned char) qGray(rgb);
- i++;
- } else {
- pixel[i] = (unsigned char) qRed(rgb);
- pixel[i+1] = (unsigned char) qGreen(rgb);
- pixel[i+2] = (unsigned char) qBlue(rgb);
- i += 3;
- }
- }
- }
- } else {
- for(int y=0; y < height; y++) {
- QRgb * s = (QRgb*)(image.scanLine(y));
- for(int x=0; x < width; x++) {
- QRgb rgb = (*s++);
- if (gray) {
- pixel[i] = (unsigned char) qGray(rgb);
- i++;
- } else {
- pixel[i] = (unsigned char) qRed(rgb);
- pixel[i+1] = (unsigned char) qGreen(rgb);
- pixel[i+2] = (unsigned char) qBlue(rgb);
- i += 3;
- }
- }
- }
- }
- *format = Raw;
- if (depth == 1) {
- pixelData = runlengthEncode(pixelData);
- *format = Runlength;
- }
- }
- QByteArray outarr = QPdf::ascii85Encode(pixelData);
- return outarr;
-}
-
-void QPSPrintEnginePrivate::drawImageHelper(qreal x, qreal y, qreal w, qreal h, const QImage &img,
- const QImage &mask, bool gray, qreal scaleX, qreal scaleY)
-{
- Q_UNUSED(h);
- Q_UNUSED(w);
- int width = img.width();
- int height = img.height();
-
- QByteArray out;
- int size = 0;
- const char *bits;
-
- if (!mask.isNull()) {
- int format;
-