painting/qpaintengine.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4qreal QTextItem::descent() const -
5{ -
6 const QTextItemInt *ti = static_cast<const QTextItemInt *>(this); -
7 return ti->descent.toReal();
never executed: return ti->descent.toReal();
0
8} -
9 -
10 -
11 -
12 -
13 -
14 -
15qreal QTextItem::ascent() const -
16{ -
17 const QTextItemInt *ti = static_cast<const QTextItemInt *>(this); -
18 return ti->ascent.toReal();
never executed: return ti->ascent.toReal();
0
19} -
20 -
21 -
22 -
23 -
24 -
25 -
26qreal QTextItem::width() const -
27{ -
28 const QTextItemInt *ti = static_cast<const QTextItemInt *>(this); -
29 return ti->width.toReal();
never executed: return ti->width.toReal();
0
30} -
31 -
32 -
33 -
34 -
35 -
36 -
37QTextItem::RenderFlags QTextItem::renderFlags() const -
38{ -
39 const QTextItemInt *ti = static_cast<const QTextItemInt *>(this); -
40 return ti->flags;
never executed: return ti->flags;
0
41} -
42 -
43 -
44 -
45 -
46 -
47 -
48QString QTextItem::text() const -
49{ -
50 const QTextItemInt *ti = static_cast<const QTextItemInt *>(this); -
51 return QString(ti->chars, ti->num_chars);
never executed: return QString(ti->chars, ti->num_chars);
0
52} -
53 -
54 -
55 -
56 -
57 -
58 -
59QFont QTextItem::font() const -
60{ -
61 const QTextItemInt *ti = static_cast<const QTextItemInt *>(this); -
62 return ti->f ? *ti->f : QGuiApplication::font();
never executed: return ti->f ? *ti->f : QGuiApplication::font();
0
63} -
64void QPaintEngine::syncState() -
65{ -
66 qt_noop(); -
67 updateState(*state); -
68 -
69 if (isExtended())
never evaluated: isExtended()
0
70 static_cast<QPaintEngineEx *>(this)->sync();
never executed: static_cast<QPaintEngineEx *>(this)->sync();
0
71}
never executed: }
0
72 -
73static QPaintEngine *qt_polygon_recursion = 0; -
74struct QT_Point { -
75 int x; -
76 int y; -
77}; -
78void QPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) -
79{ -
80 qt_noop(); -
81 -
82 qt_polygon_recursion = this; -
83 qt_noop(); -
84 QVarLengthArray<QT_Point> p(pointCount); -
85 for (int i = 0; i < pointCount; ++i) {
never evaluated: i < pointCount
0
86 p[i].x = qRound(points[i].x()); -
87 p[i].y = qRound(points[i].y()); -
88 }
never executed: }
0
89 drawPolygon((QPoint *)p.data(), pointCount, mode); -
90 qt_polygon_recursion = 0; -
91}
never executed: }
0
92 -
93struct QT_PointF { -
94 qreal x; -
95 qreal y; -
96}; -
97void QPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) -
98{ -
99 qt_noop(); -
100 -
101 qt_polygon_recursion = this; -
102 qt_noop(); -
103 QVarLengthArray<QT_PointF> p(pointCount); -
104 for (int i=0; i<pointCount; ++i) {
never evaluated: i<pointCount
0
105 p[i].x = points[i].x(); -
106 p[i].y = points[i].y(); -
107 }
never executed: }
0
108 drawPolygon((QPointF *)p.data(), pointCount, mode); -
109 qt_polygon_recursion = 0; -
110}
never executed: }
0
111void QPaintEngine::drawPoints(const QPointF *points, int pointCount) -
112{ -
113 QPainter *p = painter(); -
114 if (!p)
partially evaluated: !p
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
115 return;
never executed: return;
0
116 -
117 qreal penWidth = p->pen().widthF(); -
118 if (penWidth == 0)
partially evaluated: penWidth == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
119 penWidth = 1;
never executed: penWidth = 1;
0
120 -
121 bool ellipses = p->pen().capStyle() == Qt::RoundCap; -
122 -
123 p->save(); -
124 -
125 QTransform transform; -
126 if (qt_pen_is_cosmetic(p->pen(), p->renderHints())) {
partially evaluated: qt_pen_is_cosmetic(p->pen(), p->renderHints())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
127 transform = p->transform(); -
128 p->setTransform(QTransform()); -
129 }
never executed: }
0
130 -
131 p->setBrush(p->pen().brush()); -
132 p->setPen(Qt::NoPen); -
133 -
134 for (int i=0; i<pointCount; ++i) {
evaluated: i<pointCount
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:8
8
135 QPointF pos = transform.map(points[i]); -
136 QRectF rect(pos.x() - penWidth / 2, pos.y() - penWidth / 2, penWidth, penWidth); -
137 -
138 if (ellipses)
partially evaluated: ellipses
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
139 p->drawEllipse(rect);
never executed: p->drawEllipse(rect);
0
140 else -
141 p->drawRect(rect);
executed: p->drawRect(rect);
Execution Count:8
8
142 } -
143 -
144 p->restore(); -
145}
executed: }
Execution Count:8
8
146void QPaintEngine::drawPoints(const QPoint *points, int pointCount) -
147{ -
148 qt_noop(); -
149 QT_PointF fp[256]; -
150 while (pointCount) {
evaluated: pointCount
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:8
8
151 int i = 0; -
152 while (i < pointCount && i < 256) {
evaluated: i < pointCount
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:8
partially evaluated: i < 256
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
153 fp[i].x = points[i].x(); -
154 fp[i].y = points[i].y(); -
155 ++i; -
156 }
executed: }
Execution Count:8
8
157 drawPoints((QPointF *)(void *)fp, i); -
158 points += i; -
159 pointCount -= i; -
160 }
executed: }
Execution Count:8
8
161}
executed: }
Execution Count:8
8
162void QPaintEngine::drawEllipse(const QRectF &rect) -
163{ -
164 QPainterPath path; -
165 path.addEllipse(rect); -
166 if (hasFeature(PainterPaths)) {
never evaluated: hasFeature(PainterPaths)
0
167 drawPath(path); -
168 } else {
never executed: }
0
169 QPolygonF polygon = path.toFillPolygon(); -
170 drawPolygon(polygon.data(), polygon.size(), ConvexMode); -
171 }
never executed: }
0
172} -
173 -
174 -
175 -
176 -
177 -
178void QPaintEngine::drawEllipse(const QRect &rect) -
179{ -
180 drawEllipse(QRectF(rect)); -
181}
never executed: }
0
182void qt_fill_tile(QPixmap *tile, const QPixmap &pixmap) -
183{ -
184 QPainter p(tile); -
185 p.drawPixmap(0, 0, pixmap); -
186 int x = pixmap.width(); -
187 while (x < tile->width()) {
never evaluated: x < tile->width()
0
188 p.drawPixmap(x, 0, *tile, 0, 0, x, pixmap.height()); -
189 x *= 2; -
190 }
never executed: }
0
191 int y = pixmap.height(); -
192 while (y < tile->height()) {
never evaluated: y < tile->height()
0
193 p.drawPixmap(0, y, *tile, 0, 0, tile->width(), y); -
194 y *= 2; -
195 }
never executed: }
0
196}
never executed: }
0
197 -
198void qt_draw_tile(QPaintEngine *gc, qreal x, qreal y, qreal w, qreal h, -
199 const QPixmap &pixmap, qreal xOffset, qreal yOffset) -
200{ -
201 qreal yPos, xPos, drawH, drawW, yOff, xOff; -
202 yPos = y; -
203 yOff = yOffset; -
204 while(yPos < y + h) {
never evaluated: yPos < y + h
0
205 drawH = pixmap.height() - yOff; -
206 if (yPos + drawH > y + h)
never evaluated: yPos + drawH > y + h
0
207 drawH = y + h - yPos;
never executed: drawH = y + h - yPos;
0
208 xPos = x; -
209 xOff = xOffset; -
210 while(xPos < x + w) {
never evaluated: xPos < x + w
0
211 drawW = pixmap.width() - xOff; -
212 if (xPos + drawW > x + w)
never evaluated: xPos + drawW > x + w
0
213 drawW = x + w - xPos;
never executed: drawW = x + w - xPos;
0
214 if (drawW > 0 && drawH > 0)
never evaluated: drawW > 0
never evaluated: drawH > 0
0
215 gc->drawPixmap(QRectF(xPos, yPos, drawW, drawH), pixmap, QRectF(xOff, yOff, drawW, drawH));
never executed: gc->drawPixmap(QRectF(xPos, yPos, drawW, drawH), pixmap, QRectF(xOff, yOff, drawW, drawH));
0
216 xPos += drawW; -
217 xOff = 0; -
218 }
never executed: }
0
219 yPos += drawH; -
220 yOff = 0; -
221 }
never executed: }
0
222}
never executed: }
0
223 -
224 -
225 -
226 -
227 -
228 -
229 -
230void QPaintEngine::drawTiledPixmap(const QRectF &rect, const QPixmap &pixmap, const QPointF &p) -
231{ -
232 int sw = pixmap.width(); -
233 int sh = pixmap.height(); -
234 -
235 if (sw*sh < 8192 && sw*sh < 16*rect.width()*rect.height()) {
never evaluated: sw*sh < 8192
never evaluated: sw*sh < 16*rect.width()*rect.height()
0
236 int tw = sw, th = sh; -
237 while (tw*th < 32678 && tw < rect.width()/2)
never evaluated: tw*th < 32678
never evaluated: tw < rect.width()/2
0
238 tw *= 2;
never executed: tw *= 2;
0
239 while (tw*th < 32678 && th < rect.height()/2)
never evaluated: tw*th < 32678
never evaluated: th < rect.height()/2
0
240 th *= 2;
never executed: th *= 2;
0
241 QPixmap tile; -
242 if (pixmap.depth() == 1) {
never evaluated: pixmap.depth() == 1
0
243 tile = QBitmap(tw, th); -
244 } else {
never executed: }
0
245 tile = QPixmap(tw, th); -
246 if (pixmap.hasAlphaChannel())
never evaluated: pixmap.hasAlphaChannel()
0
247 tile.fill(Qt::transparent);
never executed: tile.fill(Qt::transparent);
0
248 }
never executed: }
0
249 qt_fill_tile(&tile, pixmap); -
250 qt_draw_tile(this, rect.x(), rect.y(), rect.width(), rect.height(), tile, p.x(), p.y()); -
251 } else {
never executed: }
0
252 qt_draw_tile(this, rect.x(), rect.y(), rect.width(), rect.height(), pixmap, p.x(), p.y()); -
253 }
never executed: }
0
254} -
255void QPaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr, -
256 Qt::ImageConversionFlags flags) -
257{ -
258 QRectF baseSize(0, 0, image.width(), image.height()); -
259 QImage im = image; -
260 if (baseSize != sr)
never evaluated: baseSize != sr
0
261 im = im.copy(qFloor(sr.x()), qFloor(sr.y()), 0
262 qCeil(sr.width()), qCeil(sr.height()));
never executed: im = im.copy(qFloor(sr.x()), qFloor(sr.y()), qCeil(sr.width()), qCeil(sr.height()));
0
263 QPixmap pm = QPixmap::fromImage(im, flags); -
264 drawPixmap(r, pm, QRectF(QPointF(0, 0), pm.size())); -
265}
never executed: }
0
266QPaintEngine::QPaintEngine(PaintEngineFeatures caps) -
267 : state(0), -
268 gccaps(caps), -
269 active(0), -
270 selfDestruct(false), -
271 extended(false), -
272 d_ptr(new QPaintEnginePrivate) -
273{ -
274 d_ptr->q_ptr = this; -
275}
executed: }
Execution Count:2
2
276 -
277 -
278 -
279 -
280 -
281QPaintEngine::QPaintEngine(QPaintEnginePrivate &dptr, PaintEngineFeatures caps) -
282 : state(0), -
283 gccaps(caps), -
284 active(0), -
285 selfDestruct(false), -
286 extended(false), -
287 d_ptr(&dptr) -
288{ -
289 d_ptr->q_ptr = this; -
290}
executed: }
Execution Count:8807
8807
291 -
292 -
293 -
294 -
295QPaintEngine::~QPaintEngine() -
296{ -
297} -
298 -
299 -
300 -
301 -
302QPainter *QPaintEngine::painter() const -
303{ -
304 return state ? state->painter() : 0;
executed: return state ? state->painter() : 0;
Execution Count:23062
23062
305} -
306 -
307 -
308 -
309 -
310 -
311void QPaintEngine::drawPath(const QPainterPath &) -
312{ -
313 if (hasFeature(PainterPaths)) {
never evaluated: hasFeature(PainterPaths)
0
314 QMessageLogger("painting/qpaintengine.cpp", 739, __PRETTY_FUNCTION__).warning("QPaintEngine::drawPath: Must be implemented when feature PainterPaths is set"); -
315 }
never executed: }
0
316}
never executed: }
0
317 -
318 -
319 -
320 -
321 -
322 -
323 -
324void QPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) -
325{ -
326 const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); -
327 -
328 QPainterPath path; -
329 path.setFillRule(Qt::WindingFill); -
330 if (ti.glyphs.numGlyphs)
never evaluated: ti.glyphs.numGlyphs
0
331 ti.fontEngine->addOutlineToPath(0, 0, ti.glyphs, &path, ti.flags);
never executed: ti.fontEngine->addOutlineToPath(0, 0, ti.glyphs, &path, ti.flags);
0
332 if (!path.isEmpty()) {
never evaluated: !path.isEmpty()
0
333 painter()->save(); -
334 painter()->setRenderHint(QPainter::Antialiasing, -
335 bool((painter()->renderHints() & QPainter::TextAntialiasing) -
336 && !(painter()->font().styleStrategy() & QFont::NoAntialias))); -
337 painter()->translate(p.x(), p.y()); -
338 painter()->fillPath(path, state->pen().brush()); -
339 painter()->restore(); -
340 }
never executed: }
0
341}
never executed: }
0
342 -
343 -
344 -
345 -
346 -
347 -
348void QPaintEngine::drawLines(const QLineF *lines, int lineCount) -
349{ -
350 for (int i=0; i<lineCount; ++i) {
evaluated: i<lineCount
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
351 QPointF pts[2] = { lines[i].p1(), lines[i].p2() }; -
352 -
353 if (pts[0] == pts[1]) {
partially evaluated: pts[0] == pts[1]
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
354 if (state->pen().capStyle() != Qt::FlatCap)
never evaluated: state->pen().capStyle() != Qt::FlatCap
0
355 drawPoints(pts, 1);
never executed: drawPoints(pts, 1);
0
356 continue;
never executed: continue;
0
357 } -
358 -
359 drawPolygon(pts, 2, PolylineMode); -
360 }
executed: }
Execution Count:6
6
361}
executed: }
Execution Count:6
6
362void QPaintEngine::drawLines(const QLine *lines, int lineCount) -
363{ -
364 struct PointF { -
365 qreal x; -
366 qreal y; -
367 }; -
368 struct LineF { -
369 PointF p1; -
370 PointF p2; -
371 }; -
372 qt_noop(); -
373 qt_noop(); -
374 LineF fl[256]; -
375 while (lineCount) {
evaluated: lineCount
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
376 int i = 0; -
377 while (i < lineCount && i < 256) {
evaluated: i < lineCount
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
partially evaluated: i < 256
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
378 fl[i].p1.x = lines[i].x1(); -
379 fl[i].p1.y = lines[i].y1(); -
380 fl[i].p2.x = lines[i].x2(); -
381 fl[i].p2.y = lines[i].y2(); -
382 ++i; -
383 }
executed: }
Execution Count:6
6
384 drawLines((QLineF *)(void *)fl, i); -
385 lines += i; -
386 lineCount -= i; -
387 }
executed: }
Execution Count:6
6
388}
executed: }
Execution Count:6
6
389void QPaintEngine::drawRects(const QRect *rects, int rectCount) -
390{ -
391 struct RectF { -
392 qreal x; -
393 qreal y; -
394 qreal w; -
395 qreal h; -
396 }; -
397 qt_noop(); -
398 RectF fr[256]; -
399 while (rectCount) {
evaluated: rectCount
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
400 int i = 0; -
401 while (i < rectCount && i < 256) {
evaluated: i < rectCount
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
partially evaluated: i < 256
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
402 fr[i].x = rects[i].x(); -
403 fr[i].y = rects[i].y(); -
404 fr[i].w = rects[i].width(); -
405 fr[i].h = rects[i].height(); -
406 ++i; -
407 }
executed: }
Execution Count:2
2
408 drawRects((QRectF *)(void *)fr, i); -
409 rects += i; -
410 rectCount -= i; -
411 }
executed: }
Execution Count:2
2
412}
executed: }
Execution Count:2
2
413 -
414 -
415 -
416 -
417 -
418 -
419void QPaintEngine::drawRects(const QRectF *rects, int rectCount) -
420{ -
421 if (hasFeature(PainterPaths) &&
partially evaluated: hasFeature(PainterPaths)
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
422 !state->penNeedsResolving() &&
partially evaluated: !state->penNeedsResolving()
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
423 !state->brushNeedsResolving()) {
partially evaluated: !state->brushNeedsResolving()
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
424 for (int i=0; i<rectCount; ++i) {
evaluated: i<rectCount
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:10
10
425 QPainterPath path; -
426 path.addRect(rects[i]); -
427 if (path.isEmpty())
partially evaluated: path.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
428 continue;
never executed: continue;
0
429 drawPath(path); -
430 }
executed: }
Execution Count:10
10
431 } else {
executed: }
Execution Count:10
10
432 for (int i=0; i<rectCount; ++i) {
never evaluated: i<rectCount
0
433 QRectF rf = rects[i]; -
434 QPointF pts[4] = { QPointF(rf.x(), rf.y()), -
435 QPointF(rf.x() + rf.width(), rf.y()), -
436 QPointF(rf.x() + rf.width(), rf.y() + rf.height()), -
437 QPointF(rf.x(), rf.y() + rf.height()) }; -
438 drawPolygon(pts, 4, ConvexMode); -
439 }
never executed: }
0
440 }
never executed: }
0
441} -
442 -
443 -
444 -
445 -
446 -
447void QPaintEngine::setPaintDevice(QPaintDevice *device) -
448{ -
449 d_func()->pdev = device; -
450}
executed: }
Execution Count:57549
57549
451 -
452 -
453 -
454 -
455 -
456QPaintDevice *QPaintEngine::paintDevice() const -
457{ -
458 return d_func()->pdev;
executed: return d_func()->pdev;
Execution Count:79
79
459} -
460QPoint QPaintEngine::coordinateOffset() const -
461{ -
462 return QPoint();
executed: return QPoint();
Execution Count:37
37
463} -
464void QPaintEngine::setSystemClip(const QRegion &region) -
465{ -
466 QPaintEnginePrivate * const d = d_func(); -
467 d->systemClip = region; -
468 -
469 -
470 if (d->hasSystemTransform || d->hasSystemViewport) {
partially evaluated: d->hasSystemTransform
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
partially evaluated: d->hasSystemViewport
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
471 d->transformSystemClip(); -
472 d->systemStateChanged(); -
473 }
never executed: }
0
474}
executed: }
Execution Count:10
10
475QRegion QPaintEngine::systemClip() const -
476{ -
477 return d_func()->systemClip;
executed: return d_func()->systemClip;
Execution Count:22187
22187
478} -
479 -
480 -
481 -
482 -
483 -
484 -
485 -
486void QPaintEngine::setSystemRect(const QRect &rect) -
487{ -
488 if (isActive()) {
never evaluated: isActive()
0
489 QMessageLogger("painting/qpaintengine.cpp", 961, __PRETTY_FUNCTION__).warning("QPaintEngine::setSystemRect: Should not be changed while engine is active"); -
490 return;
never executed: return;
0
491 } -
492 d_func()->systemRect = rect; -
493}
never executed: }
0
494 -
495 -
496 -
497 -
498 -
499 -
500 -
501QRect QPaintEngine::systemRect() const -
502{ -
503 return d_func()->systemRect;
executed: return d_func()->systemRect;
Execution Count:28773
28773
504} -
505 -
506void QPaintEnginePrivate::drawBoxTextItem(const QPointF &p, const QTextItemInt &ti) -
507{ -
508 if (!ti.glyphs.numGlyphs)
never evaluated: !ti.glyphs.numGlyphs
0
509 return;
never executed: return;
0
510 -
511 -
512 const int size = qRound(ti.fontEngine->ascent()); -
513 QVarLengthArray<QFixedPoint> positions; -
514 QVarLengthArray<glyph_t> glyphs; -
515 QTransform matrix = QTransform::fromTranslate(p.x(), p.y() - size); -
516 ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); -
517 if (glyphs.size() == 0)
never evaluated: glyphs.size() == 0
0
518 return;
never executed: return;
0
519 -
520 QSize s(size - 3, size - 3); -
521 -
522 QPainter *painter = q_func()->state->painter(); -
523 painter->save(); -
524 painter->setBrush(Qt::NoBrush); -
525 QPen pen = painter->pen(); -
526 pen.setWidthF(ti.fontEngine->lineThickness().toReal()); -
527 painter->setPen(pen); -
528 for (int k = 0; k < positions.size(); k++)
never evaluated: k < positions.size()
0
529 painter->drawRect(QRectF(positions[k].toPointF(), s));
never executed: painter->drawRect(QRectF(positions[k].toPointF(), s));
0
530 painter->restore(); -
531}
never executed: }
0
532 -
533 -
534 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial