painting/qmemrotate.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5static const int tileSize = 32; -
6template <class T> -
7static __attribute__((always_inline)) -
8inline void qt_memrotate90_cachedRead(const T *src, int w, int h, int sstride, T *dest, -
9 int dstride) -
10{ -
11 const char *s = reinterpret_cast<const char*>(src); -
12 char *d = reinterpret_cast<char*>(dest); -
13 for (int y = 0; y < h; ++y) {
never evaluated: y < h
0
14 for (int x = w - 1; x >= 0; --x) {
never evaluated: x >= 0
0
15 T *destline = reinterpret_cast<T *>(d + (w - x - 1) * dstride); -
16 destline[y] = src[x]; -
17 }
never executed: }
0
18 s += sstride; -
19 src = reinterpret_cast<const T*>(s); -
20 }
never executed: }
0
21}
never executed: }
0
22 -
23template <class T> -
24static __attribute__((always_inline)) -
25inline void qt_memrotate270_cachedRead(const T *src, int w, int h, int sstride, T *dest, -
26 int dstride) -
27{ -
28 const char *s = reinterpret_cast<const char*>(src); -
29 char *d = reinterpret_cast<char*>(dest); -
30 s += (h - 1) * sstride; -
31 for (int y = h - 1; y >= 0; --y) {
never evaluated: y >= 0
0
32 src = reinterpret_cast<const T*>(s); -
33 for (int x = 0; x < w; ++x) {
never evaluated: x < w
0
34 T *destline = reinterpret_cast<T *>(d + x * dstride); -
35 destline[h - y - 1] = src[x]; -
36 }
never executed: }
0
37 s -= sstride; -
38 }
never executed: }
0
39}
never executed: }
0
40template <class T> -
41static __attribute__((always_inline)) -
42inline void qt_memrotate90_tiled(const T *src, int w, int h, int sstride, T *dest, int dstride) -
43{ -
44 sstride /= sizeof(T); -
45 dstride /= sizeof(T); -
46 -
47 const int pack = sizeof(quint32) / sizeof(T); -
48 const int unaligned = -
49 qMin(uint((quintptr(dest) & (sizeof(quint32)-1)) / sizeof(T)), uint(h)); -
50 const int restX = w % tileSize; -
51 const int restY = (h - unaligned) % tileSize; -
52 const int unoptimizedY = restY % pack; -
53 const int numTilesX = w / tileSize + (restX > 0); -
54 const int numTilesY = (h - unaligned) / tileSize + (restY >= pack); -
55 -
56 for (int tx = 0; tx < numTilesX; ++tx) {
evaluated: tx < numTilesX
TRUEFALSE
yes
Evaluation Count:127
yes
Evaluation Count:36
36-127
57 const int startx = w - tx * tileSize - 1; -
58 const int stopx = qMax(startx - tileSize, 0); -
59 -
60 if (unaligned) {
partially evaluated: unaligned
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127
0-127
61 for (int x = startx; x >= stopx; --x) {
never evaluated: x >= stopx
0
62 T *d = dest + (w - x - 1) * dstride; -
63 for (int y = 0; y < unaligned; ++y) {
never evaluated: y < unaligned
0
64 *d++ = src[y * sstride + x]; -
65 }
never executed: }
0
66 }
never executed: }
0
67 }
never executed: }
0
68 -
69 for (int ty = 0; ty < numTilesY; ++ty) {
evaluated: ty < numTilesY
TRUEFALSE
yes
Evaluation Count:547
yes
Evaluation Count:127
127-547
70 const int starty = ty * tileSize + unaligned; -
71 const int stopy = qMin(starty + tileSize, h - unoptimizedY); -
72 -
73 for (int x = startx; x >= stopx; --x) {
evaluated: x >= stopx
TRUEFALSE
yes
Evaluation Count:16678
yes
Evaluation Count:547
547-16678
74 quint32 *d = reinterpret_cast<quint32*>(dest + (w - x - 1) * dstride + starty); -
75 for (int y = starty; y < stopy; y += pack) {
evaluated: y < stopy
TRUEFALSE
yes
Evaluation Count:478676
yes
Evaluation Count:16678
16678-478676
76 quint32 c = src[y * sstride + x]; -
77 for (int i = 1; i < pack; ++i) {
evaluated: i < pack
TRUEFALSE
yes
Evaluation Count:5112
yes
Evaluation Count:478676
5112-478676
78 const int shift = (sizeof(int) * 8 / pack * i); -
79 const T color = src[(y + i) * sstride + x]; -
80 c |= color << shift; -
81 }
executed: }
Execution Count:5112
5112
82 *d++ = c; -
83 }
executed: }
Execution Count:478676
478676
84 }
executed: }
Execution Count:16678
16678
85 }
executed: }
Execution Count:547
547
86 -
87 if (unoptimizedY) {
evaluated: unoptimizedY
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:113
14-113
88 const int starty = h - unoptimizedY; -
89 for (int x = startx; x >= stopx; --x) {
evaluated: x >= stopx
TRUEFALSE
yes
Evaluation Count:356
yes
Evaluation Count:14
14-356
90 T *d = dest + (w - x - 1) * dstride + starty; -
91 for (int y = starty; y < h; ++y) {
evaluated: y < h
TRUEFALSE
yes
Evaluation Count:382
yes
Evaluation Count:356
356-382
92 *d++ = src[y * sstride + x]; -
93 }
executed: }
Execution Count:382
382
94 }
executed: }
Execution Count:356
356
95 }
executed: }
Execution Count:14
14
96 }
executed: }
Execution Count:127
127
97}
executed: }
Execution Count:36
36
98 -
99template <class T> -
100static __attribute__((always_inline)) -
101inline void qt_memrotate90_tiled_unpacked(const T *src, int w, int h, int sstride, T *dest, -
102 int dstride) -
103{ -
104 const int numTilesX = (w + tileSize - 1) / tileSize; -
105 const int numTilesY = (h + tileSize - 1) / tileSize; -
106 -
107 for (int tx = 0; tx < numTilesX; ++tx) {
evaluated: tx < numTilesX
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:16
16-24
108 const int startx = w - tx * tileSize - 1; -
109 const int stopx = qMax(startx - tileSize, 0); -
110 -
111 for (int ty = 0; ty < numTilesY; ++ty) {
evaluated: ty < numTilesY
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:24
24-32
112 const int starty = ty * tileSize; -
113 const int stopy = qMin(starty + tileSize, h); -
114 -
115 for (int x = startx; x >= stopx; --x) {
evaluated: x >= stopx
TRUEFALSE
yes
Evaluation Count:648
yes
Evaluation Count:32
32-648
116 T *d = (T *)((char*)dest + (w - x - 1) * dstride) + starty; -
117 const char *s = (const char*)(src + x) + starty * sstride; -
118 for (int y = starty; y < stopy; ++y) {
evaluated: y < stopy
TRUEFALSE
yes
Evaluation Count:11336
yes
Evaluation Count:648
648-11336
119 *d++ = *(const T *)(s); -
120 s += sstride; -
121 }
executed: }
Execution Count:11336
11336
122 }
executed: }
Execution Count:648
648
123 }
executed: }
Execution Count:32
32
124 }
executed: }
Execution Count:24
24
125}
executed: }
Execution Count:16
16
126 -
127template <class T> -
128static __attribute__((always_inline)) -
129inline void qt_memrotate270_tiled(const T *src, int w, int h, int sstride, T *dest, int dstride) -
130{ -
131 sstride /= sizeof(T); -
132 dstride /= sizeof(T); -
133 -
134 const int pack = sizeof(quint32) / sizeof(T); -
135 const int unaligned = -
136 qMin(uint((long(dest) & (sizeof(quint32)-1)) / sizeof(T)), uint(h)); -
137 const int restX = w % tileSize; -
138 const int restY = (h - unaligned) % tileSize; -
139 const int unoptimizedY = restY % pack; -
140 const int numTilesX = w / tileSize + (restX > 0); -
141 const int numTilesY = (h - unaligned) / tileSize + (restY >= pack); -
142 -
143 for (int tx = 0; tx < numTilesX; ++tx) {
never evaluated: tx < numTilesX
0
144 const int startx = tx * tileSize; -
145 const int stopx = qMin(startx + tileSize, w); -
146 -
147 if (unaligned) {
never evaluated: unaligned
0
148 for (int x = startx; x < stopx; ++x) {
never evaluated: x < stopx
0
149 T *d = dest + x * dstride; -
150 for (int y = h - 1; y >= h - unaligned; --y) {
never evaluated: y >= h - unaligned
0
151 *d++ = src[y * sstride + x]; -
152 }
never executed: }
0
153 }
never executed: }
0
154 }
never executed: }
0
155 -
156 for (int ty = 0; ty < numTilesY; ++ty) {
never evaluated: ty < numTilesY
0
157 const int starty = h - 1 - unaligned - ty * tileSize; -
158 const int stopy = qMax(starty - tileSize, unoptimizedY); -
159 -
160 for (int x = startx; x < stopx; ++x) {
never evaluated: x < stopx
0
161 quint32 *d = reinterpret_cast<quint32*>(dest + x * dstride -
162 + h - 1 - starty); -
163 for (int y = starty; y > stopy; y -= pack) {
never evaluated: y > stopy
0
164 quint32 c = src[y * sstride + x]; -
165 for (int i = 1; i < pack; ++i) {
never evaluated: i < pack
0
166 const int shift = (sizeof(int) * 8 / pack * i); -
167 const T color = src[(y - i) * sstride + x]; -
168 c |= color << shift; -
169 }
never executed: }
0
170 *d++ = c; -
171 }
never executed: }
0
172 }
never executed: }
0
173 }
never executed: }
0
174 if (unoptimizedY) {
never evaluated: unoptimizedY
0
175 const int starty = unoptimizedY - 1; -
176 for (int x = startx; x < stopx; ++x) {
never evaluated: x < stopx
0
177 T *d = dest + x * dstride + h - 1 - starty; -
178 for (int y = starty; y >= 0; --y) {
never evaluated: y >= 0
0
179 *d++ = src[y * sstride + x]; -
180 }
never executed: }
0
181 }
never executed: }
0
182 }
never executed: }
0
183 }
never executed: }
0
184}
never executed: }
0
185 -
186template <class T> -
187static __attribute__((always_inline)) -
188inline void qt_memrotate270_tiled_unpacked(const T *src, int w, int h, int sstride, T *dest, -
189 int dstride) -
190{ -
191 const int numTilesX = (w + tileSize - 1) / tileSize; -
192 const int numTilesY = (h + tileSize - 1) / tileSize; -
193 -
194 for (int tx = 0; tx < numTilesX; ++tx) {
evaluated: tx < numTilesX
TRUEFALSE
yes
Evaluation Count:121
yes
Evaluation Count:53
53-121
195 const int startx = tx * tileSize; -
196 const int stopx = qMin(startx + tileSize, w); -
197 -
198 for (int ty = 0; ty < numTilesY; ++ty) {
evaluated: ty < numTilesY
TRUEFALSE
yes
Evaluation Count:580
yes
Evaluation Count:121
121-580
199 const int starty = h - 1 - ty * tileSize; -
200 const int stopy = qMax(starty - tileSize, 0); -
201 -
202 for (int x = startx; x < stopx; ++x) {
evaluated: x < stopx
TRUEFALSE
yes
Evaluation Count:16466
yes
Evaluation Count:580
580-16466
203 T *d = (T*)((char*)dest + x * dstride) + h - 1 - starty; -
204 const char *s = (const char*)(src + x) + starty * sstride; -
205 for (int y = starty; y >= stopy; --y) {
evaluated: y >= stopy
TRUEFALSE
yes
Evaluation Count:496018
yes
Evaluation Count:16466
16466-496018
206 *d++ = *(const T*)s; -
207 s -= sstride; -
208 }
executed: }
Execution Count:496018
496018
209 }
executed: }
Execution Count:16466
16466
210 }
executed: }
Execution Count:580
580
211 }
executed: }
Execution Count:121
121
212}
executed: }
Execution Count:53
53
213 -
214 -
215 -
216template <class T> -
217static __attribute__((always_inline)) -
218inline void qt_memrotate90_template(const T *src, int srcWidth, int srcHeight, int srcStride, -
219 T *dest, int dstStride) -
220{ -
221 -
222 -
223 -
224 -
225 -
226 -
227 -
228 qt_memrotate90_tiled<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride); -
229 -
230}
executed: }
Execution Count:36
36
231 -
232template <class T> -
233static __attribute__((always_inline)) -
234inline void qt_memrotate180_template(const T *src, int w, int h, int sstride, T *dest, int dstride) -
235{ -
236 const char *s = (const char*)(src) + (h - 1) * sstride; -
237 for (int y = h - 1; y >= 0; --y) {
evaluated: y >= 0
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:2
2-26
238 T *d = reinterpret_cast<T*>((char *)(dest) + (h - y - 1) * dstride); -
239 src = reinterpret_cast<const T*>(s); -
240 for (int x = w - 1; x >= 0; --x) {
evaluated: x >= 0
TRUEFALSE
yes
Evaluation Count:456
yes
Evaluation Count:26
26-456
241 d[w - x - 1] = src[x]; -
242 }
executed: }
Execution Count:456
456
243 s -= sstride; -
244 }
executed: }
Execution Count:26
26
245}
executed: }
Execution Count:2
2
246 -
247template <class T> -
248static __attribute__((always_inline)) -
249inline void qt_memrotate270_template(const T *src, int srcWidth, int srcHeight, int srcStride, -
250 T *dest, int dstStride) -
251{ -
252 -
253 -
254 -
255 -
256 -
257 -
258 -
259 qt_memrotate270_tiled_unpacked<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride); -
260 -
261}
executed: }
Execution Count:53
53
262 -
263template <> -
264inline void qt_memrotate90_template<quint24>(const quint24 *src, int srcWidth, int srcHeight, -
265 int srcStride, quint24 *dest, int dstStride) -
266{ -
267 qt_memrotate90_tiled_unpacked<quint24>(src, srcWidth, srcHeight, srcStride, dest, dstStride); -
268 -
269}
executed: }
Execution Count:16
16
270__attribute__((visibility("default"))) void qt_memrotate90(const quint32 *src, int w, int h, int sstride, quint32 *dest, int dstride) { qt_memrotate90_template(src, w, h, sstride, dest, dstride); } __attribute__((visibility("default"))) void qt_memrotate180(const quint32 *src, int w, int h, int sstride, quint32 *dest, int dstride) { qt_memrotate180_template(src, w, h, sstride, dest, dstride); } __attribute__((visibility("default"))) void qt_memrotate270(const quint32 *src, int w, int h, int sstride, quint32 *dest, int dstride) { qt_memrotate270_template(src, w, h, sstride, dest, dstride); }
executed: }
Execution Count:23
executed: }
Execution Count:2
executed: }
Execution Count:23
2-23
271__attribute__((visibility("default"))) void qt_memrotate90(const quint16 *src, int w, int h, int sstride, quint16 *dest, int dstride) { qt_memrotate90_template(src, w, h, sstride, dest, dstride); } __attribute__((visibility("default"))) void qt_memrotate180(const quint16 *src, int w, int h, int sstride, quint16 *dest, int dstride) { qt_memrotate180_template(src, w, h, sstride, dest, dstride); } __attribute__((visibility("default"))) void qt_memrotate270(const quint16 *src, int w, int h, int sstride, quint16 *dest, int dstride) { qt_memrotate270_template(src, w, h, sstride, dest, dstride); }
executed: }
Execution Count:8
never executed: }
executed: }
Execution Count:8
0-8
272__attribute__((visibility("default"))) void qt_memrotate90(const quint24 *src, int w, int h, int sstride, quint24 *dest, int dstride) { qt_memrotate90_template(src, w, h, sstride, dest, dstride); } __attribute__((visibility("default"))) void qt_memrotate180(const quint24 *src, int w, int h, int sstride, quint24 *dest, int dstride) { qt_memrotate180_template(src, w, h, sstride, dest, dstride); } __attribute__((visibility("default"))) void qt_memrotate270(const quint24 *src, int w, int h, int sstride, quint24 *dest, int dstride) { qt_memrotate270_template(src, w, h, sstride, dest, dstride); }
executed: }
Execution Count:16
never executed: }
executed: }
Execution Count:16
0-16
273__attribute__((visibility("default"))) void qt_memrotate90(const quint8 *src, int w, int h, int sstride, quint8 *dest, int dstride) { qt_memrotate90_template(src, w, h, sstride, dest, dstride); } __attribute__((visibility("default"))) void qt_memrotate180(const quint8 *src, int w, int h, int sstride, quint8 *dest, int dstride) { qt_memrotate180_template(src, w, h, sstride, dest, dstride); } __attribute__((visibility("default"))) void qt_memrotate270(const quint8 *src, int w, int h, int sstride, quint8 *dest, int dstride) { qt_memrotate270_template(src, w, h, sstride, dest, dstride); }
executed: }
Execution Count:5
never executed: }
executed: }
Execution Count:6
0-6
274 -
275void qt_memrotate90_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) -
276{ -
277 qt_memrotate90((const ushort *)srcPixels, w, h, sbpl, (ushort *)destPixels, dbpl); -
278}
never executed: }
0
279 -
280void qt_memrotate180_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) -
281{ -
282 qt_memrotate180((const ushort *)srcPixels, w, h, sbpl, (ushort *)destPixels, dbpl); -
283}
never executed: }
0
284 -
285void qt_memrotate270_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) -
286{ -
287 qt_memrotate270((const ushort *)srcPixels, w, h, sbpl, (ushort *)destPixels, dbpl); -
288}
never executed: }
0
289 -
290void qt_memrotate90_32(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) -
291{ -
292 qt_memrotate90((const uint *)srcPixels, w, h, sbpl, (uint *)destPixels, dbpl); -
293}
executed: }
Execution Count:1
1
294 -
295void qt_memrotate180_32(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) -
296{ -
297 qt_memrotate180((const uint *)srcPixels, w, h, sbpl, (uint *)destPixels, dbpl); -
298}
executed: }
Execution Count:2
2
299 -
300void qt_memrotate270_32(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) -
301{ -
302 qt_memrotate270((const uint *)srcPixels, w, h, sbpl, (uint *)destPixels, dbpl); -
303}
executed: }
Execution Count:1
1
304 -
305MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3] = -
306 -
307{ -
308 { 0, 0, 0 }, -
309 { 0, 0, 0 }, -
310 { 0, 0, 0 }, -
311 { 0, 0, 0 }, -
312 { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, -
313 { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, -
314 { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, -
315 { qt_memrotate90_16, qt_memrotate180_16, qt_memrotate270_16 }, -
316 { 0, 0, 0 }, -
317 { 0, 0, 0 }, -
318 { 0, 0, 0 }, -
319 { 0, 0, 0 }, -
320 { 0, 0, 0 }, -
321 { 0, 0, 0 }, -
322 { 0, 0, 0 }, -
323 { 0, 0, 0 } -
324}; -
325 -
326 -
327 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial