42 #include "private/qmemrotate_p.h" 46 #if QT_ROTATION_ALGORITHM == QT_ROTATION_TILED 50 #if Q_BYTE_ORDER == Q_BIG_ENDIAN 51 #if QT_ROTATION_ALGORITHM == QT_ROTATION_PACKED || QT_ROTATION_ALGORITHM == QT_ROTATION_TILED 52 #error Big endian version not implemented for the transformed driver! 56 template <
class DST,
class SRC>
59 DST *dest,
int dstride)
61 const char *s =
reinterpret_cast<const char*
>(src);
62 char *
d =
reinterpret_cast<char*
>(dest);
63 for (
int y = 0; y < h; ++y) {
64 for (
int x = w - 1; x >= 0; --x) {
65 DST *destline =
reinterpret_cast<DST*
>(d + (w - x - 1) * dstride);
66 destline[y] = qt_colorConvert<DST,SRC>(src[x], 0);
69 src =
reinterpret_cast<const SRC*
>(s);
73 template <
class DST,
class SRC>
76 DST *dest,
int dstride)
78 const char *s =
reinterpret_cast<const char*
>(src);
79 char *
d =
reinterpret_cast<char*
>(dest);
80 s += (h - 1) * sstride;
81 for (
int y = h - 1; y >= 0; --y) {
82 src =
reinterpret_cast<const SRC*
>(s);
83 for (
int x = 0; x < w; ++x) {
84 DST *destline =
reinterpret_cast<DST*
>(d + x * dstride);
85 destline[h - y - 1] = qt_colorConvert<DST,SRC>(src[x], 0);
91 #if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE 93 template <
class DST,
class SRC>
96 DST *dest,
int dstride)
98 for (
int x = w - 1; x >= 0; --x) {
99 DST *
d = dest + (w - x - 1) * dstride;
100 for (
int y = 0; y < h; ++y) {
101 *d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
107 template <
class DST,
class SRC>
110 DST *dest,
int dstride)
112 for (
int x = 0; x < w; ++x) {
113 DST *
d = dest + x * dstride;
114 for (
int y = h - 1; y >= 0; --y) {
115 *d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
120 #endif // QT_ROTATION_CACHEDWRITE 122 #if QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING 126 template <
class DST,
class SRC>
129 DST *dest,
int dstride)
131 sstride /=
sizeof(SRC);
132 dstride /=
sizeof(DST);
134 const int pack =
sizeof(
quint32) /
sizeof(DST);
135 const int unaligned = int((
long(dest) & (
sizeof(
quint32)-1))) /
sizeof(DST);
137 for (
int x = w - 1; x >= 0; --x) {
140 for (
int i = 0; i < unaligned; ++i) {
141 dest[(w - x - 1) * dstride + y]
142 = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
148 const int rest = (h - unaligned) % pack;
149 while (y < h - rest) {
150 quint32 c = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
151 for (
int i = 1; i < pack; ++i) {
152 c |= qt_colorConvert<DST,SRC>(src[(y + i) * sstride + x], 0)
153 << (
sizeof(int) * 8 / pack * i);
160 dest[(w - x - 1) * dstride + y]
161 = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
167 template <
class DST,
class SRC>
170 DST *dest,
int dstride)
172 sstride /=
sizeof(SRC);
173 dstride /=
sizeof(DST);
175 const int pack =
sizeof(
quint32) /
sizeof(DST);
176 const int unaligned = int((
long(dest) & (
sizeof(
quint32)-1))) /
sizeof(DST);
178 for (
int x = 0; x < w; ++x) {
181 for (
int i = 0; i < unaligned; ++i) {
182 dest[x * dstride + h - y - 1]
183 = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
189 const int rest = (h - unaligned) % pack;
191 quint32 c = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
192 for (
int i = 1; i < pack; ++i) {
193 c |= qt_colorConvert<DST,SRC>(src[(y - i) * sstride + x], 0)
194 << (
sizeof(int) * 8 / pack * i);
200 dest[x * dstride + h - y - 1]
201 = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
207 #endif // QT_ROTATION_PACKING 209 #if QT_ROTATION_ALGORITHM == QT_ROTATION_TILED 210 template <
class DST,
class SRC>
213 DST *dest,
int dstride)
215 sstride /=
sizeof(SRC);
216 dstride /=
sizeof(DST);
218 const int pack =
sizeof(
quint32) /
sizeof(DST);
219 const int unaligned =
222 const int restY = (h - unaligned) %
tileSize;
223 const int unoptimizedY = restY % pack;
224 const int numTilesX = w /
tileSize + (restX > 0);
225 const int numTilesY = (h - unaligned) /
tileSize + (restY >= pack);
227 for (
int tx = 0; tx < numTilesX; ++tx) {
228 const int startx = w - tx *
tileSize - 1;
229 const int stopx =
qMax(startx - tileSize, 0);
232 for (
int x = startx; x >= stopx; --x) {
233 DST *
d = dest + (w - x - 1) * dstride;
234 for (
int y = 0; y < unaligned; ++y) {
235 *d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
240 for (
int ty = 0; ty < numTilesY; ++ty) {
241 const int starty = ty * tileSize + unaligned;
242 const int stopy =
qMin(starty + tileSize, h - unoptimizedY);
244 for (
int x = startx; x >= stopx; --x) {
245 quint32 *
d =
reinterpret_cast<quint32*
>(dest + (w - x - 1) * dstride + starty);
246 for (
int y = starty; y < stopy; y += pack) {
247 quint32 c = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
248 for (
int i = 1; i < pack; ++i) {
249 const int shift = (
sizeof(int) * 8 / pack * i);
250 const DST color = qt_colorConvert<DST,SRC>(src[(y + i) * sstride + x], 0);
259 const int starty = h - unoptimizedY;
260 for (
int x = startx; x >= stopx; --x) {
261 DST *
d = dest + (w - x - 1) * dstride + starty;
262 for (
int y = starty; y < h; ++y) {
263 *d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
270 template <
class DST,
class SRC>
273 DST *dest,
int dstride)
278 for (
int tx = 0; tx < numTilesX; ++tx) {
279 const int startx = w - tx *
tileSize - 1;
280 const int stopx =
qMax(startx - tileSize, 0);
282 for (
int ty = 0; ty < numTilesY; ++ty) {
284 const int stopy =
qMin(starty + tileSize, h);
286 for (
int x = startx; x >= stopx; --x) {
287 DST *
d = (DST*)((
char*)dest + (w - x - 1) * dstride) + starty;
288 const char *s = (
const char*)(src + x) + starty * sstride;
289 for (
int y = starty; y < stopy; ++y) {
290 *d++ = qt_colorConvert<DST,SRC>(*(
const SRC*)(s), 0);
298 template <
class DST,
class SRC>
301 DST *dest,
int dstride)
303 sstride /=
sizeof(SRC);
304 dstride /=
sizeof(DST);
306 const int pack =
sizeof(
quint32) /
sizeof(DST);
307 const int unaligned =
310 const int restY = (h - unaligned) %
tileSize;
311 const int unoptimizedY = restY % pack;
312 const int numTilesX = w /
tileSize + (restX > 0);
313 const int numTilesY = (h - unaligned) /
tileSize + (restY >= pack);
315 for (
int tx = 0; tx < numTilesX; ++tx) {
317 const int stopx =
qMin(startx + tileSize, w);
320 for (
int x = startx; x < stopx; ++x) {
321 DST *
d = dest + x * dstride;
322 for (
int y = h - 1; y >= h - unaligned; --y) {
323 *d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
328 for (
int ty = 0; ty < numTilesY; ++ty) {
329 const int starty = h - 1 - unaligned - ty *
tileSize;
330 const int stopy =
qMax(starty - tileSize, unoptimizedY);
332 for (
int x = startx; x < stopx; ++x) {
335 for (
int y = starty; y > stopy; y -= pack) {
336 quint32 c = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
337 for (
int i = 1; i < pack; ++i) {
338 const int shift = (
sizeof(int) * 8 / pack * i);
339 const DST color = qt_colorConvert<DST,SRC>(src[(y - i) * sstride + x], 0);
347 const int starty = unoptimizedY - 1;
348 for (
int x = startx; x < stopx; ++x) {
349 DST *
d = dest + x * dstride + h - 1 - starty;
350 for (
int y = starty; y >= 0; --y) {
351 *d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
358 template <
class DST,
class SRC>
361 DST *dest,
int dstride)
366 for (
int tx = 0; tx < numTilesX; ++tx) {
368 const int stopx =
qMin(startx + tileSize, w);
370 for (
int ty = 0; ty < numTilesY; ++ty) {
371 const int starty = h - 1 - ty *
tileSize;
372 const int stopy =
qMax(starty - tileSize, 0);
374 for (
int x = startx; x < stopx; ++x) {
375 DST *
d = (DST*)((
char*)dest + x * dstride) + h - 1 - starty;
376 const char *s = (
const char*)(src + x) + starty * sstride;
377 for (
int y = starty; y >= stopy; --y) {
378 *d++ = qt_colorConvert<DST,SRC>(*(
const SRC*)s, 0);
386 #endif // QT_ROTATION_ALGORITHM 388 template <
class DST,
class SRC>
390 int srcWidth,
int srcHeight,
int srcStride,
391 DST *dest,
int dstStride)
393 #if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD 394 qt_memrotate90_cachedRead<DST,SRC>(src, srcWidth, srcHeight, srcStride,
396 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE 397 qt_memrotate90_cachedWrite<DST,SRC>(src, srcWidth, srcHeight, srcStride,
399 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING 400 qt_memrotate90_packing<DST,SRC>(src, srcWidth, srcHeight, srcStride,
402 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED 403 qt_memrotate90_tiled<DST,SRC>(src, srcWidth, srcHeight, srcStride,
408 template <
class DST,
class SRC>
410 int w,
int h,
int sstride,
411 DST *dest,
int dstride)
413 const char *s = (
const char*)(src) + (h - 1) * sstride;
414 for (
int y = h - 1; y >= 0; --y) {
415 DST *
d =
reinterpret_cast<DST*
>((
char *)(dest) + (h - y - 1) * dstride);
416 src =
reinterpret_cast<const SRC*
>(s);
417 for (
int x = w - 1; x >= 0; --x) {
418 d[w - x - 1] = qt_colorConvert<DST,SRC>(src[x], 0);
424 template <
class DST,
class SRC>
426 int srcWidth,
int srcHeight,
int srcStride,
427 DST *dest,
int dstStride)
429 #if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD 430 qt_memrotate270_cachedRead<DST,SRC>(src, srcWidth, srcHeight, srcStride,
432 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE 433 qt_memrotate270_cachedWrite<DST,SRC>(src, srcWidth, srcHeight, srcStride,
435 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING 436 qt_memrotate270_packing<DST,SRC>(src, srcWidth, srcHeight, srcStride,
438 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED 439 qt_memrotate270_tiled_unpacked<DST,SRC>(src, srcWidth, srcHeight,
448 int srcWidth,
int srcHeight,
int srcStride,
451 #if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD 452 qt_memrotate90_cachedRead<quint24,quint24>(src, srcWidth, srcHeight,
453 srcStride, dest, dstStride);
454 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE 455 qt_memrotate90_cachedWrite<quint24,quint24>(src, srcWidth, srcHeight,
456 srcStride, dest, dstStride);
457 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING 459 qt_memrotate90_cachedRead<quint24,quint24>(src, srcWidth, srcHeight,
460 srcStride, dest, dstStride);
461 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED 463 qt_memrotate90_tiled_unpacked<quint24,quint24>(src, srcWidth, srcHeight,
464 srcStride, dest, dstStride);
471 int srcWidth,
int srcHeight,
int srcStride,
474 #if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD 475 qt_memrotate90_cachedRead<quint24,quint32>(src, srcWidth, srcHeight,
476 srcStride, dest, dstStride);
477 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE 478 qt_memrotate90_cachedWrite<quint24,quint32>(src, srcWidth, srcHeight,
479 srcStride, dest, dstStride);
480 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING 482 qt_memrotate90_cachedRead<quint24,quint32>(src, srcWidth, srcHeight,
483 srcStride, dest, dstStride);
484 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED 486 qt_memrotate90_tiled_unpacked<quint24,quint32>(src, srcWidth, srcHeight,
487 srcStride, dest, dstStride);
494 int srcWidth,
int srcHeight,
int srcStride,
497 #if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD 498 qt_memrotate90_cachedRead<quint18,quint32>(src, srcWidth, srcHeight,
499 srcStride, dest, dstStride);
500 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE 501 qt_memrotate90_cachedWrite<quint18,quint32>(src, srcWidth, srcHeight,
502 srcStride, dest, dstStride);
503 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING 505 qt_memrotate90_cachedRead<quint18,quint32>(src, srcWidth, srcHeight,
506 srcStride, dest, dstStride);
507 #elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED 509 qt_memrotate90_tiled_unpacked<quint18,quint32>(src, srcWidth, srcHeight,
510 srcStride, dest, dstStride);
514 #define QT_IMPL_MEMROTATE(srctype, desttype) \ 515 void qt_memrotate90(const srctype *src, int w, int h, int sstride, \ 516 desttype *dest, int dstride) \ 518 qt_memrotate90_template(src, w, h, sstride, dest, dstride); \ 520 void qt_memrotate180(const srctype *src, int w, int h, int sstride, \ 521 desttype *dest, int dstride) \ 523 qt_memrotate180_template(src, w, h, sstride, dest, dstride); \ 525 void qt_memrotate270(const srctype *src, int w, int h, int sstride, \ 526 desttype *dest, int dstride) \ 528 qt_memrotate270_template(src, w, h, sstride, dest, dstride); \ 531 #define QT_IMPL_SIMPLE_MEMROTATE(srctype, desttype) \ 532 void qt_memrotate90(const srctype *src, int w, int h, int sstride, \ 533 desttype *dest, int dstride) \ 535 qt_memrotate90_tiled_unpacked<desttype,srctype>(src, w, h, sstride, dest, dstride); \ 537 void qt_memrotate180(const srctype *src, int w, int h, int sstride, \ 538 desttype *dest, int dstride) \ 540 qt_memrotate180_template(src, w, h, sstride, dest, dstride); \ 542 void qt_memrotate270(const srctype *src, int w, int h, int sstride, \ 543 desttype *dest, int dstride) \ 545 qt_memrotate270_tiled_unpacked<desttype,srctype>(src, w, h, sstride, dest, dstride); \ 563 #if defined(QT_QWS_ROTATE_BGR) 570 #ifdef QT_QWS_DEPTH_GENERIC 579 if (QSysInfo::ByteOrder == QSysInfo::LittleEndian)
580 data = ((v << 16) & 0xff0000) | ((v >> 16) & 0xff) | (v & 0xff00ff00);
582 data = (v << 8) | ((v >> 24) & 0xff);
594 qt_memrotate90_template(src, srcWidth, srcHeight, srcStride, reinterpret_cast<qrgb_gl_rgba *>(dest), dstStride);
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate90_tiled_unpacked(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)
static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
QIntegerForSizeof< void * >::Unsigned quintptr
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate90_tiled(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)
void qt_memrotate90_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
#define QT_IMPL_MEMROTATE(srctype, desttype)
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate270_cachedWrite(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate270_tiled_unpacked(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)
Q_STATIC_TEMPLATE_SPECIALIZATION void qt_memrotate90_template< quint24, quint32 >(const quint32 *src, int srcWidth, int srcHeight, int srcStride, quint24 *dest, int dstStride)
void qt_memrotate180_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
struct qrgb_gl_rgba Q_PACKED
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate180_template(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)
Q_STATIC_TEMPLATE_SPECIALIZATION void qt_memrotate90_template< quint24, quint24 >(const quint24 *src, int srcWidth, int srcHeight, int srcStride, quint24 *dest, int dstStride)
#define Q_STATIC_TEMPLATE_FUNCTION
void Q_GUI_QWS_EXPORT qt_memrotate180(const quint32 *, int, int, int, quint32 *, int)
void Q_GUI_EXPORT qt_memrotate90_gl(const quint32 *src, int srcWidth, int srcHeight, int srcStride, quint32 *dest, int dstStride)
void Q_GUI_EXPORT qt_memrotate90(const quint32 *, int, int, int, quint32 *, int)
Q_STATIC_TEMPLATE_SPECIALIZATION void qt_memrotate90_template< quint18, quint32 >(const quint32 *src, int srcWidth, int srcHeight, int srcStride, quint18 *dest, int dstStride)
#define QT_IMPL_SIMPLE_MEMROTATE(srctype, desttype)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
void qt_memrotate90_32(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
#define Q_STATIC_TEMPLATE_SPECIALIZATION
#define QT_BEGIN_NAMESPACE
This macro expands to.
void qt_memrotate270_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate90_cachedWrite(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)
void Q_GUI_QWS_EXPORT qt_memrotate270(const quint32 *, int, int, int, quint32 *, int)
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate270_cachedRead(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate90_cachedRead(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate90_template(const SRC *src, int srcWidth, int srcHeight, int srcStride, DST *dest, int dstStride)
MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3]
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate270_template(const SRC *src, int srcWidth, int srcHeight, int srcStride, DST *dest, int dstStride)
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate270_packing(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate270_tiled(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)
void qt_memrotate270_32(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
static const int tileSize
void(* MemRotateFunc)(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
void qt_memrotate180_32(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
Q_STATIC_TEMPLATE_FUNCTION void qt_memrotate90_packing(const SRC *src, int w, int h, int sstride, DST *dest, int dstride)