summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-11-08 11:44:57 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-11-13 20:43:27 +0000
commit26e66694fad4f3ec1afba2f2c1de3c66c6d3d7ac (patch)
treee859a7400ed310a85672195e8c8ba5647b836162 /src
parentc1da13f6db756a9b23c46193304156c5e10f3bc1 (diff)
QFontEngineFT: Minor optimization to convertGRAYToARGB()
Precalculate everything we can and use faster loop. Make inlined as it is used just in a single place. Change-Id: If3c33d60739eb4ce896020321442ae81edd1c13d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qfontengine_ft.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 0d28785aa1..162f409acd 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -590,13 +590,16 @@ static void convertRGBToARGB_V(const uchar *src, uint *dst, int width, int heigh
}
}
-static void convertGRAYToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch) {
- for (int y = 0; y < height; ++y) {
- int readpos = (y * src_pitch);
- int writepos = (y * width);
- for (int x = 0; x < width; ++x) {
- dst[writepos + x] = (0xFF << 24) + (src[readpos + x] << 16) + (src[readpos + x] << 8) + src[readpos + x];
+static inline void convertGRAYToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch)
+{
+ while (height--) {
+ const uchar *p = src;
+ const uchar * const e = p + width;
+ while (p < e) {
+ uchar gray = *p++;
+ *dst++ = (0xFF << 24) | (gray << 16) | (gray << 8) | gray;
}
+ src += src_pitch;
}
}