summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/dialogs/qcolordialog.cpp6
-rw-r--r--src/gui/dialogs/qprintdialog_qws.cpp6
-rw-r--r--src/gui/dialogs/qprintdialog_unix.cpp6
-rw-r--r--src/gui/effects/qgraphicseffect.cpp26
-rw-r--r--src/gui/egl/qegl.cpp87
-rw-r--r--src/gui/egl/qegl_p.h12
-rw-r--r--src/gui/egl/qegl_qws.cpp6
-rw-r--r--src/gui/egl/qegl_symbian.cpp12
-rw-r--r--src/gui/egl/qegl_wince.cpp13
-rw-r--r--src/gui/egl/qegl_x11.cpp7
-rw-r--r--src/gui/egl/qeglproperties.cpp6
-rw-r--r--src/gui/embedded/directfb.pri2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp35
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp33
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp4
-rw-r--r--src/gui/gui.pro27
-rw-r--r--src/gui/image/image.pri4
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks.cpp21
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks_p.h3
-rw-r--r--src/gui/image/qpixmap.cpp9
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp5
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp5
-rw-r--r--src/gui/itemviews/qtreeview.cpp9
-rw-r--r--src/gui/kernel/qapplication.cpp6
-rw-r--r--src/gui/kernel/qapplication_x11.cpp116
-rw-r--r--src/gui/kernel/qeventdispatcher_mac.mm8
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp29
-rw-r--r--src/gui/kernel/qsoftkeymanager_p.h2
-rw-r--r--src/gui/kernel/qt_x11_p.h5
-rw-r--r--src/gui/painting/qbezier.cpp36
-rw-r--r--src/gui/painting/qbezier_p.h6
-rw-r--r--src/gui/painting/qcups.cpp4
-rw-r--r--src/gui/painting/qdrawhelper.cpp49
-rw-r--r--src/gui/painting/qdrawhelper_neon.cpp130
-rw-r--r--src/gui/painting/qdrawhelper_sse2.cpp211
-rw-r--r--src/gui/painting/qdrawhelper_x86_p.h8
-rw-r--r--src/gui/painting/qemulationpaintengine.cpp5
-rw-r--r--src/gui/painting/qemulationpaintengine_p.h1
-rw-r--r--src/gui/painting/qpaintbuffer.cpp141
-rw-r--r--src/gui/painting/qpaintbuffer_p.h5
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp59
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h5
-rw-r--r--src/gui/painting/qpaintengineex_p.h3
-rw-r--r--src/gui/painting/qpainter.cpp144
-rw-r--r--src/gui/painting/qpainter.h15
-rw-r--r--src/gui/painting/qpathclipper.cpp259
-rw-r--r--src/gui/painting/qpathclipper_p.h1
-rw-r--r--src/gui/painting/qpdf.cpp12
-rw-r--r--src/gui/painting/qpdf_p.h2
-rw-r--r--src/gui/painting/qprintengine.h2
-rw-r--r--src/gui/painting/qprintengine_mac.mm10
-rw-r--r--src/gui/painting/qprintengine_qws.cpp5
-rw-r--r--src/gui/painting/qprintengine_win.cpp9
-rw-r--r--src/gui/painting/qprintengine_win_p.h1
-rw-r--r--src/gui/painting/qprinter.cpp99
-rw-r--r--src/gui/painting/qprinter.h4
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp43
-rw-r--r--src/gui/painting/qtextureglyphcache_p.h11
-rw-r--r--src/gui/styles/qs60style.cpp37
-rw-r--r--src/gui/styles/qs60style_p.h3
-rw-r--r--src/gui/text/qfontdatabase_win.cpp14
-rw-r--r--src/gui/text/qstatictext.cpp616
-rw-r--r--src/gui/text/qstatictext.h106
-rw-r--r--src/gui/text/qstatictext_p.h146
-rw-r--r--src/gui/text/qtextcursor.cpp26
-rw-r--r--src/gui/text/qtextcursor.h1
-rw-r--r--src/gui/text/qtextdocument.cpp4
-rw-r--r--src/gui/text/text.pri7
-rw-r--r--src/gui/util/qdesktopservices_s60.cpp8
-rw-r--r--src/gui/widgets/qcombobox.cpp6
-rw-r--r--src/gui/widgets/qdockarealayout.cpp2
-rw-r--r--src/gui/widgets/qdockwidget.cpp2
-rw-r--r--src/gui/widgets/qmainwindow.cpp5
-rw-r--r--src/gui/widgets/qmainwindowlayout.cpp1
-rw-r--r--src/gui/widgets/qmenu.cpp20
-rw-r--r--src/gui/widgets/qplaintextedit.cpp20
-rw-r--r--src/gui/widgets/qplaintextedit.h2
77 files changed, 2358 insertions, 458 deletions
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index 83ecc30..e6abf7f 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -1078,8 +1078,7 @@ QColorShower::QColorShower(QColorDialog *parent)
#ifdef QT_SMALL_COLORDIALOG
# ifdef Q_WS_S60
- QS60Data s60Data = QS60Data();
- const bool nonTouchUI = !s60Data.hasTouchscreen;
+ const bool nonTouchUI = !S60->hasTouchscreen;
# elif defined Q_WS_MAEMO_5
const bool nonTouchUI = false;
# endif
@@ -1506,8 +1505,7 @@ void QColorDialogPrivate::init(const QColor &initial)
#if defined(QT_SMALL_COLORDIALOG)
# if defined(Q_WS_S60)
- QS60Data s60Data = QS60Data();
- const bool nonTouchUI = !s60Data.hasTouchscreen;
+ const bool nonTouchUI = !S60->hasTouchscreen;
# elif defined(Q_WS_MAEMO_5)
const bool nonTouchUI = false;
# endif
diff --git a/src/gui/dialogs/qprintdialog_qws.cpp b/src/gui/dialogs/qprintdialog_qws.cpp
index 6b531a2..1336c04 100644
--- a/src/gui/dialogs/qprintdialog_qws.cpp
+++ b/src/gui/dialogs/qprintdialog_qws.cpp
@@ -163,7 +163,7 @@ void QPrintDialogPrivate::_q_okClicked()
printer->setPaperSize(pageSize);
printer->setPageOrder(pageOrder2);
printer->setColorMode(colorMode2);
- printer->setNumCopies(numCopies);
+ printer->setCopyCount(numCopies);
switch ((rangeCombo->itemData(rangeCombo->currentIndex())).toInt()){
case (int)QPrintDialog::AllPages:
@@ -479,8 +479,8 @@ void QPrintDialogPrivate::setPrinter(QPrinter *p, bool pickUpSettings)
printGray->setChecked(true);
// number of copies
- copies->setValue(p->numCopies());
- _q_setNumCopies(p->numCopies());
+ copies->setValue(p->copyCount());
+ _q_setNumCopies(p->copyCount());
}
if (p) {
diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp
index 23f5831..2d169cf 100644
--- a/src/gui/dialogs/qprintdialog_unix.cpp
+++ b/src/gui/dialogs/qprintdialog_unix.cpp
@@ -72,8 +72,6 @@
QT_BEGIN_NAMESPACE
-extern int qt_printerRealNumCopies(QPaintEngine *);
-
class QOptionTreeItem;
class QPPDOptionsModel;
@@ -439,7 +437,7 @@ void QPrintDialogPrivate::applyPrinterProperties(QPrinter *p)
case QPrinter::DuplexShortSide:
options.duplexShort->setChecked(true); break;
}
- options.copies->setValue(qt_printerRealNumCopies(p->paintEngine()));
+ options.copies->setValue(p->copyCount());
options.collate->setChecked(p->collateCopies());
options.reverse->setChecked(p->pageOrder() == QPrinter::LastPageFirst);
top->d->applyPrinterProperties(p);
@@ -510,7 +508,7 @@ void QPrintDialogPrivate::setupPrinter()
}
// copies
- p->setNumCopies(options.copies->value());
+ p->setCopyCount(options.copies->value());
p->setCollateCopies(options.collate->isChecked());
top->d->setupPrinter();
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index 10ef5ea..ce4ce6a 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -699,12 +699,17 @@ void QGraphicsColorizeEffect::draw(QPainter *painter)
if (sourceIsPixmap()) {
// No point in drawing in device coordinates (pixmap will be scaled anyways).
const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad);
- d->filter->draw(painter, offset, pixmap);
+ if (!pixmap.isNull())
+ d->filter->draw(painter, offset, pixmap);
+
return;
}
// Draw pixmap in deviceCoordinates to avoid pixmap scaling.
const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
+ if (pixmap.isNull())
+ return;
+
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
d->filter->draw(painter, offset, pixmap);
@@ -721,7 +726,8 @@ void QGraphicsColorizeEffect::draw(QPainter *painter)
elements. The level of detail can be modified using the setBlurRadius()
function. Use setBlurHints() to choose the blur hints.
- By default, the blur radius is 5 pixels.
+ By default, the blur radius is 5 pixels. The blur radius is specified in
+ device coordinates.
\img graphicseffect-blur.png
@@ -776,6 +782,9 @@ QGraphicsBlurEffect::~QGraphicsBlurEffect()
radius results in a more blurred appearance.
By default, the blur radius is 5 pixels.
+
+ The radius is given in device coordinates, meaning it is
+ unaffected by scale.
*/
qreal QGraphicsBlurEffect::blurRadius() const
{
@@ -858,9 +867,11 @@ void QGraphicsBlurEffect::draw(QPainter *painter)
if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
mode = NoPad;
- // Draw pixmap in device coordinates to avoid pixmap scaling.
QPoint offset;
QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, mode);
+ if (pixmap.isNull())
+ return;
+
d->filter->draw(painter, offset, pixmap);
}
@@ -877,7 +888,8 @@ void QGraphicsBlurEffect::draw(QPainter *painter)
By default, the drop shadow is a semi-transparent dark gray
(QColor(63, 63, 63, 180)) shadow, blurred with a radius of 1 at an offset
- of 8 pixels towards the lower right.
+ of 8 pixels towards the lower right. The drop shadow offset is specified
+ in device coordinates.
\img graphicseffect-drop-shadow.png
@@ -906,6 +918,9 @@ QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect()
By default, the offset is 8 pixels towards the lower right.
+ The offset is given in device coordinates, which means it is
+ unaffected by scale.
+
\sa xOffset(), yOffset(), blurRadius(), color()
*/
QPointF QGraphicsDropShadowEffect::offset() const
@@ -1047,6 +1062,9 @@ void QGraphicsDropShadowEffect::draw(QPainter *painter)
// Draw pixmap in device coordinates to avoid pixmap scaling.
QPoint offset;
const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode);
+ if (pixmap.isNull())
+ return;
+
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
d->filter->draw(painter, offset, pixmap);
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp
index ae3d6c3..0ed95ea 100644
--- a/src/gui/egl/qegl.cpp
+++ b/src/gui/egl/qegl.cpp
@@ -54,9 +54,10 @@ QT_BEGIN_NAMESPACE
static QEglContext * volatile currentGLContext = 0;
static QEglContext * volatile currentVGContext = 0;
+EGLDisplay QEglContext::dpy = EGL_NO_DISPLAY;
+
QEglContext::QEglContext()
: apiType(QEgl::OpenGL)
- , dpy(EGL_NO_DISPLAY)
, ctx(EGL_NO_CONTEXT)
, cfg(0)
, currentSurface(EGL_NO_SURFACE)
@@ -68,7 +69,7 @@ QEglContext::QEglContext()
QEglContext::~QEglContext()
{
- destroy();
+ destroyContext();
if (currentGLContext == this)
currentGLContext = 0;
@@ -86,14 +87,6 @@ bool QEglContext::isCurrent() const
return current;
}
-// Open the EGL display associated with "device".
-bool QEglContext::openDisplay(QPaintDevice *device)
-{
- if (dpy == EGL_NO_DISPLAY)
- dpy = defaultDisplay(device);
- return (dpy != EGL_NO_DISPLAY);
-}
-
// Choose a configuration that matches "properties".
bool QEglContext::chooseConfig
(const QEglProperties& properties, QEgl::PixelFormatMatch match)
@@ -102,13 +95,13 @@ bool QEglContext::chooseConfig
do {
// Get the number of matching configurations for this set of properties.
EGLint matching = 0;
- if (!eglChooseConfig(dpy, props.properties(), 0, 0, &matching) || !matching)
+ if (!eglChooseConfig(display(), props.properties(), 0, 0, &matching) || !matching)
continue;
// If we want the best pixel format, then return the first
// matching configuration.
if (match == QEgl::BestPixelFormat) {
- eglChooseConfig(dpy, props.properties(), &cfg, 1, &matching);
+ eglChooseConfig(display(), props.properties(), &cfg, 1, &matching);
if (matching < 1)
continue;
return true;
@@ -118,13 +111,13 @@ bool QEglContext::chooseConfig
// first that matches the pixel format we wanted.
EGLint size = matching;
EGLConfig *configs = new EGLConfig [size];
- eglChooseConfig(dpy, props.properties(), configs, size, &matching);
+ eglChooseConfig(display(), props.properties(), configs, size, &matching);
for (EGLint index = 0; index < size; ++index) {
EGLint red, green, blue, alpha;
- eglGetConfigAttrib(dpy, configs[index], EGL_RED_SIZE, &red);
- eglGetConfigAttrib(dpy, configs[index], EGL_GREEN_SIZE, &green);
- eglGetConfigAttrib(dpy, configs[index], EGL_BLUE_SIZE, &blue);
- eglGetConfigAttrib(dpy, configs[index], EGL_ALPHA_SIZE, &alpha);
+ eglGetConfigAttrib(display(), configs[index], EGL_RED_SIZE, &red);
+ eglGetConfigAttrib(display(), configs[index], EGL_GREEN_SIZE, &green);
+ eglGetConfigAttrib(display(), configs[index], EGL_BLUE_SIZE, &blue);
+ eglGetConfigAttrib(display(), configs[index], EGL_ALPHA_SIZE, &alpha);
if (red == props.value(EGL_RED_SIZE) &&
green == props.value(EGL_GREEN_SIZE) &&
blue == props.value(EGL_BLUE_SIZE) &&
@@ -179,7 +172,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties
if (shareContext && shareContext->ctx == EGL_NO_CONTEXT)
shareContext = 0;
if (shareContext) {
- ctx = eglCreateContext(dpy, cfg, shareContext->ctx, contextProps.properties());
+ ctx = eglCreateContext(display(), cfg, shareContext->ctx, contextProps.properties());
if (ctx == EGL_NO_CONTEXT) {
qWarning() << "QEglContext::createContext(): Could not share context:" << errorString(eglGetError());
shareContext = 0;
@@ -188,7 +181,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties
}
}
if (ctx == EGL_NO_CONTEXT) {
- ctx = eglCreateContext(dpy, cfg, 0, contextProps.properties());
+ ctx = eglCreateContext(display(), cfg, 0, contextProps.properties());
if (ctx == EGL_NO_CONTEXT) {
qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << errorString(eglGetError());
return false;
@@ -204,16 +197,15 @@ void QEglContext::destroySurface(EGLSurface surface)
if (surface != EGL_NO_SURFACE) {
if (surface == currentSurface)
doneCurrent();
- eglDestroySurface(dpy, surface);
+ eglDestroySurface(display(), surface);
}
}
// Destroy the context. Note: this does not destroy the surface.
-void QEglContext::destroy()
+void QEglContext::destroyContext()
{
if (ctx != EGL_NO_CONTEXT && ownsContext)
- eglDestroyContext(dpy, ctx);
- dpy = EGL_NO_DISPLAY;
+ eglDestroyContext(display(), ctx);
ctx = EGL_NO_CONTEXT;
cfg = 0;
}
@@ -248,7 +240,7 @@ bool QEglContext::makeCurrent(EGLSurface surface)
eglBindAPI(EGL_OPENVG_API);
#endif
- bool ok = eglMakeCurrent(dpy, surface, surface, ctx);
+ bool ok = eglMakeCurrent(display(), surface, surface, ctx);
if (!ok)
qWarning() << "QEglContext::makeCurrent():" << errorString(eglGetError());
return ok;
@@ -277,7 +269,7 @@ bool QEglContext::doneCurrent()
eglBindAPI(EGL_OPENVG_API);
#endif
- bool ok = eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ bool ok = eglMakeCurrent(display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (!ok)
qWarning() << "QEglContext::doneCurrent():" << errorString(eglGetError());
return ok;
@@ -299,7 +291,7 @@ bool QEglContext::swapBuffers(EGLSurface surface)
if(ctx == EGL_NO_CONTEXT)
return false;
- bool ok = eglSwapBuffers(dpy, surface);
+ bool ok = eglSwapBuffers(display(), surface);
if (!ok)
qWarning() << "QEglContext::swapBuffers():" << errorString(eglGetError());
return ok;
@@ -338,7 +330,7 @@ void QEglContext::waitClient()
// Query the value of a configuration attribute.
bool QEglContext::configAttrib(int name, EGLint *value) const
{
- return eglGetConfigAttrib(dpy, cfg, name, value);
+ return eglGetConfigAttrib(display(), cfg, name, value);
}
// Retrieve all of the properties on "cfg". If zero, return
@@ -350,34 +342,45 @@ QEglProperties QEglContext::configProperties(EGLConfig cfg) const
QEglProperties props;
for (int name = 0x3020; name <= 0x304F; ++name) {
EGLint value;
- if (name != EGL_NONE && eglGetConfigAttrib(dpy, cfg, name, &value))
+ if (name != EGL_NONE && eglGetConfigAttrib(display(), cfg, name, &value))
props.setValue(name, value);
}
eglGetError(); // Clear the error state.
return props;
}
-// Initialize and return the default display.
-EGLDisplay QEglContext::defaultDisplay(QPaintDevice *device)
+EGLDisplay QEglContext::display()
{
- static EGLDisplay dpy = EGL_NO_DISPLAY;
- if (dpy == EGL_NO_DISPLAY) {
- dpy = getDisplay(device);
+ static bool openedDisplay = false;
+
+ if (!openedDisplay) {
+ dpy = eglGetDisplay(nativeDisplay());
+ openedDisplay = true;
+ if (dpy == EGL_NO_DISPLAY) {
+ qWarning("QEglContext::display(): Falling back to EGL_DEFAULT_DISPLAY");
+ dpy = eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY));
+ }
if (dpy == EGL_NO_DISPLAY) {
- qWarning() << "QEglContext::defaultDisplay(): Cannot open EGL display";
+ qWarning("QEglContext::display(): Can't even open the default display");
return EGL_NO_DISPLAY;
}
+
if (!eglInitialize(dpy, NULL, NULL)) {
- qWarning() << "QEglContext::defaultDisplay(): Cannot initialize EGL display:" << errorString(eglGetError());
+ qWarning() << "QEglContext::display(): Cannot initialize EGL display:" << errorString(eglGetError());
return EGL_NO_DISPLAY;
}
-#ifdef EGL_OPENGL_ES_API
- eglBindAPI(EGL_OPENGL_ES_API);
-#endif
}
+
return dpy;
}
+#if !defined(Q_WS_X11) && !defined(Q_WS_WINCE) // WinCE & X11 implement this properly
+EGLNativeDisplayType QEglContext::nativeDisplay()
+{
+ return EGL_DEFAULT_DISPLAY;
+}
+#endif
+
// Return the error string associated with a specific code.
QString QEglContext::errorString(EGLint code)
{
@@ -410,10 +413,10 @@ void QEglContext::dumpAllConfigs()
{
QEglProperties props;
EGLint count = 0;
- if (!eglGetConfigs(dpy, 0, 0, &count) || count < 1)
+ if (!eglGetConfigs(display(), 0, 0, &count) || count < 1)
return;
EGLConfig *configs = new EGLConfig [count];
- eglGetConfigs(dpy, configs, count, &count);
+ eglGetConfigs(display(), configs, count, &count);
for (EGLint index = 0; index < count; ++index) {
props = configProperties(configs[index]);
qWarning() << props.toString();
@@ -423,7 +426,7 @@ void QEglContext::dumpAllConfigs()
QString QEglContext::extensions()
{
- const char* exts = eglQueryString(QEglContext::defaultDisplay(0), EGL_EXTENSIONS);
+ const char* exts = eglQueryString(QEglContext::display(), EGL_EXTENSIONS);
return QString(QLatin1String(exts));
}
@@ -431,7 +434,7 @@ bool QEglContext::hasExtension(const char* extensionName)
{
QList<QByteArray> extensions =
QByteArray(reinterpret_cast<const char *>
- (eglQueryString(QEglContext::defaultDisplay(0), EGL_EXTENSIONS))).split(' ');
+ (eglQueryString(QEglContext::display(), EGL_EXTENSIONS))).split(' ');
return extensions.contains(extensionName);
}
diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h
index a7de9c8..87ed818 100644
--- a/src/gui/egl/qegl_p.h
+++ b/src/gui/egl/qegl_p.h
@@ -86,14 +86,12 @@ public:
QEgl::API api() const { return apiType; }
void setApi(QEgl::API api) { apiType = api; }
- bool openDisplay(QPaintDevice *device);
bool chooseConfig(const QEglProperties& properties, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat);
bool createContext(QEglContext *shareContext = 0, const QEglProperties *properties = 0);
+ void destroyContext();
EGLSurface createSurface(QPaintDevice *device, const QEglProperties *properties = 0);
void destroySurface(EGLSurface surface);
- void destroy();
-
bool makeCurrent(EGLSurface surface);
bool doneCurrent();
bool lazyDoneCurrent();
@@ -108,7 +106,7 @@ public:
static EGLint error() { return eglGetError(); }
static QString errorString(EGLint code);
- EGLDisplay display() const { return dpy; }
+ static EGLDisplay display();
EGLContext context() const { return ctx; }
void setContext(EGLContext context) { ctx = context; ownsContext = false;}
@@ -118,8 +116,6 @@ public:
QEglProperties configProperties(EGLConfig cfg = 0) const;
- static EGLDisplay defaultDisplay(QPaintDevice *device);
-
void dumpAllConfigs();
static QString extensions();
@@ -127,7 +123,6 @@ public:
private:
QEgl::API apiType;
- EGLDisplay dpy;
EGLContext ctx;
EGLConfig cfg;
EGLSurface currentSurface;
@@ -135,7 +130,8 @@ private:
bool ownsContext;
bool sharing;
- static EGLDisplay getDisplay(QPaintDevice *device);
+ static EGLDisplay dpy;
+ static EGLNativeDisplayType nativeDisplay();
static QEglContext *currentContext(QEgl::API api);
static void setCurrentContext(QEgl::API api, QEglContext *context);
diff --git a/src/gui/egl/qegl_qws.cpp b/src/gui/egl/qegl_qws.cpp
index e999e0b..2a61beb 100644
--- a/src/gui/egl/qegl_qws.cpp
+++ b/src/gui/egl/qegl_qws.cpp
@@ -64,12 +64,6 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties
return EGL_NO_SURFACE;
}
-EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
-{
- Q_UNUSED(device);
- return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY));
-}
-
static QScreen *screenForDevice(QPaintDevice *device)
{
QScreen *screen = qt_screen;
diff --git a/src/gui/egl/qegl_symbian.cpp b/src/gui/egl/qegl_symbian.cpp
index 44ecd19..5a010cd 100644
--- a/src/gui/egl/qegl_symbian.cpp
+++ b/src/gui/egl/qegl_symbian.cpp
@@ -78,22 +78,14 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties
props = 0;
EGLSurface surf;
if (devType == QInternal::Widget)
- surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, 0);
+ surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, props);
else
- surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, 0);
+ surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, props);
if (surf == EGL_NO_SURFACE)
qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
return surf;
}
-EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
-{
- EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- if (dpy == EGL_NO_DISPLAY)
- qWarning("QEglContext::defaultDisplay(): Falling back to EGL_DEFAULT_DISPLAY");
- return dpy;
-}
-
// Set pixel format and other properties based on a paint device.
void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev)
{
diff --git a/src/gui/egl/qegl_wince.cpp b/src/gui/egl/qegl_wince.cpp
index 026a7b1..c9c9773 100644
--- a/src/gui/egl/qegl_wince.cpp
+++ b/src/gui/egl/qegl_wince.cpp
@@ -87,20 +87,15 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties
return surf;
}
-EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
+EGLNativeDisplayType QEglContext::nativeDisplay()
{
- EGLDisplay dpy = 0;
HWND win = (static_cast<QWidget*>(device))->winId();
HDC myDc = GetDC(win);
if (!myDc) {
- qWarning("QEglContext::defaultDisplay(): WinCE display is not open");
+ qWarning("QEglContext::nativeDisplay(): WinCE display is not open");
+ return EGL_DEFAULT_DISPLAY;
}
- dpy = eglGetDisplay(EGLNativeDisplayType(myDc));
- if (dpy == EGL_NO_DISPLAY) {
- qWarning("QEglContext::defaultDisplay(): Falling back to EGL_DEFAULT_DISPLAY");
- dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- }
- return dpy;
+ return EGLNativeDisplayType(myDc);
}
// Set pixel format and other properties based on a paint device.
diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp
index 2cf4e33..634ff13 100644
--- a/src/gui/egl/qegl_x11.cpp
+++ b/src/gui/egl/qegl_x11.cpp
@@ -93,15 +93,14 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties
return surf;
}
-EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
+EGLNativeDisplayType QEglContext::nativeDisplay()
{
- Q_UNUSED(device);
Display *xdpy = QX11Info::display();
if (!xdpy) {
qWarning("QEglContext::getDisplay(): X11 display is not open");
- return EGL_NO_DISPLAY;
+ return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY);
}
- return eglGetDisplay(EGLNativeDisplayType(xdpy));
+ return EGLNativeDisplayType(xdpy);
}
static int countBits(unsigned long mask)
diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp
index 2915fb9..236ec37 100644
--- a/src/gui/egl/qeglproperties.cpp
+++ b/src/gui/egl/qeglproperties.cpp
@@ -60,7 +60,7 @@ QEglProperties::QEglProperties(EGLConfig cfg)
props.append(EGL_NONE);
for (int name = 0x3020; name <= 0x304F; ++name) {
EGLint value;
- if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::defaultDisplay(0), cfg, name, &value))
+ if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::display(), cfg, name, &value))
setValue(name, value);
}
eglGetError(); // Clear the error state.
@@ -273,12 +273,12 @@ static void addTag(QString& str, const QString& tag)
void QEglProperties::dumpAllConfigs()
{
EGLint count = 0;
- eglGetConfigs(QEglContext::defaultDisplay(0), 0, 0, &count);
+ eglGetConfigs(QEglContext::display(), 0, 0, &count);
if (count < 1)
return;
EGLConfig *configs = new EGLConfig [count];
- eglGetConfigs(QEglContext::defaultDisplay(0), configs, count, &count);
+ eglGetConfigs(QEglContext::display(), configs, count, &count);
for (EGLint index = 0; index < count; ++index)
qWarning() << QEglProperties(configs[index]).toString();
delete [] configs;
diff --git a/src/gui/embedded/directfb.pri b/src/gui/embedded/directfb.pri
index bd1d947..d6d77b4 100644
--- a/src/gui/embedded/directfb.pri
+++ b/src/gui/embedded/directfb.pri
@@ -15,7 +15,7 @@
#DEFINES += QT_DIRECTFB_TIMING
#DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION
#DEFINES += QT_NO_DIRECTFB_STRETCHBLIT
-#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS|DRAW_ROUNDED_RECT
+#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS|DRAW_ROUNDED_RECT|DRAW_STATICTEXT
#DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\"
#DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\"
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 63b0ec7..ca20101 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -357,19 +357,22 @@
default, child items are stacked on top of the parent item. But setting
this flag, the child will be stacked behind it. This flag is useful for
drop shadow effects and for decoration objects that follow the parent
- item's geometry without drawing on top of it.
+ item's geometry without drawing on top of it. This flag was introduced
+ in Qt 4.5.
\value ItemUsesExtendedStyleOption The item makes use of either
- \l{QStyleOptionGraphicsItem::}{exposedRect} or
- \l{QStyleOptionGraphicsItem::}{matrix} in QStyleOptionGraphicsItem. By default,
- the \l{QStyleOptionGraphicsItem::}{exposedRect} is initialized to the item's
- boundingRect() and the \l{QStyleOptionGraphicsItem::}{matrix} is untransformed.
- You can enable this flag for the style options to be set up with more
- fine-grained values.
- Note that QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag
+ \l{QStyleOptionGraphicsItem::} {exposedRect} or
+ \l{QStyleOptionGraphicsItem::} {matrix} in
+ QStyleOptionGraphicsItem. By default, the
+ \l{QStyleOptionGraphicsItem::} {exposedRect} is initialized to the
+ item's boundingRect() and the
+ \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. You can
+ enable this flag for the style options to be set up with more
+ fine-grained values. Note that
+ QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag
and always initialized to 1. Use
- QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need a higher
- value.
+ QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need
+ a higher value. This flag was introduced in Qt 4.6.
\value ItemHasNoContents The item does not paint anything (i.e., calling
paint() on the item has no effect). You should set this flag on items that
@@ -387,9 +390,10 @@
used for Asian languages.
This flag was introduced in Qt 4.6.
- \value ItemNegativeZStacksBehindParent The item automatically stacks behind
- it's parent if it's z-value is negative. This flag enables setZValue() to
- toggle ItemStacksBehindParent.
+ \value ItemNegativeZStacksBehindParent The item automatically
+ stacks behind it's parent if it's z-value is negative. This flag
+ enables setZValue() to toggle ItemStacksBehindParent. This flag
+ was introduced in Qt 4.6.
\value ItemIsPanel The item is a panel. A panel provides activation and
contained focus handling. Only one panel can be active at a time (see
@@ -3174,8 +3178,9 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim
*/
void QGraphicsItem::clearFocus()
{
- // Pass focus to the closest parent focus scope.
- if (!d_ptr->inDestructor) {
+ // Pass focus to the closest parent focus scope when clearing focus
+ // from a focus scope.
+ if (!d_ptr->inDestructor && (d_ptr->flags & ItemIsFocusScope)) {
QGraphicsItem *p = d_ptr->parent;
while (p) {
if (p->flags() & ItemIsFocusScope) {
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 3280e86..aaae88e 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -5134,6 +5134,8 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
}
/*!
+ \obsolete
+
Paints the given \a items using the provided \a painter, after the
background has been drawn, and before the foreground has been
drawn. All painting is done in \e scene coordinates. Before
@@ -5156,7 +5158,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
\snippet doc/src/snippets/graphicssceneadditemsnippet.cpp 0
- \obsolete Since Qt 4.6, this function is not called anymore unless
+ Since Qt 4.6, this function is not called anymore unless
the QGraphicsView::IndirectPainting flag is given as an Optimization
flag.
@@ -5712,8 +5714,15 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
item->d_ptr->acceptedTouchBeginEvent = true;
bool res = sendTouchBeginEvent(item, &touchEvent)
&& touchEvent.isAccepted();
- if (!res)
+ if (!res) {
+ // forget about these touch points, we didn't handle them
+ for (int i = 0; i < touchEvent.touchPoints().count(); ++i) {
+ const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().at(i);
+ itemForTouchPointId.remove(touchPoint.id());
+ sceneCurrentTouchPoints.remove(touchPoint.id());
+ }
ignoreSceneTouchEvent = false;
+ }
break;
}
default:
@@ -5904,13 +5913,21 @@ void QGraphicsScenePrivate::getGestureTargets(const QSet<QGesture *> &gestures,
QList<QGraphicsItem *> items = itemsAtPosition(screenPos, QPointF(), viewport);
QList<QGraphicsObject *> result;
for (int j = 0; j < items.size(); ++j) {
- QGraphicsObject *item = items.at(j)->toGraphicsObject();
- if (!item)
- continue;
- QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
- if (d->gestureContext.contains(gestureType)) {
- result.append(item);
+ QGraphicsItem *item = items.at(j);
+
+ // Check if the item is blocked by a modal panel and use it as
+ // a target instead of this item.
+ (void) item->isBlockedByModalPanel(&item);
+
+ if (QGraphicsObject *itemobj = item->toGraphicsObject()) {
+ QGraphicsItemPrivate *d = item->d_func();
+ if (d->gestureContext.contains(gestureType)) {
+ result.append(itemobj);
+ }
}
+ // Don't propagate through panels.
+ if (item->isPanel())
+ break;
}
DEBUG() << "QGraphicsScenePrivate::getGestureTargets:"
<< gesture << result;
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 96b9373..06b7438 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -3609,6 +3609,8 @@ void QGraphicsView::drawForeground(QPainter *painter, const QRectF &rect)
}
/*!
+ \obsolete
+
Draws the items \a items in the scene using \a painter, after the
background and before the foreground are drawn. \a numItems is the number
of items in \a items and options in \a options. \a options is a list of
@@ -3617,7 +3619,7 @@ void QGraphicsView::drawForeground(QPainter *painter, const QRectF &rect)
The default implementation calls the scene's drawItems() function.
- \obsolete Since Qt 4.6, this function is not called anymore unless
+ Since Qt 4.6, this function is not called anymore unless
the QGraphicsView::IndirectPainting flag is given as an Optimization
flag.
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index 8ad3bac..d46f3b4 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -51,8 +51,27 @@ contains(DEFINES,QT_EVAL):include($$QT_SOURCE_TREE/src/corelib/eval.pri)
QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist
DEFINES += Q_INTERNAL_QAPP_SRC
-symbian:TARGET.UID3=0x2001B2DD
+symbian: {
+ TARGET.UID3=0x2001B2DD
+
+ # ro-section in gui can exceed default allocated space, so move rw-section a little further
+ QMAKE_LFLAGS.ARMCC += --rw-base 0x800000
+ QMAKE_LFLAGS.GCCE += -Tdata 0xC00000
+
+ # Partial upgrade SIS file
+ vendorinfo = \
+ "&EN" \
+ "; Localised Vendor name" \
+ "%{\"Nokia, Qt\"}" \
+ " " \
+ "; Unique Vendor name" \
+ ":\"Nokia, Qt\"" \
+ " "
+ pu_header = "; Partial upgrade package for testing QtGui changes without reinstalling everything" \
+ "$${LITERAL_HASH}{\"Qt gui\"}, (0x2001E61C), $${QT_MAJOR_VERSION},$${QT_MINOR_VERSION},$${QT_PATCH_VERSION}, TYPE=PU"
+ partial_upgrade.pkg_prerules = pu_header vendorinfo
+ partial_upgrade.sources = qtgui.dll
+ partial_upgrade.path = c:/sys/bin
+ DEPLOYMENT = partial_upgrade $$DEPLOYMENT
+}
-# ro-section in gui can exceed default allocated space, so more rw-section little further
-symbian-sbsv2: QMAKE_LFLAGS.ARMCC += --rw-base 0x800000
-symbian: QMAKE_LFLAGS.GCCE += -Tdata 0xC00000
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri
index b67be55..8d75fdd 100644
--- a/src/gui/image/image.pri
+++ b/src/gui/image/image.pri
@@ -96,6 +96,7 @@ SOURCES += \
unix:LIBS_PRIVATE += -lpng
win32:LIBS += libpng.lib
} else {
+ DEFINES *= QT_USE_BUNDLED_LIBPNG
!isEqual(QT_ARCH, i386):!isEqual(QT_ARCH, x86_64):DEFINES += PNG_NO_ASSEMBLER_CODE
INCLUDEPATH += ../3rdparty/libpng ../3rdparty/zlib
SOURCES += ../3rdparty/libpng/png.c \
@@ -112,8 +113,7 @@ SOURCES += \
../3rdparty/libpng/pngwio.c \
../3rdparty/libpng/pngwrite.c \
../3rdparty/libpng/pngwtran.c \
- ../3rdparty/libpng/pngwutil.c \
- ../3rdparty/libpng/pnggccrd.c
+ ../3rdparty/libpng/pngwutil.c
}
} else {
DEFINES *= QT_NO_IMAGEFORMAT_PNG
diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp
index ace4bb6..517fcb0 100644
--- a/src/gui/image/qimagepixmapcleanuphooks.cpp
+++ b/src/gui/image/qimagepixmapcleanuphooks.cpp
@@ -122,19 +122,32 @@ void QImagePixmapCleanupHooks::executeImageHooks(qint64 key)
qt_image_cleanup_hook_64(key);
}
-void QImagePixmapCleanupHooks::enableCleanupHooks(const QPixmap &pixmap)
-{
- enableCleanupHooks(const_cast<QPixmap &>(pixmap).data_ptr().data());
-}
void QImagePixmapCleanupHooks::enableCleanupHooks(QPixmapData *pixmapData)
{
pixmapData->is_cached = true;
}
+void QImagePixmapCleanupHooks::enableCleanupHooks(const QPixmap &pixmap)
+{
+ enableCleanupHooks(const_cast<QPixmap &>(pixmap).data_ptr().data());
+}
+
void QImagePixmapCleanupHooks::enableCleanupHooks(const QImage &image)
{
const_cast<QImage &>(image).data_ptr()->is_cached = true;
}
+bool QImagePixmapCleanupHooks::isImageCached(const QImage &image)
+{
+ return const_cast<QImage &>(image).data_ptr()->is_cached;
+}
+
+bool QImagePixmapCleanupHooks::isPixmapCached(const QPixmap &pixmap)
+{
+ return const_cast<QPixmap&>(pixmap).data_ptr().data()->is_cached;
+}
+
+
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h
index 88dd3a6..eae11f4 100644
--- a/src/gui/image/qimagepixmapcleanuphooks_p.h
+++ b/src/gui/image/qimagepixmapcleanuphooks_p.h
@@ -72,6 +72,9 @@ public:
static void enableCleanupHooks(const QPixmap &pixmap);
static void enableCleanupHooks(QPixmapData *pixmapData);
+ static bool isImageCached(const QImage &image);
+ static bool isPixmapCached(const QPixmap &pixmap);
+
// Gets called when a pixmap data is about to be modified:
void addPixmapDataModificationHook(_qt_pixmap_cleanup_hook_pmd);
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 7cafbd0..ae62f06 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -1690,10 +1690,9 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
\o
The hasAlphaChannel() returns true if the pixmap has a format that
- respects the alpha channel, otherwise returns false, while the
- hasAlpha() function returns true if the pixmap has an alpha
- channel \e or a mask (otherwise false). The mask() function returns
- the mask as a QBitmap object, which can be set using setMask().
+ respects the alpha channel, otherwise returns false. The hasAlpha(),
+ setMask() and mask() functions are legacy and should not be used.
+ They are potentially very slow.
The createHeuristicMask() function creates and returns a 1-bpp
heuristic mask (i.e. a QBitmap) for this pixmap. It works by
@@ -1780,6 +1779,8 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
Returns true if this pixmap has an alpha channel, \e or has a
mask, otherwise returns false.
+ \warning This is potentially an expensive operation.
+
\sa hasAlphaChannel(), mask()
*/
bool QPixmap::hasAlpha() const
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index 2b91711..1ac8ace 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -113,7 +113,7 @@ void QCoeFepInputContext::update()
updateHints(false);
// For pre-5.0 SDKs, we don't do text updates on S60 side.
- if (QSysInfo::s60Version() != QSysInfo::SV_S60_5_0) {
+ if (QSysInfo::s60Version() < QSysInfo::SV_S60_5_0) {
return;
}
@@ -740,6 +740,9 @@ void QCoeFepInputContext::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLin
void QCoeFepInputContext::DoCommitFepInlineEditL()
{
commitCurrentString(false);
+ if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0)
+ ReportAknEdStateEvent(QT_EAknCursorPositionChanged);
+
}
void QCoeFepInputContext::commitCurrentString(bool cancelFepTransaction)
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index cbd9a8a..adf3ce3 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -1540,6 +1540,11 @@ bool QAbstractItemView::event(QEvent *event)
case QEvent::FontChange:
d->doDelayedItemsLayout(); // the size of the items will change
break;
+#ifdef QT_SOFTKEYS_ENABLED
+ case QEvent::LanguageChange:
+ d->doneSoftKey->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::DoneSoftKey));
+ break;
+#endif
default:
break;
}
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index d0fa22d..706d2a8 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -2474,10 +2474,11 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end)
QVector<QTreeViewItem> insertedItems(delta);
for (int i = 0; i < delta; ++i) {
- insertedItems[i].index = d->model->index(i + start, 0, parent);
- insertedItems[i].level = childLevel;
- insertedItems[i].hasChildren = d->hasVisibleChildren(insertedItems[i].index);
- insertedItems[i].hasMoreSiblings = !((i == delta - 1) && (parentRowCount == end +1));
+ QTreeViewItem &item = insertedItems[i];
+ item.index = d->model->index(i + start, 0, parent);
+ item.level = childLevel;
+ item.hasChildren = d->hasVisibleChildren(item.index);
+ item.hasMoreSiblings = !((i == delta - 1) && (parentRowCount == end +1));
}
if (d->viewItems.isEmpty())
d->defaultItemHeight = indexRowSizeHint(insertedItems[0].index);
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 336be91..4ec2ae2 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -122,15 +122,19 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
static void initResources()
{
#if defined(Q_WS_WINCE)
+ Q_INIT_RESOURCE_EXTERN(qstyle_wince)
Q_INIT_RESOURCE(qstyle_wince);
#elif defined(Q_OS_SYMBIAN)
+ Q_INIT_RESOURCE_EXTERN(qstyle_s60)
Q_INIT_RESOURCE(qstyle_s60);
#else
+ Q_INIT_RESOURCE_EXTERN(qstyle)
Q_INIT_RESOURCE(qstyle);
#endif
-
+ Q_INIT_RESOURCE_EXTERN(qmessagebox)
Q_INIT_RESOURCE(qmessagebox);
#if !defined(QT_NO_PRINTDIALOG)
+ Q_INIT_RESOURCE_EXTERN(qprintdialog)
Q_INIT_RESOURCE(qprintdialog);
#endif
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 34865b5..c6e192b 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -208,11 +208,8 @@ static const char * x11_atomnames = {
"_MOTIF_WM_HINTS\0"
"DTWM_IS_RUNNING\0"
- "KDE_FULL_SESSION\0"
- "KWIN_RUNNING\0"
- "KWM_RUNNING\0"
- "GNOME_BACKGROUND_PROPERTIES\0"
"ENLIGHTENMENT_DESKTOP\0"
+ "_DT_SAVE_MODE\0"
"_SGI_DESKS_MANAGER\0"
// EWMH (aka NETWM)
@@ -626,8 +623,6 @@ static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
|| err->resourceid == XA_RGB_DEFAULT_MAP
|| err->resourceid == ATOM(_NET_SUPPORTED)
|| err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK)
- || err->resourceid == ATOM(KDE_FULL_SESSION)
- || err->resourceid == ATOM(KWIN_RUNNING)
|| err->resourceid == ATOM(XdndProxy)
|| err->resourceid == ATOM(XdndAware))) {
// Perhaps we're running under SECURITY reduction? :/
@@ -2222,87 +2217,36 @@ void qt_init(QApplicationPrivate *priv, int,
X11->desktopEnvironment = DE_UNKNOWN;
X11->desktopVersion = 0;
- // See if the current window manager is using the freedesktop.org spec to give its name
- Window windowManagerWindow = XNone;
- Atom typeReturned;
- int formatReturned;
- unsigned long nitemsReturned;
- unsigned long unused;
- unsigned char *data = 0;
- if (XGetWindowProperty(QX11Info::display(), QX11Info::appRootWindow(),
- ATOM(_NET_SUPPORTING_WM_CHECK),
- 0, 1024, False, XA_WINDOW, &typeReturned,
- &formatReturned, &nitemsReturned, &unused, &data)
- == Success) {
- if (typeReturned == XA_WINDOW && formatReturned == 32)
- windowManagerWindow = *((Window*) data);
- if (data)
- XFree(data);
-
- if (windowManagerWindow != XNone) {
- QString wmName;
- Atom utf8atom = ATOM(UTF8_STRING);
- if (XGetWindowProperty(QX11Info::display(), windowManagerWindow, ATOM(_NET_WM_NAME),
- 0, 1024, False, utf8atom, &typeReturned,
- &formatReturned, &nitemsReturned, &unused, &data)
- == Success) {
- if (typeReturned == utf8atom && formatReturned == 8)
- wmName = QString::fromUtf8((const char*)data);
- if (data)
- XFree(data);
- if (wmName == QLatin1String("KWin"))
- X11->desktopEnvironment = DE_KDE;
- if (wmName == QLatin1String("Metacity"))
- X11->desktopEnvironment = DE_GNOME;
- }
- }
- }
-
- // Running a different/newer/older window manager? Try some other things
- if (X11->desktopEnvironment == DE_UNKNOWN){
- Atom type;
- int format;
- unsigned long length, after;
- uchar *data = 0;
-
- QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION"));
- if (session == QLatin1String("kde")) {
- X11->desktopEnvironment = DE_KDE;
- } else if (session == QLatin1String("gnome") || session == QLatin1String("xfce")) {
- X11->desktopEnvironment = DE_GNOME;
- } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING),
- 0, 1, False, AnyPropertyType, &type, &format, &length,
- &after, &data) == Success && length) {
- // DTWM is running, meaning most likely CDE is running...
- X11->desktopEnvironment = DE_CDE;
- } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
- ATOM(GNOME_BACKGROUND_PROPERTIES), 0, 1, False, AnyPropertyType,
- &type, &format, &length, &after, &data) == Success && length) {
- X11->desktopEnvironment = DE_GNOME;
- } else if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty()) {
- X11->desktopEnvironment = DE_GNOME;
- } else if ((XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KDE_FULL_SESSION),
- 0, 1, False, AnyPropertyType, &type, &format, &length, &after, &data) == Success
- && length)
- || (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KWIN_RUNNING),
- 0, 1, False, AnyPropertyType, &type, &format, &length,
- &after, &data) == Success
- && length)
- || (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KWM_RUNNING),
- 0, 1, False, AnyPropertyType, &type, &format, &length,
- &after, &data) == Success && length)) {
- X11->desktopEnvironment = DE_KDE;
- } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_SGI_DESKS_MANAGER),
- 0, 1, False, XA_WINDOW, &type, &format, &length, &after, &data) == Success
- && length) {
- X11->desktopEnvironment = DE_4DWM;
- }
- if (data)
- XFree((char *)data);
+ Atom type;
+ int format;
+ unsigned long length, after;
+ uchar *data = 0;
+
+ if (!qgetenv("KDE_FULL_SESSION").isEmpty()) {
+ X11->desktopEnvironment = DE_KDE;
+ X11->desktopVersion = qgetenv("KDE_SESSION_VERSION").toInt();
+ } else if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty() // Deprecated for some reason.
+ || qgetenv("DESKTOP_SESSION") == "gnome") { // De-facto-standardized by GNOME.
+ X11->desktopEnvironment = DE_GNOME;
+ } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_DT_SAVE_MODE),
+ 0, 2, False, XA_STRING, &type, &format, &length,
+ &after, &data) == Success
+ && !strcmp(reinterpret_cast<char *>(data), "xfce4")) {
+ // Pretend that xfce4 is gnome, as it uses the same libraries.
+ // The detection above is stolen from xdg-open.
+ X11->desktopEnvironment = DE_GNOME;
+ } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING),
+ 0, 1, False, AnyPropertyType, &type, &format, &length,
+ &after, &data) == Success && length) {
+ // DTWM is running, meaning most likely CDE is running...
+ X11->desktopEnvironment = DE_CDE;
+ } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_SGI_DESKS_MANAGER),
+ 0, 1, False, XA_WINDOW, &type, &format, &length, &after, &data) == Success
+ && length) {
+ X11->desktopEnvironment = DE_4DWM;
}
-
- if (X11->desktopEnvironment == DE_KDE)
- X11->desktopVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
+ if (data)
+ XFree((char *)data);
#if !defined(QT_NO_STYLE_GTK)
if (X11->desktopEnvironment == DE_GNOME) {
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm
index 8a67dee..99b77d0 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/gui/kernel/qeventdispatcher_mac.mm
@@ -497,6 +497,14 @@ static bool IsMouseOrKeyEvent( NSEvent* event )
case NSOtherMouseDown:
case NSOtherMouseUp:
case NSOtherMouseDragged:
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ case NSEventTypeGesture: // touch events
+ case NSEventTypeMagnify:
+ case NSEventTypeSwipe:
+ case NSEventTypeRotate:
+ case NSEventTypeBeginGesture:
+ case NSEventTypeEndGesture:
+#endif
result = true;
break;
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index 6d108b0..c9a94ee 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/gui/kernel/qsoftkeymanager.cpp
@@ -55,24 +55,24 @@ QT_BEGIN_NAMESPACE
QSoftKeyManager *QSoftKeyManagerPrivate::self = 0;
-const char *QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
+QString QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
{
- const char *softKeyText = 0;
+ QString softKeyText;
switch (standardKey) {
case OkSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Ok");
+ softKeyText = QSoftKeyManager::tr("Ok");
break;
case SelectSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Select");
+ softKeyText = QSoftKeyManager::tr("Select");
break;
case DoneSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Done");
+ softKeyText = QSoftKeyManager::tr("Done");
break;
case MenuSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Options");
+ softKeyText = QSoftKeyManager::tr("Options");
break;
case CancelSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Cancel");
+ softKeyText = QSoftKeyManager::tr("Cancel");
break;
default:
break;
@@ -100,8 +100,7 @@ QSoftKeyManager::QSoftKeyManager() :
QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *actionWidget)
{
- const char* text = standardSoftKeyText(standardKey);
- QAction *action = new QAction(QSoftKeyManager::tr(text), actionWidget);
+ QAction *action = new QAction(standardSoftKeyText(standardKey), actionWidget);
QAction::SoftKeyRole softKeyRole = QAction::NoSoftKey;
switch (standardKey) {
case MenuSoftKey: // FALL-THROUGH
@@ -211,13 +210,11 @@ bool QSoftKeyManager::handleUpdateSoftKeys()
d->requestedSoftKeyActions.clear();
bool recursiveMerging = false;
QWidget *source = softkeySource(NULL, recursiveMerging);
- do {
- if (source) {
- bool added = appendSoftkeys(*source, level);
- source = softkeySource(source, recursiveMerging);
- level = added ? ++level : level;
- }
- } while (source);
+ while (source) {
+ if (appendSoftkeys(*source, level))
+ ++level;
+ source = softkeySource(source, recursiveMerging);
+ }
d->updateSoftKeys_sys();
return true;
diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h
index ce902fe..a6fe17e 100644
--- a/src/gui/kernel/qsoftkeymanager_p.h
+++ b/src/gui/kernel/qsoftkeymanager_p.h
@@ -87,6 +87,7 @@ public:
static QAction *createAction(StandardSoftKey standardKey, QWidget *actionWidget);
static QAction *createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget);
+ static QString standardSoftKeyText(StandardSoftKey standardKey);
protected:
bool event(QEvent *e);
@@ -94,7 +95,6 @@ protected:
private:
QSoftKeyManager();
static QSoftKeyManager *instance();
- static const char *standardSoftKeyText(StandardSoftKey standardKey);
bool appendSoftkeys(const QWidget &source, int level);
QWidget *softkeySource(QWidget *previousSource, bool& recursiveMerging);
bool handleUpdateSoftKeys();
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index b2ce754..167557b 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -564,11 +564,8 @@ struct QX11Data
_MOTIF_WM_HINTS,
DTWM_IS_RUNNING,
- KDE_FULL_SESSION,
- KWIN_RUNNING,
- KWM_RUNNING,
- GNOME_BACKGROUND_PROPERTIES,
ENLIGHTENMENT_DESKTOP,
+ _DT_SAVE_MODE,
_SGI_DESKS_MANAGER,
// EWMH (aka NETWM)
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp
index bbffda1..ea7fe4f 100644
--- a/src/gui/painting/qbezier.cpp
+++ b/src/gui/painting/qbezier.cpp
@@ -112,6 +112,11 @@ QPolygonF QBezier::toPolygon() const
return polygon;
}
+QBezier QBezier::mapBy(const QTransform &transform) const
+{
+ return QBezier::fromPoints(transform.map(pt1()), transform.map(pt2()), transform.map(pt3()), transform.map(pt4()));
+}
+
//0.5 is really low
static const qreal flatness = 0.5;
@@ -140,6 +145,25 @@ static inline void flattenBezierWithoutInflections(QBezier &bez,
}
}
+QBezier QBezier::getSubRange(qreal t0, qreal t1) const
+{
+ QBezier result;
+ QBezier temp;
+
+ // cut at t1
+ if (qFuzzyIsNull(t1 - qreal(1.))) {
+ result = *this;
+ } else {
+ temp = *this;
+ temp.parameterSplitLeft(t1, &result);
+ }
+
+ // cut at t0
+ if (!qFuzzyIsNull(t0))
+ result.parameterSplitLeft(t0 / t1, &temp);
+
+ return result;
+}
static inline int quadraticRoots(qreal a, qreal b, qreal c,
qreal *x1, qreal *x2)
@@ -1018,13 +1042,19 @@ int QBezier::stationaryYPoints(qreal &t0, qreal &t1) const
const qreal b = 2 * y1 - 4 * y2 + 2 * y3;
const qreal c = -y1 + y2;
- qreal reciprocal = b * b - 4 * a * c;
+ if (qFuzzyIsNull(a)) {
+ if (qFuzzyIsNull(b))
+ return 0;
- QList<qreal> result;
+ t0 = -c / b;
+ return t0 > 0 && t0 < 1;
+ }
+
+ qreal reciprocal = b * b - 4 * a * c;
if (qFuzzyIsNull(reciprocal)) {
t0 = -b / (2 * a);
- return 1;
+ return t0 > 0 && t0 < 1;
} else if (reciprocal > 0) {
qreal temp = qSqrt(reciprocal);
diff --git a/src/gui/painting/qbezier_p.h b/src/gui/painting/qbezier_p.h
index 3409bc7..f015ea8 100644
--- a/src/gui/painting/qbezier_p.h
+++ b/src/gui/painting/qbezier_p.h
@@ -59,6 +59,7 @@
#include "QtCore/qvector.h"
#include "QtCore/qlist.h"
#include "QtCore/qpair.h"
+#include "QtGui/qtransform.h"
QT_BEGIN_NAMESPACE
@@ -96,6 +97,8 @@ public:
QPointF pt3() const { return QPointF(x3, y3); }
QPointF pt4() const { return QPointF(x4, y4); }
+ QBezier mapBy(const QTransform &transform) const;
+
inline QPointF midPoint() const;
inline QLineF midTangent() const;
@@ -104,6 +107,7 @@ public:
inline void parameterSplitLeft(qreal t, QBezier *left);
inline void split(QBezier *firstHalf, QBezier *secondHalf) const;
+
int shifted(QBezier *curveSegments, int maxSegmets,
qreal offset, float threshold) const;
@@ -117,6 +121,8 @@ public:
static bool findIntersections(const QBezier &a, const QBezier &b,
QVector<QPair<qreal, qreal> > *t);
+ QBezier getSubRange(qreal t0, qreal t1) const;
+
qreal x1, y1, x2, y2, x3, y3, x4, y4;
};
diff --git a/src/gui/painting/qcups.cpp b/src/gui/painting/qcups.cpp
index 7903762..ac41692 100644
--- a/src/gui/painting/qcups.cpp
+++ b/src/gui/painting/qcups.cpp
@@ -342,7 +342,9 @@ bool QCUPSSupport::printerHasPPD(const char *printerName)
{
if (!isAvailable())
return false;
- return _cupsGetPPD(printerName) != 0;
+ const char *ppdFile = _cupsGetPPD(printerName);
+ unlink(ppdFile);
+ return (ppdFile != 0);
}
QString QCUPSSupport::unicodeString(const char *s)
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 7a3da20..070491d 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -8092,20 +8092,43 @@ void qInitDrawhelperAsm()
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_sse3dnow;
}
#endif // 3DNOW
- extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl,
- const uchar *srcPixels, int sbpl,
- int w, int h,
- int const_alpha);
- extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl,
- const uchar *srcPixels, int sbpl,
- int w, int h,
- int const_alpha);
- qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse;
- qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse;
- qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse;
- qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse;
- }
+
+#ifdef QT_HAVE_SSE2
+ if (features & SSE2) {
+ extern void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha);
+ extern void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha);
+
+
+ qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2;
+ qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2;
+ qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2;
+ qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2;
+ } else
+#endif
+ {
+ extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha);
+ extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha);
+
+
+ qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse;
+ qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse;
+ qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse;
+ qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse;
+ }
+}
#endif // SSE
#ifdef QT_HAVE_IWMMXT
diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp
index 25860a0..77c5202 100644
--- a/src/gui/painting/qdrawhelper_neon.cpp
+++ b/src/gui/painting/qdrawhelper_neon.cpp
@@ -48,43 +48,43 @@
QT_BEGIN_NAMESPACE
-static inline int16x8_t qvdiv_255_s16(int16x8_t x, int16x8_t half)
+static inline uint16x8_t qvdiv_255_u16(uint16x8_t x, uint16x8_t half)
{
// result = (x + (x >> 8) + 0x80) >> 8
- const int16x8_t temp = vshrq_n_s16(x, 8); // x >> 8
- const int16x8_t sum_part = vaddq_s16(x, half); // x + 0x80
- const int16x8_t sum = vaddq_s16(temp, sum_part);
+ const uint16x8_t temp = vshrq_n_u16(x, 8); // x >> 8
+ const uint16x8_t sum_part = vaddq_u16(x, half); // x + 0x80
+ const uint16x8_t sum = vaddq_u16(temp, sum_part);
- return vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(sum), 8));
+ return vshrq_n_u16(sum, 8);
}
-static inline int16x8_t qvbyte_mul_s16(int16x8_t x, int16x8_t alpha, int16x8_t half)
+static inline uint16x8_t qvbyte_mul_u16(uint16x8_t x, uint16x8_t alpha, uint16x8_t half)
{
// t = qRound(x * alpha / 255.0)
- const int16x8_t t = vmulq_s16(x, alpha); // t
- return qvdiv_255_s16(t, half);
+ const uint16x8_t t = vmulq_u16(x, alpha); // t
+ return qvdiv_255_u16(t, half);
}
-static inline int16x8_t qvinterpolate_pixel_255(int16x8_t x, int16x8_t a, int16x8_t y, int16x8_t b, int16x8_t half)
+static inline uint16x8_t qvinterpolate_pixel_255(uint16x8_t x, uint16x8_t a, uint16x8_t y, uint16x8_t b, uint16x8_t half)
{
// t = x * a + y * b
- const int16x8_t ta = vmulq_s16(x, a);
- const int16x8_t tb = vmulq_s16(y, b);
+ const uint16x8_t ta = vmulq_u16(x, a);
+ const uint16x8_t tb = vmulq_u16(y, b);
- return qvdiv_255_s16(vaddq_s16(ta, tb), half);
+ return qvdiv_255_u16(vaddq_u16(ta, tb), half);
}
-static inline int16x8_t qvsource_over_s16(int16x8_t src16, int16x8_t dst16, int16x8_t half, int16x8_t full)
+static inline uint16x8_t qvsource_over_u16(uint16x8_t src16, uint16x8_t dst16, uint16x8_t half, uint16x8_t full)
{
- const int16x4_t alpha16_high = vdup_lane_s16(vget_high_s16(src16), 3);
- const int16x4_t alpha16_low = vdup_lane_s16(vget_low_s16(src16), 3);
+ const uint16x4_t alpha16_high = vdup_lane_u16(vget_high_u16(src16), 3);
+ const uint16x4_t alpha16_low = vdup_lane_u16(vget_low_u16(src16), 3);
- const int16x8_t alpha16 = vsubq_s16(full, vcombine_s16(alpha16_low, alpha16_high));
+ const uint16x8_t alpha16 = vsubq_u16(full, vcombine_u16(alpha16_low, alpha16_high));
- return vaddq_s16(src16, qvbyte_mul_s16(dst16, alpha16, half));
+ return vaddq_u16(src16, qvbyte_mul_u16(dst16, alpha16, half));
}
void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
@@ -94,21 +94,21 @@ void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
{
const uint *src = (const uint *) srcPixels;
uint *dst = (uint *) destPixels;
- int16x8_t half = vdupq_n_s16(0x80);
- int16x8_t full = vdupq_n_s16(0xff);
+ uint16x8_t half = vdupq_n_u16(0x80);
+ uint16x8_t full = vdupq_n_u16(0xff);
if (const_alpha == 256) {
for (int y = 0; y < h; ++y) {
int x = 0;
for (; x < w-3; x += 4) {
- int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
+ uint32x4_t src32 = vld1q_u32((uint32_t *)&src[x]);
if ((src[x] & src[x+1] & src[x+2] & src[x+3]) >= 0xff000000) {
// all opaque
- vst1q_s32((int32_t *)&dst[x], src32);
+ vst1q_u32((uint32_t *)&dst[x], src32);
} else if (src[x] | src[x+1] | src[x+2] | src[x+3]) {
- int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
+ uint32x4_t dst32 = vld1q_u32((uint32_t *)&dst[x]);
- const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
- const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
+ const uint8x16_t src8 = vreinterpretq_u8_u32(src32);
+ const uint8x16_t dst8 = vreinterpretq_u8_u32(dst32);
const uint8x8_t src8_low = vget_low_u8(src8);
const uint8x8_t dst8_low = vget_low_u8(dst8);
@@ -116,19 +116,19 @@ void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
const uint8x8_t src8_high = vget_high_u8(src8);
const uint8x8_t dst8_high = vget_high_u8(dst8);
- const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
- const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
+ const uint16x8_t src16_low = vmovl_u8(src8_low);
+ const uint16x8_t dst16_low = vmovl_u8(dst8_low);
- const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
- const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
+ const uint16x8_t src16_high = vmovl_u8(src8_high);
+ const uint16x8_t dst16_high = vmovl_u8(dst8_high);
- const int16x8_t result16_low = qvsource_over_s16(src16_low, dst16_low, half, full);
- const int16x8_t result16_high = qvsource_over_s16(src16_high, dst16_high, half, full);
+ const uint16x8_t result16_low = qvsource_over_u16(src16_low, dst16_low, half, full);
+ const uint16x8_t result16_high = qvsource_over_u16(src16_high, dst16_high, half, full);
- const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
- const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
+ const uint32x2_t result32_low = vreinterpret_u32_u8(vmovn_u16(result16_low));
+ const uint32x2_t result32_high = vreinterpret_u32_u8(vmovn_u16(result16_high));
- vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
+ vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high));
}
}
for (; x<w; ++x) {
@@ -143,16 +143,16 @@ void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
}
} else if (const_alpha != 0) {
const_alpha = (const_alpha * 255) >> 8;
- int16x8_t const_alpha16 = vdupq_n_s16(const_alpha);
+ uint16x8_t const_alpha16 = vdupq_n_u16(const_alpha);
for (int y = 0; y < h; ++y) {
int x = 0;
for (; x < w-3; x += 4) {
if (src[x] | src[x+1] | src[x+2] | src[x+3]) {
- int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
- int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
+ uint32x4_t src32 = vld1q_u32((uint32_t *)&src[x]);
+ uint32x4_t dst32 = vld1q_u32((uint32_t *)&dst[x]);
- const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
- const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
+ const uint8x16_t src8 = vreinterpretq_u8_u32(src32);
+ const uint8x16_t dst8 = vreinterpretq_u8_u32(dst32);
const uint8x8_t src8_low = vget_low_u8(src8);
const uint8x8_t dst8_low = vget_low_u8(dst8);
@@ -160,22 +160,22 @@ void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
const uint8x8_t src8_high = vget_high_u8(src8);
const uint8x8_t dst8_high = vget_high_u8(dst8);
- const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
- const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
+ const uint16x8_t src16_low = vmovl_u8(src8_low);
+ const uint16x8_t dst16_low = vmovl_u8(dst8_low);
- const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
- const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
+ const uint16x8_t src16_high = vmovl_u8(src8_high);
+ const uint16x8_t dst16_high = vmovl_u8(dst8_high);
- const int16x8_t srcalpha16_low = qvbyte_mul_s16(src16_low, const_alpha16, half);
- const int16x8_t srcalpha16_high = qvbyte_mul_s16(src16_high, const_alpha16, half);
+ const uint16x8_t srcalpha16_low = qvbyte_mul_u16(src16_low, const_alpha16, half);
+ const uint16x8_t srcalpha16_high = qvbyte_mul_u16(src16_high, const_alpha16, half);
- const int16x8_t result16_low = qvsource_over_s16(srcalpha16_low, dst16_low, half, full);
- const int16x8_t result16_high = qvsource_over_s16(srcalpha16_high, dst16_high, half, full);
+ const uint16x8_t result16_low = qvsource_over_u16(srcalpha16_low, dst16_low, half, full);
+ const uint16x8_t result16_high = qvsource_over_u16(srcalpha16_high, dst16_high, half, full);
- const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
- const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
+ const uint32x2_t result32_low = vreinterpret_u32_u8(vmovn_u16(result16_low));
+ const uint32x2_t result32_high = vreinterpret_u32_u8(vmovn_u16(result16_high));
- vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
+ vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high));
}
}
for (; x<w; ++x) {
@@ -206,19 +206,19 @@ void qt_blend_rgb32_on_rgb32_neon(uchar *destPixels, int dbpl,
if (const_alpha != 0) {
const uint *src = (const uint *) srcPixels;
uint *dst = (uint *) destPixels;
- int16x8_t half = vdupq_n_s16(0x80);
+ uint16x8_t half = vdupq_n_u16(0x80);
const_alpha = (const_alpha * 255) >> 8;
int one_minus_const_alpha = 255 - const_alpha;
- int16x8_t const_alpha16 = vdupq_n_s16(const_alpha);
- int16x8_t one_minus_const_alpha16 = vdupq_n_s16(255 - const_alpha);
+ uint16x8_t const_alpha16 = vdupq_n_u16(const_alpha);
+ uint16x8_t one_minus_const_alpha16 = vdupq_n_u16(255 - const_alpha);
for (int y = 0; y < h; ++y) {
int x = 0;
for (; x < w-3; x += 4) {
- int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
- int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
+ uint32x4_t src32 = vld1q_u32((uint32_t *)&src[x]);
+ uint32x4_t dst32 = vld1q_u32((uint32_t *)&dst[x]);
- const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
- const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
+ const uint8x16_t src8 = vreinterpretq_u8_u32(src32);
+ const uint8x16_t dst8 = vreinterpretq_u8_u32(dst32);
const uint8x8_t src8_low = vget_low_u8(src8);
const uint8x8_t dst8_low = vget_low_u8(dst8);
@@ -226,19 +226,19 @@ void qt_blend_rgb32_on_rgb32_neon(uchar *destPixels, int dbpl,
const uint8x8_t src8_high = vget_high_u8(src8);
const uint8x8_t dst8_high = vget_high_u8(dst8);
- const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
- const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
+ const uint16x8_t src16_low = vmovl_u8(src8_low);
+ const uint16x8_t dst16_low = vmovl_u8(dst8_low);
- const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
- const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
+ const uint16x8_t src16_high = vmovl_u8(src8_high);
+ const uint16x8_t dst16_high = vmovl_u8(dst8_high);
- const int16x8_t result16_low = qvinterpolate_pixel_255(src16_low, const_alpha16, dst16_low, one_minus_const_alpha16, half);
- const int16x8_t result16_high = qvinterpolate_pixel_255(src16_high, const_alpha16, dst16_high, one_minus_const_alpha16, half);
+ const uint16x8_t result16_low = qvinterpolate_pixel_255(src16_low, const_alpha16, dst16_low, one_minus_const_alpha16, half);
+ const uint16x8_t result16_high = qvinterpolate_pixel_255(src16_high, const_alpha16, dst16_high, one_minus_const_alpha16, half);
- const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
- const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
+ const uint32x2_t result32_low = vreinterpret_u32_u8(vmovn_u16(result16_low));
+ const uint32x2_t result32_high = vreinterpret_u32_u8(vmovn_u16(result16_high));
- vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
+ vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high));
}
for (; x<w; ++x) {
uint s = src[x];
diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp
index dd6fa1b..6ac64d3 100644
--- a/src/gui/painting/qdrawhelper_sse2.cpp
+++ b/src/gui/painting/qdrawhelper_sse2.cpp
@@ -57,6 +57,217 @@
QT_BEGIN_NAMESPACE
+/*
+ * Multiply the components of pixelVector by alphaChannel
+ * Each 32bits components of alphaChannel must be in the form 0x00AA00AA
+ * colorMask must have 0x00ff00ff on each 32 bits component
+ * half must have the value 128 (0x80) for each 32 bits compnent
+ */
+#define BYTE_MUL_SSE2(result, pixelVector, alphaChannel, colorMask, half) \
+{ \
+ /* 1. separate the colors in 2 vectors so each color is on 16 bits \
+ (in order to be multiplied by the alpha \
+ each 32 bit of dstVectorAG are in the form 0x00AA00GG \
+ each 32 bit of dstVectorRB are in the form 0x00RR00BB */\
+ __m128i pixelVectorAG = _mm_srli_epi16(pixelVector, 8); \
+ __m128i pixelVectorRB = _mm_and_si128(pixelVector, colorMask); \
+ \
+ /* 2. multiply the vectors by the alpha channel */\
+ pixelVectorAG = _mm_mullo_epi16(pixelVectorAG, alphaChannel); \
+ pixelVectorRB = _mm_mullo_epi16(pixelVectorRB, alphaChannel); \
+ \
+ /* 3. devide by 255, that's the tricky part. \
+ we do it like for BYTE_MUL(), with bit shift: X/255 ~= (X + X/256 + rounding)/256 */ \
+ /** so first (X + X/256 + rounding) */\
+ pixelVectorRB = _mm_add_epi16(pixelVectorRB, _mm_srli_epi16(pixelVectorRB, 8)); \
+ pixelVectorRB = _mm_add_epi16(pixelVectorRB, half); \
+ pixelVectorAG = _mm_add_epi16(pixelVectorAG, _mm_srli_epi16(pixelVectorAG, 8)); \
+ pixelVectorAG = _mm_add_epi16(pixelVectorAG, half); \
+ \
+ /** second devide by 256 */\
+ pixelVectorRB = _mm_srli_epi16(pixelVectorRB, 8); \
+ /** for AG, we could >> 8 to divide followed by << 8 to put the \
+ bytes in the correct position. By masking instead, we execute \
+ only one instruction */\
+ pixelVectorAG = _mm_andnot_si128(colorMask, pixelVectorAG); \
+ \
+ /* 4. combine the 2 pairs of colors */ \
+ result = _mm_or_si128(pixelVectorAG, pixelVectorRB); \
+}
+
+/*
+ * Each 32bits components of alphaChannel must be in the form 0x00AA00AA
+ * oneMinusAlphaChannel must be 255 - alpha for each 32 bits component
+ * colorMask must have 0x00ff00ff on each 32 bits component
+ * half must have the value 128 (0x80) for each 32 bits compnent
+ */
+#define INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, alphaChannel, oneMinusAlphaChannel, colorMask, half) { \
+ /* interpolate AG */\
+ __m128i srcVectorAG = _mm_srli_epi16(srcVector, 8); \
+ __m128i dstVectorAG = _mm_srli_epi16(dstVector, 8); \
+ __m128i srcVectorAGalpha = _mm_mullo_epi16(srcVectorAG, alphaChannel); \
+ __m128i dstVectorAGoneMinusAlphalpha = _mm_mullo_epi16(dstVectorAG, oneMinusAlphaChannel); \
+ __m128i finalAG = _mm_add_epi16(srcVectorAGalpha, dstVectorAGoneMinusAlphalpha); \
+ finalAG = _mm_add_epi16(finalAG, _mm_srli_epi16(finalAG, 8)); \
+ finalAG = _mm_add_epi16(finalAG, half); \
+ finalAG = _mm_andnot_si128(colorMask, finalAG); \
+ \
+ /* interpolate RB */\
+ __m128i srcVectorRB = _mm_and_si128(srcVector, colorMask); \
+ __m128i dstVectorRB = _mm_and_si128(dstVector, colorMask); \
+ __m128i srcVectorRBalpha = _mm_mullo_epi16(srcVectorRB, alphaChannel); \
+ __m128i dstVectorRBoneMinusAlphalpha = _mm_mullo_epi16(dstVectorRB, oneMinusAlphaChannel); \
+ __m128i finalRB = _mm_add_epi16(srcVectorRBalpha, dstVectorRBoneMinusAlphalpha); \
+ finalRB = _mm_add_epi16(finalRB, _mm_srli_epi16(finalRB, 8)); \
+ finalRB = _mm_add_epi16(finalRB, half); \
+ finalRB = _mm_srli_epi16(finalRB, 8); \
+ \
+ /* combine */\
+ result = _mm_or_si128(finalAG, finalRB); \
+}
+
+void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha)
+{
+ const quint32 *src = (const quint32 *) srcPixels;
+ quint32 *dst = (uint *) destPixels;
+ if (const_alpha == 256) {
+ const __m128i alphaMask = _mm_set1_epi32(0xff000000);
+ const __m128i nullVector = _mm_set1_epi32(0);
+ const __m128i half = _mm_set1_epi16(0x80);
+ const __m128i one = _mm_set1_epi16(0xff);
+ const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
+ for (int y = 0; y < h; ++y) {
+ int x = 0;
+ for (; x < w-3; x += 4) {
+ const __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]);
+ const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask);
+ if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) {
+ // all opaque
+ _mm_storeu_si128((__m128i *)&dst[x], srcVector);
+ } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) != 0xffff) {
+ // not fully transparent
+ // result = s + d * (1-alpha)
+
+ // extract the alpha channel on 2 x 16 bits
+ // so we have room for the multiplication
+ // each 32 bits will be in the form 0x00AA00AA
+ // with A being the 1 - alpha
+ __m128i alphaChannel = _mm_srli_epi32(srcVector, 24);
+ alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16));
+ alphaChannel = _mm_sub_epi16(one, alphaChannel);
+
+ const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]);
+ __m128i destMultipliedByOneMinusAlpha;
+ BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half);
+
+ // result = s + d * (1-alpha)
+ const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha);
+ _mm_storeu_si128((__m128i *)&dst[x], result);
+ }
+ }
+ for (; x<w; ++x) {
+ uint s = src[x];
+ if (s >= 0xff000000)
+ dst[x] = s;
+ else if (s != 0)
+ dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
+ }
+ dst = (quint32 *)(((uchar *) dst) + dbpl);
+ src = (const quint32 *)(((const uchar *) src) + sbpl);
+ }
+ } else if (const_alpha != 0) {
+ // dest = (s + d * sia) * ca + d * cia
+ // = s * ca + d * (sia * ca + cia)
+ // = s * ca + d * (1 - sa*ca)
+ const_alpha = (const_alpha * 255) >> 8;
+ const __m128i nullVector = _mm_set1_epi32(0);
+ const __m128i half = _mm_set1_epi16(0x80);
+ const __m128i one = _mm_set1_epi16(0xff);
+ const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
+ const __m128i constAlphaVector = _mm_set1_epi16(const_alpha);
+ for (int y = 0; y < h; ++y) {
+ int x = 0;
+ for (; x < w-3; x += 4) {
+ __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]);
+ if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) {
+ BYTE_MUL_SSE2(srcVector, srcVector, constAlphaVector, colorMask, half);
+
+ __m128i alphaChannel = _mm_srli_epi32(srcVector, 24);
+ alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16));
+ alphaChannel = _mm_sub_epi16(one, alphaChannel);
+
+ const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]);
+ __m128i destMultipliedByOneMinusAlpha;
+ BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half);
+
+ const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha);
+ _mm_storeu_si128((__m128i *)&dst[x], result);
+ }
+ }
+ for (; x<w; ++x) {
+ quint32 s = src[x];
+ if (s != 0) {
+ s = BYTE_MUL(s, const_alpha);
+ dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
+ }
+ }
+ dst = (quint32 *)(((uchar *) dst) + dbpl);
+ src = (const quint32 *)(((const uchar *) src) + sbpl);
+ }
+ }
+}
+
+// qblendfunctions.cpp
+void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha);
+
+void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha)
+{
+ const quint32 *src = (const quint32 *) srcPixels;
+ quint32 *dst = (uint *) destPixels;
+ if (const_alpha != 256) {
+ if (const_alpha != 0) {
+ const __m128i nullVector = _mm_set1_epi32(0);
+ const __m128i half = _mm_set1_epi16(0x80);
+ const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
+
+ const_alpha = (const_alpha * 255) >> 8;
+ int one_minus_const_alpha = 255 - const_alpha;
+ const __m128i constAlphaVector = _mm_set1_epi16(const_alpha);
+ const __m128i oneMinusConstAlpha = _mm_set1_epi16(one_minus_const_alpha);
+ for (int y = 0; y < h; ++y) {
+ int x = 0;
+ for (; x < w-3; x += 4) {
+ __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]);
+ if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) {
+ const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]);
+ __m128i result;
+ INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half);
+ _mm_storeu_si128((__m128i *)&dst[x], result);
+ }
+ }
+ for (; x<w; ++x) {
+ quint32 s = src[x];
+ s = BYTE_MUL(s, const_alpha);
+ dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha);
+ }
+ dst = (quint32 *)(((uchar *) dst) + dbpl);
+ src = (const quint32 *)(((const uchar *) src) + sbpl);
+ }
+ }
+ } else {
+ qt_blend_rgb32_on_rgb32(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
+ }
+}
+
void qt_memfill32_sse2(quint32 *dest, quint32 value, int count)
{
if (count < 7) {
diff --git a/src/gui/painting/qdrawhelper_x86_p.h b/src/gui/painting/qdrawhelper_x86_p.h
index 30aadd0..d7282a7 100644
--- a/src/gui/painting/qdrawhelper_x86_p.h
+++ b/src/gui/painting/qdrawhelper_x86_p.h
@@ -114,6 +114,14 @@ void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride);
+void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha);
+void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha);
#endif // QT_HAVE_SSE2
#ifdef QT_HAVE_IWMMXT
diff --git a/src/gui/painting/qemulationpaintengine.cpp b/src/gui/painting/qemulationpaintengine.cpp
index fd42736..0510b10 100644
--- a/src/gui/painting/qemulationpaintengine.cpp
+++ b/src/gui/painting/qemulationpaintengine.cpp
@@ -205,6 +205,11 @@ void QEmulationPaintEngine::drawTextItem(const QPointF &p, const QTextItem &text
real_engine->drawTextItem(p, textItem);
}
+void QEmulationPaintEngine::drawStaticTextItem(QStaticTextItem *item)
+{
+ real_engine->drawStaticTextItem(item);
+}
+
void QEmulationPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s)
{
if (state()->bgMode == Qt::OpaqueMode && pixmap.isQBitmap())
diff --git a/src/gui/painting/qemulationpaintengine_p.h b/src/gui/painting/qemulationpaintengine_p.h
index 0ed641b..5835f10 100644
--- a/src/gui/painting/qemulationpaintengine_p.h
+++ b/src/gui/painting/qemulationpaintengine_p.h
@@ -78,6 +78,7 @@ public:
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem);
+ virtual void drawStaticTextItem(QStaticTextItem *item);
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags);
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp
index 2344c04..39b76c8 100644
--- a/src/gui/painting/qpaintbuffer.cpp
+++ b/src/gui/painting/qpaintbuffer.cpp
@@ -45,6 +45,8 @@
#include <private/qfontengine_p.h>
#include <private/qemulationpaintengine_p.h>
#include <private/qimage_p.h>
+#include <qstatictext.h>
+#include <private/qstatictext_p.h>
#include <QDebug>
@@ -306,6 +308,8 @@ public:
Q_Q(QPaintBufferEngine);
q->buffer->addCommand(QPaintBufferPrivate::Cmd_SystemStateChanged, QVariant(systemClip));
}
+
+ QTransform last;
};
@@ -492,6 +496,32 @@ void QPaintBufferEngine::renderHintsChanged()
void QPaintBufferEngine::transformChanged()
{
+ Q_D(QPaintBufferEngine);
+ const QTransform &transform = state()->matrix;
+
+ QTransform delta;
+
+ bool invertible = false;
+ if (transform.type() <= QTransform::TxScale && transform.type() == d->last.type())
+ delta = transform * d->last.inverted(&invertible);
+
+ d->last = transform;
+
+ if (invertible && delta.type() == QTransform::TxNone)
+ return;
+
+ if (invertible && delta.type() == QTransform::TxTranslate) {
+#ifdef QPAINTBUFFER_DEBUG_DRAW
+ qDebug() << "QPaintBufferEngine: transformChanged (translate only) " << state()->matrix;
+#endif
+ QPaintBufferCommand *cmd =
+ buffer->addCommand(QPaintBufferPrivate::Cmd_Translate);
+
+ qreal data[] = { delta.dx(), delta.dy() };
+ cmd->extra = buffer->addData((qreal *) data, 2);
+ return;
+ }
+
// ### accumulate, like in QBrush case...
if (!buffer->commands.isEmpty()
&& buffer->commands.last().id == QPaintBufferPrivate::Cmd_SetTransform) {
@@ -960,6 +990,18 @@ void QPaintBufferEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con
buffer->updateBoundingRect(r);
}
+void QPaintBufferEngine::drawStaticTextItem(QStaticTextItem *staticTextItem)
+{
+ QString text = QString(staticTextItem->chars, staticTextItem->numChars);
+
+ QStaticText staticText(text);
+ staticText.prepare(state()->matrix, staticTextItem->font);
+
+ QVariantList variants;
+ variants << QVariant(staticTextItem->font) << QVariant::fromValue(staticText);
+ buffer->addCommand(QPaintBufferPrivate::Cmd_DrawStaticText, QVariant(variants));
+}
+
void QPaintBufferEngine::drawTextItem(const QPointF &pos, const QTextItem &ti)
{
#ifdef QPAINTBUFFER_DEBUG_DRAW
@@ -999,6 +1041,7 @@ void QPaintBufferEngine::drawTextItem(const QPointF &pos, const QTextItem &ti)
void QPaintBufferEngine::setState(QPainterState *s)
{
+ Q_D(QPaintBufferEngine);
if (m_begin_detected) {
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << "QPaintBufferEngine: setState: begin, ignoring.";
@@ -1017,6 +1060,8 @@ void QPaintBufferEngine::setState(QPainterState *s)
buffer->addCommand(QPaintBufferPrivate::Cmd_Restore);
}
+ d->last = s->matrix;
+
QPaintEngineEx::setState(s);
}
@@ -1138,6 +1183,15 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
painter->setTransform(xform * m_world_matrix);
break; }
+ case QPaintBufferPrivate::Cmd_Translate: {
+ QPointF delta(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1));
+#ifdef QPAINTBUFFER_DEBUG_DRAW
+ qDebug() << " -> Cmd_Translate, offset: " << cmd.offset << delta;
+#endif
+ painter->translate(delta.x(), delta.y());
+ return;
+ }
+
case QPaintBufferPrivate::Cmd_SetCompositionMode: {
QPainter::CompositionMode mode = (QPainter::CompositionMode) cmd.extra;
#ifdef QPAINTBUFFER_DEBUG_DRAW
@@ -1425,6 +1479,19 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
#endif
painter->setClipRegion(region, Qt::ClipOperation(cmd.extra));
break; }
+
+ case QPaintBufferPrivate::Cmd_DrawStaticText: {
+
+ QVariantList variants(d->variants.at(cmd.offset).value<QVariantList>());
+
+ QFont font(variants.at(0).value<QFont>());
+ QStaticText text(variants.at(0).value<QStaticText>());
+
+ painter->setFont(font);
+ painter->drawStaticText(QPointF(0, 0), text);
+
+ break;
+ }
case QPaintBufferPrivate::Cmd_DrawText: {
QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1));
@@ -1770,8 +1837,28 @@ struct QPaintBufferCacheEntry
QVariant::Type type;
quint64 cacheKey;
};
+
+struct QPaintBufferCacheEntryV2
+{
+ enum Type {
+ ImageKey,
+ PixmapKey
+ };
+
+ struct Flags {
+ uint type : 8;
+ uint key : 24;
+ };
+
+ union {
+ Flags flags;
+ uint bits;
+ };
+};
+
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QPaintBufferCacheEntry)
+Q_DECLARE_METATYPE(QPaintBufferCacheEntryV2)
QT_BEGIN_NAMESPACE
QDataStream &operator<<(QDataStream &stream, const QPaintBufferCacheEntry &entry)
@@ -1784,10 +1871,22 @@ QDataStream &operator>>(QDataStream &stream, QPaintBufferCacheEntry &entry)
return stream >> entry.type >> entry.cacheKey;
}
+QDataStream &operator<<(QDataStream &stream, const QPaintBufferCacheEntryV2 &entry)
+{
+ return stream << entry.bits;
+}
+
+QDataStream &operator>>(QDataStream &stream, QPaintBufferCacheEntryV2 &entry)
+{
+ return stream >> entry.bits;
+}
+
static int qRegisterPaintBufferMetaTypes()
{
qRegisterMetaType<QPaintBufferCacheEntry>();
qRegisterMetaTypeStreamOperators<QPaintBufferCacheEntry>("QPaintBufferCacheEntry");
+ qRegisterMetaType<QPaintBufferCacheEntryV2>();
+ qRegisterMetaTypeStreamOperators<QPaintBufferCacheEntryV2>("QPaintBufferCacheEntryV2");
return 0; // something
}
@@ -1796,6 +1895,9 @@ Q_CONSTRUCTOR_FUNCTION(qRegisterPaintBufferMetaTypes)
QDataStream &operator<<(QDataStream &stream, const QPaintBuffer &buffer)
{
+ QHash<qint64, uint> pixmapKeys;
+ QHash<qint64, uint> imageKeys;
+
QHash<qint64, QPixmap> pixmaps;
QHash<qint64, QImage> images;
@@ -1804,19 +1906,33 @@ QDataStream &operator<<(QDataStream &stream, const QPaintBuffer &buffer)
const QVariant &v = variants.at(i);
if (v.type() == QVariant::Image) {
const QImage image(v.value<QImage>());
- images[image.cacheKey()] = image;
- QPaintBufferCacheEntry entry;
- entry.type = QVariant::Image;
- entry.cacheKey = image.cacheKey();
+ QPaintBufferCacheEntryV2 entry;
+ entry.flags.type = QPaintBufferCacheEntryV2::ImageKey;
+
+ QHash<qint64, uint>::iterator it = imageKeys.find(image.cacheKey());
+ if (it != imageKeys.end()) {
+ entry.flags.key = *it;
+ } else {
+ imageKeys[image.cacheKey()] = entry.flags.key = images.size();
+ images[images.size()] = image;
+ }
+
variants[i] = QVariant::fromValue(entry);
} else if (v.type() == QVariant::Pixmap) {
const QPixmap pixmap(v.value<QPixmap>());
- pixmaps[pixmap.cacheKey()] = pixmap;
- QPaintBufferCacheEntry entry;
- entry.type = QVariant::Pixmap;
- entry.cacheKey = pixmap.cacheKey();
+ QPaintBufferCacheEntryV2 entry;
+ entry.flags.type = QPaintBufferCacheEntryV2::PixmapKey;
+
+ QHash<qint64, uint>::iterator it = pixmapKeys.find(pixmap.cacheKey());
+ if (it != pixmapKeys.end()) {
+ entry.flags.key = *it;
+ } else {
+ pixmapKeys[pixmap.cacheKey()] = entry.flags.key = pixmaps.size();
+ pixmaps[pixmaps.size()] = pixmap;
+ }
+
variants[i] = QVariant::fromValue(entry);
}
}
@@ -1858,6 +1974,15 @@ QDataStream &operator>>(QDataStream &stream, QPaintBuffer &buffer)
variants[i] = QVariant(images.value(entry.cacheKey));
else
variants[i] = QVariant(pixmaps.value(entry.cacheKey));
+ } else if (v.canConvert<QPaintBufferCacheEntryV2>()) {
+ QPaintBufferCacheEntryV2 entry = v.value<QPaintBufferCacheEntryV2>();
+
+ if (entry.flags.type == QPaintBufferCacheEntryV2::ImageKey)
+ variants[i] = QVariant(images.value(entry.flags.key));
+ else if (entry.flags.type == QPaintBufferCacheEntryV2::PixmapKey)
+ variants[i] = QVariant(pixmaps.value(entry.flags.key));
+ else
+ qWarning() << "operator<<(QDataStream &stream, QPaintBuffer &buffer): unrecognized cache entry type:" << entry.flags.type;
}
}
diff --git a/src/gui/painting/qpaintbuffer_p.h b/src/gui/painting/qpaintbuffer_p.h
index 79d7b35..0fde290 100644
--- a/src/gui/painting/qpaintbuffer_p.h
+++ b/src/gui/painting/qpaintbuffer_p.h
@@ -183,6 +183,10 @@ public:
Cmd_DrawTiledPixmap,
Cmd_SystemStateChanged,
+ Cmd_Translate,
+ Cmd_DrawStaticText,
+
+ // new commands must be added above this line
Cmd_LastCommand
};
@@ -394,6 +398,7 @@ public:
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
virtual void drawTextItem(const QPointF &pos, const QTextItem &ti);
+ virtual void drawStaticTextItem(QStaticTextItem *staticTextItem);
virtual void setState(QPainterState *s);
virtual uint flags() const {return QPaintEngineEx::DoNotEmulate;}
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index bc56ed0..60265c5 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -67,6 +67,7 @@
// #include <private/qpolygonclipper_p.h>
// #include <private/qrasterizer_p.h>
#include <private/qimage_p.h>
+#include <private/qstatictext_p.h>
#include "qpaintengine_raster_p.h"
// #include "qbezier_p.h"
@@ -100,10 +101,6 @@
#endif
#include <limits.h>
-#if defined(QT_NO_FPU) || (_MSC_VER >= 1300 && _MSC_VER < 1400)
-# define FLOATING_POINT_BUGGY_OR_NO_FPU
-#endif
-
QT_BEGIN_NAMESPACE
extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
@@ -3006,27 +3003,22 @@ void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx
blend(current, spans, &s->penData);
}
-void QRasterPaintEngine::drawCachedGlyphs(const QPointF &p, const QTextItemInt &ti)
+void QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
+ const QFixedPoint *positions, QFontEngine *fontEngine)
{
Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
- QVarLengthArray<QFixedPoint> positions;
- QVarLengthArray<glyph_t> glyphs;
- QTransform matrix = s->matrix;
- matrix.translate(p.x(), p.y());
- ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
-
- QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : d->glyphCacheType;
+ QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(fontEngine->glyphFormat) : d->glyphCacheType;
QImageTextureGlyphCache *cache =
- (QImageTextureGlyphCache *) ti.fontEngine->glyphCache(0, glyphType, s->matrix);
+ static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphType, s->matrix));
if (!cache) {
cache = new QImageTextureGlyphCache(glyphType, s->matrix);
- ti.fontEngine->setGlyphCache(0, cache);
+ fontEngine->setGlyphCache(0, cache);
}
- cache->populate(ti, glyphs, positions);
+ cache->populate(fontEngine, numGlyphs, glyphs, positions);
const QImage &image = cache->image();
int bpl = image.bytesPerLine();
@@ -3044,7 +3036,7 @@ void QRasterPaintEngine::drawCachedGlyphs(const QPointF &p, const QTextItemInt &
const QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
const uchar *bits = image.bits();
- for (int i=0; i<glyphs.size(); ++i) {
+ for (int i=0; i<numGlyphs; ++i) {
const QTextureGlyphCache::Coord &c = cache->coords.value(glyphs[i]);
int x = qFloor(positions[i].x + offs) + c.baseLineX - margin;
int y = qFloor(positions[i].y + offs) - c.baseLineY - margin;
@@ -3221,6 +3213,15 @@ QRasterPaintEnginePrivate::getPenFunc(const QRectF &rect,
return isUnclipped(rect, penWidth) ? data->unclipped_blend : data->blend;
}
+void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
+{
+ ensurePen();
+ ensureState();
+
+ drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions,
+ textItem->fontEngine);
+}
+
/*!
\reimp
*/
@@ -3269,7 +3270,17 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
drawCached = false;
#endif
if (drawCached) {
- drawCachedGlyphs(p, ti);
+ QRasterPaintEngineState *s = state();
+
+ QVarLengthArray<QFixedPoint> positions;
+ QVarLengthArray<glyph_t> glyphs;
+
+ QTransform matrix = s->matrix;
+ matrix.translate(p.x(), p.y());
+
+ ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
+
+ drawCachedGlyphs(glyphs.size(), glyphs.constData(), positions.constData(), ti.fontEngine);
return;
}
@@ -3679,9 +3690,6 @@ void QRasterPaintEngine::drawEllipse(const QRectF &rect)
if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen)
|| (qpen_style(s->lastPen) == Qt::NoPen && !s->flags.antialiased))
&& qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT
-#ifdef FLOATING_POINT_BUGGY_OR_NO_FPU
- && qMax(rect.width(), rect.height()) < 128 // integer math breakdown
-#endif
&& s->matrix.type() <= QTransform::TxScale) // no shear
{
ensureBrush();
@@ -6054,15 +6062,9 @@ static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip,
ProcessSpans pen_func, ProcessSpans brush_func,
QSpanData *pen_data, QSpanData *brush_data)
{
-#ifdef FLOATING_POINT_BUGGY_OR_NO_FPU // no fpu, so use fixed point
- const QFixed a = QFixed(rect.width()) >> 1;
- const QFixed b = QFixed(rect.height()) >> 1;
- QFixed d = b*b - (a*a*b) + ((a*a) >> 2);
-#else
const qreal a = qreal(rect.width()) / 2;
const qreal b = qreal(rect.height()) / 2;
qreal d = b*b - (a*a*b) + 0.25*a*a;
-#endif
int x = 0;
int y = (rect.height() + 1) / 2;
@@ -6085,12 +6087,7 @@ static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip,
pen_func, brush_func, pen_data, brush_data);
// region 2
-#ifdef FLOATING_POINT_BUGGY_OR_NO_FPU
- d = b*b*(x + (QFixed(1) >> 1))*(x + (QFixed(1) >> 1))
- + a*a*((y - 1)*(y - 1) - b*b);
-#else
d = b*b*(x + 0.5)*(x + 0.5) + a*a*((y - 1)*(y - 1) - b*b);
-#endif
const int miny = rect.height() & 0x1;
while (y > miny) {
if (d < 0) { // select SE
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index a1c73cc..55eb82e 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -203,6 +203,8 @@ public:
void clip(const QRect &rect, Qt::ClipOperation op);
void clip(const QRegion &region, Qt::ClipOperation op);
+ void drawStaticTextItem(QStaticTextItem *textItem);
+
enum ClipType {
RectClip,
ComplexClip
@@ -257,7 +259,8 @@ private:
void fillRect(const QRectF &rect, QSpanData *data);
void drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fill);
- void drawCachedGlyphs(const QPointF &p, const QTextItemInt &ti);
+ void drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions,
+ QFontEngine *fontEngine);
#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
void drawGlyphsS60(const QPointF &p, const QTextItemInt &ti);
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index fccd1dc..90c4f9f 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -70,6 +70,7 @@ QT_MODULE(Gui)
class QPainterState;
class QPaintEngineExPrivate;
+class QStaticTextItem;
struct StrokeHandler;
struct QIntRect {
@@ -200,6 +201,8 @@ public:
virtual void updateState(const QPaintEngineState &state);
+ virtual void drawStaticTextItem(QStaticTextItem *) = 0;
+
virtual void setState(QPainterState *s);
inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); }
inline const QPainterState *state() const { return static_cast<const QPainterState *>(QPaintEngine::state); }
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 3bcaf8c..e69512d 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -69,6 +69,8 @@
#include <private/qwidget_p.h>
#include <private/qpaintengine_raster_p.h>
#include <private/qmath_p.h>
+#include <qstatictext.h>
+#include <private/qstatictext_p.h>
QT_BEGIN_NAMESPACE
@@ -708,13 +710,14 @@ void QPainterPrivate::updateEmulationSpecifier(QPainterState *s)
bool penTextureAlpha = false;
if (penBrush.style() == Qt::TexturePattern)
penTextureAlpha = qHasPixmapTexture(penBrush)
- ? penBrush.texture().hasAlpha()
+ ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha()
: penBrush.textureImage().hasAlphaChannel();
bool brushTextureAlpha = false;
- if (s->brush.style() == Qt::TexturePattern)
+ if (s->brush.style() == Qt::TexturePattern) {
brushTextureAlpha = qHasPixmapTexture(s->brush)
- ? s->brush.texture().hasAlpha()
+ ? (s->brush.texture().depth() > 1) && s->brush.texture().hasAlpha()
: s->brush.textureImage().hasAlphaChannel();
+ }
if (((penBrush.style() == Qt::TexturePattern && penTextureAlpha)
|| (s->brush.style() == Qt::TexturePattern && brushTextureAlpha))
&& !engine->hasFeature(QPaintEngine::MaskedBrush))
@@ -5697,6 +5700,23 @@ void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QR
}
/*!
+
+ \fn void QPainter::drawStaticText(const QPoint &position, const QStaticText &staticText)
+
+ \since 4.7
+
+ \overload
+*/
+
+/*!
+ \fn void QPainter::drawStaticText(int x, int y, const QStaticText &staticText)
+
+ \since 4.7
+
+ \overload
+*/
+
+/*!
\fn void QPainter::drawText(const QPointF &position, const QString &text)
Draws the given \a text with the currently defined text direction,
@@ -5719,6 +5739,124 @@ void QPainter::drawText(const QPointF &p, const QString &str)
}
/*!
+ \since 4.7
+
+ Draws the given \a staticText at the given \a position.
+
+ The text will be drawn using the font and the transformation set on the painter. If the
+ font and/or transformation set on the painter are different from the ones used to initialize
+ the layout of the QStaticText, then the layout will have to be recalculated. Use
+ QStaticText::prepare() to initialize \a staticText with the font and transformation with which
+ it will later be drawn.
+
+ If \a position is not the same as when \a staticText was initialized, or when it was last drawn,
+ then there will be a slight overhead when translating the text to its new position.
+
+ \note If the painter's transformation is not affine, then \a staticText will be drawn using regular
+ calls to drawText(), losing any potential performance improvement.
+
+ \sa QStaticText
+*/
+void QPainter::drawStaticText(const QPointF &position, const QStaticText &staticText)
+{
+ Q_D(QPainter);
+ if (!d->engine || staticText.text().isEmpty() || pen().style() == Qt::NoPen)
+ return;
+
+ QStaticTextPrivate *staticText_d =
+ const_cast<QStaticTextPrivate *>(QStaticTextPrivate::get(&staticText));
+
+ // If we don't have an extended paint engine, or if the painter is projected,
+ // we go through standard code path
+ if (d->extended == 0 || !d->state->matrix.isAffine()) {
+ staticText_d->paintText(position, this);
+ return;
+ }
+
+ // Don't recalculate entire layout because of translation, rather add the dx and dy
+ // into the position to move each text item the correct distance.
+ QPointF transformedPosition = position * d->state->matrix;
+ QTransform matrix = d->state->matrix;
+
+ // The translation has been applied to transformedPosition. Remove translation
+ // component from matrix.
+ if (d->state->matrix.isTranslating()) {
+ qreal m11 = d->state->matrix.m11();
+ qreal m12 = d->state->matrix.m12();
+ qreal m13 = d->state->matrix.m13();
+ qreal m21 = d->state->matrix.m21();
+ qreal m22 = d->state->matrix.m22();
+ qreal m23 = d->state->matrix.m23();
+ qreal m33 = d->state->matrix.m33();
+
+ d->state->matrix.setMatrix(m11, m12, m13,
+ m21, m22, m23,
+ 0.0, 0.0, m33);
+ }
+
+ // If the transform is not identical to the text transform,
+ // we have to relayout the text (for other transformations than plain translation)
+ bool staticTextNeedsReinit = false;
+ if (staticText_d->matrix != d->state->matrix) {
+ staticText_d->matrix = d->state->matrix;
+ staticTextNeedsReinit = true;
+ }
+
+ bool restoreWhenFinished = false;
+ if (staticText_d->needsClipRect) {
+ save();
+ setClipRect(QRectF(position, staticText_d->maximumSize));
+
+ restoreWhenFinished = true;
+ }
+
+ if (font() != staticText_d->font) {
+ staticText_d->font = font();
+ staticTextNeedsReinit = true;
+ }
+
+ // Recreate the layout of the static text because the matrix or font has changed
+ if (staticTextNeedsReinit)
+ staticText_d->init();
+
+ if (transformedPosition != staticText_d->position) { // Translate to actual position
+ QFixed fx = QFixed::fromReal(transformedPosition.x());
+ QFixed fy = QFixed::fromReal(transformedPosition.y());
+ QFixed oldX = QFixed::fromReal(staticText_d->position.x());
+ QFixed oldY = QFixed::fromReal(staticText_d->position.y());
+ for (int item=0; item<staticText_d->itemCount;++item) {
+ QStaticTextItem *textItem = staticText_d->items + item;
+ for (int i=0; i<textItem->numGlyphs; ++i) {
+ textItem->glyphPositions[i].x += fx - oldX;
+ textItem->glyphPositions[i].y += fy - oldY;
+ }
+ textItem->userDataNeedsUpdate = true;
+ }
+
+ staticText_d->position = transformedPosition;
+ }
+
+ QPen oldPen = d->state->pen;
+ QColor currentColor = oldPen.color();
+ for (int i=0; i<staticText_d->itemCount; ++i) {
+ QStaticTextItem *item = staticText_d->items + i;
+ if (currentColor != item->color) {
+ setPen(item->color);
+ currentColor = item->color;
+ }
+ d->extended->drawStaticTextItem(item);
+ }
+ if (currentColor != oldPen.color())
+ setPen(oldPen);
+
+ if (restoreWhenFinished)
+ restore();
+
+ if (matrix.isTranslating())
+ d->state->matrix = matrix;
+}
+
+/*!
\internal
*/
void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justificationPadding)
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index ffddcba..e9fd532 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -78,6 +78,7 @@ class QPolygon;
class QTextItem;
class QMatrix;
class QTransform;
+class QStaticText;
class QPainterPrivateDeleter;
@@ -369,6 +370,10 @@ public:
void setLayoutDirection(Qt::LayoutDirection direction);
Qt::LayoutDirection layoutDirection() const;
+ void drawStaticText(const QPointF &p, const QStaticText &staticText);
+ inline void drawStaticText(const QPoint &p, const QStaticText &staticText);
+ inline void drawStaticText(int x, int y, const QStaticText &staticText);
+
void drawText(const QPointF &p, const QString &s);
inline void drawText(const QPoint &p, const QString &s);
inline void drawText(int x, int y, const QString &s);
@@ -896,6 +901,16 @@ inline void QPainter::drawImage(int x, int y, const QImage &image, int sx, int s
drawImage(QRectF(x, y, -1, -1), image, QRectF(sx, sy, sw, sh), flags);
}
+inline void QPainter::drawStaticText(const QPoint &p, const QStaticText &staticText)
+{
+ drawStaticText(QPointF(p), staticText);
+}
+
+inline void QPainter::drawStaticText(int x, int y, const QStaticText &staticText)
+{
+ drawStaticText(QPointF(x, y), staticText);
+}
+
inline void QPainter::drawTextItem(const QPoint &p, const QTextItem &ti)
{
drawTextItem(QPointF(p), ti);
diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp
index bc81514..949a820 100644
--- a/src/gui/painting/qpathclipper.cpp
+++ b/src/gui/painting/qpathclipper.cpp
@@ -1705,6 +1705,9 @@ QPainterPath QPathClipper::clip(Operation operation)
if (subjectPath == clipPath)
return op == BoolSub ? QPainterPath() : subjectPath;
+ bool subjectIsRect = pathToRect(subjectPath, 0);
+ bool clipIsRect = pathToRect(clipPath, 0);
+
const QRectF clipBounds = clipPath.boundingRect();
const QRectF subjectBounds = subjectPath.boundingRect();
@@ -1732,8 +1735,7 @@ QPainterPath QPathClipper::clip(Operation operation)
}
if (clipBounds.contains(subjectBounds)) {
- QRectF clipRect;
- if (pathToRect(clipPath, &clipRect) && clipRect.contains(subjectBounds)) {
+ if (clipIsRect) {
switch (op) {
case BoolSub:
return QPainterPath();
@@ -1746,17 +1748,16 @@ QPainterPath QPathClipper::clip(Operation operation)
}
}
} else if (subjectBounds.contains(clipBounds)) {
- QRectF subjectRect;
- if (pathToRect(subjectPath, &subjectRect) && subjectRect.contains(clipBounds)) {
+ if (subjectIsRect) {
switch (op) {
case BoolSub:
if (clipPath.fillRule() == Qt::OddEvenFill) {
QPainterPath result = clipPath;
- result.addRect(subjectRect);
+ result.addRect(subjectBounds);
return result;
} else {
QPainterPath result = clipPath.simplified();
- result.addRect(subjectRect);
+ result.addRect(subjectBounds);
return result;
}
break;
@@ -1769,6 +1770,13 @@ QPainterPath QPathClipper::clip(Operation operation)
}
}
}
+
+ if (op == BoolAnd) {
+ if (subjectIsRect)
+ return intersect(clipPath, subjectBounds);
+ else if (clipIsRect)
+ return intersect(subjectPath, clipBounds);
+ }
}
QWingedEdge list(subjectPath, clipPath);
@@ -2052,4 +2060,243 @@ bool QPathClipper::handleCrossingEdges(QWingedEdge &list, qreal y, ClipperMode m
return false;
}
+namespace {
+
+QList<QPainterPath> toSubpaths(const QPainterPath &path)
+{
+
+ QList<QPainterPath> subpaths;
+ if (path.isEmpty())
+ return subpaths;
+
+ QPainterPath current;
+ for (int i = 0; i < path.elementCount(); ++i) {
+ const QPainterPath::Element &e = path.elementAt(i);
+ switch (e.type) {
+ case QPainterPath::MoveToElement:
+ if (current.elementCount() > 1)
+ subpaths += current;
+ current = QPainterPath();
+ current.moveTo(e);
+ break;
+ case QPainterPath::LineToElement:
+ current.lineTo(e);
+ break;
+ case QPainterPath::CurveToElement: {
+ current.cubicTo(e, path.elementAt(i + 1), path.elementAt(i + 2));
+ i+=2;
+ break;
+ }
+ case QPainterPath::CurveToDataElement:
+ Q_ASSERT(!"toSubpaths(), bad element type");
+ break;
+ }
+ }
+
+ if (current.elementCount() > 1)
+ subpaths << current;
+
+ return subpaths;
+}
+
+enum Edge
+{
+ Left, Top, Right, Bottom
+};
+
+static bool isVertical(Edge edge)
+{
+ return edge == Left || edge == Right;
+}
+
+template <Edge edge>
+bool compare(const QPointF &p, qreal t)
+{
+ switch (edge)
+ {
+ case Left:
+ return p.x() < t;
+ case Right:
+ return p.x() > t;
+ case Top:
+ return p.y() < t;
+ default:
+ return p.y() > t;
+ }
+}
+
+template <Edge edge>
+QPointF intersectLine(const QPointF &a, const QPointF &b, qreal t)
+{
+ QLineF line(a, b);
+ switch (edge) {
+ case Left: // fall-through
+ case Right:
+ return line.pointAt((t - a.x()) / (b.x() - a.x()));
+ default:
+ return line.pointAt((t - a.y()) / (b.y() - a.y()));
+ }
+}
+
+void addLine(QPainterPath &path, const QLineF &line)
+{
+ if (path.elementCount() > 0)
+ path.lineTo(line.p1());
+ else
+ path.moveTo(line.p1());
+
+ path.lineTo(line.p2());
+}
+
+template <Edge edge>
+void clipLine(const QPointF &a, const QPointF &b, qreal t, QPainterPath &result)
+{
+ bool outA = compare<edge>(a, t);
+ bool outB = compare<edge>(b, t);
+ if (outA && outB)
+ return;
+
+ if (outA)
+ addLine(result, QLineF(intersectLine<edge>(a, b, t), b));
+ else if(outB)
+ addLine(result, QLineF(a, intersectLine<edge>(a, b, t)));
+ else
+ addLine(result, QLineF(a, b));
+}
+
+void addBezier(QPainterPath &path, const QBezier &bezier)
+{
+ if (path.elementCount() > 0)
+ path.lineTo(bezier.pt1());
+ else
+ path.moveTo(bezier.pt1());
+
+ path.cubicTo(bezier.pt2(), bezier.pt3(), bezier.pt4());
+}
+
+template <Edge edge>
+void clipBezier(const QPointF &a, const QPointF &b, const QPointF &c, const QPointF &d, qreal t, QPainterPath &result)
+{
+ QBezier bezier = QBezier::fromPoints(a, b, c, d);
+
+ bool outA = compare<edge>(a, t);
+ bool outB = compare<edge>(b, t);
+ bool outC = compare<edge>(c, t);
+ bool outD = compare<edge>(d, t);
+
+ int outCount = int(outA) + int(outB) + int(outC) + int(outD);
+
+ if (outCount == 4)
+ return;
+
+ if (outCount == 0) {
+ addBezier(result, bezier);
+ return;
+ }
+
+ QTransform flip = isVertical(edge) ? QTransform(0, 1, 1, 0, 0, 0) : QTransform();
+ QBezier unflipped = bezier;
+ QBezier flipped = bezier.mapBy(flip);
+
+ qreal t0 = 0, t1 = 1;
+ int stationary = flipped.stationaryYPoints(t0, t1);
+
+ qreal segments[4];
+ QPointF points[4];
+ points[0] = unflipped.pt1();
+ segments[0] = 0;
+
+ int segmentCount = 0;
+ if (stationary > 0) {
+ ++segmentCount;
+ segments[segmentCount] = t0;
+ points[segmentCount] = unflipped.pointAt(t0);
+ }
+ if (stationary > 1) {
+ ++segmentCount;
+ segments[segmentCount] = t1;
+ points[segmentCount] = unflipped.pointAt(t1);
+ }
+ ++segmentCount;
+ segments[segmentCount] = 1;
+ points[segmentCount] = unflipped.pt4();
+
+ qreal lastIntersection = 0;
+ for (int i = 0; i < segmentCount; ++i) {
+ outA = compare<edge>(points[i], t);
+ outB = compare<edge>(points[i+1], t);
+
+ if (outA != outB) {
+ qreal intersection = flipped.tForY(segments[i], segments[i+1], t);
+
+ if (outB)
+ addBezier(result, unflipped.getSubRange(lastIntersection, intersection));
+
+ lastIntersection = intersection;
+ }
+ }
+
+ if (!outB)
+ addBezier(result, unflipped.getSubRange(lastIntersection, 1));
+}
+
+// clips a single subpath against a single edge
+template <Edge edge>
+QPainterPath clip(const QPainterPath &path, qreal t)
+{
+ QPainterPath result;
+ for (int i = 1; i < path.elementCount(); ++i) {
+ const QPainterPath::Element &element = path.elementAt(i);
+ Q_ASSERT(!element.isMoveTo());
+ if (element.isLineTo()) {
+ clipLine<edge>(path.elementAt(i-1), path.elementAt(i), t, result);
+ } else {
+ clipBezier<edge>(path.elementAt(i-1), path.elementAt(i), path.elementAt(i+1), path.elementAt(i+2), t, result);
+ i += 2;
+ }
+ }
+
+ int last = path.elementCount() - 1;
+ if (QPointF(path.elementAt(last)) != QPointF(path.elementAt(0)))
+ clipLine<edge>(path.elementAt(last), path.elementAt(0), t, result);
+
+ return result;
+}
+
+QPainterPath intersectPath(const QPainterPath &path, const QRectF &rect)
+{
+ QList<QPainterPath> subpaths = toSubpaths(path);
+
+ QPainterPath result;
+ result.setFillRule(path.fillRule());
+ for (int i = 0; i < subpaths.size(); ++i) {
+ QPainterPath subPath = subpaths.at(i);
+ QRectF bounds = subPath.boundingRect();
+ if (bounds.intersects(rect)) {
+ if (bounds.left() < rect.left())
+ subPath = clip<Left>(subPath, rect.left());
+ if (bounds.right() > rect.right())
+ subPath = clip<Right>(subPath, rect.right());
+
+ bounds = subPath.boundingRect();
+
+ if (bounds.top() < rect.top())
+ subPath = clip<Top>(subPath, rect.top());
+ if (bounds.bottom() > rect.bottom())
+ subPath = clip<Bottom>(subPath, rect.bottom());
+
+ if (subPath.elementCount() > 1)
+ result.addPath(subPath);
+ }
+ }
+ return result;
+}
+
+}
+
+QPainterPath QPathClipper::intersect(const QPainterPath &path, const QRectF &rect)
+{
+ return intersectPath(path, rect);
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h
index b900862..b42dc1d 100644
--- a/src/gui/painting/qpathclipper_p.h
+++ b/src/gui/painting/qpathclipper_p.h
@@ -87,6 +87,7 @@ public:
bool contains();
static bool pathToRect(const QPainterPath &path, QRectF *rect = 0);
+ static QPainterPath intersect(const QPainterPath &path, const QRectF &rect);
private:
Q_DISABLE_COPY(QPathClipper)
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index dd516b1..dcf745f 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1415,6 +1415,7 @@ void QPdfBaseEngine::setProperty(PrintEnginePropertyKey key, const QVariant &val
case PPK_FullPage:
d->fullPage = value.toBool();
break;
+ case PPK_CopyCount: // fallthrough
case PPK_NumberOfCopies:
d->copies = value.toInt();
break;
@@ -1504,6 +1505,17 @@ QVariant QPdfBaseEngine::property(PrintEnginePropertyKey key) const
case PPK_FullPage:
ret = d->fullPage;
break;
+ case PPK_CopyCount:
+ ret = d->copies;
+ break;
+ case PPK_SupportsMultipleCopies:
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ if (QCUPSSupport::isAvailable())
+ ret = true;
+ else
+#endif
+ ret = false;
+ break;
case PPK_NumberOfCopies:
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
if (QCUPSSupport::isAvailable())
diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h
index f79c5cc..9c4d05d 100644
--- a/src/gui/painting/qpdf_p.h
+++ b/src/gui/painting/qpdf_p.h
@@ -216,8 +216,6 @@ public:
private:
void updateClipPath(const QPainterPath & path, Qt::ClipOperation op);
-
- friend int qt_printerRealNumCopies(QPaintEngine *);
};
class QPdfBaseEnginePrivate : public QAlphaPaintEnginePrivate
diff --git a/src/gui/painting/qprintengine.h b/src/gui/painting/qprintengine.h
index 35715fb..71ff954 100644
--- a/src/gui/painting/qprintengine.h
+++ b/src/gui/painting/qprintengine.h
@@ -86,6 +86,8 @@ public:
PPK_PaperSources,
PPK_CustomPaperSize,
PPK_PageMargins,
+ PPK_CopyCount,
+ PPK_SupportsMultipleCopies,
PPK_PaperSize = PPK_PageSize,
PPK_CustomBase = 0xff00
diff --git a/src/gui/painting/qprintengine_mac.mm b/src/gui/painting/qprintengine_mac.mm
index 7195c63..3d5d1d5 100644
--- a/src/gui/painting/qprintengine_mac.mm
+++ b/src/gui/painting/qprintengine_mac.mm
@@ -685,6 +685,7 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
case PPK_FullPage:
d->fullPage = value.toBool();
break;
+ case PPK_CopyCount: // fallthrough
case PPK_NumberOfCopies:
PMSetCopies(d->settings, value.toInt(), false);
break;
@@ -787,6 +788,15 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
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);
diff --git a/src/gui/painting/qprintengine_qws.cpp b/src/gui/painting/qprintengine_qws.cpp
index 2d355b8..396d712 100644
--- a/src/gui/painting/qprintengine_qws.cpp
+++ b/src/gui/painting/qprintengine_qws.cpp
@@ -268,9 +268,13 @@ QVariant QtopiaPrintEngine::property(PrintEnginePropertyKey key) const
case PPK_FullPage:
ret = d->fullPage;
break;
+ case PPK_CopyCount: // fallthrough
case PPK_NumberOfCopies:
ret = d->numCopies;
break;
+ case PPK_SupportsMultipleCopies:
+ ret = false;
+ break;
case PPK_Orientation:
ret = d->orientation;
break;
@@ -329,6 +333,7 @@ void QtopiaPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
case PPK_FullPage:
d->fullPage = value.toBool();
break;
+ case PPK_CopyCount: // fallthrough
case PPK_NumberOfCopies:
d->numCopies = value.toInt();
break;
diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp
index 374bfa0..d029b1e 100644
--- a/src/gui/painting/qprintengine_win.cpp
+++ b/src/gui/painting/qprintengine_win.cpp
@@ -1240,6 +1240,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->updateOrigin();
break;
+ case PPK_CopyCount: // fallthrough
case PPK_NumberOfCopies:
if (!d->devMode)
break;
@@ -1406,6 +1407,14 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
value = d->fullPage;
break;
+ case PPK_CopyCount:
+ value = d->num_copies;
+ break;
+
+ case PPK_SupportsMultipleCopies:
+ value = true;
+ break;
+
case PPK_NumberOfCopies:
value = 1;
break;
diff --git a/src/gui/painting/qprintengine_win_p.h b/src/gui/painting/qprintengine_win_p.h
index a3271cb..d435831 100644
--- a/src/gui/painting/qprintengine_win_p.h
+++ b/src/gui/painting/qprintengine_win_p.h
@@ -108,7 +108,6 @@ public:
private:
friend class QPrintDialog;
friend class QPageSetupDialog;
- friend int qt_printerRealNumCopies(QPaintEngine *);
};
class QWin32PrintEnginePrivate : public QAlphaPaintEnginePrivate
diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp
index 4d2b50a..edf224d 100644
--- a/src/gui/painting/qprinter.cpp
+++ b/src/gui/painting/qprinter.cpp
@@ -158,27 +158,6 @@ QSizeF qt_printerPaperSize(QPrinter::Orientation orientation,
(qt_paperSizes[paperSize][height_index] * 72 / 25.4) / multiplier);
}
-
-// returns the actual num copies set on a printer, not
-// the number that is documented in QPrinter::numCopies()
-int qt_printerRealNumCopies(QPaintEngine *engine)
-{
- int numCopies = 1;
- if (engine->type() == QPaintEngine::PostScript
- || engine->type() == QPaintEngine::Pdf)
- {
- QPdfBaseEngine *base = static_cast<QPdfBaseEngine *>(engine);
- numCopies = base->d_func()->copies;
- }
-#ifdef Q_WS_WIN
- else if (engine->type() == QPaintEngine::Windows) {
- QWin32PrintEngine *base = static_cast<QWin32PrintEngine *>(engine);
- numCopies = base->d_func()->num_copies;
- }
-#endif
- return numCopies;
-}
-
void QPrinterPrivate::createDefaultEngines()
{
QPrinter::OutputFormat realOutputFormat = outputFormat;
@@ -302,7 +281,7 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
printer to provide, in dots per inch (DPI).
\i setFullPage() tells QPrinter whether you want to deal with the
full page or just with the part the printer can draw on.
- \i setNumCopies() tells QPrinter how many copies of the document
+ \i setCopyCount() tells QPrinter how many copies of the document
it should print.
\endlist
@@ -748,7 +727,6 @@ void QPrinter::setOutputFormat(OutputFormat format)
d->outputFormat = format;
QPrintEngine *oldPrintEngine = d->printEngine;
- QPaintEngine *oldPaintEngine = d->paintEngine; // same as the above - shouldn't be deleted
const bool def_engine = d->use_default_engine;
d->printEngine = 0;
@@ -761,7 +739,7 @@ void QPrinter::setOutputFormat(OutputFormat format)
// PPK_NumberOfCopies need special treatmeant since it in most cases
// will return 1, disregarding the actual value that was set
if (key == QPrintEngine::PPK_NumberOfCopies)
- prop = QVariant(qt_printerRealNumCopies(oldPaintEngine));
+ prop = QVariant(copyCount());
else
prop = oldPrintEngine->property(key);
if (prop.isValid())
@@ -1263,6 +1241,7 @@ QPrinter::ColorMode QPrinter::colorMode() const
/*!
+ \obsolete
Returns the number of copies to be printed. The default value is 1.
On Windows, Mac OS X and X11 systems that support CUPS, this will always
@@ -1275,6 +1254,8 @@ QPrinter::ColorMode QPrinter::colorMode() const
buffering up the copies and in those cases the application must make an
explicit call to the print code for each copy.
+ Use copyCount() in conjunction with supportsMultipleCopies() instead.
+
\sa setNumCopies(), actualNumCopies()
*/
@@ -1286,6 +1267,7 @@ int QPrinter::numCopies() const
/*!
+ \obsolete
\since 4.6
Returns the number of copies that will be printed. The default
@@ -1294,22 +1276,26 @@ int QPrinter::numCopies() const
This function always returns the actual value specified in the print
dialog or using setNumCopies().
+ Use copyCount() instead.
+
\sa setNumCopies(), numCopies()
*/
int QPrinter::actualNumCopies() const
{
- Q_D(const QPrinter);
- return qt_printerRealNumCopies(d->paintEngine);
+ return copyCount();
}
/*!
+ \obsolete
Sets the number of copies to be printed to \a numCopies.
The printer driver reads this setting and prints the specified
number of copies.
+ Use setCopyCount() instead.
+
\sa numCopies()
*/
@@ -1321,6 +1307,58 @@ void QPrinter::setNumCopies(int numCopies)
d->addToManualSetList(QPrintEngine::PPK_NumberOfCopies);
}
+/*!
+ \since 4.7
+
+ Sets the number of copies to be printed to \a count.
+
+ The printer driver reads this setting and prints the specified number of
+ copies.
+
+ \sa copyCount(), supportsMultipleCopies()
+*/
+
+void QPrinter::setCopyCount(int count)
+{
+ Q_D(QPrinter);
+ ABORT_IF_ACTIVE("QPrinter::setCopyCount;");
+ d->printEngine->setProperty(QPrintEngine::PPK_CopyCount, count);
+ d->addToManualSetList(QPrintEngine::PPK_CopyCount);
+}
+
+/*!
+ \since 4.7
+
+ Returns the number of copies that will be printed. The default value is 1.
+
+ \sa setCopyCount(), supportsMultipleCopies()
+*/
+
+int QPrinter::copyCount() const
+{
+ Q_D(const QPrinter);
+ return d->printEngine->property(QPrintEngine::PPK_CopyCount).toInt();
+}
+
+/*!
+ \since 4.7
+
+ Returns true if the printer supports printing multiple copies of the same
+ document in one job; otherwise false is returned.
+
+ On most systems this function will return true. However, on X11 systems
+ that do not support CUPS, this function will return false. That means the
+ application has to handle the number of copies by printing the same
+ document the required number of times.
+
+ \sa setCopyCount(), copyCount()
+*/
+
+bool QPrinter::supportsMultipleCopies() const
+{
+ Q_D(const QPrinter);
+ return d->printEngine->property(QPrintEngine::PPK_SupportsMultipleCopies).toBool();
+}
/*!
\since 4.1
@@ -2262,8 +2300,8 @@ bool QPrinter::isOptionEnabled( PrinterOption option ) const
\value PPK_FullPage A boolean describing if the printer should be
full page or not.
- \value PPK_NumberOfCopies An integer specifying the number of
- copies
+ \value PPK_NumberOfCopies Obsolete. An integer specifying the number of
+ copies. Use PPK_CopyCount instead.
\value PPK_Orientation Specifies a QPrinter::Orientation value.
@@ -2310,6 +2348,11 @@ bool QPrinter::isOptionEnabled( PrinterOption option ) const
\value PPK_PageMargins A QList<QVariant> containing the left, top,
right and bottom margin values.
+ \value PPK_CopyCount An integer specifying the number of copies to print.
+
+ \value PPK_SupportsMultipleCopies A boolean value indicating whether or not
+ the printer supports printing multiple copies in one job.
+
\value PPK_CustomBase Basis for extension.
*/
diff --git a/src/gui/painting/qprinter.h b/src/gui/painting/qprinter.h
index 5aa891e..6636179 100644
--- a/src/gui/painting/qprinter.h
+++ b/src/gui/painting/qprinter.h
@@ -199,6 +199,10 @@ public:
int actualNumCopies() const;
+ void setCopyCount(int);
+ int copyCount() const;
+ bool supportsMultipleCopies() const;
+
void setPaperSource(PaperSource);
PaperSource paperSource() const;
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 7b7f325..cf3957b 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -55,29 +55,42 @@ QT_BEGIN_NAMESPACE
// #define CACHE_DEBUG
-void QTextureGlyphCache::populate(const QTextItemInt &ti,
- const QVarLengthArray<glyph_t> &glyphs,
- const QVarLengthArray<QFixedPoint> &)
+// returns the highest number closest to v, which is a power of 2
+// NB! assumes 32 bit ints
+int qt_next_power_of_two(int v)
+{
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ ++v;
+ return v;
+}
+
+void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const glyph_t *glyphs,
+ const QFixedPoint *)
{
#ifdef CACHE_DEBUG
printf("Populating with '%s'\n", QString::fromRawData(ti.chars, ti.num_chars).toLatin1().data());
qDebug() << " -> current transformation: " << m_transform;
#endif
- m_current_textitem = &ti;
+ m_current_fontengine = fontEngine;
const int margin = glyphMargin();
QHash<glyph_t, Coord> listItemCoordinates;
int rowHeight = 0;
// check each glyph for its metrics and get the required rowHeight.
- for (int i=0; i < glyphs.size(); ++i) {
+ for (int i=0; i < numGlyphs; ++i) {
const glyph_t glyph = glyphs[i];
if (coords.contains(glyph))
continue;
if (listItemCoordinates.contains(glyph))
continue;
- glyph_metrics_t metrics = ti.fontEngine->boundingBox(glyph, m_transform);
+ glyph_metrics_t metrics = fontEngine->boundingBox(glyph, m_transform);
#ifdef CACHE_DEBUG
printf("'%c' (%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f, ti.ascent=%.2f, ti.descent=%.2f\n",
@@ -116,7 +129,7 @@ void QTextureGlyphCache::populate(const QTextItemInt &ti,
rowHeight += margin * 2;
if (isNull())
- createCache(QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH, rowHeight);
+ createCache(QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH, qt_next_power_of_two(rowHeight));
// now actually use the coords and paint the wanted glyps into cache.
QHash<glyph_t, Coord>::iterator iter = listItemCoordinates.begin();
@@ -129,13 +142,9 @@ void QTextureGlyphCache::populate(const QTextItemInt &ti,
m_cy = m_h;
}
if (m_cy + c.h > m_h) {
- int new_height;
- if (m_cx == 0) { // add a whole row
- new_height = m_h + rowHeight;
- m_cy = m_h;
- } else { // just extend row
- new_height = m_cy + rowHeight;
- }
+ int new_height = m_h*2;
+ while (new_height < m_cy + c.h)
+ new_height *= 2;
// if no room in the current texture - realloc a larger texture
resizeTextureData(m_w, new_height);
m_h = new_height;
@@ -182,7 +191,7 @@ QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g) const
break;
};
- QFontEngineFT *ft = static_cast<QFontEngineFT*> (m_current_textitem->fontEngine);
+ QFontEngineFT *ft = static_cast<QFontEngineFT*> (m_current_fontengine);
QFontEngineFT::QGlyphSet *gset = ft->loadTransformedGlyphSet(m_transform);
if (gset && ft->loadGlyphs(gset, &g, 1, format)) {
@@ -194,9 +203,9 @@ QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g) const
} else
#endif
if (m_type == QFontEngineGlyphCache::Raster_RGBMask)
- return m_current_textitem->fontEngine->alphaRGBMapForGlyph(g, glyphMargin(), m_transform);
+ return m_current_fontengine->alphaRGBMapForGlyph(g, glyphMargin(), m_transform);
else
- return m_current_textitem->fontEngine->alphaMapForGlyph(g, m_transform);
+ return m_current_fontengine->alphaMapForGlyph(g, m_transform);
return QImage();
}
diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h
index d347e61..803e71b 100644
--- a/src/gui/painting/qtextureglyphcache_p.h
+++ b/src/gui/painting/qtextureglyphcache_p.h
@@ -76,7 +76,9 @@ class Q_GUI_EXPORT QTextureGlyphCache : public QFontEngineGlyphCache
{
public:
QTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix)
- : QFontEngineGlyphCache(matrix, type), m_w(0), m_h(0), m_cx(0), m_cy(0) { }
+ : QFontEngineGlyphCache(matrix, type), m_current_fontengine(0),
+ m_w(0), m_h(0), m_cx(0), m_cy(0)
+ { }
virtual ~QTextureGlyphCache() { }
@@ -90,9 +92,8 @@ public:
int baseLineY;
};
- void populate(const QTextItemInt &ti,
- const QVarLengthArray<glyph_t> &glyphs,
- const QVarLengthArray<QFixedPoint> &positions);
+ void populate(QFontEngine *fontEngine, int numGlyphs, const glyph_t *glyphs,
+ const QFixedPoint *positions);
virtual void createTextureData(int width, int height) = 0;
virtual void resizeTextureData(int width, int height) = 0;
@@ -113,7 +114,7 @@ public:
QImage textureMapForGlyph(glyph_t g) const;
protected:
- const QTextItemInt *m_current_textitem;
+ QFontEngine *m_current_fontengine;
int m_w; // image width
int m_h; // image height
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index ea7399f..565cc2c 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -120,6 +120,8 @@ QPixmap *QS60StylePrivate::m_background = 0;
// theme palette
QPalette *QS60StylePrivate::m_themePalette = 0;
+qint64 QS60StylePrivate::m_webPaletteKey = 0;
+
const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = {
{SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter},
{SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed},
@@ -807,8 +809,12 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const
QPalette webPalette = *palette;
webPalette.setColor(QPalette::WindowText, Qt::black);
webPalette.setColor(QPalette::Text, Qt::black);
+ webPalette.setBrush(QPalette::Base, Qt::white);
+
QApplication::setPalette(webPalette, "QWebView");
QApplication::setPalette(webPalette, "QGraphicsWebView");
+
+ m_webPaletteKey = webPalette.cacheKey();
}
QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags)
@@ -896,8 +902,11 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag
return result;
}
-bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush)
+bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush, const QWidget *widget)
{
+ // Always return true for web pages.
+ if (widget && m_webPaletteKey == QApplication::palette(widget).cacheKey())
+ return true;
//If brush is not changed from style's default values, draw theme graphics.
return (backgroundBrush.color() == Qt::transparent ||
backgroundBrush.style() == Qt::NoBrush) ? true : false;
@@ -1901,7 +1910,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
case CE_ShapedFrame:
if (const QTextEdit *textEdit = qobject_cast<const QTextEdit *>(widget)) {
const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option);
- if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base()))
+ if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base(), widget))
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags);
else
QCommonStyle::drawControl(element, option, painter, widget);
@@ -2013,7 +2022,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
if (widget && qobject_cast<const QComboBox *>(widget->parentWidget()))
break;
#endif
- if (QS60StylePrivate::canDrawThemeBackground(option->palette.base()))
+ if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget))
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags);
else
commonStyleDraws = true;
@@ -2093,7 +2102,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_PanelButtonTool:
case PE_PanelButtonBevel:
case PE_FrameButtonBevel:
- if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) {
+ if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)) {
const bool isPressed = option->state & State_Sunken;
const QS60StylePrivate::SkinElements skinElement =
isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal;
@@ -2125,7 +2134,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorSpinDown:
case PE_IndicatorSpinUp:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base())) {
+ if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base(), widget)) {
QStyleOptionSpinBox optionSpinBox = *spinBox;
const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ?
QS60StyleEnums::SP_QgnGrafScrollArrowUp :
@@ -2140,7 +2149,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
#endif //QT_NO_SPINBOX
#ifndef QT_NO_COMBOBOX
if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- if (QS60StylePrivate::canDrawThemeBackground( option->palette.base())) {
+ if (QS60StylePrivate::canDrawThemeBackground( option->palette.base(), widget)) {
// We want to draw down arrow here for comboboxes as well.
QStyleOptionFrame optionsComboBox = *cmb;
const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown;
@@ -2179,7 +2188,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
#endif //QT_NO_MENU
) {
//Need extra check since dialogs have their own theme background
- if (QS60StylePrivate::canDrawThemeBackground(option->palette.base()) &&
+ if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) &&
option->palette.window().texture().cacheKey() ==
QS60StylePrivate::m_themePalette->window().texture().cacheKey())
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags);
@@ -2387,10 +2396,20 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_PushButton:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
//FIXME properly - style should calculate the location of border frame-part
- sz += QSize(2 * pixelMetric(PM_ButtonMargin), 2 * pixelMetric(PM_ButtonMargin));
- if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget)))
+ if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) {
if (buttonWidget->isCheckable())
sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0);
+ const int iconHeight = (!buttonWidget->icon().isNull()) ? buttonWidget->iconSize().height() : 0;
+ const int textHeight = (buttonWidget->text().length() > 0) ?
+ buttonWidget->fontMetrics().size(Qt::TextSingleLine, buttonWidget->text()).height() : 0;
+ const int decoratorHeight = (buttonWidget->isCheckable()) ? pixelMetric(PM_IndicatorHeight) : 0;
+
+ const int contentHeight =
+ qMax(qMax(iconHeight, decoratorHeight) + pixelMetric(PM_ButtonMargin),
+ textHeight + 2*pixelMetric(PM_ButtonMargin));
+ sz.setHeight(contentHeight);
+ sz += QSize(2 * pixelMetric(PM_ButtonMargin), 0);
+ }
break;
case CT_LineEdit:
if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt))
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index ea30b81..16d82e7 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -542,7 +542,7 @@ public:
//Checks that the current brush is transparent or has BrushStyle NoBrush,
//so that theme graphic background can be drawn.
- static bool canDrawThemeBackground(const QBrush &backgroundBrush);
+ static bool canDrawThemeBackground(const QBrush &backgroundBrush, const QWidget *widget);
static int currentAnimationFrame(QS60StyleEnums::SkinParts part);
#ifdef Q_WS_S60
@@ -596,6 +596,7 @@ private:
QPalette m_originalPalette;
QPointer<QFocusFrame> m_focusFrame;
+ static qint64 m_webPaletteKey;
#ifdef Q_WS_S60
//list of progress bars having animation running
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp
index b30a6c3..c50d363 100644
--- a/src/gui/text/qfontdatabase_win.cpp
+++ b/src/gui/text/qfontdatabase_win.cpp
@@ -336,8 +336,18 @@ void addFontToDatabase(QString familyName, const QString &scriptName,
signature->fsCsb[0], signature->fsCsb[1]
};
QList<QFontDatabase::WritingSystem> systems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
- for (int i = 0; i < systems.count(); ++i)
- family->writingSystems[systems.at(i)] = QtFontFamily::Supported;
+
+ for (int i = 0; i < systems.count(); ++i) {
+ QFontDatabase::WritingSystem writingSystem = systems.at(i);
+
+ // ### Hack to work around problem with Thai text on Windows 7. Segoe UI contains
+ // the symbol for Baht, and Windows thus reports that it supports the Thai script.
+ // Since it's the default UI font on this platform, most widgets will be unable to
+ // display Thai text by default. As a temporary work around, we special case Segoe UI
+ // and remove the Thai script from its list of supported writing systems.
+ if (writingSystem != QFontDatabase::Thai || familyName != QLatin1String("Segoe UI"))
+ family->writingSystems[writingSystem] = QtFontFamily::Supported;
+ }
} else if (!family->writingSystemCheck) {
//qDebug("family='%s' script=%s", family->name.latin1(), script.latin1());
if (scriptName == QLatin1String("Western")
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
new file mode 100644
index 0000000..a7138b9
--- /dev/null
+++ b/src/gui/text/qstatictext.cpp
@@ -0,0 +1,616 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstatictext.h"
+#include "qstatictext_p.h"
+#include <private/qtextengine_p.h>
+#include <private/qfontengine_p.h>
+
+#include <QtGui/qapplication.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QStaticText
+ \brief The QStaticText class enables optimized drawing of text when the text and its layout
+ is updated rarely.
+ \since 4.7
+
+ \ingroup multimedia
+ \ingroup text
+ \mainclass
+
+ QStaticText provides a way to cache layout data for a block of text so that it can be drawn
+ more efficiently than by using QPainter::drawText() in which the layout information is
+ recalculated with every call.
+
+ The class primarily provides an optimization for cases where the text, its font and the
+ transformations on the painter are static over several paint events. If the text or its layout
+ is changed for every iteration, QPainter::drawText() is the more efficient alternative, since
+ the static text's layout would have to be recalculated to take the new state into consideration.
+
+ Translating the painter will not cause the layout of the text to be recalculated, but will cause
+ a very small performance impact on drawStaticText(). Altering any other parts of the painter's
+ transformation or the painter's font will cause the layout of the static text to be
+ recalculated. This should be avoided as often as possible to maximize the performance
+ benefit of using QStaticText.
+
+ In addition, only affine transformations are supported by drawStaticText(). Calling
+ drawStaticText() on a projected painter will perform slightly worse than using the regular
+ drawText() call, so this should be avoided.
+
+ \code
+ class MyWidget: public QWidget
+ {
+ public:
+ MyWidget(QWidget *parent = 0) : QWidget(parent), m_staticText("This is static text")
+
+ protected:
+ void paintEvent(QPaintEvent *)
+ {
+ QPainter painter(this);
+ painter.drawStaticText(0, 0, m_staticText);
+ }
+
+ private:
+ QStaticText m_staticText;
+ };
+ \endcode
+
+ The QStaticText class can be used to mimic the behavior of QPainter::drawText() to a specific
+ point with no boundaries, and also when QPainter::drawText() is called with a bounding
+ rectangle.
+
+ If a bounding rectangle is not required, create a QStaticText object without setting a maximum
+ size. The text will then occupy a single line.
+
+ If you set a maximum size on the QStaticText object, this will bound the text. The text will
+ be formatted so that no line exceeds the given width. When the object is painted, it will
+ be clipped at the given size. The position of the text is decided by the argument
+ passed to QPainter::drawStaticText() and can change from call to call with a minimal impact
+ on performance.
+
+ QStaticText will attempt to guess the format of the input text using Qt::mightBeRichText().
+ To force QStaticText to display its contents as either plain text or rich text, use the
+ function QStaticText::setTextFormat() and pass in, respectively, Qt::PlainText and
+ Qt::RichText.
+
+ \sa QPainter::drawText(), QPainter::drawStaticText(), QTextLayout, QTextDocument
+*/
+
+/*!
+ \enum QStaticText::PerformanceHint
+
+ This enum the different performance hints that can be set on the QStaticText. These hints
+ can be used to indicate that the QStaticText should use additional caches, if possible,
+ to improve performance at the expense of memory. In particular, setting the performance hint
+ AggressiveCaching on the QStaticText will improve performance when using the OpenGL graphics
+ system or when drawing to a QGLWidget.
+
+ \value ModerateCaching Do basic caching for high performance at a low memory cost.
+ \value AggressiveCaching Use additional caching when available. This may improve performance
+ at a higher memory cost.
+*/
+
+/*!
+ Constructs an empty QStaticText
+*/
+QStaticText::QStaticText()
+ : data(new QStaticTextPrivate)
+{
+}
+
+/*!
+ Constructs a QStaticText object with the given \a text and bounded by the given \a size.
+
+ If an invalid size is passed for \a size the text will be unbounded.
+*/
+QStaticText::QStaticText(const QString &text, const QSizeF &size)
+ : data(new QStaticTextPrivate)
+{
+ data->text = text;
+ data->maximumSize = size;
+ data->init();
+}
+
+/*!
+ Constructs a QStaticText object which is a copy of \a other.
+*/
+QStaticText::QStaticText(const QStaticText &other)
+{
+ data = other.data;
+}
+
+/*!
+ Destroys the QStaticText.
+*/
+QStaticText::~QStaticText()
+{
+ Q_ASSERT(!data || data->ref >= 1);
+}
+
+/*!
+ \internal
+*/
+void QStaticText::detach()
+{
+ if (data->ref != 1)
+ data.detach();
+}
+
+/*!
+ Prepares the QStaticText object for being painted with the given \a matrix and the given
+ \a font to avoid overhead when the actual drawStaticText() call is made.
+
+ When drawStaticText() is called, the layout of the QStaticText will be recalculated if the
+ painter's font or matrix is different from the one used for the currently cached layout. By
+ default, QStaticText will use a default constructed QFont and an identity matrix to create
+ its layout.
+
+ To avoid the overhead of creating the layout the first time you draw the QStaticText with
+ a painter whose matrix or font are different from the defaults, you can use the prepare()
+ function and pass in the matrix and font you expect to use when drawing the text.
+
+ \sa QPainter::setFont(), QPainter::setMatrix()
+*/
+void QStaticText::prepare(const QTransform &matrix, const QFont &font)
+{
+ data->matrix = matrix;
+ data->font = font;
+ data->init();
+}
+
+
+/*!
+ Assigns \a other to this QStaticText.
+*/
+QStaticText &QStaticText::operator=(const QStaticText &other)
+{
+ data = other.data;
+ return *this;
+}
+
+/*!
+ Compares \a other to this QStaticText. Returns true if the texts, fonts and maximum sizes
+ are equal.
+*/
+bool QStaticText::operator==(const QStaticText &other) const
+{
+ return (data == other.data
+ || (data->text == other.data->text
+ && data->font == other.data->font
+ && data->maximumSize == other.data->maximumSize));
+}
+
+/*!
+ Compares \a other to this QStaticText. Returns true if the texts, fonts or maximum sizes
+ are different.
+*/
+bool QStaticText::operator!=(const QStaticText &other) const
+{
+ return !(*this == other);
+}
+
+/*!
+ Sets the text of the QStaticText to \a text.
+
+ \note This function will cause the layout of the text to be recalculated.
+
+ \sa text()
+*/
+void QStaticText::setText(const QString &text)
+{
+ detach();
+ data->text = text;
+ data->init();
+}
+
+/*!
+ Sets the text format of the QStaticText to \a textFormat. If \a textFormat is set to
+ Qt::AutoText (the default), the format of the text will try to be determined using the
+ function Qt::mightBeRichText(). If the text format is Qt::PlainText, then the text will be
+ displayed as is, whereas it will be interpreted as HTML if the format is Qt::RichText. HTML tags
+ that alter the font of the text, its color, or its layout are supported by QStaticText.
+
+ \note This function will cause the layout of the text to be recalculated.
+
+ \sa textFormat(), setText(), text()
+*/
+void QStaticText::setTextFormat(Qt::TextFormat textFormat)
+{
+ detach();
+ data->textFormat = textFormat;
+ data->init();
+}
+
+/*!
+ Returns the text format of the QStaticText.
+
+ \sa setTextFormat(), setText(), text()
+*/
+Qt::TextFormat QStaticText::textFormat() const
+{
+ return Qt::TextFormat(data->textFormat);
+}
+
+/*!
+ Returns the text of the QStaticText.
+
+ \sa setText()
+*/
+QString QStaticText::text() const
+{
+ return data->text;
+}
+
+/*!
+ Sets the performance hint of the QStaticText. This hint can be used to customize how much
+ caching is done internally to improve performance.
+
+ The default is QStaticText::ModerateCaching.
+
+ \note This function will cause the layout of the text to be recalculated.
+
+ \sa performanceHint()
+*/
+void QStaticText::setPerformanceHint(PerformanceHint performanceHint)
+{
+ if ((performanceHint == ModerateCaching && !data->useBackendOptimizations)
+ || (performanceHint == AggressiveCaching && data->useBackendOptimizations)) {
+ return;
+ }
+ detach();
+ data->useBackendOptimizations = (performanceHint == AggressiveCaching);
+ data->init();
+}
+
+/*!
+ Returns which performance hint is set for the QStaticText.
+
+ \sa setPerformanceHint()
+*/
+QStaticText::PerformanceHint QStaticText::performanceHint() const
+{
+ return data->useBackendOptimizations ? AggressiveCaching : ModerateCaching;
+}
+
+/*!
+ Sets the maximum size of the QStaticText to \a size.
+
+ \note This function will cause the layout of the text to be recalculated.
+
+ \sa maximumSize(), size()
+*/
+void QStaticText::setMaximumSize(const QSizeF &size)
+{
+ detach();
+ data->maximumSize = size;
+ data->init();
+}
+
+/*!
+ Returns the maximum size of the QStaticText.
+
+ \sa setMaximumSize()
+*/
+QSizeF QStaticText::maximumSize() const
+{
+ return data->maximumSize;
+}
+
+/*!
+ Returns the size of the bounding rect for this QStaticText.
+
+ \sa maximumSize()
+*/
+QSizeF QStaticText::size() const
+{
+ return data->actualSize;
+}
+
+QStaticTextPrivate::QStaticTextPrivate()
+ : items(0), itemCount(0), glyphPool(0), positionPool(0), needsClipRect(false),
+ useBackendOptimizations(false), textFormat(Qt::AutoText)
+{
+ ref = 1;
+}
+
+QStaticTextPrivate::QStaticTextPrivate(const QStaticTextPrivate &other)
+ : text(other.text), font(other.font), maximumSize(other.maximumSize), matrix(other.matrix),
+ items(0), itemCount(0), glyphPool(0), positionPool(0), needsClipRect(false),
+ useBackendOptimizations(false), textFormat(other.textFormat)
+{
+ ref = 1;
+}
+
+QStaticTextPrivate::~QStaticTextPrivate()
+{
+ delete[] items;
+ delete[] glyphPool;
+ delete[] positionPool;
+}
+
+QStaticTextPrivate *QStaticTextPrivate::get(const QStaticText *q)
+{
+ return q->data.data();
+}
+
+extern int qt_defaultDpiX();
+extern int qt_defaultDpiY();
+
+namespace {
+
+ class DrawTextItemRecorder: public QPaintEngine
+ {
+ public:
+ DrawTextItemRecorder(int expectedItemCount, QStaticTextItem *items,
+ int expectedGlyphCount, QFixedPoint *positionPool, glyph_t *glyphPool)
+ : m_items(items),
+ m_itemCount(0), m_glyphCount(0),
+ m_expectedItemCount(expectedItemCount),
+ m_expectedGlyphCount(expectedGlyphCount),
+ m_glyphPool(glyphPool),
+ m_positionPool(positionPool)
+ {
+ }
+
+ virtual void drawTextItem(const QPointF &position, const QTextItem &textItem)
+ {
+ const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
+
+ m_itemCount++;
+ m_glyphCount += ti.glyphs.numGlyphs;
+ if (m_items == 0)
+ return;
+
+ Q_ASSERT(m_itemCount <= m_expectedItemCount);
+ Q_ASSERT(m_glyphCount <= m_expectedGlyphCount);
+
+ QStaticTextItem *currentItem = (m_items + (m_itemCount - 1));
+ currentItem->fontEngine = ti.fontEngine;
+ currentItem->font = ti.font();
+ currentItem->chars = ti.chars;
+ currentItem->numChars = ti.num_chars;
+ currentItem->numGlyphs = ti.glyphs.numGlyphs;
+ currentItem->glyphs = m_glyphPool;
+ currentItem->glyphPositions = m_positionPool;
+ currentItem->color = state->pen().color();
+
+ QTransform matrix = state->transform();
+ matrix.translate(position.x(), position.y());
+
+ QVarLengthArray<glyph_t> glyphs;
+ QVarLengthArray<QFixedPoint> positions;
+ ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
+
+ int size = glyphs.size();
+ Q_ASSERT(size == ti.glyphs.numGlyphs);
+ Q_ASSERT(size == positions.size());
+
+ memmove(currentItem->glyphs, glyphs.constData(), sizeof(glyph_t) * size);
+ memmove(currentItem->glyphPositions, positions.constData(), sizeof(QFixedPoint) * size);
+
+ m_glyphPool += size;
+ m_positionPool += size;
+ }
+
+
+ virtual bool begin(QPaintDevice *) { return true; }
+ virtual bool end() { return true; }
+ virtual void updateState(const QPaintEngineState &) {}
+ virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) {}
+ virtual Type type() const
+ {
+ return User;
+ }
+
+ int itemCount() const
+ {
+ return m_itemCount;
+ }
+
+ int glyphCount() const
+ {
+ return m_glyphCount;
+ }
+
+ private:
+ QStaticTextItem *m_items;
+ int m_itemCount;
+ int m_glyphCount;
+ int m_expectedItemCount;
+ int m_expectedGlyphCount;
+
+ glyph_t *m_glyphPool;
+ QFixedPoint *m_positionPool;
+ };
+
+ class DrawTextItemDevice: public QPaintDevice
+ {
+ public:
+ DrawTextItemDevice(int expectedItemCount = -1, QStaticTextItem *items = 0,
+ int expectedGlyphCount = -1, QFixedPoint *positionPool = 0,
+ glyph_t *glyphPool = 0)
+ {
+ m_paintEngine = new DrawTextItemRecorder(expectedItemCount, items,
+ expectedGlyphCount, positionPool, glyphPool);
+ }
+
+ ~DrawTextItemDevice()
+ {
+ delete m_paintEngine;
+ }
+
+ int metric(PaintDeviceMetric m) const
+ {
+ int val;
+ switch (m) {
+ case PdmWidth:
+ case PdmHeight:
+ case PdmWidthMM:
+ case PdmHeightMM:
+ val = 0;
+ break;
+ case PdmDpiX:
+ case PdmPhysicalDpiX:
+ val = qt_defaultDpiX();
+ break;
+ case PdmDpiY:
+ case PdmPhysicalDpiY:
+ val = qt_defaultDpiY();
+ break;
+ case PdmNumColors:
+ val = 16777216;
+ break;
+ case PdmDepth:
+ val = 24;
+ break;
+ default:
+ val = 0;
+ qWarning("DrawTextItemDevice::metric: Invalid metric command");
+ }
+ return val;
+ }
+
+ virtual QPaintEngine *paintEngine() const
+ {
+ return m_paintEngine;
+ }
+
+ int itemCount() const
+ {
+ return m_paintEngine->itemCount();
+ }
+
+ int glyphCount() const
+ {
+ return m_paintEngine->glyphCount();
+ }
+
+ private:
+ DrawTextItemRecorder *m_paintEngine;
+ };
+}
+
+void QStaticTextPrivate::paintText(const QPointF &pos, QPainter *p)
+{
+ bool preferRichText = textFormat == Qt::RichText
+ || (textFormat == Qt::AutoText && Qt::mightBeRichText(text));
+
+ if (!preferRichText) {
+ if (maximumSize.isValid()) {
+ QRectF boundingRect;
+ p->drawText(QRectF(pos, maximumSize), Qt::TextWordWrap, text, &boundingRect);
+
+ actualSize = boundingRect.size();
+ needsClipRect = boundingRect.width() > maximumSize.width()
+ || boundingRect.height() > maximumSize.height();
+ } else {
+ p->drawText(pos, text);
+ needsClipRect = false;
+
+ QFontMetrics fm(font);
+ actualSize = fm.boundingRect(text).size();
+ }
+ } else {
+ QTextDocument document;
+ document.setDefaultFont(font);
+ document.setHtml(text);
+
+ QRectF rect = maximumSize.isValid() ? QRectF(pos, maximumSize) : QRectF();
+ document.adjustSize();
+ p->save();
+ p->translate(pos);
+ document.drawContents(p, rect);
+ p->restore();
+ actualSize = document.size();
+ needsClipRect = maximumSize.isValid()
+ && (actualSize.width() > maximumSize.width()
+ || actualSize.height() > maximumSize.height());
+ }
+}
+
+void QStaticTextPrivate::init()
+{
+ delete[] items;
+ delete[] glyphPool;
+ delete[] positionPool;
+
+ position = QPointF(0, 0);
+
+ // Draw once to count number of items and glyphs, so that we can use as little memory
+ // as possible to store the data
+ DrawTextItemDevice counterDevice;
+ {
+ QPainter painter(&counterDevice);
+ painter.setFont(font);
+ painter.setTransform(matrix);
+
+ paintText(QPointF(0, 0), &painter);
+
+ }
+
+ itemCount = counterDevice.itemCount();
+ items = new QStaticTextItem[itemCount];
+
+ if (useBackendOptimizations) {
+ for (int i=0; i<itemCount; ++i)
+ items[i].useBackendOptimizations = true;
+ }
+
+
+ int glyphCount = counterDevice.glyphCount();
+ glyphPool = new glyph_t[glyphCount];
+ positionPool = new QFixedPoint[glyphCount];
+
+ // Draw again to actually record the items and glyphs
+ DrawTextItemDevice recorderDevice(itemCount, items, glyphCount, positionPool, glyphPool);
+ {
+ QPainter painter(&recorderDevice);
+ painter.setFont(font);
+ painter.setTransform(matrix);
+
+ paintText(QPointF(0, 0), &painter);
+ }
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h
new file mode 100644
index 0000000..00d42e0
--- /dev/null
+++ b/src/gui/text/qstatictext.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTATICTEXT_H
+#define QSTATICTEXT_H
+
+#include <QtCore/qsize.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qmetatype.h>
+
+#include <QtGui/qtransform.h>
+#include <QtGui/qfont.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QStaticTextPrivate;
+class Q_GUI_EXPORT QStaticText
+{
+public:
+ enum PerformanceHint {
+ ModerateCaching,
+ AggressiveCaching
+ };
+
+ QStaticText();
+ QStaticText(const QString &text, const QSizeF &maximumSize = QSizeF());
+ QStaticText(const QStaticText &other);
+ ~QStaticText();
+
+ void setText(const QString &text);
+ QString text() const;
+
+ void setTextFormat(Qt::TextFormat textFormat);
+ Qt::TextFormat textFormat() const;
+
+ void setMaximumSize(const QSizeF &maximumSize);
+ QSizeF maximumSize() const;
+
+ QSizeF size() const;
+
+ void prepare(const QTransform &matrix, const QFont &font);
+
+ void setPerformanceHint(PerformanceHint performanceHint);
+ PerformanceHint performanceHint() const;
+
+ QStaticText &operator=(const QStaticText &);
+ bool operator==(const QStaticText &) const;
+ bool operator!=(const QStaticText &) const;
+
+private:
+ void detach();
+
+ QExplicitlySharedDataPointer<QStaticTextPrivate> data;
+ friend class QStaticTextPrivate;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QStaticText)
+
+QT_END_HEADER
+
+#endif // QSTATICTEXT_H
diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h
new file mode 100644
index 0000000..e758244
--- /dev/null
+++ b/src/gui/text/qstatictext_p.h
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTATICTEXT_P_H
+#define QSTATICTEXT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of internal files. This header file may change from version to version
+// without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qtextureglyphcache_p.h>
+#include <QtGui/qcolor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QStaticTextUserData
+{
+public:
+ enum Type {
+ NoUserData,
+ OpenGLUserData
+ };
+
+ QStaticTextUserData(Type t) : type(t) {}
+ virtual ~QStaticTextUserData() {}
+
+ Type type;
+};
+
+class Q_GUI_EXPORT QStaticTextItem
+{
+public:
+ QStaticTextItem() : chars(0), numChars(0), fontEngine(0), userData(0),
+ useBackendOptimizations(false), userDataNeedsUpdate(0) {}
+ ~QStaticTextItem() { delete userData; }
+
+ void setUserData(QStaticTextUserData *newUserData)
+ {
+ if (userData == newUserData)
+ return;
+
+ delete userData;
+ userData = newUserData;
+ }
+
+ QFixedPoint *glyphPositions; // 8 bytes per glyph
+ glyph_t *glyphs; // 4 bytes per glyph
+ const QChar *chars; // 2 bytes per glyph
+ // =================
+ // 14 bytes per glyph
+
+ // 12 bytes for pointers
+ int numGlyphs; // 4 bytes per item
+ int numChars; // 4 bytes per item
+ QFontEngine *fontEngine; // 4 bytes per item
+ QFont font; // 8 bytes per item
+ QColor color; // 10 bytes per item
+ QStaticTextUserData *userData; // 8 bytes per item
+ char useBackendOptimizations : 1; // 1 byte per item
+ char userDataNeedsUpdate : 1; //
+ // ================
+ // 51 bytes per item
+};
+
+class QStaticText;
+class Q_AUTOTEST_EXPORT QStaticTextPrivate
+{
+public:
+ QStaticTextPrivate();
+ QStaticTextPrivate(const QStaticTextPrivate &other);
+ ~QStaticTextPrivate();
+
+ void init();
+ void paintText(const QPointF &pos, QPainter *p);
+
+ QAtomicInt ref; // 4 bytes per text
+
+ QString text; // 4 bytes per text
+ QFont font; // 8 bytes per text
+ QSizeF maximumSize; // 16 bytes per text
+ QSizeF actualSize; // 16 bytes per text
+ QPointF position; // 16 bytes per text
+
+ QTransform matrix; // 80 bytes per text
+ QStaticTextItem *items; // 4 bytes per text
+ int itemCount; // 4 bytes per text
+ glyph_t *glyphPool; // 4 bytes per text
+ QFixedPoint *positionPool; // 4 bytes per text
+
+ unsigned char needsClipRect : 1; // 1 byte per text
+ unsigned char useBackendOptimizations : 1;
+ unsigned char textFormat : 2;
+ // ================
+ // 171 bytes per text
+
+ static QStaticTextPrivate *get(const QStaticText *q);
+};
+
+QT_END_NAMESPACE
+
+#endif // QSTATICTEXT_P_H
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index c81d538..c91df3c 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -1145,7 +1145,7 @@ void QTextCursor::setPosition(int pos, MoveMode m)
Returns the absolute position of the cursor within the document.
The cursor is positioned between characters.
- \sa setPosition() movePosition() anchor()
+ \sa setPosition() movePosition() anchor() positionInBlock()
*/
int QTextCursor::position() const
{
@@ -1155,6 +1155,22 @@ int QTextCursor::position() const
}
/*!
+ \since 4.7
+ Returns the relative position of the cursor within the block.
+ The cursor is positioned between characters.
+
+ This is equivalent to \c{ position() - block().position()}.
+
+ \sa position()
+*/
+int QTextCursor::positionInBlock() const
+{
+ if (!d || !d->priv)
+ return 0;
+ return d->position - d->block().position();
+}
+
+/*!
Returns the anchor position; this is the same as position() unless
there is a selection in which case position() marks one end of the
selection and anchor() marks the other end. Just like the cursor
@@ -2414,9 +2430,17 @@ int QTextCursor::blockNumber() const
return d->block().blockNumber();
}
+
/*!
\since 4.2
Returns the position of the cursor within its containing line.
+
+ Note that this is the column number relative to a wrapped line,
+ not relative to the block (i.e. the paragraph).
+
+ You probably want to call positionInBlock() instead.
+
+ \sa positionInBlock()
*/
int QTextCursor::columnNumber() const
{
diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h
index 38bc39d..3e968a3 100644
--- a/src/gui/text/qtextcursor.h
+++ b/src/gui/text/qtextcursor.h
@@ -89,6 +89,7 @@ public:
void setPosition(int pos, MoveMode mode = MoveAnchor);
int position() const;
+ int positionInBlock() const;
int anchor() const;
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index e1cfa9c..9a1b70c 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1774,9 +1774,9 @@ void QTextDocument::print(QPrinter *printer) const
int pageCopies;
if (printer->collateCopies() == true){
docCopies = 1;
- pageCopies = printer->numCopies();
+ pageCopies = printer->supportsMultipleCopies() ? 1 : printer->copyCount();
} else {
- docCopies = printer->numCopies();
+ docCopies = printer->supportsMultipleCopies() ? 1 : printer->copyCount();
pageCopies = 1;
}
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index b7615a4..9ec3142 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -37,7 +37,9 @@ HEADERS += \
text/qtexttable_p.h \
text/qzipreader_p.h \
text/qzipwriter_p.h \
- text/qtextodfwriter_p.h
+ text/qtextodfwriter_p.h \
+ text/qstatictext_p.h \
+ text/qstatictext.h
SOURCES += \
text/qfont.cpp \
@@ -66,7 +68,8 @@ SOURCES += \
text/qsyntaxhighlighter.cpp \
text/qcssparser.cpp \
text/qzip.cpp \
- text/qtextodfwriter.cpp
+ text/qtextodfwriter.cpp \
+ text/qstatictext.cpp
win32 {
SOURCES += \
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
index 319c4b0..65b998f 100644
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ b/src/gui/util/qdesktopservices_s60.cpp
@@ -48,7 +48,6 @@
#include <qurl.h>
#include <private/qcore_symbian_p.h>
-#include <miutset.h> // KUidMsgTypeSMTP
#include <txtrich.h> // CRichText
#include <f32file.h> // TDriveUnit etc
#include <eikenv.h> // CEikonEnv
@@ -57,6 +56,9 @@
#include <rsendas.h> // RSendAs
#include <rsendasmessage.h> // RSendAsMessage
+// copied from miutset.h, so we don't get a dependency into the app layer
+const TUid KUidMsgTypeSMTP = {0x10001028}; // 268439592
+
#ifdef Q_WS_S60
# include <pathinfo.h> // PathInfo
# ifdef USE_DOCUMENTHANDLER
@@ -413,11 +415,11 @@ QString QDesktopServices::storageLocation(StandardLocation type)
//return QDir::homePath(); break;
break;
case DataLocation:
- CEikonEnv::Static()->FsSession().PrivatePath(path);
+ qt_s60GetRFs().PrivatePath(path);
path.Insert(0, writableExeDrive().Name());
break;
case CacheLocation:
- CEikonEnv::Static()->FsSession().PrivatePath(path);
+ qt_s60GetRFs().PrivatePath(path);
path.Insert(0, writableExeDrive().Name());
path.Append(KCacheSubDir);
break;
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index be20a38..f71d250 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -607,7 +607,13 @@ void QComboBoxPrivateContainer::changeEvent(QEvent *e)
view->setMouseTracking(combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) ||
combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo));
setFrameStyle(combo->style()->styleHint(QStyle::SH_ComboBox_PopupFrameStyle, &opt, combo));
+#ifdef QT_SOFTKEYS_ENABLED
+ } else if (e->type() == QEvent::LanguageChange) {
+ selectAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::SelectSoftKey));
+ cancelAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::CancelSoftKey));
+#endif
}
+
QWidget::changeEvent(e);
}
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index 13f31df..2b8cf59 100644
--- a/src/gui/widgets/qdockarealayout.cpp
+++ b/src/gui/widgets/qdockarealayout.cpp
@@ -2637,7 +2637,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
QSize bottom_max = docks[QInternal::BottomDock].maximumSize();
bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min);
- fallbackToSizeHints = !have_central;
+ fallbackToSizeHints = false;
if (_ver_struct_list != 0) {
QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list;
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp
index fdace46..54189de 100644
--- a/src/gui/widgets/qdockwidget.cpp
+++ b/src/gui/widgets/qdockwidget.cpp
@@ -1010,7 +1010,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
if (!floating && parent) {
QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
- if (!mwlayout || mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
+ if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
return; // this dockwidget can't be redocked
}
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index a63f3bf..4620597 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -1427,6 +1427,11 @@ bool QMainWindow::event(QEvent *event)
}
break;
#endif
+#ifdef QT_SOFTKEYS_ENABLED
+ case QEvent::LanguageChange:
+ d->menuBarAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::MenuSoftKey));
+ break;
+#endif
default:
break;
}
diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp
index fc75c92..593e391 100644
--- a/src/gui/widgets/qmainwindowlayout.cpp
+++ b/src/gui/widgets/qmainwindowlayout.cpp
@@ -1772,6 +1772,7 @@ void QMainWindowLayout::setCentralWidget(QWidget *widget)
if (savedState.isValid()) {
#ifndef QT_NO_DOCKWIDGET
savedState.dockAreaLayout.centralWidgetItem = layoutState.dockAreaLayout.centralWidgetItem;
+ savedState.dockAreaLayout.fallbackToSizeHints = true;
#else
savedState.centralWidgetItem = layoutState.centralWidgetItem;
#endif
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 08960da..e2cf25b 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -117,7 +117,7 @@ public:
if (parentWidget->parentWidget())
parentWidget = parentWidget->parentWidget();
setParent(parentWidget, Qt::Window | Qt::Tool);
- setAttribute(Qt::WA_DeleteOnClose, true);
+ setAttribute(Qt::WA_DeleteOnClose, true);
setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true);
setWindowTitle(p->windowTitle());
setEnabled(p->isEnabled());
@@ -1226,7 +1226,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
else if (action->isSeparator())
option->menuItemType = QStyleOptionMenuItem::Separator;
else if (d->defaultAction == action)
- option->menuItemType = QStyleOptionMenuItem::DefaultItem;
+ option->menuItemType = QStyleOptionMenuItem::DefaultItem;
else
option->menuItemType = QStyleOptionMenuItem::Normal;
if (action->isIconVisibleInMenu())
@@ -1719,7 +1719,14 @@ bool QMenu::isEmpty() const
void QMenu::clear()
{
QList<QAction*> acts = actions();
+
for(int i = 0; i < acts.size(); i++) {
+#ifdef QT_SOFTKEYS_ENABLED
+ Q_D(QMenu);
+ // Lets not touch to our internal softkey actions
+ if(acts[i] == d->selectAction || acts[i] == d->cancelAction)
+ continue;
+#endif
removeAction(acts[i]);
if (acts[i]->parent() == this && acts[i]->d_func()->widgets.isEmpty())
delete acts[i];
@@ -2406,6 +2413,13 @@ QMenu::event(QEvent *e)
}
return true;
#endif
+#ifdef QT_SOFTKEYS_ENABLED
+ case QEvent::LanguageChange: {
+ d->selectAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::SelectSoftKey));
+ d->cancelAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::CancelSoftKey));
+ }
+ break;
+#endif
default:
break;
}
@@ -2917,7 +2931,7 @@ void QMenu::actionEvent(QActionEvent *e)
#endif
if (isVisible()) {
d->updateActionRects();
- resize(sizeHint());
+ resize(sizeHint());
update();
}
}
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 0d798b7..ef9fac3 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -1320,6 +1320,26 @@ QTextCursor QPlainTextEdit::textCursor() const
return d->control->textCursor();
}
+/*!
+ Returns the reference of the anchor at position \a pos, or an
+ empty string if no anchor exists at that point.
+
+ \since 4.7
+ */
+QString QPlainTextEdit::anchorAt(const QPoint &pos) const
+{
+ Q_D(const QPlainTextEdit);
+ int cursorPos = d->control->hitTest(pos + QPoint(d->horizontalOffset(),
+ d->verticalOffset()),
+ Qt::ExactHit);
+ if (cursorPos < 0)
+ return QString();
+
+ QTextDocumentPrivate *pieceTable = document()->docHandle();
+ QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos);
+ QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format);
+ return fmt.anchorHref();
+}
/*!
Undoes the last operation.
diff --git a/src/gui/widgets/qplaintextedit.h b/src/gui/widgets/qplaintextedit.h
index 15cf0967..106ae6d 100644
--- a/src/gui/widgets/qplaintextedit.h
+++ b/src/gui/widgets/qplaintextedit.h
@@ -159,6 +159,8 @@ public:
QRect cursorRect(const QTextCursor &cursor) const;
QRect cursorRect() const;
+ QString anchorAt(const QPoint &pos) const;
+
bool overwriteMode() const;
void setOverwriteMode(bool overwrite);