| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qdistancefield.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | namespace | - | ||||||||||||||||||||||||
| 5 | { | - | ||||||||||||||||||||||||
| 6 | enum FillHDir | - | ||||||||||||||||||||||||
| 7 | { | - | ||||||||||||||||||||||||
| 8 | LeftToRight, | - | ||||||||||||||||||||||||
| 9 | RightToLeft | - | ||||||||||||||||||||||||
| 10 | }; | - | ||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | enum FillVDir | - | ||||||||||||||||||||||||
| 13 | { | - | ||||||||||||||||||||||||
| 14 | TopDown, | - | ||||||||||||||||||||||||
| 15 | BottomUp | - | ||||||||||||||||||||||||
| 16 | }; | - | ||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||
| 18 | enum FillClip | - | ||||||||||||||||||||||||
| 19 | { | - | ||||||||||||||||||||||||
| 20 | NoClip, | - | ||||||||||||||||||||||||
| 21 | Clip | - | ||||||||||||||||||||||||
| 22 | }; | - | ||||||||||||||||||||||||
| 23 | } | - | ||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | template <FillClip clip, FillHDir dir> | - | ||||||||||||||||||||||||
| 26 | inline void fillLine(qint32 *, int, int, int, qint32, qint32) | - | ||||||||||||||||||||||||
| 27 | { | - | ||||||||||||||||||||||||
| 28 | } | - | ||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | template <> | - | ||||||||||||||||||||||||
| 31 | inline void fillLine<Clip, LeftToRight>(qint32 *line, int width, int lx, int rx, qint32 d, qint32 dd) | - | ||||||||||||||||||||||||
| 32 | { | - | ||||||||||||||||||||||||
| 33 | int fromX = qMax(0, lx >> 8); | - | ||||||||||||||||||||||||
| 34 | int toX = qMin(width, rx >> 8); | - | ||||||||||||||||||||||||
| 35 | int x = toX - fromX; | - | ||||||||||||||||||||||||
| 36 | if (x <= 0
| 0 | ||||||||||||||||||||||||
| 37 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 38 | qint32 val = d + (((fromX << 8) + 0xff - lx) * dd >> 8); | - | ||||||||||||||||||||||||
| 39 | line += fromX; | - | ||||||||||||||||||||||||
| 40 | do { | - | ||||||||||||||||||||||||
| 41 | *line = abs(val) < abs(*line)
| 0 | ||||||||||||||||||||||||
| 42 | val += dd; | - | ||||||||||||||||||||||||
| 43 | ++line; | - | ||||||||||||||||||||||||
| 44 | } never executed: while (--end of block
| 0 | ||||||||||||||||||||||||
| 45 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||
| 47 | template <> | - | ||||||||||||||||||||||||
| 48 | inline void fillLine<Clip, RightToLeft>(qint32 *line, int width, int lx, int rx, qint32 d, qint32 dd) | - | ||||||||||||||||||||||||
| 49 | { | - | ||||||||||||||||||||||||
| 50 | int fromX = qMax(0, lx >> 8); | - | ||||||||||||||||||||||||
| 51 | int toX = qMin(width, rx >> 8); | - | ||||||||||||||||||||||||
| 52 | int x = toX - fromX; | - | ||||||||||||||||||||||||
| 53 | if (x <= 0
| 0 | ||||||||||||||||||||||||
| 54 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 55 | qint32 val = d + (((toX << 8) + 0xff - rx) * dd >> 8); | - | ||||||||||||||||||||||||
| 56 | line += toX; | - | ||||||||||||||||||||||||
| 57 | do { | - | ||||||||||||||||||||||||
| 58 | val -= dd; | - | ||||||||||||||||||||||||
| 59 | --line; | - | ||||||||||||||||||||||||
| 60 | *line = abs(val) < abs(*line)
| 0 | ||||||||||||||||||||||||
| 61 | } never executed: while (--end of block
| 0 | ||||||||||||||||||||||||
| 62 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | template <> | - | ||||||||||||||||||||||||
| 65 | inline void fillLine<NoClip, LeftToRight>(qint32 *line, int, int lx, int rx, qint32 d, qint32 dd) | - | ||||||||||||||||||||||||
| 66 | { | - | ||||||||||||||||||||||||
| 67 | int fromX = lx >> 8; | - | ||||||||||||||||||||||||
| 68 | int toX = rx >> 8; | - | ||||||||||||||||||||||||
| 69 | int x = toX - fromX; | - | ||||||||||||||||||||||||
| 70 | if (x <= 0
| 0 | ||||||||||||||||||||||||
| 71 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 72 | qint32 val = d + ((~lx & 0xff) * dd >> 8); | - | ||||||||||||||||||||||||
| 73 | line += fromX; | - | ||||||||||||||||||||||||
| 74 | do { | - | ||||||||||||||||||||||||
| 75 | *line = abs(val) < abs(*line)
| 0 | ||||||||||||||||||||||||
| 76 | val += dd; | - | ||||||||||||||||||||||||
| 77 | ++line; | - | ||||||||||||||||||||||||
| 78 | } never executed: while (--end of block
| 0 | ||||||||||||||||||||||||
| 79 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||
| 81 | template <> | - | ||||||||||||||||||||||||
| 82 | inline void fillLine<NoClip, RightToLeft>(qint32 *line, int, int lx, int rx, qint32 d, qint32 dd) | - | ||||||||||||||||||||||||
| 83 | { | - | ||||||||||||||||||||||||
| 84 | int fromX = lx >> 8; | - | ||||||||||||||||||||||||
| 85 | int toX = rx >> 8; | - | ||||||||||||||||||||||||
| 86 | int x = toX - fromX; | - | ||||||||||||||||||||||||
| 87 | if (x <= 0
| 0 | ||||||||||||||||||||||||
| 88 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 89 | qint32 val = d + ((~rx & 0xff) * dd >> 8); | - | ||||||||||||||||||||||||
| 90 | line += toX; | - | ||||||||||||||||||||||||
| 91 | do { | - | ||||||||||||||||||||||||
| 92 | val -= dd; | - | ||||||||||||||||||||||||
| 93 | --line; | - | ||||||||||||||||||||||||
| 94 | *line = abs(val) < abs(*line)
| 0 | ||||||||||||||||||||||||
| 95 | } never executed: while (--end of block
| 0 | ||||||||||||||||||||||||
| 96 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | template <FillClip clip, FillVDir vDir, FillHDir hDir> | - | ||||||||||||||||||||||||
| 99 | inline void fillLines(qint32 *bits, int width, int height, int upperY, int lowerY, | - | ||||||||||||||||||||||||
| 100 | int &lx, int ldx, int &rx, int rdx, qint32 &d, qint32 ddy, qint32 ddx) | - | ||||||||||||||||||||||||
| 101 | { | - | ||||||||||||||||||||||||
| 102 | (void)height;; | - | ||||||||||||||||||||||||
| 103 | ((!(upperY < lowerY)) ? qt_assert("upperY < lowerY",__FILE__,147) : qt_noop()); | - | ||||||||||||||||||||||||
| 104 | int y = lowerY - upperY; | - | ||||||||||||||||||||||||
| 105 | if (vDir == TopDown
| 0 | ||||||||||||||||||||||||
| 106 | qint32 *line = bits + upperY * width; | - | ||||||||||||||||||||||||
| 107 | do { | - | ||||||||||||||||||||||||
| 108 | fillLine<clip, hDir>(line, width, lx, rx, d, ddx); | - | ||||||||||||||||||||||||
| 109 | lx += ldx; | - | ||||||||||||||||||||||||
| 110 | d += ddy; | - | ||||||||||||||||||||||||
| 111 | rx += rdx; | - | ||||||||||||||||||||||||
| 112 | line += width; | - | ||||||||||||||||||||||||
| 113 | } never executed: while (--end of block
| 0 | ||||||||||||||||||||||||
| 114 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 115 | qint32 *line = bits + lowerY * width; | - | ||||||||||||||||||||||||
| 116 | do { | - | ||||||||||||||||||||||||
| 117 | lx -= ldx; | - | ||||||||||||||||||||||||
| 118 | d -= ddy; | - | ||||||||||||||||||||||||
| 119 | rx -= rdx; | - | ||||||||||||||||||||||||
| 120 | line -= width; | - | ||||||||||||||||||||||||
| 121 | fillLine<clip, hDir>(line, width, lx, rx, d, ddx); | - | ||||||||||||||||||||||||
| 122 | } never executed: while (--end of block
| 0 | ||||||||||||||||||||||||
| 123 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 124 | } | - | ||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | template <FillClip clip> | - | ||||||||||||||||||||||||
| 127 | void drawTriangle(qint32 *bits, int width, int height, const QPoint *center, | - | ||||||||||||||||||||||||
| 128 | const QPoint *v1, const QPoint *v2, qint32 value) | - | ||||||||||||||||||||||||
| 129 | { | - | ||||||||||||||||||||||||
| 130 | const int y1 = clip == Clip ? qBound(0, v1->y() >> 8, height) : v1->y() >> 8; | - | ||||||||||||||||||||||||
| 131 | const int y2 = clip == Clip ? qBound(0, v2->y() >> 8, height) : v2->y() >> 8; | - | ||||||||||||||||||||||||
| 132 | const int yC = clip == Clip ? qBound(0, center->y() >> 8, height) : center->y() >> 8; | - | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | const int v1Frac = clip == Clip ? (y1 << 8) + 0xff - v1->y() : ~v2->y() & 0xff; | - | ||||||||||||||||||||||||
| 135 | const int v2Frac = clip == Clip ? (y2 << 8) + 0xff - v2->y() : ~v1->y() & 0xff; | - | ||||||||||||||||||||||||
| 136 | const int centerFrac = clip == Clip ? (yC << 8) + 0xff - center->y() : ~center->y() & 0xff; | - | ||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||
| 138 | int dx1 = 0, x1 = 0, dx2 = 0, x2 = 0; | - | ||||||||||||||||||||||||
| 139 | qint32 dd1, d1, dd2, d2; | - | ||||||||||||||||||||||||
| 140 | if (v1->y() != center->y()
| 0 | ||||||||||||||||||||||||
| 141 | dx1 = ((v1->x() - center->x()) << 8) / (v1->y() - center->y()); | - | ||||||||||||||||||||||||
| 142 | x1 = center->x() + centerFrac * (v1->x() - center->x()) / (v1->y() - center->y()); | - | ||||||||||||||||||||||||
| 143 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 144 | if (v2->y() != center->y()
| 0 | ||||||||||||||||||||||||
| 145 | dx2 = ((v2->x() - center->x()) << 8) / (v2->y() - center->y()); | - | ||||||||||||||||||||||||
| 146 | x2 = center->x() + centerFrac * (v2->x() - center->x()) / (v2->y() - center->y()); | - | ||||||||||||||||||||||||
| 147 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | const qint32 div = (v2->x() - center->x()) * (v1->y() - center->y()) | - | ||||||||||||||||||||||||
| 150 | - (v2->y() - center->y()) * (v1->x() - center->x()); | - | ||||||||||||||||||||||||
| 151 | const qint32 dd = div ? qint32((qint64(value * (v1->y() - v2->y())) << 8) / div) : 0; | - | ||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||
| 153 | if (y2 < yC
| 0 | ||||||||||||||||||||||||
| 154 | if (y1 < yC
| 0 | ||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | if (y2 < y1
| 0 | ||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||
| 159 | d1 = centerFrac * value / (v1->y() - center->y()); | - | ||||||||||||||||||||||||
| 160 | dd1 = ((value << 8) / (v1->y() - center->y())); | - | ||||||||||||||||||||||||
| 161 | fillLines<clip, BottomUp, LeftToRight>(bits, width, height, y1, yC, x1, dx1, | - | ||||||||||||||||||||||||
| 162 | x2, dx2, d1, dd1, dd); | - | ||||||||||||||||||||||||
| 163 | dx1 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 164 | x1 = v1->x() + v1Frac * (v1->x() - v2->x()) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 165 | fillLines<clip, BottomUp, LeftToRight>(bits, width, height, y2, y1, x1, dx1, | - | ||||||||||||||||||||||||
| 166 | x2, dx2, value, 0, dd); | - | ||||||||||||||||||||||||
| 167 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 168 | - | |||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | d2 = centerFrac * value / (v2->y() - center->y()); | - | ||||||||||||||||||||||||
| 171 | dd2 = ((value << 8) / (v2->y() - center->y())); | - | ||||||||||||||||||||||||
| 172 | fillLines<clip, BottomUp, RightToLeft>(bits, width, height, y2, yC, x1, dx1, | - | ||||||||||||||||||||||||
| 173 | x2, dx2, d2, dd2, dd); | - | ||||||||||||||||||||||||
| 174 | if (y1 != y2
| 0 | ||||||||||||||||||||||||
| 175 | dx2 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 176 | x2 = v2->x() + v2Frac * (v1->x() - v2->x()) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 177 | fillLines<clip, BottomUp, RightToLeft>(bits, width, height, y1, y2, x1, dx1, | - | ||||||||||||||||||||||||
| 178 | x2, dx2, value, 0, dd); | - | ||||||||||||||||||||||||
| 179 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 180 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 181 | } else { | - | ||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||
| 184 | int dx = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 185 | int xUp, xDn; | - | ||||||||||||||||||||||||
| 186 | xUp = xDn = v2->x() + (clip == Clip
| 0 | ||||||||||||||||||||||||
| 187 | : (center->y() | 0xff) - v2->y()) | - | ||||||||||||||||||||||||
| 188 | * (v1->x() - v2->x()) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 189 | fillLines<clip, BottomUp, LeftToRight>(bits, width, height, y2, yC, xUp, dx, | - | ||||||||||||||||||||||||
| 190 | x2, dx2, value, 0, dd); | - | ||||||||||||||||||||||||
| 191 | if (yC != y1
| 0 | ||||||||||||||||||||||||
| 192 | fillLines<clip, TopDown, LeftToRight>(bits, width, height, yC, y1, xDn, dx, never executed: fillLines<clip, TopDown, LeftToRight>(bits, width, height, yC, y1, xDn, dx, x1, dx1, value, 0, dd); | 0 | ||||||||||||||||||||||||
| 193 | x1, dx1, value, 0, dd); never executed: fillLines<clip, TopDown, LeftToRight>(bits, width, height, yC, y1, xDn, dx, x1, dx1, value, 0, dd); | 0 | ||||||||||||||||||||||||
| 194 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 195 | } else { | - | ||||||||||||||||||||||||
| 196 | if (y1 < yC
| 0 | ||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||
| 199 | int dx = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 200 | int xUp, xDn; | - | ||||||||||||||||||||||||
| 201 | xUp = xDn = v1->x() + (clip == Clip
| 0 | ||||||||||||||||||||||||
| 202 | : (center->y() | 0xff) - v1->y()) | - | ||||||||||||||||||||||||
| 203 | * (v1->x() - v2->x()) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 204 | fillLines<clip, BottomUp, RightToLeft>(bits, width, height, y1, yC, x1, dx1, | - | ||||||||||||||||||||||||
| 205 | xUp, dx, value, 0, dd); | - | ||||||||||||||||||||||||
| 206 | if (yC != y2
| 0 | ||||||||||||||||||||||||
| 207 | fillLines<clip, TopDown, RightToLeft>(bits, width, height, yC, y2, x2, dx2, never executed: fillLines<clip, TopDown, RightToLeft>(bits, width, height, yC, y2, x2, dx2, xDn, dx, value, 0, dd); | 0 | ||||||||||||||||||||||||
| 208 | xDn, dx, value, 0, dd); never executed: fillLines<clip, TopDown, RightToLeft>(bits, width, height, yC, y2, x2, dx2, xDn, dx, value, 0, dd); | 0 | ||||||||||||||||||||||||
| 209 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | if (y2 < y1
| 0 | ||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 | if (yC != y2
| 0 | ||||||||||||||||||||||||
| 215 | d2 = centerFrac * value / (v2->y() - center->y()); | - | ||||||||||||||||||||||||
| 216 | dd2 = ((value << 8) / (v2->y() - center->y())); | - | ||||||||||||||||||||||||
| 217 | fillLines<clip, TopDown, LeftToRight>(bits, width, height, yC, y2, x2, dx2, | - | ||||||||||||||||||||||||
| 218 | x1, dx1, d2, dd2, dd); | - | ||||||||||||||||||||||||
| 219 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 220 | dx2 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 221 | x2 = v2->x() + v2Frac * (v1->x() - v2->x()) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 222 | fillLines<clip, TopDown, LeftToRight>(bits, width, height, y2, y1, x2, dx2, | - | ||||||||||||||||||||||||
| 223 | x1, dx1, value, 0, dd); | - | ||||||||||||||||||||||||
| 224 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||
| 226 | - | |||||||||||||||||||||||||
| 227 | if (yC != y1
| 0 | ||||||||||||||||||||||||
| 228 | d1 = centerFrac * value / (v1->y() - center->y()); | - | ||||||||||||||||||||||||
| 229 | dd1 = ((value << 8) / (v1->y() - center->y())); | - | ||||||||||||||||||||||||
| 230 | fillLines<clip, TopDown, RightToLeft>(bits, width, height, yC, y1, x2, dx2, | - | ||||||||||||||||||||||||
| 231 | x1, dx1, d1, dd1, dd); | - | ||||||||||||||||||||||||
| 232 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 233 | if (y1 != y2
| 0 | ||||||||||||||||||||||||
| 234 | dx1 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 235 | x1 = v1->x() + v1Frac * (v1->x() - v2->x()) / (v1->y() - v2->y()); | - | ||||||||||||||||||||||||
| 236 | fillLines<clip, TopDown, RightToLeft>(bits, width, height, y1, y2, x2, dx2, | - | ||||||||||||||||||||||||
| 237 | x1, dx1, value, 0, dd); | - | ||||||||||||||||||||||||
| 238 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 239 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 240 | } | - | ||||||||||||||||||||||||
| 241 | } | - | ||||||||||||||||||||||||
| 242 | } | - | ||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||
| 244 | template <FillClip clip> | - | ||||||||||||||||||||||||
| 245 | void drawRectangle(qint32 *bits, int width, int height, | - | ||||||||||||||||||||||||
| 246 | const QPoint *int1, const QPoint *center1, const QPoint *ext1, | - | ||||||||||||||||||||||||
| 247 | const QPoint *int2, const QPoint *center2, const QPoint *ext2, | - | ||||||||||||||||||||||||
| 248 | qint32 extValue) | - | ||||||||||||||||||||||||
| 249 | { | - | ||||||||||||||||||||||||
| 250 | if (center1->y() > center2->y()
| 0 | ||||||||||||||||||||||||
| 251 | qSwap(center1, center2); | - | ||||||||||||||||||||||||
| 252 | qSwap(int1, ext2); | - | ||||||||||||||||||||||||
| 253 | qSwap(ext1, int2); | - | ||||||||||||||||||||||||
| 254 | extValue = -extValue; | - | ||||||||||||||||||||||||
| 255 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 256 | - | |||||||||||||||||||||||||
| 257 | ((!(ext1->x() - center1->x() == center1->x() - int1->x())) ? qt_assert("ext1->x() - center1->x() == center1->x() - int1->x()",__FILE__,301) : qt_noop()); | - | ||||||||||||||||||||||||
| 258 | ((!(ext1->y() - center1->y() == center1->y() - int1->y())) ? qt_assert("ext1->y() - center1->y() == center1->y() - int1->y()",__FILE__,302) : qt_noop()); | - | ||||||||||||||||||||||||
| 259 | ((!(ext2->x() - center2->x() == center2->x() - int2->x())) ? qt_assert("ext2->x() - center2->x() == center2->x() - int2->x()",__FILE__,303) : qt_noop()); | - | ||||||||||||||||||||||||
| 260 | ((!(ext2->y() - center2->y() == center2->y() - int2->y())) ? qt_assert("ext2->y() - center2->y() == center2->y() - int2->y()",__FILE__,304) : qt_noop()); | - | ||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | const int yc1 = clip == Clip ? qBound(0, center1->y() >> 8, height) : center1->y() >> 8; | - | ||||||||||||||||||||||||
| 263 | const int yc2 = clip == Clip ? qBound(0, center2->y() >> 8, height) : center2->y() >> 8; | - | ||||||||||||||||||||||||
| 264 | const int yi1 = clip == Clip ? qBound(0, int1->y() >> 8, height) : int1->y() >> 8; | - | ||||||||||||||||||||||||
| 265 | const int yi2 = clip == Clip ? qBound(0, int2->y() >> 8, height) : int2->y() >> 8; | - | ||||||||||||||||||||||||
| 266 | const int ye1 = clip == Clip ? qBound(0, ext1->y() >> 8, height) : ext1->y() >> 8; | - | ||||||||||||||||||||||||
| 267 | const int ye2 = clip == Clip ? qBound(0, ext2->y() >> 8, height) : ext2->y() >> 8; | - | ||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | const int center1Frac = clip == Clip ? (yc1 << 8) + 0xff - center1->y() : ~center1->y() & 0xff; | - | ||||||||||||||||||||||||
| 270 | const int center2Frac = clip == Clip ? (yc2 << 8) + 0xff - center2->y() : ~center2->y() & 0xff; | - | ||||||||||||||||||||||||
| 271 | const int int1Frac = clip == Clip ? (yi1 << 8) + 0xff - int1->y() : ~int1->y() & 0xff; | - | ||||||||||||||||||||||||
| 272 | const int ext1Frac = clip == Clip ? (ye1 << 8) + 0xff - ext1->y() : ~ext1->y() & 0xff; | - | ||||||||||||||||||||||||
| 273 | - | |||||||||||||||||||||||||
| 274 | int dxC = 0, dxE = 0; | - | ||||||||||||||||||||||||
| 275 | qint32 ddC = 0; | - | ||||||||||||||||||||||||
| 276 | if (ext1->y() != int1->y()
| 0 | ||||||||||||||||||||||||
| 277 | dxC = ((ext1->x() - int1->x()) << 8) / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 278 | ddC = (extValue << 9) / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 279 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 280 | if (ext1->y() != ext2->y()
| 0 | ||||||||||||||||||||||||
| 281 | dxE = ((ext1->x() - ext2->x()) << 8) / (ext1->y() - ext2->y()); never executed: dxE = ((ext1->x() - ext2->x()) << 8) / (ext1->y() - ext2->y()); | 0 | ||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||
| 283 | const qint32 div = (ext1->x() - int1->x()) * (ext2->y() - int1->y()) | - | ||||||||||||||||||||||||
| 284 | - (ext1->y() - int1->y()) * (ext2->x() - int1->x()); | - | ||||||||||||||||||||||||
| 285 | const qint32 dd = div ? qint32((qint64(extValue * (ext2->y() - ext1->y())) << 9) / div) : 0; | - | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | int xe1, xe2, xc1, xc2; | - | ||||||||||||||||||||||||
| 288 | qint32 d; | - | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | qint32 intValue = -extValue; | - | ||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||
| 292 | if (center2->x() < center1->x()
| 0 | ||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||
| 294 | if (int1->y() < ext2->y()
| 0 | ||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||
| 296 | ((!(ext1->y() != ext2->y())) ? qt_assert("ext1->y() != ext2->y()",__FILE__,340) : qt_noop()); | - | ||||||||||||||||||||||||
| 297 | xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); | - | ||||||||||||||||||||||||
| 298 | xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); | - | ||||||||||||||||||||||||
| 299 | if (ye1 != yi1
| 0 | ||||||||||||||||||||||||
| 300 | xc2 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 301 | xc2 += (ye1 - yc1) * dxC; | - | ||||||||||||||||||||||||
| 302 | fillLines<clip, TopDown, LeftToRight>(bits, width, height, ye1, yi1, xe1, dxE, | - | ||||||||||||||||||||||||
| 303 | xc2, dxC, extValue, 0, dd); | - | ||||||||||||||||||||||||
| 304 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 305 | if (yi1 != ye2
| 0 | ||||||||||||||||||||||||
| 306 | fillLines<clip, TopDown, LeftToRight>(bits, width, height, yi1, ye2, xe1, dxE, never executed: fillLines<clip, TopDown, LeftToRight>(bits, width, height, yi1, ye2, xe1, dxE, xe2, dxE, extValue, 0, dd); | 0 | ||||||||||||||||||||||||
| 307 | xe2, dxE, extValue, 0, dd); never executed: fillLines<clip, TopDown, LeftToRight>(bits, width, height, yi1, ye2, xe1, dxE, xe2, dxE, extValue, 0, dd); | 0 | ||||||||||||||||||||||||
| 308 | if (ye2 != yi2
| 0 | ||||||||||||||||||||||||
| 309 | xc1 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 310 | xc1 += (ye2 - yc2) * dxC; | - | ||||||||||||||||||||||||
| 311 | fillLines<clip, TopDown, RightToLeft>(bits, width, height, ye2, yi2, xc1, dxC, | - | ||||||||||||||||||||||||
| 312 | xe2, dxE, intValue, 0, dd); | - | ||||||||||||||||||||||||
| 313 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 314 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||
| 316 | ((!(ext1->y() != int1->y())) ? qt_assert("ext1->y() != int1->y()",__FILE__,360) : qt_noop()); | - | ||||||||||||||||||||||||
| 317 | xc1 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 318 | xc2 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 319 | xc1 += (ye2 - yc2) * dxC; | - | ||||||||||||||||||||||||
| 320 | xc2 += (ye1 - yc1) * dxC; | - | ||||||||||||||||||||||||
| 321 | if (ye1 != ye2
| 0 | ||||||||||||||||||||||||
| 322 | xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); | - | ||||||||||||||||||||||||
| 323 | fillLines<clip, TopDown, LeftToRight>(bits, width, height, ye1, ye2, xe1, dxE, | - | ||||||||||||||||||||||||
| 324 | xc2, dxC, extValue, 0, dd); | - | ||||||||||||||||||||||||
| 325 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 326 | if (ye2 != yi1
| 0 | ||||||||||||||||||||||||
| 327 | d = (clip == Clip
| 0 | ||||||||||||||||||||||||
| 328 | : (ext2->y() | 0xff) - center2->y()) | - | ||||||||||||||||||||||||
| 329 | * 2 * extValue / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 330 | fillLines<clip, TopDown, LeftToRight>(bits, width, height, ye2, yi1, xc1, dxC, | - | ||||||||||||||||||||||||
| 331 | xc2, dxC, d, ddC, dd); | - | ||||||||||||||||||||||||
| 332 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 333 | if (yi1 != yi2
| 0 | ||||||||||||||||||||||||
| 334 | xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); | - | ||||||||||||||||||||||||
| 335 | fillLines<clip, TopDown, RightToLeft>(bits, width, height, yi1, yi2, xc1, dxC, | - | ||||||||||||||||||||||||
| 336 | xe2, dxE, intValue, 0, dd); | - | ||||||||||||||||||||||||
| 337 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 338 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 339 | } else { | - | ||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | if (ext1->y() < int2->y()
| 0 | ||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||
| 343 | ((!(ext1->y() != ext2->y())) ? qt_assert("ext1->y() != ext2->y()",__FILE__,387) : qt_noop()); | - | ||||||||||||||||||||||||
| 344 | xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); | - | ||||||||||||||||||||||||
| 345 | xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); | - | ||||||||||||||||||||||||
| 346 | if (yi1 != ye1
| 0 | ||||||||||||||||||||||||
| 347 | xc1 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 348 | xc1 += (yi1 - yc1) * dxC; | - | ||||||||||||||||||||||||
| 349 | fillLines<clip, TopDown, RightToLeft>(bits, width, height, yi1, ye1, xc1, dxC, | - | ||||||||||||||||||||||||
| 350 | xe2, dxE, intValue, 0, dd); | - | ||||||||||||||||||||||||
| 351 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 352 | if (ye1 != yi2
| 0 | ||||||||||||||||||||||||
| 353 | fillLines<clip, TopDown, RightToLeft>(bits, width, height, ye1, yi2, xe1, dxE, never executed: fillLines<clip, TopDown, RightToLeft>(bits, width, height, ye1, yi2, xe1, dxE, xe2, dxE, intValue, 0, dd); | 0 | ||||||||||||||||||||||||
| 354 | xe2, dxE, intValue, 0, dd); never executed: fillLines<clip, TopDown, RightToLeft>(bits, width, height, ye1, yi2, xe1, dxE, xe2, dxE, intValue, 0, dd); | 0 | ||||||||||||||||||||||||
| 355 | if (yi2 != ye2
| 0 | ||||||||||||||||||||||||
| 356 | xc2 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 357 | xc2 += (yi2 - yc2) * dxC; | - | ||||||||||||||||||||||||
| 358 | fillLines<clip, TopDown, LeftToRight>(bits, width, height, yi2, ye2, xe1, dxE, | - | ||||||||||||||||||||||||
| 359 | xc2, dxC, extValue, 0, dd); | - | ||||||||||||||||||||||||
| 360 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 361 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||
| 363 | ((!(ext1->y() != int1->y())) ? qt_assert("ext1->y() != int1->y()",__FILE__,407) : qt_noop()); | - | ||||||||||||||||||||||||
| 364 | xc1 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 365 | xc2 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 366 | xc1 += (yi1 - yc1) * dxC; | - | ||||||||||||||||||||||||
| 367 | xc2 += (yi2 - yc2) * dxC; | - | ||||||||||||||||||||||||
| 368 | if (yi1 != yi2
| 0 | ||||||||||||||||||||||||
| 369 | xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); | - | ||||||||||||||||||||||||
| 370 | fillLines<clip, TopDown, RightToLeft>(bits, width, height, yi1, yi2, xc1, dxC, | - | ||||||||||||||||||||||||
| 371 | xe2, dxE, intValue, 0, dd); | - | ||||||||||||||||||||||||
| 372 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 373 | if (yi2 != ye1
| 0 | ||||||||||||||||||||||||
| 374 | d = (clip == Clip
| 0 | ||||||||||||||||||||||||
| 375 | : (int2->y() | 0xff) - center2->y()) | - | ||||||||||||||||||||||||
| 376 | * 2 * extValue / (ext1->y() - int1->y()); | - | ||||||||||||||||||||||||
| 377 | fillLines<clip, TopDown, RightToLeft>(bits, width, height, yi2, ye1, xc1, dxC, | - | ||||||||||||||||||||||||
| 378 | xc2, dxC, d, ddC, dd); | - | ||||||||||||||||||||||||
| 379 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 380 | if (ye1 != ye2
| 0 | ||||||||||||||||||||||||
| 381 | xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); | - | ||||||||||||||||||||||||
| 382 | fillLines<clip, TopDown, LeftToRight>(bits, width, height, ye1, ye2, xe1, dxE, | - | ||||||||||||||||||||||||
| 383 | xc2, dxC, extValue, 0, dd); | - | ||||||||||||||||||||||||
| 384 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 385 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 386 | } | - | ||||||||||||||||||||||||
| 387 | } | - | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | static void drawPolygons(qint32 *bits, int width, int height, const QPoint *vertices, | - | ||||||||||||||||||||||||
| 390 | const quint32 *indices, int indexCount, qint32 value) | - | ||||||||||||||||||||||||
| 391 | { | - | ||||||||||||||||||||||||
| 392 | ((!(indexCount != 0)) ? qt_assert("indexCount != 0",__FILE__,436) : qt_noop()); | - | ||||||||||||||||||||||||
| 393 | ((!(height <= 128)) ? qt_assert("height <= 128",__FILE__,437) : qt_noop()); | - | ||||||||||||||||||||||||
| 394 | QVarLengthArray<quint8, 16> scans[128]; | - | ||||||||||||||||||||||||
| 395 | int first = 0; | - | ||||||||||||||||||||||||
| 396 | for (int i = 1; i < indexCount
| 0 | ||||||||||||||||||||||||
| 397 | quint32 idx1 = indices[i - 1]; | - | ||||||||||||||||||||||||
| 398 | quint32 idx2 = indices[i]; | - | ||||||||||||||||||||||||
| 399 | ((!(idx1 != quint32(-1))) ? qt_assert("idx1 != quint32(-1)",__FILE__,443) : qt_noop()); | - | ||||||||||||||||||||||||
| 400 | if (idx2 == quint32(-1)
| 0 | ||||||||||||||||||||||||
| 401 | idx2 = indices[first]; | - | ||||||||||||||||||||||||
| 402 | ((!(idx2 != quint32(-1))) ? qt_assert("idx2 != quint32(-1)",__FILE__,446) : qt_noop()); | - | ||||||||||||||||||||||||
| 403 | first = ++i; | - | ||||||||||||||||||||||||
| 404 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 405 | const QPoint *v1 = &vertices[idx1]; | - | ||||||||||||||||||||||||
| 406 | const QPoint *v2 = &vertices[idx2]; | - | ||||||||||||||||||||||||
| 407 | if (v2->y() < v1->y()
| 0 | ||||||||||||||||||||||||
| 408 | qSwap(v1, v2); never executed: qSwap(v1, v2); | 0 | ||||||||||||||||||||||||
| 409 | int fromY = qMax(0, v1->y() >> 8); | - | ||||||||||||||||||||||||
| 410 | int toY = qMin(height, v2->y() >> 8); | - | ||||||||||||||||||||||||
| 411 | if (fromY >= toY
| 0 | ||||||||||||||||||||||||
| 412 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 413 | int dx = ((v2->x() - v1->x()) << 8) / (v2->y() - v1->y()); | - | ||||||||||||||||||||||||
| 414 | int x = v1->x() + ((fromY << 8) + 0xff - v1->y()) * (v2->x() - v1->x()) / (v2->y() - v1->y()); | - | ||||||||||||||||||||||||
| 415 | for (int y = fromY; y < toY
| 0 | ||||||||||||||||||||||||
| 416 | quint32 c = quint32(x >> 8); | - | ||||||||||||||||||||||||
| 417 | if (c < quint32(width)
| 0 | ||||||||||||||||||||||||
| 418 | scans[y].append(quint8(c)); never executed: scans[y].append(quint8(c)); | 0 | ||||||||||||||||||||||||
| 419 | x += dx; | - | ||||||||||||||||||||||||
| 420 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 421 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 422 | for (int i = 0; i < height
| 0 | ||||||||||||||||||||||||
| 423 | quint8 *scanline = scans[i].data(); | - | ||||||||||||||||||||||||
| 424 | int size = scans[i].size(); | - | ||||||||||||||||||||||||
| 425 | for (int j = 1; j < size
| 0 | ||||||||||||||||||||||||
| 426 | int k = j; | - | ||||||||||||||||||||||||
| 427 | quint8 value = scanline[k]; | - | ||||||||||||||||||||||||
| 428 | for (; k != 0
| 0 | ||||||||||||||||||||||||
| 429 | scanline[k] = scanline[k - 1]; never executed: scanline[k] = scanline[k - 1]; | 0 | ||||||||||||||||||||||||
| 430 | scanline[k] = value; | - | ||||||||||||||||||||||||
| 431 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 432 | qint32 *line = bits + i * width; | - | ||||||||||||||||||||||||
| 433 | int j = 0; | - | ||||||||||||||||||||||||
| 434 | for (; j + 1 < size
| 0 | ||||||||||||||||||||||||
| 435 | for (quint8 x = scanline[j]; x < scanline[j + 1]
| 0 | ||||||||||||||||||||||||
| 436 | line[x] = value; never executed: line[x] = value; | 0 | ||||||||||||||||||||||||
| 437 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 438 | if (j < size
| 0 | ||||||||||||||||||||||||
| 439 | for (int x = scanline[j]; x < width
| 0 | ||||||||||||||||||||||||
| 440 | line[x] = value; never executed: line[x] = value; | 0 | ||||||||||||||||||||||||
| 441 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 442 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 443 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||
| 445 | static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path, int dfScale, int offs) | - | ||||||||||||||||||||||||
| 446 | { | - | ||||||||||||||||||||||||
| 447 | if (!data
| 0 | ||||||||||||||||||||||||
| 448 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | if (path.isEmpty()
| 0 | ||||||||||||||||||||||||
| 451 | memset(data->data, 0, data->nbytes); | - | ||||||||||||||||||||||||
| 452 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 453 | } | - | ||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | int imgWidth = data->width; | - | ||||||||||||||||||||||||
| 456 | int imgHeight = data->height; | - | ||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | QTransform transform; | - | ||||||||||||||||||||||||
| 459 | transform.translate(offs, offs); | - | ||||||||||||||||||||||||
| 460 | transform.scale(qreal(1) / dfScale, qreal(1) / dfScale); | - | ||||||||||||||||||||||||
| 461 | - | |||||||||||||||||||||||||
| 462 | QDataBuffer<quint32> pathIndices(0); | - | ||||||||||||||||||||||||
| 463 | QDataBuffer<QPoint> pathVertices(0); | - | ||||||||||||||||||||||||
| 464 | qSimplifyPath(path, pathVertices, pathIndices, transform); | - | ||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||
| 466 | const qint32 interiorColor = -0x7f80; | - | ||||||||||||||||||||||||
| 467 | const qint32 exteriorColor = 0x7f80; | - | ||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||
| 469 | QScopedArrayPointer<qint32> bits(new qint32[imgWidth * imgHeight]); | - | ||||||||||||||||||||||||
| 470 | for (int i = 0; i < imgWidth * imgHeight
| 0 | ||||||||||||||||||||||||
| 471 | bits[i] = exteriorColor; never executed: bits[i] = exteriorColor; | 0 | ||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||
| 473 | const qreal angleStep = qreal(15 * 3.141592653589793238 / 180); | - | ||||||||||||||||||||||||
| 474 | const QPoint rotation(qRound(qCos(angleStep) * 0x4000), | - | ||||||||||||||||||||||||
| 475 | qRound(qSin(angleStep) * 0x4000)); | - | ||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||
| 477 | const quint32 *indices = pathIndices.data(); | - | ||||||||||||||||||||||||
| 478 | QVarLengthArray<QPoint> normals; | - | ||||||||||||||||||||||||
| 479 | QVarLengthArray<QPoint> vertices; | - | ||||||||||||||||||||||||
| 480 | QVarLengthArray<bool> isConvex; | - | ||||||||||||||||||||||||
| 481 | QVarLengthArray<bool> needsClipping; | - | ||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||
| 483 | drawPolygons(bits.data(), imgWidth, imgHeight, pathVertices.data(), | - | ||||||||||||||||||||||||
| 484 | indices, pathIndices.size(), interiorColor); | - | ||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||
| 486 | int index = 0; | - | ||||||||||||||||||||||||
| 487 | - | |||||||||||||||||||||||||
| 488 | while (index < pathIndices.size()
| 0 | ||||||||||||||||||||||||
| 489 | normals.clear(); | - | ||||||||||||||||||||||||
| 490 | vertices.clear(); | - | ||||||||||||||||||||||||
| 491 | needsClipping.clear(); | - | ||||||||||||||||||||||||
| 492 | - | |||||||||||||||||||||||||
| 493 | - | |||||||||||||||||||||||||
| 494 | int end = index; | - | ||||||||||||||||||||||||
| 495 | while (indices[end] != quint32(-1)
| 0 | ||||||||||||||||||||||||
| 496 | ++ never executed: end;++end;never executed: ++end; | 0 | ||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||
| 499 | for (int next = index, prev = end - 1; next < end
| 0 | ||||||||||||||||||||||||
| 500 | quint32 fromVertexIndex = indices[prev]; | - | ||||||||||||||||||||||||
| 501 | quint32 toVertexIndex = indices[next]; | - | ||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||
| 503 | const QPoint &from = pathVertices.at(fromVertexIndex); | - | ||||||||||||||||||||||||
| 504 | const QPoint &to = pathVertices.at(toVertexIndex); | - | ||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||
| 506 | QPoint n(to.y() - from.y(), from.x() - to.x()); | - | ||||||||||||||||||||||||
| 507 | if (n.x() == 0
| 0 | ||||||||||||||||||||||||
| 508 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 509 | int scale = qRound((offs << 16) / qSqrt(qreal(n.x()) * n.x() + qreal(n.y()) * n.y())); | - | ||||||||||||||||||||||||
| 510 | ((!(scale != 0)) ? qt_assert("scale != 0",__FILE__,554) : qt_noop()); | - | ||||||||||||||||||||||||
| 511 | - | |||||||||||||||||||||||||
| 512 | n.rx() = n.x() * scale >> 8; | - | ||||||||||||||||||||||||
| 513 | n.ry() = n.y() * scale >> 8; | - | ||||||||||||||||||||||||
| 514 | normals.append(n); | - | ||||||||||||||||||||||||
| 515 | QPoint v(to.x() + 0x7f, to.y() + 0x7f); | - | ||||||||||||||||||||||||
| 516 | vertices.append(v); | - | ||||||||||||||||||||||||
| 517 | needsClipping.append((to.x() < offs << 8) || (to.x() >= (imgWidth - offs) << 8) | - | ||||||||||||||||||||||||
| 518 | || (to.y() < offs << 8) || (to.y() >= (imgHeight - offs) << 8)); | - | ||||||||||||||||||||||||
| 519 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||
| 521 | isConvex.resize(normals.count()); | - | ||||||||||||||||||||||||
| 522 | for (int next = 0, prev = normals.count() - 1; next < normals.count()
| 0 | ||||||||||||||||||||||||
| 523 | isConvex[prev] = normals.at(prev).x() * normals.at(next).y() | - | ||||||||||||||||||||||||
| 524 | - normals.at(prev).y() * normals.at(next).x() < 0; | - | ||||||||||||||||||||||||
| 525 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 526 | - | |||||||||||||||||||||||||
| 527 | - | |||||||||||||||||||||||||
| 528 | for (int next = 0, prev = normals.count() - 1; next < normals.count()
| 0 | ||||||||||||||||||||||||
| 529 | QPoint n = normals.at(next); | - | ||||||||||||||||||||||||
| 530 | QPoint intPrev = vertices.at(prev); | - | ||||||||||||||||||||||||
| 531 | QPoint extPrev = vertices.at(prev); | - | ||||||||||||||||||||||||
| 532 | QPoint intNext = vertices.at(next); | - | ||||||||||||||||||||||||
| 533 | QPoint extNext = vertices.at(next); | - | ||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||
| 535 | extPrev.rx() -= n.x(); | - | ||||||||||||||||||||||||
| 536 | extPrev.ry() -= n.y(); | - | ||||||||||||||||||||||||
| 537 | intPrev.rx() += n.x(); | - | ||||||||||||||||||||||||
| 538 | intPrev.ry() += n.y(); | - | ||||||||||||||||||||||||
| 539 | extNext.rx() -= n.x(); | - | ||||||||||||||||||||||||
| 540 | extNext.ry() -= n.y(); | - | ||||||||||||||||||||||||
| 541 | intNext.rx() += n.x(); | - | ||||||||||||||||||||||||
| 542 | intNext.ry() += n.y(); | - | ||||||||||||||||||||||||
| 543 | - | |||||||||||||||||||||||||
| 544 | if (needsClipping[prev]
| 0 | ||||||||||||||||||||||||
| 545 | drawRectangle<Clip>(bits.data(), imgWidth, imgHeight, | - | ||||||||||||||||||||||||
| 546 | &intPrev, &vertices.at(prev), &extPrev, | - | ||||||||||||||||||||||||
| 547 | &intNext, &vertices.at(next), &extNext, | - | ||||||||||||||||||||||||
| 548 | exteriorColor); | - | ||||||||||||||||||||||||
| 549 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 550 | drawRectangle<NoClip>(bits.data(), imgWidth, imgHeight, | - | ||||||||||||||||||||||||
| 551 | &intPrev, &vertices.at(prev), &extPrev, | - | ||||||||||||||||||||||||
| 552 | &intNext, &vertices.at(next), &extNext, | - | ||||||||||||||||||||||||
| 553 | exteriorColor); | - | ||||||||||||||||||||||||
| 554 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 555 | - | |||||||||||||||||||||||||
| 556 | if (isConvex.at(prev)
| 0 | ||||||||||||||||||||||||
| 557 | QPoint p = extPrev; | - | ||||||||||||||||||||||||
| 558 | if (needsClipping[prev]
| 0 | ||||||||||||||||||||||||
| 559 | for (;;) { | - | ||||||||||||||||||||||||
| 560 | QPoint rn((n.x() * rotation.x() - n.y() * rotation.y()) >> 14, | - | ||||||||||||||||||||||||
| 561 | (n.y() * rotation.x() + n.x() * rotation.y()) >> 14); | - | ||||||||||||||||||||||||
| 562 | n = rn; | - | ||||||||||||||||||||||||
| 563 | if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() <= 0
| 0 | ||||||||||||||||||||||||
| 564 | p.rx() = vertices.at(prev).x() - normals.at(prev).x(); | - | ||||||||||||||||||||||||
| 565 | p.ry() = vertices.at(prev).y() - normals.at(prev).y(); | - | ||||||||||||||||||||||||
| 566 | drawTriangle<Clip>(bits.data(), imgWidth, imgHeight, &vertices.at(prev), | - | ||||||||||||||||||||||||
| 567 | &extPrev, &p, exteriorColor); | - | ||||||||||||||||||||||||
| 568 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 569 | } | - | ||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||
| 571 | p.rx() = vertices.at(prev).x() - n.x(); | - | ||||||||||||||||||||||||
| 572 | p.ry() = vertices.at(prev).y() - n.y(); | - | ||||||||||||||||||||||||
| 573 | drawTriangle<Clip>(bits.data(), imgWidth, imgHeight, &vertices.at(prev), | - | ||||||||||||||||||||||||
| 574 | &extPrev, &p, exteriorColor); | - | ||||||||||||||||||||||||
| 575 | extPrev = p; | - | ||||||||||||||||||||||||
| 576 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 577 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 578 | for (;;) { | - | ||||||||||||||||||||||||
| 579 | QPoint rn((n.x() * rotation.x() - n.y() * rotation.y()) >> 14, | - | ||||||||||||||||||||||||
| 580 | (n.y() * rotation.x() + n.x() * rotation.y()) >> 14); | - | ||||||||||||||||||||||||
| 581 | n = rn; | - | ||||||||||||||||||||||||
| 582 | if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() <= 0
| 0 | ||||||||||||||||||||||||
| 583 | p.rx() = vertices.at(prev).x() - normals.at(prev).x(); | - | ||||||||||||||||||||||||
| 584 | p.ry() = vertices.at(prev).y() - normals.at(prev).y(); | - | ||||||||||||||||||||||||
| 585 | drawTriangle<NoClip>(bits.data(), imgWidth, imgHeight, &vertices.at(prev), | - | ||||||||||||||||||||||||
| 586 | &extPrev, &p, exteriorColor); | - | ||||||||||||||||||||||||
| 587 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 588 | } | - | ||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||
| 590 | p.rx() = vertices.at(prev).x() - n.x(); | - | ||||||||||||||||||||||||
| 591 | p.ry() = vertices.at(prev).y() - n.y(); | - | ||||||||||||||||||||||||
| 592 | drawTriangle<NoClip>(bits.data(), imgWidth, imgHeight, &vertices.at(prev), | - | ||||||||||||||||||||||||
| 593 | &extPrev, &p, exteriorColor); | - | ||||||||||||||||||||||||
| 594 | extPrev = p; | - | ||||||||||||||||||||||||
| 595 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 596 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 597 | } else { | - | ||||||||||||||||||||||||
| 598 | QPoint p = intPrev; | - | ||||||||||||||||||||||||
| 599 | if (needsClipping[prev]
| 0 | ||||||||||||||||||||||||
| 600 | for (;;) { | - | ||||||||||||||||||||||||
| 601 | QPoint rn((n.x() * rotation.x() + n.y() * rotation.y()) >> 14, | - | ||||||||||||||||||||||||
| 602 | (n.y() * rotation.x() - n.x() * rotation.y()) >> 14); | - | ||||||||||||||||||||||||
| 603 | n = rn; | - | ||||||||||||||||||||||||
| 604 | if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() >= 0
| 0 | ||||||||||||||||||||||||
| 605 | p.rx() = vertices.at(prev).x() + normals.at(prev).x(); | - | ||||||||||||||||||||||||
| 606 | p.ry() = vertices.at(prev).y() + normals.at(prev).y(); | - | ||||||||||||||||||||||||
| 607 | drawTriangle<Clip>(bits.data(), imgWidth, imgHeight, &vertices.at(prev), | - | ||||||||||||||||||||||||
| 608 | &p, &intPrev, interiorColor); | - | ||||||||||||||||||||||||
| 609 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 610 | } | - | ||||||||||||||||||||||||
| 611 | - | |||||||||||||||||||||||||
| 612 | p.rx() = vertices.at(prev).x() + n.x(); | - | ||||||||||||||||||||||||
| 613 | p.ry() = vertices.at(prev).y() + n.y(); | - | ||||||||||||||||||||||||
| 614 | drawTriangle<Clip>(bits.data(), imgWidth, imgHeight, &vertices.at(prev), | - | ||||||||||||||||||||||||
| 615 | &p, &intPrev, interiorColor); | - | ||||||||||||||||||||||||
| 616 | intPrev = p; | - | ||||||||||||||||||||||||
| 617 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 618 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 619 | for (;;) { | - | ||||||||||||||||||||||||
| 620 | QPoint rn((n.x() * rotation.x() + n.y() * rotation.y()) >> 14, | - | ||||||||||||||||||||||||
| 621 | (n.y() * rotation.x() - n.x() * rotation.y()) >> 14); | - | ||||||||||||||||||||||||
| 622 | n = rn; | - | ||||||||||||||||||||||||
| 623 | if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() >= 0
| 0 | ||||||||||||||||||||||||
| 624 | p.rx() = vertices.at(prev).x() + normals.at(prev).x(); | - | ||||||||||||||||||||||||
| 625 | p.ry() = vertices.at(prev).y() + normals.at(prev).y(); | - | ||||||||||||||||||||||||
| 626 | drawTriangle<NoClip>(bits.data(), imgWidth, imgHeight, &vertices.at(prev), | - | ||||||||||||||||||||||||
| 627 | &p, &intPrev, interiorColor); | - | ||||||||||||||||||||||||
| 628 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 629 | } | - | ||||||||||||||||||||||||
| 630 | - | |||||||||||||||||||||||||
| 631 | p.rx() = vertices.at(prev).x() + n.x(); | - | ||||||||||||||||||||||||
| 632 | p.ry() = vertices.at(prev).y() + n.y(); | - | ||||||||||||||||||||||||
| 633 | drawTriangle<NoClip>(bits.data(), imgWidth, imgHeight, &vertices.at(prev), | - | ||||||||||||||||||||||||
| 634 | &p, &intPrev, interiorColor); | - | ||||||||||||||||||||||||
| 635 | intPrev = p; | - | ||||||||||||||||||||||||
| 636 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 637 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 638 | } | - | ||||||||||||||||||||||||
| 639 | } | - | ||||||||||||||||||||||||
| 640 | - | |||||||||||||||||||||||||
| 641 | index = end + 1; | - | ||||||||||||||||||||||||
| 642 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 643 | - | |||||||||||||||||||||||||
| 644 | const qint32 *inLine = bits.data(); | - | ||||||||||||||||||||||||
| 645 | uchar *outLine = data->data; | - | ||||||||||||||||||||||||
| 646 | for (int y = 0; y < imgHeight
| 0 | ||||||||||||||||||||||||
| 647 | for (int x = 0; x < imgWidth
| 0 | ||||||||||||||||||||||||
| 648 | * never executed: outLine = uchar((0x7f80 - *inLine) >> 8);*outLine = uchar((0x7f80 - *inLine) >> 8);never executed: *outLine = uchar((0x7f80 - *inLine) >> 8); | 0 | ||||||||||||||||||||||||
| 649 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 650 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||
| 652 | static bool imageHasNarrowOutlines(const QImage &im) | - | ||||||||||||||||||||||||
| 653 | { | - | ||||||||||||||||||||||||
| 654 | if (im.isNull()
| 0 | ||||||||||||||||||||||||
| 655 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 656 | else if (im.width() == 1
| 0 | ||||||||||||||||||||||||
| 657 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 658 | - | |||||||||||||||||||||||||
| 659 | int minHThick = 999; | - | ||||||||||||||||||||||||
| 660 | int minVThick = 999; | - | ||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||
| 662 | int thick = 0; | - | ||||||||||||||||||||||||
| 663 | bool in = false; | - | ||||||||||||||||||||||||
| 664 | int y = (im.height() + 1) / 2; | - | ||||||||||||||||||||||||
| 665 | for (int x = 0; x < im.width()
| 0 | ||||||||||||||||||||||||
| 666 | int a = qAlpha(im.pixel(x, y)); | - | ||||||||||||||||||||||||
| 667 | if (a > 127
| 0 | ||||||||||||||||||||||||
| 668 | in = true; | - | ||||||||||||||||||||||||
| 669 | ++thick; | - | ||||||||||||||||||||||||
| 670 | } never executed: else if (inend of block
| 0 | ||||||||||||||||||||||||
| 671 | in = false; | - | ||||||||||||||||||||||||
| 672 | minHThick = qMin(minHThick, thick); | - | ||||||||||||||||||||||||
| 673 | thick = 0; | - | ||||||||||||||||||||||||
| 674 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 675 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||
| 677 | thick = 0; | - | ||||||||||||||||||||||||
| 678 | in = false; | - | ||||||||||||||||||||||||
| 679 | int x = (im.width() + 1) / 2; | - | ||||||||||||||||||||||||
| 680 | for (int y = 0; y < im.height()
| 0 | ||||||||||||||||||||||||
| 681 | int a = qAlpha(im.pixel(x, y)); | - | ||||||||||||||||||||||||
| 682 | if (a > 127
| 0 | ||||||||||||||||||||||||
| 683 | in = true; | - | ||||||||||||||||||||||||
| 684 | ++thick; | - | ||||||||||||||||||||||||
| 685 | } never executed: else if (inend of block
| 0 | ||||||||||||||||||||||||
| 686 | in = false; | - | ||||||||||||||||||||||||
| 687 | minVThick = qMin(minVThick, thick); | - | ||||||||||||||||||||||||
| 688 | thick = 0; | - | ||||||||||||||||||||||||
| 689 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 690 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 691 | - | |||||||||||||||||||||||||
| 692 | return never executed: minHThick == 1 || minVThick == 1;return minHThick == 1 || minVThick == 1;never executed: return minHThick == 1 || minVThick == 1; | 0 | ||||||||||||||||||||||||
| 693 | } | - | ||||||||||||||||||||||||
| 694 | - | |||||||||||||||||||||||||
| 695 | bool qt_fontHasNarrowOutlines(QFontEngine *fontEngine) | - | ||||||||||||||||||||||||
| 696 | { | - | ||||||||||||||||||||||||
| 697 | QFontEngine *fe = fontEngine->cloneWithSize(54); | - | ||||||||||||||||||||||||
| 698 | if (!fe
| 0 | ||||||||||||||||||||||||
| 699 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||
| 701 | QImage im; | - | ||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | const glyph_t glyph = fe->glyphIndex('O'); | - | ||||||||||||||||||||||||
| 704 | if (glyph != 0
| 0 | ||||||||||||||||||||||||
| 705 | im = fe->alphaMapForGlyph(glyph, QFixed(), QTransform()); never executed: im = fe->alphaMapForGlyph(glyph, QFixed(), QTransform()); | 0 | ||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||
| 707 | ((!(fe->ref.load() == 0)) ? qt_assert("fe->ref.load() == 0",__FILE__,751) : qt_noop()); | - | ||||||||||||||||||||||||
| 708 | delete fe; | - | ||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | return never executed: imageHasNarrowOutlines(im);return imageHasNarrowOutlines(im);never executed: return imageHasNarrowOutlines(im); | 0 | ||||||||||||||||||||||||
| 711 | } | - | ||||||||||||||||||||||||
| 712 | - | |||||||||||||||||||||||||
| 713 | bool qt_fontHasNarrowOutlines(const QRawFont &f) | - | ||||||||||||||||||||||||
| 714 | { | - | ||||||||||||||||||||||||
| 715 | QRawFont font = f; | - | ||||||||||||||||||||||||
| 716 | font.setPixelSize(54); | - | ||||||||||||||||||||||||
| 717 | if (!font.isValid()
| 0 | ||||||||||||||||||||||||
| 718 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 719 | - | |||||||||||||||||||||||||
| 720 | QVector<quint32> glyphIndices = font.glyphIndexesForString(QLatin1String("O")); | - | ||||||||||||||||||||||||
| 721 | if (glyphIndices.isEmpty()
| 0 | ||||||||||||||||||||||||
| 722 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 723 | - | |||||||||||||||||||||||||
| 724 | return never executed: imageHasNarrowOutlines(font.alphaMapForGlyph(glyphIndices.at(0),return imageHasNarrowOutlines(font.alphaMapForGlyph(glyphIndices.at(0), QRawFont::PixelAntialiasing));never executed: return imageHasNarrowOutlines(font.alphaMapForGlyph(glyphIndices.at(0), QRawFont::PixelAntialiasing)); | 0 | ||||||||||||||||||||||||
| 725 | QRawFont::PixelAntialiasing)); never executed: return imageHasNarrowOutlines(font.alphaMapForGlyph(glyphIndices.at(0), QRawFont::PixelAntialiasing)); | 0 | ||||||||||||||||||||||||
| 726 | } | - | ||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||
| 729 | QDistanceFieldData::QDistanceFieldData(const QDistanceFieldData &other) | - | ||||||||||||||||||||||||
| 730 | : QSharedData(other) | - | ||||||||||||||||||||||||
| 731 | , glyph(other.glyph) | - | ||||||||||||||||||||||||
| 732 | , width(other.width) | - | ||||||||||||||||||||||||
| 733 | , height(other.height) | - | ||||||||||||||||||||||||
| 734 | , nbytes(other.nbytes) | - | ||||||||||||||||||||||||
| 735 | { | - | ||||||||||||||||||||||||
| 736 | if (nbytes
| 0 | ||||||||||||||||||||||||
| 737 | data = (uchar *)memcpy(malloc(nbytes), other.data, nbytes); never executed: data = (uchar *)memcpy(malloc(nbytes), other.data, nbytes); | 0 | ||||||||||||||||||||||||
| 738 | else | - | ||||||||||||||||||||||||
| 739 | data = 0; never executed: data = 0; | 0 | ||||||||||||||||||||||||
| 740 | } | - | ||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||
| 742 | QDistanceFieldData::~QDistanceFieldData() | - | ||||||||||||||||||||||||
| 743 | { | - | ||||||||||||||||||||||||
| 744 | free(data); | - | ||||||||||||||||||||||||
| 745 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||
| 747 | QDistanceFieldData *QDistanceFieldData::create(const QSize &size) | - | ||||||||||||||||||||||||
| 748 | { | - | ||||||||||||||||||||||||
| 749 | QDistanceFieldData *data = new QDistanceFieldData; | - | ||||||||||||||||||||||||
| 750 | - | |||||||||||||||||||||||||
| 751 | if (size.isValid()
| 0 | ||||||||||||||||||||||||
| 752 | data->width = size.width(); | - | ||||||||||||||||||||||||
| 753 | data->height = size.height(); | - | ||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||
| 755 | data->nbytes = data->width * data->height; | - | ||||||||||||||||||||||||
| 756 | data->data = (uchar *)malloc(data->nbytes); | - | ||||||||||||||||||||||||
| 757 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 758 | - | |||||||||||||||||||||||||
| 759 | return never executed: data;return data;never executed: return data; | 0 | ||||||||||||||||||||||||
| 760 | } | - | ||||||||||||||||||||||||
| 761 | - | |||||||||||||||||||||||||
| 762 | QDistanceFieldData *QDistanceFieldData::create(const QPainterPath &path, bool doubleResolution) | - | ||||||||||||||||||||||||
| 763 | { | - | ||||||||||||||||||||||||
| 764 | int dfMargin = (doubleResolution
| 0 | ||||||||||||||||||||||||
| 765 | int glyphWidth = qCeil(path.boundingRect().width() / (doubleResolution ? 16 / 2 : 16)) + dfMargin * 2; | - | ||||||||||||||||||||||||
| 766 | int glyphHeight = qCeil(path.boundingRect().height() / (doubleResolution ? 16 / 2 : 16)) + dfMargin * 2; | - | ||||||||||||||||||||||||
| 767 | - | |||||||||||||||||||||||||
| 768 | QDistanceFieldData *data = create(QSize(glyphWidth, glyphHeight)); | - | ||||||||||||||||||||||||
| 769 | - | |||||||||||||||||||||||||
| 770 | makeDistanceField(data, | - | ||||||||||||||||||||||||
| 771 | path, | - | ||||||||||||||||||||||||
| 772 | (doubleResolution ? 16 / 2 : 16), | - | ||||||||||||||||||||||||
| 773 | (doubleResolution ? 80 / 2 : 80) / (doubleResolution ? 16 / 2 : 16)); | - | ||||||||||||||||||||||||
| 774 | return never executed: data;return data;never executed: return data; | 0 | ||||||||||||||||||||||||
| 775 | } | - | ||||||||||||||||||||||||
| 776 | - | |||||||||||||||||||||||||
| 777 | - | |||||||||||||||||||||||||
| 778 | QDistanceField::QDistanceField() | - | ||||||||||||||||||||||||
| 779 | : d(new QDistanceFieldData) | - | ||||||||||||||||||||||||
| 780 | { | - | ||||||||||||||||||||||||
| 781 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 782 | - | |||||||||||||||||||||||||
| 783 | QDistanceField::QDistanceField(int width, int height) | - | ||||||||||||||||||||||||
| 784 | : d(QDistanceFieldData::create(QSize(width, height))) | - | ||||||||||||||||||||||||
| 785 | { | - | ||||||||||||||||||||||||
| 786 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 787 | - | |||||||||||||||||||||||||
| 788 | QDistanceField::QDistanceField(const QDistanceField &other) | - | ||||||||||||||||||||||||
| 789 | { | - | ||||||||||||||||||||||||
| 790 | d = other.d; | - | ||||||||||||||||||||||||
| 791 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 792 | - | |||||||||||||||||||||||||
| 793 | QDistanceField::QDistanceField(const QRawFont &font, glyph_t glyph, bool doubleResolution) | - | ||||||||||||||||||||||||
| 794 | { | - | ||||||||||||||||||||||||
| 795 | setGlyph(font, glyph, doubleResolution); | - | ||||||||||||||||||||||||
| 796 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||
| 798 | QDistanceField::QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution) | - | ||||||||||||||||||||||||
| 799 | { | - | ||||||||||||||||||||||||
| 800 | setGlyph(fontEngine, glyph, doubleResolution); | - | ||||||||||||||||||||||||
| 801 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 802 | - | |||||||||||||||||||||||||
| 803 | QDistanceField::QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution) | - | ||||||||||||||||||||||||
| 804 | { | - | ||||||||||||||||||||||||
| 805 | QPainterPath dfPath = path; | - | ||||||||||||||||||||||||
| 806 | dfPath.translate(-dfPath.boundingRect().topLeft()); | - | ||||||||||||||||||||||||
| 807 | dfPath.setFillRule(Qt::WindingFill); | - | ||||||||||||||||||||||||
| 808 | - | |||||||||||||||||||||||||
| 809 | d = QDistanceFieldData::create(dfPath, doubleResolution); | - | ||||||||||||||||||||||||
| 810 | d->glyph = glyph; | - | ||||||||||||||||||||||||
| 811 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 812 | - | |||||||||||||||||||||||||
| 813 | - | |||||||||||||||||||||||||
| 814 | QDistanceField::QDistanceField(QDistanceFieldData *data) | - | ||||||||||||||||||||||||
| 815 | : d(data) | - | ||||||||||||||||||||||||
| 816 | { | - | ||||||||||||||||||||||||
| 817 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||
| 819 | bool QDistanceField::isNull() const | - | ||||||||||||||||||||||||
| 820 | { | - | ||||||||||||||||||||||||
| 821 | return never executed: !d->data;return !d->data;never executed: return !d->data; | 0 | ||||||||||||||||||||||||
| 822 | } | - | ||||||||||||||||||||||||
| 823 | - | |||||||||||||||||||||||||
| 824 | glyph_t QDistanceField::glyph() const | - | ||||||||||||||||||||||||
| 825 | { | - | ||||||||||||||||||||||||
| 826 | return never executed: d->glyph;return d->glyph;never executed: return d->glyph; | 0 | ||||||||||||||||||||||||
| 827 | } | - | ||||||||||||||||||||||||
| 828 | - | |||||||||||||||||||||||||
| 829 | void QDistanceField::setGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution) | - | ||||||||||||||||||||||||
| 830 | { | - | ||||||||||||||||||||||||
| 831 | QRawFont renderFont = font; | - | ||||||||||||||||||||||||
| 832 | renderFont.setPixelSize((doubleResolution ? 54 * 2 : 54) * (doubleResolution ? 16 / 2 : 16)); | - | ||||||||||||||||||||||||
| 833 | - | |||||||||||||||||||||||||
| 834 | QPainterPath path = renderFont.pathForGlyph(glyph); | - | ||||||||||||||||||||||||
| 835 | path.translate(-path.boundingRect().topLeft()); | - | ||||||||||||||||||||||||
| 836 | path.setFillRule(Qt::WindingFill); | - | ||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||
| 838 | d = QDistanceFieldData::create(path, doubleResolution); | - | ||||||||||||||||||||||||
| 839 | d->glyph = glyph; | - | ||||||||||||||||||||||||
| 840 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 841 | - | |||||||||||||||||||||||||
| 842 | void QDistanceField::setGlyph(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution) | - | ||||||||||||||||||||||||
| 843 | { | - | ||||||||||||||||||||||||
| 844 | QFixedPoint position; | - | ||||||||||||||||||||||||
| 845 | QPainterPath path; | - | ||||||||||||||||||||||||
| 846 | fontEngine->addGlyphsToPath(&glyph, &position, 1, &path, 0); | - | ||||||||||||||||||||||||
| 847 | path.translate(-path.boundingRect().topLeft()); | - | ||||||||||||||||||||||||
| 848 | path.setFillRule(Qt::WindingFill); | - | ||||||||||||||||||||||||
| 849 | - | |||||||||||||||||||||||||
| 850 | d = QDistanceFieldData::create(path, doubleResolution); | - | ||||||||||||||||||||||||
| 851 | d->glyph = glyph; | - | ||||||||||||||||||||||||
| 852 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 853 | - | |||||||||||||||||||||||||
| 854 | int QDistanceField::width() const | - | ||||||||||||||||||||||||
| 855 | { | - | ||||||||||||||||||||||||
| 856 | return never executed: d->width;return d->width;never executed: return d->width; | 0 | ||||||||||||||||||||||||
| 857 | } | - | ||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||
| 859 | int QDistanceField::height() const | - | ||||||||||||||||||||||||
| 860 | { | - | ||||||||||||||||||||||||
| 861 | return never executed: d->height;return d->height;never executed: return d->height; | 0 | ||||||||||||||||||||||||
| 862 | } | - | ||||||||||||||||||||||||
| 863 | - | |||||||||||||||||||||||||
| 864 | QDistanceField QDistanceField::copy(const QRect &r) const | - | ||||||||||||||||||||||||
| 865 | { | - | ||||||||||||||||||||||||
| 866 | if (isNull()
| 0 | ||||||||||||||||||||||||
| 867 | return never executed: QDistanceField();return QDistanceField();never executed: return QDistanceField(); | 0 | ||||||||||||||||||||||||
| 868 | - | |||||||||||||||||||||||||
| 869 | if (r.isNull()
| 0 | ||||||||||||||||||||||||
| 870 | return never executed: QDistanceField(new QDistanceFieldData(*d));return QDistanceField(new QDistanceFieldData(*d));never executed: return QDistanceField(new QDistanceFieldData(*d)); | 0 | ||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||
| 872 | int x = r.x(); | - | ||||||||||||||||||||||||
| 873 | int y = r.y(); | - | ||||||||||||||||||||||||
| 874 | int w = r.width(); | - | ||||||||||||||||||||||||
| 875 | int h = r.height(); | - | ||||||||||||||||||||||||
| 876 | - | |||||||||||||||||||||||||
| 877 | int dx = 0; | - | ||||||||||||||||||||||||
| 878 | int dy = 0; | - | ||||||||||||||||||||||||
| 879 | if (w <= 0
| 0 | ||||||||||||||||||||||||
| 880 | return never executed: QDistanceField();return QDistanceField();never executed: return QDistanceField(); | 0 | ||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||
| 882 | QDistanceField df(w, h); | - | ||||||||||||||||||||||||
| 883 | if (df.isNull()
| 0 | ||||||||||||||||||||||||
| 884 | return never executed: df;return df;never executed: return df; | 0 | ||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||
| 886 | if (x < 0
| 0 | ||||||||||||||||||||||||
| 887 | memset(df.d->data, 0, df.d->nbytes); | - | ||||||||||||||||||||||||
| 888 | if (x < 0
| 0 | ||||||||||||||||||||||||
| 889 | dx = -x; | - | ||||||||||||||||||||||||
| 890 | x = 0; | - | ||||||||||||||||||||||||
| 891 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 892 | if (y < 0
| 0 | ||||||||||||||||||||||||
| 893 | dy = -y; | - | ||||||||||||||||||||||||
| 894 | y = 0; | - | ||||||||||||||||||||||||
| 895 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 896 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 897 | - | |||||||||||||||||||||||||
| 898 | int pixels_to_copy = qMax(w - dx, 0); | - | ||||||||||||||||||||||||
| 899 | if (x > d->width
| 0 | ||||||||||||||||||||||||
| 900 | pixels_to_copy = 0; never executed: pixels_to_copy = 0; | 0 | ||||||||||||||||||||||||
| 901 | else if (pixels_to_copy > d->width - x
| 0 | ||||||||||||||||||||||||
| 902 | pixels_to_copy = d->width - x; never executed: pixels_to_copy = d->width - x; | 0 | ||||||||||||||||||||||||
| 903 | int lines_to_copy = qMax(h - dy, 0); | - | ||||||||||||||||||||||||
| 904 | if (y > d->height
| 0 | ||||||||||||||||||||||||
| 905 | lines_to_copy = 0; never executed: lines_to_copy = 0; | 0 | ||||||||||||||||||||||||
| 906 | else if (lines_to_copy > d->height - y
| 0 | ||||||||||||||||||||||||
| 907 | lines_to_copy = d->height - y; never executed: lines_to_copy = d->height - y; | 0 | ||||||||||||||||||||||||
| 908 | - | |||||||||||||||||||||||||
| 909 | const uchar *src = d->data + x + y * d->width; | - | ||||||||||||||||||||||||
| 910 | uchar *dest = df.d->data + dx + dy * df.d->width; | - | ||||||||||||||||||||||||
| 911 | for (int i = 0; i < lines_to_copy
| 0 | ||||||||||||||||||||||||
| 912 | memcpy(dest, src, pixels_to_copy); | - | ||||||||||||||||||||||||
| 913 | src += d->width; | - | ||||||||||||||||||||||||
| 914 | dest += df.d->width; | - | ||||||||||||||||||||||||
| 915 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 916 | - | |||||||||||||||||||||||||
| 917 | df.d->glyph = d->glyph; | - | ||||||||||||||||||||||||
| 918 | - | |||||||||||||||||||||||||
| 919 | return never executed: df;return df;never executed: return df; | 0 | ||||||||||||||||||||||||
| 920 | } | - | ||||||||||||||||||||||||
| 921 | - | |||||||||||||||||||||||||
| 922 | uchar *QDistanceField::bits() | - | ||||||||||||||||||||||||
| 923 | { | - | ||||||||||||||||||||||||
| 924 | return never executed: d->data;return d->data;never executed: return d->data; | 0 | ||||||||||||||||||||||||
| 925 | } | - | ||||||||||||||||||||||||
| 926 | - | |||||||||||||||||||||||||
| 927 | const uchar *QDistanceField::bits() const | - | ||||||||||||||||||||||||
| 928 | { | - | ||||||||||||||||||||||||
| 929 | return never executed: d->data;return d->data;never executed: return d->data; | 0 | ||||||||||||||||||||||||
| 930 | } | - | ||||||||||||||||||||||||
| 931 | - | |||||||||||||||||||||||||
| 932 | const uchar *QDistanceField::constBits() const | - | ||||||||||||||||||||||||
| 933 | { | - | ||||||||||||||||||||||||
| 934 | return never executed: d->data;return d->data;never executed: return d->data; | 0 | ||||||||||||||||||||||||
| 935 | } | - | ||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||
| 937 | uchar *QDistanceField::scanLine(int i) | - | ||||||||||||||||||||||||
| 938 | { | - | ||||||||||||||||||||||||
| 939 | if (isNull()
| 0 | ||||||||||||||||||||||||
| 940 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 941 | - | |||||||||||||||||||||||||
| 942 | ((!(i >= 0 && i < d->height)) ? qt_assert("i >= 0 && i < d->height",__FILE__,986) : qt_noop()); | - | ||||||||||||||||||||||||
| 943 | return never executed: d->data + i * d->width;return d->data + i * d->width;never executed: return d->data + i * d->width; | 0 | ||||||||||||||||||||||||
| 944 | } | - | ||||||||||||||||||||||||
| 945 | - | |||||||||||||||||||||||||
| 946 | const uchar *QDistanceField::scanLine(int i) const | - | ||||||||||||||||||||||||
| 947 | { | - | ||||||||||||||||||||||||
| 948 | if (isNull()
| 0 | ||||||||||||||||||||||||
| 949 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 950 | - | |||||||||||||||||||||||||
| 951 | ((!(i >= 0 && i < d->height)) ? qt_assert("i >= 0 && i < d->height",__FILE__,995) : qt_noop()); | - | ||||||||||||||||||||||||
| 952 | return never executed: d->data + i * d->width;return d->data + i * d->width;never executed: return d->data + i * d->width; | 0 | ||||||||||||||||||||||||
| 953 | } | - | ||||||||||||||||||||||||
| 954 | - | |||||||||||||||||||||||||
| 955 | const uchar *QDistanceField::constScanLine(int i) const | - | ||||||||||||||||||||||||
| 956 | { | - | ||||||||||||||||||||||||
| 957 | if (isNull()
| 0 | ||||||||||||||||||||||||
| 958 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 959 | - | |||||||||||||||||||||||||
| 960 | ((!(i >= 0 && i < d->height)) ? qt_assert("i >= 0 && i < d->height",__FILE__,1004) : qt_noop()); | - | ||||||||||||||||||||||||
| 961 | return never executed: d->data + i * d->width;return d->data + i * d->width;never executed: return d->data + i * d->width; | 0 | ||||||||||||||||||||||||
| 962 | } | - | ||||||||||||||||||||||||
| 963 | - | |||||||||||||||||||||||||
| 964 | QImage QDistanceField::toImage(QImage::Format format) const | - | ||||||||||||||||||||||||
| 965 | { | - | ||||||||||||||||||||||||
| 966 | if (isNull()
| 0 | ||||||||||||||||||||||||
| 967 | return never executed: QImage();return QImage();never executed: return QImage(); | 0 | ||||||||||||||||||||||||
| 968 | - | |||||||||||||||||||||||||
| 969 | QImage image(d->width, d->height, qt_depthForFormat(format) == 8 ? | - | ||||||||||||||||||||||||
| 970 | format : QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||||||||
| 971 | if (image.isNull()
| 0 | ||||||||||||||||||||||||
| 972 | return never executed: image;return image;never executed: return image; | 0 | ||||||||||||||||||||||||
| 973 | - | |||||||||||||||||||||||||
| 974 | if (image.depth() == 8
| 0 | ||||||||||||||||||||||||
| 975 | for (int y = 0; y < d->height
| 0 | ||||||||||||||||||||||||
| 976 | memcpy(image.scanLine(y), scanLine(y), d->width); never executed: memcpy(image.scanLine(y), scanLine(y), d->width); | 0 | ||||||||||||||||||||||||
| 977 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 978 | for (int y = 0; y < d->height
| 0 | ||||||||||||||||||||||||
| 979 | for (int x = 0; x < d->width
| 0 | ||||||||||||||||||||||||
| 980 | uint alpha = *(d->data + x + y * d->width); | - | ||||||||||||||||||||||||
| 981 | image.setPixel(x, y, alpha << 24); | - | ||||||||||||||||||||||||
| 982 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 983 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 984 | - | |||||||||||||||||||||||||
| 985 | if (image.format() != format
| 0 | ||||||||||||||||||||||||
| 986 | image = image.convertToFormat(format); never executed: image = image.convertToFormat(format); | 0 | ||||||||||||||||||||||||
| 987 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 988 | - | |||||||||||||||||||||||||
| 989 | return never executed: image;return image;never executed: return image; | 0 | ||||||||||||||||||||||||
| 990 | } | - | ||||||||||||||||||||||||
| 991 | - | |||||||||||||||||||||||||
| 992 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |