summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmapdata_p.h
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-17 09:36:40 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-17 09:44:48 (GMT)
commitfa8030a935acaacee570eee320e7510a4cfdc853 (patch)
tree51d48d56c94739aa569bb60f5ef6998da35ff110 /src/gui/image/qpixmapdata_p.h
parent24580f35a58390b4177aef8edef1192dc05f8ac2 (diff)
downloadQt-fa8030a935acaacee570eee320e7510a4cfdc853.zip
Qt-fa8030a935acaacee570eee320e7510a4cfdc853.tar.gz
Qt-fa8030a935acaacee570eee320e7510a4cfdc853.tar.bz2
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/qpixmapdata_p.h')
-rw-r--r--src/gui/image/qpixmapdata_p.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h
index 4c49dd2..29dafaf 100644
--- a/src/gui/image/qpixmapdata_p.h
+++ b/src/gui/image/qpixmapdata_p.h
@@ -99,13 +99,18 @@ public:
virtual QImage* buffer();
- int width() const { return metric(QPaintDevice::PdmWidth); }
- int height() const { return metric(QPaintDevice::PdmHeight); }
- int numColors() const { return metric(QPaintDevice::PdmNumColors); }
- int depth() const { return metric(QPaintDevice::PdmDepth); }
+ inline int width() const { return w; }
+ inline int height() const { return h; }
+ inline int numColors() const { return metric(QPaintDevice::PdmNumColors); }
+ inline int depth() const { return d; }
+ inline bool isNull() const { return is_null; }
protected:
void setSerialNumber(int serNo);
+ int w;
+ int h;
+ int d;
+ bool is_null;
private:
friend class QPixmap;