painting/qtextureglyphcache.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include <qmath.h> -
43 -
44#include "qtextureglyphcache_p.h" -
45#include "private/qfontengine_p.h" -
46#include "private/qnumeric_p.h" -
47#include "private/qnativeimage_p.h" -
48 -
49QT_BEGIN_NAMESPACE -
50 -
51// #define CACHE_DEBUG -
52 -
53// returns the highest number closest to v, which is a power of 2 -
54// NB! assumes 32 bit ints -
55static inline int qt_next_power_of_two(int v) -
56{ -
57 v--;
executed (the execution status of this line is deduced): v--;
-
58 v |= v >> 1;
executed (the execution status of this line is deduced): v |= v >> 1;
-
59 v |= v >> 2;
executed (the execution status of this line is deduced): v |= v >> 2;
-
60 v |= v >> 4;
executed (the execution status of this line is deduced): v |= v >> 4;
-
61 v |= v >> 8;
executed (the execution status of this line is deduced): v |= v >> 8;
-
62 v |= v >> 16;
executed (the execution status of this line is deduced): v |= v >> 16;
-
63 ++v;
executed (the execution status of this line is deduced): ++v;
-
64 return v;
executed: return v;
Execution Count:2
2
65} -
66 -
67int QTextureGlyphCache::calculateSubPixelPositionCount(glyph_t glyph) const -
68{ -
69 // Test 12 different subpixel positions since it factors into 3*4 so it gives -
70 // the coverage we need. -
71 -
72 QList<QImage> images;
never executed (the execution status of this line is deduced): QList<QImage> images;
-
73 for (int i=0; i<12; ++i) {
never evaluated: i<12
0
74 QImage img = textureMapForGlyph(glyph, QFixed::fromReal(i / 12.0));
never executed (the execution status of this line is deduced): QImage img = textureMapForGlyph(glyph, QFixed::fromReal(i / 12.0));
-
75 -
76 if (images.isEmpty()) {
never evaluated: images.isEmpty()
0
77 QPainterPath path;
never executed (the execution status of this line is deduced): QPainterPath path;
-
78 QFixedPoint point;
never executed (the execution status of this line is deduced): QFixedPoint point;
-
79 m_current_fontengine->addGlyphsToPath(&glyph, &point, 1, &path, QTextItem::RenderFlags());
never executed (the execution status of this line is deduced): m_current_fontengine->addGlyphsToPath(&glyph, &point, 1, &path, QTextItem::RenderFlags());
-
80 -
81 // Glyph is space, return 0 to indicate that we need to keep trying -
82 if (path.isEmpty())
never evaluated: path.isEmpty()
0
83 break;
never executed: break;
0
84 -
85 images.append(img);
never executed (the execution status of this line is deduced): images.append(img);
-
86 } else {
never executed: }
0
87 bool found = false;
never executed (the execution status of this line is deduced): bool found = false;
-
88 for (int j=0; j<images.size(); ++j) {
never evaluated: j<images.size()
0
89 if (images.at(j) == img) {
never evaluated: images.at(j) == img
0
90 found = true;
never executed (the execution status of this line is deduced): found = true;
-
91 break;
never executed: break;
0
92 } -
93 }
never executed: }
0
94 if (!found)
never evaluated: !found
0
95 images.append(img);
never executed: images.append(img);
0
96 }
never executed: }
0
97 } -
98 -
99 return images.size();
never executed: return images.size();
0
100} -
101 -
102bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const glyph_t *glyphs, -
103 const QFixedPoint *positions) -
104{ -
105#ifdef CACHE_DEBUG -
106 printf("Populating with %d glyphs\n", numGlyphs); -
107 qDebug() << " -> current transformation: " << m_transform; -
108#endif -
109 -
110 m_current_fontengine = fontEngine;
executed (the execution status of this line is deduced): m_current_fontengine = fontEngine;
-
111 const int margin = m_current_fontengine->glyphMargin(m_type);
executed (the execution status of this line is deduced): const int margin = m_current_fontengine->glyphMargin(m_type);
-
112 const int paddingDoubled = glyphPadding() * 2;
executed (the execution status of this line is deduced): const int paddingDoubled = glyphPadding() * 2;
-
113 -
114 bool supportsSubPixelPositions = fontEngine->supportsSubPixelPositions();
executed (the execution status of this line is deduced): bool supportsSubPixelPositions = fontEngine->supportsSubPixelPositions();
-
115 if (fontEngine->m_subPixelPositionCount == 0) {
evaluated: fontEngine->m_subPixelPositionCount == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
116 if (!supportsSubPixelPositions) {
partially evaluated: !supportsSubPixelPositions
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
117 fontEngine->m_subPixelPositionCount = 1;
executed (the execution status of this line is deduced): fontEngine->m_subPixelPositionCount = 1;
-
118 } else {
executed: }
Execution Count:1
1
119 int i = 0;
never executed (the execution status of this line is deduced): int i = 0;
-
120 while (fontEngine->m_subPixelPositionCount == 0 && i < numGlyphs)
never evaluated: fontEngine->m_subPixelPositionCount == 0
never evaluated: i < numGlyphs
0
121 fontEngine->m_subPixelPositionCount = calculateSubPixelPositionCount(glyphs[i++]);
never executed: fontEngine->m_subPixelPositionCount = calculateSubPixelPositionCount(glyphs[i++]);
0
122 }
never executed: }
0
123 } -
124 -
125 QHash<GlyphAndSubPixelPosition, Coord> listItemCoordinates;
executed (the execution status of this line is deduced): QHash<GlyphAndSubPixelPosition, Coord> listItemCoordinates;
-
126 int rowHeight = 0;
executed (the execution status of this line is deduced): int rowHeight = 0;
-
127 -
128 QFontEngine::GlyphFormat format;
executed (the execution status of this line is deduced): QFontEngine::GlyphFormat format;
-
129 switch (m_type) { -
130 case Raster_A8: format = QFontEngine::Format_A8; break;
executed: break;
Execution Count:8
8
131 case Raster_RGBMask: format = QFontEngine::Format_A32; break;
never executed: break;
0
132 default: format = QFontEngine::Format_Mono; break;
never executed: break;
0
133 } -
134 -
135 // check each glyph for its metrics and get the required rowHeight. -
136 for (int i=0; i < numGlyphs; ++i) {
evaluated: i < numGlyphs
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:8
8-24
137 const glyph_t glyph = glyphs[i];
executed (the execution status of this line is deduced): const glyph_t glyph = glyphs[i];
-
138 -
139 QFixed subPixelPosition;
executed (the execution status of this line is deduced): QFixed subPixelPosition;
-
140 if (supportsSubPixelPositions) {
partially evaluated: supportsSubPixelPositions
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
141 QFixed x = positions != 0 ? positions[i].x : QFixed();
never evaluated: positions != 0
0
142 subPixelPosition = fontEngine->subPixelPositionForX(x);
never executed (the execution status of this line is deduced): subPixelPosition = fontEngine->subPixelPositionForX(x);
-
143 }
never executed: }
0
144 -
145 if (coords.contains(GlyphAndSubPixelPosition(glyph, subPixelPosition)))
evaluated: coords.contains(GlyphAndSubPixelPosition(glyph, subPixelPosition))
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:3
3-21
146 continue;
executed: continue;
Execution Count:21
21
147 if (listItemCoordinates.contains(GlyphAndSubPixelPosition(glyph, subPixelPosition)))
evaluated: listItemCoordinates.contains(GlyphAndSubPixelPosition(glyph, subPixelPosition))
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
148 continue;
executed: continue;
Execution Count:2
2
149 glyph_metrics_t metrics = fontEngine->alphaMapBoundingBox(glyph, subPixelPosition, m_transform, format);
executed (the execution status of this line is deduced): glyph_metrics_t metrics = fontEngine->alphaMapBoundingBox(glyph, subPixelPosition, m_transform, format);
-
150 -
151#ifdef CACHE_DEBUG -
152 printf("(%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f\n", -
153 glyph, -
154 metrics.width.toReal(), -
155 metrics.height.toReal(), -
156 metrics.xoff.toReal(), -
157 metrics.yoff.toReal(), -
158 metrics.x.toReal(), -
159 metrics.y.toReal()); -
160#endif -
161 GlyphAndSubPixelPosition key(glyph, subPixelPosition);
executed (the execution status of this line is deduced): GlyphAndSubPixelPosition key(glyph, subPixelPosition);
-
162 int glyph_width = metrics.width.ceil().toInt();
executed (the execution status of this line is deduced): int glyph_width = metrics.width.ceil().toInt();
-
163 int glyph_height = metrics.height.ceil().toInt();
executed (the execution status of this line is deduced): int glyph_height = metrics.height.ceil().toInt();
-
164 if (glyph_height == 0 || glyph_width == 0) {
partially evaluated: glyph_height == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: glyph_width == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
165 // Avoid multiple calls to boundingBox() for non-printable characters -
166 Coord c = { 0, 0, 0, 0, 0, 0 };
never executed (the execution status of this line is deduced): Coord c = { 0, 0, 0, 0, 0, 0 };
-
167 coords.insert(key, c);
never executed (the execution status of this line is deduced): coords.insert(key, c);
-
168 continue;
never executed: continue;
0
169 } -
170 glyph_width += margin * 2 + 4;
executed (the execution status of this line is deduced): glyph_width += margin * 2 + 4;
-
171 glyph_height += margin * 2 + 4;
executed (the execution status of this line is deduced): glyph_height += margin * 2 + 4;
-
172 // align to 8-bit boundary -
173 if (m_type == QFontEngineGlyphCache::Raster_Mono)
partially evaluated: m_type == QFontEngineGlyphCache::Raster_Mono
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
174 glyph_width = (glyph_width+7)&~7;
never executed: glyph_width = (glyph_width+7)&~7;
0
175 -
176 Coord c = { 0, 0, // will be filled in later
executed (the execution status of this line is deduced): Coord c = { 0, 0,
-
177 glyph_width,
executed (the execution status of this line is deduced): glyph_width,
-
178 glyph_height, // texture coords
executed (the execution status of this line is deduced): glyph_height,
-
179 metrics.x.truncate(),
executed (the execution status of this line is deduced): metrics.x.truncate(),
-
180 -metrics.y.truncate() }; // baseline for horizontal scripts
executed (the execution status of this line is deduced): -metrics.y.truncate() };
-
181 -
182 listItemCoordinates.insert(key, c);
executed (the execution status of this line is deduced): listItemCoordinates.insert(key, c);
-
183 rowHeight = qMax(rowHeight, glyph_height);
executed (the execution status of this line is deduced): rowHeight = qMax(rowHeight, glyph_height);
-
184 }
executed: }
Execution Count:1
1
185 if (listItemCoordinates.isEmpty())
evaluated: listItemCoordinates.isEmpty()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:1
1-7
186 return true;
executed: return true;
Execution Count:7
7
187 -
188 rowHeight += margin * 2 + paddingDoubled;
executed (the execution status of this line is deduced): rowHeight += margin * 2 + paddingDoubled;
-
189 -
190 if (m_w == 0) {
partially evaluated: m_w == 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
191 if (fontEngine->maxCharWidth() <= QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH)
partially evaluated: fontEngine->maxCharWidth() <= 256
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
192 m_w = QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH;
executed: m_w = 256;
Execution Count:1
1
193 else -
194 m_w = qt_next_power_of_two(fontEngine->maxCharWidth());
never executed: m_w = qt_next_power_of_two(fontEngine->maxCharWidth());
0
195 } -
196 -
197 // now actually use the coords and paint the wanted glyps into cache. -
198 QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = listItemCoordinates.begin();
executed (the execution status of this line is deduced): QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = listItemCoordinates.begin();
-
199 int requiredWidth = m_w;
executed (the execution status of this line is deduced): int requiredWidth = m_w;
-
200 while (iter != listItemCoordinates.end()) {
evaluated: iter != listItemCoordinates.end()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
201 Coord c = iter.value();
executed (the execution status of this line is deduced): Coord c = iter.value();
-
202 -
203 m_currentRowHeight = qMax(m_currentRowHeight, c.h + margin * 2);
executed (the execution status of this line is deduced): m_currentRowHeight = qMax(m_currentRowHeight, c.h + margin * 2);
-
204 -
205 if (m_cx + c.w > requiredWidth) {
partially evaluated: m_cx + c.w > requiredWidth
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
206 int new_width = requiredWidth*2;
never executed (the execution status of this line is deduced): int new_width = requiredWidth*2;
-
207 while (new_width < m_cx + c.w)
never evaluated: new_width < m_cx + c.w
0
208 new_width *= 2;
never executed: new_width *= 2;
0
209 if (new_width <= maxTextureWidth()) {
never evaluated: new_width <= maxTextureWidth()
0
210 requiredWidth = new_width;
never executed (the execution status of this line is deduced): requiredWidth = new_width;
-
211 } else {
never executed: }
0
212 // no room on the current line, start new glyph strip -
213 m_cx = 0;
never executed (the execution status of this line is deduced): m_cx = 0;
-
214 m_cy += m_currentRowHeight + paddingDoubled;
never executed (the execution status of this line is deduced): m_cy += m_currentRowHeight + paddingDoubled;
-
215 m_currentRowHeight = c.h + margin * 2; // New row
never executed (the execution status of this line is deduced): m_currentRowHeight = c.h + margin * 2;
-
216 }
never executed: }
0
217 } -
218 -
219 if (maxTextureHeight() > 0 && m_cy + c.h > maxTextureHeight()) {
partially evaluated: maxTextureHeight() > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: m_cy + c.h > maxTextureHeight()
0-1
220 // We can't make a cache of the required size, so we bail out -
221 return false;
never executed: return false;
0
222 } -
223 -
224 c.x = m_cx;
executed (the execution status of this line is deduced): c.x = m_cx;
-
225 c.y = m_cy;
executed (the execution status of this line is deduced): c.y = m_cy;
-
226 -
227 coords.insert(iter.key(), c);
executed (the execution status of this line is deduced): coords.insert(iter.key(), c);
-
228 m_pendingGlyphs.insert(iter.key(), c);
executed (the execution status of this line is deduced): m_pendingGlyphs.insert(iter.key(), c);
-
229 -
230 m_cx += c.w + paddingDoubled;
executed (the execution status of this line is deduced): m_cx += c.w + paddingDoubled;
-
231 ++iter;
executed (the execution status of this line is deduced): ++iter;
-
232 }
executed: }
Execution Count:1
1
233 return true;
executed: return true;
Execution Count:1
1
234 -
235} -
236 -
237void QTextureGlyphCache::fillInPendingGlyphs() -
238{ -
239 if (m_pendingGlyphs.isEmpty())
evaluated: m_pendingGlyphs.isEmpty()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:1
1-7
240 return;
executed: return;
Execution Count:7
7
241 -
242 int requiredHeight = m_h;
executed (the execution status of this line is deduced): int requiredHeight = m_h;
-
243 int requiredWidth = m_w; // Use a minimum size to avoid a lot of initial reallocations
executed (the execution status of this line is deduced): int requiredWidth = m_w;
-
244 { -
245 QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin();
executed (the execution status of this line is deduced): QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin();
-
246 while (iter != m_pendingGlyphs.end()) {
evaluated: iter != m_pendingGlyphs.end()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
247 Coord c = iter.value();
executed (the execution status of this line is deduced): Coord c = iter.value();
-
248 requiredHeight = qMax(requiredHeight, c.y + c.h);
executed (the execution status of this line is deduced): requiredHeight = qMax(requiredHeight, c.y + c.h);
-
249 requiredWidth = qMax(requiredWidth, c.x + c.w);
executed (the execution status of this line is deduced): requiredWidth = qMax(requiredWidth, c.x + c.w);
-
250 ++iter;
executed (the execution status of this line is deduced): ++iter;
-
251 }
executed: }
Execution Count:1
1
252 } -
253 -
254 if (isNull() || requiredHeight > m_h || requiredWidth > m_w) {
partially evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
never evaluated: requiredHeight > m_h
never evaluated: requiredWidth > m_w
0-1
255 if (isNull())
partially evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
256 createCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight));
executed: createCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight));
Execution Count:1
1
257 else -
258 resizeCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight));
never executed: resizeCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight));
0
259 } -
260 -
261 { -
262 QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin();
executed (the execution status of this line is deduced): QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin();
-
263 while (iter != m_pendingGlyphs.end()) {
evaluated: iter != m_pendingGlyphs.end()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
264 GlyphAndSubPixelPosition key = iter.key();
executed (the execution status of this line is deduced): GlyphAndSubPixelPosition key = iter.key();
-
265 fillTexture(iter.value(), key.glyph, key.subPixelPosition);
executed (the execution status of this line is deduced): fillTexture(iter.value(), key.glyph, key.subPixelPosition);
-
266 -
267 ++iter;
executed (the execution status of this line is deduced): ++iter;
-
268 }
executed: }
Execution Count:1
1
269 } -
270 -
271 m_pendingGlyphs.clear();
executed (the execution status of this line is deduced): m_pendingGlyphs.clear();
-
272}
executed: }
Execution Count:1
1
273 -
274QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g, QFixed subPixelPosition) const -
275{ -
276 if (m_type == QFontEngineGlyphCache::Raster_RGBMask)
partially evaluated: m_type == QFontEngineGlyphCache::Raster_RGBMask
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
277 return m_current_fontengine->alphaRGBMapForGlyph(g, subPixelPosition, m_transform);
never executed: return m_current_fontengine->alphaRGBMapForGlyph(g, subPixelPosition, m_transform);
0
278 return m_current_fontengine->alphaMapForGlyph(g, subPixelPosition, m_transform);
executed: return m_current_fontengine->alphaMapForGlyph(g, subPixelPosition, m_transform);
Execution Count:1
1
279} -
280 -
281/************************************************************************ -
282 * QImageTextureGlyphCache -
283 */ -
284 -
285void QImageTextureGlyphCache::resizeTextureData(int width, int height) -
286{ -
287 m_image = m_image.copy(0, 0, width, height);
never executed (the execution status of this line is deduced): m_image = m_image.copy(0, 0, width, height);
-
288}
never executed: }
0
289 -
290void QImageTextureGlyphCache::createTextureData(int width, int height) -
291{ -
292 switch (m_type) { -
293 case QFontEngineGlyphCache::Raster_Mono: -
294 m_image = QImage(width, height, QImage::Format_Mono);
never executed (the execution status of this line is deduced): m_image = QImage(width, height, QImage::Format_Mono);
-
295 break;
never executed: break;
0
296 case QFontEngineGlyphCache::Raster_A8: { -
297 m_image = QImage(width, height, QImage::Format_Indexed8);
executed (the execution status of this line is deduced): m_image = QImage(width, height, QImage::Format_Indexed8);
-
298 m_image.fill(0);
executed (the execution status of this line is deduced): m_image.fill(0);
-
299 QVector<QRgb> colors(256);
executed (the execution status of this line is deduced): QVector<QRgb> colors(256);
-
300 QRgb *it = colors.data();
executed (the execution status of this line is deduced): QRgb *it = colors.data();
-
301 for (int i=0; i<256; ++i, ++it)
evaluated: i<256
TRUEFALSE
yes
Evaluation Count:256
yes
Evaluation Count:1
1-256
302 *it = 0xff000000 | i | (i<<8) | (i<<16);
executed: *it = 0xff000000 | i | (i<<8) | (i<<16);
Execution Count:256
256
303 m_image.setColorTable(colors);
executed (the execution status of this line is deduced): m_image.setColorTable(colors);
-
304 break; }
executed: break;
Execution Count:1
1
305 case QFontEngineGlyphCache::Raster_RGBMask: -
306 m_image = QImage(width, height, QImage::Format_RGB32);
never executed (the execution status of this line is deduced): m_image = QImage(width, height, QImage::Format_RGB32);
-
307 break;
never executed: break;
0
308 case QFontEngineGlyphCache::Raster_ARGB: -
309 break;
never executed: break;
0
310 } -
311}
executed: }
Execution Count:1
1
312 -
313void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subPixelPosition) -
314{ -
315 QImage mask = textureMapForGlyph(g, subPixelPosition);
executed (the execution status of this line is deduced): QImage mask = textureMapForGlyph(g, subPixelPosition);
-
316 -
317#ifdef CACHE_DEBUG -
318 printf("fillTexture of %dx%d at %d,%d in the cache of %dx%d\n", c.w, c.h, c.x, c.y, m_image.width(), m_image.height()); -
319 if (mask.width() > c.w || mask.height() > c.h) { -
320 printf(" ERROR; mask is bigger than reserved space! %dx%d instead of %dx%d\n", mask.width(), mask.height(), c.w,c.h); -
321 return; -
322 } -
323#endif -
324 -
325 if (m_type == QFontEngineGlyphCache::Raster_RGBMask) {
partially evaluated: m_type == QFontEngineGlyphCache::Raster_RGBMask
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
326 QImage ref(m_image.bits() + (c.x * 4 + c.y * m_image.bytesPerLine()),
never executed (the execution status of this line is deduced): QImage ref(m_image.bits() + (c.x * 4 + c.y * m_image.bytesPerLine()),
-
327 qMax(mask.width(), c.w), qMax(mask.height(), c.h), m_image.bytesPerLine(),
never executed (the execution status of this line is deduced): qMax(mask.width(), c.w), qMax(mask.height(), c.h), m_image.bytesPerLine(),
-
328 m_image.format());
never executed (the execution status of this line is deduced): m_image.format());
-
329 QPainter p(&ref);
never executed (the execution status of this line is deduced): QPainter p(&ref);
-
330 p.setCompositionMode(QPainter::CompositionMode_Source);
never executed (the execution status of this line is deduced): p.setCompositionMode(QPainter::CompositionMode_Source);
-
331 p.fillRect(0, 0, c.w, c.h, QColor(0,0,0,0)); // TODO optimize this
never executed (the execution status of this line is deduced): p.fillRect(0, 0, c.w, c.h, QColor(0,0,0,0));
-
332 p.drawImage(0, 0, mask);
never executed (the execution status of this line is deduced): p.drawImage(0, 0, mask);
-
333 p.end();
never executed (the execution status of this line is deduced): p.end();
-
334 } else if (m_type == QFontEngineGlyphCache::Raster_Mono) {
never executed: }
partially evaluated: m_type == QFontEngineGlyphCache::Raster_Mono
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
335 if (mask.depth() > 1) {
never evaluated: mask.depth() > 1
0
336 // TODO optimize this -
337 mask = mask.alphaChannel();
never executed (the execution status of this line is deduced): mask = mask.alphaChannel();
-
338 mask.invertPixels();
never executed (the execution status of this line is deduced): mask.invertPixels();
-
339 mask = mask.convertToFormat(QImage::Format_Mono);
never executed (the execution status of this line is deduced): mask = mask.convertToFormat(QImage::Format_Mono);
-
340 }
never executed: }
0
341 -
342 int mw = qMin(mask.width(), c.w);
never executed (the execution status of this line is deduced): int mw = qMin(mask.width(), c.w);
-
343 int mh = qMin(mask.height(), c.h);
never executed (the execution status of this line is deduced): int mh = qMin(mask.height(), c.h);
-
344 uchar *d = m_image.bits();
never executed (the execution status of this line is deduced): uchar *d = m_image.bits();
-
345 int dbpl = m_image.bytesPerLine();
never executed (the execution status of this line is deduced): int dbpl = m_image.bytesPerLine();
-
346 -
347 for (int y = 0; y < c.h; ++y) {
never evaluated: y < c.h
0
348 uchar *dest = d + (c.y + y) *dbpl + c.x/8;
never executed (the execution status of this line is deduced): uchar *dest = d + (c.y + y) *dbpl + c.x/8;
-
349 -
350 if (y < mh) {
never evaluated: y < mh
0
351 uchar *src = mask.scanLine(y);
never executed (the execution status of this line is deduced): uchar *src = mask.scanLine(y);
-
352 for (int x = 0; x < c.w/8; ++x) {
never evaluated: x < c.w/8
0
353 if (x < (mw+7)/8)
never evaluated: x < (mw+7)/8
0
354 dest[x] = src[x];
never executed: dest[x] = src[x];
0
355 else -
356 dest[x] = 0;
never executed: dest[x] = 0;
0
357 } -
358 } else {
never executed: }
0
359 for (int x = 0; x < c.w/8; ++x)
never evaluated: x < c.w/8
0
360 dest[x] = 0;
never executed: dest[x] = 0;
0
361 }
never executed: }
0
362 } -
363 } else { // A8
never executed: }
0
364 int mw = qMin(mask.width(), c.w);
executed (the execution status of this line is deduced): int mw = qMin(mask.width(), c.w);
-
365 int mh = qMin(mask.height(), c.h);
executed (the execution status of this line is deduced): int mh = qMin(mask.height(), c.h);
-
366 uchar *d = m_image.bits();
executed (the execution status of this line is deduced): uchar *d = m_image.bits();
-
367 int dbpl = m_image.bytesPerLine();
executed (the execution status of this line is deduced): int dbpl = m_image.bytesPerLine();
-
368 -
369 if (mask.depth() == 1) {
partially evaluated: mask.depth() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
370 for (int y = 0; y < c.h; ++y) {
never evaluated: y < c.h
0
371 uchar *dest = d + (c.y + y) *dbpl + c.x;
never executed (the execution status of this line is deduced): uchar *dest = d + (c.y + y) *dbpl + c.x;
-
372 if (y < mh) {
never evaluated: y < mh
0
373 uchar *src = (uchar *) mask.scanLine(y);
never executed (the execution status of this line is deduced): uchar *src = (uchar *) mask.scanLine(y);
-
374 for (int x = 0; x < c.w; ++x) {
never evaluated: x < c.w
0
375 if (x < mw)
never evaluated: x < mw
0
376 dest[x] = (src[x >> 3] & (1 << (7 - (x & 7)))) > 0 ? 255 : 0;
never executed: dest[x] = (src[x >> 3] & (1 << (7 - (x & 7)))) > 0 ? 255 : 0;
never evaluated: (src[x >> 3] & (1 << (7 - (x & 7)))) > 0
0
377 }
never executed: }
0
378 }
never executed: }
0
379 }
never executed: }
0
380 } else if (mask.depth() == 8) {
never executed: }
partially evaluated: mask.depth() == 8
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
381 for (int y = 0; y < c.h; ++y) {
evaluated: y < c.h
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:1
1-17
382 uchar *dest = d + (c.y + y) *dbpl + c.x;
executed (the execution status of this line is deduced): uchar *dest = d + (c.y + y) *dbpl + c.x;
-
383 if (y < mh) {
evaluated: y < mh
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:4
4-13
384 uchar *src = (uchar *) mask.scanLine(y);
executed (the execution status of this line is deduced): uchar *src = (uchar *) mask.scanLine(y);
-
385 for (int x = 0; x < c.w; ++x) {
evaluated: x < c.w
TRUEFALSE
yes
Evaluation Count:221
yes
Evaluation Count:13
13-221
386 if (x < mw)
evaluated: x < mw
TRUEFALSE
yes
Evaluation Count:169
yes
Evaluation Count:52
52-169
387 dest[x] = src[x];
executed: dest[x] = src[x];
Execution Count:169
169
388 }
executed: }
Execution Count:221
221
389 }
executed: }
Execution Count:13
13
390 }
executed: }
Execution Count:17
17
391 }
executed: }
Execution Count:1
1
392 } -
393 -
394#ifdef CACHE_DEBUG -
395// QPainter p(&m_image); -
396// p.drawLine( -
397 int margin = m_current_fontengine ? m_current_fontengine->glyphMargin(m_type) : 0; -
398 QPoint base(c.x + margin, c.y + margin + c.baseLineY-1); -
399 if (m_image.rect().contains(base)) -
400 m_image.setPixel(base, 255); -
401 m_image.save(QString::fromLatin1("cache-%1.png").arg(qint64(this))); -
402#endif -
403} -
404 -
405QT_END_NAMESPACE -
406 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial