summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmap_x11.cpp
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-17 11:36:40 +0200
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-17 11:44:48 +0200
commitfa8030a935acaacee570eee320e7510a4cfdc853 (patch)
tree51d48d56c94739aa569bb60f5ef6998da35ff110 /src/gui/image/qpixmap_x11.cpp
parent24580f35a58390b4177aef8edef1192dc05f8ac2 (diff)
Speed up QPixmap::width(), height(), isNull() and depth().
This change moves the w, h, d variables to QPixmapData and introduces is_null to keep track of nullness. This is possible only because QPixmapData is internal API; otherwise we'd have to be smarter. The optimization makes the QPixmap::width() function take 7 instructions, down from 34 before. For the calculator demo in the declarative ui branch this reduces a block of 750000 instructions (out of 30000000) to around 100000-150000 instructions. Tested on Windows, Linux, Mac. Raster, X11 and OpenGL paint engines. Have not tested the DirectFB engine. Reviewed-by: Trond
Diffstat (limited to 'src/gui/image/qpixmap_x11.cpp')
-rw-r--r--src/gui/image/qpixmap_x11.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index b7fe92aa38..86cf515da7 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -312,7 +312,7 @@ static int qt_pixmap_serial = 0;
int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0;
QX11PixmapData::QX11PixmapData(PixelType type)
- : QPixmapData(type, X11Class), hd(0), w(0), h(0), d(0),
+ : QPixmapData(type, X11Class), hd(0),
uninit(true), read_only(false), x11_mask(0), picture(0), mask_picture(0), hd2(0),
share_mode(QPixmap::ImplicitlyShared), pengine(0)
{
@@ -324,6 +324,7 @@ void QX11PixmapData::resize(int width, int height)
w = width;
h = height;
+ is_null = (w <= 0 || h <= 0);
if (defaultScreen >= 0 && defaultScreen != xinfo.screen()) {
QX11InfoData* xd = xinfo.getX11Data(true);
@@ -347,6 +348,7 @@ void QX11PixmapData::resize(int width, int height)
if (make_null || d == 0) {
w = 0;
h = 0;
+ is_null = true;
hd = 0;
picture = 0;
d = 0;
@@ -375,6 +377,7 @@ void QX11PixmapData::fromImage(const QImage &img,
w = img.width();
h = img.height();
d = img.depth();
+ is_null = (w <= 0 || h <= 0);
if (defaultScreen >= 0 && defaultScreen != xinfo.screen()) {
QX11InfoData* xd = xinfo.getX11Data(true);
@@ -395,6 +398,7 @@ void QX11PixmapData::fromImage(const QImage &img,
if (uint(w) >= 32768 || uint(h) >= 32768) {
w = h = 0;
+ is_null = true;
return;
}
@@ -1109,6 +1113,7 @@ void QX11PixmapData::bitmapFromImage(const QImage &image)
w = img.width();
h = img.height();
d = 1;
+ is_null = (w <= 0 || h <= 0);
int bpl = (w + 7) / 8;
int ibpl = img.bytesPerLine();
if (bpl != ibpl) {
@@ -1876,6 +1881,7 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
x11Data->d = d;
x11Data->w = w;
x11Data->h = h;
+ x11Data->is_null = (w <= 0 || h <= 0);
x11Data->hd = (Qt::HANDLE)XCreatePixmap(X11->display,
RootWindow(X11->display, xinfo.screen()),
w, h, d);
@@ -2132,6 +2138,7 @@ void QX11PixmapData::copy(const QPixmapData *data, const QRect &rect)
d = x11Data->d;
w = rect.width();
h = rect.height();
+ is_null = (w <= 0 || h <= 0);
hd = (Qt::HANDLE)XCreatePixmap(X11->display,
RootWindow(X11->display, x11Data->xinfo.screen()),
w, h, d);
@@ -2250,6 +2257,7 @@ QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap, QPixmap::ShareMode mode)
data->uninit = false;
data->w = width;
data->h = height;
+ data->is_null = (width <= 0 || height <= 0);
data->d = depth;
data->hd = pixmap;