Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qmemrotate.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||
25 | ** | - | ||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||
29 | ** | - | ||||||
30 | ** $QT_END_LICENSE$ | - | ||||||
31 | ** | - | ||||||
32 | ****************************************************************************/ | - | ||||||
33 | - | |||||||
34 | #include "private/qmemrotate_p.h" | - | ||||||
35 | - | |||||||
36 | QT_BEGIN_NAMESPACE | - | ||||||
37 | - | |||||||
38 | #if QT_ROTATION_ALGORITHM == QT_ROTATION_TILED | - | ||||||
39 | static const int tileSize = 32; | - | ||||||
40 | #endif | - | ||||||
41 | - | |||||||
42 | #if Q_BYTE_ORDER == Q_BIG_ENDIAN | - | ||||||
43 | #if QT_ROTATION_ALGORITHM == QT_ROTATION_PACKED || QT_ROTATION_ALGORITHM == QT_ROTATION_TILED | - | ||||||
44 | #error Big endian version not implemented for the transformed driver! | - | ||||||
45 | #endif | - | ||||||
46 | #endif | - | ||||||
47 | - | |||||||
48 | template <class T> | - | ||||||
49 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
50 | inline void qt_memrotate90_cachedRead(const T *src, int w, int h, int sstride, T *dest, | - | ||||||
51 | int dstride) | - | ||||||
52 | { | - | ||||||
53 | const char *s = reinterpret_cast<const char*>(src); | - | ||||||
54 | char *d = reinterpret_cast<char*>(dest); | - | ||||||
55 | for (int y = 0; y < h; ++y) {
| 0 | ||||||
56 | for (int x = w - 1; x >= 0; --x) {
| 0 | ||||||
57 | T *destline = reinterpret_cast<T *>(d + (w - x - 1) * dstride); | - | ||||||
58 | destline[y] = src[x]; | - | ||||||
59 | } never executed: end of block | 0 | ||||||
60 | s += sstride; | - | ||||||
61 | src = reinterpret_cast<const T*>(s); | - | ||||||
62 | } never executed: end of block | 0 | ||||||
63 | } never executed: end of block | 0 | ||||||
64 | - | |||||||
65 | template <class T> | - | ||||||
66 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
67 | inline void qt_memrotate270_cachedRead(const T *src, int w, int h, int sstride, T *dest, | - | ||||||
68 | int dstride) | - | ||||||
69 | { | - | ||||||
70 | const char *s = reinterpret_cast<const char*>(src); | - | ||||||
71 | char *d = reinterpret_cast<char*>(dest); | - | ||||||
72 | s += (h - 1) * sstride; | - | ||||||
73 | for (int y = h - 1; y >= 0; --y) {
| 0 | ||||||
74 | src = reinterpret_cast<const T*>(s); | - | ||||||
75 | for (int x = 0; x < w; ++x) {
| 0 | ||||||
76 | T *destline = reinterpret_cast<T *>(d + x * dstride); | - | ||||||
77 | destline[h - y - 1] = src[x]; | - | ||||||
78 | } never executed: end of block | 0 | ||||||
79 | s -= sstride; | - | ||||||
80 | } never executed: end of block | 0 | ||||||
81 | } never executed: end of block | 0 | ||||||
82 | - | |||||||
83 | #if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE | - | ||||||
84 | - | |||||||
85 | template <class T> | - | ||||||
86 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
87 | inline void qt_memrotate90_cachedWrite(const T *src, int w, int h, int sstride, T *dest, | - | ||||||
88 | int dstride) | - | ||||||
89 | { | - | ||||||
90 | for (int x = w - 1; x >= 0; --x) { | - | ||||||
91 | T *d = dest + (w - x - 1) * dstride; | - | ||||||
92 | for (int y = 0; y < h; ++y) { | - | ||||||
93 | *d++ = src[y * sstride + x]; | - | ||||||
94 | } | - | ||||||
95 | } | - | ||||||
96 | - | |||||||
97 | } | - | ||||||
98 | - | |||||||
99 | template <class T> | - | ||||||
100 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
101 | inline void qt_memrotate270_cachedWrite(const T *src, int w, int h, int sstride, T *dest, | - | ||||||
102 | int dstride) | - | ||||||
103 | { | - | ||||||
104 | for (int x = 0; x < w; ++x) { | - | ||||||
105 | T *d = dest + x * dstride; | - | ||||||
106 | for (int y = h - 1; y >= 0; --y) { | - | ||||||
107 | *d++ = src[y * sstride + x]; | - | ||||||
108 | } | - | ||||||
109 | } | - | ||||||
110 | } | - | ||||||
111 | - | |||||||
112 | #endif // QT_ROTATION_CACHEDWRITE | - | ||||||
113 | - | |||||||
114 | #if QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING | - | ||||||
115 | - | |||||||
116 | // TODO: packing algorithms should probably be modified on 64-bit architectures | - | ||||||
117 | - | |||||||
118 | template <class T> | - | ||||||
119 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
120 | inline void qt_memrotate90_packing(const T *src, int w, int h, int sstride, T *dest, int dstride) | - | ||||||
121 | { | - | ||||||
122 | sstride /= sizeof(T); | - | ||||||
123 | dstride /= sizeof(T); | - | ||||||
124 | - | |||||||
125 | const int pack = sizeof(quint32) / sizeof(T); | - | ||||||
126 | const int unaligned = int((long(dest) & (sizeof(quint32)-1))) / sizeof(T); | - | ||||||
127 | - | |||||||
128 | for (int x = w - 1; x >= 0; --x) { | - | ||||||
129 | int y = 0; | - | ||||||
130 | - | |||||||
131 | for (int i = 0; i < unaligned; ++i) { | - | ||||||
132 | dest[(w - x - 1) * dstride + y] = src[y * sstride + x]; | - | ||||||
133 | ++y; | - | ||||||
134 | } | - | ||||||
135 | - | |||||||
136 | quint32 *d = reinterpret_cast<quint32*>(dest + (w - x - 1) * dstride | - | ||||||
137 | + unaligned); | - | ||||||
138 | const int rest = (h - unaligned) % pack; | - | ||||||
139 | while (y < h - rest) { | - | ||||||
140 | quint32 c = src[y * sstride + x]; | - | ||||||
141 | for (int i = 1; i < pack; ++i) { | - | ||||||
142 | c |= src[(y + i) * sstride + x] << (sizeof(int) * 8 / pack * i); | - | ||||||
143 | } | - | ||||||
144 | *d++ = c; | - | ||||||
145 | y += pack; | - | ||||||
146 | } | - | ||||||
147 | - | |||||||
148 | while (y < h) { | - | ||||||
149 | dest[(w - x - 1) * dstride + y] = src[y * sstride + x]; | - | ||||||
150 | ++y; | - | ||||||
151 | } | - | ||||||
152 | } | - | ||||||
153 | } | - | ||||||
154 | - | |||||||
155 | template <class T> | - | ||||||
156 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
157 | inline void qt_memrotate270_packing(const T *src, int w, int h, int sstride, T *dest, int dstride) | - | ||||||
158 | { | - | ||||||
159 | sstride /= sizeof(T); | - | ||||||
160 | dstride /= sizeof(T); | - | ||||||
161 | - | |||||||
162 | const int pack = sizeof(quint32) / sizeof(T); | - | ||||||
163 | const int unaligned = int((long(dest) & (sizeof(quint32)-1))) / sizeof(T); | - | ||||||
164 | - | |||||||
165 | for (int x = 0; x < w; ++x) { | - | ||||||
166 | int y = h - 1; | - | ||||||
167 | - | |||||||
168 | for (int i = 0; i < unaligned; ++i) { | - | ||||||
169 | dest[x * dstride + h - y - 1] = src[y * sstride + x]; | - | ||||||
170 | --y; | - | ||||||
171 | } | - | ||||||
172 | - | |||||||
173 | quint32 *d = reinterpret_cast<quint32*>(dest + x * dstride | - | ||||||
174 | + unaligned); | - | ||||||
175 | const int rest = (h - unaligned) % pack; | - | ||||||
176 | while (y > rest) { | - | ||||||
177 | quint32 c = src[y * sstride + x]; | - | ||||||
178 | for (int i = 1; i < pack; ++i) { | - | ||||||
179 | c |= src[(y - i) * sstride + x] << (sizeof(int) * 8 / pack * i); | - | ||||||
180 | } | - | ||||||
181 | *d++ = c; | - | ||||||
182 | y -= pack; | - | ||||||
183 | } | - | ||||||
184 | while (y >= 0) { | - | ||||||
185 | dest[x * dstride + h - y - 1] = src[y * sstride + x]; | - | ||||||
186 | --y; | - | ||||||
187 | } | - | ||||||
188 | } | - | ||||||
189 | } | - | ||||||
190 | - | |||||||
191 | #endif // QT_ROTATION_PACKING | - | ||||||
192 | - | |||||||
193 | #if QT_ROTATION_ALGORITHM == QT_ROTATION_TILED | - | ||||||
194 | template <class T> | - | ||||||
195 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
196 | inline void qt_memrotate90_tiled(const T *src, int w, int h, int sstride, T *dest, int dstride) | - | ||||||
197 | { | - | ||||||
198 | sstride /= sizeof(T); | - | ||||||
199 | dstride /= sizeof(T); | - | ||||||
200 | - | |||||||
201 | const int pack = sizeof(quint32) / sizeof(T); | - | ||||||
202 | const int unaligned = | - | ||||||
203 | qMin(uint((quintptr(dest) & (sizeof(quint32)-1)) / sizeof(T)), uint(h)); | - | ||||||
204 | const int restX = w % tileSize; | - | ||||||
205 | const int restY = (h - unaligned) % tileSize; | - | ||||||
206 | const int unoptimizedY = restY % pack; | - | ||||||
207 | const int numTilesX = w / tileSize + (restX > 0); | - | ||||||
208 | const int numTilesY = (h - unaligned) / tileSize + (restY >= pack); | - | ||||||
209 | - | |||||||
210 | for (int tx = 0; tx < numTilesX; ++tx) {
| 0 | ||||||
211 | const int startx = w - tx * tileSize - 1; | - | ||||||
212 | const int stopx = qMax(startx - tileSize, 0); | - | ||||||
213 | - | |||||||
214 | if (unaligned) {
| 0 | ||||||
215 | for (int x = startx; x >= stopx; --x) {
| 0 | ||||||
216 | T *d = dest + (w - x - 1) * dstride; | - | ||||||
217 | for (int y = 0; y < unaligned; ++y) {
| 0 | ||||||
218 | *d++ = src[y * sstride + x]; | - | ||||||
219 | } never executed: end of block | 0 | ||||||
220 | } never executed: end of block | 0 | ||||||
221 | } never executed: end of block | 0 | ||||||
222 | - | |||||||
223 | for (int ty = 0; ty < numTilesY; ++ty) {
| 0 | ||||||
224 | const int starty = ty * tileSize + unaligned; | - | ||||||
225 | const int stopy = qMin(starty + tileSize, h - unoptimizedY); | - | ||||||
226 | - | |||||||
227 | for (int x = startx; x >= stopx; --x) {
| 0 | ||||||
228 | quint32 *d = reinterpret_cast<quint32*>(dest + (w - x - 1) * dstride + starty); | - | ||||||
229 | for (int y = starty; y < stopy; y += pack) {
| 0 | ||||||
230 | quint32 c = src[y * sstride + x]; | - | ||||||
231 | for (int i = 1; i < pack; ++i) {
| 0 | ||||||
232 | const int shift = (sizeof(int) * 8 / pack * i); | - | ||||||
233 | const T color = src[(y + i) * sstride + x]; | - | ||||||
234 | c |= color << shift; | - | ||||||
235 | } never executed: end of block | 0 | ||||||
236 | *d++ = c; | - | ||||||
237 | } never executed: end of block | 0 | ||||||
238 | } never executed: end of block | 0 | ||||||
239 | } never executed: end of block | 0 | ||||||
240 | - | |||||||
241 | if (unoptimizedY) {
| 0 | ||||||
242 | const int starty = h - unoptimizedY; | - | ||||||
243 | for (int x = startx; x >= stopx; --x) {
| 0 | ||||||
244 | T *d = dest + (w - x - 1) * dstride + starty; | - | ||||||
245 | for (int y = starty; y < h; ++y) {
| 0 | ||||||
246 | *d++ = src[y * sstride + x]; | - | ||||||
247 | } never executed: end of block | 0 | ||||||
248 | } never executed: end of block | 0 | ||||||
249 | } never executed: end of block | 0 | ||||||
250 | } never executed: end of block | 0 | ||||||
251 | } never executed: end of block | 0 | ||||||
252 | - | |||||||
253 | template <class T> | - | ||||||
254 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
255 | inline void qt_memrotate90_tiled_unpacked(const T *src, int w, int h, int sstride, T *dest, | - | ||||||
256 | int dstride) | - | ||||||
257 | { | - | ||||||
258 | const int numTilesX = (w + tileSize - 1) / tileSize; | - | ||||||
259 | const int numTilesY = (h + tileSize - 1) / tileSize; | - | ||||||
260 | - | |||||||
261 | for (int tx = 0; tx < numTilesX; ++tx) {
| 0 | ||||||
262 | const int startx = w - tx * tileSize - 1; | - | ||||||
263 | const int stopx = qMax(startx - tileSize, 0); | - | ||||||
264 | - | |||||||
265 | for (int ty = 0; ty < numTilesY; ++ty) {
| 0 | ||||||
266 | const int starty = ty * tileSize; | - | ||||||
267 | const int stopy = qMin(starty + tileSize, h); | - | ||||||
268 | - | |||||||
269 | for (int x = startx; x >= stopx; --x) {
| 0 | ||||||
270 | T *d = (T *)((char*)dest + (w - x - 1) * dstride) + starty; | - | ||||||
271 | const char *s = (const char*)(src + x) + starty * sstride; | - | ||||||
272 | for (int y = starty; y < stopy; ++y) {
| 0 | ||||||
273 | *d++ = *(const T *)(s); | - | ||||||
274 | s += sstride; | - | ||||||
275 | } never executed: end of block | 0 | ||||||
276 | } never executed: end of block | 0 | ||||||
277 | } never executed: end of block | 0 | ||||||
278 | } never executed: end of block | 0 | ||||||
279 | } never executed: end of block | 0 | ||||||
280 | - | |||||||
281 | template <class T> | - | ||||||
282 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
283 | inline void qt_memrotate270_tiled(const T *src, int w, int h, int sstride, T *dest, int dstride) | - | ||||||
284 | { | - | ||||||
285 | sstride /= sizeof(T); | - | ||||||
286 | dstride /= sizeof(T); | - | ||||||
287 | - | |||||||
288 | const int pack = sizeof(quint32) / sizeof(T); | - | ||||||
289 | const int unaligned = | - | ||||||
290 | qMin(uint((long(dest) & (sizeof(quint32)-1)) / sizeof(T)), uint(h)); | - | ||||||
291 | const int restX = w % tileSize; | - | ||||||
292 | const int restY = (h - unaligned) % tileSize; | - | ||||||
293 | const int unoptimizedY = restY % pack; | - | ||||||
294 | const int numTilesX = w / tileSize + (restX > 0); | - | ||||||
295 | const int numTilesY = (h - unaligned) / tileSize + (restY >= pack); | - | ||||||
296 | - | |||||||
297 | for (int tx = 0; tx < numTilesX; ++tx) {
| 0 | ||||||
298 | const int startx = tx * tileSize; | - | ||||||
299 | const int stopx = qMin(startx + tileSize, w); | - | ||||||
300 | - | |||||||
301 | if (unaligned) {
| 0 | ||||||
302 | for (int x = startx; x < stopx; ++x) {
| 0 | ||||||
303 | T *d = dest + x * dstride; | - | ||||||
304 | for (int y = h - 1; y >= h - unaligned; --y) {
| 0 | ||||||
305 | *d++ = src[y * sstride + x]; | - | ||||||
306 | } never executed: end of block | 0 | ||||||
307 | } never executed: end of block | 0 | ||||||
308 | } never executed: end of block | 0 | ||||||
309 | - | |||||||
310 | for (int ty = 0; ty < numTilesY; ++ty) {
| 0 | ||||||
311 | const int starty = h - 1 - unaligned - ty * tileSize; | - | ||||||
312 | const int stopy = qMax(starty - tileSize, unoptimizedY); | - | ||||||
313 | - | |||||||
314 | for (int x = startx; x < stopx; ++x) {
| 0 | ||||||
315 | quint32 *d = reinterpret_cast<quint32*>(dest + x * dstride | - | ||||||
316 | + h - 1 - starty); | - | ||||||
317 | for (int y = starty; y > stopy; y -= pack) {
| 0 | ||||||
318 | quint32 c = src[y * sstride + x]; | - | ||||||
319 | for (int i = 1; i < pack; ++i) {
| 0 | ||||||
320 | const int shift = (sizeof(int) * 8 / pack * i); | - | ||||||
321 | const T color = src[(y - i) * sstride + x]; | - | ||||||
322 | c |= color << shift; | - | ||||||
323 | } never executed: end of block | 0 | ||||||
324 | *d++ = c; | - | ||||||
325 | } never executed: end of block | 0 | ||||||
326 | } never executed: end of block | 0 | ||||||
327 | } never executed: end of block | 0 | ||||||
328 | if (unoptimizedY) {
| 0 | ||||||
329 | const int starty = unoptimizedY - 1; | - | ||||||
330 | for (int x = startx; x < stopx; ++x) {
| 0 | ||||||
331 | T *d = dest + x * dstride + h - 1 - starty; | - | ||||||
332 | for (int y = starty; y >= 0; --y) {
| 0 | ||||||
333 | *d++ = src[y * sstride + x]; | - | ||||||
334 | } never executed: end of block | 0 | ||||||
335 | } never executed: end of block | 0 | ||||||
336 | } never executed: end of block | 0 | ||||||
337 | } never executed: end of block | 0 | ||||||
338 | } never executed: end of block | 0 | ||||||
339 | - | |||||||
340 | template <class T> | - | ||||||
341 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
342 | inline void qt_memrotate270_tiled_unpacked(const T *src, int w, int h, int sstride, T *dest, | - | ||||||
343 | int dstride) | - | ||||||
344 | { | - | ||||||
345 | const int numTilesX = (w + tileSize - 1) / tileSize; | - | ||||||
346 | const int numTilesY = (h + tileSize - 1) / tileSize; | - | ||||||
347 | - | |||||||
348 | for (int tx = 0; tx < numTilesX; ++tx) {
| 0 | ||||||
349 | const int startx = tx * tileSize; | - | ||||||
350 | const int stopx = qMin(startx + tileSize, w); | - | ||||||
351 | - | |||||||
352 | for (int ty = 0; ty < numTilesY; ++ty) {
| 0 | ||||||
353 | const int starty = h - 1 - ty * tileSize; | - | ||||||
354 | const int stopy = qMax(starty - tileSize, 0); | - | ||||||
355 | - | |||||||
356 | for (int x = startx; x < stopx; ++x) {
| 0 | ||||||
357 | T *d = (T*)((char*)dest + x * dstride) + h - 1 - starty; | - | ||||||
358 | const char *s = (const char*)(src + x) + starty * sstride; | - | ||||||
359 | for (int y = starty; y >= stopy; --y) {
| 0 | ||||||
360 | *d++ = *(const T*)s; | - | ||||||
361 | s -= sstride; | - | ||||||
362 | } never executed: end of block | 0 | ||||||
363 | } never executed: end of block | 0 | ||||||
364 | } never executed: end of block | 0 | ||||||
365 | } never executed: end of block | 0 | ||||||
366 | } never executed: end of block | 0 | ||||||
367 | - | |||||||
368 | #endif // QT_ROTATION_ALGORITHM | - | ||||||
369 | - | |||||||
370 | template <class T> | - | ||||||
371 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
372 | inline void qt_memrotate90_template(const T *src, int srcWidth, int srcHeight, int srcStride, | - | ||||||
373 | T *dest, int dstStride) | - | ||||||
374 | { | - | ||||||
375 | #if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD | - | ||||||
376 | qt_memrotate90_cachedRead<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
377 | #elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE | - | ||||||
378 | qt_memrotate90_cachedWrite<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
379 | #elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING | - | ||||||
380 | qt_memrotate90_packing<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
381 | #elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED | - | ||||||
382 | qt_memrotate90_tiled<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
383 | #endif | - | ||||||
384 | } never executed: end of block | 0 | ||||||
385 | - | |||||||
386 | template <class T> | - | ||||||
387 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
388 | inline void qt_memrotate180_template(const T *src, int w, int h, int sstride, T *dest, int dstride) | - | ||||||
389 | { | - | ||||||
390 | const char *s = (const char*)(src) + (h - 1) * sstride; | - | ||||||
391 | for (int y = h - 1; y >= 0; --y) {
| 0 | ||||||
392 | T *d = reinterpret_cast<T*>((char *)(dest) + (h - y - 1) * dstride); | - | ||||||
393 | src = reinterpret_cast<const T*>(s); | - | ||||||
394 | for (int x = w - 1; x >= 0; --x) {
| 0 | ||||||
395 | d[w - x - 1] = src[x]; | - | ||||||
396 | } never executed: end of block | 0 | ||||||
397 | s -= sstride; | - | ||||||
398 | } never executed: end of block | 0 | ||||||
399 | } never executed: end of block | 0 | ||||||
400 | - | |||||||
401 | template <class T> | - | ||||||
402 | Q_STATIC_TEMPLATE_FUNCTION | - | ||||||
403 | inline void qt_memrotate270_template(const T *src, int srcWidth, int srcHeight, int srcStride, | - | ||||||
404 | T *dest, int dstStride) | - | ||||||
405 | { | - | ||||||
406 | #if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD | - | ||||||
407 | qt_memrotate270_cachedRead<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
408 | #elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE | - | ||||||
409 | qt_memrotate270_cachedWrite<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
410 | #elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING | - | ||||||
411 | qt_memrotate270_packing<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
412 | #elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED | - | ||||||
413 | qt_memrotate270_tiled_unpacked<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
414 | #endif | - | ||||||
415 | } never executed: end of block | 0 | ||||||
416 | - | |||||||
417 | template <> | - | ||||||
418 | inline void qt_memrotate90_template<quint24>(const quint24 *src, int srcWidth, int srcHeight, | - | ||||||
419 | int srcStride, quint24 *dest, int dstStride) | - | ||||||
420 | { | - | ||||||
421 | #if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD | - | ||||||
422 | qt_memrotate90_cachedRead<quint24>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
423 | #elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE | - | ||||||
424 | qt_memrotate90_cachedWrite<quint24>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
425 | #elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING | - | ||||||
426 | // packed algorithm not implemented | - | ||||||
427 | qt_memrotate90_cachedRead<quint24>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
428 | #elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED | - | ||||||
429 | // packed algorithm not implemented | - | ||||||
430 | qt_memrotate90_tiled_unpacked<quint24>(src, srcWidth, srcHeight, srcStride, dest, dstStride); | - | ||||||
431 | #endif | - | ||||||
432 | } never executed: end of block | 0 | ||||||
433 | - | |||||||
434 | #define QT_IMPL_MEMROTATE(type) \ | - | ||||||
435 | Q_GUI_EXPORT void qt_memrotate90(const type *src, int w, int h, int sstride, \ | - | ||||||
436 | type *dest, int dstride) \ | - | ||||||
437 | { \ | - | ||||||
438 | qt_memrotate90_template(src, w, h, sstride, dest, dstride); \ | - | ||||||
439 | } \ | - | ||||||
440 | Q_GUI_EXPORT void qt_memrotate180(const type *src, int w, int h, int sstride, \ | - | ||||||
441 | type *dest, int dstride) \ | - | ||||||
442 | { \ | - | ||||||
443 | qt_memrotate180_template(src, w, h, sstride, dest, dstride); \ | - | ||||||
444 | } \ | - | ||||||
445 | Q_GUI_EXPORT void qt_memrotate270(const type *src, int w, int h, int sstride, \ | - | ||||||
446 | type *dest, int dstride) \ | - | ||||||
447 | { \ | - | ||||||
448 | qt_memrotate270_template(src, w, h, sstride, dest, dstride); \ | - | ||||||
449 | } | - | ||||||
450 | - | |||||||
451 | #define QT_IMPL_SIMPLE_MEMROTATE(type) \ | - | ||||||
452 | Q_GUI_EXPORT void qt_memrotate90(const type *src, int w, int h, int sstride, \ | - | ||||||
453 | type *dest, int dstride) \ | - | ||||||
454 | { \ | - | ||||||
455 | qt_memrotate90_tiled_unpacked<type>(src, w, h, sstride, dest, dstride); \ | - | ||||||
456 | } \ | - | ||||||
457 | Q_GUI_EXPORT void qt_memrotate180(const type *src, int w, int h, int sstride, \ | - | ||||||
458 | type *dest, int dstride) \ | - | ||||||
459 | { \ | - | ||||||
460 | qt_memrotate180_template(src, w, h, sstride, dest, dstride); \ | - | ||||||
461 | } \ | - | ||||||
462 | Q_GUI_EXPORT void qt_memrotate270(const type *src, int w, int h, int sstride, \ | - | ||||||
463 | type *dest, int dstride) \ | - | ||||||
464 | { \ | - | ||||||
465 | qt_memrotate270_tiled_unpacked<type>(src, w, h, sstride, dest, dstride); \ | - | ||||||
466 | } | - | ||||||
467 | - | |||||||
468 | - | |||||||
469 | - | |||||||
470 | - | |||||||
471 | QT_IMPL_MEMROTATE(quint32) never executed: end of block never executed: end of block never executed: end of block | 0 | ||||||
472 | QT_IMPL_MEMROTATE(quint16) never executed: end of block never executed: end of block never executed: end of block | 0 | ||||||
473 | QT_IMPL_MEMROTATE(quint24) never executed: end of block never executed: end of block never executed: end of block | 0 | ||||||
474 | QT_IMPL_MEMROTATE(quint8) never executed: end of block never executed: end of block never executed: end of block | 0 | ||||||
475 | - | |||||||
476 | void qt_memrotate90_8(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) | - | ||||||
477 | { | - | ||||||
478 | qt_memrotate90(srcPixels, w, h, sbpl, destPixels, dbpl); | - | ||||||
479 | } never executed: end of block | 0 | ||||||
480 | - | |||||||
481 | void qt_memrotate180_8(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) | - | ||||||
482 | { | - | ||||||
483 | qt_memrotate180(srcPixels, w, h, sbpl, destPixels, dbpl); | - | ||||||
484 | } never executed: end of block | 0 | ||||||
485 | - | |||||||
486 | void qt_memrotate270_8(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) | - | ||||||
487 | { | - | ||||||
488 | qt_memrotate270(srcPixels, w, h, sbpl, destPixels, dbpl); | - | ||||||
489 | } never executed: end of block | 0 | ||||||
490 | - | |||||||
491 | void qt_memrotate90_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) | - | ||||||
492 | { | - | ||||||
493 | qt_memrotate90((const ushort *)srcPixels, w, h, sbpl, (ushort *)destPixels, dbpl); | - | ||||||
494 | } never executed: end of block | 0 | ||||||
495 | - | |||||||
496 | void qt_memrotate180_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) | - | ||||||
497 | { | - | ||||||
498 | qt_memrotate180((const ushort *)srcPixels, w, h, sbpl, (ushort *)destPixels, dbpl); | - | ||||||
499 | } never executed: end of block | 0 | ||||||
500 | - | |||||||
501 | void qt_memrotate270_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) | - | ||||||
502 | { | - | ||||||
503 | qt_memrotate270((const ushort *)srcPixels, w, h, sbpl, (ushort *)destPixels, dbpl); | - | ||||||
504 | } never executed: end of block | 0 | ||||||
505 | - | |||||||
506 | void qt_memrotate90_32(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) | - | ||||||
507 | { | - | ||||||
508 | qt_memrotate90((const uint *)srcPixels, w, h, sbpl, (uint *)destPixels, dbpl); | - | ||||||
509 | } never executed: end of block | 0 | ||||||
510 | - | |||||||
511 | void qt_memrotate180_32(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) | - | ||||||
512 | { | - | ||||||
513 | qt_memrotate180((const uint *)srcPixels, w, h, sbpl, (uint *)destPixels, dbpl); | - | ||||||
514 | } never executed: end of block | 0 | ||||||
515 | - | |||||||
516 | void qt_memrotate270_32(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl) | - | ||||||
517 | { | - | ||||||
518 | qt_memrotate270((const uint *)srcPixels, w, h, sbpl, (uint *)destPixels, dbpl); | - | ||||||
519 | } never executed: end of block | 0 | ||||||
520 | - | |||||||
521 | MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3] = | - | ||||||
522 | // 90, 180, 270 | - | ||||||
523 | { | - | ||||||
524 | { 0, 0, 0 }, // Format_Invalid, | - | ||||||
525 | { 0, 0, 0 }, // Format_Mono, | - | ||||||
526 | { 0, 0, 0 }, // Format_MonoLSB, | - | ||||||
527 | { 0, 0, 0 }, // Format_Indexed8, | - | ||||||
528 | { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGB32, | - | ||||||
529 | { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_ARGB32, | - | ||||||
530 | { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_ARGB32_Premultiplied, | - | ||||||
531 | { qt_memrotate90_16, qt_memrotate180_16, qt_memrotate270_16 }, // Format_RGB16, | - | ||||||
532 | { 0, 0, 0 }, // Format_ARGB8565_Premultiplied, | - | ||||||
533 | { 0, 0, 0 }, // Format_RGB666, | - | ||||||
534 | { 0, 0, 0 }, // Format_ARGB6666_Premultiplied, | - | ||||||
535 | { 0, 0, 0 }, // Format_RGB555, | - | ||||||
536 | { 0, 0, 0 }, // Format_ARGB8555_Premultiplied, | - | ||||||
537 | { 0, 0, 0 }, // Format_RGB888, | - | ||||||
538 | { 0, 0, 0 }, // Format_RGB444, | - | ||||||
539 | { 0, 0, 0 }, // Format_ARGB4444_Premultiplied, | - | ||||||
540 | { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGBX8888, | - | ||||||
541 | { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGBA8888, | - | ||||||
542 | { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGBA8888_Premultiplied, | - | ||||||
543 | { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_BGB30, | - | ||||||
544 | { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_A2BGR30_Premultiplied, | - | ||||||
545 | { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGB30, | - | ||||||
546 | { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_A2RGB30_Premultiplied, | - | ||||||
547 | { qt_memrotate90_8, qt_memrotate180_8, qt_memrotate270_8 }, // Format_Alpha8, | - | ||||||
548 | { qt_memrotate90_8, qt_memrotate180_8, qt_memrotate270_8 }, // Format_Grayscale8, | - | ||||||
549 | }; | - | ||||||
550 | - | |||||||
551 | QT_END_NAMESPACE | - | ||||||
Source code | Switch to Preprocessed file |