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