Get rid of QCustomRasterPaintDevice / QWS stuff in raster engine.
[profile/ivi/qtbase.git] / src / gui / painting / qdrawhelper_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtGui module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file.  Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 **
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QDRAWHELPER_P_H
43 #define QDRAWHELPER_P_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists purely as an
50 // implementation detail.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55
56 #include "QtCore/qglobal.h"
57 #include "QtGui/qcolor.h"
58 #include "QtGui/qpainter.h"
59 #include "QtGui/qimage.h"
60 #ifndef QT_FT_BEGIN_HEADER
61 #define QT_FT_BEGIN_HEADER
62 #define QT_FT_END_HEADER
63 #endif
64 #include "private/qrasterdefs_p.h"
65 #include <private/qsimd_p.h>
66
67 QT_BEGIN_NAMESPACE
68
69 #if defined(Q_CC_MSVC) && _MSCVER <= 1300 && !defined(Q_CC_INTEL)
70 #define Q_STATIC_TEMPLATE_SPECIALIZATION static
71 #else
72 #define Q_STATIC_TEMPLATE_SPECIALIZATION
73 #endif
74
75 #if defined(Q_CC_RVCT)
76 // RVCT doesn't like static template functions
77 #  define Q_STATIC_TEMPLATE_FUNCTION
78 #  define Q_STATIC_INLINE_FUNCTION static __forceinline
79 #else
80 #  define Q_STATIC_TEMPLATE_FUNCTION static
81 #  define Q_STATIC_INLINE_FUNCTION static inline
82 #endif
83
84 static const uint AMASK = 0xff000000;
85 static const uint RMASK = 0x00ff0000;
86 static const uint GMASK = 0x0000ff00;
87 static const uint BMASK = 0x000000ff;
88
89 /*******************************************************************************
90  * QSpan
91  *
92  * duplicate definition of FT_Span
93  */
94 typedef QT_FT_Span QSpan;
95
96 struct QSolidData;
97 struct QTextureData;
98 struct QGradientData;
99 struct QLinearGradientData;
100 struct QRadialGradientData;
101 struct QConicalGradientData;
102 struct QSpanData;
103 class QGradient;
104 class QRasterBuffer;
105 class QClipData;
106 class QRasterPaintEngineState;
107
108 typedef QT_FT_SpanFunc ProcessSpans;
109 typedef void (*BitmapBlitFunc)(QRasterBuffer *rasterBuffer,
110                                int x, int y, quint32 color,
111                                const uchar *bitmap,
112                                int mapWidth, int mapHeight, int mapStride);
113
114 typedef void (*AlphamapBlitFunc)(QRasterBuffer *rasterBuffer,
115                                  int x, int y, quint32 color,
116                                  const uchar *bitmap,
117                                  int mapWidth, int mapHeight, int mapStride,
118                                  const QClipData *clip);
119
120 typedef void (*AlphaRGBBlitFunc)(QRasterBuffer *rasterBuffer,
121                                  int x, int y, quint32 color,
122                                  const uint *rgbmask,
123                                  int mapWidth, int mapHeight, int mapStride,
124                                  const QClipData *clip);
125
126 typedef void (*RectFillFunc)(QRasterBuffer *rasterBuffer,
127                              int x, int y, int width, int height,
128                              quint32 color);
129
130 typedef void (*SrcOverBlendFunc)(uchar *destPixels, int dbpl,
131                                  const uchar *src, int spbl,
132                                  int w, int h,
133                                  int const_alpha);
134
135 typedef void (*SrcOverScaleFunc)(uchar *destPixels, int dbpl,
136                                  const uchar *src, int spbl,
137                                  const QRectF &targetRect,
138                                  const QRectF &sourceRect,
139                                  const QRect &clipRect,
140                                  int const_alpha);
141
142 typedef void (*SrcOverTransformFunc)(uchar *destPixels, int dbpl,
143                                      const uchar *src, int spbl,
144                                      const QRectF &targetRect,
145                                      const QRectF &sourceRect,
146                                      const QRect &clipRect,
147                                      const QTransform &targetRectTransform,
148                                      int const_alpha);
149
150 typedef void (*MemRotateFunc)(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl);
151
152 struct DrawHelper {
153     ProcessSpans blendColor;
154     ProcessSpans blendGradient;
155     BitmapBlitFunc bitmapBlit;
156     AlphamapBlitFunc alphamapBlit;
157     AlphaRGBBlitFunc alphaRGBBlit;
158     RectFillFunc fillRect;
159 };
160
161 extern SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats];
162 extern SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats];
163 extern SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats];
164 extern MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3];
165
166 extern DrawHelper qDrawHelper[QImage::NImageFormats];
167
168 void qBlendTexture(int count, const QSpan *spans, void *userData);
169
170 typedef void (QT_FASTCALL *CompositionFunction)(uint *dest, const uint *src, int length, uint const_alpha);
171 typedef void (QT_FASTCALL *CompositionFunctionSolid)(uint *dest, int length, uint color, uint const_alpha);
172
173 void qInitDrawhelperAsm();
174
175 class QRasterPaintEngine;
176
177 struct QSolidData
178 {
179     uint color;
180 };
181
182 struct QLinearGradientData
183 {
184     struct {
185         qreal x;
186         qreal y;
187     } origin;
188     struct {
189         qreal x;
190         qreal y;
191     } end;
192 };
193
194 struct QRadialGradientData
195 {
196     struct {
197         qreal x;
198         qreal y;
199     } center;
200     struct {
201         qreal x;
202         qreal y;
203     } focal;
204     qreal radius;
205 };
206
207 struct QConicalGradientData
208 {
209     struct {
210         qreal x;
211         qreal y;
212     } center;
213     qreal angle;
214 };
215
216 struct QGradientData
217 {
218     QGradient::Spread spread;
219
220     union {
221         QLinearGradientData linear;
222         QRadialGradientData radial;
223         QConicalGradientData conical;
224     };
225
226 #define GRADIENT_STOPTABLE_SIZE 1024
227
228     uint* colorTable; //[GRADIENT_STOPTABLE_SIZE];
229
230     uint alphaColor : 1;
231 };
232
233 struct QTextureData
234 {
235     const uchar *imageData;
236     const uchar *scanLine(int y) const { return imageData + y*bytesPerLine; }
237
238     int width;
239     int height;
240     // clip rect
241     int x1;
242     int y1;
243     int x2;
244     int y2;
245     int bytesPerLine;
246     QImage::Format format;
247     const QVector<QRgb> *colorTable;
248     bool hasAlpha;
249     enum Type {
250         Plain,
251         Tiled
252     };
253     Type type;
254     int const_alpha;
255 };
256
257 struct QSpanData
258 {
259     QSpanData() : tempImage(0) {}
260     ~QSpanData() { delete tempImage; }
261
262     QRasterBuffer *rasterBuffer;
263     ProcessSpans blend;
264     ProcessSpans unclipped_blend;
265     BitmapBlitFunc bitmapBlit;
266     AlphamapBlitFunc alphamapBlit;
267     AlphaRGBBlitFunc alphaRGBBlit;
268     RectFillFunc fillRect;
269     qreal m11, m12, m13, m21, m22, m23, m33, dx, dy;   // inverse xform matrix
270     const QClipData *clip;
271     enum Type {
272         None,
273         Solid,
274         LinearGradient,
275         RadialGradient,
276         ConicalGradient,
277         Texture
278     } type : 8;
279     int txop : 8;
280     int fast_matrix : 1;
281     bool bilinear;
282     QImage *tempImage;
283     union {
284         QSolidData solid;
285         QGradientData gradient;
286         QTextureData texture;
287     };
288
289     void init(QRasterBuffer *rb, const QRasterPaintEngine *pe);
290     void setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode);
291     void setupMatrix(const QTransform &matrix, int bilinear);
292     void initTexture(const QImage *image, int alpha, QTextureData::Type = QTextureData::Plain, const QRect &sourceRect = QRect());
293     void adjustSpanMethods();
294 };
295
296 #if defined(Q_CC_RVCT)
297 #  pragma push
298 #  pragma arm
299 #endif
300 Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) {
301     uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
302     t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
303     t &= 0xff00ff;
304
305     x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
306     x = (x + ((x >> 8) & 0xff00ff) + 0x800080);
307     x &= 0xff00ff00;
308     x |= t;
309     return x;
310 }
311 #if defined(Q_CC_RVCT)
312 #  pragma pop
313 #endif
314
315 #if QT_POINTER_SIZE == 8 // 64-bit versions
316
317 Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
318     quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
319     t += (((quint64(y)) | ((quint64(y)) << 24)) & 0x00ff00ff00ff00ff) * b;
320     t >>= 8;
321     t &= 0x00ff00ff00ff00ff;
322     return (uint(t)) | (uint(t >> 24));
323 }
324
325 Q_STATIC_INLINE_FUNCTION uint BYTE_MUL(uint x, uint a) {
326     quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
327     t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080) >> 8;
328     t &= 0x00ff00ff00ff00ff;
329     return (uint(t)) | (uint(t >> 24));
330 }
331
332 Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) {
333     uint a = x >> 24;
334     quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
335     t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080) >> 8;
336     t &= 0x000000ff00ff00ff;
337     return (uint(t)) | (uint(t >> 24)) | (a << 24);
338 }
339
340 #else // 32-bit versions
341
342 Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
343     uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
344     t >>= 8;
345     t &= 0xff00ff;
346
347     x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
348     x &= 0xff00ff00;
349     x |= t;
350     return x;
351 }
352
353 #if defined(Q_CC_RVCT)
354 #  pragma push
355 #  pragma arm
356 #endif
357 Q_STATIC_INLINE_FUNCTION uint BYTE_MUL(uint x, uint a) {
358     uint t = (x & 0xff00ff) * a;
359     t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
360     t &= 0xff00ff;
361
362     x = ((x >> 8) & 0xff00ff) * a;
363     x = (x + ((x >> 8) & 0xff00ff) + 0x800080);
364     x &= 0xff00ff00;
365     x |= t;
366     return x;
367 }
368 #if defined(Q_CC_RVCT)
369 #  pragma pop
370 #endif
371
372 Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) {
373     uint a = x >> 24;
374     uint t = (x & 0xff00ff) * a;
375     t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
376     t &= 0xff00ff;
377
378     x = ((x >> 8) & 0xff) * a;
379     x = (x + ((x >> 8) & 0xff) + 0x80);
380     x &= 0xff00;
381     x |= t | (a << 24);
382     return x;
383 }
384 #endif
385
386
387 Q_STATIC_INLINE_FUNCTION uint BYTE_MUL_RGB16(uint x, uint a) {
388     a += 1;
389     uint t = (((x & 0x07e0)*a) >> 8) & 0x07e0;
390     t |= (((x & 0xf81f)*(a>>2)) >> 6) & 0xf81f;
391     return t;
392 }
393
394 Q_STATIC_INLINE_FUNCTION uint BYTE_MUL_RGB16_32(uint x, uint a) {
395     uint t = (((x & 0xf81f07e0) >> 5)*a) & 0xf81f07e0;
396     t |= (((x & 0x07e0f81f)*a) >> 5) & 0x07e0f81f;
397     return t;
398 }
399
400 #define INV_PREMUL(p)                                   \
401     (qAlpha(p) == 0 ? 0 :                               \
402     ((qAlpha(p) << 24)                                  \
403      | (((255*qRed(p))/ qAlpha(p)) << 16)               \
404      | (((255*qGreen(p)) / qAlpha(p))  << 8)            \
405      | ((255*qBlue(p)) / qAlpha(p))))
406
407 template <class DST, class SRC>
408 inline DST qt_colorConvert(SRC color, DST dummy)
409 {
410     Q_UNUSED(dummy);
411     return DST(color);
412 }
413
414
415 template <>
416 inline quint32 qt_colorConvert(quint16 color, quint32 dummy)
417 {
418     Q_UNUSED(dummy);
419     const int r = (color & 0xf800);
420     const int g = (color & 0x07e0);
421     const int b = (color & 0x001f);
422     const int tr = (r >> 8) | (r >> 13);
423     const int tg = (g >> 3) | (g >> 9);
424     const int tb = (b << 3) | (b >> 2);
425
426     return qRgb(tr, tg, tb);
427 }
428
429 template <>
430 inline quint16 qt_colorConvert(quint32 color, quint16 dummy)
431 {
432     Q_UNUSED(dummy);
433     const int r = qRed(color) << 8;
434     const int g = qGreen(color) << 3;
435     const int b = qBlue(color) >> 3;
436
437     return (r & 0xf800) | (g & 0x07e0)| (b & 0x001f);
438 }
439
440 class quint32p
441 {
442 public:
443     inline quint32p(quint32 v) : data(PREMUL(v)) {}
444
445     inline operator quint32() const { return data; }
446
447     inline operator quint16() const
448     {
449         return qt_colorConvert<quint16, quint32>(data, 0);
450     }
451
452     Q_STATIC_INLINE_FUNCTION quint32p fromRawData(quint32 v)
453     {
454         quint32p p;
455         p.data = v;
456         return p;
457     }
458
459 private:
460     quint32p() {}
461     quint32 data;
462 } Q_PACKED;
463
464 class qabgr8888
465 {
466 public:
467     inline qabgr8888(quint32 v)
468     {
469         data = qRgba(qBlue(v), qGreen(v), qRed(v), qAlpha(v));
470     }
471
472     inline bool operator==(const qabgr8888 &v) const { return data == v.data; }
473
474 private:
475     quint32 data;
476 } Q_PACKED;
477
478 class qrgb565;
479
480 class qargb8565
481 {
482 public:
483     Q_STATIC_INLINE_FUNCTION bool hasAlpha() { return true; }
484
485     inline qargb8565() {}
486     inline qargb8565(quint32 v);
487     inline explicit qargb8565(quint32p v);
488     inline qargb8565(const qargb8565 &v);
489     inline qargb8565(const qrgb565 &v);
490
491     inline operator quint32() const;
492     inline operator quint16() const;
493
494     inline quint8 alpha() const { return data[0]; }
495     inline qargb8565 truncedAlpha() {
496         data[0] &= 0xf8;
497         data[1] &= 0xdf;
498         return *this;
499     }
500     Q_STATIC_INLINE_FUNCTION quint8 alpha(quint8 a) { return (a + 1) >> 3; }
501     Q_STATIC_INLINE_FUNCTION quint8 ialpha(quint8 a) { return 0x20 - alpha(a); }
502
503     inline qargb8565 byte_mul(quint8 a) const;
504     inline qargb8565 operator+(qargb8565 v) const;
505     inline bool operator==(const qargb8565 &v) const;
506
507     inline quint32 rawValue() const;
508     inline quint16 rawValue16() const;
509
510 private:
511     friend class qrgb565;
512
513     quint8 data[3];
514 } Q_PACKED;
515
516 class qrgb565
517 {
518 public:
519     Q_STATIC_INLINE_FUNCTION bool hasAlpha() { return false; }
520
521     qrgb565(int v = 0) : data(v) {}
522
523     inline explicit qrgb565(quint32p v);
524     inline explicit qrgb565(quint32 v);
525     inline explicit qrgb565(const qargb8565 &v);
526
527     inline operator quint32() const;
528     inline operator quint16() const;
529
530     inline qrgb565 operator+(qrgb565 v) const;
531
532     inline quint8 alpha() const { return 0xff; }
533     inline qrgb565 truncedAlpha() { return *this; }
534     Q_STATIC_INLINE_FUNCTION quint8 alpha(quint8 a) { return (a + 1) >> 3; }
535     Q_STATIC_INLINE_FUNCTION quint8 ialpha(quint8 a) { return 0x20 - alpha(a); }
536
537     inline qrgb565 byte_mul(quint8 a) const;
538
539     inline bool operator==(const qrgb565 &v) const;
540     inline quint16 rawValue() const { return data; }
541
542 private:
543     friend class qargb8565;
544
545     quint16 data;
546 } Q_PACKED;
547
548 qargb8565::qargb8565(quint32 v)
549 {
550     *this = qargb8565(quint32p(v));
551 }
552
553 qargb8565::qargb8565(quint32p v)
554 {
555     data[0] = qAlpha(v);
556     const int r = qRed(v);
557     const int g = qGreen(v);
558     const int b = qBlue(v);
559     data[1] = ((g << 3) & 0xe0) | (b >> 3);
560     data[2] = (r & 0xf8) | (g >> 5);
561 }
562
563 qargb8565::qargb8565(const qargb8565 &v)
564 {
565     data[0] = v.data[0];
566     data[1] = v.data[1];
567     data[2] = v.data[2];
568 }
569
570 qargb8565::qargb8565(const qrgb565 &v)
571 {
572     data[0] = 0xff;
573     data[1] = v.data & 0xff;
574     data[2] = v.data >> 8;
575 }
576
577 qargb8565::operator quint32() const
578 {
579     const quint16 rgb = (data[2] << 8) | data[1];
580     const int a = data[0];
581     const int r = (rgb & 0xf800);
582     const int g = (rgb & 0x07e0);
583     const int b = (rgb & 0x001f);
584     const int tr = qMin(a, (r >> 8) | (r >> 13));
585     const int tg = qMin(a, (g >> 3) | (g >> 9));
586     const int tb = qMin(a, (b << 3) | (b >> 2));
587     return qRgba(tr, tg, tb, data[0]);
588 }
589
590 qargb8565::operator quint16() const
591 {
592     return (data[2] << 8) | data[1];
593 }
594
595 qargb8565 qargb8565::operator+(qargb8565 v) const
596 {
597     qargb8565 t;
598     t.data[0] = data[0] + v.data[0];
599     const quint16 rgb =  ((data[2] + v.data[2]) << 8)
600                          + (data[1] + v.data[1]);
601     t.data[1] = rgb & 0xff;
602     t.data[2] = rgb >> 8;
603     return t;
604 }
605
606 qargb8565 qargb8565::byte_mul(quint8 a) const
607 {
608     qargb8565 result;
609     result.data[0] = (data[0] * a) >> 5;
610
611     const quint16 x = (data[2] << 8) | data[1];
612     const quint16 t = ((((x & 0x07e0) >> 5) * a) & 0x07e0) |
613                       ((((x & 0xf81f) * a) >> 5) & 0xf81f);
614     result.data[1] = t & 0xff;
615     result.data[2] = t >> 8;
616     return result;
617 }
618
619 bool qargb8565::operator==(const qargb8565 &v) const
620 {
621     return data[0] == v.data[0]
622         && data[1] == v.data[1]
623         && data[2] == v.data[2];
624 }
625
626 quint32 qargb8565::rawValue() const
627 {
628     return (data[2] << 16) | (data[1] << 8) | data[0];
629 }
630
631 quint16 qargb8565::rawValue16() const
632 {
633     return (data[2] << 8) | data[1];
634 }
635
636 qrgb565::qrgb565(quint32p v)
637 {
638     *this = qrgb565(quint32(v));
639 }
640
641 qrgb565::qrgb565(quint32 v)
642 {
643     const int r = qRed(v) << 8;
644     const int g = qGreen(v) << 3;
645     const int b = qBlue(v) >> 3;
646
647     data = (r & 0xf800) | (g & 0x07e0)| (b & 0x001f);
648 }
649
650 qrgb565::qrgb565(const qargb8565 &v)
651 {
652     data = (v.data[2] << 8) | v.data[1];
653 }
654
655 qrgb565::operator quint32() const
656 {
657     const int r = (data & 0xf800);
658     const int g = (data & 0x07e0);
659     const int b = (data & 0x001f);
660     const int tr = (r >> 8) | (r >> 13);
661     const int tg = (g >> 3) | (g >> 9);
662     const int tb = (b << 3) | (b >> 2);
663     return qRgb(tr, tg, tb);
664 }
665
666 qrgb565::operator quint16() const
667 {
668     return data;
669 }
670
671 qrgb565 qrgb565::operator+(qrgb565 v) const
672 {
673     qrgb565 t;
674     t.data = data + v.data;
675     return t;
676 }
677
678 qrgb565 qrgb565::byte_mul(quint8 a) const
679 {
680     qrgb565 result;
681     result.data = ((((data & 0x07e0) >> 5) * a) & 0x07e0) |
682                   ((((data & 0xf81f) * a) >> 5) & 0xf81f);
683     return result;
684 }
685
686 bool qrgb565::operator==(const qrgb565 &v) const
687 {
688     return data == v.data;
689 }
690
691 class qbgr565
692 {
693 public:
694     inline qbgr565(quint16 v)
695     {
696         data = ((v & 0x001f) << 11) |
697                (v & 0x07e0) |
698                ((v & 0xf800) >> 11);
699     }
700
701     inline bool operator==(const qbgr565 &v) const
702     {
703         return data == v.data;
704     }
705
706 private:
707     quint16 data;
708 } Q_PACKED;
709
710 class qrgb555;
711
712 class qargb8555
713 {
714 public:
715     Q_STATIC_INLINE_FUNCTION bool hasAlpha() { return true; }
716
717     qargb8555() {}
718     inline qargb8555(quint32 v);
719     inline explicit qargb8555(quint32p v);
720     inline qargb8555(const qargb8555 &v);
721     inline qargb8555(const qrgb555 &v);
722
723     inline operator quint32() const;
724
725     inline quint8 alpha() const { return data[0]; }
726     inline qargb8555 truncedAlpha() { data[0] &= 0xf8; return *this; }
727     Q_STATIC_INLINE_FUNCTION quint8 alpha(quint8 a) { return (a + 1) >> 3; }
728     Q_STATIC_INLINE_FUNCTION quint8 ialpha(quint8 a) { return 0x20 - alpha(a); }
729
730     inline qargb8555 operator+(qargb8555 v) const;
731     inline qargb8555 byte_mul(quint8 a) const;
732
733     inline bool operator==(const qargb8555 &v) const;
734
735     inline quint32 rawValue() const;
736
737 private:
738     friend class qrgb555;
739     quint8 data[3];
740 } Q_PACKED;
741
742 class qrgb555
743 {
744 public:
745     Q_STATIC_INLINE_FUNCTION bool hasAlpha() { return false; }
746
747     inline qrgb555(int v = 0) : data(v) {}
748
749     inline explicit qrgb555(quint32p v) { *this = qrgb555(quint32(v)); }
750
751     inline explicit qrgb555(quint32 v)
752     {
753         const int r = qRed(v) << 7;
754         const int g = qGreen(v) << 2;
755         const int b = qBlue(v) >> 3;
756
757         data = (r & 0x7c00) | (g & 0x03e0) | (b & 0x001f);
758     }
759
760     inline explicit qrgb555(quint16 v)
761     {
762         data = ((v >> 1) & (0x7c00 | 0x03e0)) |
763                (v & 0x001f);
764     }
765
766     inline explicit qrgb555(const qargb8555 &v);
767
768     inline operator quint32() const
769     {
770         const int r = (data & 0x7c00);
771         const int g = (data & 0x03e0);
772         const int b = (data & 0x001f);
773         const int tr = (r >> 7) | (r >> 12);
774         const int tg = (g >> 2) | (g >> 7);
775         const int tb = (b << 3) | (b >> 2);
776
777         return qRgb(tr, tg, tb);
778     }
779
780     inline operator quint16() const
781     {
782         const int r = ((data & 0x7c00) << 1) & 0xf800;
783         const int g = (((data & 0x03e0) << 1) | ((data >> 4) & 0x0020)) & 0x07e0;
784         const int b = (data & 0x001f);
785
786         return r | g | b;
787     }
788
789     inline qrgb555 operator+(qrgb555 v) const;
790     inline qrgb555 byte_mul(quint8 a) const;
791
792     inline quint8 alpha() const { return 0xff; }
793     inline qrgb555 truncedAlpha() { return *this; }
794     Q_STATIC_INLINE_FUNCTION quint8 alpha(quint8 a) { return (a + 1) >> 3; }
795     Q_STATIC_INLINE_FUNCTION quint8 ialpha(quint8 a) { return 0x20 - alpha(a); }
796
797     inline bool operator==(const qrgb555 &v) const { return v.data == data; }
798     inline bool operator!=(const qrgb555 &v) const { return v.data != data; }
799
800     inline quint16 rawValue() const { return data; }
801
802 private:
803     friend class qargb8555;
804     friend class qbgr555;
805     quint16 data;
806
807 } Q_PACKED;
808
809 qrgb555::qrgb555(const qargb8555 &v)
810 {
811     data = (v.data[2] << 8) | v.data[1];
812 }
813
814 qrgb555 qrgb555::operator+(qrgb555 v) const
815 {
816     qrgb555 t;
817     t.data = data + v.data;
818     return t;
819 }
820
821 qrgb555 qrgb555::byte_mul(quint8 a) const
822 {
823     quint16 t = (((data & 0x3e0) * a) >> 5) & 0x03e0;
824     t |= (((data & 0x7c1f) * a) >> 5) & 0x7c1f;
825
826     qrgb555 result;
827     result.data = t;
828     return result;
829 }
830
831 class qbgr555
832 {
833 public:
834     inline qbgr555(quint32 v) { *this = qbgr555(qrgb555(v)); }
835
836     inline qbgr555(qrgb555 v)
837     {
838         data = ((v.data & 0x001f) << 10) |
839                (v.data & 0x03e0) |
840                ((v.data & 0x7c00) >> 10);
841     }
842
843     inline bool operator==(const qbgr555 &v) const
844     {
845         return data == v.data;
846     }
847
848 private:
849     quint16 data;
850 } Q_PACKED;
851
852 qargb8555::qargb8555(quint32 v)
853 {
854     v = quint32p(v);
855     data[0] = qAlpha(v);
856     const int r = qRed(v);
857     const int g = qGreen(v);
858     const int b = qBlue(v);
859     data[1] = ((g << 2) & 0xe0) | (b >> 3);
860     data[2] = ((r >> 1) & 0x7c) | (g >> 6);
861
862 }
863
864 qargb8555::qargb8555(quint32p v)
865 {
866     data[0] = qAlpha(v);
867     const int r = qRed(v);
868     const int g = qGreen(v);
869     const int b = qBlue(v);
870     data[1] = ((g << 2) & 0xe0) | (b >> 3);
871     data[2] = ((r >> 1) & 0x7c) | (g >> 6);
872 }
873
874 qargb8555::qargb8555(const qargb8555 &v)
875 {
876     data[0] = v.data[0];
877     data[1] = v.data[1];
878     data[2] = v.data[2];
879 }
880
881 qargb8555::qargb8555(const qrgb555 &v)
882 {
883     data[0] = 0xff;
884     data[1] = v.data & 0xff;
885     data[2] = v.data >> 8;
886 }
887
888 qargb8555::operator quint32() const
889 {
890     const quint16 rgb = (data[2] << 8) | data[1];
891     const int r = (rgb & 0x7c00);
892     const int g = (rgb & 0x03e0);
893     const int b = (rgb & 0x001f);
894     const int tr = (r >> 7) | (r >> 12);
895     const int tg = (g >> 2) | (g >> 7);
896     const int tb = (b << 3) | (b >> 2);
897
898     return qRgba(tr, tg, tb, data[0]);
899 }
900
901 bool qargb8555::operator==(const qargb8555 &v) const
902 {
903     return data[0] == v.data[0]
904         && data[1] == v.data[1]
905         && data[2] == v.data[2];
906 }
907
908 quint32 qargb8555::rawValue() const
909 {
910     return (data[2] << 16) | (data[1] << 8) | data[0];
911 }
912
913 qargb8555 qargb8555::operator+(qargb8555 v) const
914 {
915     qargb8555 t;
916     t.data[0] = data[0] + v.data[0];
917     const quint16 rgb =  ((data[2] + v.data[2]) << 8)
918                          + (data[1] + v.data[1]);
919     t.data[1] = rgb & 0xff;
920     t.data[2] = rgb >> 8;
921     return t;
922 }
923
924 qargb8555 qargb8555::byte_mul(quint8 a) const
925 {
926     qargb8555 result;
927     result.data[0] = (data[0] * a) >> 5;
928
929     const quint16 x = (data[2] << 8) | data[1];
930     quint16 t = (((x & 0x3e0) * a) >> 5) & 0x03e0;
931     t |= (((x & 0x7c1f) * a) >> 5) & 0x7c1f;
932     result.data[1] = t & 0xff;
933     result.data[2] = t >> 8;
934     return result;
935
936 }
937
938 class qrgb666;
939
940 class qargb6666
941 {
942 public:
943     Q_STATIC_INLINE_FUNCTION bool hasAlpha() { return true; }
944
945     inline qargb6666() {}
946     inline qargb6666(quint32 v) { *this = qargb6666(quint32p(v)); }
947     inline explicit qargb6666(quint32p v);
948     inline qargb6666(const qargb6666 &v);
949     inline qargb6666(const qrgb666 &v);
950
951     inline operator quint32 () const;
952
953     inline quint8 alpha() const;
954     inline qargb6666 truncedAlpha() { return *this; }
955     Q_STATIC_INLINE_FUNCTION quint8 alpha(quint8 a) { return (a + 1) >> 2; }
956     Q_STATIC_INLINE_FUNCTION quint8 ialpha(quint8 a) { return (255 - a + 1) >> 2; }
957
958     inline qargb6666 byte_mul(quint8 a) const;
959     inline qargb6666 operator+(qargb6666 v) const;
960     inline bool operator==(const qargb6666 &v) const;
961
962     inline quint32 rawValue() const;
963
964 private:
965     friend class qrgb666;
966     quint8 data[3];
967
968 } Q_PACKED;
969
970 class qrgb666
971 {
972 public:
973     Q_STATIC_INLINE_FUNCTION bool hasAlpha() { return false; }
974
975     inline qrgb666() {}
976     inline qrgb666(quint32 v);
977     inline qrgb666(const qargb6666 &v);
978
979     inline operator quint32 () const;
980
981     inline quint8 alpha() const { return 0xff; }
982     inline qrgb666 truncedAlpha() { return *this; }
983     Q_STATIC_INLINE_FUNCTION quint8 alpha(quint8 a) { return (a + 1) >> 2; }
984     Q_STATIC_INLINE_FUNCTION quint8 ialpha(quint8 a) { return (255 - a + 1) >> 2; }
985
986     inline qrgb666 operator+(qrgb666 v) const;
987     inline qrgb666 byte_mul(quint8 a) const;
988
989     inline bool operator==(const qrgb666 &v) const;
990     inline bool operator!=(const qrgb666 &v) const { return !(*this == v); }
991
992     inline quint32 rawValue() const
993     {
994         return (data[2] << 16) | (data[1] << 8) | data[0];
995     }
996
997 private:
998     friend class qargb6666;
999
1000     quint8 data[3];
1001 } Q_PACKED;
1002
1003 qrgb666::qrgb666(quint32 v)
1004 {
1005     const uchar b = qBlue(v);
1006     const uchar g = qGreen(v);
1007     const uchar r = qRed(v);
1008     const uint p = (b >> 2) | ((g >> 2) << 6) | ((r >> 2) << 12);
1009     data[0] = qBlue(p);
1010     data[1] = qGreen(p);
1011     data[2] = qRed(p);
1012 }
1013
1014 qrgb666::qrgb666(const qargb6666 &v)
1015 {
1016     data[0] = v.data[0];
1017     data[1] = v.data[1];
1018     data[2] = v.data[2] & 0x03;
1019 }
1020
1021 qrgb666::operator quint32 () const
1022 {
1023     const uchar r = (data[2] << 6) | ((data[1] & 0xf0) >> 2) | (data[2] & 0x3);
1024     const uchar g = (data[1] << 4) | ((data[0] & 0xc0) >> 4) | ((data[1] & 0x0f) >> 2);
1025     const uchar b = (data[0] << 2) | ((data[0] & 0x3f) >> 4);
1026     return qRgb(r, g, b);
1027 }
1028
1029 qrgb666 qrgb666::operator+(qrgb666 v) const
1030 {
1031     const quint32 x1 = (data[2] << 16) | (data[1] << 8) | data[0];
1032     const quint32 x2 = (v.data[2] << 16) | (v.data[1] << 8) | v.data[0];
1033     const quint32 t = x1 + x2;
1034     qrgb666 r;
1035     r.data[0] = t & 0xff;
1036     r.data[1] = (t >> 8) & 0xff;
1037     r.data[2] = (t >> 16) & 0xff;
1038     return r;
1039 }
1040
1041 qrgb666 qrgb666::byte_mul(quint8 a) const
1042 {
1043     const quint32 x = (data[2] << 16) | (data[1] << 8) | data[0];
1044     const quint32 t = ((((x & 0x03f03f) * a) >> 6) & 0x03f03f) |
1045                       ((((x & 0x000fc0) * a) >> 6) & 0x000fc0);
1046
1047     qrgb666 r;
1048     r.data[0] = t & 0xff;
1049     r.data[1] = (t >> 8) & 0xff;
1050     r.data[2] = (t >> 16) & 0xff;
1051     return r;
1052 }
1053
1054 bool qrgb666::operator==(const qrgb666 &v) const
1055 {
1056     return (data[0] == v.data[0] &&
1057             data[1] == v.data[1] &&
1058             data[2] == v.data[2]);
1059 }
1060
1061 qargb6666::qargb6666(quint32p v)
1062 {
1063     const quint8 b = qBlue(v) >> 2;
1064     const quint8 g = qGreen(v) >> 2;
1065     const quint8 r = qRed(v) >> 2;
1066     const quint8 a = qAlpha(v) >> 2;
1067     const uint p = (a << 18) | (r << 12) | (g << 6) | b;
1068     data[0] = qBlue(p);
1069     data[1] = qGreen(p);
1070     data[2] = qRed(p);
1071 }
1072
1073 qargb6666::qargb6666(const qargb6666 &v)
1074 {
1075     data[0] = v.data[0];
1076     data[1] = v.data[1];
1077     data[2] = v.data[2];
1078 }
1079
1080 qargb6666::qargb6666(const qrgb666 &v)
1081 {
1082     data[0] = v.data[0];
1083     data[1] = v.data[1];
1084     data[2] = (v.data[2] | 0xfc);
1085 }
1086
1087 qargb6666::operator quint32 () const
1088 {
1089     const quint8 r = (data[2] << 6) | ((data[1] & 0xf0) >> 2) | (data[2] & 0x3);
1090     const quint8 g = (data[1] << 4) | ((data[0] & 0xc0) >> 4) | ((data[1] & 0x0f) >> 2);
1091     const quint8 b = (data[0] << 2) | ((data[0] & 0x3f) >> 4);
1092     const quint8 a = (data[2] & 0xfc) | (data[2] >> 6);
1093     return qRgba(r, g, b, a);
1094 }
1095
1096 qargb6666 qargb6666::operator+(qargb6666 v) const
1097 {
1098     const quint32 x1 = (data[2] << 16) | (data[1] << 8) | data[0];
1099     const quint32 x2 = (v.data[2] << 16) | (v.data[1] << 8) | v.data[0];
1100     const quint32 t = x1 + x2;
1101     qargb6666 r;
1102     r.data[0] = t & 0xff;
1103     r.data[1] = (t >> 8) & 0xff;
1104     r.data[2] = (t >> 16) & 0xff;
1105     return r;
1106 }
1107
1108 quint8 qargb6666::alpha() const
1109 {
1110     return (data[2] & 0xfc) | (data[2] >> 6);
1111 }
1112
1113 inline qargb6666 qargb6666::byte_mul(quint8 a) const
1114 {
1115     const quint32 x = (data[2] << 16) | (data[1] << 8) | data[0];
1116     const quint32 t = ((((x & 0x03f03f) * a) >> 6) & 0x03f03f) |
1117                       ((((x & 0xfc0fc0) * a) >> 6) & 0xfc0fc0);
1118
1119     qargb6666 r;
1120     r.data[0] = t & 0xff;
1121     r.data[1] = (t >> 8) & 0xff;
1122     r.data[2] = (t >> 16) & 0xff;
1123     return r;
1124 }
1125
1126 bool qargb6666::operator==(const qargb6666 &v) const
1127 {
1128     return data[0] == v.data[0]
1129         && data[1] == v.data[1]
1130         && data[2] == v.data[2];
1131 }
1132
1133 quint32 qargb6666::rawValue() const
1134 {
1135     return (data[2] << 16) | (data[1] << 8) | data[0];
1136 }
1137
1138 class qrgb888
1139 {
1140 public:
1141     Q_STATIC_INLINE_FUNCTION bool hasAlpha() { return false; }
1142
1143     inline qrgb888() {}
1144     inline qrgb888(quint32 v);
1145
1146     inline operator quint32() const;
1147
1148     inline quint8 alpha() const { return 0xff; }
1149     inline qrgb888 truncedAlpha() { return *this; }
1150     Q_STATIC_INLINE_FUNCTION quint8 alpha(quint8 a) { return a; }
1151     Q_STATIC_INLINE_FUNCTION quint8 ialpha(quint8 a) { return 255 - a; }
1152
1153     inline qrgb888 byte_mul(quint8 a) const;
1154     inline qrgb888 operator+(qrgb888 v) const;
1155     inline bool operator==(qrgb888 v) const;
1156
1157     inline quint32 rawValue() const;
1158
1159 private:
1160     uchar data[3];
1161
1162 } Q_PACKED;
1163
1164 qrgb888::qrgb888(quint32 v)
1165 {
1166     data[0] = qRed(v);
1167     data[1] = qGreen(v);
1168     data[2] = qBlue(v);
1169 }
1170
1171 qrgb888::operator quint32() const
1172 {
1173     return qRgb(data[0], data[1], data[2]);
1174 }
1175
1176 qrgb888 qrgb888::operator+(qrgb888 v) const
1177 {
1178     qrgb888 t = *this;
1179     t.data[0] += v.data[0];
1180     t.data[1] += v.data[1];
1181     t.data[2] += v.data[2];
1182     return t;
1183 }
1184
1185 qrgb888 qrgb888::byte_mul(quint8 a) const
1186 {
1187     quint32 x(*this);
1188
1189     quint32 t = (x & 0xff00ff) * a;
1190     t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
1191     t &= 0xff00ff;
1192
1193     x = ((x >> 8) & 0xff00ff) * a;
1194     x = (x + ((x >> 8) & 0xff00ff) + 0x800080);
1195     x &= 0xff00ff00;
1196     x |= t;
1197     return qrgb888(x);
1198 }
1199
1200 bool qrgb888::operator==(qrgb888 v) const
1201 {
1202     return (data[0] == v.data[0] &&
1203             data[1] == v.data[1] &&
1204             data[2] == v.data[2]);
1205 }
1206
1207 quint32 qrgb888::rawValue() const
1208 {
1209     return (data[2] << 16) | (data[1] << 8) | data[0];
1210 }
1211
1212 template <>
1213 inline qrgb888 qt_colorConvert(quint32 color, qrgb888 dummy)
1214 {
1215     Q_UNUSED(dummy);
1216     return qrgb888(color);
1217 }
1218
1219 template <>
1220 inline quint32 qt_colorConvert(qrgb888 color, quint32 dummy)
1221 {
1222     Q_UNUSED(dummy);
1223     return quint32(color);
1224 }
1225
1226 // hw: endianess??
1227 class quint24
1228 {
1229 public:
1230     inline quint24(quint32 v)
1231     {
1232         data[0] = qBlue(v);
1233         data[1] = qGreen(v);
1234         data[2] = qRed(v);
1235     }
1236
1237     inline operator quint32 ()
1238     {
1239         return qRgb(data[2], data[1], data[0]);
1240     }
1241
1242     inline bool operator==(const quint24 &v) const
1243     {
1244         return data[0] == v.data[0]
1245             && data[1] == v.data[1]
1246             && data[2] == v.data[2];
1247     }
1248
1249 private:
1250     uchar data[3];
1251 } Q_PACKED;
1252
1253 template <>
1254 inline quint24 qt_colorConvert(quint32 color, quint24 dummy)
1255 {
1256     Q_UNUSED(dummy);
1257     return quint24(color);
1258 }
1259
1260 // hw: endianess??
1261 class quint18
1262 {
1263 public:
1264     inline quint18(quint32 v)
1265     {
1266         uchar b = qBlue(v);
1267         uchar g = qGreen(v);
1268         uchar r = qRed(v);
1269         uint p = (b >> 2) | ((g >> 2) << 6) | ((r >> 2) << 12);
1270         data[0] = qBlue(p);
1271         data[1] = qGreen(p);
1272         data[2] = qRed(p);
1273     }
1274
1275     inline operator quint32 ()
1276     {
1277         const uchar r = (data[2] << 6) | ((data[1] & 0xf0) >> 2) | (data[2] & 0x3);
1278         const uchar g = (data[1] << 4) | ((data[0] & 0xc0) >> 4) | ((data[1] & 0x0f) >> 2);
1279         const uchar b = (data[0] << 2) | ((data[0] & 0x3f) >> 4);
1280         return qRgb(r, g, b);
1281     }
1282
1283 private:
1284     uchar data[3];
1285 } Q_PACKED;
1286
1287 template <>
1288 inline quint18 qt_colorConvert(quint32 color, quint18 dummy)
1289 {
1290     Q_UNUSED(dummy);
1291     return quint18(color);
1292 }
1293
1294 class qrgb444;
1295
1296 class qargb4444
1297 {
1298 public:
1299     Q_STATIC_INLINE_FUNCTION bool hasAlpha() { return true; }
1300
1301     inline qargb4444() {}
1302     inline qargb4444(quint32 v) { *this = qargb4444(quint32p(v)); }
1303     inline explicit qargb4444(quint32p v);
1304     inline qargb4444(const qrgb444 &v);
1305
1306     inline operator quint32() const;
1307     inline operator quint8() const;
1308
1309     inline qargb4444 operator+(qargb4444 v) const;
1310
1311     inline quint8 alpha() const { return ((data & 0xf000) >> 8) | ((data & 0xf000) >> 12); }
1312     inline qargb4444 truncedAlpha() { return *this; }
1313     Q_STATIC_INLINE_FUNCTION quint8 alpha(quint8 a) { return (a + 1) >> 4; }
1314     Q_STATIC_INLINE_FUNCTION quint8 ialpha(quint8 a) { return 0x10 - alpha(a); }
1315     inline qargb4444 byte_mul(quint8 a) const;
1316
1317     inline bool operator==(const qargb4444 &v) const { return data == v.data; }
1318
1319     inline quint16 rawValue() const { return data; }
1320
1321 private:
1322     friend class qrgb444;
1323     quint16 data;
1324
1325 } Q_PACKED;
1326
1327 class qrgb444
1328 {
1329 public:
1330     Q_STATIC_INLINE_FUNCTION bool hasAlpha() { return false; }
1331
1332     inline qrgb444() {}
1333     inline qrgb444(quint32 v);
1334     inline explicit qrgb444(qargb4444 v);
1335
1336     inline operator quint32() const;
1337     inline operator quint8() const;
1338
1339     inline qrgb444 operator+(qrgb444 v) const;
1340     inline quint8 alpha() const { return 0xff; }
1341     inline qrgb444 truncedAlpha() { return *this; }
1342     Q_STATIC_INLINE_FUNCTION quint8 alpha(quint8 a) { return (a + 1) >> 4; }
1343     Q_STATIC_INLINE_FUNCTION quint8 ialpha(quint8 a) { return 0x10 - alpha(a); }
1344     inline qrgb444 byte_mul(quint8 a) const;
1345
1346     inline bool operator==(const qrgb444 &v) const { return data == v.data; }
1347     inline bool operator!=(const qrgb444 &v) const { return data != v.data; }
1348
1349     inline quint16 rawValue() const { return data; }
1350
1351 private:
1352     friend class qargb4444;
1353     quint16 data;
1354
1355 } Q_PACKED;
1356
1357
1358 qargb4444::qargb4444(quint32p color)
1359 {
1360     quint32 v = color;
1361     v &= 0xf0f0f0f0;
1362     const int a = qAlpha(v) << 8;
1363     const int r = qRed(v) << 4;
1364     const int g = qGreen(v);
1365     const int b = qBlue(v) >> 4;
1366
1367     data = a | r | g | b;
1368 }
1369
1370 qargb4444::qargb4444(const qrgb444 &v)
1371 {
1372     data = v.data | 0xf000;
1373 }
1374
1375 qargb4444::operator quint32() const
1376 {
1377     const int a = (data & 0xf000);
1378     const int r = (data & 0x0f00);
1379     const int g = (data & 0x00f0);
1380     const int b = (data & 0x000f);
1381     const int ta = (a >> 8) | (a >> 12);
1382     const int tr = (r >> 4) | (r >> 8);
1383     const int tg = g | (g >> 4);
1384     const int tb = (b << 4) | b;
1385
1386     return qRgba(tr, tg, tb, ta);
1387 }
1388
1389 qargb4444::operator quint8() const
1390 {
1391     // hw: optimize!
1392     return qt_colorConvert<quint8, quint32>(operator quint32(), 0);
1393 }
1394
1395 qargb4444 qargb4444::operator+(qargb4444 v) const
1396 {
1397     qargb4444 t;
1398     t.data = data + v.data;
1399     return t;
1400 }
1401
1402 qargb4444 qargb4444::byte_mul(quint8 a) const
1403 {
1404     quint16 t = (((data & 0xf0f0) * a) >> 4) & 0xf0f0;
1405     t |= (((data & 0x0f0f) * a) >> 4) & 0x0f0f;
1406
1407     qargb4444 result;
1408     result.data = t;
1409     return result;
1410 }
1411
1412 qrgb444::qrgb444(quint32 v)
1413 {
1414     v &= 0xf0f0f0f0;
1415     const int r = qRed(v) << 4;
1416     const int g = qGreen(v);
1417     const int b = qBlue(v) >> 4;
1418
1419     data = r | g | b;
1420 }
1421
1422 qrgb444::qrgb444(qargb4444 v)
1423 {
1424     data = v.data & 0x0fff;
1425 }
1426
1427 qrgb444::operator quint32() const
1428 {
1429     const int r = (data & 0x0f00);
1430     const int g = (data & 0x00f0);
1431     const int b = (data & 0x000f);
1432     const int tr = (r >> 4) | (r >> 8);
1433     const int tg = g | (g >> 4);
1434     const int tb = (b << 4) | b;
1435
1436     return qRgb(tr, tg, tb);
1437 }
1438
1439 qrgb444::operator quint8() const
1440 {
1441     // hw: optimize!
1442     return qt_colorConvert<quint8, quint32>(operator quint32(), 0);
1443 }
1444
1445 qrgb444 qrgb444::operator+(qrgb444 v) const
1446 {
1447     qrgb444 t;
1448     t.data = data + v.data;
1449     return t;
1450 }
1451
1452 qrgb444 qrgb444::byte_mul(quint8 a) const
1453 {
1454     quint16 t = (((data & 0xf0f0) * a) >> 4) & 0xf0f0;
1455     t |= (((data & 0x0f0f) * a) >> 4) & 0x0f0f;
1456
1457     qrgb444 result;
1458     result.data = t;
1459     return result;
1460 }
1461
1462 template <class T>
1463 void qt_memfill(T *dest, T value, int count);
1464
1465 template<> inline void qt_memfill(quint32 *dest, quint32 color, int count)
1466 {
1467     extern void (*qt_memfill32)(quint32 *dest, quint32 value, int count);
1468     qt_memfill32(dest, color, count);
1469 }
1470
1471 template<> inline void qt_memfill(quint16 *dest, quint16 color, int count)
1472 {
1473     extern void (*qt_memfill16)(quint16 *dest, quint16 value, int count);
1474     qt_memfill16(dest, color, count);
1475 }
1476
1477 template<> inline void qt_memfill(quint8 *dest, quint8 color, int count)
1478 {
1479     memset(dest, color, count);
1480 }
1481
1482 template <class T>
1483 inline void qt_memfill(T *dest, T value, int count)
1484 {
1485     if (!count)
1486         return;
1487
1488     int n = (count + 7) / 8;
1489     switch (count & 0x07)
1490     {
1491     case 0: do { *dest++ = value;
1492     case 7:      *dest++ = value;
1493     case 6:      *dest++ = value;
1494     case 5:      *dest++ = value;
1495     case 4:      *dest++ = value;
1496     case 3:      *dest++ = value;
1497     case 2:      *dest++ = value;
1498     case 1:      *dest++ = value;
1499     } while (--n > 0);
1500     }
1501 }
1502
1503 template <class T>
1504 inline void qt_rectfill(T *dest, T value,
1505                         int x, int y, int width, int height, int stride)
1506 {
1507     char *d = reinterpret_cast<char*>(dest + x) + y * stride;
1508     if (uint(stride) == (width * sizeof(T))) {
1509         qt_memfill(reinterpret_cast<T*>(d), value, width * height);
1510     } else {
1511         for (int j = 0; j < height; ++j) {
1512             dest = reinterpret_cast<T*>(d);
1513             qt_memfill(dest, value, width);
1514             d += stride;
1515         }
1516     }
1517 }
1518
1519 template <class DST, class SRC>
1520 inline void qt_memconvert(DST *dest, const SRC *src, int count)
1521 {
1522     if (sizeof(DST) == 1) {
1523         while (count) {
1524             int n = 1;
1525             const SRC color = *src++;
1526             const DST dstColor = qt_colorConvert<DST, SRC>(color, 0);
1527             while (--count && (*src == color || dstColor == qt_colorConvert<DST, SRC>(*src, 0))) {
1528                 ++n;
1529                 ++src;
1530             }
1531             qt_memfill(dest, dstColor, n);
1532             dest += n;
1533         }
1534     } else {
1535         /* Duff's device */
1536         int n = (count + 7) / 8;
1537         switch (count & 0x07)
1538         {
1539         case 0: do { *dest++ = qt_colorConvert<DST, SRC>(*src++, 0);
1540             case 7:      *dest++ = qt_colorConvert<DST, SRC>(*src++, 0);
1541             case 6:      *dest++ = qt_colorConvert<DST, SRC>(*src++, 0);
1542             case 5:      *dest++ = qt_colorConvert<DST, SRC>(*src++, 0);
1543             case 4:      *dest++ = qt_colorConvert<DST, SRC>(*src++, 0);
1544             case 3:      *dest++ = qt_colorConvert<DST, SRC>(*src++, 0);
1545             case 2:      *dest++ = qt_colorConvert<DST, SRC>(*src++, 0);
1546             case 1:      *dest++ = qt_colorConvert<DST, SRC>(*src++, 0);
1547             } while (--n > 0);
1548         }
1549     }
1550 }
1551
1552 #define QT_TRIVIAL_MEMCONVERT_IMPL(T) \
1553     template <> \
1554     inline void qt_memconvert(T *dest, const T *src, int count) \
1555     { \
1556         memcpy(dest, src, count * sizeof(T)); \
1557     }
1558 QT_TRIVIAL_MEMCONVERT_IMPL(quint32)
1559 QT_TRIVIAL_MEMCONVERT_IMPL(qrgb888)
1560 QT_TRIVIAL_MEMCONVERT_IMPL(qargb6666)
1561 QT_TRIVIAL_MEMCONVERT_IMPL(qrgb666)
1562 QT_TRIVIAL_MEMCONVERT_IMPL(quint16)
1563 QT_TRIVIAL_MEMCONVERT_IMPL(qrgb565)
1564 QT_TRIVIAL_MEMCONVERT_IMPL(qargb8565)
1565 QT_TRIVIAL_MEMCONVERT_IMPL(qargb8555)
1566 QT_TRIVIAL_MEMCONVERT_IMPL(qrgb555)
1567 QT_TRIVIAL_MEMCONVERT_IMPL(qargb4444)
1568 QT_TRIVIAL_MEMCONVERT_IMPL(qrgb444)
1569 #undef QT_TRIVIAL_MEMCONVERT_IMPL
1570
1571 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
1572 template <>
1573 inline void qt_memconvert(qrgb666 *dest, const quint32 *src, int count)
1574 {
1575     if (count < 3) {
1576         switch (count) {
1577         case 2: *dest++ = qrgb666(*src++);
1578         case 1: *dest = qrgb666(*src);
1579         }
1580         return;
1581     }
1582
1583     const int align = (quintptr(dest) & 3);
1584     switch (align) {
1585     case 1: *dest++ = qrgb666(*src++); --count;
1586     case 2: *dest++ = qrgb666(*src++); --count;
1587     case 3: *dest++ = qrgb666(*src++); --count;
1588     }
1589
1590     quint32 *dest32 = reinterpret_cast<quint32*>(dest);
1591     int sourceCount = count >> 2;
1592     while (sourceCount--) {
1593         dest32[0] = ((src[1] & 0x00000c00) << 20)
1594                     | ((src[1] & 0x000000fc) << 22)
1595                     | ((src[0] & 0x00fc0000) >> 6)
1596                     | ((src[0] & 0x0000fc00) >> 4)
1597                     |  ((src[0] & 0x000000fc) >> 2);
1598         dest32[1] = ((src[2] & 0x003c0000) << 10)
1599                     | ((src[2] & 0x0000fc00) << 12)
1600                     | ((src[2] & 0x000000fc) << 14)
1601                     | ((src[1] & 0x00fc0000) >> 14)
1602                     | ((src[1] & 0x0000f000) >> 12);
1603         dest32[2] = ((src[3] & 0x00fc0000) << 2)
1604                     | ((src[3] & 0x0000fc00) << 4)
1605                     | ((src[3] & 0x000000fc) << 6)
1606                     | ((src[2] & 0x00c00000) >> 22);
1607         dest32 += 3;
1608         src += 4;
1609     }
1610
1611     dest = reinterpret_cast<qrgb666*>(dest32);
1612     switch (count & 3) {
1613     case 3: *dest++ = qrgb666(*src++);
1614     case 2: *dest++ = qrgb666(*src++);
1615     case 1: *dest = qrgb666(*src);
1616     }
1617 }
1618 #endif // Q_BYTE_ORDER
1619
1620 template <class T>
1621 inline void qt_rectcopy(T *dest, const T *src,
1622                         int x, int y, int width, int height,
1623                         int dstStride, int srcStride)
1624 {
1625     char *d = (char*)(dest + x) + y * dstStride;
1626     const char *s = (char*)(src);
1627     for (int i = 0; i < height; ++i) {
1628         ::memcpy(d, s, width * sizeof(T));
1629         d += dstStride;
1630         s += srcStride;
1631     }
1632 }
1633
1634 template <class DST, class SRC>
1635 inline void qt_rectconvert(DST *dest, const SRC *src,
1636                            int x, int y, int width, int height,
1637                            int dstStride, int srcStride)
1638 {
1639     char *d = (char*)(dest + x) + y * dstStride;
1640     const char *s = (char*)(src);
1641     for (int i = 0; i < height; ++i) {
1642         qt_memconvert<DST,SRC>((DST*)d, (const SRC*)s, width);
1643         d += dstStride;
1644         s += srcStride;
1645     }
1646 }
1647
1648 #define QT_RECTCONVERT_TRIVIAL_IMPL(T)                                  \
1649     template <>                                                         \
1650     inline void qt_rectconvert(T *dest, const T *src,                   \
1651                                int x, int y, int width, int height,     \
1652                                int dstStride, int srcStride)            \
1653     {                                                                   \
1654         qt_rectcopy(dest, src, x, y, width, height, dstStride, srcStride); \
1655     }
1656 QT_RECTCONVERT_TRIVIAL_IMPL(quint32)
1657 QT_RECTCONVERT_TRIVIAL_IMPL(qrgb888)
1658 QT_RECTCONVERT_TRIVIAL_IMPL(qargb6666)
1659 QT_RECTCONVERT_TRIVIAL_IMPL(qrgb666)
1660 QT_RECTCONVERT_TRIVIAL_IMPL(qrgb565)
1661 QT_RECTCONVERT_TRIVIAL_IMPL(qargb8565)
1662 QT_RECTCONVERT_TRIVIAL_IMPL(quint16)
1663 QT_RECTCONVERT_TRIVIAL_IMPL(qargb8555)
1664 QT_RECTCONVERT_TRIVIAL_IMPL(qrgb555)
1665 QT_RECTCONVERT_TRIVIAL_IMPL(qargb4444)
1666 QT_RECTCONVERT_TRIVIAL_IMPL(qrgb444)
1667 #undef QT_RECTCONVERT_TRIVIAL_IMPL
1668
1669 #define QT_MEMFILL_UINT(dest, length, color)            \
1670     qt_memfill<quint32>(dest, color, length);
1671
1672 #define QT_MEMFILL_USHORT(dest, length, color) \
1673     qt_memfill<quint16>(dest, color, length);
1674
1675 #define QT_MEMCPY_REV_UINT(dest, src, length) \
1676 do {                                          \
1677     /* Duff's device */                       \
1678     uint *_d = (uint*)(dest) + length;         \
1679     const uint *_s = (uint*)(src) + length;    \
1680     register int n = ((length) + 7) / 8;      \
1681     switch ((length) & 0x07)                  \
1682     {                                         \
1683     case 0: do { *--_d = *--_s;                 \
1684     case 7:      *--_d = *--_s;                 \
1685     case 6:      *--_d = *--_s;                 \
1686     case 5:      *--_d = *--_s;                 \
1687     case 4:      *--_d = *--_s;                 \
1688     case 3:      *--_d = *--_s;                 \
1689     case 2:      *--_d = *--_s;                 \
1690     case 1:      *--_d = *--_s;                 \
1691     } while (--n > 0);                        \
1692     }                                         \
1693 } while (0)
1694
1695 #define QT_MEMCPY_USHORT(dest, src, length) \
1696 do {                                          \
1697     /* Duff's device */                       \
1698     ushort *_d = (ushort*)(dest);         \
1699     const ushort *_s = (ushort*)(src);    \
1700     register int n = ((length) + 7) / 8;      \
1701     switch ((length) & 0x07)                  \
1702     {                                         \
1703     case 0: do { *_d++ = *_s++;                 \
1704     case 7:      *_d++ = *_s++;                 \
1705     case 6:      *_d++ = *_s++;                 \
1706     case 5:      *_d++ = *_s++;                 \
1707     case 4:      *_d++ = *_s++;                 \
1708     case 3:      *_d++ = *_s++;                 \
1709     case 2:      *_d++ = *_s++;                 \
1710     case 1:      *_d++ = *_s++;                 \
1711     } while (--n > 0);                        \
1712     }                                         \
1713 } while (0)
1714
1715 #if defined(Q_CC_RVCT)
1716 #  pragma push
1717 #  pragma arm
1718 #endif
1719 Q_STATIC_INLINE_FUNCTION int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; }
1720 #if defined(Q_CC_RVCT)
1721 #  pragma pop
1722 #endif
1723
1724 inline ushort qConvertRgb32To16(uint c)
1725 {
1726    return (((c) >> 3) & 0x001f)
1727        | (((c) >> 5) & 0x07e0)
1728        | (((c) >> 8) & 0xf800);
1729 }
1730
1731 inline QRgb qConvertRgb16To32(uint c)
1732 {
1733     return 0xff000000
1734         | ((((c) << 3) & 0xf8) | (((c) >> 2) & 0x7))
1735         | ((((c) << 5) & 0xfc00) | (((c) >> 1) & 0x300))
1736         | ((((c) << 8) & 0xf80000) | (((c) << 3) & 0x70000));
1737 }
1738
1739 inline int qRed565(quint16 rgb) {
1740     const int r = (rgb & 0xf800);
1741     return (r >> 8) | (r >> 13);
1742 }
1743
1744 inline int qGreen565(quint16 rgb) {
1745     const int g = (rgb & 0x07e0);
1746     return (g >> 3) | (g >> 9);
1747 }
1748
1749 inline int qBlue565(quint16 rgb) {
1750     const int b = (rgb & 0x001f);
1751     return (b << 3) | (b >> 2);
1752 }
1753
1754 const uint qt_bayer_matrix[16][16] = {
1755     { 0x1, 0xc0, 0x30, 0xf0, 0xc, 0xcc, 0x3c, 0xfc,
1756       0x3, 0xc3, 0x33, 0xf3, 0xf, 0xcf, 0x3f, 0xff},
1757     { 0x80, 0x40, 0xb0, 0x70, 0x8c, 0x4c, 0xbc, 0x7c,
1758       0x83, 0x43, 0xb3, 0x73, 0x8f, 0x4f, 0xbf, 0x7f},
1759     { 0x20, 0xe0, 0x10, 0xd0, 0x2c, 0xec, 0x1c, 0xdc,
1760       0x23, 0xe3, 0x13, 0xd3, 0x2f, 0xef, 0x1f, 0xdf},
1761     { 0xa0, 0x60, 0x90, 0x50, 0xac, 0x6c, 0x9c, 0x5c,
1762       0xa3, 0x63, 0x93, 0x53, 0xaf, 0x6f, 0x9f, 0x5f},
1763     { 0x8, 0xc8, 0x38, 0xf8, 0x4, 0xc4, 0x34, 0xf4,
1764       0xb, 0xcb, 0x3b, 0xfb, 0x7, 0xc7, 0x37, 0xf7},
1765     { 0x88, 0x48, 0xb8, 0x78, 0x84, 0x44, 0xb4, 0x74,
1766       0x8b, 0x4b, 0xbb, 0x7b, 0x87, 0x47, 0xb7, 0x77},
1767     { 0x28, 0xe8, 0x18, 0xd8, 0x24, 0xe4, 0x14, 0xd4,
1768       0x2b, 0xeb, 0x1b, 0xdb, 0x27, 0xe7, 0x17, 0xd7},
1769     { 0xa8, 0x68, 0x98, 0x58, 0xa4, 0x64, 0x94, 0x54,
1770       0xab, 0x6b, 0x9b, 0x5b, 0xa7, 0x67, 0x97, 0x57},
1771     { 0x2, 0xc2, 0x32, 0xf2, 0xe, 0xce, 0x3e, 0xfe,
1772       0x1, 0xc1, 0x31, 0xf1, 0xd, 0xcd, 0x3d, 0xfd},
1773     { 0x82, 0x42, 0xb2, 0x72, 0x8e, 0x4e, 0xbe, 0x7e,
1774       0x81, 0x41, 0xb1, 0x71, 0x8d, 0x4d, 0xbd, 0x7d},
1775     { 0x22, 0xe2, 0x12, 0xd2, 0x2e, 0xee, 0x1e, 0xde,
1776       0x21, 0xe1, 0x11, 0xd1, 0x2d, 0xed, 0x1d, 0xdd},
1777     { 0xa2, 0x62, 0x92, 0x52, 0xae, 0x6e, 0x9e, 0x5e,
1778       0xa1, 0x61, 0x91, 0x51, 0xad, 0x6d, 0x9d, 0x5d},
1779     { 0xa, 0xca, 0x3a, 0xfa, 0x6, 0xc6, 0x36, 0xf6,
1780       0x9, 0xc9, 0x39, 0xf9, 0x5, 0xc5, 0x35, 0xf5},
1781     { 0x8a, 0x4a, 0xba, 0x7a, 0x86, 0x46, 0xb6, 0x76,
1782       0x89, 0x49, 0xb9, 0x79, 0x85, 0x45, 0xb5, 0x75},
1783     { 0x2a, 0xea, 0x1a, 0xda, 0x26, 0xe6, 0x16, 0xd6,
1784       0x29, 0xe9, 0x19, 0xd9, 0x25, 0xe5, 0x15, 0xd5},
1785     { 0xaa, 0x6a, 0x9a, 0x5a, 0xa6, 0x66, 0x96, 0x56,
1786       0xa9, 0x69, 0x99, 0x59, 0xa5, 0x65, 0x95, 0x55}
1787 };
1788
1789 #define ARGB_COMBINE_ALPHA(argb, alpha) \
1790     ((((argb >> 24) * alpha) >> 8) << 24) | (argb & 0x00ffffff)
1791
1792
1793 #if QT_POINTER_SIZE == 8 // 64-bit versions
1794 #define AMIX(mask) (qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
1795 #define MIX(mask) (qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
1796 #else // 32 bits
1797 // The mask for alpha can overflow over 32 bits
1798 #define AMIX(mask) quint32(qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
1799 #define MIX(mask) (qMin(((quint32(s)&mask) + (quint32(d)&mask)), quint32(mask)))
1800 #endif
1801
1802 inline int comp_func_Plus_one_pixel_const_alpha(uint d, const uint s, const uint const_alpha, const uint one_minus_const_alpha)
1803 {
1804     const int result = (AMIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK));
1805     return INTERPOLATE_PIXEL_255(result, const_alpha, d, one_minus_const_alpha);
1806 }
1807
1808 inline int comp_func_Plus_one_pixel(uint d, const uint s)
1809 {
1810     const int result = (AMIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK));
1811     return result;
1812 }
1813
1814 #undef MIX
1815 #undef AMIX
1816
1817 // prototypes of all the composition functions
1818 void QT_FASTCALL comp_func_SourceOver(uint *dest, const uint *src, int length, uint const_alpha);
1819 void QT_FASTCALL comp_func_DestinationOver(uint *dest, const uint *src, int length, uint const_alpha);
1820 void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha);
1821 void QT_FASTCALL comp_func_Source(uint *dest, const uint *src, int length, uint const_alpha);
1822 void QT_FASTCALL comp_func_Destination(uint *, const uint *, int, uint);
1823 void QT_FASTCALL comp_func_SourceIn(uint *dest, const uint *src, int length, uint const_alpha);
1824 void QT_FASTCALL comp_func_DestinationIn(uint *dest, const uint *src, int length, uint const_alpha);
1825 void QT_FASTCALL comp_func_SourceOut(uint *dest, const uint *src, int length, uint const_alpha);
1826 void QT_FASTCALL comp_func_DestinationOut(uint *dest, const uint *src, int length, uint const_alpha);
1827 void QT_FASTCALL comp_func_SourceAtop(uint *dest, const uint *src, int length, uint const_alpha);
1828 void QT_FASTCALL comp_func_DestinationAtop(uint *dest, const uint *src, int length, uint const_alpha);
1829 void QT_FASTCALL comp_func_XOR(uint *dest, const uint *src, int length, uint const_alpha);
1830 void QT_FASTCALL comp_func_Plus(uint *dest, const uint *src, int length, uint const_alpha);
1831 void QT_FASTCALL comp_func_Multiply(uint *dest, const uint *src, int length, uint const_alpha);
1832 void QT_FASTCALL comp_func_Screen(uint *dest, const uint *src, int length, uint const_alpha);
1833 void QT_FASTCALL comp_func_Overlay(uint *dest, const uint *src, int length, uint const_alpha);
1834 void QT_FASTCALL comp_func_Darken(uint *dest, const uint *src, int length, uint const_alpha);
1835 void QT_FASTCALL comp_func_Lighten(uint *dest, const uint *src, int length, uint const_alpha);
1836 void QT_FASTCALL comp_func_ColorDodge(uint *dest, const uint *src, int length, uint const_alpha);
1837 void QT_FASTCALL comp_func_ColorBurn(uint *dest, const uint *src, int length, uint const_alpha);
1838 void QT_FASTCALL comp_func_HardLight(uint *dest, const uint *src, int length, uint const_alpha);
1839 void QT_FASTCALL comp_func_SoftLight(uint *dest, const uint *src, int length, uint const_alpha);
1840 void QT_FASTCALL comp_func_Difference(uint *dest, const uint *src, int length, uint const_alpha);
1841 void QT_FASTCALL comp_func_Exclusion(uint *dest, const uint *src, int length, uint const_alpha);
1842 void QT_FASTCALL rasterop_SourceOrDestination(uint *dest, const uint *src, int length, uint const_alpha);
1843 void QT_FASTCALL rasterop_SourceAndDestination(uint *dest, const uint *src, int length, uint const_alpha);
1844 void QT_FASTCALL rasterop_SourceXorDestination(uint *dest, const uint *src, int length, uint const_alpha);
1845 void QT_FASTCALL rasterop_NotSourceAndNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
1846 void QT_FASTCALL rasterop_NotSourceOrNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
1847 void QT_FASTCALL rasterop_NotSourceXorDestination(uint *dest, const uint *src, int length, uint const_alpha);
1848 void QT_FASTCALL rasterop_NotSource(uint *dest, const uint *src, int length, uint const_alpha);
1849 void QT_FASTCALL rasterop_NotSourceAndDestination(uint *dest, const uint *src, int length, uint const_alpha);
1850 void QT_FASTCALL rasterop_SourceAndNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
1851
1852 // prototypes of all the solid composition functions
1853 void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha);
1854 void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha);
1855 void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint color, uint const_alpha);
1856 void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint const_alpha);
1857 void QT_FASTCALL comp_func_solid_Destination(uint *dest, int length, uint color, uint const_alpha);
1858 void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, uint const_alpha);
1859 void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha);
1860 void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, uint const_alpha);
1861 void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha);
1862 void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, uint const_alpha);
1863 void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint color, uint const_alpha);
1864 void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint const_alpha);
1865 void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint const_alpha);
1866 void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha);
1867 void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha);
1868 void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha);
1869 void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha);
1870 void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha);
1871 void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha);
1872 void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha);
1873 void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha);
1874 void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha);
1875 void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha);
1876 void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha);
1877 void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest, int length, uint color, uint const_alpha);
1878 void QT_FASTCALL rasterop_solid_SourceAndDestination(uint *dest, int length, uint color, uint const_alpha);
1879 void QT_FASTCALL rasterop_solid_SourceXorDestination(uint *dest, int length, uint color, uint const_alpha);
1880 void QT_FASTCALL rasterop_solid_NotSourceAndNotDestination(uint *dest, int length, uint color, uint const_alpha);
1881 void QT_FASTCALL rasterop_solid_NotSourceOrNotDestination(uint *dest, int length, uint color, uint const_alpha);
1882 void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest, int length, uint color, uint const_alpha);
1883 void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length, uint color, uint const_alpha);
1884 void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest, int length, uint color, uint const_alpha);
1885 void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest, int length, uint color, uint const_alpha);
1886
1887 QT_END_NAMESPACE
1888
1889 #endif // QDRAWHELPER_P_H