author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 10:37:55 +0300 | |
changeset 33 | 3e2da88830cd |
parent 30 | 5dc02b23752f |
child 37 | 758a864f9613 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 |
#include <private/qdrawhelper_p.h> |
|
43 |
#include <private/qpaintengine_raster_p.h> |
|
44 |
#include <private/qpainter_p.h> |
|
45 |
#include <private/qdrawhelper_x86_p.h> |
|
46 |
#include <private/qdrawhelper_armv6_p.h> |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
#include <private/qdrawhelper_neon_p.h> |
0 | 48 |
#include <private/qmath_p.h> |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
49 |
#include <private/qsimd_p.h> |
0 | 50 |
#include <qmath.h> |
51 |
||
52 |
QT_BEGIN_NAMESPACE |
|
53 |
||
54 |
||
55 |
#define MASK(src, a) src = BYTE_MUL(src, a) |
|
56 |
||
57 |
#if defined(Q_OS_IRIX) && defined(Q_CC_GNU) && __GNUC__ == 3 && __GNUC__ < 4 && QT_POINTER_SIZE == 8 |
|
58 |
#define Q_IRIX_GCC3_3_WORKAROUND |
|
59 |
// |
|
60 |
// work around http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14484 |
|
61 |
// |
|
62 |
static uint gccBug(uint value) __attribute__((noinline)); |
|
63 |
static uint gccBug(uint value) |
|
64 |
{ |
|
65 |
return value; |
|
66 |
} |
|
67 |
#endif |
|
68 |
||
69 |
/* |
|
70 |
constants and structures |
|
71 |
*/ |
|
72 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
73 |
enum { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
74 |
fixed_scale = 1 << 16, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
75 |
half_point = 1 << 15 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
76 |
}; |
0 | 77 |
static const int buffer_size = 2048; |
78 |
||
79 |
struct LinearGradientValues |
|
80 |
{ |
|
81 |
qreal dx; |
|
82 |
qreal dy; |
|
83 |
qreal l; |
|
84 |
qreal off; |
|
85 |
}; |
|
86 |
||
87 |
struct RadialGradientValues |
|
88 |
{ |
|
89 |
qreal dx; |
|
90 |
qreal dy; |
|
91 |
qreal a; |
|
92 |
}; |
|
93 |
||
94 |
struct Operator; |
|
95 |
typedef uint* (QT_FASTCALL *DestFetchProc)(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length); |
|
96 |
typedef void (QT_FASTCALL *DestStoreProc)(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length); |
|
97 |
typedef const uint* (QT_FASTCALL *SourceFetchProc)(uint *buffer, const Operator *o, const QSpanData *data, int y, int x, int length); |
|
98 |
||
99 |
||
100 |
struct Operator |
|
101 |
{ |
|
102 |
QPainter::CompositionMode mode; |
|
103 |
DestFetchProc dest_fetch; |
|
104 |
DestStoreProc dest_store; |
|
105 |
SourceFetchProc src_fetch; |
|
106 |
CompositionFunctionSolid funcSolid; |
|
107 |
CompositionFunction func; |
|
108 |
union { |
|
109 |
LinearGradientValues linear; |
|
110 |
RadialGradientValues radial; |
|
111 |
// TextureValues texture; |
|
112 |
}; |
|
113 |
}; |
|
114 |
||
115 |
/* |
|
116 |
Destination fetch. This is simple as we don't have to do bounds checks or |
|
117 |
transformations |
|
118 |
*/ |
|
119 |
||
120 |
static uint * QT_FASTCALL destFetchMono(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) |
|
121 |
{ |
|
122 |
uchar *data = (uchar *)rasterBuffer->scanLine(y); |
|
123 |
uint *start = buffer; |
|
124 |
const uint *end = buffer + length; |
|
125 |
while (buffer < end) { |
|
126 |
*buffer = data[x>>3] & (0x80 >> (x & 7)) ? rasterBuffer->destColor1 : rasterBuffer->destColor0; |
|
127 |
++buffer; |
|
128 |
++x; |
|
129 |
} |
|
130 |
return start; |
|
131 |
} |
|
132 |
||
133 |
static uint * QT_FASTCALL destFetchMonoLsb(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) |
|
134 |
{ |
|
135 |
uchar *data = (uchar *)rasterBuffer->scanLine(y); |
|
136 |
uint *start = buffer; |
|
137 |
const uint *end = buffer + length; |
|
138 |
while (buffer < end) { |
|
139 |
*buffer = data[x>>3] & (0x1 << (x & 7)) ? rasterBuffer->destColor1 : rasterBuffer->destColor0; |
|
140 |
++buffer; |
|
141 |
++x; |
|
142 |
} |
|
143 |
return start; |
|
144 |
} |
|
145 |
||
146 |
static uint * QT_FASTCALL destFetchARGB32(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) |
|
147 |
{ |
|
148 |
const uint *data = (const uint *)rasterBuffer->scanLine(y) + x; |
|
149 |
for (int i = 0; i < length; ++i) |
|
150 |
buffer[i] = PREMUL(data[i]); |
|
151 |
return buffer; |
|
152 |
} |
|
153 |
||
154 |
static uint * QT_FASTCALL destFetchARGB32P(uint *, QRasterBuffer *rasterBuffer, int x, int y, int) |
|
155 |
{ |
|
156 |
return (uint *)rasterBuffer->scanLine(y) + x; |
|
157 |
} |
|
158 |
||
159 |
static uint * QT_FASTCALL destFetchRGB16(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) |
|
160 |
{ |
|
161 |
const ushort *data = (const ushort *)rasterBuffer->scanLine(y) + x; |
|
162 |
for (int i = 0; i < length; ++i) |
|
163 |
buffer[i] = qConvertRgb16To32(data[i]); |
|
164 |
return buffer; |
|
165 |
} |
|
166 |
||
167 |
template <class DST> |
|
168 |
Q_STATIC_TEMPLATE_FUNCTION uint * QT_FASTCALL destFetch(uint *buffer, QRasterBuffer *rasterBuffer, |
|
169 |
int x, int y, int length) |
|
170 |
{ |
|
171 |
const DST *src = reinterpret_cast<DST*>(rasterBuffer->scanLine(y)) + x; |
|
172 |
quint32 *dest = reinterpret_cast<quint32*>(buffer); |
|
173 |
while (length--) |
|
174 |
*dest++ = *src++; |
|
175 |
return buffer; |
|
176 |
} |
|
177 |
||
178 |
# define SPANFUNC_POINTER_DESTFETCH(Arg) destFetch<Arg> |
|
179 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
180 |
static DestFetchProc destFetchProc[QImage::NImageFormats] = |
0 | 181 |
{ |
182 |
0, // Format_Invalid |
|
183 |
destFetchMono, // Format_Mono, |
|
184 |
destFetchMonoLsb, // Format_MonoLSB |
|
185 |
0, // Format_Indexed8 |
|
186 |
destFetchARGB32P, // Format_RGB32 |
|
187 |
destFetchARGB32, // Format_ARGB32, |
|
188 |
destFetchARGB32P, // Format_ARGB32_Premultiplied |
|
189 |
destFetchRGB16, // Format_RGB16 |
|
190 |
SPANFUNC_POINTER_DESTFETCH(qargb8565), // Format_ARGB8565_Premultiplied |
|
191 |
SPANFUNC_POINTER_DESTFETCH(qrgb666), // Format_RGB666 |
|
192 |
SPANFUNC_POINTER_DESTFETCH(qargb6666), // Format_ARGB6666_Premultiplied |
|
193 |
SPANFUNC_POINTER_DESTFETCH(qrgb555), // Format_RGB555 |
|
194 |
SPANFUNC_POINTER_DESTFETCH(qargb8555), // Format_ARGB8555_Premultiplied |
|
195 |
SPANFUNC_POINTER_DESTFETCH(qrgb888), // Format_RGB888 |
|
196 |
SPANFUNC_POINTER_DESTFETCH(qrgb444), // Format_RGB444 |
|
197 |
SPANFUNC_POINTER_DESTFETCH(qargb4444) // Format_ARGB4444_Premultiplied |
|
198 |
}; |
|
199 |
||
200 |
/* |
|
201 |
Returns the color in the mono destination color table |
|
202 |
that is the "nearest" to /color/. |
|
203 |
*/ |
|
204 |
static inline QRgb findNearestColor(QRgb color, QRasterBuffer *rbuf) |
|
205 |
{ |
|
206 |
QRgb color_0 = PREMUL(rbuf->destColor0); |
|
207 |
QRgb color_1 = PREMUL(rbuf->destColor1); |
|
208 |
color = PREMUL(color); |
|
209 |
||
210 |
int r = qRed(color); |
|
211 |
int g = qGreen(color); |
|
212 |
int b = qBlue(color); |
|
213 |
int rx, gx, bx; |
|
214 |
int dist_0, dist_1; |
|
215 |
||
216 |
rx = r - qRed(color_0); |
|
217 |
gx = g - qGreen(color_0); |
|
218 |
bx = b - qBlue(color_0); |
|
219 |
dist_0 = rx*rx + gx*gx + bx*bx; |
|
220 |
||
221 |
rx = r - qRed(color_1); |
|
222 |
gx = g - qGreen(color_1); |
|
223 |
bx = b - qBlue(color_1); |
|
224 |
dist_1 = rx*rx + gx*gx + bx*bx; |
|
225 |
||
226 |
if (dist_0 < dist_1) |
|
227 |
return color_0; |
|
228 |
return color_1; |
|
229 |
} |
|
230 |
||
231 |
/* |
|
232 |
Destination store. |
|
233 |
*/ |
|
234 |
||
235 |
static void QT_FASTCALL destStoreMono(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) |
|
236 |
{ |
|
237 |
uchar *data = (uchar *)rasterBuffer->scanLine(y); |
|
238 |
if (rasterBuffer->monoDestinationWithClut) { |
|
239 |
for (int i = 0; i < length; ++i) { |
|
240 |
if (buffer[i] == rasterBuffer->destColor0) { |
|
241 |
data[x >> 3] &= ~(0x80 >> (x & 7)); |
|
242 |
} else if (buffer[i] == rasterBuffer->destColor1) { |
|
243 |
data[x >> 3] |= 0x80 >> (x & 7); |
|
244 |
} else if (findNearestColor(buffer[i], rasterBuffer) == rasterBuffer->destColor0) { |
|
245 |
data[x >> 3] &= ~(0x80 >> (x & 7)); |
|
246 |
} else { |
|
247 |
data[x >> 3] |= 0x80 >> (x & 7); |
|
248 |
} |
|
249 |
++x; |
|
250 |
} |
|
251 |
} else { |
|
252 |
for (int i = 0; i < length; ++i) { |
|
253 |
if (qGray(buffer[i]) < int(qt_bayer_matrix[y & 15][x & 15])) |
|
254 |
data[x >> 3] |= 0x80 >> (x & 7); |
|
255 |
else |
|
256 |
data[x >> 3] &= ~(0x80 >> (x & 7)); |
|
257 |
++x; |
|
258 |
} |
|
259 |
} |
|
260 |
} |
|
261 |
||
262 |
static void QT_FASTCALL destStoreMonoLsb(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) |
|
263 |
{ |
|
264 |
uchar *data = (uchar *)rasterBuffer->scanLine(y); |
|
265 |
if (rasterBuffer->monoDestinationWithClut) { |
|
266 |
for (int i = 0; i < length; ++i) { |
|
267 |
if (buffer[i] == rasterBuffer->destColor0) { |
|
268 |
data[x >> 3] &= ~(1 << (x & 7)); |
|
269 |
} else if (buffer[i] == rasterBuffer->destColor1) { |
|
270 |
data[x >> 3] |= 1 << (x & 7); |
|
271 |
} else if (findNearestColor(buffer[i], rasterBuffer) == rasterBuffer->destColor0) { |
|
272 |
data[x >> 3] &= ~(1 << (x & 7)); |
|
273 |
} else { |
|
274 |
data[x >> 3] |= 1 << (x & 7); |
|
275 |
} |
|
276 |
++x; |
|
277 |
} |
|
278 |
} else { |
|
279 |
for (int i = 0; i < length; ++i) { |
|
280 |
if (qGray(buffer[i]) < int(qt_bayer_matrix[y & 15][x & 15])) |
|
281 |
data[x >> 3] |= 1 << (x & 7); |
|
282 |
else |
|
283 |
data[x >> 3] &= ~(1 << (x & 7)); |
|
284 |
++x; |
|
285 |
} |
|
286 |
} |
|
287 |
} |
|
288 |
||
289 |
static void QT_FASTCALL destStoreARGB32(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) |
|
290 |
{ |
|
291 |
uint *data = (uint *)rasterBuffer->scanLine(y) + x; |
|
292 |
for (int i = 0; i < length; ++i) { |
|
293 |
int p = buffer[i]; |
|
294 |
int alpha = qAlpha(p); |
|
295 |
if (alpha == 255) |
|
296 |
data[i] = p; |
|
297 |
else if (alpha == 0) |
|
298 |
data[i] = 0; |
|
299 |
else { |
|
300 |
int inv_alpha = 0xff0000/qAlpha(buffer[i]); |
|
301 |
data[i] = (p & 0xff000000) |
|
302 |
| ((qRed(p)*inv_alpha) & 0xff0000) |
|
303 |
| (((qGreen(p)*inv_alpha) >> 8) & 0xff00) |
|
304 |
| ((qBlue(p)*inv_alpha) >> 16); |
|
305 |
} |
|
306 |
} |
|
307 |
} |
|
308 |
||
309 |
static void QT_FASTCALL destStoreRGB16(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) |
|
310 |
{ |
|
311 |
quint16 *data = (quint16*)rasterBuffer->scanLine(y) + x; |
|
312 |
qt_memconvert<quint16, quint32>(data, buffer, length); |
|
313 |
} |
|
314 |
||
315 |
template <class DST> |
|
316 |
Q_STATIC_TEMPLATE_FUNCTION void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer, |
|
317 |
int x, int y, |
|
318 |
const uint *buffer, int length) |
|
319 |
{ |
|
320 |
DST *dest = reinterpret_cast<DST*>(rasterBuffer->scanLine(y)) + x; |
|
321 |
const quint32p *src = reinterpret_cast<const quint32p*>(buffer); |
|
322 |
while (length--) |
|
323 |
*dest++ = DST(*src++); |
|
324 |
} |
|
325 |
||
326 |
# define SPANFUNC_POINTER_DESTSTORE(DEST) destStore<DEST> |
|
327 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
328 |
static DestStoreProc destStoreProc[QImage::NImageFormats] = |
0 | 329 |
{ |
330 |
0, // Format_Invalid |
|
331 |
destStoreMono, // Format_Mono, |
|
332 |
destStoreMonoLsb, // Format_MonoLSB |
|
333 |
0, // Format_Indexed8 |
|
334 |
0, // Format_RGB32 |
|
335 |
destStoreARGB32, // Format_ARGB32, |
|
336 |
0, // Format_ARGB32_Premultiplied |
|
337 |
destStoreRGB16, // Format_RGB16 |
|
338 |
SPANFUNC_POINTER_DESTSTORE(qargb8565), // Format_ARGB8565_Premultiplied |
|
339 |
SPANFUNC_POINTER_DESTSTORE(qrgb666), // Format_RGB666 |
|
340 |
SPANFUNC_POINTER_DESTSTORE(qargb6666), // Format_ARGB6666_Premultiplied |
|
341 |
SPANFUNC_POINTER_DESTSTORE(qrgb555), // Format_RGB555 |
|
342 |
SPANFUNC_POINTER_DESTSTORE(qargb8555), // Format_ARGB8555_Premultiplied |
|
343 |
SPANFUNC_POINTER_DESTSTORE(qrgb888), // Format_RGB888 |
|
344 |
SPANFUNC_POINTER_DESTSTORE(qrgb444), // Format_RGB444 |
|
345 |
SPANFUNC_POINTER_DESTSTORE(qargb4444) // Format_ARGB4444_Premultiplied |
|
346 |
}; |
|
347 |
||
348 |
/* |
|
349 |
Source fetches |
|
350 |
||
351 |
This is a bit more complicated, as we need several fetch routines for every surface type |
|
352 |
||
353 |
We need 5 fetch methods per surface type: |
|
354 |
untransformed |
|
355 |
transformed (tiled and not tiled) |
|
356 |
transformed bilinear (tiled and not tiled) |
|
357 |
||
358 |
We don't need bounds checks for untransformed, but we need them for the other ones. |
|
359 |
||
360 |
The generic implementation does pixel by pixel fetches |
|
361 |
*/ |
|
362 |
||
363 |
template <QImage::Format format> |
|
364 |
Q_STATIC_TEMPLATE_FUNCTION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, const QVector<QRgb> *rgb); |
|
365 |
||
366 |
template<> |
|
367 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
368 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_Mono>(const uchar *scanLine, |
|
369 |
int x, const QVector<QRgb> *rgb) |
|
370 |
{ |
|
371 |
bool pixel = scanLine[x>>3] & (0x80 >> (x & 7)); |
|
372 |
if (rgb) return PREMUL(rgb->at(pixel ? 1 : 0)); |
|
373 |
return pixel ? 0xff000000 : 0xffffffff; |
|
374 |
} |
|
375 |
||
376 |
template<> |
|
377 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
378 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_MonoLSB>(const uchar *scanLine, |
|
379 |
int x, const QVector<QRgb> *rgb) |
|
380 |
{ |
|
381 |
bool pixel = scanLine[x>>3] & (0x1 << (x & 7)); |
|
382 |
if (rgb) return PREMUL(rgb->at(pixel ? 1 : 0)); |
|
383 |
return pixel ? 0xff000000 : 0xffffffff; |
|
384 |
} |
|
385 |
||
386 |
template<> |
|
387 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
388 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_Indexed8>(const uchar *scanLine, |
|
389 |
int x, const QVector<QRgb> *rgb) |
|
390 |
{ |
|
391 |
return PREMUL(rgb->at(scanLine[x])); |
|
392 |
} |
|
393 |
||
394 |
template<> |
|
395 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
396 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB32>(const uchar *scanLine, |
|
397 |
int x, const QVector<QRgb> *) |
|
398 |
{ |
|
399 |
return PREMUL(((const uint *)scanLine)[x]); |
|
400 |
} |
|
401 |
||
402 |
template<> |
|
403 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
404 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB32_Premultiplied>(const uchar *scanLine, |
|
405 |
int x, const QVector<QRgb> *) |
|
406 |
{ |
|
407 |
return ((const uint *)scanLine)[x]; |
|
408 |
} |
|
409 |
||
410 |
template<> |
|
411 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
412 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB16>(const uchar *scanLine, |
|
413 |
int x, const QVector<QRgb> *) |
|
414 |
{ |
|
415 |
return qConvertRgb16To32(((const ushort *)scanLine)[x]); |
|
416 |
} |
|
417 |
||
418 |
template<> |
|
419 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
420 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB8565_Premultiplied>(const uchar *scanLine, |
|
421 |
int x, |
|
422 |
const QVector<QRgb> *) |
|
423 |
{ |
|
424 |
const qargb8565 color = reinterpret_cast<const qargb8565*>(scanLine)[x]; |
|
425 |
return qt_colorConvert<quint32, qargb8565>(color, 0); |
|
426 |
} |
|
427 |
||
428 |
template<> |
|
429 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
430 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB666>(const uchar *scanLine, |
|
431 |
int x, |
|
432 |
const QVector<QRgb> *) |
|
433 |
{ |
|
434 |
const qrgb666 color = reinterpret_cast<const qrgb666*>(scanLine)[x]; |
|
435 |
return qt_colorConvert<quint32, qrgb666>(color, 0); |
|
436 |
} |
|
437 |
||
438 |
template<> |
|
439 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
440 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB6666_Premultiplied>(const uchar *scanLine, |
|
441 |
int x, |
|
442 |
const QVector<QRgb> *) |
|
443 |
{ |
|
444 |
const qargb6666 color = reinterpret_cast<const qargb6666*>(scanLine)[x]; |
|
445 |
return qt_colorConvert<quint32, qargb6666>(color, 0); |
|
446 |
} |
|
447 |
||
448 |
template<> |
|
449 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
450 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB555>(const uchar *scanLine, |
|
451 |
int x, |
|
452 |
const QVector<QRgb> *) |
|
453 |
{ |
|
454 |
const qrgb555 color = reinterpret_cast<const qrgb555*>(scanLine)[x]; |
|
455 |
return qt_colorConvert<quint32, qrgb555>(color, 0); |
|
456 |
} |
|
457 |
||
458 |
template<> |
|
459 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
460 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB8555_Premultiplied>(const uchar *scanLine, |
|
461 |
int x, |
|
462 |
const QVector<QRgb> *) |
|
463 |
{ |
|
464 |
const qargb8555 color = reinterpret_cast<const qargb8555*>(scanLine)[x]; |
|
465 |
return qt_colorConvert<quint32, qargb8555>(color, 0); |
|
466 |
} |
|
467 |
||
468 |
template<> |
|
469 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
470 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB888>(const uchar *scanLine, |
|
471 |
int x, |
|
472 |
const QVector<QRgb> *) |
|
473 |
{ |
|
474 |
const qrgb888 color = reinterpret_cast<const qrgb888*>(scanLine)[x]; |
|
475 |
return qt_colorConvert<quint32, qrgb888>(color, 0); |
|
476 |
} |
|
477 |
||
478 |
template<> |
|
479 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
480 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB444>(const uchar *scanLine, |
|
481 |
int x, |
|
482 |
const QVector<QRgb> *) |
|
483 |
{ |
|
484 |
const qrgb444 color = reinterpret_cast<const qrgb444*>(scanLine)[x]; |
|
485 |
return qt_colorConvert<quint32, qrgb444>(color, 0); |
|
486 |
} |
|
487 |
||
488 |
template<> |
|
489 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
490 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB4444_Premultiplied>(const uchar *scanLine, |
|
491 |
int x, |
|
492 |
const QVector<QRgb> *) |
|
493 |
{ |
|
494 |
const qargb4444 color = reinterpret_cast<const qargb4444*>(scanLine)[x]; |
|
495 |
return qt_colorConvert<quint32, qargb4444>(color, 0); |
|
496 |
} |
|
497 |
||
498 |
template<> |
|
499 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
500 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_Invalid>(const uchar *, |
|
501 |
int , |
|
502 |
const QVector<QRgb> *) |
|
503 |
{ |
|
504 |
return 0; |
|
505 |
} |
|
506 |
||
507 |
typedef uint (QT_FASTCALL *FetchPixelProc)(const uchar *scanLine, int x, const QVector<QRgb> *); |
|
508 |
||
509 |
#define SPANFUNC_POINTER_FETCHPIXEL(Arg) qt_fetchPixel<QImage::Arg> |
|
510 |
||
511 |
||
512 |
static const FetchPixelProc fetchPixelProc[QImage::NImageFormats] = |
|
513 |
{ |
|
514 |
0, |
|
515 |
SPANFUNC_POINTER_FETCHPIXEL(Format_Mono), |
|
516 |
SPANFUNC_POINTER_FETCHPIXEL(Format_MonoLSB), |
|
517 |
SPANFUNC_POINTER_FETCHPIXEL(Format_Indexed8), |
|
518 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB32_Premultiplied), |
|
519 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB32), |
|
520 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB32_Premultiplied), |
|
521 |
SPANFUNC_POINTER_FETCHPIXEL(Format_RGB16), |
|
522 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB8565_Premultiplied), |
|
523 |
SPANFUNC_POINTER_FETCHPIXEL(Format_RGB666), |
|
524 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB6666_Premultiplied), |
|
525 |
SPANFUNC_POINTER_FETCHPIXEL(Format_RGB555), |
|
526 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB8555_Premultiplied), |
|
527 |
SPANFUNC_POINTER_FETCHPIXEL(Format_RGB888), |
|
528 |
SPANFUNC_POINTER_FETCHPIXEL(Format_RGB444), |
|
529 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB4444_Premultiplied) |
|
530 |
}; |
|
531 |
||
532 |
enum TextureBlendType { |
|
533 |
BlendUntransformed, |
|
534 |
BlendTiled, |
|
535 |
BlendTransformed, |
|
536 |
BlendTransformedTiled, |
|
537 |
BlendTransformedBilinear, |
|
538 |
BlendTransformedBilinearTiled, |
|
539 |
NBlendTypes |
|
540 |
}; |
|
541 |
||
542 |
template <QImage::Format format> |
|
543 |
Q_STATIC_TEMPLATE_FUNCTION const uint * QT_FASTCALL qt_fetchUntransformed(uint *buffer, const Operator *, const QSpanData *data, |
|
544 |
int y, int x, int length) |
|
545 |
{ |
|
546 |
const uchar *scanLine = data->texture.scanLine(y); |
|
547 |
for (int i = 0; i < length; ++i) |
|
548 |
buffer[i] = qt_fetchPixel<format>(scanLine, x + i, data->texture.colorTable); |
|
549 |
return buffer; |
|
550 |
} |
|
551 |
||
552 |
template <> |
|
553 |
Q_STATIC_TEMPLATE_SPECIALIZATION const uint * QT_FASTCALL |
|
554 |
qt_fetchUntransformed<QImage::Format_ARGB32_Premultiplied>(uint *, const Operator *, |
|
555 |
const QSpanData *data, |
|
556 |
int y, int x, int) |
|
557 |
{ |
|
558 |
const uchar *scanLine = data->texture.scanLine(y); |
|
559 |
return ((const uint *)scanLine) + x; |
|
560 |
} |
|
561 |
||
562 |
template<TextureBlendType blendType> /* either BlendTransformed or BlendTransformedTiled */ |
|
563 |
Q_STATIC_TEMPLATE_FUNCTION |
|
564 |
const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data, |
|
565 |
int y, int x, int length) |
|
566 |
{ |
|
567 |
FetchPixelProc fetch = fetchPixelProc[data->texture.format]; |
|
568 |
||
569 |
int image_width = data->texture.width; |
|
570 |
int image_height = data->texture.height; |
|
571 |
||
572 |
const qreal cx = x + 0.5; |
|
573 |
const qreal cy = y + 0.5; |
|
574 |
||
575 |
const uint *end = buffer + length; |
|
576 |
uint *b = buffer; |
|
577 |
if (data->fast_matrix) { |
|
578 |
// The increment pr x in the scanline |
|
579 |
int fdx = (int)(data->m11 * fixed_scale); |
|
580 |
int fdy = (int)(data->m12 * fixed_scale); |
|
581 |
||
582 |
int fx = int((data->m21 * cy |
|
583 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
584 |
int fy = int((data->m22 * cy |
|
585 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
586 |
||
587 |
while (b < end) { |
|
588 |
int px = fx >> 16; |
|
589 |
int py = fy >> 16; |
|
590 |
||
591 |
if (blendType == BlendTransformedTiled) { |
|
592 |
px %= image_width; |
|
593 |
py %= image_height; |
|
594 |
if (px < 0) px += image_width; |
|
595 |
if (py < 0) py += image_height; |
|
596 |
||
597 |
const uchar *scanLine = data->texture.scanLine(py); |
|
598 |
*b = fetch(scanLine, px, data->texture.colorTable); |
|
599 |
} else { |
|
600 |
if ((px < 0) || (px >= image_width) |
|
601 |
|| (py < 0) || (py >= image_height)) { |
|
602 |
*b = uint(0); |
|
603 |
} else { |
|
604 |
const uchar *scanLine = data->texture.scanLine(py); |
|
605 |
*b = fetch(scanLine, px, data->texture.colorTable); |
|
606 |
} |
|
607 |
} |
|
608 |
fx += fdx; |
|
609 |
fy += fdy; |
|
610 |
++b; |
|
611 |
} |
|
612 |
} else { |
|
613 |
const qreal fdx = data->m11; |
|
614 |
const qreal fdy = data->m12; |
|
615 |
const qreal fdw = data->m13; |
|
616 |
||
617 |
qreal fx = data->m21 * cy + data->m11 * cx + data->dx; |
|
618 |
qreal fy = data->m22 * cy + data->m12 * cx + data->dy; |
|
619 |
qreal fw = data->m23 * cy + data->m13 * cx + data->m33; |
|
620 |
||
621 |
while (b < end) { |
|
622 |
const qreal iw = fw == 0 ? 1 : 1 / fw; |
|
623 |
const qreal tx = fx * iw; |
|
624 |
const qreal ty = fy * iw; |
|
625 |
int px = int(tx) - (tx < 0); |
|
626 |
int py = int(ty) - (ty < 0); |
|
627 |
||
628 |
if (blendType == BlendTransformedTiled) { |
|
629 |
px %= image_width; |
|
630 |
py %= image_height; |
|
631 |
if (px < 0) px += image_width; |
|
632 |
if (py < 0) py += image_height; |
|
633 |
||
634 |
const uchar *scanLine = data->texture.scanLine(py); |
|
635 |
*b = fetch(scanLine, px, data->texture.colorTable); |
|
636 |
} else { |
|
637 |
if ((px < 0) || (px >= image_width) |
|
638 |
|| (py < 0) || (py >= image_height)) { |
|
639 |
*b = uint(0); |
|
640 |
} else { |
|
641 |
const uchar *scanLine = data->texture.scanLine(py); |
|
642 |
*b = fetch(scanLine, px, data->texture.colorTable); |
|
643 |
} |
|
644 |
} |
|
645 |
fx += fdx; |
|
646 |
fy += fdy; |
|
647 |
fw += fdw; |
|
648 |
//force increment to avoid /0 |
|
649 |
if (!fw) { |
|
650 |
fw += fdw; |
|
651 |
} |
|
652 |
++b; |
|
653 |
} |
|
654 |
} |
|
655 |
||
656 |
return buffer; |
|
657 |
} |
|
658 |
||
659 |
template<TextureBlendType blendType, QImage::Format format> /* blendType = BlendTransformedBilinear or BlendTransformedBilinearTiled */ |
|
660 |
Q_STATIC_TEMPLATE_FUNCTION |
|
661 |
const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, const QSpanData *data, |
|
662 |
int y, int x, int length) |
|
663 |
{ |
|
664 |
#ifdef Q_CC_RVCT // needed to avoid compiler crash in RVCT 2.2 |
|
665 |
FetchPixelProc fetch; |
|
666 |
if (format != QImage::Format_Invalid) |
|
667 |
fetch = qt_fetchPixel<format>; |
|
668 |
else |
|
669 |
fetch = fetchPixelProc[data->texture.format]; |
|
670 |
#else |
|
671 |
FetchPixelProc fetch = (format != QImage::Format_Invalid) ? FetchPixelProc(qt_fetchPixel<format>) : fetchPixelProc[data->texture.format]; |
|
672 |
#endif |
|
673 |
||
674 |
int image_width = data->texture.width; |
|
675 |
int image_height = data->texture.height; |
|
676 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
677 |
int image_x1 = data->texture.x1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
678 |
int image_y1 = data->texture.y1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
679 |
int image_x2 = data->texture.x2; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
680 |
int image_y2 = data->texture.y2; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
681 |
|
0 | 682 |
const qreal cx = x + 0.5; |
683 |
const qreal cy = y + 0.5; |
|
684 |
||
685 |
const uint *end = buffer + length; |
|
686 |
uint *b = buffer; |
|
687 |
if (data->fast_matrix) { |
|
688 |
// The increment pr x in the scanline |
|
689 |
int fdx = (int)(data->m11 * fixed_scale); |
|
690 |
int fdy = (int)(data->m12 * fixed_scale); |
|
691 |
||
692 |
int fx = int((data->m21 * cy |
|
693 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
694 |
int fy = int((data->m22 * cy |
|
695 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
696 |
||
697 |
fx -= half_point; |
|
698 |
fy -= half_point; |
|
699 |
while (b < end) { |
|
700 |
int x1 = (fx >> 16); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
701 |
int x2; |
0 | 702 |
int y1 = (fy >> 16); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
703 |
int y2; |
0 | 704 |
|
705 |
if (blendType == BlendTransformedBilinearTiled) { |
|
706 |
x1 %= image_width; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
707 |
if (x1 < 0) x1 += image_width; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
708 |
x2 = x1 + 1; |
0 | 709 |
x2 %= image_width; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
710 |
|
0 | 711 |
y1 %= image_height; |
712 |
if (y1 < 0) y1 += image_height; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
713 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
714 |
y2 %= image_height; |
0 | 715 |
} else { |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
716 |
if (x1 < image_x1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
717 |
x2 = x1 = image_x1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
718 |
} else if (x1 >= image_x2 - 1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
719 |
x2 = x1 = image_x2 - 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
720 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
721 |
x2 = x1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
722 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
723 |
if (y1 < image_y1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
724 |
y2 = y1 = image_y1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
725 |
} else if (y1 >= image_y2 - 1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
726 |
y2 = y1 = image_y2 - 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
727 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
728 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
729 |
} |
0 | 730 |
} |
731 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
732 |
Q_ASSERT(x1 >= 0 && x1 < image_width); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
733 |
Q_ASSERT(x2 >= 0 && x2 < image_width); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
734 |
Q_ASSERT(y1 >= 0 && y1 < image_height); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
735 |
Q_ASSERT(y2 >= 0 && y2 < image_height); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
736 |
|
0 | 737 |
const uchar *s1 = data->texture.scanLine(y1); |
738 |
const uchar *s2 = data->texture.scanLine(y2); |
|
739 |
||
740 |
uint tl = fetch(s1, x1, data->texture.colorTable); |
|
741 |
uint tr = fetch(s1, x2, data->texture.colorTable); |
|
742 |
uint bl = fetch(s2, x1, data->texture.colorTable); |
|
743 |
uint br = fetch(s2, x2, data->texture.colorTable); |
|
744 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
745 |
int distx = (fx & 0x0000ffff) >> 8; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
746 |
int disty = (fy & 0x0000ffff) >> 8; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
747 |
int idistx = 256 - distx; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
748 |
int idisty = 256 - disty; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
749 |
|
0 | 750 |
uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); |
751 |
uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); |
|
752 |
*b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); |
|
753 |
||
754 |
fx += fdx; |
|
755 |
fy += fdy; |
|
756 |
++b; |
|
757 |
} |
|
758 |
} else { |
|
759 |
const qreal fdx = data->m11; |
|
760 |
const qreal fdy = data->m12; |
|
761 |
const qreal fdw = data->m13; |
|
762 |
||
763 |
qreal fx = data->m21 * cy + data->m11 * cx + data->dx; |
|
764 |
qreal fy = data->m22 * cy + data->m12 * cx + data->dy; |
|
765 |
qreal fw = data->m23 * cy + data->m13 * cx + data->m33; |
|
766 |
||
767 |
while (b < end) { |
|
768 |
const qreal iw = fw == 0 ? 1 : 1 / fw; |
|
769 |
const qreal px = fx * iw - 0.5; |
|
770 |
const qreal py = fy * iw - 0.5; |
|
771 |
||
772 |
int x1 = int(px) - (px < 0); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
773 |
int x2; |
0 | 774 |
int y1 = int(py) - (py < 0); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
775 |
int y2; |
0 | 776 |
|
777 |
int distx = int((px - x1) * 256); |
|
778 |
int disty = int((py - y1) * 256); |
|
779 |
int idistx = 256 - distx; |
|
780 |
int idisty = 256 - disty; |
|
781 |
||
782 |
if (blendType == BlendTransformedBilinearTiled) { |
|
783 |
x1 %= image_width; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
784 |
if (x1 < 0) x1 += image_width; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
785 |
x2 = x1 + 1; |
0 | 786 |
x2 %= image_width; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
787 |
|
0 | 788 |
y1 %= image_height; |
789 |
if (y1 < 0) y1 += image_height; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
790 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
791 |
y2 %= image_height; |
0 | 792 |
} else { |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
793 |
if (x1 < 0) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
794 |
x2 = x1 = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
795 |
} else if (x1 >= image_width - 1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
796 |
x2 = x1 = image_width - 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
797 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
798 |
x2 = x1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
799 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
800 |
if (y1 < 0) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
801 |
y2 = y1 = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
802 |
} else if (y1 >= image_height - 1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
803 |
y2 = y1 = image_height - 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
804 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
805 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
806 |
} |
0 | 807 |
} |
808 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
809 |
Q_ASSERT(x1 >= 0 && x1 < image_width); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
810 |
Q_ASSERT(x2 >= 0 && x2 < image_width); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
811 |
Q_ASSERT(y1 >= 0 && y1 < image_height); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
812 |
Q_ASSERT(y2 >= 0 && y2 < image_height); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
813 |
|
0 | 814 |
const uchar *s1 = data->texture.scanLine(y1); |
815 |
const uchar *s2 = data->texture.scanLine(y2); |
|
816 |
||
817 |
uint tl = fetch(s1, x1, data->texture.colorTable); |
|
818 |
uint tr = fetch(s1, x2, data->texture.colorTable); |
|
819 |
uint bl = fetch(s2, x1, data->texture.colorTable); |
|
820 |
uint br = fetch(s2, x2, data->texture.colorTable); |
|
821 |
||
822 |
uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); |
|
823 |
uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); |
|
824 |
*b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); |
|
825 |
||
826 |
fx += fdx; |
|
827 |
fy += fdy; |
|
828 |
fw += fdw; |
|
829 |
//force increment to avoid /0 |
|
830 |
if (!fw) { |
|
831 |
fw += fdw; |
|
832 |
} |
|
833 |
++b; |
|
834 |
} |
|
835 |
} |
|
836 |
||
837 |
return buffer; |
|
838 |
} |
|
839 |
||
840 |
#define SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Arg) qt_fetchUntransformed<QImage::Arg> |
|
841 |
||
842 |
static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { |
|
843 |
// Untransformed |
|
844 |
{ |
|
845 |
0, // Invalid |
|
846 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_Mono), // Mono |
|
847 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_MonoLSB), // MonoLsb |
|
848 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_Indexed8), // Indexed8 |
|
849 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32_Premultiplied), // RGB32 |
|
850 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32), // ARGB32 |
|
851 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32_Premultiplied), // ARGB32_Premultiplied |
|
852 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB16), // RGB16 |
|
853 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB8565_Premultiplied),// ARGB8565_Premultiplied |
|
854 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB666), // RGB666 |
|
855 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB6666_Premultiplied),// ARGB6666_Premultiplied |
|
856 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB555), // RGB555 |
|
857 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB8555_Premultiplied),// ARGB8555_Premultiplied |
|
858 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB888), // RGB888 |
|
859 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB444), // RGB444 |
|
860 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB4444_Premultiplied) // ARGB4444_Premultiplied |
|
861 |
}, |
|
862 |
// Tiled |
|
863 |
{ |
|
864 |
0, // Invalid |
|
865 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_Mono), // Mono |
|
866 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_MonoLSB), // MonoLsb |
|
867 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_Indexed8), // Indexed8 |
|
868 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32_Premultiplied), // RGB32 |
|
869 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32), // ARGB32 |
|
870 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32_Premultiplied), // ARGB32_Premultiplied |
|
871 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB16), // RGB16 |
|
872 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB8565_Premultiplied),// ARGB8565_Premultiplied |
|
873 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB666), // RGB666 |
|
874 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB6666_Premultiplied),// ARGB6666_Premultiplied |
|
875 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB555), // RGB555 |
|
876 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB8555_Premultiplied),// ARGB8555_Premultiplied |
|
877 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB888), // RGB888 |
|
878 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB444), // RGB444 |
|
879 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB4444_Premultiplied) // ARGB4444_Premultiplied |
|
880 |
}, |
|
881 |
// Transformed |
|
882 |
{ |
|
883 |
0, // Invalid |
|
884 |
fetchTransformed<BlendTransformed>, // Mono |
|
885 |
fetchTransformed<BlendTransformed>, // MonoLsb |
|
886 |
fetchTransformed<BlendTransformed>, // Indexed8 |
|
887 |
fetchTransformed<BlendTransformed>, // RGB32 |
|
888 |
fetchTransformed<BlendTransformed>, // ARGB32 |
|
889 |
fetchTransformed<BlendTransformed>, // ARGB32_Premultiplied |
|
890 |
fetchTransformed<BlendTransformed>, // RGB16 |
|
891 |
fetchTransformed<BlendTransformed>, // ARGB8565_Premultiplied |
|
892 |
fetchTransformed<BlendTransformed>, // RGB666 |
|
893 |
fetchTransformed<BlendTransformed>, // ARGB6666_Premultiplied |
|
894 |
fetchTransformed<BlendTransformed>, // RGB555 |
|
895 |
fetchTransformed<BlendTransformed>, // ARGB8555_Premultiplied |
|
896 |
fetchTransformed<BlendTransformed>, // RGB888 |
|
897 |
fetchTransformed<BlendTransformed>, // RGB444 |
|
898 |
fetchTransformed<BlendTransformed>, // ARGB4444_Premultiplied |
|
899 |
}, |
|
900 |
{ |
|
901 |
0, // TransformedTiled |
|
902 |
fetchTransformed<BlendTransformedTiled>, // Mono |
|
903 |
fetchTransformed<BlendTransformedTiled>, // MonoLsb |
|
904 |
fetchTransformed<BlendTransformedTiled>, // Indexed8 |
|
905 |
fetchTransformed<BlendTransformedTiled>, // RGB32 |
|
906 |
fetchTransformed<BlendTransformedTiled>, // ARGB32 |
|
907 |
fetchTransformed<BlendTransformedTiled>, // ARGB32_Premultiplied |
|
908 |
fetchTransformed<BlendTransformedTiled>, // RGB16 |
|
909 |
fetchTransformed<BlendTransformedTiled>, // ARGB8565_Premultiplied |
|
910 |
fetchTransformed<BlendTransformedTiled>, // RGB666 |
|
911 |
fetchTransformed<BlendTransformedTiled>, // ARGB6666_Premultiplied |
|
912 |
fetchTransformed<BlendTransformedTiled>, // RGB555 |
|
913 |
fetchTransformed<BlendTransformedTiled>, // ARGB8555_Premultiplied |
|
914 |
fetchTransformed<BlendTransformedTiled>, // RGB888 |
|
915 |
fetchTransformed<BlendTransformedTiled>, // RGB444 |
|
916 |
fetchTransformed<BlendTransformedTiled>, // ARGB4444_Premultiplied |
|
917 |
}, |
|
918 |
{ |
|
919 |
0, // Bilinear |
|
920 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // Mono |
|
921 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // MonoLsb |
|
922 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // Indexed8 |
|
923 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_ARGB32_Premultiplied>, // RGB32 |
|
924 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_ARGB32>, // ARGB32 |
|
925 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_ARGB32_Premultiplied>, // ARGB32_Premultiplied |
|
926 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB16 |
|
927 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // ARGB8565_Premultiplied |
|
928 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB666 |
|
929 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // ARGB6666_Premultiplied |
|
930 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB555 |
|
931 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // ARGB8555_Premultiplied |
|
932 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB888 |
|
933 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB444 |
|
934 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid> // ARGB4444_Premultiplied |
|
935 |
}, |
|
936 |
{ |
|
937 |
0, // BilinearTiled |
|
938 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // Mono |
|
939 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // MonoLsb |
|
940 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // Indexed8 |
|
941 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_ARGB32_Premultiplied>, // RGB32 |
|
942 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_ARGB32>, // ARGB32 |
|
943 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_ARGB32_Premultiplied>, // ARGB32_Premultiplied |
|
944 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB16 |
|
945 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // ARGB8565_Premultiplied |
|
946 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB666 |
|
947 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // ARGB6666_Premultiplied |
|
948 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB555 |
|
949 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // ARGB8555_Premultiplied |
|
950 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB888 |
|
951 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB444 |
|
952 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid> // ARGB4444_Premultiplied |
|
953 |
}, |
|
954 |
}; |
|
955 |
||
956 |
||
957 |
static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos) |
|
958 |
{ |
|
959 |
int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + 0.5); |
|
960 |
||
961 |
// calculate the actual offset. |
|
962 |
if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) { |
|
963 |
if (data->spread == QGradient::RepeatSpread) { |
|
964 |
ipos = ipos % GRADIENT_STOPTABLE_SIZE; |
|
965 |
ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos; |
|
966 |
||
967 |
} else if (data->spread == QGradient::ReflectSpread) { |
|
968 |
const int limit = GRADIENT_STOPTABLE_SIZE * 2 - 1; |
|
969 |
ipos = ipos % limit; |
|
970 |
ipos = ipos < 0 ? limit + ipos : ipos; |
|
971 |
ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos; |
|
972 |
||
973 |
} else { |
|
974 |
if (ipos < 0) ipos = 0; |
|
975 |
else if (ipos >= GRADIENT_STOPTABLE_SIZE) ipos = GRADIENT_STOPTABLE_SIZE-1; |
|
976 |
} |
|
977 |
} |
|
978 |
||
979 |
Q_ASSERT(ipos >= 0); |
|
980 |
Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE); |
|
981 |
||
982 |
return data->colorTable[ipos]; |
|
983 |
} |
|
984 |
||
985 |
#define FIXPT_BITS 8 |
|
986 |
#define FIXPT_SIZE (1<<FIXPT_BITS) |
|
987 |
||
988 |
static uint qt_gradient_pixel_fixed(const QGradientData *data, int fixed_pos) |
|
989 |
{ |
|
990 |
int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS; |
|
991 |
||
992 |
// calculate the actual offset. |
|
993 |
if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) { |
|
994 |
if (data->spread == QGradient::RepeatSpread) { |
|
995 |
ipos = ipos % GRADIENT_STOPTABLE_SIZE; |
|
996 |
ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos; |
|
997 |
||
998 |
} else if (data->spread == QGradient::ReflectSpread) { |
|
999 |
const int limit = GRADIENT_STOPTABLE_SIZE * 2 - 1; |
|
1000 |
ipos = ipos % limit; |
|
1001 |
ipos = ipos < 0 ? limit + ipos : ipos; |
|
1002 |
ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos; |
|
1003 |
||
1004 |
} else { |
|
1005 |
if (ipos < 0) ipos = 0; |
|
1006 |
else if (ipos >= GRADIENT_STOPTABLE_SIZE) ipos = GRADIENT_STOPTABLE_SIZE-1; |
|
1007 |
} |
|
1008 |
} |
|
1009 |
||
1010 |
Q_ASSERT(ipos >= 0); |
|
1011 |
Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE); |
|
1012 |
||
1013 |
return data->colorTable[ipos]; |
|
1014 |
} |
|
1015 |
||
1016 |
static void QT_FASTCALL getLinearGradientValues(LinearGradientValues *v, const QSpanData *data) |
|
1017 |
{ |
|
1018 |
v->dx = data->gradient.linear.end.x - data->gradient.linear.origin.x; |
|
1019 |
v->dy = data->gradient.linear.end.y - data->gradient.linear.origin.y; |
|
1020 |
v->l = v->dx * v->dx + v->dy * v->dy; |
|
1021 |
v->off = 0; |
|
1022 |
if (v->l != 0) { |
|
1023 |
v->dx /= v->l; |
|
1024 |
v->dy /= v->l; |
|
1025 |
v->off = -v->dx * data->gradient.linear.origin.x - v->dy * data->gradient.linear.origin.y; |
|
1026 |
} |
|
1027 |
} |
|
1028 |
||
1029 |
static const uint * QT_FASTCALL fetchLinearGradient(uint *buffer, const Operator *op, const QSpanData *data, |
|
1030 |
int y, int x, int length) |
|
1031 |
{ |
|
1032 |
const uint *b = buffer; |
|
1033 |
qreal t, inc; |
|
1034 |
||
1035 |
bool affine = true; |
|
1036 |
qreal rx=0, ry=0; |
|
1037 |
if (op->linear.l == 0) { |
|
1038 |
t = inc = 0; |
|
1039 |
} else { |
|
1040 |
rx = data->m21 * (y + 0.5) + data->m11 * (x + 0.5) + data->dx; |
|
1041 |
ry = data->m22 * (y + 0.5) + data->m12 * (x + 0.5) + data->dy; |
|
1042 |
t = op->linear.dx*rx + op->linear.dy*ry + op->linear.off; |
|
1043 |
inc = op->linear.dx * data->m11 + op->linear.dy * data->m12; |
|
1044 |
affine = !data->m13 && !data->m23; |
|
1045 |
||
1046 |
if (affine) { |
|
1047 |
t *= (GRADIENT_STOPTABLE_SIZE - 1); |
|
1048 |
inc *= (GRADIENT_STOPTABLE_SIZE - 1); |
|
1049 |
} |
|
1050 |
} |
|
1051 |
||
1052 |
const uint *end = buffer + length; |
|
1053 |
if (affine) { |
|
1054 |
if (inc > -1e-5 && inc < 1e-5) { |
|
1055 |
QT_MEMFILL_UINT(buffer, length, qt_gradient_pixel_fixed(&data->gradient, int(t * FIXPT_SIZE))); |
|
1056 |
} else { |
|
1057 |
if (t+inc*length < qreal(INT_MAX >> (FIXPT_BITS + 1)) && |
|
1058 |
t+inc*length > qreal(INT_MIN >> (FIXPT_BITS + 1))) { |
|
1059 |
// we can use fixed point math |
|
1060 |
int t_fixed = int(t * FIXPT_SIZE); |
|
1061 |
int inc_fixed = int(inc * FIXPT_SIZE); |
|
1062 |
while (buffer < end) { |
|
1063 |
*buffer = qt_gradient_pixel_fixed(&data->gradient, t_fixed); |
|
1064 |
t_fixed += inc_fixed; |
|
1065 |
++buffer; |
|
1066 |
} |
|
1067 |
} else { |
|
1068 |
// we have to fall back to float math |
|
1069 |
while (buffer < end) { |
|
1070 |
*buffer = qt_gradient_pixel(&data->gradient, t/GRADIENT_STOPTABLE_SIZE); |
|
1071 |
t += inc; |
|
1072 |
++buffer; |
|
1073 |
} |
|
1074 |
} |
|
1075 |
} |
|
1076 |
} else { // fall back to float math here as well |
|
1077 |
qreal rw = data->m23 * (y + 0.5) + data->m13 * (x + 0.5) + data->m33; |
|
1078 |
while (buffer < end) { |
|
1079 |
qreal x = rx/rw; |
|
1080 |
qreal y = ry/rw; |
|
1081 |
t = (op->linear.dx*x + op->linear.dy *y) + op->linear.off; |
|
1082 |
||
1083 |
*buffer = qt_gradient_pixel(&data->gradient, t); |
|
1084 |
rx += data->m11; |
|
1085 |
ry += data->m12; |
|
1086 |
rw += data->m13; |
|
1087 |
if (!rw) { |
|
1088 |
rw += data->m13; |
|
1089 |
} |
|
1090 |
++buffer; |
|
1091 |
} |
|
1092 |
} |
|
1093 |
||
1094 |
return b; |
|
1095 |
} |
|
1096 |
||
1097 |
static inline qreal determinant(qreal a, qreal b, qreal c) |
|
1098 |
{ |
|
1099 |
return (b * b) - (4 * a * c); |
|
1100 |
} |
|
1101 |
||
1102 |
// function to evaluate real roots |
|
1103 |
static inline qreal realRoots(qreal a, qreal b, qreal detSqrt) |
|
1104 |
{ |
|
1105 |
return (-b + detSqrt)/(2 * a); |
|
1106 |
} |
|
1107 |
||
1108 |
static inline qreal qSafeSqrt(qreal x) |
|
1109 |
{ |
|
1110 |
return x > 0 ? qSqrt(x) : 0; |
|
1111 |
} |
|
1112 |
||
1113 |
static void QT_FASTCALL getRadialGradientValues(RadialGradientValues *v, const QSpanData *data) |
|
1114 |
{ |
|
1115 |
v->dx = data->gradient.radial.center.x - data->gradient.radial.focal.x; |
|
1116 |
v->dy = data->gradient.radial.center.y - data->gradient.radial.focal.y; |
|
1117 |
v->a = data->gradient.radial.radius*data->gradient.radial.radius - v->dx*v->dx - v->dy*v->dy; |
|
1118 |
} |
|
1119 |
||
1120 |
static const uint * QT_FASTCALL fetchRadialGradient(uint *buffer, const Operator *op, const QSpanData *data, |
|
1121 |
int y, int x, int length) |
|
1122 |
{ |
|
1123 |
const uint *b = buffer; |
|
1124 |
qreal rx = data->m21 * (y + 0.5) |
|
1125 |
+ data->dx + data->m11 * (x + 0.5); |
|
1126 |
qreal ry = data->m22 * (y + 0.5) |
|
1127 |
+ data->dy + data->m12 * (x + 0.5); |
|
1128 |
bool affine = !data->m13 && !data->m23; |
|
1129 |
//qreal r = data->gradient.radial.radius; |
|
1130 |
||
1131 |
const uint *end = buffer + length; |
|
1132 |
if (affine) { |
|
1133 |
rx -= data->gradient.radial.focal.x; |
|
1134 |
ry -= data->gradient.radial.focal.y; |
|
1135 |
||
1136 |
qreal inv_a = 1 / qreal(2 * op->radial.a); |
|
1137 |
||
1138 |
const qreal delta_rx = data->m11; |
|
1139 |
const qreal delta_ry = data->m12; |
|
1140 |
||
1141 |
qreal b = 2*(rx * op->radial.dx + ry * op->radial.dy); |
|
1142 |
qreal delta_b = 2*(delta_rx * op->radial.dx + delta_ry * op->radial.dy); |
|
1143 |
const qreal b_delta_b = 2 * b * delta_b; |
|
1144 |
const qreal delta_b_delta_b = 2 * delta_b * delta_b; |
|
1145 |
||
1146 |
const qreal bb = b * b; |
|
1147 |
const qreal delta_bb = delta_b * delta_b; |
|
1148 |
||
1149 |
b *= inv_a; |
|
1150 |
delta_b *= inv_a; |
|
1151 |
||
1152 |
const qreal rxrxryry = rx * rx + ry * ry; |
|
1153 |
const qreal delta_rxrxryry = delta_rx * delta_rx + delta_ry * delta_ry; |
|
1154 |
const qreal rx_plus_ry = 2*(rx * delta_rx + ry * delta_ry); |
|
1155 |
const qreal delta_rx_plus_ry = 2 * delta_rxrxryry; |
|
1156 |
||
1157 |
inv_a *= inv_a; |
|
1158 |
||
1159 |
qreal det = (bb + 4 * op->radial.a * rxrxryry) * inv_a; |
|
1160 |
qreal delta_det = (b_delta_b + delta_bb + 4 * op->radial.a * (rx_plus_ry + delta_rxrxryry)) * inv_a; |
|
1161 |
const qreal delta_delta_det = (delta_b_delta_b + 4 * op->radial.a * delta_rx_plus_ry) * inv_a; |
|
1162 |
||
1163 |
while (buffer < end) { |
|
1164 |
*buffer = qt_gradient_pixel(&data->gradient, qSafeSqrt(det) - b); |
|
1165 |
||
1166 |
det += delta_det; |
|
1167 |
delta_det += delta_delta_det; |
|
1168 |
b += delta_b; |
|
1169 |
||
1170 |
++buffer; |
|
1171 |
} |
|
1172 |
} else { |
|
1173 |
qreal rw = data->m23 * (y + 0.5) |
|
1174 |
+ data->m33 + data->m13 * (x + 0.5); |
|
1175 |
if (!rw) |
|
1176 |
rw = 1; |
|
1177 |
while (buffer < end) { |
|
1178 |
qreal gx = rx/rw - data->gradient.radial.focal.x; |
|
1179 |
qreal gy = ry/rw - data->gradient.radial.focal.y; |
|
1180 |
qreal b = 2*(gx*op->radial.dx + gy*op->radial.dy); |
|
1181 |
qreal det = determinant(op->radial.a, b , -(gx*gx + gy*gy)); |
|
1182 |
qreal s = realRoots(op->radial.a, b, qSafeSqrt(det)); |
|
1183 |
||
1184 |
*buffer = qt_gradient_pixel(&data->gradient, s); |
|
1185 |
||
1186 |
rx += data->m11; |
|
1187 |
ry += data->m12; |
|
1188 |
rw += data->m13; |
|
1189 |
if (!rw) { |
|
1190 |
rw += data->m13; |
|
1191 |
} |
|
1192 |
++buffer; |
|
1193 |
} |
|
1194 |
} |
|
1195 |
||
1196 |
return b; |
|
1197 |
} |
|
1198 |
||
1199 |
static const uint * QT_FASTCALL fetchConicalGradient(uint *buffer, const Operator *, const QSpanData *data, |
|
1200 |
int y, int x, int length) |
|
1201 |
{ |
|
1202 |
const uint *b = buffer; |
|
1203 |
qreal rx = data->m21 * (y + 0.5) |
|
1204 |
+ data->dx + data->m11 * (x + 0.5); |
|
1205 |
qreal ry = data->m22 * (y + 0.5) |
|
1206 |
+ data->dy + data->m12 * (x + 0.5); |
|
1207 |
bool affine = !data->m13 && !data->m23; |
|
1208 |
||
1209 |
const uint *end = buffer + length; |
|
1210 |
if (affine) { |
|
1211 |
rx -= data->gradient.conical.center.x; |
|
1212 |
ry -= data->gradient.conical.center.y; |
|
1213 |
while (buffer < end) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1214 |
qreal angle = qAtan2(ry, rx) + data->gradient.conical.angle; |
0 | 1215 |
|
1216 |
*buffer = qt_gradient_pixel(&data->gradient, 1 - angle / (2*Q_PI)); |
|
1217 |
||
1218 |
rx += data->m11; |
|
1219 |
ry += data->m12; |
|
1220 |
++buffer; |
|
1221 |
} |
|
1222 |
} else { |
|
1223 |
qreal rw = data->m23 * (y + 0.5) |
|
1224 |
+ data->m33 + data->m13 * (x + 0.5); |
|
1225 |
if (!rw) |
|
1226 |
rw = 1; |
|
1227 |
while (buffer < end) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1228 |
qreal angle = qAtan2(ry/rw - data->gradient.conical.center.x, |
0 | 1229 |
rx/rw - data->gradient.conical.center.y) |
1230 |
+ data->gradient.conical.angle; |
|
1231 |
||
1232 |
*buffer = qt_gradient_pixel(&data->gradient, 1. - angle / (2*Q_PI)); |
|
1233 |
||
1234 |
rx += data->m11; |
|
1235 |
ry += data->m12; |
|
1236 |
rw += data->m13; |
|
1237 |
if (!rw) { |
|
1238 |
rw += data->m13; |
|
1239 |
} |
|
1240 |
++buffer; |
|
1241 |
} |
|
1242 |
} |
|
1243 |
return b; |
|
1244 |
} |
|
1245 |
||
1246 |
#if defined(Q_CC_RVCT) |
|
1247 |
// Force ARM code generation for comp_func_* -methods |
|
1248 |
# pragma push |
|
1249 |
# pragma arm |
|
1250 |
# if defined(QT_HAVE_ARMV6) |
|
1251 |
static __forceinline void preload(const uint *start) |
|
1252 |
{ |
|
1253 |
asm( "pld [start]" ); |
|
1254 |
} |
|
1255 |
static const uint L2CacheLineLength = 32; |
|
1256 |
static const uint L2CacheLineLengthInInts = L2CacheLineLength/sizeof(uint); |
|
1257 |
# define PRELOAD_INIT(x) preload(x); |
|
1258 |
# define PRELOAD_INIT2(x,y) PRELOAD_INIT(x) PRELOAD_INIT(y) |
|
1259 |
# define PRELOAD_COND(x) if (((uint)&x[i])%L2CacheLineLength == 0) preload(&x[i] + L2CacheLineLengthInInts); |
|
1260 |
// Two consecutive preloads stall, so space them out a bit by using different modulus. |
|
1261 |
# define PRELOAD_COND2(x,y) if (((uint)&x[i])%L2CacheLineLength == 0) preload(&x[i] + L2CacheLineLengthInInts); \ |
|
1262 |
if (((uint)&y[i])%L2CacheLineLength == 16) preload(&y[i] + L2CacheLineLengthInInts); |
|
1263 |
# endif // QT_HAVE_ARMV6 |
|
1264 |
#endif // Q_CC_RVCT |
|
1265 |
||
1266 |
#if !defined(Q_CC_RVCT) || !defined(QT_HAVE_ARMV6) |
|
1267 |
# define PRELOAD_INIT(x) |
|
1268 |
# define PRELOAD_INIT2(x,y) |
|
1269 |
# define PRELOAD_COND(x) |
|
1270 |
# define PRELOAD_COND2(x,y) |
|
1271 |
#endif |
|
1272 |
||
1273 |
/* The constant alpha factor describes an alpha factor that gets applied |
|
1274 |
to the result of the composition operation combining it with the destination. |
|
1275 |
||
1276 |
The intent is that if const_alpha == 0. we get back dest, and if const_alpha == 1. |
|
1277 |
we get the unmodified operation |
|
1278 |
||
1279 |
result = src op dest |
|
1280 |
dest = result * const_alpha + dest * (1. - const_alpha) |
|
1281 |
||
1282 |
This means that in the comments below, the first line is the const_alpha==255 case, the |
|
1283 |
second line the general one. |
|
1284 |
||
1285 |
In the lines below: |
|
1286 |
s == src, sa == alpha(src), sia = 1 - alpha(src) |
|
1287 |
d == dest, da == alpha(dest), dia = 1 - alpha(dest) |
|
1288 |
ca = const_alpha, cia = 1 - const_alpha |
|
1289 |
||
1290 |
The methods exist in two variants. One where we have a constant source, the other |
|
1291 |
where the source is an array of pixels. |
|
1292 |
*/ |
|
1293 |
||
1294 |
/* |
|
1295 |
result = 0 |
|
1296 |
d = d * cia |
|
1297 |
*/ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1298 |
#define comp_func_Clear_impl(dest, length, const_alpha)\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1299 |
{\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1300 |
if (const_alpha == 255) {\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1301 |
QT_MEMFILL_UINT(dest, length, 0);\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1302 |
} else {\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1303 |
int ialpha = 255 - const_alpha;\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1304 |
PRELOAD_INIT(dest)\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1305 |
for (int i = 0; i < length; ++i) {\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1306 |
PRELOAD_COND(dest)\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1307 |
dest[i] = BYTE_MUL(dest[i], ialpha);\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1308 |
}\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1309 |
}\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1310 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1311 |
|
0 | 1312 |
static void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha) |
1313 |
{ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1314 |
comp_func_Clear_impl(dest, length, const_alpha); |
0 | 1315 |
} |
1316 |
||
1317 |
static void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha) |
|
1318 |
{ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1319 |
comp_func_Clear_impl(dest, length, const_alpha); |
0 | 1320 |
} |
1321 |
||
1322 |
/* |
|
1323 |
result = s |
|
1324 |
dest = s * ca + d * cia |
|
1325 |
*/ |
|
1326 |
static void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint const_alpha) |
|
1327 |
{ |
|
1328 |
if (const_alpha == 255) { |
|
1329 |
QT_MEMFILL_UINT(dest, length, color); |
|
1330 |
} else { |
|
1331 |
int ialpha = 255 - const_alpha; |
|
1332 |
color = BYTE_MUL(color, const_alpha); |
|
1333 |
PRELOAD_INIT(dest) |
|
1334 |
for (int i = 0; i < length; ++i) { |
|
1335 |
PRELOAD_COND(dest) |
|
1336 |
dest[i] = color + BYTE_MUL(dest[i], ialpha); |
|
1337 |
} |
|
1338 |
} |
|
1339 |
} |
|
1340 |
||
1341 |
static void QT_FASTCALL comp_func_Source(uint *dest, const uint *src, int length, uint const_alpha) |
|
1342 |
{ |
|
1343 |
if (const_alpha == 255) { |
|
1344 |
::memcpy(dest, src, length * sizeof(uint)); |
|
1345 |
} else { |
|
1346 |
int ialpha = 255 - const_alpha; |
|
1347 |
PRELOAD_INIT2(dest, src) |
|
1348 |
for (int i = 0; i < length; ++i) { |
|
1349 |
PRELOAD_COND2(dest, src) |
|
1350 |
dest[i] = INTERPOLATE_PIXEL_255(src[i], const_alpha, dest[i], ialpha); |
|
1351 |
} |
|
1352 |
} |
|
1353 |
} |
|
1354 |
||
1355 |
static void QT_FASTCALL comp_func_solid_Destination(uint *, int, uint, uint) |
|
1356 |
{ |
|
1357 |
} |
|
1358 |
||
1359 |
static void QT_FASTCALL comp_func_Destination(uint *, const uint *, int, uint) |
|
1360 |
{ |
|
1361 |
} |
|
1362 |
||
1363 |
/* |
|
1364 |
result = s + d * sia |
|
1365 |
dest = (s + d * sia) * ca + d * cia |
|
1366 |
= s * ca + d * (sia * ca + cia) |
|
1367 |
= s * ca + d * (1 - sa*ca) |
|
1368 |
*/ |
|
1369 |
static void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha) |
|
1370 |
{ |
|
1371 |
if ((const_alpha & qAlpha(color)) == 255) { |
|
1372 |
QT_MEMFILL_UINT(dest, length, color); |
|
1373 |
} else { |
|
1374 |
if (const_alpha != 255) |
|
1375 |
color = BYTE_MUL(color, const_alpha); |
|
1376 |
PRELOAD_INIT(dest) |
|
1377 |
for (int i = 0; i < length; ++i) { |
|
1378 |
PRELOAD_COND(dest) |
|
1379 |
dest[i] = color + BYTE_MUL(dest[i], qAlpha(~color)); |
|
1380 |
} |
|
1381 |
} |
|
1382 |
} |
|
1383 |
||
1384 |
static void QT_FASTCALL comp_func_SourceOver(uint *dest, const uint *src, int length, uint const_alpha) |
|
1385 |
{ |
|
1386 |
PRELOAD_INIT2(dest, src) |
|
1387 |
if (const_alpha == 255) { |
|
1388 |
for (int i = 0; i < length; ++i) { |
|
1389 |
PRELOAD_COND2(dest, src) |
|
1390 |
uint s = src[i]; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1391 |
if (s >= 0xff000000) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1392 |
dest[i] = s; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1393 |
else if (s != 0) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1394 |
dest[i] = s + BYTE_MUL(dest[i], qAlpha(~s)); |
0 | 1395 |
} |
1396 |
} else { |
|
1397 |
for (int i = 0; i < length; ++i) { |
|
1398 |
PRELOAD_COND2(dest, src) |
|
1399 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1400 |
dest[i] = s + BYTE_MUL(dest[i], qAlpha(~s)); |
|
1401 |
} |
|
1402 |
} |
|
1403 |
} |
|
1404 |
||
1405 |
/* |
|
1406 |
result = d + s * dia |
|
1407 |
dest = (d + s * dia) * ca + d * cia |
|
1408 |
= d + s * dia * ca |
|
1409 |
*/ |
|
1410 |
static void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha) |
|
1411 |
{ |
|
1412 |
if (const_alpha != 255) |
|
1413 |
color = BYTE_MUL(color, const_alpha); |
|
1414 |
PRELOAD_INIT(dest) |
|
1415 |
for (int i = 0; i < length; ++i) { |
|
1416 |
PRELOAD_COND(dest) |
|
1417 |
uint d = dest[i]; |
|
1418 |
dest[i] = d + BYTE_MUL(color, qAlpha(~d)); |
|
1419 |
} |
|
1420 |
} |
|
1421 |
||
1422 |
static void QT_FASTCALL comp_func_DestinationOver(uint *dest, const uint *src, int length, uint const_alpha) |
|
1423 |
{ |
|
1424 |
PRELOAD_INIT2(dest, src) |
|
1425 |
if (const_alpha == 255) { |
|
1426 |
for (int i = 0; i < length; ++i) { |
|
1427 |
PRELOAD_COND2(dest, src) |
|
1428 |
uint d = dest[i]; |
|
1429 |
dest[i] = d + BYTE_MUL(src[i], qAlpha(~d)); |
|
1430 |
} |
|
1431 |
} else { |
|
1432 |
for (int i = 0; i < length; ++i) { |
|
1433 |
PRELOAD_COND2(dest, src) |
|
1434 |
uint d = dest[i]; |
|
1435 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1436 |
dest[i] = d + BYTE_MUL(s, qAlpha(~d)); |
|
1437 |
} |
|
1438 |
} |
|
1439 |
} |
|
1440 |
||
1441 |
/* |
|
1442 |
result = s * da |
|
1443 |
dest = s * da * ca + d * cia |
|
1444 |
*/ |
|
1445 |
static void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, uint const_alpha) |
|
1446 |
{ |
|
1447 |
PRELOAD_INIT(dest) |
|
1448 |
if (const_alpha == 255) { |
|
1449 |
for (int i = 0; i < length; ++i) { |
|
1450 |
PRELOAD_COND(dest) |
|
1451 |
dest[i] = BYTE_MUL(color, qAlpha(dest[i])); |
|
1452 |
} |
|
1453 |
} else { |
|
1454 |
color = BYTE_MUL(color, const_alpha); |
|
1455 |
uint cia = 255 - const_alpha; |
|
1456 |
for (int i = 0; i < length; ++i) { |
|
1457 |
PRELOAD_COND(dest) |
|
1458 |
uint d = dest[i]; |
|
1459 |
dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(d), d, cia); |
|
1460 |
} |
|
1461 |
} |
|
1462 |
} |
|
1463 |
||
1464 |
static void QT_FASTCALL comp_func_SourceIn(uint *dest, const uint *src, int length, uint const_alpha) |
|
1465 |
{ |
|
1466 |
PRELOAD_INIT2(dest, src) |
|
1467 |
if (const_alpha == 255) { |
|
1468 |
for (int i = 0; i < length; ++i) { |
|
1469 |
PRELOAD_COND2(dest, src) |
|
1470 |
dest[i] = BYTE_MUL(src[i], qAlpha(dest[i])); |
|
1471 |
} |
|
1472 |
} else { |
|
1473 |
uint cia = 255 - const_alpha; |
|
1474 |
for (int i = 0; i < length; ++i) { |
|
1475 |
PRELOAD_COND2(dest, src) |
|
1476 |
uint d = dest[i]; |
|
1477 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1478 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, cia); |
|
1479 |
} |
|
1480 |
} |
|
1481 |
} |
|
1482 |
||
1483 |
/* |
|
1484 |
result = d * sa |
|
1485 |
dest = d * sa * ca + d * cia |
|
1486 |
= d * (sa * ca + cia) |
|
1487 |
*/ |
|
1488 |
static void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha) |
|
1489 |
{ |
|
1490 |
uint a = qAlpha(color); |
|
1491 |
if (const_alpha != 255) { |
|
1492 |
a = BYTE_MUL(a, const_alpha) + 255 - const_alpha; |
|
1493 |
} |
|
1494 |
PRELOAD_INIT(dest) |
|
1495 |
for (int i = 0; i < length; ++i) { |
|
1496 |
PRELOAD_COND(dest) |
|
1497 |
dest[i] = BYTE_MUL(dest[i], a); |
|
1498 |
} |
|
1499 |
} |
|
1500 |
||
1501 |
static void QT_FASTCALL comp_func_DestinationIn(uint *dest, const uint *src, int length, uint const_alpha) |
|
1502 |
{ |
|
1503 |
PRELOAD_INIT2(dest, src) |
|
1504 |
if (const_alpha == 255) { |
|
1505 |
for (int i = 0; i < length; ++i) { |
|
1506 |
PRELOAD_COND2(dest, src) |
|
1507 |
dest[i] = BYTE_MUL(dest[i], qAlpha(src[i])); |
|
1508 |
} |
|
1509 |
} else { |
|
1510 |
int cia = 255 - const_alpha; |
|
1511 |
for (int i = 0; i < length; ++i) { |
|
1512 |
PRELOAD_COND2(dest, src) |
|
1513 |
uint a = BYTE_MUL(qAlpha(src[i]), const_alpha) + cia; |
|
1514 |
dest[i] = BYTE_MUL(dest[i], a); |
|
1515 |
} |
|
1516 |
} |
|
1517 |
} |
|
1518 |
||
1519 |
/* |
|
1520 |
result = s * dia |
|
1521 |
dest = s * dia * ca + d * cia |
|
1522 |
*/ |
|
1523 |
||
1524 |
static void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, uint const_alpha) |
|
1525 |
{ |
|
1526 |
PRELOAD_INIT(dest) |
|
1527 |
if (const_alpha == 255) { |
|
1528 |
for (int i = 0; i < length; ++i) { |
|
1529 |
PRELOAD_COND(dest) |
|
1530 |
dest[i] = BYTE_MUL(color, qAlpha(~dest[i])); |
|
1531 |
} |
|
1532 |
} else { |
|
1533 |
color = BYTE_MUL(color, const_alpha); |
|
1534 |
int cia = 255 - const_alpha; |
|
1535 |
for (int i = 0; i < length; ++i) { |
|
1536 |
PRELOAD_COND(dest) |
|
1537 |
uint d = dest[i]; |
|
1538 |
dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(~d), d, cia); |
|
1539 |
} |
|
1540 |
} |
|
1541 |
} |
|
1542 |
||
1543 |
static void QT_FASTCALL comp_func_SourceOut(uint *dest, const uint *src, int length, uint const_alpha) |
|
1544 |
{ |
|
1545 |
PRELOAD_INIT2(dest, src) |
|
1546 |
if (const_alpha == 255) { |
|
1547 |
for (int i = 0; i < length; ++i) { |
|
1548 |
PRELOAD_COND2(dest, src) |
|
1549 |
dest[i] = BYTE_MUL(src[i], qAlpha(~dest[i])); |
|
1550 |
} |
|
1551 |
} else { |
|
1552 |
int cia = 255 - const_alpha; |
|
1553 |
for (int i = 0; i < length; ++i) { |
|
1554 |
PRELOAD_COND2(dest, src) |
|
1555 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1556 |
uint d = dest[i]; |
|
1557 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, cia); |
|
1558 |
} |
|
1559 |
} |
|
1560 |
} |
|
1561 |
||
1562 |
/* |
|
1563 |
result = d * sia |
|
1564 |
dest = d * sia * ca + d * cia |
|
1565 |
= d * (sia * ca + cia) |
|
1566 |
*/ |
|
1567 |
static void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha) |
|
1568 |
{ |
|
1569 |
uint a = qAlpha(~color); |
|
1570 |
if (const_alpha != 255) |
|
1571 |
a = BYTE_MUL(a, const_alpha) + 255 - const_alpha; |
|
1572 |
PRELOAD_INIT(dest) |
|
1573 |
for (int i = 0; i < length; ++i) { |
|
1574 |
PRELOAD_COND(dest) |
|
1575 |
dest[i] = BYTE_MUL(dest[i], a); |
|
1576 |
} |
|
1577 |
} |
|
1578 |
||
1579 |
static void QT_FASTCALL comp_func_DestinationOut(uint *dest, const uint *src, int length, uint const_alpha) |
|
1580 |
{ |
|
1581 |
PRELOAD_INIT2(dest, src) |
|
1582 |
if (const_alpha == 255) { |
|
1583 |
for (int i = 0; i < length; ++i) { |
|
1584 |
PRELOAD_COND2(dest, src) |
|
1585 |
dest[i] = BYTE_MUL(dest[i], qAlpha(~src[i])); |
|
1586 |
} |
|
1587 |
} else { |
|
1588 |
int cia = 255 - const_alpha; |
|
1589 |
for (int i = 0; i < length; ++i) { |
|
1590 |
PRELOAD_COND2(dest, src) |
|
1591 |
uint sia = BYTE_MUL(qAlpha(~src[i]), const_alpha) + cia; |
|
1592 |
dest[i] = BYTE_MUL(dest[i], sia); |
|
1593 |
} |
|
1594 |
} |
|
1595 |
} |
|
1596 |
||
1597 |
/* |
|
1598 |
result = s*da + d*sia |
|
1599 |
dest = s*da*ca + d*sia*ca + d *cia |
|
1600 |
= s*ca * da + d * (sia*ca + cia) |
|
1601 |
= s*ca * da + d * (1 - sa*ca) |
|
1602 |
*/ |
|
1603 |
static void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, uint const_alpha) |
|
1604 |
{ |
|
1605 |
if (const_alpha != 255) { |
|
1606 |
color = BYTE_MUL(color, const_alpha); |
|
1607 |
} |
|
1608 |
uint sia = qAlpha(~color); |
|
1609 |
PRELOAD_INIT(dest) |
|
1610 |
for (int i = 0; i < length; ++i) { |
|
1611 |
PRELOAD_COND(dest) |
|
1612 |
dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(dest[i]), dest[i], sia); |
|
1613 |
} |
|
1614 |
} |
|
1615 |
||
1616 |
static void QT_FASTCALL comp_func_SourceAtop(uint *dest, const uint *src, int length, uint const_alpha) |
|
1617 |
{ |
|
1618 |
PRELOAD_INIT2(dest, src) |
|
1619 |
if (const_alpha == 255) { |
|
1620 |
for (int i = 0; i < length; ++i) { |
|
1621 |
PRELOAD_COND2(dest, src) |
|
1622 |
uint s = src[i]; |
|
1623 |
uint d = dest[i]; |
|
1624 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, qAlpha(~s)); |
|
1625 |
} |
|
1626 |
} else { |
|
1627 |
for (int i = 0; i < length; ++i) { |
|
1628 |
PRELOAD_COND2(dest, src) |
|
1629 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1630 |
uint d = dest[i]; |
|
1631 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, qAlpha(~s)); |
|
1632 |
} |
|
1633 |
} |
|
1634 |
} |
|
1635 |
||
1636 |
/* |
|
1637 |
result = d*sa + s*dia |
|
1638 |
dest = d*sa*ca + s*dia*ca + d *cia |
|
1639 |
= s*ca * dia + d * (sa*ca + cia) |
|
1640 |
*/ |
|
1641 |
static void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint color, uint const_alpha) |
|
1642 |
{ |
|
1643 |
uint a = qAlpha(color); |
|
1644 |
if (const_alpha != 255) { |
|
1645 |
color = BYTE_MUL(color, const_alpha); |
|
1646 |
a = qAlpha(color) + 255 - const_alpha; |
|
1647 |
} |
|
1648 |
PRELOAD_INIT(dest) |
|
1649 |
for (int i = 0; i < length; ++i) { |
|
1650 |
PRELOAD_COND(dest) |
|
1651 |
uint d = dest[i]; |
|
1652 |
dest[i] = INTERPOLATE_PIXEL_255(d, a, color, qAlpha(~d)); |
|
1653 |
} |
|
1654 |
} |
|
1655 |
||
1656 |
static void QT_FASTCALL comp_func_DestinationAtop(uint *dest, const uint *src, int length, uint const_alpha) |
|
1657 |
{ |
|
1658 |
PRELOAD_INIT2(dest, src) |
|
1659 |
if (const_alpha == 255) { |
|
1660 |
for (int i = 0; i < length; ++i) { |
|
1661 |
PRELOAD_COND2(dest, src) |
|
1662 |
uint s = src[i]; |
|
1663 |
uint d = dest[i]; |
|
1664 |
dest[i] = INTERPOLATE_PIXEL_255(d, qAlpha(s), s, qAlpha(~d)); |
|
1665 |
} |
|
1666 |
} else { |
|
1667 |
int cia = 255 - const_alpha; |
|
1668 |
for (int i = 0; i < length; ++i) { |
|
1669 |
PRELOAD_COND2(dest, src) |
|
1670 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1671 |
uint d = dest[i]; |
|
1672 |
uint a = qAlpha(s) + cia; |
|
1673 |
dest[i] = INTERPOLATE_PIXEL_255(d, a, s, qAlpha(~d)); |
|
1674 |
} |
|
1675 |
} |
|
1676 |
} |
|
1677 |
||
1678 |
/* |
|
1679 |
result = d*sia + s*dia |
|
1680 |
dest = d*sia*ca + s*dia*ca + d *cia |
|
1681 |
= s*ca * dia + d * (sia*ca + cia) |
|
1682 |
= s*ca * dia + d * (1 - sa*ca) |
|
1683 |
*/ |
|
1684 |
static void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint const_alpha) |
|
1685 |
{ |
|
1686 |
if (const_alpha != 255) |
|
1687 |
color = BYTE_MUL(color, const_alpha); |
|
1688 |
uint sia = qAlpha(~color); |
|
1689 |
||
1690 |
PRELOAD_INIT(dest) |
|
1691 |
for (int i = 0; i < length; ++i) { |
|
1692 |
PRELOAD_COND(dest) |
|
1693 |
uint d = dest[i]; |
|
1694 |
dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(~d), d, sia); |
|
1695 |
} |
|
1696 |
} |
|
1697 |
||
1698 |
static void QT_FASTCALL comp_func_XOR(uint *dest, const uint *src, int length, uint const_alpha) |
|
1699 |
{ |
|
1700 |
PRELOAD_INIT2(dest, src) |
|
1701 |
if (const_alpha == 255) { |
|
1702 |
for (int i = 0; i < length; ++i) { |
|
1703 |
PRELOAD_COND2(dest, src) |
|
1704 |
uint d = dest[i]; |
|
1705 |
uint s = src[i]; |
|
1706 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, qAlpha(~s)); |
|
1707 |
} |
|
1708 |
} else { |
|
1709 |
for (int i = 0; i < length; ++i) { |
|
1710 |
PRELOAD_COND2(dest, src) |
|
1711 |
uint d = dest[i]; |
|
1712 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1713 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, qAlpha(~s)); |
|
1714 |
} |
|
1715 |
} |
|
1716 |
} |
|
1717 |
||
1718 |
static const uint AMASK = 0xff000000; |
|
1719 |
static const uint RMASK = 0x00ff0000; |
|
1720 |
static const uint GMASK = 0x0000ff00; |
|
1721 |
static const uint BMASK = 0x000000ff; |
|
1722 |
||
1723 |
struct QFullCoverage { |
|
1724 |
inline void store(uint *dest, const uint src) const |
|
1725 |
{ |
|
1726 |
*dest = src; |
|
1727 |
} |
|
1728 |
}; |
|
1729 |
||
1730 |
struct QPartialCoverage { |
|
1731 |
inline QPartialCoverage(uint const_alpha) |
|
1732 |
: ca(const_alpha) |
|
1733 |
, ica(255 - const_alpha) |
|
1734 |
{ |
|
1735 |
} |
|
1736 |
||
1737 |
inline void store(uint *dest, const uint src) const |
|
1738 |
{ |
|
1739 |
*dest = INTERPOLATE_PIXEL_255(src, ca, *dest, ica); |
|
1740 |
} |
|
1741 |
||
1742 |
private: |
|
1743 |
const uint ca; |
|
1744 |
const uint ica; |
|
1745 |
}; |
|
1746 |
||
1747 |
static inline int mix_alpha(int da, int sa) |
|
1748 |
{ |
|
1749 |
return 255 - ((255 - sa) * (255 - da) >> 8); |
|
1750 |
} |
|
1751 |
||
1752 |
/* |
|
1753 |
Dca' = Sca.Da + Dca.Sa + Sca.(1 - Da) + Dca.(1 - Sa) |
|
1754 |
= Sca + Dca |
|
1755 |
*/ |
|
1756 |
template <typename T> |
|
1757 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Plus_impl(uint *dest, int length, uint color, const T &coverage) |
|
1758 |
{ |
|
1759 |
uint s = color; |
|
1760 |
||
1761 |
PRELOAD_INIT(dest) |
|
1762 |
for (int i = 0; i < length; ++i) { |
|
1763 |
PRELOAD_COND(dest) |
|
1764 |
uint d = dest[i]; |
|
1765 |
#define MIX(mask) (qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask))) |
|
1766 |
d = (MIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK)); |
|
1767 |
#undef MIX |
|
1768 |
coverage.store(&dest[i], d); |
|
1769 |
} |
|
1770 |
} |
|
1771 |
||
1772 |
static void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint const_alpha) |
|
1773 |
{ |
|
1774 |
if (const_alpha == 255) |
|
1775 |
comp_func_solid_Plus_impl(dest, length, color, QFullCoverage()); |
|
1776 |
else |
|
1777 |
comp_func_solid_Plus_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
1778 |
} |
|
1779 |
||
1780 |
template <typename T> |
|
1781 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Plus_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
1782 |
{ |
|
1783 |
PRELOAD_INIT2(dest, src) |
|
1784 |
for (int i = 0; i < length; ++i) { |
|
1785 |
PRELOAD_COND2(dest, src) |
|
1786 |
uint d = dest[i]; |
|
1787 |
uint s = src[i]; |
|
1788 |
||
1789 |
#define MIX(mask) (qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask))) |
|
1790 |
d = (MIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK)); |
|
1791 |
#undef MIX |
|
1792 |
||
1793 |
coverage.store(&dest[i], d); |
|
1794 |
} |
|
1795 |
} |
|
1796 |
||
1797 |
static void QT_FASTCALL comp_func_Plus(uint *dest, const uint *src, int length, uint const_alpha) |
|
1798 |
{ |
|
1799 |
if (const_alpha == 255) |
|
1800 |
comp_func_Plus_impl(dest, src, length, QFullCoverage()); |
|
1801 |
else |
|
1802 |
comp_func_Plus_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
1803 |
} |
|
1804 |
||
1805 |
/* |
|
1806 |
Dca' = Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) |
|
1807 |
*/ |
|
1808 |
static inline int multiply_op(int dst, int src, int da, int sa) |
|
1809 |
{ |
|
1810 |
return qt_div_255(src * dst + src * (255 - da) + dst * (255 - sa)); |
|
1811 |
} |
|
1812 |
||
1813 |
template <typename T> |
|
1814 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(uint *dest, int length, uint color, const T &coverage) |
|
1815 |
{ |
|
1816 |
int sa = qAlpha(color); |
|
1817 |
int sr = qRed(color); |
|
1818 |
int sg = qGreen(color); |
|
1819 |
int sb = qBlue(color); |
|
1820 |
||
1821 |
PRELOAD_INIT(dest) |
|
1822 |
for (int i = 0; i < length; ++i) { |
|
1823 |
PRELOAD_COND(dest) |
|
1824 |
uint d = dest[i]; |
|
1825 |
int da = qAlpha(d); |
|
1826 |
||
1827 |
#define OP(a, b) multiply_op(a, b, da, sa) |
|
1828 |
int r = OP( qRed(d), sr); |
|
1829 |
int b = OP( qBlue(d), sb); |
|
1830 |
int g = OP(qGreen(d), sg); |
|
1831 |
int a = mix_alpha(da, sa); |
|
1832 |
#undef OP |
|
1833 |
||
1834 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
1835 |
} |
|
1836 |
} |
|
1837 |
||
1838 |
static void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha) |
|
1839 |
{ |
|
1840 |
if (const_alpha == 255) |
|
1841 |
comp_func_solid_Multiply_impl(dest, length, color, QFullCoverage()); |
|
1842 |
else |
|
1843 |
comp_func_solid_Multiply_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
1844 |
} |
|
1845 |
||
1846 |
template <typename T> |
|
1847 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Multiply_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
1848 |
{ |
|
1849 |
PRELOAD_INIT2(dest, src) |
|
1850 |
for (int i = 0; i < length; ++i) { |
|
1851 |
PRELOAD_COND2(dest, src) |
|
1852 |
uint d = dest[i]; |
|
1853 |
uint s = src[i]; |
|
1854 |
||
1855 |
int da = qAlpha(d); |
|
1856 |
int sa = qAlpha(s); |
|
1857 |
||
1858 |
#define OP(a, b) multiply_op(a, b, da, sa) |
|
1859 |
int r = OP( qRed(d), qRed(s)); |
|
1860 |
int b = OP( qBlue(d), qBlue(s)); |
|
1861 |
int g = OP(qGreen(d), qGreen(s)); |
|
1862 |
int a = mix_alpha(da, sa); |
|
1863 |
#undef OP |
|
1864 |
||
1865 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
1866 |
} |
|
1867 |
} |
|
1868 |
||
1869 |
static void QT_FASTCALL comp_func_Multiply(uint *dest, const uint *src, int length, uint const_alpha) |
|
1870 |
{ |
|
1871 |
if (const_alpha == 255) |
|
1872 |
comp_func_Multiply_impl(dest, src, length, QFullCoverage()); |
|
1873 |
else |
|
1874 |
comp_func_Multiply_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
1875 |
} |
|
1876 |
||
1877 |
/* |
|
1878 |
Dca' = (Sca.Da + Dca.Sa - Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
1879 |
= Sca + Dca - Sca.Dca |
|
1880 |
*/ |
|
1881 |
template <typename T> |
|
1882 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Screen_impl(uint *dest, int length, uint color, const T &coverage) |
|
1883 |
{ |
|
1884 |
int sa = qAlpha(color); |
|
1885 |
int sr = qRed(color); |
|
1886 |
int sg = qGreen(color); |
|
1887 |
int sb = qBlue(color); |
|
1888 |
||
1889 |
PRELOAD_INIT(dest) |
|
1890 |
for (int i = 0; i < length; ++i) { |
|
1891 |
PRELOAD_COND(dest) |
|
1892 |
uint d = dest[i]; |
|
1893 |
int da = qAlpha(d); |
|
1894 |
||
1895 |
#define OP(a, b) 255 - qt_div_255((255-a) * (255-b)) |
|
1896 |
int r = OP( qRed(d), sr); |
|
1897 |
int b = OP( qBlue(d), sb); |
|
1898 |
int g = OP(qGreen(d), sg); |
|
1899 |
int a = mix_alpha(da, sa); |
|
1900 |
#undef OP |
|
1901 |
||
1902 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
1903 |
} |
|
1904 |
} |
|
1905 |
||
1906 |
static void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha) |
|
1907 |
{ |
|
1908 |
if (const_alpha == 255) |
|
1909 |
comp_func_solid_Screen_impl(dest, length, color, QFullCoverage()); |
|
1910 |
else |
|
1911 |
comp_func_solid_Screen_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
1912 |
} |
|
1913 |
||
1914 |
template <typename T> |
|
1915 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Screen_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
1916 |
{ |
|
1917 |
PRELOAD_INIT2(dest, src) |
|
1918 |
for (int i = 0; i < length; ++i) { |
|
1919 |
PRELOAD_COND2(dest, src) |
|
1920 |
uint d = dest[i]; |
|
1921 |
uint s = src[i]; |
|
1922 |
||
1923 |
int da = qAlpha(d); |
|
1924 |
int sa = qAlpha(s); |
|
1925 |
||
1926 |
#define OP(a, b) 255 - (((255-a) * (255-b)) >> 8) |
|
1927 |
int r = OP( qRed(d), qRed(s)); |
|
1928 |
int b = OP( qBlue(d), qBlue(s)); |
|
1929 |
int g = OP(qGreen(d), qGreen(s)); |
|
1930 |
int a = mix_alpha(da, sa); |
|
1931 |
#undef OP |
|
1932 |
||
1933 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
1934 |
} |
|
1935 |
} |
|
1936 |
||
1937 |
static void QT_FASTCALL comp_func_Screen(uint *dest, const uint *src, int length, uint const_alpha) |
|
1938 |
{ |
|
1939 |
if (const_alpha == 255) |
|
1940 |
comp_func_Screen_impl(dest, src, length, QFullCoverage()); |
|
1941 |
else |
|
1942 |
comp_func_Screen_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
1943 |
} |
|
1944 |
||
1945 |
/* |
|
1946 |
if 2.Dca < Da |
|
1947 |
Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) |
|
1948 |
otherwise |
|
1949 |
Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
1950 |
*/ |
|
1951 |
static inline int overlay_op(int dst, int src, int da, int sa) |
|
1952 |
{ |
|
1953 |
const int temp = src * (255 - da) + dst * (255 - sa); |
|
1954 |
if (2 * dst < da) |
|
1955 |
return qt_div_255(2 * src * dst + temp); |
|
1956 |
else |
|
1957 |
return qt_div_255(sa * da - 2 * (da - dst) * (sa - src) + temp); |
|
1958 |
} |
|
1959 |
||
1960 |
template <typename T> |
|
1961 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(uint *dest, int length, uint color, const T &coverage) |
|
1962 |
{ |
|
1963 |
int sa = qAlpha(color); |
|
1964 |
int sr = qRed(color); |
|
1965 |
int sg = qGreen(color); |
|
1966 |
int sb = qBlue(color); |
|
1967 |
||
1968 |
PRELOAD_INIT(dest) |
|
1969 |
for (int i = 0; i < length; ++i) { |
|
1970 |
PRELOAD_COND(dest) |
|
1971 |
uint d = dest[i]; |
|
1972 |
int da = qAlpha(d); |
|
1973 |
||
1974 |
#define OP(a, b) overlay_op(a, b, da, sa) |
|
1975 |
int r = OP( qRed(d), sr); |
|
1976 |
int b = OP( qBlue(d), sb); |
|
1977 |
int g = OP(qGreen(d), sg); |
|
1978 |
int a = mix_alpha(da, sa); |
|
1979 |
#undef OP |
|
1980 |
||
1981 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
1982 |
} |
|
1983 |
} |
|
1984 |
||
1985 |
static void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha) |
|
1986 |
{ |
|
1987 |
if (const_alpha == 255) |
|
1988 |
comp_func_solid_Overlay_impl(dest, length, color, QFullCoverage()); |
|
1989 |
else |
|
1990 |
comp_func_solid_Overlay_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
1991 |
} |
|
1992 |
||
1993 |
template <typename T> |
|
1994 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Overlay_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
1995 |
{ |
|
1996 |
PRELOAD_INIT2(dest, src) |
|
1997 |
for (int i = 0; i < length; ++i) { |
|
1998 |
PRELOAD_COND2(dest, src) |
|
1999 |
uint d = dest[i]; |
|
2000 |
uint s = src[i]; |
|
2001 |
||
2002 |
int da = qAlpha(d); |
|
2003 |
int sa = qAlpha(s); |
|
2004 |
||
2005 |
#define OP(a, b) overlay_op(a, b, da, sa) |
|
2006 |
int r = OP( qRed(d), qRed(s)); |
|
2007 |
int b = OP( qBlue(d), qBlue(s)); |
|
2008 |
int g = OP(qGreen(d), qGreen(s)); |
|
2009 |
int a = mix_alpha(da, sa); |
|
2010 |
#undef OP |
|
2011 |
||
2012 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2013 |
} |
|
2014 |
} |
|
2015 |
||
2016 |
static void QT_FASTCALL comp_func_Overlay(uint *dest, const uint *src, int length, uint const_alpha) |
|
2017 |
{ |
|
2018 |
if (const_alpha == 255) |
|
2019 |
comp_func_Overlay_impl(dest, src, length, QFullCoverage()); |
|
2020 |
else |
|
2021 |
comp_func_Overlay_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2022 |
} |
|
2023 |
||
2024 |
/* |
|
2025 |
Dca' = min(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2026 |
Da' = Sa + Da - Sa.Da |
|
2027 |
*/ |
|
2028 |
static inline int darken_op(int dst, int src, int da, int sa) |
|
2029 |
{ |
|
2030 |
return qt_div_255(qMin(src * da, dst * sa) + src * (255 - da) + dst * (255 - sa)); |
|
2031 |
} |
|
2032 |
||
2033 |
template <typename T> |
|
2034 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(uint *dest, int length, uint color, const T &coverage) |
|
2035 |
{ |
|
2036 |
int sa = qAlpha(color); |
|
2037 |
int sr = qRed(color); |
|
2038 |
int sg = qGreen(color); |
|
2039 |
int sb = qBlue(color); |
|
2040 |
||
2041 |
PRELOAD_INIT(dest) |
|
2042 |
for (int i = 0; i < length; ++i) { |
|
2043 |
PRELOAD_COND(dest) |
|
2044 |
uint d = dest[i]; |
|
2045 |
int da = qAlpha(d); |
|
2046 |
||
2047 |
#define OP(a, b) darken_op(a, b, da, sa) |
|
2048 |
int r = OP( qRed(d), sr); |
|
2049 |
int b = OP( qBlue(d), sb); |
|
2050 |
int g = OP(qGreen(d), sg); |
|
2051 |
int a = mix_alpha(da, sa); |
|
2052 |
#undef OP |
|
2053 |
||
2054 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2055 |
} |
|
2056 |
} |
|
2057 |
||
2058 |
static void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha) |
|
2059 |
{ |
|
2060 |
if (const_alpha == 255) |
|
2061 |
comp_func_solid_Darken_impl(dest, length, color, QFullCoverage()); |
|
2062 |
else |
|
2063 |
comp_func_solid_Darken_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2064 |
} |
|
2065 |
||
2066 |
template <typename T> |
|
2067 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Darken_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2068 |
{ |
|
2069 |
PRELOAD_INIT2(dest, src) |
|
2070 |
for (int i = 0; i < length; ++i) { |
|
2071 |
PRELOAD_COND2(dest, src) |
|
2072 |
uint d = dest[i]; |
|
2073 |
uint s = src[i]; |
|
2074 |
||
2075 |
int da = qAlpha(d); |
|
2076 |
int sa = qAlpha(s); |
|
2077 |
||
2078 |
#define OP(a, b) darken_op(a, b, da, sa) |
|
2079 |
int r = OP( qRed(d), qRed(s)); |
|
2080 |
int b = OP( qBlue(d), qBlue(s)); |
|
2081 |
int g = OP(qGreen(d), qGreen(s)); |
|
2082 |
int a = mix_alpha(da, sa); |
|
2083 |
#undef OP |
|
2084 |
||
2085 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2086 |
} |
|
2087 |
} |
|
2088 |
||
2089 |
static void QT_FASTCALL comp_func_Darken(uint *dest, const uint *src, int length, uint const_alpha) |
|
2090 |
{ |
|
2091 |
if (const_alpha == 255) |
|
2092 |
comp_func_Darken_impl(dest, src, length, QFullCoverage()); |
|
2093 |
else |
|
2094 |
comp_func_Darken_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2095 |
} |
|
2096 |
||
2097 |
/* |
|
2098 |
Dca' = max(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2099 |
Da' = Sa + Da - Sa.Da |
|
2100 |
*/ |
|
2101 |
static inline int lighten_op(int dst, int src, int da, int sa) |
|
2102 |
{ |
|
2103 |
return qt_div_255(qMax(src * da, dst * sa) + src * (255 - da) + dst * (255 - sa)); |
|
2104 |
} |
|
2105 |
||
2106 |
template <typename T> |
|
2107 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(uint *dest, int length, uint color, const T &coverage) |
|
2108 |
{ |
|
2109 |
int sa = qAlpha(color); |
|
2110 |
int sr = qRed(color); |
|
2111 |
int sg = qGreen(color); |
|
2112 |
int sb = qBlue(color); |
|
2113 |
||
2114 |
PRELOAD_INIT(dest) |
|
2115 |
for (int i = 0; i < length; ++i) { |
|
2116 |
PRELOAD_COND(dest) |
|
2117 |
uint d = dest[i]; |
|
2118 |
int da = qAlpha(d); |
|
2119 |
||
2120 |
#define OP(a, b) lighten_op(a, b, da, sa) |
|
2121 |
int r = OP( qRed(d), sr); |
|
2122 |
int b = OP( qBlue(d), sb); |
|
2123 |
int g = OP(qGreen(d), sg); |
|
2124 |
int a = mix_alpha(da, sa); |
|
2125 |
#undef OP |
|
2126 |
||
2127 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2128 |
} |
|
2129 |
} |
|
2130 |
||
2131 |
static void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha) |
|
2132 |
{ |
|
2133 |
if (const_alpha == 255) |
|
2134 |
comp_func_solid_Lighten_impl(dest, length, color, QFullCoverage()); |
|
2135 |
else |
|
2136 |
comp_func_solid_Lighten_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2137 |
} |
|
2138 |
||
2139 |
template <typename T> |
|
2140 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Lighten_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2141 |
{ |
|
2142 |
PRELOAD_INIT2(dest, src) |
|
2143 |
for (int i = 0; i < length; ++i) { |
|
2144 |
PRELOAD_COND2(dest, src) |
|
2145 |
uint d = dest[i]; |
|
2146 |
uint s = src[i]; |
|
2147 |
||
2148 |
int da = qAlpha(d); |
|
2149 |
int sa = qAlpha(s); |
|
2150 |
||
2151 |
#define OP(a, b) lighten_op(a, b, da, sa) |
|
2152 |
int r = OP( qRed(d), qRed(s)); |
|
2153 |
int b = OP( qBlue(d), qBlue(s)); |
|
2154 |
int g = OP(qGreen(d), qGreen(s)); |
|
2155 |
int a = mix_alpha(da, sa); |
|
2156 |
#undef OP |
|
2157 |
||
2158 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2159 |
} |
|
2160 |
} |
|
2161 |
||
2162 |
static void QT_FASTCALL comp_func_Lighten(uint *dest, const uint *src, int length, uint const_alpha) |
|
2163 |
{ |
|
2164 |
if (const_alpha == 255) |
|
2165 |
comp_func_Lighten_impl(dest, src, length, QFullCoverage()); |
|
2166 |
else |
|
2167 |
comp_func_Lighten_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2168 |
} |
|
2169 |
||
2170 |
/* |
|
2171 |
if Sca.Da + Dca.Sa >= Sa.Da |
|
2172 |
Dca' = Sa.Da + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2173 |
otherwise |
|
2174 |
Dca' = Dca.Sa/(1-Sca/Sa) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2175 |
*/ |
|
2176 |
static inline int color_dodge_op(int dst, int src, int da, int sa) |
|
2177 |
{ |
|
2178 |
const int sa_da = sa * da; |
|
2179 |
const int dst_sa = dst * sa; |
|
2180 |
const int src_da = src * da; |
|
2181 |
||
2182 |
const int temp = src * (255 - da) + dst * (255 - sa); |
|
2183 |
if (src_da + dst_sa >= sa_da) |
|
2184 |
return qt_div_255(sa_da + temp); |
|
2185 |
else |
|
2186 |
return qt_div_255(255 * dst_sa / (255 - 255 * src / sa) + temp); |
|
2187 |
} |
|
2188 |
||
2189 |
template <typename T> |
|
2190 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(uint *dest, int length, uint color, const T &coverage) |
|
2191 |
{ |
|
2192 |
int sa = qAlpha(color); |
|
2193 |
int sr = qRed(color); |
|
2194 |
int sg = qGreen(color); |
|
2195 |
int sb = qBlue(color); |
|
2196 |
||
2197 |
PRELOAD_INIT(dest) |
|
2198 |
for (int i = 0; i < length; ++i) { |
|
2199 |
PRELOAD_COND(dest) |
|
2200 |
uint d = dest[i]; |
|
2201 |
int da = qAlpha(d); |
|
2202 |
||
2203 |
#define OP(a,b) color_dodge_op(a, b, da, sa) |
|
2204 |
int r = OP( qRed(d), sr); |
|
2205 |
int b = OP( qBlue(d), sb); |
|
2206 |
int g = OP(qGreen(d), sg); |
|
2207 |
int a = mix_alpha(da, sa); |
|
2208 |
#undef OP |
|
2209 |
||
2210 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2211 |
} |
|
2212 |
} |
|
2213 |
||
2214 |
static void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha) |
|
2215 |
{ |
|
2216 |
if (const_alpha == 255) |
|
2217 |
comp_func_solid_ColorDodge_impl(dest, length, color, QFullCoverage()); |
|
2218 |
else |
|
2219 |
comp_func_solid_ColorDodge_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2220 |
} |
|
2221 |
||
2222 |
template <typename T> |
|
2223 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorDodge_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2224 |
{ |
|
2225 |
PRELOAD_INIT2(dest, src) |
|
2226 |
for (int i = 0; i < length; ++i) { |
|
2227 |
PRELOAD_COND2(dest, src) |
|
2228 |
uint d = dest[i]; |
|
2229 |
uint s = src[i]; |
|
2230 |
||
2231 |
int da = qAlpha(d); |
|
2232 |
int sa = qAlpha(s); |
|
2233 |
||
2234 |
#define OP(a, b) color_dodge_op(a, b, da, sa) |
|
2235 |
int r = OP( qRed(d), qRed(s)); |
|
2236 |
int b = OP( qBlue(d), qBlue(s)); |
|
2237 |
int g = OP(qGreen(d), qGreen(s)); |
|
2238 |
int a = mix_alpha(da, sa); |
|
2239 |
#undef OP |
|
2240 |
||
2241 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2242 |
} |
|
2243 |
} |
|
2244 |
||
2245 |
static void QT_FASTCALL comp_func_ColorDodge(uint *dest, const uint *src, int length, uint const_alpha) |
|
2246 |
{ |
|
2247 |
if (const_alpha == 255) |
|
2248 |
comp_func_ColorDodge_impl(dest, src, length, QFullCoverage()); |
|
2249 |
else |
|
2250 |
comp_func_ColorDodge_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2251 |
} |
|
2252 |
||
2253 |
/* |
|
2254 |
if Sca.Da + Dca.Sa <= Sa.Da |
|
2255 |
Dca' = Sca.(1 - Da) + Dca.(1 - Sa) |
|
2256 |
otherwise |
|
2257 |
Dca' = Sa.(Sca.Da + Dca.Sa - Sa.Da)/Sca + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2258 |
*/ |
|
2259 |
static inline int color_burn_op(int dst, int src, int da, int sa) |
|
2260 |
{ |
|
2261 |
const int src_da = src * da; |
|
2262 |
const int dst_sa = dst * sa; |
|
2263 |
const int sa_da = sa * da; |
|
2264 |
||
2265 |
const int temp = src * (255 - da) + dst * (255 - sa); |
|
2266 |
||
2267 |
if (src == 0 || src_da + dst_sa <= sa_da) |
|
2268 |
return qt_div_255(temp); |
|
2269 |
return qt_div_255(sa * (src_da + dst_sa - sa_da) / src + temp); |
|
2270 |
} |
|
2271 |
||
2272 |
template <typename T> |
|
2273 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(uint *dest, int length, uint color, const T &coverage) |
|
2274 |
{ |
|
2275 |
int sa = qAlpha(color); |
|
2276 |
int sr = qRed(color); |
|
2277 |
int sg = qGreen(color); |
|
2278 |
int sb = qBlue(color); |
|
2279 |
||
2280 |
PRELOAD_INIT(dest) |
|
2281 |
for (int i = 0; i < length; ++i) { |
|
2282 |
PRELOAD_COND(dest) |
|
2283 |
uint d = dest[i]; |
|
2284 |
int da = qAlpha(d); |
|
2285 |
||
2286 |
#define OP(a, b) color_burn_op(a, b, da, sa) |
|
2287 |
int r = OP( qRed(d), sr); |
|
2288 |
int b = OP( qBlue(d), sb); |
|
2289 |
int g = OP(qGreen(d), sg); |
|
2290 |
int a = mix_alpha(da, sa); |
|
2291 |
#undef OP |
|
2292 |
||
2293 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2294 |
} |
|
2295 |
} |
|
2296 |
||
2297 |
static void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha) |
|
2298 |
{ |
|
2299 |
if (const_alpha == 255) |
|
2300 |
comp_func_solid_ColorBurn_impl(dest, length, color, QFullCoverage()); |
|
2301 |
else |
|
2302 |
comp_func_solid_ColorBurn_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2303 |
} |
|
2304 |
||
2305 |
template <typename T> |
|
2306 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorBurn_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2307 |
{ |
|
2308 |
PRELOAD_INIT2(dest, src) |
|
2309 |
for (int i = 0; i < length; ++i) { |
|
2310 |
PRELOAD_COND2(dest, src) |
|
2311 |
uint d = dest[i]; |
|
2312 |
uint s = src[i]; |
|
2313 |
||
2314 |
int da = qAlpha(d); |
|
2315 |
int sa = qAlpha(s); |
|
2316 |
||
2317 |
#define OP(a, b) color_burn_op(a, b, da, sa) |
|
2318 |
int r = OP( qRed(d), qRed(s)); |
|
2319 |
int b = OP( qBlue(d), qBlue(s)); |
|
2320 |
int g = OP(qGreen(d), qGreen(s)); |
|
2321 |
int a = mix_alpha(da, sa); |
|
2322 |
#undef OP |
|
2323 |
||
2324 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2325 |
} |
|
2326 |
} |
|
2327 |
||
2328 |
static void QT_FASTCALL comp_func_ColorBurn(uint *dest, const uint *src, int length, uint const_alpha) |
|
2329 |
{ |
|
2330 |
if (const_alpha == 255) |
|
2331 |
comp_func_ColorBurn_impl(dest, src, length, QFullCoverage()); |
|
2332 |
else |
|
2333 |
comp_func_ColorBurn_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2334 |
} |
|
2335 |
||
2336 |
/* |
|
2337 |
if 2.Sca < Sa |
|
2338 |
Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2339 |
otherwise |
|
2340 |
Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2341 |
*/ |
|
2342 |
static inline uint hardlight_op(int dst, int src, int da, int sa) |
|
2343 |
{ |
|
2344 |
const uint temp = src * (255 - da) + dst * (255 - sa); |
|
2345 |
||
2346 |
if (2 * src < sa) |
|
2347 |
return qt_div_255(2 * src * dst + temp); |
|
2348 |
else |
|
2349 |
return qt_div_255(sa * da - 2 * (da - dst) * (sa - src) + temp); |
|
2350 |
} |
|
2351 |
||
2352 |
template <typename T> |
|
2353 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(uint *dest, int length, uint color, const T &coverage) |
|
2354 |
{ |
|
2355 |
int sa = qAlpha(color); |
|
2356 |
int sr = qRed(color); |
|
2357 |
int sg = qGreen(color); |
|
2358 |
int sb = qBlue(color); |
|
2359 |
||
2360 |
PRELOAD_INIT(dest) |
|
2361 |
for (int i = 0; i < length; ++i) { |
|
2362 |
PRELOAD_COND(dest) |
|
2363 |
uint d = dest[i]; |
|
2364 |
int da = qAlpha(d); |
|
2365 |
||
2366 |
#define OP(a, b) hardlight_op(a, b, da, sa) |
|
2367 |
int r = OP( qRed(d), sr); |
|
2368 |
int b = OP( qBlue(d), sb); |
|
2369 |
int g = OP(qGreen(d), sg); |
|
2370 |
int a = mix_alpha(da, sa); |
|
2371 |
#undef OP |
|
2372 |
||
2373 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2374 |
} |
|
2375 |
} |
|
2376 |
||
2377 |
static void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha) |
|
2378 |
{ |
|
2379 |
if (const_alpha == 255) |
|
2380 |
comp_func_solid_HardLight_impl(dest, length, color, QFullCoverage()); |
|
2381 |
else |
|
2382 |
comp_func_solid_HardLight_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2383 |
} |
|
2384 |
||
2385 |
template <typename T> |
|
2386 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_HardLight_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2387 |
{ |
|
2388 |
PRELOAD_INIT2(dest, src) |
|
2389 |
for (int i = 0; i < length; ++i) { |
|
2390 |
PRELOAD_COND2(dest, src) |
|
2391 |
uint d = dest[i]; |
|
2392 |
uint s = src[i]; |
|
2393 |
||
2394 |
int da = qAlpha(d); |
|
2395 |
int sa = qAlpha(s); |
|
2396 |
||
2397 |
#define OP(a, b) hardlight_op(a, b, da, sa) |
|
2398 |
int r = OP( qRed(d), qRed(s)); |
|
2399 |
int b = OP( qBlue(d), qBlue(s)); |
|
2400 |
int g = OP(qGreen(d), qGreen(s)); |
|
2401 |
int a = mix_alpha(da, sa); |
|
2402 |
#undef OP |
|
2403 |
||
2404 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2405 |
} |
|
2406 |
} |
|
2407 |
||
2408 |
static void QT_FASTCALL comp_func_HardLight(uint *dest, const uint *src, int length, uint const_alpha) |
|
2409 |
{ |
|
2410 |
if (const_alpha == 255) |
|
2411 |
comp_func_HardLight_impl(dest, src, length, QFullCoverage()); |
|
2412 |
else |
|
2413 |
comp_func_HardLight_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2414 |
} |
|
2415 |
||
2416 |
/* |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2417 |
if 2.Sca <= Sa |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2418 |
Dca' = Dca.(Sa + (2.Sca - Sa).(1 - Dca/Da)) + Sca.(1 - Da) + Dca.(1 - Sa) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2419 |
otherwise if 2.Sca > Sa and 4.Dca <= Da |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2420 |
Dca' = Dca.Sa + Da.(2.Sca - Sa).(4.Dca/Da.(4.Dca/Da + 1).(Dca/Da - 1) + 7.Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2421 |
otherwise if 2.Sca > Sa and 4.Dca > Da |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2422 |
Dca' = Dca.Sa + Da.(2.Sca - Sa).((Dca/Da)^0.5 - Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa) |
0 | 2423 |
*/ |
2424 |
static inline int soft_light_op(int dst, int src, int da, int sa) |
|
2425 |
{ |
|
2426 |
const int src2 = src << 1; |
|
2427 |
const int dst_np = da != 0 ? (255 * dst) / da : 0; |
|
2428 |
const int temp = (src * (255 - da) + dst * (255 - sa)) * 255; |
|
2429 |
||
2430 |
if (src2 < sa) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2431 |
return (dst * (sa * 255 + (src2 - sa) * (255 - dst_np)) + temp) / 65025; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2432 |
else if (4 * dst <= da) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2433 |
return (dst * sa * 255 + da * (src2 - sa) * ((((16 * dst_np - 12 * 255) * dst_np + 3 * 65025) * dst_np) / 65025) + temp) / 65025; |
0 | 2434 |
else { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2435 |
# ifdef Q_CC_RVCT // needed to avoid compiler crash in RVCT 2.2 |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2436 |
return (dst * sa * 255 + da * (src2 - sa) * (qIntSqrtInt(dst_np * 255) - dst_np) + temp) / 65025; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2437 |
# else |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2438 |
return (dst * sa * 255 + da * (src2 - sa) * (int(sqrt(qreal(dst_np * 255))) - dst_np) + temp) / 65025; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2439 |
# endif |
0 | 2440 |
} |
2441 |
} |
|
2442 |
||
2443 |
template <typename T> |
|
2444 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage) |
|
2445 |
{ |
|
2446 |
int sa = qAlpha(color); |
|
2447 |
int sr = qRed(color); |
|
2448 |
int sg = qGreen(color); |
|
2449 |
int sb = qBlue(color); |
|
2450 |
||
2451 |
PRELOAD_INIT(dest) |
|
2452 |
for (int i = 0; i < length; ++i) { |
|
2453 |
PRELOAD_COND(dest) |
|
2454 |
uint d = dest[i]; |
|
2455 |
int da = qAlpha(d); |
|
2456 |
||
2457 |
#define OP(a, b) soft_light_op(a, b, da, sa) |
|
2458 |
int r = OP( qRed(d), sr); |
|
2459 |
int b = OP( qBlue(d), sb); |
|
2460 |
int g = OP(qGreen(d), sg); |
|
2461 |
int a = mix_alpha(da, sa); |
|
2462 |
#undef OP |
|
2463 |
||
2464 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2465 |
} |
|
2466 |
} |
|
2467 |
||
2468 |
static void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha) |
|
2469 |
{ |
|
2470 |
if (const_alpha == 255) |
|
2471 |
comp_func_solid_SoftLight_impl(dest, length, color, QFullCoverage()); |
|
2472 |
else |
|
2473 |
comp_func_solid_SoftLight_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2474 |
} |
|
2475 |
||
2476 |
template <typename T> |
|
2477 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_SoftLight_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2478 |
{ |
|
2479 |
PRELOAD_INIT2(dest, src) |
|
2480 |
for (int i = 0; i < length; ++i) { |
|
2481 |
PRELOAD_COND2(dest, src) |
|
2482 |
uint d = dest[i]; |
|
2483 |
uint s = src[i]; |
|
2484 |
||
2485 |
int da = qAlpha(d); |
|
2486 |
int sa = qAlpha(s); |
|
2487 |
||
2488 |
#define OP(a, b) soft_light_op(a, b, da, sa) |
|
2489 |
int r = OP( qRed(d), qRed(s)); |
|
2490 |
int b = OP( qBlue(d), qBlue(s)); |
|
2491 |
int g = OP(qGreen(d), qGreen(s)); |
|
2492 |
int a = mix_alpha(da, sa); |
|
2493 |
#undef OP |
|
2494 |
||
2495 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2496 |
} |
|
2497 |
} |
|
2498 |
||
2499 |
static void QT_FASTCALL comp_func_SoftLight(uint *dest, const uint *src, int length, uint const_alpha) |
|
2500 |
{ |
|
2501 |
if (const_alpha == 255) |
|
2502 |
comp_func_SoftLight_impl(dest, src, length, QFullCoverage()); |
|
2503 |
else |
|
2504 |
comp_func_SoftLight_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2505 |
} |
|
2506 |
||
2507 |
/* |
|
2508 |
Dca' = abs(Dca.Sa - Sca.Da) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2509 |
= Sca + Dca - 2.min(Sca.Da, Dca.Sa) |
|
2510 |
*/ |
|
2511 |
static inline int difference_op(int dst, int src, int da, int sa) |
|
2512 |
{ |
|
2513 |
return src + dst - qt_div_255(2 * qMin(src * da, dst * sa)); |
|
2514 |
} |
|
2515 |
||
2516 |
template <typename T> |
|
2517 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(uint *dest, int length, uint color, const T &coverage) |
|
2518 |
{ |
|
2519 |
int sa = qAlpha(color); |
|
2520 |
int sr = qRed(color); |
|
2521 |
int sg = qGreen(color); |
|
2522 |
int sb = qBlue(color); |
|
2523 |
||
2524 |
PRELOAD_INIT(dest) |
|
2525 |
for (int i = 0; i < length; ++i) { |
|
2526 |
PRELOAD_COND(dest) |
|
2527 |
uint d = dest[i]; |
|
2528 |
int da = qAlpha(d); |
|
2529 |
||
2530 |
#define OP(a, b) difference_op(a, b, da, sa) |
|
2531 |
int r = OP( qRed(d), sr); |
|
2532 |
int b = OP( qBlue(d), sb); |
|
2533 |
int g = OP(qGreen(d), sg); |
|
2534 |
int a = mix_alpha(da, sa); |
|
2535 |
#undef OP |
|
2536 |
||
2537 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2538 |
} |
|
2539 |
} |
|
2540 |
||
2541 |
static void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha) |
|
2542 |
{ |
|
2543 |
if (const_alpha == 255) |
|
2544 |
comp_func_solid_Difference_impl(dest, length, color, QFullCoverage()); |
|
2545 |
else |
|
2546 |
comp_func_solid_Difference_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2547 |
} |
|
2548 |
||
2549 |
template <typename T> |
|
2550 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Difference_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2551 |
{ |
|
2552 |
PRELOAD_INIT2(dest, src) |
|
2553 |
for (int i = 0; i < length; ++i) { |
|
2554 |
PRELOAD_COND2(dest, src) |
|
2555 |
uint d = dest[i]; |
|
2556 |
uint s = src[i]; |
|
2557 |
||
2558 |
int da = qAlpha(d); |
|
2559 |
int sa = qAlpha(s); |
|
2560 |
||
2561 |
#define OP(a, b) difference_op(a, b, da, sa) |
|
2562 |
int r = OP( qRed(d), qRed(s)); |
|
2563 |
int b = OP( qBlue(d), qBlue(s)); |
|
2564 |
int g = OP(qGreen(d), qGreen(s)); |
|
2565 |
int a = mix_alpha(da, sa); |
|
2566 |
#undef OP |
|
2567 |
||
2568 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2569 |
} |
|
2570 |
} |
|
2571 |
||
2572 |
static void QT_FASTCALL comp_func_Difference(uint *dest, const uint *src, int length, uint const_alpha) |
|
2573 |
{ |
|
2574 |
if (const_alpha == 255) |
|
2575 |
comp_func_Difference_impl(dest, src, length, QFullCoverage()); |
|
2576 |
else |
|
2577 |
comp_func_Difference_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2578 |
} |
|
2579 |
||
2580 |
/* |
|
2581 |
Dca' = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2582 |
*/ |
|
2583 |
template <typename T> |
|
2584 |
Q_STATIC_TEMPLATE_FUNCTION inline void QT_FASTCALL comp_func_solid_Exclusion_impl(uint *dest, int length, uint color, const T &coverage) |
|
2585 |
{ |
|
2586 |
int sa = qAlpha(color); |
|
2587 |
int sr = qRed(color); |
|
2588 |
int sg = qGreen(color); |
|
2589 |
int sb = qBlue(color); |
|
2590 |
||
2591 |
PRELOAD_INIT(dest) |
|
2592 |
for (int i = 0; i < length; ++i) { |
|
2593 |
PRELOAD_COND(dest) |
|
2594 |
uint d = dest[i]; |
|
2595 |
int da = qAlpha(d); |
|
2596 |
||
2597 |
#define OP(a, b) (a + b - qt_div_255(2*(a*b))) |
|
2598 |
int r = OP( qRed(d), sr); |
|
2599 |
int b = OP( qBlue(d), sb); |
|
2600 |
int g = OP(qGreen(d), sg); |
|
2601 |
int a = mix_alpha(da, sa); |
|
2602 |
#undef OP |
|
2603 |
||
2604 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2605 |
} |
|
2606 |
} |
|
2607 |
||
2608 |
static void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha) |
|
2609 |
{ |
|
2610 |
if (const_alpha == 255) |
|
2611 |
comp_func_solid_Exclusion_impl(dest, length, color, QFullCoverage()); |
|
2612 |
else |
|
2613 |
comp_func_solid_Exclusion_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2614 |
} |
|
2615 |
||
2616 |
template <typename T> |
|
2617 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Exclusion_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2618 |
{ |
|
2619 |
PRELOAD_INIT2(dest, src) |
|
2620 |
for (int i = 0; i < length; ++i) { |
|
2621 |
PRELOAD_COND2(dest, src) |
|
2622 |
uint d = dest[i]; |
|
2623 |
uint s = src[i]; |
|
2624 |
||
2625 |
int da = qAlpha(d); |
|
2626 |
int sa = qAlpha(s); |
|
2627 |
||
2628 |
#define OP(a, b) (a + b - ((a*b) >> 7)) |
|
2629 |
int r = OP( qRed(d), qRed(s)); |
|
2630 |
int b = OP( qBlue(d), qBlue(s)); |
|
2631 |
int g = OP(qGreen(d), qGreen(s)); |
|
2632 |
int a = mix_alpha(da, sa); |
|
2633 |
#undef OP |
|
2634 |
||
2635 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2636 |
} |
|
2637 |
} |
|
2638 |
||
2639 |
static void QT_FASTCALL comp_func_Exclusion(uint *dest, const uint *src, int length, uint const_alpha) |
|
2640 |
{ |
|
2641 |
if (const_alpha == 255) |
|
2642 |
comp_func_Exclusion_impl(dest, src, length, QFullCoverage()); |
|
2643 |
else |
|
2644 |
comp_func_Exclusion_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2645 |
} |
|
2646 |
||
2647 |
#if defined(Q_CC_RVCT) |
|
2648 |
// Restore pragma state from previous #pragma arm |
|
2649 |
# pragma pop |
|
2650 |
#endif |
|
2651 |
||
2652 |
static void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest, |
|
2653 |
int length, |
|
2654 |
uint color, |
|
2655 |
uint const_alpha) |
|
2656 |
{ |
|
2657 |
Q_UNUSED(const_alpha); |
|
2658 |
while (length--) |
|
2659 |
*dest++ |= color; |
|
2660 |
} |
|
2661 |
||
2662 |
static void QT_FASTCALL rasterop_SourceOrDestination(uint *dest, |
|
2663 |
const uint *src, |
|
2664 |
int length, |
|
2665 |
uint const_alpha) |
|
2666 |
{ |
|
2667 |
Q_UNUSED(const_alpha); |
|
2668 |
while (length--) |
|
2669 |
*dest++ |= *src++; |
|
2670 |
} |
|
2671 |
||
2672 |
static void QT_FASTCALL rasterop_solid_SourceAndDestination(uint *dest, |
|
2673 |
int length, |
|
2674 |
uint color, |
|
2675 |
uint const_alpha) |
|
2676 |
{ |
|
2677 |
Q_UNUSED(const_alpha); |
|
2678 |
color |= 0xff000000; |
|
2679 |
while (length--) |
|
2680 |
*dest++ &= color; |
|
2681 |
} |
|
2682 |
||
2683 |
static void QT_FASTCALL rasterop_SourceAndDestination(uint *dest, |
|
2684 |
const uint *src, |
|
2685 |
int length, |
|
2686 |
uint const_alpha) |
|
2687 |
{ |
|
2688 |
Q_UNUSED(const_alpha); |
|
2689 |
while (length--) { |
|
2690 |
*dest = (*src & *dest) | 0xff000000; |
|
2691 |
++dest; ++src; |
|
2692 |
} |
|
2693 |
} |
|
2694 |
||
2695 |
static void QT_FASTCALL rasterop_solid_SourceXorDestination(uint *dest, |
|
2696 |
int length, |
|
2697 |
uint color, |
|
2698 |
uint const_alpha) |
|
2699 |
{ |
|
2700 |
Q_UNUSED(const_alpha); |
|
2701 |
color &= 0x00ffffff; |
|
2702 |
while (length--) |
|
2703 |
*dest++ ^= color; |
|
2704 |
} |
|
2705 |
||
2706 |
static void QT_FASTCALL rasterop_SourceXorDestination(uint *dest, |
|
2707 |
const uint *src, |
|
2708 |
int length, |
|
2709 |
uint const_alpha) |
|
2710 |
{ |
|
2711 |
Q_UNUSED(const_alpha); |
|
2712 |
while (length--) { |
|
2713 |
*dest = (*src ^ *dest) | 0xff000000; |
|
2714 |
++dest; ++src; |
|
2715 |
} |
|
2716 |
} |
|
2717 |
||
2718 |
static void QT_FASTCALL rasterop_solid_NotSourceAndNotDestination(uint *dest, |
|
2719 |
int length, |
|
2720 |
uint color, |
|
2721 |
uint const_alpha) |
|
2722 |
{ |
|
2723 |
Q_UNUSED(const_alpha); |
|
2724 |
color = ~color; |
|
2725 |
while (length--) { |
|
2726 |
*dest = (color & ~(*dest)) | 0xff000000; |
|
2727 |
++dest; |
|
2728 |
} |
|
2729 |
} |
|
2730 |
||
2731 |
static void QT_FASTCALL rasterop_NotSourceAndNotDestination(uint *dest, |
|
2732 |
const uint *src, |
|
2733 |
int length, |
|
2734 |
uint const_alpha) |
|
2735 |
{ |
|
2736 |
Q_UNUSED(const_alpha); |
|
2737 |
while (length--) { |
|
2738 |
*dest = (~(*src) & ~(*dest)) | 0xff000000; |
|
2739 |
++dest; ++src; |
|
2740 |
} |
|
2741 |
} |
|
2742 |
||
2743 |
static void QT_FASTCALL rasterop_solid_NotSourceOrNotDestination(uint *dest, |
|
2744 |
int length, |
|
2745 |
uint color, |
|
2746 |
uint const_alpha) |
|
2747 |
{ |
|
2748 |
Q_UNUSED(const_alpha); |
|
2749 |
color = ~color | 0xff000000; |
|
2750 |
while (length--) { |
|
2751 |
*dest = color | ~(*dest); |
|
2752 |
++dest; |
|
2753 |
} |
|
2754 |
} |
|
2755 |
||
2756 |
static void QT_FASTCALL rasterop_NotSourceOrNotDestination(uint *dest, |
|
2757 |
const uint *src, |
|
2758 |
int length, |
|
2759 |
uint const_alpha) |
|
2760 |
{ |
|
2761 |
Q_UNUSED(const_alpha); |
|
2762 |
while (length--) { |
|
2763 |
*dest = ~(*src) | ~(*dest) | 0xff000000; |
|
2764 |
++dest; ++src; |
|
2765 |
} |
|
2766 |
} |
|
2767 |
||
2768 |
static void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest, |
|
2769 |
int length, |
|
2770 |
uint color, |
|
2771 |
uint const_alpha) |
|
2772 |
{ |
|
2773 |
Q_UNUSED(const_alpha); |
|
2774 |
color = ~color & 0x00ffffff; |
|
2775 |
while (length--) { |
|
2776 |
*dest = color ^ (*dest); |
|
2777 |
++dest; |
|
2778 |
} |
|
2779 |
} |
|
2780 |
||
2781 |
static void QT_FASTCALL rasterop_NotSourceXorDestination(uint *dest, |
|
2782 |
const uint *src, |
|
2783 |
int length, |
|
2784 |
uint const_alpha) |
|
2785 |
{ |
|
2786 |
Q_UNUSED(const_alpha); |
|
2787 |
while (length--) { |
|
2788 |
*dest = ((~(*src)) ^ (*dest)) | 0xff000000; |
|
2789 |
++dest; ++src; |
|
2790 |
} |
|
2791 |
} |
|
2792 |
||
2793 |
static void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length, |
|
2794 |
uint color, uint const_alpha) |
|
2795 |
{ |
|
2796 |
Q_UNUSED(const_alpha); |
|
2797 |
qt_memfill(dest, ~color | 0xff000000, length); |
|
2798 |
} |
|
2799 |
||
2800 |
static void QT_FASTCALL rasterop_NotSource(uint *dest, const uint *src, |
|
2801 |
int length, uint const_alpha) |
|
2802 |
{ |
|
2803 |
Q_UNUSED(const_alpha); |
|
2804 |
while (length--) |
|
2805 |
*dest++ = ~(*src++) | 0xff000000; |
|
2806 |
} |
|
2807 |
||
2808 |
static void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest, |
|
2809 |
int length, |
|
2810 |
uint color, |
|
2811 |
uint const_alpha) |
|
2812 |
{ |
|
2813 |
Q_UNUSED(const_alpha); |
|
2814 |
color = ~color | 0xff000000; |
|
2815 |
while (length--) { |
|
2816 |
*dest = color & *dest; |
|
2817 |
++dest; |
|
2818 |
} |
|
2819 |
} |
|
2820 |
||
2821 |
static void QT_FASTCALL rasterop_NotSourceAndDestination(uint *dest, |
|
2822 |
const uint *src, |
|
2823 |
int length, |
|
2824 |
uint const_alpha) |
|
2825 |
{ |
|
2826 |
Q_UNUSED(const_alpha); |
|
2827 |
while (length--) { |
|
2828 |
*dest = (~(*src) & *dest) | 0xff000000; |
|
2829 |
++dest; ++src; |
|
2830 |
} |
|
2831 |
} |
|
2832 |
||
2833 |
static void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest, |
|
2834 |
int length, |
|
2835 |
uint color, |
|
2836 |
uint const_alpha) |
|
2837 |
{ |
|
2838 |
Q_UNUSED(const_alpha); |
|
2839 |
while (length--) { |
|
2840 |
*dest = (color & ~(*dest)) | 0xff000000; |
|
2841 |
++dest; |
|
2842 |
} |
|
2843 |
} |
|
2844 |
||
2845 |
static void QT_FASTCALL rasterop_SourceAndNotDestination(uint *dest, |
|
2846 |
const uint *src, |
|
2847 |
int length, |
|
2848 |
uint const_alpha) |
|
2849 |
{ |
|
2850 |
Q_UNUSED(const_alpha); |
|
2851 |
while (length--) { |
|
2852 |
*dest = (*src & ~(*dest)) | 0xff000000; |
|
2853 |
++dest; ++src; |
|
2854 |
} |
|
2855 |
} |
|
2856 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2857 |
static CompositionFunctionSolid functionForModeSolid_C[] = { |
0 | 2858 |
comp_func_solid_SourceOver, |
2859 |
comp_func_solid_DestinationOver, |
|
2860 |
comp_func_solid_Clear, |
|
2861 |
comp_func_solid_Source, |
|
2862 |
comp_func_solid_Destination, |
|
2863 |
comp_func_solid_SourceIn, |
|
2864 |
comp_func_solid_DestinationIn, |
|
2865 |
comp_func_solid_SourceOut, |
|
2866 |
comp_func_solid_DestinationOut, |
|
2867 |
comp_func_solid_SourceAtop, |
|
2868 |
comp_func_solid_DestinationAtop, |
|
2869 |
comp_func_solid_XOR, |
|
2870 |
comp_func_solid_Plus, |
|
2871 |
comp_func_solid_Multiply, |
|
2872 |
comp_func_solid_Screen, |
|
2873 |
comp_func_solid_Overlay, |
|
2874 |
comp_func_solid_Darken, |
|
2875 |
comp_func_solid_Lighten, |
|
2876 |
comp_func_solid_ColorDodge, |
|
2877 |
comp_func_solid_ColorBurn, |
|
2878 |
comp_func_solid_HardLight, |
|
2879 |
comp_func_solid_SoftLight, |
|
2880 |
comp_func_solid_Difference, |
|
2881 |
comp_func_solid_Exclusion, |
|
2882 |
rasterop_solid_SourceOrDestination, |
|
2883 |
rasterop_solid_SourceAndDestination, |
|
2884 |
rasterop_solid_SourceXorDestination, |
|
2885 |
rasterop_solid_NotSourceAndNotDestination, |
|
2886 |
rasterop_solid_NotSourceOrNotDestination, |
|
2887 |
rasterop_solid_NotSourceXorDestination, |
|
2888 |
rasterop_solid_NotSource, |
|
2889 |
rasterop_solid_NotSourceAndDestination, |
|
2890 |
rasterop_solid_SourceAndNotDestination |
|
2891 |
}; |
|
2892 |
||
2893 |
static const CompositionFunctionSolid *functionForModeSolid = functionForModeSolid_C; |
|
2894 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2895 |
static CompositionFunction functionForMode_C[] = { |
0 | 2896 |
comp_func_SourceOver, |
2897 |
comp_func_DestinationOver, |
|
2898 |
comp_func_Clear, |
|
2899 |
comp_func_Source, |
|
2900 |
comp_func_Destination, |
|
2901 |
comp_func_SourceIn, |
|
2902 |
comp_func_DestinationIn, |
|
2903 |
comp_func_SourceOut, |
|
2904 |
comp_func_DestinationOut, |
|
2905 |
comp_func_SourceAtop, |
|
2906 |
comp_func_DestinationAtop, |
|
2907 |
comp_func_XOR, |
|
2908 |
comp_func_Plus, |
|
2909 |
comp_func_Multiply, |
|
2910 |
comp_func_Screen, |
|
2911 |
comp_func_Overlay, |
|
2912 |
comp_func_Darken, |
|
2913 |
comp_func_Lighten, |
|
2914 |
comp_func_ColorDodge, |
|
2915 |
comp_func_ColorBurn, |
|
2916 |
comp_func_HardLight, |
|
2917 |
comp_func_SoftLight, |
|
2918 |
comp_func_Difference, |
|
2919 |
comp_func_Exclusion, |
|
2920 |
rasterop_SourceOrDestination, |
|
2921 |
rasterop_SourceAndDestination, |
|
2922 |
rasterop_SourceXorDestination, |
|
2923 |
rasterop_NotSourceAndNotDestination, |
|
2924 |
rasterop_NotSourceOrNotDestination, |
|
2925 |
rasterop_NotSourceXorDestination, |
|
2926 |
rasterop_NotSource, |
|
2927 |
rasterop_NotSourceAndDestination, |
|
2928 |
rasterop_SourceAndNotDestination |
|
2929 |
}; |
|
2930 |
||
2931 |
static const CompositionFunction *functionForMode = functionForMode_C; |
|
2932 |
||
2933 |
static TextureBlendType getBlendType(const QSpanData *data) |
|
2934 |
{ |
|
2935 |
TextureBlendType ft; |
|
2936 |
if (data->txop <= QTransform::TxTranslate) |
|
2937 |
if (data->texture.type == QTextureData::Tiled) |
|
2938 |
ft = BlendTiled; |
|
2939 |
else |
|
2940 |
ft = BlendUntransformed; |
|
2941 |
else if (data->bilinear) |
|
2942 |
if (data->texture.type == QTextureData::Tiled) |
|
2943 |
ft = BlendTransformedBilinearTiled; |
|
2944 |
else |
|
2945 |
ft = BlendTransformedBilinear; |
|
2946 |
else |
|
2947 |
if (data->texture.type == QTextureData::Tiled) |
|
2948 |
ft = BlendTransformedTiled; |
|
2949 |
else |
|
2950 |
ft = BlendTransformed; |
|
2951 |
return ft; |
|
2952 |
} |
|
2953 |
||
2954 |
static inline Operator getOperator(const QSpanData *data, const QSpan *spans, int spanCount) |
|
2955 |
{ |
|
2956 |
Operator op; |
|
2957 |
bool solidSource = false; |
|
2958 |
||
2959 |
switch(data->type) { |
|
2960 |
case QSpanData::Solid: |
|
2961 |
solidSource = (qAlpha(data->solid.color) == 255); |
|
2962 |
break; |
|
2963 |
case QSpanData::LinearGradient: |
|
2964 |
solidSource = !data->gradient.alphaColor; |
|
2965 |
getLinearGradientValues(&op.linear, data); |
|
2966 |
op.src_fetch = fetchLinearGradient; |
|
2967 |
break; |
|
2968 |
case QSpanData::RadialGradient: |
|
2969 |
solidSource = !data->gradient.alphaColor; |
|
2970 |
getRadialGradientValues(&op.radial, data); |
|
2971 |
op.src_fetch = fetchRadialGradient; |
|
2972 |
break; |
|
2973 |
case QSpanData::ConicalGradient: |
|
2974 |
solidSource = !data->gradient.alphaColor; |
|
2975 |
op.src_fetch = fetchConicalGradient; |
|
2976 |
break; |
|
2977 |
case QSpanData::Texture: |
|
2978 |
op.src_fetch = sourceFetch[getBlendType(data)][data->texture.format]; |
|
2979 |
solidSource = !data->texture.hasAlpha; |
|
2980 |
default: |
|
2981 |
break; |
|
2982 |
} |
|
2983 |
||
2984 |
op.mode = data->rasterBuffer->compositionMode; |
|
2985 |
if (op.mode == QPainter::CompositionMode_SourceOver && solidSource) |
|
2986 |
op.mode = QPainter::CompositionMode_Source; |
|
2987 |
||
2988 |
op.dest_fetch = destFetchProc[data->rasterBuffer->format]; |
|
2989 |
if (op.mode == QPainter::CompositionMode_Source) { |
|
2990 |
switch (data->rasterBuffer->format) { |
|
2991 |
case QImage::Format_RGB32: |
|
2992 |
case QImage::Format_ARGB32_Premultiplied: |
|
2993 |
// don't clear dest_fetch as it sets up the pointer correctly to save one copy |
|
2994 |
break; |
|
2995 |
default: { |
|
2996 |
const QSpan *lastSpan = spans + spanCount; |
|
2997 |
bool alphaSpans = false; |
|
2998 |
while (spans < lastSpan) { |
|
2999 |
if (spans->coverage != 255) { |
|
3000 |
alphaSpans = true; |
|
3001 |
break; |
|
3002 |
} |
|
3003 |
++spans; |
|
3004 |
} |
|
3005 |
if (!alphaSpans) |
|
3006 |
op.dest_fetch = 0; |
|
3007 |
} |
|
3008 |
} |
|
3009 |
} |
|
3010 |
||
3011 |
op.dest_store = destStoreProc[data->rasterBuffer->format]; |
|
3012 |
||
3013 |
op.funcSolid = functionForModeSolid[op.mode]; |
|
3014 |
op.func = functionForMode[op.mode]; |
|
3015 |
||
3016 |
return op; |
|
3017 |
} |
|
3018 |
||
3019 |
||
3020 |
||
3021 |
// -------------------- blend methods --------------------- |
|
3022 |
||
3023 |
enum SpanMethod { |
|
3024 |
RegularSpans, |
|
3025 |
CallbackSpans |
|
3026 |
}; |
|
3027 |
||
3028 |
#if !defined(Q_CC_SUN) |
|
3029 |
static |
|
3030 |
#endif |
|
3031 |
void drawBufferSpan(QSpanData *data, const uint *buffer, int bufsize, |
|
3032 |
int x, int y, int length, uint const_alpha) |
|
3033 |
{ |
|
3034 |
#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS) |
|
3035 |
data->rasterEngine->drawBufferSpan(buffer, bufsize, x, y, length, const_alpha); |
|
3036 |
#else |
|
3037 |
Q_UNUSED(data); |
|
3038 |
Q_UNUSED(buffer); |
|
3039 |
Q_UNUSED(bufsize); |
|
3040 |
Q_UNUSED(x); |
|
3041 |
Q_UNUSED(y); |
|
3042 |
Q_UNUSED(length); |
|
3043 |
Q_UNUSED(const_alpha); |
|
3044 |
#endif |
|
3045 |
} |
|
3046 |
||
3047 |
#if !defined(Q_CC_SUN) |
|
3048 |
static |
|
3049 |
#endif |
|
3050 |
void blend_color_generic(int count, const QSpan *spans, void *userData) |
|
3051 |
{ |
|
3052 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3053 |
uint buffer[buffer_size]; |
|
3054 |
Operator op = getOperator(data, spans, count); |
|
3055 |
||
3056 |
while (count--) { |
|
3057 |
int x = spans->x; |
|
3058 |
int length = spans->len; |
|
3059 |
while (length) { |
|
3060 |
int l = qMin(buffer_size, length); |
|
3061 |
uint *dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer; |
|
3062 |
op.funcSolid(dest, l, data->solid.color, spans->coverage); |
|
3063 |
if (op.dest_store) |
|
3064 |
op.dest_store(data->rasterBuffer, x, spans->y, dest, l); |
|
3065 |
length -= l; |
|
3066 |
x += l; |
|
3067 |
} |
|
3068 |
++spans; |
|
3069 |
} |
|
3070 |
} |
|
3071 |
||
3072 |
#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS) |
|
3073 |
static void blend_color_generic_callback(int count, const QSpan *spans, void *userData) |
|
3074 |
{ |
|
3075 |
// ### Falcon |
|
3076 |
Q_UNUSED(count); |
|
3077 |
Q_UNUSED(spans); |
|
3078 |
Q_UNUSED(userData); |
|
3079 |
// QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
3080 |
// data->rasterEngine->drawColorSpans(spans, count, data->solid.color); |
|
3081 |
} |
|
3082 |
#endif // QT_NO_RASTERCALLBACKS |
|
3083 |
||
3084 |
static void blend_color_argb(int count, const QSpan *spans, void *userData) |
|
3085 |
{ |
|
3086 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3087 |
||
3088 |
Operator op = getOperator(data, spans, count); |
|
3089 |
||
3090 |
if (op.mode == QPainter::CompositionMode_Source) { |
|
3091 |
// inline for performance |
|
3092 |
while (count--) { |
|
3093 |
uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
3094 |
if (spans->coverage == 255) { |
|
3095 |
QT_MEMFILL_UINT(target, spans->len, data->solid.color); |
|
3096 |
} else { |
|
3097 |
uint c = BYTE_MUL(data->solid.color, spans->coverage); |
|
3098 |
int ialpha = 255 - spans->coverage; |
|
3099 |
for (int i = 0; i < spans->len; ++i) |
|
3100 |
target[i] = c + BYTE_MUL(target[i], ialpha); |
|
3101 |
} |
|
3102 |
++spans; |
|
3103 |
} |
|
3104 |
return; |
|
3105 |
} |
|
3106 |
||
3107 |
while (count--) { |
|
3108 |
uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
3109 |
op.funcSolid(target, spans->len, data->solid.color, spans->coverage); |
|
3110 |
++spans; |
|
3111 |
} |
|
3112 |
} |
|
3113 |
||
3114 |
template <class T> |
|
3115 |
Q_STATIC_TEMPLATE_FUNCTION void blendColor(int count, const QSpan *spans, void *userData) |
|
3116 |
{ |
|
3117 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3118 |
Operator op = getOperator(data, spans, count); |
|
3119 |
||
3120 |
if (op.mode == QPainter::CompositionMode_Source) { |
|
3121 |
const T c = qt_colorConvert<T, quint32p>(quint32p::fromRawData(data->solid.color), 0); |
|
3122 |
while (count--) { |
|
3123 |
T *target = ((T*)data->rasterBuffer->scanLine(spans->y)) |
|
3124 |
+ spans->x; |
|
3125 |
if (spans->coverage == 255) { |
|
3126 |
qt_memfill(target, c, spans->len); |
|
3127 |
} else { |
|
3128 |
const quint8 alpha = T::alpha(spans->coverage); |
|
3129 |
const T color = c.byte_mul(alpha); |
|
3130 |
const int ialpha = T::ialpha(spans->coverage); |
|
3131 |
const T *end = target + spans->len; |
|
3132 |
while (target < end) { |
|
3133 |
*target = color + target->byte_mul(ialpha); |
|
3134 |
++target; |
|
3135 |
} |
|
3136 |
} |
|
3137 |
++spans; |
|
3138 |
} |
|
3139 |
return; |
|
3140 |
} |
|
3141 |
||
3142 |
if (op.mode == QPainter::CompositionMode_SourceOver) { |
|
3143 |
while (count--) { |
|
3144 |
const quint32 color = BYTE_MUL(data->solid.color, spans->coverage); |
|
3145 |
const T c = qt_colorConvert<T, quint32p>(quint32p::fromRawData(color), 0); |
|
3146 |
const quint8 ialpha = T::alpha(qAlpha(~color)); |
|
3147 |
T *target = ((T*)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
3148 |
const T *end = target + spans->len; |
|
3149 |
while (target != end) { |
|
3150 |
*target = c + target->byte_mul(ialpha); |
|
3151 |
++target; |
|
3152 |
} |
|
3153 |
++spans; |
|
3154 |
} |
|
3155 |
return; |
|
3156 |
} |
|
3157 |
||
3158 |
blend_color_generic(count, spans, userData); |
|
3159 |
} |
|
3160 |
||
3161 |
#define SPANFUNC_POINTER_BLENDCOLOR(DST) blendColor<DST> |
|
3162 |
||
3163 |
static void blend_color_rgb16(int count, const QSpan *spans, void *userData) |
|
3164 |
{ |
|
3165 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3166 |
||
3167 |
/* |
|
3168 |
We duplicate a little logic from getOperator() and calculate the |
|
3169 |
composition mode directly. This allows blend_color_rgb16 to be used |
|
3170 |
from qt_gradient_quint16 with minimal overhead. |
|
3171 |
*/ |
|
3172 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
3173 |
if (mode == QPainter::CompositionMode_SourceOver && |
|
3174 |
qAlpha(data->solid.color) == 255) |
|
3175 |
mode = QPainter::CompositionMode_Source; |
|
3176 |
||
3177 |
if (mode == QPainter::CompositionMode_Source) { |
|
3178 |
// inline for performance |
|
3179 |
ushort c = qConvertRgb32To16(data->solid.color); |
|
3180 |
while (count--) { |
|
3181 |
ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
3182 |
if (spans->coverage == 255) { |
|
3183 |
QT_MEMFILL_USHORT(target, spans->len, c); |
|
3184 |
} else { |
|
3185 |
ushort color = BYTE_MUL_RGB16(c, spans->coverage); |
|
3186 |
int ialpha = 255 - spans->coverage; |
|
3187 |
const ushort *end = target + spans->len; |
|
3188 |
while (target < end) { |
|
3189 |
*target = color + BYTE_MUL_RGB16(*target, ialpha); |
|
3190 |
++target; |
|
3191 |
} |
|
3192 |
} |
|
3193 |
++spans; |
|
3194 |
} |
|
3195 |
return; |
|
3196 |
} |
|
3197 |
||
3198 |
if (mode == QPainter::CompositionMode_SourceOver) { |
|
3199 |
while (count--) { |
|
3200 |
uint color = BYTE_MUL(data->solid.color, spans->coverage); |
|
3201 |
int ialpha = qAlpha(~color); |
|
3202 |
ushort c = qConvertRgb32To16(color); |
|
3203 |
ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
3204 |
int len = spans->len; |
|
3205 |
bool pre = (((quintptr)target) & 0x3) != 0; |
|
3206 |
bool post = false; |
|
3207 |
if (pre) { |
|
3208 |
// skip to word boundary |
|
3209 |
*target = c + BYTE_MUL_RGB16(*target, ialpha); |
|
3210 |
++target; |
|
3211 |
--len; |
|
3212 |
} |
|
3213 |
if (len & 0x1) { |
|
3214 |
post = true; |
|
3215 |
--len; |
|
3216 |
} |
|
3217 |
uint *target32 = (uint*)target; |
|
3218 |
uint c32 = c | (c<<16); |
|
3219 |
len >>= 1; |
|
3220 |
uint salpha = (ialpha+1) >> 3; // calculate here rather than in loop |
|
3221 |
while (len--) { |
|
3222 |
// blend full words |
|
3223 |
*target32 = c32 + BYTE_MUL_RGB16_32(*target32, salpha); |
|
3224 |
++target32; |
|
3225 |
target += 2; |
|
3226 |
} |
|
3227 |
if (post) { |
|
3228 |
// one last pixel beyond a full word |
|
3229 |
*target = c + BYTE_MUL_RGB16(*target, ialpha); |
|
3230 |
} |
|
3231 |
++spans; |
|
3232 |
} |
|
3233 |
return; |
|
3234 |
} |
|
3235 |
||
3236 |
blend_color_generic(count, spans, userData); |
|
3237 |
} |
|
3238 |
||
3239 |
template <typename T> |
|
3240 |
void handleSpans(int count, const QSpan *spans, const QSpanData *data, T &handler) |
|
3241 |
{ |
|
3242 |
uint const_alpha = 256; |
|
3243 |
if (data->type == QSpanData::Texture) |
|
3244 |
const_alpha = data->texture.const_alpha; |
|
3245 |
||
3246 |
int coverage = 0; |
|
3247 |
while (count) { |
|
3248 |
int x = spans->x; |
|
3249 |
const int y = spans->y; |
|
3250 |
int right = x + spans->len; |
|
3251 |
||
3252 |
// compute length of adjacent spans |
|
3253 |
for (int i = 1; i < count && spans[i].y == y && spans[i].x == right; ++i) |
|
3254 |
right += spans[i].len; |
|
3255 |
int length = right - x; |
|
3256 |
||
3257 |
while (length) { |
|
3258 |
int l = qMin(buffer_size, length); |
|
3259 |
length -= l; |
|
3260 |
||
3261 |
int process_length = l; |
|
3262 |
int process_x = x; |
|
3263 |
||
3264 |
const uint *src = handler.fetch(process_x, y, process_length); |
|
3265 |
int offset = 0; |
|
3266 |
while (l > 0) { |
|
3267 |
if (x == spans->x) // new span? |
|
3268 |
coverage = (spans->coverage * const_alpha) >> 8; |
|
3269 |
||
3270 |
int right = spans->x + spans->len; |
|
3271 |
int len = qMin(l, right - x); |
|
3272 |
||
3273 |
handler.process(x, y, len, coverage, src, offset); |
|
3274 |
||
3275 |
l -= len; |
|
3276 |
x += len; |
|
3277 |
offset += len; |
|
3278 |
||
3279 |
if (x == right) { // done with current span? |
|
3280 |
++spans; |
|
3281 |
--count; |
|
3282 |
} |
|
3283 |
} |
|
3284 |
handler.store(process_x, y, process_length); |
|
3285 |
} |
|
3286 |
} |
|
3287 |
} |
|
3288 |
||
3289 |
struct QBlendBase |
|
3290 |
{ |
|
3291 |
QBlendBase(QSpanData *d, Operator o) |
|
3292 |
: data(d) |
|
3293 |
, op(o) |
|
3294 |
, dest(0) |
|
3295 |
{ |
|
3296 |
} |
|
3297 |
||
3298 |
QSpanData *data; |
|
3299 |
Operator op; |
|
3300 |
||
3301 |
uint *dest; |
|
3302 |
||
3303 |
uint buffer[buffer_size]; |
|
3304 |
uint src_buffer[buffer_size]; |
|
3305 |
}; |
|
3306 |
||
3307 |
template <SpanMethod spanMethod> |
|
3308 |
class BlendSrcGeneric : public QBlendBase |
|
3309 |
{ |
|
3310 |
public: |
|
3311 |
BlendSrcGeneric(QSpanData *d, Operator o) |
|
3312 |
: QBlendBase(d, o) |
|
3313 |
{ |
|
3314 |
} |
|
3315 |
||
3316 |
const uint *fetch(int x, int y, int len) |
|
3317 |
{ |
|
3318 |
if (spanMethod == RegularSpans) |
|
3319 |
dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, y, len) : buffer; |
|
3320 |
||
3321 |
return op.src_fetch(src_buffer, &op, data, y, x, len); |
|
3322 |
} |
|
3323 |
||
3324 |
void process(int x, int y, int len, int coverage, const uint *src, int offset) |
|
3325 |
{ |
|
3326 |
if (spanMethod == RegularSpans) |
|
3327 |
op.func(dest + offset, src + offset, len, coverage); |
|
3328 |
else |
|
3329 |
drawBufferSpan(data, src + offset, len, x, y, len, coverage); |
|
3330 |
} |
|
3331 |
||
3332 |
void store(int x, int y, int len) |
|
3333 |
{ |
|
3334 |
if (spanMethod == RegularSpans && op.dest_store) { |
|
3335 |
op.dest_store(data->rasterBuffer, x, y, dest, len); |
|
3336 |
} |
|
3337 |
} |
|
3338 |
}; |
|
3339 |
||
3340 |
template <SpanMethod spanMethod> |
|
3341 |
Q_STATIC_TEMPLATE_FUNCTION void blend_src_generic(int count, const QSpan *spans, void *userData) |
|
3342 |
{ |
|
3343 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3344 |
BlendSrcGeneric<spanMethod> blend(data, getOperator(data, spans, count)); |
|
3345 |
handleSpans(count, spans, data, blend); |
|
3346 |
} |
|
3347 |
||
3348 |
template <SpanMethod spanMethod> |
|
3349 |
Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_generic(int count, const QSpan *spans, void *userData) |
|
3350 |
{ |
|
3351 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3352 |
||
3353 |
uint buffer[buffer_size]; |
|
3354 |
uint src_buffer[buffer_size]; |
|
3355 |
Operator op = getOperator(data, spans, count); |
|
3356 |
||
3357 |
const int image_width = data->texture.width; |
|
3358 |
const int image_height = data->texture.height; |
|
3359 |
int xoff = -qRound(-data->dx); |
|
3360 |
int yoff = -qRound(-data->dy); |
|
3361 |
||
3362 |
while (count--) { |
|
3363 |
int x = spans->x; |
|
3364 |
int length = spans->len; |
|
3365 |
int sx = xoff + x; |
|
3366 |
int sy = yoff + spans->y; |
|
3367 |
if (sy >= 0 && sy < image_height && sx < image_width) { |
|
3368 |
if (sx < 0) { |
|
3369 |
x -= sx; |
|
3370 |
length += sx; |
|
3371 |
sx = 0; |
|
3372 |
} |
|
3373 |
if (sx + length > image_width) |
|
3374 |
length = image_width - sx; |
|
3375 |
if (length > 0) { |
|
3376 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
3377 |
while (length) { |
|
3378 |
int l = qMin(buffer_size, length); |
|
3379 |
const uint *src = op.src_fetch(src_buffer, &op, data, sy, sx, l); |
|
3380 |
if (spanMethod == RegularSpans) { |
|
3381 |
uint *dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer; |
|
3382 |
op.func(dest, src, l, coverage); |
|
3383 |
if (op.dest_store) |
|
3384 |
op.dest_store(data->rasterBuffer, x, spans->y, dest, l); |
|
3385 |
} else { |
|
3386 |
drawBufferSpan(data, src, l, x, spans->y, |
|
3387 |
l, coverage); |
|
3388 |
} |
|
3389 |
x += l; |
|
3390 |
sx += l; |
|
3391 |
length -= l; |
|
3392 |
} |
|
3393 |
} |
|
3394 |
} |
|
3395 |
++spans; |
|
3396 |
} |
|
3397 |
} |
|
3398 |
||
3399 |
template <SpanMethod spanMethod> |
|
3400 |
Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_argb(int count, const QSpan *spans, void *userData) |
|
3401 |
{ |
|
3402 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3403 |
if (data->texture.format != QImage::Format_ARGB32_Premultiplied |
|
3404 |
&& data->texture.format != QImage::Format_RGB32) { |
|
3405 |
blend_untransformed_generic<spanMethod>(count, spans, userData); |
|
3406 |
return; |
|
3407 |
} |
|
3408 |
||
3409 |
Operator op = getOperator(data, spans, count); |
|
3410 |
||
3411 |
const int image_width = data->texture.width; |
|
3412 |
const int image_height = data->texture.height; |
|
3413 |
int xoff = -qRound(-data->dx); |
|
3414 |
int yoff = -qRound(-data->dy); |
|
3415 |
||
3416 |
while (count--) { |
|
3417 |
int x = spans->x; |
|
3418 |
int length = spans->len; |
|
3419 |
int sx = xoff + x; |
|
3420 |
int sy = yoff + spans->y; |
|
3421 |
if (sy >= 0 && sy < image_height && sx < image_width) { |
|
3422 |
if (sx < 0) { |
|
3423 |
x -= sx; |
|
3424 |
length += sx; |
|
3425 |
sx = 0; |
|
3426 |
} |
|
3427 |
if (sx + length > image_width) |
|
3428 |
length = image_width - sx; |
|
3429 |
if (length > 0) { |
|
3430 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
3431 |
const uint *src = (uint *)data->texture.scanLine(sy) + sx; |
|
3432 |
if (spanMethod == RegularSpans) { |
|
3433 |
uint *dest = ((uint *)data->rasterBuffer->scanLine(spans->y)) + x; |
|
3434 |
op.func(dest, src, length, coverage); |
|
3435 |
} else { |
|
3436 |
drawBufferSpan(data, src, length, x, |
|
3437 |
spans->y, length, coverage); |
|
3438 |
} |
|
3439 |
} |
|
3440 |
} |
|
3441 |
++spans; |
|
3442 |
} |
|
3443 |
} |
|
3444 |
||
3445 |
static inline quint16 interpolate_pixel_rgb16_255(quint16 x, quint8 a, |
|
3446 |
quint16 y, quint8 b) |
|
3447 |
{ |
|
3448 |
quint16 t = ((((x & 0x07e0) * a) + ((y & 0x07e0) * b)) >> 5) & 0x07e0; |
|
3449 |
t |= ((((x & 0xf81f) * a) + ((y & 0xf81f) * b)) >> 5) & 0xf81f; |
|
3450 |
||
3451 |
return t; |
|
3452 |
} |
|
3453 |
||
3454 |
static inline quint32 interpolate_pixel_rgb16x2_255(quint32 x, quint8 a, |
|
3455 |
quint32 y, quint8 b) |
|
3456 |
{ |
|
3457 |
uint t; |
|
3458 |
t = ((((x & 0xf81f07e0) >> 5) * a) + (((y & 0xf81f07e0) >> 5) * b)) & 0xf81f07e0; |
|
3459 |
t |= ((((x & 0x07e0f81f) * a) + ((y & 0x07e0f81f) * b)) >> 5) & 0x07e0f81f; |
|
3460 |
return t; |
|
3461 |
} |
|
3462 |
||
3463 |
static inline void blend_sourceOver_rgb16_rgb16(quint16 *dest, |
|
3464 |
const quint16 *src, |
|
3465 |
int length, |
|
3466 |
const quint8 alpha, |
|
3467 |
const quint8 ialpha) |
|
3468 |
{ |
|
3469 |
const int dstAlign = ((quintptr)dest) & 0x3; |
|
3470 |
if (dstAlign) { |
|
3471 |
*dest = interpolate_pixel_rgb16_255(*src, alpha, *dest, ialpha); |
|
3472 |
++dest; |
|
3473 |
++src; |
|
3474 |
--length; |
|
3475 |
} |
|
3476 |
const int srcAlign = ((quintptr)src) & 0x3; |
|
3477 |
int length32 = length >> 1; |
|
3478 |
if (length32 && srcAlign == 0) { |
|
3479 |
while (length32--) { |
|
3480 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
3481 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
3482 |
*dest32 = interpolate_pixel_rgb16x2_255(*src32, alpha, |
|
3483 |
*dest32, ialpha); |
|
3484 |
dest += 2; |
|
3485 |
src += 2; |
|
3486 |
} |
|
3487 |
length &= 0x1; |
|
3488 |
} |
|
3489 |
while (length--) { |
|
3490 |
*dest = interpolate_pixel_rgb16_255(*src, alpha, *dest, ialpha); |
|
3491 |
++dest; |
|
3492 |
++src; |
|
3493 |
} |
|
3494 |
} |
|
3495 |
||
3496 |
template <class DST, class SRC> |
|
3497 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3498 |
inline void madd_2(DST *dest, const quint16 alpha, const SRC *src) |
|
3499 |
{ |
|
3500 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
|
3501 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3502 |
dest[0] = dest[0].byte_mul(alpha >> 8) + DST(src[0]); |
|
3503 |
dest[1] = dest[1].byte_mul(alpha & 0xff) + DST(src[1]); |
|
3504 |
} |
|
3505 |
||
3506 |
template <class DST, class SRC> |
|
3507 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3508 |
inline void madd_4(DST *dest, const quint32 alpha, const SRC *src) |
|
3509 |
{ |
|
3510 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
|
3511 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3512 |
dest[0] = dest[0].byte_mul(alpha >> 24) + DST(src[0]); |
|
3513 |
dest[1] = dest[1].byte_mul((alpha >> 16) & 0xff) + DST(src[1]); |
|
3514 |
dest[2] = dest[2].byte_mul((alpha >> 8) & 0xff) + DST(src[2]); |
|
3515 |
dest[3] = dest[3].byte_mul(alpha & 0xff) + DST(src[3]); |
|
3516 |
} |
|
3517 |
||
3518 |
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
|
3519 |
template <> |
|
3520 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3521 |
inline void madd_4(qargb8565 *dest, const quint32 a, const qargb8565 *src) |
|
3522 |
{ |
|
3523 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
|
3524 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3525 |
||
3526 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
3527 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
3528 |
quint32 x, y, t; |
|
3529 |
quint8 a8; |
|
3530 |
||
3531 |
{ |
|
3532 |
x = dest32[0]; |
|
3533 |
y = src32[0]; |
|
3534 |
||
3535 |
a8 = a >> 24; |
|
3536 |
||
3537 |
// a0,g0 |
|
3538 |
t = ((((x & 0x0007e0ff) * a8) >> 5) & 0x0007e0ff) + (y & 0x0007c0f8); |
|
3539 |
||
3540 |
// r0,b0 |
|
3541 |
t |= ((((x & 0x00f81f00) * a8) >> 5) & 0x00f81f00) + (y & 0x00f81f00); |
|
3542 |
||
3543 |
a8 = (a >> 16) & 0xff; |
|
3544 |
||
3545 |
// a1 |
|
3546 |
t |= ((((x & 0xff000000) >> 5) * a8) & 0xff000000) + (y & 0xf8000000); |
|
3547 |
||
3548 |
dest32[0] = t; |
|
3549 |
} |
|
3550 |
{ |
|
3551 |
x = dest32[1]; |
|
3552 |
y = src32[1]; |
|
3553 |
||
3554 |
// r1,b1 |
|
3555 |
t = ((((x & 0x0000f81f) * a8) >> 5) & 0x0000f81f) + (y & 0x0000f81f); |
|
3556 |
||
3557 |
// g1 |
|
3558 |
t |= ((((x & 0x000007e0) * a8) >> 5) & 0x000007e0) + (y & 0x000007c0); |
|
3559 |
||
3560 |
a8 = (a >> 8) & 0xff; |
|
3561 |
||
3562 |
// a2 |
|
3563 |
t |= ((((x & 0x00ff0000) * a8) >> 5) & 0x00ff0000) + (y & 0x00f80000); |
|
3564 |
||
3565 |
{ |
|
3566 |
// rgb2 |
|
3567 |
quint16 x16 = (x >> 24) | ((dest32[2] & 0x000000ff) << 8); |
|
3568 |
quint16 y16 = (y >> 24) | ((src32[2] & 0x000000ff) << 8); |
|
3569 |
quint16 t16; |
|
3570 |
||
3571 |
t16 = ((((x16 & 0xf81f) * a8) >> 5) & 0xf81f) + (y16 & 0xf81f); |
|
3572 |
t16 |= ((((x16 & 0x07e0) * a8) >> 5) & 0x07e0) + (y16 & 0x07c0); |
|
3573 |
||
3574 |
// rg2 |
|
3575 |
t |= ((t16 & 0x00ff) << 24); |
|
3576 |
||
3577 |
dest32[1] = t; |
|
3578 |
||
3579 |
x = dest32[2]; |
|
3580 |
y = src32[2]; |
|
3581 |
||
3582 |
// gb2 |
|
3583 |
t = (t16 >> 8); |
|
3584 |
} |
|
3585 |
} |
|
3586 |
{ |
|
3587 |
a8 = a & 0xff; |
|
3588 |
||
3589 |
// g3,a3 |
|
3590 |
t |= ((((x & 0x07e0ff00) * a8) >> 5) & 0x07e0ff00) + (y & 0x07c0f800); |
|
3591 |
||
3592 |
// r3,b3 |
|
3593 |
t |= ((((x & 0xf81f0000) >> 5) * a8) & 0xf81f0000)+ (y & 0xf81f0000); |
|
3594 |
||
3595 |
dest32[2] = t; |
|
3596 |
} |
|
3597 |
} |
|
3598 |
#endif |
|
3599 |
||
3600 |
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
|
3601 |
template <> |
|
3602 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3603 |
inline void madd_4(qargb8555 *dest, const quint32 a, const qargb8555 *src) |
|
3604 |
{ |
|
3605 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
|
3606 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3607 |
||
3608 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
3609 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
3610 |
quint32 x, y, t; |
|
3611 |
quint8 a8; |
|
3612 |
||
3613 |
{ |
|
3614 |
x = dest32[0]; |
|
3615 |
y = src32[0]; |
|
3616 |
||
3617 |
a8 = a >> 24; |
|
3618 |
||
3619 |
// a0,g0 |
|
3620 |
t = ((((x & 0x0003e0ff) * a8) >> 5) & 0x0003e0ff) + (y & 0x0003e0f8); |
|
3621 |
||
3622 |
// r0,b0 |
|
3623 |
t |= ((((x & 0x007c1f00) * a8) >> 5) & 0x007c1f00) + (y & 0x007c1f00); |
|
3624 |
||
3625 |
a8 = (a >> 16) & 0xff; |
|
3626 |
||
3627 |
// a1 |
|
3628 |
t |= ((((x & 0xff000000) >> 5) * a8) & 0xff000000) + (y & 0xf8000000); |
|
3629 |
||
3630 |
dest32[0] = t; |
|
3631 |
} |
|
3632 |
{ |
|
3633 |
x = dest32[1]; |
|
3634 |
y = src32[1]; |
|
3635 |
||
3636 |
// r1,b1 |
|
3637 |
t = ((((x & 0x00007c1f) * a8) >> 5) & 0x00007c1f) + (y & 0x00007c1f); |
|
3638 |
||
3639 |
// g1 |
|
3640 |
t |= ((((x & 0x000003e0) * a8) >> 5) & 0x000003e0) + (y & 0x000003e0); |
|
3641 |
||
3642 |
a8 = (a >> 8) & 0xff; |
|
3643 |
||
3644 |
// a2 |
|
3645 |
t |= ((((x & 0x00ff0000) * a8) >> 5) & 0x00ff0000) + (y & 0x00f80000); |
|
3646 |
||
3647 |
{ |
|
3648 |
// rgb2 |
|
3649 |
quint16 x16 = (x >> 24) | ((dest32[2] & 0x000000ff) << 8); |
|
3650 |
quint16 y16 = (y >> 24) | ((src32[2] & 0x000000ff) << 8); |
|
3651 |
quint16 t16; |
|
3652 |
||
3653 |
t16 = ((((x16 & 0x7c1f) * a8) >> 5) & 0x7c1f) + (y16 & 0x7c1f); |
|
3654 |
t16 |= ((((x16 & 0x03e0) * a8) >> 5) & 0x03e0) + (y16 & 0x03e0); |
|
3655 |
||
3656 |
// rg2 |
|
3657 |
t |= ((t16 & 0x00ff) << 24); |
|
3658 |
||
3659 |
dest32[1] = t; |
|
3660 |
||
3661 |
x = dest32[2]; |
|
3662 |
y = src32[2]; |
|
3663 |
||
3664 |
// gb2 |
|
3665 |
t = (t16 >> 8); |
|
3666 |
} |
|
3667 |
} |
|
3668 |
{ |
|
3669 |
a8 = a & 0xff; |
|
3670 |
||
3671 |
// g3,a3 |
|
3672 |
t |= ((((x & 0x03e0ff00) * a8) >> 5) & 0x03e0ff00) + (y & 0x03e0f800); |
|
3673 |
||
3674 |
// r3,b3 |
|
3675 |
t |= ((((x & 0x7c1f0000) >> 5) * a8) & 0x7c1f0000)+ (y & 0x7c1f0000); |
|
3676 |
||
3677 |
dest32[2] = t; |
|
3678 |
} |
|
3679 |
} |
|
3680 |
#endif |
|
3681 |
||
3682 |
template <class T> |
|
3683 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3684 |
inline quint16 alpha_2(const T *src) |
|
3685 |
{ |
|
3686 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3687 |
||
3688 |
if (T::hasAlpha()) |
|
3689 |
return (src[0].alpha() << 8) | src[1].alpha(); |
|
3690 |
else |
|
3691 |
return 0xffff; |
|
3692 |
} |
|
3693 |
||
3694 |
template <class T> |
|
3695 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3696 |
inline quint32 alpha_4(const T *src) |
|
3697 |
{ |
|
3698 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3699 |
||
3700 |
if (T::hasAlpha()) { |
|
3701 |
return (src[0].alpha() << 24) | (src[1].alpha() << 16) |
|
3702 |
| (src[2].alpha() << 8) | src[3].alpha(); |
|
3703 |
} else { |
|
3704 |
return 0xffffffff; |
|
3705 |
} |
|
3706 |
} |
|
3707 |
||
3708 |
template <> |
|
3709 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3710 |
inline quint32 alpha_4(const qargb8565 *src) |
|
3711 |
{ |
|
3712 |
const quint8 *src8 = reinterpret_cast<const quint8*>(src); |
|
3713 |
return src8[0] << 24 | src8[3] << 16 | src8[6] << 8 | src8[9]; |
|
3714 |
} |
|
3715 |
||
3716 |
template <> |
|
3717 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3718 |
inline quint32 alpha_4(const qargb6666 *src) |
|
3719 |
{ |
|
3720 |
const quint8 *src8 = reinterpret_cast<const quint8*>(src); |
|
3721 |
return ((src8[2] & 0xfc) | (src8[2] >> 6)) << 24 |
|
3722 |
| ((src8[5] & 0xfc) | (src8[5] >> 6)) << 16 |
|
3723 |
| ((src8[8] & 0xfc) | (src8[8] >> 6)) << 8 |
|
3724 |
| ((src8[11] & 0xfc) | (src8[11] >> 6)); |
|
3725 |
} |
|
3726 |
||
3727 |
template <> |
|
3728 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3729 |
inline quint32 alpha_4(const qargb8555 *src) |
|
3730 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3731 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 3732 |
const quint8 *src8 = reinterpret_cast<const quint8*>(src); |
3733 |
return src8[0] << 24 | src8[3] << 16 | src8[6] << 8 | src8[9]; |
|
3734 |
} |
|
3735 |
||
3736 |
template <> |
|
3737 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3738 |
inline quint16 alpha_2(const qargb4444 *src) |
|
3739 |
{ |
|
3740 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
3741 |
const quint32 t = (*src32 & 0xf000f000) | |
|
3742 |
((*src32 & 0xf000f000) >> 4); |
|
3743 |
return (t >> 24) | (t & 0xff00); |
|
3744 |
} |
|
3745 |
||
3746 |
template <class T> |
|
3747 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3748 |
inline quint16 eff_alpha_2(quint16 alpha, const T*) |
|
3749 |
{ |
|
3750 |
return (T::alpha((alpha >> 8) & 0xff) << 8) |
|
3751 |
| T::alpha(alpha & 0xff); |
|
3752 |
} |
|
3753 |
||
3754 |
template <> |
|
3755 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3756 |
inline quint16 eff_alpha_2(quint16 a, const qrgb565*) |
|
3757 |
{ |
|
3758 |
return ((((a & 0xff00) + 0x0100) >> 3) & 0xff00) |
|
3759 |
| ((((a & 0x00ff) + 0x0001) >> 3) & 0x00ff); |
|
3760 |
} |
|
3761 |
||
3762 |
template <> |
|
3763 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3764 |
inline quint16 eff_alpha_2(quint16 a, const qrgb444*) |
|
3765 |
{ |
|
3766 |
return (((a & 0x00ff) + 0x0001) >> 4) |
|
3767 |
| ((((a & 0xff00) + 0x0100) >> 4) & 0xff00); |
|
3768 |
} |
|
3769 |
||
3770 |
template <> |
|
3771 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3772 |
inline quint16 eff_alpha_2(quint16 a, const qargb4444*) |
|
3773 |
{ |
|
3774 |
return (((a & 0x00ff) + 0x0001) >> 4) |
|
3775 |
| ((((a & 0xff00) + 0x0100) >> 4) & 0xff00); |
|
3776 |
} |
|
3777 |
||
3778 |
template <class T> |
|
3779 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3780 |
inline quint16 eff_ialpha_2(quint16 alpha, const T*) |
|
3781 |
{ |
|
3782 |
return (T::ialpha((alpha >> 8) & 0xff) << 8) |
|
3783 |
| T::ialpha(alpha & 0xff); |
|
3784 |
} |
|
3785 |
||
3786 |
template <> |
|
3787 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3788 |
inline quint16 eff_ialpha_2(quint16 a, const qrgb565 *dummy) |
|
3789 |
{ |
|
3790 |
return 0x2020 - eff_alpha_2(a, dummy); |
|
3791 |
} |
|
3792 |
||
3793 |
template <> |
|
3794 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3795 |
inline quint16 eff_ialpha_2(quint16 a, const qargb4444 *dummy) |
|
3796 |
{ |
|
3797 |
return 0x1010 - eff_alpha_2(a, dummy); |
|
3798 |
} |
|
3799 |
||
3800 |
template <> |
|
3801 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3802 |
inline quint16 eff_ialpha_2(quint16 a, const qrgb444 *dummy) |
|
3803 |
{ |
|
3804 |
return 0x1010 - eff_alpha_2(a, dummy); |
|
3805 |
} |
|
3806 |
||
3807 |
template <class T> |
|
3808 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3809 |
inline quint32 eff_alpha_4(quint32 alpha, const T*) |
|
3810 |
{ |
|
3811 |
return (T::alpha(alpha >> 24) << 24) |
|
3812 |
| (T::alpha((alpha >> 16) & 0xff) << 16) |
|
3813 |
| (T::alpha((alpha >> 8) & 0xff) << 8) |
|
3814 |
| T::alpha(alpha & 0xff); |
|
3815 |
} |
|
3816 |
||
3817 |
template <> |
|
3818 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3819 |
inline quint32 eff_alpha_4(quint32 a, const qrgb888*) |
|
3820 |
{ |
|
3821 |
return a; |
|
3822 |
} |
|
3823 |
||
3824 |
template <> |
|
3825 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3826 |
inline quint32 eff_alpha_4(quint32 a, const qargb8565*) |
|
3827 |
{ |
|
3828 |
return ((((a & 0xff00ff00) + 0x01000100) >> 3) & 0xff00ff00) |
|
3829 |
| ((((a & 0x00ff00ff) + 0x00010001) >> 3) & 0x00ff00ff); |
|
3830 |
} |
|
3831 |
||
3832 |
template <> |
|
3833 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3834 |
inline quint32 eff_alpha_4(quint32 a, const qargb6666*) |
|
3835 |
{ |
|
3836 |
return ((((a & 0xff00ff00) >> 2) + 0x00400040) & 0xff00ff00) |
|
3837 |
| ((((a & 0x00ff00ff) + 0x00010001) >> 2) & 0x00ff00ff); |
|
3838 |
} |
|
3839 |
||
3840 |
template <> |
|
3841 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3842 |
inline quint32 eff_alpha_4(quint32 a, const qrgb666*) |
|
3843 |
{ |
|
3844 |
return ((((a & 0xff00ff00) >> 2) + 0x00400040) & 0xff00ff00) |
|
3845 |
| ((((a & 0x00ff00ff) + 0x00010001) >> 2) & 0x00ff00ff); |
|
3846 |
} |
|
3847 |
||
3848 |
template <> |
|
3849 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3850 |
inline quint32 eff_alpha_4(quint32 a, const qargb8555*) |
|
3851 |
{ |
|
3852 |
return ((((a & 0xff00ff00) + 0x01000100) >> 3) & 0xff00ff00) |
|
3853 |
| ((((a & 0x00ff00ff) + 0x00010001) >> 3) & 0x00ff00ff); |
|
3854 |
} |
|
3855 |
||
3856 |
template <class T> |
|
3857 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3858 |
inline quint32 eff_ialpha_4(quint32 alpha, const T*) |
|
3859 |
{ |
|
3860 |
return (T::ialpha(alpha >> 24) << 24) |
|
3861 |
| (T::ialpha((alpha >> 16) & 0xff) << 16) |
|
3862 |
| (T::ialpha((alpha >> 8) & 0xff) << 8) |
|
3863 |
| T::ialpha(alpha & 0xff); |
|
3864 |
} |
|
3865 |
||
3866 |
template <> |
|
3867 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3868 |
inline quint32 eff_ialpha_4(quint32 a, const qrgb888*) |
|
3869 |
{ |
|
3870 |
return ~a; |
|
3871 |
} |
|
3872 |
||
3873 |
template <> |
|
3874 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3875 |
inline quint32 eff_ialpha_4(quint32 a, const qargb8565 *dummy) |
|
3876 |
{ |
|
3877 |
return 0x20202020 - eff_alpha_4(a, dummy); |
|
3878 |
} |
|
3879 |
||
3880 |
template <> |
|
3881 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3882 |
inline quint32 eff_ialpha_4(quint32 a, const qargb6666 *dummy) |
|
3883 |
{ |
|
3884 |
return 0x40404040 - eff_alpha_4(a, dummy); |
|
3885 |
} |
|
3886 |
||
3887 |
template <> |
|
3888 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3889 |
inline quint32 eff_ialpha_4(quint32 a, const qrgb666 *dummy) |
|
3890 |
{ |
|
3891 |
return 0x40404040 - eff_alpha_4(a, dummy); |
|
3892 |
} |
|
3893 |
||
3894 |
template <> |
|
3895 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3896 |
inline quint32 eff_ialpha_4(quint32 a, const qargb8555 *dummy) |
|
3897 |
{ |
|
3898 |
return 0x20202020 - eff_alpha_4(a, dummy); |
|
3899 |
} |
|
3900 |
||
3901 |
template <class DST, class SRC> |
|
3902 |
inline void interpolate_pixel_unaligned_2(DST *dest, const SRC *src, |
|
3903 |
quint16 alpha) |
|
3904 |
{ |
|
3905 |
const quint16 a = eff_alpha_2(alpha, dest); |
|
3906 |
const quint16 ia = eff_ialpha_2(alpha, dest); |
|
3907 |
dest[0] = DST(src[0]).byte_mul(a >> 8) + dest[0].byte_mul(ia >> 8); |
|
3908 |
dest[1] = DST(src[1]).byte_mul(a & 0xff) + dest[1].byte_mul(ia & 0xff); |
|
3909 |
} |
|
3910 |
||
3911 |
template <class DST, class SRC> |
|
3912 |
inline void interpolate_pixel_2(DST *dest, const SRC *src, quint16 alpha) |
|
3913 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3914 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3915 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 3916 |
|
3917 |
const quint16 a = eff_alpha_2(alpha, dest); |
|
3918 |
const quint16 ia = eff_ialpha_2(alpha, dest); |
|
3919 |
||
3920 |
dest[0] = DST(src[0]).byte_mul(a >> 8) + dest[0].byte_mul(ia >> 8); |
|
3921 |
dest[1] = DST(src[1]).byte_mul(a & 0xff) + dest[1].byte_mul(ia & 0xff); |
|
3922 |
} |
|
3923 |
||
3924 |
template <class DST, class SRC> |
|
3925 |
inline void interpolate_pixel(DST &dest, quint8 a, const SRC &src, quint8 b) |
|
3926 |
{ |
|
3927 |
if (SRC::hasAlpha() && !DST::hasAlpha()) |
|
3928 |
interpolate_pixel(dest, a, DST(src), b); |
|
3929 |
else |
|
3930 |
dest = dest.byte_mul(a) + DST(src).byte_mul(b); |
|
3931 |
} |
|
3932 |
||
3933 |
template <> |
|
3934 |
inline void interpolate_pixel(qargb8565 &dest, quint8 a, |
|
3935 |
const qargb8565 &src, quint8 b) |
|
3936 |
{ |
|
3937 |
quint8 *d = reinterpret_cast<quint8*>(&dest); |
|
3938 |
const quint8 *s = reinterpret_cast<const quint8*>(&src); |
|
3939 |
d[0] = (d[0] * a + s[0] * b) >> 5; |
|
3940 |
||
3941 |
const quint16 x = (d[2] << 8) | d[1]; |
|
3942 |
const quint16 y = (s[2] << 8) | s[1]; |
|
3943 |
quint16 t = (((x & 0x07e0) * a + (y & 0x07e0) * b) >> 5) & 0x07e0; |
|
3944 |
t |= (((x & 0xf81f) * a + (y & 0xf81f) * b) >> 5) & 0xf81f; |
|
3945 |
||
3946 |
d[1] = t & 0xff; |
|
3947 |
d[2] = t >> 8; |
|
3948 |
} |
|
3949 |
||
3950 |
template <> |
|
3951 |
inline void interpolate_pixel(qrgb565 &dest, quint8 a, |
|
3952 |
const qrgb565 &src, quint8 b) |
|
3953 |
{ |
|
3954 |
const quint16 x = dest.rawValue(); |
|
3955 |
const quint16 y = src.rawValue(); |
|
3956 |
quint16 t = (((x & 0x07e0) * a + (y & 0x07e0) * b) >> 5) & 0x07e0; |
|
3957 |
t |= (((x & 0xf81f) * a + (y & 0xf81f) * b) >> 5) & 0xf81f; |
|
3958 |
dest = t; |
|
3959 |
} |
|
3960 |
||
3961 |
template <> |
|
3962 |
inline void interpolate_pixel(qrgb555 &dest, quint8 a, |
|
3963 |
const qrgb555 &src, quint8 b) |
|
3964 |
{ |
|
3965 |
const quint16 x = dest.rawValue(); |
|
3966 |
const quint16 y = src.rawValue(); |
|
3967 |
quint16 t = (((x & 0x03e0) * a + (y & 0x03e0) * b) >> 5) & 0x03e0; |
|
3968 |
t |= ((((x & 0x7c1f) * a) + ((y & 0x7c1f) * b)) >> 5) & 0x7c1f; |
|
3969 |
dest = t; |
|
3970 |
} |
|
3971 |
||
3972 |
template <> |
|
3973 |
inline void interpolate_pixel(qrgb444 &dest, quint8 a, |
|
3974 |
const qrgb444 &src, quint8 b) |
|
3975 |
{ |
|
3976 |
const quint16 x = dest.rawValue(); |
|
3977 |
const quint16 y = src.rawValue(); |
|
3978 |
quint16 t = ((x & 0x00f0) * a + (y & 0x00f0) * b) & 0x0f00; |
|
3979 |
t |= ((x & 0x0f0f) * a + (y & 0x0f0f) * b) & 0xf0f0; |
|
3980 |
quint16 *d = reinterpret_cast<quint16*>(&dest); |
|
3981 |
*d = (t >> 4); |
|
3982 |
} |
|
3983 |
||
3984 |
template <class DST, class SRC> |
|
3985 |
inline void interpolate_pixel_2(DST *dest, quint8 a, |
|
3986 |
const SRC *src, quint8 b) |
|
3987 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3988 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3989 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 3990 |
|
3991 |
Q_ASSERT(!SRC::hasAlpha()); |
|
3992 |
||
3993 |
dest[0] = dest[0].byte_mul(a) + DST(src[0]).byte_mul(b); |
|
3994 |
dest[1] = dest[1].byte_mul(a) + DST(src[1]).byte_mul(b); |
|
3995 |
} |
|
3996 |
||
3997 |
template <> |
|
3998 |
inline void interpolate_pixel_2(qrgb565 *dest, quint8 a, |
|
3999 |
const qrgb565 *src, quint8 b) |
|
4000 |
{ |
|
4001 |
quint32 *x = reinterpret_cast<quint32*>(dest); |
|
4002 |
const quint32 *y = reinterpret_cast<const quint32*>(src); |
|
4003 |
quint32 t = (((*x & 0xf81f07e0) >> 5) * a + |
|
4004 |
((*y & 0xf81f07e0) >> 5) * b) & 0xf81f07e0; |
|
4005 |
t |= (((*x & 0x07e0f81f) * a |
|
4006 |
+ (*y & 0x07e0f81f) * b) >> 5) & 0x07e0f81f; |
|
4007 |
*x = t; |
|
4008 |
} |
|
4009 |
||
4010 |
template <> |
|
4011 |
inline void interpolate_pixel_2(qrgb555 *dest, quint8 a, |
|
4012 |
const qrgb555 *src, quint8 b) |
|
4013 |
{ |
|
4014 |
quint32 *x = reinterpret_cast<quint32*>(dest); |
|
4015 |
const quint32 *y = reinterpret_cast<const quint32*>(src); |
|
4016 |
quint32 t = (((*x & 0x7c1f03e0) >> 5) * a + |
|
4017 |
((*y & 0x7c1f03e0) >> 5) * b) & 0x7c1f03e0; |
|
4018 |
t |= (((*x & 0x03e07c1f) * a |
|
4019 |
+ (*y & 0x03e07c1f) * b) >> 5) & 0x03e07c1f; |
|
4020 |
*x = t; |
|
4021 |
} |
|
4022 |
||
4023 |
template <> |
|
4024 |
inline void interpolate_pixel_2(qrgb444 *dest, quint8 a, |
|
4025 |
const qrgb444 *src, quint8 b) |
|
4026 |
{ |
|
4027 |
quint32 *x = reinterpret_cast<quint32*>(dest); |
|
4028 |
const quint32 *y = reinterpret_cast<const quint32*>(src); |
|
4029 |
quint32 t = ((*x & 0x0f0f0f0f) * a + (*y & 0x0f0f0f0f) * b) & 0xf0f0f0f0; |
|
4030 |
t |= ((*x & 0x00f000f0) * a + (*y & 0x00f000f0) * b) & 0x0f000f00; |
|
4031 |
*x = t >> 4; |
|
4032 |
} |
|
4033 |
||
4034 |
template <class DST, class SRC> |
|
4035 |
inline void interpolate_pixel_4(DST *dest, const SRC *src, quint32 alpha) |
|
4036 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4037 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4038 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4039 |
|
4040 |
const quint32 a = eff_alpha_4(alpha, dest); |
|
4041 |
const quint32 ia = eff_ialpha_4(alpha, dest); |
|
4042 |
dest[0] = DST(src[0]).byte_mul(a >> 24) |
|
4043 |
+ dest[0].byte_mul(ia >> 24); |
|
4044 |
dest[1] = DST(src[1]).byte_mul((a >> 16) & 0xff) |
|
4045 |
+ dest[1].byte_mul((ia >> 16) & 0xff); |
|
4046 |
dest[2] = DST(src[2]).byte_mul((a >> 8) & 0xff) |
|
4047 |
+ dest[2].byte_mul((ia >> 8) & 0xff); |
|
4048 |
dest[3] = DST(src[3]).byte_mul(a & 0xff) |
|
4049 |
+ dest[3].byte_mul(ia & 0xff); |
|
4050 |
} |
|
4051 |
||
4052 |
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
|
4053 |
template <> |
|
4054 |
inline void interpolate_pixel_4(qargb8565 *dest, const qargb8565 *src, |
|
4055 |
quint32 alpha) |
|
4056 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4057 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4058 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4059 |
|
4060 |
const quint32 a = eff_alpha_4(alpha, dest); |
|
4061 |
const quint32 ia = eff_ialpha_4(alpha, dest); |
|
4062 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
4063 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
4064 |
||
4065 |
quint32 x, y, t; |
|
4066 |
quint8 a8, ia8; |
|
4067 |
{ |
|
4068 |
x = src32[0]; |
|
4069 |
y = dest32[0]; |
|
4070 |
||
4071 |
a8 = a >> 24; |
|
4072 |
ia8 = ia >> 24; |
|
4073 |
||
4074 |
// a0,g0 |
|
4075 |
t = (((x & 0x0007e0ff) * a8 + (y & 0x0007e0ff) * ia8) >> 5) |
|
4076 |
& 0x0007e0ff; |
|
4077 |
||
4078 |
// r0,b0 |
|
4079 |
t |= (((x & 0x00f81f00) * a8 + (y & 0x00f81f00) * ia8) >> 5) |
|
4080 |
& 0x00f81f00; |
|
4081 |
||
4082 |
a8 = (a >> 16) & 0xff; |
|
4083 |
ia8 = (ia >> 16) & 0xff; |
|
4084 |
||
4085 |
// a1 |
|
4086 |
t |= (((x & 0xff000000) >> 5) * a8 + ((y & 0xff000000) >> 5) * ia8) |
|
4087 |
& 0xff000000; |
|
4088 |
||
4089 |
dest32[0] = t; |
|
4090 |
} |
|
4091 |
{ |
|
4092 |
x = src32[1]; |
|
4093 |
y = dest32[1]; |
|
4094 |
||
4095 |
// r1,b1 |
|
4096 |
t = (((x & 0x0000f81f) * a8 + (y & 0x0000f81f) * ia8) >> 5) |
|
4097 |
& 0x0000f81f; |
|
4098 |
||
4099 |
// g1 |
|
4100 |
t |= (((x & 0x000007e0) * a8 + (y & 0x000007e0) * ia8) >> 5) |
|
4101 |
& 0x000007e0; |
|
4102 |
||
4103 |
a8 = (a >> 8) & 0xff; |
|
4104 |
ia8 = (ia >> 8) & 0xff; |
|
4105 |
||
4106 |
// a2 |
|
4107 |
t |= (((x & 0x00ff0000) * a8 + (y & 0x00ff0000) * ia8) >> 5) |
|
4108 |
& 0x00ff0000; |
|
4109 |
||
4110 |
{ |
|
4111 |
// rgb2 |
|
4112 |
quint16 x16 = (x >> 24) | ((src32[2] & 0x000000ff) << 8); |
|
4113 |
quint16 y16 = (y >> 24) | ((dest32[2] & 0x000000ff) << 8); |
|
4114 |
quint16 t16; |
|
4115 |
||
4116 |
t16 = (((x16 & 0xf81f) * a8 + (y16 & 0xf81f) * ia8) >> 5) & 0xf81f; |
|
4117 |
t16 |= (((x16 & 0x07e0) * a8 + (y16 & 0x07e0) * ia8) >> 5) & 0x07e0; |
|
4118 |
||
4119 |
// rg2 |
|
4120 |
t |= ((t16 & 0x00ff) << 24); |
|
4121 |
||
4122 |
dest32[1] = t; |
|
4123 |
||
4124 |
x = src32[2]; |
|
4125 |
y = dest32[2]; |
|
4126 |
||
4127 |
// gb2 |
|
4128 |
t = (t16 >> 8); |
|
4129 |
} |
|
4130 |
} |
|
4131 |
{ |
|
4132 |
a8 = a & 0xff; |
|
4133 |
ia8 = ia & 0xff; |
|
4134 |
||
4135 |
// g3,a3 |
|
4136 |
t |= (((x & 0x07e0ff00) * a8 + (y & 0x07e0ff00) * ia8) >> 5) |
|
4137 |
& 0x07e0ff00; |
|
4138 |
||
4139 |
// r3,b3 |
|
4140 |
t |= (((x & 0xf81f0000) >> 5) * a8 + ((y & 0xf81f0000) >> 5) * ia8) |
|
4141 |
& 0xf81f0000; |
|
4142 |
||
4143 |
dest32[2] = t; |
|
4144 |
} |
|
4145 |
} |
|
4146 |
#endif |
|
4147 |
||
4148 |
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
|
4149 |
template <> |
|
4150 |
inline void interpolate_pixel_4(qargb8555 *dest, const qargb8555 *src, |
|
4151 |
quint32 alpha) |
|
4152 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4153 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4154 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4155 |
|
4156 |
||
4157 |
const quint32 a = eff_alpha_4(alpha, dest); |
|
4158 |
const quint32 ia = eff_ialpha_4(alpha, dest); |
|
4159 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
4160 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
4161 |
||
4162 |
quint32 x, y, t; |
|
4163 |
quint8 a8, ia8; |
|
4164 |
{ |
|
4165 |
x = src32[0]; |
|
4166 |
y = dest32[0]; |
|
4167 |
||
4168 |
a8 = a >> 24; |
|
4169 |
ia8 = ia >> 24; |
|
4170 |
||
4171 |
// a0,g0 |
|
4172 |
t = (((x & 0x0003e0ff) * a8 + (y & 0x0003e0ff) * ia8) >> 5) |
|
4173 |
& 0x0003e0ff; |
|
4174 |
||
4175 |
// r0,b0 |
|
4176 |
t |= (((x & 0x007c1f00) * a8 + (y & 0x007c1f00) * ia8) >> 5) |
|
4177 |
& 0x007c1f00; |
|
4178 |
||
4179 |
a8 = (a >> 16) & 0xff; |
|
4180 |
ia8 = (ia >> 16) & 0xff; |
|
4181 |
||
4182 |
// a1 |
|
4183 |
t |= (((x & 0xff000000) >> 5) * a8 + ((y & 0xff000000) >> 5) * ia8) |
|
4184 |
& 0xff000000; |
|
4185 |
||
4186 |
dest32[0] = t; |
|
4187 |
} |
|
4188 |
{ |
|
4189 |
x = src32[1]; |
|
4190 |
y = dest32[1]; |
|
4191 |
||
4192 |
// r1,b1 |
|
4193 |
t = (((x & 0x00007c1f) * a8 + (y & 0x00007c1f) * ia8) >> 5) |
|
4194 |
& 0x00007c1f; |
|
4195 |
||
4196 |
// g1 |
|
4197 |
t |= (((x & 0x000003e0) * a8 + (y & 0x000003e0) * ia8) >> 5) |
|
4198 |
& 0x000003e0; |
|
4199 |
||
4200 |
a8 = (a >> 8) & 0xff; |
|
4201 |
ia8 = (ia >> 8) & 0xff; |
|
4202 |
||
4203 |
// a2 |
|
4204 |
t |= (((x & 0x00ff0000) * a8 + (y & 0x00ff0000) * ia8) >> 5) |
|
4205 |
& 0x00ff0000; |
|
4206 |
||
4207 |
{ |
|
4208 |
// rgb2 |
|
4209 |
quint16 x16 = (x >> 24) | ((src32[2] & 0x000000ff) << 8); |
|
4210 |
quint16 y16 = (y >> 24) | ((dest32[2] & 0x000000ff) << 8); |
|
4211 |
quint16 t16; |
|
4212 |
||
4213 |
t16 = (((x16 & 0x7c1f) * a8 + (y16 & 0x7c1f) * ia8) >> 5) & 0x7c1f; |
|
4214 |
t16 |= (((x16 & 0x03e0) * a8 + (y16 & 0x03e0) * ia8) >> 5) & 0x03e0; |
|
4215 |
||
4216 |
// rg2 |
|
4217 |
t |= ((t16 & 0x00ff) << 24); |
|
4218 |
||
4219 |
dest32[1] = t; |
|
4220 |
||
4221 |
x = src32[2]; |
|
4222 |
y = dest32[2]; |
|
4223 |
||
4224 |
// gb2 |
|
4225 |
t = (t16 >> 8); |
|
4226 |
} |
|
4227 |
} |
|
4228 |
{ |
|
4229 |
a8 = a & 0xff; |
|
4230 |
ia8 = ia & 0xff; |
|
4231 |
||
4232 |
// g3,a3 |
|
4233 |
t |= (((x & 0x03e0ff00) * a8 + (y & 0x03e0ff00) * ia8) >> 5) |
|
4234 |
& 0x03e0ff00; |
|
4235 |
||
4236 |
// r3,b3 |
|
4237 |
t |= (((x & 0x7c1f0000) >> 5) * a8 + ((y & 0x7c1f0000) >> 5) * ia8) |
|
4238 |
& 0x7c1f0000; |
|
4239 |
||
4240 |
dest32[2] = t; |
|
4241 |
} |
|
4242 |
} |
|
4243 |
#endif |
|
4244 |
||
4245 |
template <> |
|
4246 |
inline void interpolate_pixel_4(qrgb888 *dest, const qrgb888 *src, |
|
4247 |
quint32 alpha) |
|
4248 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4249 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4250 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4251 |
|
4252 |
const quint32 a = eff_alpha_4(alpha, dest); |
|
4253 |
const quint32 ia = eff_ialpha_4(alpha, dest); |
|
4254 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
4255 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
4256 |
||
4257 |
{ |
|
4258 |
quint32 x = src32[0]; |
|
4259 |
quint32 y = dest32[0]; |
|
4260 |
||
4261 |
quint32 t; |
|
4262 |
t = ((x >> 8) & 0xff00ff) * (a >> 24) |
|
4263 |
+ ((y >> 8) & 0xff00ff) * (ia >> 24); |
|
4264 |
t = (t + ((t >> 8) & 0xff00ff) + 0x800080); |
|
4265 |
t &= 0xff00ff00; |
|
4266 |
||
4267 |
x = (x & 0xff0000) * (a >> 24) |
|
4268 |
+ (x & 0x0000ff) * ((a >> 16) & 0xff) |
|
4269 |
+ (y & 0xff0000) * (ia >> 24) |
|
4270 |
+ (y & 0x0000ff) * ((ia >> 16) & 0xff); |
|
4271 |
x = (x + ((x >> 8) & 0xff00ff) + 0x800080) >> 8; |
|
4272 |
x &= 0x00ff00ff; |
|
4273 |
||
4274 |
dest32[0] = x | t; |
|
4275 |
} |
|
4276 |
{ |
|
4277 |
quint32 x = src32[1]; |
|
4278 |
quint32 y = dest32[1]; |
|
4279 |
||
4280 |
quint32 t; |
|
4281 |
t = ((x >> 8) & 0xff0000) * ((a >> 16) & 0xff) |
|
4282 |
+ ((x >> 8) & 0x0000ff) * ((a >> 8) & 0xff) |
|
4283 |
+ ((y >> 8) & 0xff0000) * ((ia >> 16) & 0xff) |
|
4284 |
+ ((y >> 8) & 0x0000ff) * ((ia >> 8) & 0xff); |
|
4285 |
t = (t + ((t >> 8) & 0xff00ff) + 0x800080); |
|
4286 |
t &= 0xff00ff00; |
|
4287 |
||
4288 |
x = (x & 0xff0000) * ((a >> 16) & 0xff) |
|
4289 |
+ (x & 0x0000ff) * ((a >> 8) & 0xff) |
|
4290 |
+ (y & 0xff0000) * ((ia >> 16) & 0xff) |
|
4291 |
+ (y & 0x0000ff) * ((ia >> 8) & 0xff); |
|
4292 |
x = (x + ((x >> 8) & 0xff00ff) + 0x800080) >> 8; |
|
4293 |
x &= 0x00ff00ff; |
|
4294 |
||
4295 |
dest32[1] = x | t; |
|
4296 |
} |
|
4297 |
{ |
|
4298 |
quint32 x = src32[2]; |
|
4299 |
quint32 y = dest32[2]; |
|
4300 |
||
4301 |
quint32 t; |
|
4302 |
t = ((x >> 8) & 0xff0000) * ((a >> 8) & 0xff) |
|
4303 |
+ ((x >> 8) & 0x0000ff) * (a & 0xff) |
|
4304 |
+ ((y >> 8) & 0xff0000) * ((ia >> 8) & 0xff) |
|
4305 |
+ ((y >> 8) & 0x0000ff) * (ia & 0xff); |
|
4306 |
t = (t + ((t >> 8) & 0xff00ff) + 0x800080); |
|
4307 |
t &= 0xff00ff00; |
|
4308 |
||
4309 |
x = (x & 0xff00ff) * (a & 0xff) |
|
4310 |
+ (y & 0xff00ff) * (ia & 0xff); |
|
4311 |
x = (x + ((x >> 8) & 0xff00ff) + 0x800080) >> 8; |
|
4312 |
x &= 0x00ff00ff; |
|
4313 |
||
4314 |
dest32[2] = x | t; |
|
4315 |
} |
|
4316 |
} |
|
4317 |
||
4318 |
template <class DST, class SRC> |
|
4319 |
inline void interpolate_pixel_4(DST *dest, quint8 a, |
|
4320 |
const SRC *src, quint8 b) |
|
4321 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4322 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4323 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4324 |
|
4325 |
dest[0] = dest[0].byte_mul(a) + DST(src[0]).byte_mul(b); |
|
4326 |
dest[1] = dest[1].byte_mul(a) + DST(src[1]).byte_mul(b); |
|
4327 |
dest[2] = dest[2].byte_mul(a) + DST(src[2]).byte_mul(b); |
|
4328 |
dest[3] = dest[3].byte_mul(a) + DST(src[3]).byte_mul(b); |
|
4329 |
} |
|
4330 |
||
4331 |
template <class DST, class SRC> |
|
4332 |
inline void blend_sourceOver_4(DST *dest, const SRC *src) |
|
4333 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4334 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4335 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4336 |
|
4337 |
const quint32 a = alpha_4(src); |
|
4338 |
if (a == 0xffffffff) { |
|
4339 |
qt_memconvert(dest, src, 4); |
|
4340 |
} else if (a > 0) { |
|
4341 |
quint32 buf[3]; // array of quint32 to get correct alignment |
|
4342 |
qt_memconvert((DST*)(void*)buf, src, 4); |
|
4343 |
madd_4(dest, eff_ialpha_4(a, dest), (DST*)(void*)buf); |
|
4344 |
} |
|
4345 |
} |
|
4346 |
||
4347 |
template <> |
|
4348 |
inline void blend_sourceOver_4(qargb8565 *dest, const qargb8565 *src) |
|
4349 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4350 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4351 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4352 |
|
4353 |
const quint32 a = alpha_4(src); |
|
4354 |
if (a == 0xffffffff) { |
|
4355 |
qt_memconvert(dest, src, 4); |
|
4356 |
} else if (a > 0) { |
|
4357 |
madd_4(dest, eff_ialpha_4(a, dest), src); |
|
4358 |
} |
|
4359 |
} |
|
4360 |
||
4361 |
template <> |
|
4362 |
inline void blend_sourceOver_4(qargb8555 *dest, const qargb8555 *src) |
|
4363 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4364 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4365 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4366 |
|
4367 |
const quint32 a = alpha_4(src); |
|
4368 |
if (a == 0xffffffff) { |
|
4369 |
qt_memconvert(dest, src, 4); |
|
4370 |
} else if (a > 0) { |
|
4371 |
madd_4(dest, eff_ialpha_4(a, dest), src); |
|
4372 |
} |
|
4373 |
} |
|
4374 |
||
4375 |
template <> |
|
4376 |
inline void blend_sourceOver_4(qargb6666 *dest, const qargb6666 *src) |
|
4377 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4378 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4379 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4380 |
|
4381 |
const quint32 a = alpha_4(src); |
|
4382 |
if (a == 0xffffffff) { |
|
4383 |
qt_memconvert(dest, src, 4); |
|
4384 |
} else if (a > 0) { |
|
4385 |
madd_4(dest, eff_ialpha_4(a, dest), src); |
|
4386 |
} |
|
4387 |
} |
|
4388 |
||
4389 |
template <class DST, class SRC> |
|
4390 |
void QT_FASTCALL blendUntransformed_unaligned(DST *dest, const SRC *src, |
|
4391 |
quint8 coverage, int length) |
|
4392 |
{ |
|
4393 |
Q_ASSERT(coverage > 0); |
|
4394 |
||
4395 |
if (coverage < 255) { |
|
4396 |
if (SRC::hasAlpha()) { |
|
4397 |
for (int i = 0; i < length; ++i) { |
|
4398 |
if (src[i].alpha()) { |
|
4399 |
const quint8 alpha = qt_div_255(int(src[i].alpha()) * int(coverage)); |
|
4400 |
interpolate_pixel(dest[i], DST::ialpha(alpha), |
|
4401 |
src[i], DST::alpha(alpha)); |
|
4402 |
} |
|
4403 |
} |
|
4404 |
} else { |
|
4405 |
const quint8 alpha = DST::alpha(coverage); |
|
4406 |
const quint8 ialpha = DST::ialpha(coverage); |
|
4407 |
if (alpha) { |
|
4408 |
for (int i = 0; i < length; ++i) |
|
4409 |
interpolate_pixel(dest[i], ialpha, src[i], alpha); |
|
4410 |
} |
|
4411 |
} |
|
4412 |
return; |
|
4413 |
} |
|
4414 |
||
4415 |
Q_ASSERT(coverage == 0xff); |
|
4416 |
Q_ASSERT(SRC::hasAlpha()); |
|
4417 |
||
4418 |
if (SRC::hasAlpha()) { |
|
4419 |
for (int i = 0; i < length; ++i) { |
|
4420 |
const quint8 a = src->alpha(); |
|
4421 |
if (a == 0xff) |
|
4422 |
*dest = DST(*src); |
|
4423 |
else if (a > 0) { |
|
4424 |
if (DST::hasAlpha()) |
|
4425 |
*dest = DST(*src).truncedAlpha() + dest->byte_mul(DST::ialpha(a)); |
|
4426 |
else |
|
4427 |
*dest = DST(SRC(*src).truncedAlpha()) + dest->byte_mul(DST::ialpha(a)); |
|
4428 |
} |
|
4429 |
++src; |
|
4430 |
++dest; |
|
4431 |
} |
|
4432 |
} |
|
4433 |
} |
|
4434 |
||
4435 |
template <class DST, class SRC> |
|
4436 |
void QT_FASTCALL blendUntransformed_dest16(DST *dest, const SRC *src, |
|
4437 |
quint8 coverage, int length) |
|
4438 |
{ |
|
4439 |
Q_ASSERT(sizeof(DST) == 2); |
|
4440 |
Q_ASSERT(sizeof(SRC) == 2); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4441 |
Q_ASSERT((quintptr(dest) & 0x3) == (quintptr(src) & 0x3)); |
0 | 4442 |
Q_ASSERT(coverage > 0); |
4443 |
||
4444 |
const int align = quintptr(dest) & 0x3; |
|
4445 |
||
4446 |
if (coverage < 255) { |
|
4447 |
// align |
|
4448 |
if (align) { |
|
4449 |
const quint8 alpha = SRC::hasAlpha() |
|
4450 |
? qt_div_255(int(src->alpha()) * int(coverage)) |
|
4451 |
: coverage; |
|
4452 |
if (alpha) { |
|
4453 |
interpolate_pixel(*dest, DST::ialpha(alpha), |
|
4454 |
*src, DST::alpha(alpha)); |
|
4455 |
} |
|
4456 |
++dest; |
|
4457 |
++src; |
|
4458 |
--length; |
|
4459 |
} |
|
4460 |
||
4461 |
if (SRC::hasAlpha()) { |
|
4462 |
while (length >= 2) { |
|
4463 |
const quint16 alpha16 = BYTE_MUL(uint(alpha_2(src)), uint(coverage)); |
|
4464 |
interpolate_pixel_2(dest, src, alpha16); |
|
4465 |
length -= 2; |
|
4466 |
src += 2; |
|
4467 |
dest += 2; |
|
4468 |
} |
|
4469 |
} else { |
|
4470 |
const quint8 alpha = DST::alpha(coverage); |
|
4471 |
const quint8 ialpha = DST::ialpha(coverage); |
|
4472 |
||
4473 |
while (length >= 2) { |
|
4474 |
interpolate_pixel_2(dest, ialpha, src, alpha); |
|
4475 |
length -= 2; |
|
4476 |
src += 2; |
|
4477 |
dest += 2; |
|
4478 |
} |
|
4479 |
} |
|
4480 |
||
4481 |
// tail |
|
4482 |
if (length) { |
|
4483 |
const quint8 alpha = SRC::hasAlpha() |
|
4484 |
? qt_div_255(int(src->alpha()) * int(coverage)) |
|
4485 |
: coverage; |
|
4486 |
if (alpha) { |
|
4487 |
interpolate_pixel(*dest, DST::ialpha(alpha), |
|
4488 |
*src, DST::alpha(alpha)); |
|
4489 |
} |
|
4490 |
} |
|
4491 |
||
4492 |
return; |
|
4493 |
} |
|
4494 |
||
4495 |
Q_ASSERT(SRC::hasAlpha()); |
|
4496 |
if (SRC::hasAlpha()) { |
|
4497 |
if (align) { |
|
4498 |
const quint8 alpha = src->alpha(); |
|
4499 |
if (alpha == 0xff) |
|
4500 |
*dest = DST(*src); |
|
4501 |
else if (alpha > 0) |
|
4502 |
*dest = DST(*src).truncedAlpha() + dest->byte_mul(DST::ialpha(alpha)); |
|
4503 |
++dest; |
|
4504 |
++src; |
|
4505 |
--length; |
|
4506 |
} |
|
4507 |
||
4508 |
while (length >= 2) { |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4509 |
Q_ASSERT((quintptr(dest) & 3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4510 |
Q_ASSERT((quintptr(src) & 3) == 0); |
0 | 4511 |
|
4512 |
const quint16 a = alpha_2(src); |
|
4513 |
if (a == 0xffff) { |
|
4514 |
qt_memconvert(dest, src, 2); |
|
4515 |
} else if (a > 0) { |
|
4516 |
quint32 buf; |
|
4517 |
if (sizeof(DST) == 2) |
|
4518 |
qt_memconvert((DST*)(void*)&buf, src, 2); |
|
4519 |
madd_2(dest, eff_ialpha_2(a, dest), (DST*)(void*)&buf); |
|
4520 |
} |
|
4521 |
||
4522 |
length -= 2; |
|
4523 |
src += 2; |
|
4524 |
dest += 2; |
|
4525 |
} |
|
4526 |
||
4527 |
if (length) { |
|
4528 |
const quint8 alpha = src->alpha(); |
|
4529 |
if (alpha == 0xff) |
|
4530 |
*dest = DST(*src); |
|
4531 |
else if (alpha > 0) |
|
4532 |
*dest = DST(*src).truncedAlpha() + dest->byte_mul(DST::ialpha(alpha)); |
|
4533 |
} |
|
4534 |
} |
|
4535 |
} |
|
4536 |
||
4537 |
template <class DST, class SRC> |
|
4538 |
void QT_FASTCALL blendUntransformed_dest24(DST *dest, const SRC *src, |
|
4539 |
quint8 coverage, int length) |
|
4540 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4541 |
Q_ASSERT((quintptr(dest) & 0x3) == (quintptr(src) & 0x3)); |
0 | 4542 |
Q_ASSERT(sizeof(DST) == 3); |
4543 |
Q_ASSERT(coverage > 0); |
|
4544 |
||
4545 |
const int align = quintptr(dest) & 0x3; |
|
4546 |
||
4547 |
if (coverage < 255) { |
|
4548 |
// align |
|
4549 |
for (int i = 0; i < align; ++i) { |
|
4550 |
if (SRC::hasAlpha()) { |
|
4551 |
const quint8 alpha = qt_div_255(int(src->alpha()) * int(coverage)); |
|
4552 |
if (alpha) |
|
4553 |
interpolate_pixel(*dest, DST::ialpha(alpha), |
|
4554 |
*src, DST::alpha(alpha)); |
|
4555 |
} else { |
|
4556 |
interpolate_pixel(*dest, DST::ialpha(coverage), |
|
4557 |
*src, DST::alpha(coverage)); |
|
4558 |
} |
|
4559 |
++dest; |
|
4560 |
++src; |
|
4561 |
--length; |
|
4562 |
} |
|
4563 |
||
4564 |
if (SRC::hasAlpha()) { |
|
4565 |
while (length >= 4) { |
|
4566 |
const quint32 alpha = BYTE_MUL(uint(alpha_4(src)), uint(coverage)); |
|
4567 |
if (alpha) |
|
4568 |
interpolate_pixel_4(dest, src, alpha); |
|
4569 |
length -= 4; |
|
4570 |
src += 4; |
|
4571 |
dest += 4; |
|
4572 |
} |
|
4573 |
} else { |
|
4574 |
const quint8 alpha = DST::alpha(coverage); |
|
4575 |
const quint8 ialpha = DST::ialpha(coverage); |
|
4576 |
while (length >= 4) { |
|
4577 |
interpolate_pixel_4(dest, ialpha, src, alpha); |
|
4578 |
length -= 4; |
|
4579 |
src += 4; |
|
4580 |
dest += 4; |
|
4581 |
} |
|
4582 |
} |
|
4583 |
||
4584 |
// tail |
|
4585 |
while (length--) { |
|
4586 |
if (SRC::hasAlpha()) { |
|
4587 |
const quint8 alpha = qt_div_255(int(src->alpha()) * int(coverage)); |
|
4588 |
if (alpha) |
|
4589 |
interpolate_pixel(*dest, DST::ialpha(alpha), |
|
4590 |
*src, DST::alpha(alpha)); |
|
4591 |
} else { |
|
4592 |
interpolate_pixel(*dest, DST::ialpha(coverage), |
|
4593 |
*src, DST::alpha(coverage)); |
|
4594 |
} |
|
4595 |
++dest; |
|
4596 |
++src; |
|
4597 |
} |
|
4598 |
||
4599 |
return; |
|
4600 |
} |
|
4601 |
||
4602 |
||
4603 |
Q_ASSERT(coverage == 255); |
|
4604 |
Q_ASSERT(SRC::hasAlpha()); |
|
4605 |
||
4606 |
if (SRC::hasAlpha()) { |
|
4607 |
// align |
|
4608 |
for (int i = 0; i < align; ++i) { |
|
4609 |
const quint8 a = src->alpha(); |
|
4610 |
if (a == 0xff) { |
|
4611 |
*dest = DST(*src); |
|
4612 |
} else if (a > 0) { |
|
4613 |
*dest = DST(*src).truncedAlpha() + dest->byte_mul(DST::ialpha(a)); |
|
4614 |
} |
|
4615 |
++dest; |
|
4616 |
++src; |
|
4617 |
--length; |
|
4618 |
} |
|
4619 |
||
4620 |
while (length >= 4) { |
|
4621 |
blend_sourceOver_4(dest, src); |
|
4622 |
length -= 4; |
|
4623 |
src += 4; |
|
4624 |
dest += 4; |
|
4625 |
} |
|
4626 |
||
4627 |
// tail |
|
4628 |
while (length--) { |
|
4629 |
const quint8 a = src->alpha(); |
|
4630 |
if (a == 0xff) { |
|
4631 |
*dest = DST(*src); |
|
4632 |
} else if (a > 0) { |
|
4633 |
*dest = DST(*src).truncedAlpha() + dest->byte_mul(DST::ialpha(a)); |
|
4634 |
} |
|
4635 |
++dest; |
|
4636 |
++src; |
|
4637 |
} |
|
4638 |
} |
|
4639 |
} |
|
4640 |
||
4641 |
template <class DST, class SRC> |
|
4642 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4643 |
void QT_FASTCALL blendUntransformed(int count, const QSpan *spans, void *userData) |
|
4644 |
{ |
|
4645 |
QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
4646 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
4647 |
||
4648 |
if (mode != QPainter::CompositionMode_SourceOver && |
|
4649 |
mode != QPainter::CompositionMode_Source) |
|
4650 |
{ |
|
4651 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
4652 |
return; |
|
4653 |
} |
|
4654 |
||
4655 |
const bool modeSource = !SRC::hasAlpha() || |
|
4656 |
mode == QPainter::CompositionMode_Source; |
|
4657 |
const int image_width = data->texture.width; |
|
4658 |
const int image_height = data->texture.height; |
|
4659 |
int xoff = -qRound(-data->dx); |
|
4660 |
int yoff = -qRound(-data->dy); |
|
4661 |
||
4662 |
while (count--) { |
|
4663 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
4664 |
if (coverage == 0) { |
|
4665 |
++spans; |
|
4666 |
continue; |
|
4667 |
} |
|
4668 |
||
4669 |
int x = spans->x; |
|
4670 |
int length = spans->len; |
|
4671 |
int sx = xoff + x; |
|
4672 |
int sy = yoff + spans->y; |
|
4673 |
if (sy >= 0 && sy < image_height && sx < image_width) { |
|
4674 |
if (sx < 0) { |
|
4675 |
x -= sx; |
|
4676 |
length += sx; |
|
4677 |
sx = 0; |
|
4678 |
} |
|
4679 |
if (sx + length > image_width) |
|
4680 |
length = image_width - sx; |
|
4681 |
if (length > 0) { |
|
4682 |
DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x; |
|
4683 |
const SRC *src = (SRC*)data->texture.scanLine(sy) + sx; |
|
4684 |
if (modeSource && coverage == 255) { |
|
4685 |
qt_memconvert<DST, SRC>(dest, src, length); |
|
4686 |
} else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && length >= 3 && |
|
4687 |
(quintptr(dest) & 3) == (quintptr(src) & 3)) |
|
4688 |
{ |
|
4689 |
blendUntransformed_dest24(dest, src, coverage, length); |
|
4690 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && length >= 3 && |
|
4691 |
(quintptr(dest) & 3) == (quintptr(src) & 3)) |
|
4692 |
{ |
|
4693 |
blendUntransformed_dest16(dest, src, coverage, length); |
|
4694 |
} else { |
|
4695 |
blendUntransformed_unaligned(dest, src, coverage, length); |
|
4696 |
} |
|
4697 |
} |
|
4698 |
} |
|
4699 |
++spans; |
|
4700 |
} |
|
4701 |
} |
|
4702 |
||
4703 |
static void blend_untransformed_rgb888(int count, const QSpan *spans, |
|
4704 |
void *userData) |
|
4705 |
{ |
|
4706 |
#if defined(QT_QWS_DEPTH_24) |
|
4707 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4708 |
||
4709 |
if (data->texture.format == QImage::Format_RGB888) |
|
4710 |
blendUntransformed<qrgb888, qrgb888>(count, spans, userData); |
|
4711 |
else |
|
4712 |
#endif |
|
4713 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4714 |
} |
|
4715 |
||
4716 |
static void blend_untransformed_argb6666(int count, const QSpan *spans, |
|
4717 |
void *userData) |
|
4718 |
{ |
|
4719 |
#if defined(QT_QWS_DEPTH_18) |
|
4720 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4721 |
||
4722 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
4723 |
blendUntransformed<qargb6666, qargb6666>(count, spans, userData); |
|
4724 |
else if (data->texture.format == QImage::Format_RGB666) |
|
4725 |
blendUntransformed<qargb6666, qrgb666>(count, spans, userData); |
|
4726 |
else |
|
4727 |
#endif |
|
4728 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4729 |
} |
|
4730 |
||
4731 |
static void blend_untransformed_rgb666(int count, const QSpan *spans, |
|
4732 |
void *userData) |
|
4733 |
{ |
|
4734 |
#if defined(QT_QWS_DEPTH_18) |
|
4735 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4736 |
||
4737 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
4738 |
blendUntransformed<qrgb666, qargb6666>(count, spans, userData); |
|
4739 |
else if (data->texture.format == QImage::Format_RGB666) |
|
4740 |
blendUntransformed<qrgb666, qrgb666>(count, spans, userData); |
|
4741 |
else |
|
4742 |
#endif |
|
4743 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4744 |
} |
|
4745 |
||
4746 |
static void blend_untransformed_argb8565(int count, const QSpan *spans, |
|
4747 |
void *userData) |
|
4748 |
{ |
|
4749 |
#if defined(QT_QWS_DEPTH_16) |
|
4750 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4751 |
||
4752 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
4753 |
blendUntransformed<qargb8565, qargb8565>(count, spans, userData); |
|
4754 |
else if (data->texture.format == QImage::Format_RGB16) |
|
4755 |
blendUntransformed<qargb8565, qrgb565>(count, spans, userData); |
|
4756 |
else |
|
4757 |
#endif |
|
4758 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4759 |
} |
|
4760 |
||
4761 |
static void blend_untransformed_rgb565(int count, const QSpan *spans, |
|
4762 |
void *userData) |
|
4763 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4764 |
#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) |
0 | 4765 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
4766 |
||
4767 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
4768 |
blendUntransformed<qrgb565, qargb8565>(count, spans, userData); |
|
4769 |
else if (data->texture.format == QImage::Format_RGB16) |
|
4770 |
blendUntransformed<qrgb565, qrgb565>(count, spans, userData); |
|
4771 |
else |
|
4772 |
#endif |
|
4773 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4774 |
} |
|
4775 |
||
4776 |
static void blend_untransformed_argb8555(int count, const QSpan *spans, |
|
4777 |
void *userData) |
|
4778 |
{ |
|
4779 |
#if defined(QT_QWS_DEPTH_15) |
|
4780 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4781 |
||
4782 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
4783 |
blendUntransformed<qargb8555, qargb8555>(count, spans, userData); |
|
4784 |
else if (data->texture.format == QImage::Format_RGB555) |
|
4785 |
blendUntransformed<qargb8555, qrgb555>(count, spans, userData); |
|
4786 |
else |
|
4787 |
#endif |
|
4788 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4789 |
} |
|
4790 |
||
4791 |
static void blend_untransformed_rgb555(int count, const QSpan *spans, |
|
4792 |
void *userData) |
|
4793 |
{ |
|
4794 |
#if defined(QT_QWS_DEPTH_15) |
|
4795 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4796 |
||
4797 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
4798 |
blendUntransformed<qrgb555, qargb8555>(count, spans, userData); |
|
4799 |
else if (data->texture.format == QImage::Format_RGB555) |
|
4800 |
blendUntransformed<qrgb555, qrgb555>(count, spans, userData); |
|
4801 |
else |
|
4802 |
#endif |
|
4803 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4804 |
} |
|
4805 |
||
4806 |
static void blend_untransformed_argb4444(int count, const QSpan *spans, |
|
4807 |
void *userData) |
|
4808 |
{ |
|
4809 |
#if defined(QT_QWS_DEPTH_12) |
|
4810 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4811 |
||
4812 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
4813 |
blendUntransformed<qargb4444, qargb4444>(count, spans, userData); |
|
4814 |
else if (data->texture.format == QImage::Format_RGB444) |
|
4815 |
blendUntransformed<qargb4444, qrgb444>(count, spans, userData); |
|
4816 |
else |
|
4817 |
#endif |
|
4818 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4819 |
} |
|
4820 |
||
4821 |
static void blend_untransformed_rgb444(int count, const QSpan *spans, |
|
4822 |
void *userData) |
|
4823 |
{ |
|
4824 |
#if defined(QT_QWS_DEPTH_12) |
|
4825 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4826 |
||
4827 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
4828 |
blendUntransformed<qrgb444, qargb4444>(count, spans, userData); |
|
4829 |
else if (data->texture.format == QImage::Format_RGB444) |
|
4830 |
blendUntransformed<qrgb444, qrgb444>(count, spans, userData); |
|
4831 |
else |
|
4832 |
#endif |
|
4833 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4834 |
} |
|
4835 |
||
4836 |
template <SpanMethod spanMethod> |
|
4837 |
Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_generic(int count, const QSpan *spans, void *userData) |
|
4838 |
{ |
|
4839 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4840 |
||
4841 |
uint buffer[buffer_size]; |
|
4842 |
uint src_buffer[buffer_size]; |
|
4843 |
Operator op = getOperator(data, spans, count); |
|
4844 |
||
4845 |
const int image_width = data->texture.width; |
|
4846 |
const int image_height = data->texture.height; |
|
4847 |
int xoff = -qRound(-data->dx) % image_width; |
|
4848 |
int yoff = -qRound(-data->dy) % image_height; |
|
4849 |
||
4850 |
if (xoff < 0) |
|
4851 |
xoff += image_width; |
|
4852 |
if (yoff < 0) |
|
4853 |
yoff += image_height; |
|
4854 |
||
4855 |
while (count--) { |
|
4856 |
int x = spans->x; |
|
4857 |
int length = spans->len; |
|
4858 |
int sx = (xoff + spans->x) % image_width; |
|
4859 |
int sy = (spans->y + yoff) % image_height; |
|
4860 |
if (sx < 0) |
|
4861 |
sx += image_width; |
|
4862 |
if (sy < 0) |
|
4863 |
sy += image_height; |
|
4864 |
||
4865 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
4866 |
while (length) { |
|
4867 |
int l = qMin(image_width - sx, length); |
|
4868 |
if (buffer_size < l) |
|
4869 |
l = buffer_size; |
|
4870 |
const uint *src = op.src_fetch(src_buffer, &op, data, sy, sx, l); |
|
4871 |
if (spanMethod == RegularSpans) { |
|
4872 |
uint *dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer; |
|
4873 |
op.func(dest, src, l, coverage); |
|
4874 |
if (op.dest_store) |
|
4875 |
op.dest_store(data->rasterBuffer, x, spans->y, dest, l); |
|
4876 |
} else { |
|
4877 |
drawBufferSpan(data, src, l, x, spans->y, l, |
|
4878 |
coverage); |
|
4879 |
} |
|
4880 |
x += l; |
|
4881 |
sx += l; |
|
4882 |
length -= l; |
|
4883 |
if (sx >= image_width) |
|
4884 |
sx = 0; |
|
4885 |
} |
|
4886 |
++spans; |
|
4887 |
} |
|
4888 |
} |
|
4889 |
||
4890 |
template <SpanMethod spanMethod> |
|
4891 |
Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_argb(int count, const QSpan *spans, void *userData) |
|
4892 |
{ |
|
4893 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4894 |
if (data->texture.format != QImage::Format_ARGB32_Premultiplied |
|
4895 |
&& data->texture.format != QImage::Format_RGB32) { |
|
4896 |
blend_tiled_generic<spanMethod>(count, spans, userData); |
|
4897 |
return; |
|
4898 |
} |
|
4899 |
||
4900 |
Operator op = getOperator(data, spans, count); |
|
4901 |
||
4902 |
int image_width = data->texture.width; |
|
4903 |
int image_height = data->texture.height; |
|
4904 |
int xoff = -qRound(-data->dx) % image_width; |
|
4905 |
int yoff = -qRound(-data->dy) % image_height; |
|
4906 |
||
4907 |
if (xoff < 0) |
|
4908 |
xoff += image_width; |
|
4909 |
if (yoff < 0) |
|
4910 |
yoff += image_height; |
|
4911 |
||
4912 |
while (count--) { |
|
4913 |
int x = spans->x; |
|
4914 |
int length = spans->len; |
|
4915 |
int sx = (xoff + spans->x) % image_width; |
|
4916 |
int sy = (spans->y + yoff) % image_height; |
|
4917 |
if (sx < 0) |
|
4918 |
sx += image_width; |
|
4919 |
if (sy < 0) |
|
4920 |
sy += image_height; |
|
4921 |
||
4922 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
4923 |
while (length) { |
|
4924 |
int l = qMin(image_width - sx, length); |
|
4925 |
if (buffer_size < l) |
|
4926 |
l = buffer_size; |
|
4927 |
const uint *src = (uint *)data->texture.scanLine(sy) + sx; |
|
4928 |
if (spanMethod == RegularSpans) { |
|
4929 |
uint *dest = ((uint *)data->rasterBuffer->scanLine(spans->y)) + x; |
|
4930 |
op.func(dest, src, l, coverage); |
|
4931 |
} else { |
|
4932 |
drawBufferSpan(data, src, buffer_size, |
|
4933 |
x, spans->y, l, coverage); |
|
4934 |
} |
|
4935 |
x += l; |
|
4936 |
length -= l; |
|
4937 |
sx = 0; |
|
4938 |
} |
|
4939 |
++spans; |
|
4940 |
} |
|
4941 |
} |
|
4942 |
||
4943 |
template <class DST, class SRC> |
|
4944 |
Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void *userData) |
|
4945 |
{ |
|
4946 |
QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
4947 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
4948 |
||
4949 |
if (mode != QPainter::CompositionMode_SourceOver && |
|
4950 |
mode != QPainter::CompositionMode_Source) |
|
4951 |
{ |
|
4952 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
4953 |
return; |
|
4954 |
} |
|
4955 |
||
4956 |
const bool modeSource = !SRC::hasAlpha() || |
|
4957 |
mode == QPainter::CompositionMode_Source; |
|
4958 |
const int image_width = data->texture.width; |
|
4959 |
const int image_height = data->texture.height; |
|
4960 |
int xoff = -qRound(-data->dx) % image_width; |
|
4961 |
int yoff = -qRound(-data->dy) % image_height; |
|
4962 |
||
4963 |
if (xoff < 0) |
|
4964 |
xoff += image_width; |
|
4965 |
if (yoff < 0) |
|
4966 |
yoff += image_height; |
|
4967 |
||
4968 |
while (count--) { |
|
4969 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
4970 |
if (coverage == 0) { |
|
4971 |
++spans; |
|
4972 |
continue; |
|
4973 |
} |
|
4974 |
||
4975 |
int x = spans->x; |
|
4976 |
int length = spans->len; |
|
4977 |
int sx = (xoff + spans->x) % image_width; |
|
4978 |
int sy = (spans->y + yoff) % image_height; |
|
4979 |
if (sx < 0) |
|
4980 |
sx += image_width; |
|
4981 |
if (sy < 0) |
|
4982 |
sy += image_height; |
|
4983 |
||
4984 |
if (modeSource && coverage == 255) { |
|
4985 |
// Copy the first texture block |
|
4986 |
length = qMin(image_width,length); |
|
4987 |
int tx = x; |
|
4988 |
while (length) { |
|
4989 |
int l = qMin(image_width - sx, length); |
|
4990 |
if (buffer_size < l) |
|
4991 |
l = buffer_size; |
|
4992 |
DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + tx; |
|
4993 |
const SRC *src = (SRC*)data->texture.scanLine(sy) + sx; |
|
4994 |
||
4995 |
qt_memconvert<DST, SRC>(dest, src, l); |
|
4996 |
length -= l; |
|
4997 |
tx += l; |
|
4998 |
sx = 0; |
|
4999 |
} |
|
5000 |
||
5001 |
// Now use the rasterBuffer as the source of the texture, |
|
5002 |
// We can now progressively copy larger blocks |
|
5003 |
// - Less cpu time in code figuring out what to copy |
|
5004 |
// We are dealing with one block of data |
|
5005 |
// - More likely to fit in the cache |
|
5006 |
// - can use memcpy |
|
5007 |
int copy_image_width = qMin(image_width, int(spans->len)); |
|
5008 |
length = spans->len - copy_image_width; |
|
5009 |
DST *src = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x; |
|
5010 |
DST *dest = src + copy_image_width; |
|
5011 |
while (copy_image_width < length) { |
|
5012 |
qt_memconvert(dest, src, copy_image_width); |
|
5013 |
dest += copy_image_width; |
|
5014 |
length -= copy_image_width; |
|
5015 |
copy_image_width *= 2; |
|
5016 |
} |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5017 |
if (length > 0) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5018 |
qt_memconvert(dest, src, length); |
0 | 5019 |
} else { |
5020 |
while (length) { |
|
5021 |
int l = qMin(image_width - sx, length); |
|
5022 |
if (buffer_size < l) |
|
5023 |
l = buffer_size; |
|
5024 |
DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x; |
|
5025 |
const SRC *src = (SRC*)data->texture.scanLine(sy) + sx; |
|
5026 |
if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && |
|
5027 |
(quintptr(dest) & 3) == (quintptr(src) & 3)) |
|
5028 |
{ |
|
5029 |
blendUntransformed_dest24(dest, src, coverage, l); |
|
5030 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
5031 |
(quintptr(dest) & 3) == (quintptr(src) & 3)) |
|
5032 |
{ |
|
5033 |
blendUntransformed_dest16(dest, src, coverage, l); |
|
5034 |
} else { |
|
5035 |
blendUntransformed_unaligned(dest, src, coverage, l); |
|
5036 |
} |
|
5037 |
||
5038 |
x += l; |
|
5039 |
length -= l; |
|
5040 |
sx = 0; |
|
5041 |
} |
|
5042 |
} |
|
5043 |
++spans; |
|
5044 |
} |
|
5045 |
} |
|
5046 |
||
5047 |
static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData) |
|
5048 |
{ |
|
5049 |
#if defined(QT_QWS_DEPTH_24) |
|
5050 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5051 |
||
5052 |
if (data->texture.format == QImage::Format_RGB888) |
|
5053 |
blendTiled<qrgb888, qrgb888>(count, spans, userData); |
|
5054 |
else |
|
5055 |
#endif |
|
5056 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5057 |
} |
|
5058 |
||
5059 |
static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData) |
|
5060 |
{ |
|
5061 |
#if defined(QT_QWS_DEPTH_18) |
|
5062 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5063 |
||
5064 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
5065 |
blendTiled<qargb6666, qargb6666>(count, spans, userData); |
|
5066 |
else if (data->texture.format == QImage::Format_RGB666) |
|
5067 |
blendTiled<qargb6666, qrgb666>(count, spans, userData); |
|
5068 |
else |
|
5069 |
#endif |
|
5070 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5071 |
} |
|
5072 |
||
5073 |
static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData) |
|
5074 |
{ |
|
5075 |
#if defined(QT_QWS_DEPTH_18) |
|
5076 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5077 |
||
5078 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
5079 |
blendTiled<qrgb666, qargb6666>(count, spans, userData); |
|
5080 |
else if (data->texture.format == QImage::Format_RGB666) |
|
5081 |
blendTiled<qrgb666, qrgb666>(count, spans, userData); |
|
5082 |
else |
|
5083 |
#endif |
|
5084 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5085 |
} |
|
5086 |
||
5087 |
static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData) |
|
5088 |
{ |
|
5089 |
#if defined(QT_QWS_DEPTH_16) |
|
5090 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5091 |
||
5092 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
5093 |
blendTiled<qargb8565, qargb8565>(count, spans, userData); |
|
5094 |
else if (data->texture.format == QImage::Format_RGB16) |
|
5095 |
blendTiled<qargb8565, qrgb565>(count, spans, userData); |
|
5096 |
else |
|
5097 |
#endif |
|
5098 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5099 |
} |
|
5100 |
||
5101 |
static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) |
|
5102 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5103 |
#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) |
0 | 5104 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
5105 |
||
5106 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
5107 |
blendTiled<qrgb565, qargb8565>(count, spans, userData); |
|
5108 |
else if (data->texture.format == QImage::Format_RGB16) |
|
5109 |
blendTiled<qrgb565, qrgb565>(count, spans, userData); |
|
5110 |
else |
|
5111 |
#endif |
|
5112 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5113 |
} |
|
5114 |
||
5115 |
static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData) |
|
5116 |
{ |
|
5117 |
#if defined(QT_QWS_DEPTH_15) |
|
5118 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5119 |
||
5120 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
5121 |
blendTiled<qargb8555, qargb8555>(count, spans, userData); |
|
5122 |
else if (data->texture.format == QImage::Format_RGB555) |
|
5123 |
blendTiled<qargb8555, qrgb555>(count, spans, userData); |
|
5124 |
else |
|
5125 |
#endif |
|
5126 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5127 |
} |
|
5128 |
||
5129 |
static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData) |
|
5130 |
{ |
|
5131 |
#if defined(QT_QWS_DEPTH_15) |
|
5132 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5133 |
||
5134 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
5135 |
blendTiled<qrgb555, qargb8555>(count, spans, userData); |
|
5136 |
else if (data->texture.format == QImage::Format_RGB555) |
|
5137 |
blendTiled<qrgb555, qrgb555>(count, spans, userData); |
|
5138 |
else |
|
5139 |
#endif |
|
5140 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5141 |
} |
|
5142 |
||
5143 |
static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData) |
|
5144 |
{ |
|
5145 |
#if defined(QT_QWS_DEPTH_12) |
|
5146 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5147 |
||
5148 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
5149 |
blendTiled<qargb4444, qargb4444>(count, spans, userData); |
|
5150 |
else if (data->texture.format == QImage::Format_RGB444) |
|
5151 |
blendTiled<qargb4444, qrgb444>(count, spans, userData); |
|
5152 |
else |
|
5153 |
#endif |
|
5154 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5155 |
} |
|
5156 |
||
5157 |
static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData) |
|
5158 |
{ |
|
5159 |
#if defined(QT_QWS_DEPTH_12) |
|
5160 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5161 |
||
5162 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
5163 |
blendTiled<qrgb444, qargb4444>(count, spans, userData); |
|
5164 |
else if (data->texture.format == QImage::Format_RGB444) |
|
5165 |
blendTiled<qrgb444, qrgb444>(count, spans, userData); |
|
5166 |
else |
|
5167 |
#endif |
|
5168 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5169 |
} |
|
5170 |
||
5171 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5172 |
template <SpanMethod spanMethod, TextureBlendType blendType> /* blendType must be either BlendTransformedBilinear or BlendTransformedBilinearTiled */ |
0 | 5173 |
Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const QSpan *spans, void *userData) |
5174 |
{ |
|
5175 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5176 |
if (data->texture.format != QImage::Format_ARGB32_Premultiplied |
|
5177 |
&& data->texture.format != QImage::Format_RGB32) { |
|
5178 |
blend_src_generic<spanMethod>(count, spans, userData); |
|
5179 |
return; |
|
5180 |
} |
|
5181 |
||
5182 |
CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; |
|
5183 |
uint buffer[buffer_size]; |
|
5184 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5185 |
const int image_x1 = data->texture.x1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5186 |
const int image_y1 = data->texture.y1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5187 |
const int image_x2 = data->texture.x2; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5188 |
const int image_y2 = data->texture.y2; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5189 |
const int image_width = data->texture.width; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5190 |
const int image_height = data->texture.height; |
0 | 5191 |
const int scanline_offset = data->texture.bytesPerLine / 4; |
5192 |
||
5193 |
if (data->fast_matrix) { |
|
5194 |
// The increment pr x in the scanline |
|
5195 |
int fdx = (int)(data->m11 * fixed_scale); |
|
5196 |
int fdy = (int)(data->m12 * fixed_scale); |
|
5197 |
||
5198 |
while (count--) { |
|
5199 |
void *t = data->rasterBuffer->scanLine(spans->y); |
|
5200 |
||
5201 |
uint *target = ((uint *)t) + spans->x; |
|
5202 |
uint *image_bits = (uint *)data->texture.imageData; |
|
5203 |
||
5204 |
const qreal cx = spans->x + 0.5; |
|
5205 |
const qreal cy = spans->y + 0.5; |
|
5206 |
||
5207 |
int x = int((data->m21 * cy |
|
5208 |
+ data->m11 * cx + data->dx) * fixed_scale) - half_point; |
|
5209 |
int y = int((data->m22 * cy |
|
5210 |
+ data->m12 * cx + data->dy) * fixed_scale) - half_point; |
|
5211 |
||
5212 |
int length = spans->len; |
|
5213 |
const int coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5214 |
while (length) { |
|
5215 |
int l = qMin(length, buffer_size); |
|
5216 |
const uint *end = buffer + l; |
|
5217 |
uint *b = buffer; |
|
5218 |
while (b < end) { |
|
5219 |
int x1 = (x >> 16); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5220 |
int x2; |
0 | 5221 |
int y1 = (y >> 16); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5222 |
int y2; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5223 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5224 |
if (blendType == BlendTransformedBilinearTiled) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5225 |
x1 %= image_width; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5226 |
if (x1 < 0) x1 += image_width; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5227 |
x2 = x1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5228 |
x2 %= image_width; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5229 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5230 |
y1 %= image_height; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5231 |
if (y1 < 0) y1 += image_height; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5232 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5233 |
y2 %= image_height; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5234 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5235 |
Q_ASSERT(x1 >= 0 && x1 < image_width); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5236 |
Q_ASSERT(x2 >= 0 && x2 < image_width); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5237 |
Q_ASSERT(y1 >= 0 && y1 < image_height); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5238 |
Q_ASSERT(y2 >= 0 && y2 < image_height); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5239 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5240 |
if (x1 < image_x1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5241 |
x2 = x1 = image_x1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5242 |
} else if (x1 >= image_x2 - 1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5243 |
x2 = x1 = image_x2 - 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5244 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5245 |
x2 = x1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5246 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5247 |
if (y1 < image_y1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5248 |
y2 = y1 = image_y1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5249 |
} else if (y1 >= image_y2 - 1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5250 |
y2 = y1 = image_y2 - 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5251 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5252 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5253 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5254 |
} |
0 | 5255 |
|
5256 |
int y1_offset = y1 * scanline_offset; |
|
5257 |
int y2_offset = y2 * scanline_offset; |
|
5258 |
||
5259 |
#if defined(Q_IRIX_GCC3_3_WORKAROUND) |
|
5260 |
uint tl = gccBug(image_bits[y1_offset + x1]); |
|
5261 |
uint tr = gccBug(image_bits[y1_offset + x2]); |
|
5262 |
uint bl = gccBug(image_bits[y2_offset + x1]); |
|
5263 |
uint br = gccBug(image_bits[y2_offset + x2]); |
|
5264 |
#else |
|
5265 |
uint tl = image_bits[y1_offset + x1]; |
|
5266 |
uint tr = image_bits[y1_offset + x2]; |
|
5267 |
uint bl = image_bits[y2_offset + x1]; |
|
5268 |
uint br = image_bits[y2_offset + x2]; |
|
5269 |
#endif |
|
5270 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5271 |
int distx = (x & 0x0000ffff) >> 8; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5272 |
int disty = (y & 0x0000ffff) >> 8; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5273 |
int idistx = 256 - distx; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5274 |
int idisty = 256 - disty; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5275 |
|
0 | 5276 |
uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); |
5277 |
uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); |
|
5278 |
*b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); |
|
5279 |
++b; |
|
5280 |
||
5281 |
x += fdx; |
|
5282 |
y += fdy; |
|
5283 |
} |
|
5284 |
if (spanMethod == RegularSpans) |
|
5285 |
func(target, buffer, l, coverage); |
|
5286 |
else |
|
5287 |
drawBufferSpan(data, buffer, buffer_size, |
|
5288 |
spans->x + spans->len - length, |
|
5289 |
spans->y, l, coverage); |
|
5290 |
target += l; |
|
5291 |
length -= l; |
|
5292 |
} |
|
5293 |
++spans; |
|
5294 |
} |
|
5295 |
} else { |
|
5296 |
const qreal fdx = data->m11; |
|
5297 |
const qreal fdy = data->m12; |
|
5298 |
const qreal fdw = data->m13; |
|
5299 |
||
5300 |
while (count--) { |
|
5301 |
void *t = data->rasterBuffer->scanLine(spans->y); |
|
5302 |
||
5303 |
uint *target = ((uint *)t) + spans->x; |
|
5304 |
uint *image_bits = (uint *)data->texture.imageData; |
|
5305 |
||
5306 |
const qreal cx = spans->x + 0.5; |
|
5307 |
const qreal cy = spans->y + 0.5; |
|
5308 |
||
5309 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
5310 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
5311 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
5312 |
||
5313 |
int length = spans->len; |
|
5314 |
const int coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5315 |
while (length) { |
|
5316 |
int l = qMin(length, buffer_size); |
|
5317 |
const uint *end = buffer + l; |
|
5318 |
uint *b = buffer; |
|
5319 |
while (b < end) { |
|
5320 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
5321 |
const qreal px = x * iw - 0.5; |
|
5322 |
const qreal py = y * iw - 0.5; |
|
5323 |
||
5324 |
int x1 = int(px) - (px < 0); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5325 |
int x2; |
0 | 5326 |
int y1 = int(py) - (py < 0); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5327 |
int y2; |
0 | 5328 |
|
5329 |
int distx = int((px - x1) * 256); |
|
5330 |
int disty = int((py - y1) * 256); |
|
5331 |
int idistx = 256 - distx; |
|
5332 |
int idisty = 256 - disty; |
|
5333 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5334 |
if (blendType == BlendTransformedBilinearTiled) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5335 |
x1 %= image_width; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5336 |
if (x1 < 0) x1 += image_width; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5337 |
x2 = x1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5338 |
x2 %= image_width; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5339 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5340 |
y1 %= image_height; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5341 |
if (y1 < 0) y1 += image_height; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5342 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5343 |
y2 %= image_height; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5344 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5345 |
Q_ASSERT(x1 >= 0 && x1 < image_width); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5346 |
Q_ASSERT(x2 >= 0 && x2 < image_width); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5347 |
Q_ASSERT(y1 >= 0 && y1 < image_height); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5348 |
Q_ASSERT(y2 >= 0 && y2 < image_height); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5349 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5350 |
if (x1 < image_x1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5351 |
x2 = x1 = image_x1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5352 |
} else if (x1 >= image_x2 - 1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5353 |
x2 = x1 = image_x2 - 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5354 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5355 |
x2 = x1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5356 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5357 |
if (y1 < image_y1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5358 |
y2 = y1 = image_y1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5359 |
} else if (y1 >= image_y2 - 1) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5360 |
y2 = y1 = image_y2 - 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5361 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5362 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5363 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5364 |
} |
0 | 5365 |
|
5366 |
int y1_offset = y1 * scanline_offset; |
|
5367 |
int y2_offset = y2 * scanline_offset; |
|
5368 |
||
5369 |
#if defined(Q_IRIX_GCC3_3_WORKAROUND) |
|
5370 |
uint tl = gccBug(image_bits[y1_offset + x1]); |
|
5371 |
uint tr = gccBug(image_bits[y1_offset + x2]); |
|
5372 |
uint bl = gccBug(image_bits[y2_offset + x1]); |
|
5373 |
uint br = gccBug(image_bits[y2_offset + x2]); |
|
5374 |
#else |
|
5375 |
uint tl = image_bits[y1_offset + x1]; |
|
5376 |
uint tr = image_bits[y1_offset + x2]; |
|
5377 |
uint bl = image_bits[y2_offset + x1]; |
|
5378 |
uint br = image_bits[y2_offset + x2]; |
|
5379 |
#endif |
|
5380 |
||
5381 |
uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); |
|
5382 |
uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); |
|
5383 |
*b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); |
|
5384 |
++b; |
|
5385 |
||
5386 |
x += fdx; |
|
5387 |
y += fdy; |
|
5388 |
w += fdw; |
|
5389 |
} |
|
5390 |
if (spanMethod == RegularSpans) |
|
5391 |
func(target, buffer, l, coverage); |
|
5392 |
else |
|
5393 |
drawBufferSpan(data, buffer, buffer_size, |
|
5394 |
spans->x + spans->len - length, |
|
5395 |
spans->y, l, coverage); |
|
5396 |
target += l; |
|
5397 |
length -= l; |
|
5398 |
} |
|
5399 |
++spans; |
|
5400 |
} |
|
5401 |
} |
|
5402 |
} |
|
5403 |
||
5404 |
template <class DST, class SRC> |
|
5405 |
Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan *spans, |
|
5406 |
void *userData) |
|
5407 |
{ |
|
5408 |
QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
5409 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
5410 |
||
5411 |
||
5412 |
if (mode != QPainter::CompositionMode_SourceOver) { |
|
5413 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5414 |
return; |
|
5415 |
} |
|
5416 |
||
5417 |
SRC buffer[buffer_size]; |
|
5418 |
||
5419 |
const int src_minx = data->texture.x1; |
|
5420 |
const int src_miny = data->texture.y1; |
|
5421 |
const int src_maxx = data->texture.x2 - 1; |
|
5422 |
const int src_maxy = data->texture.y2 - 1; |
|
5423 |
||
5424 |
if (data->fast_matrix) { |
|
5425 |
// The increment pr x in the scanline |
|
5426 |
const int fdx = (int)(data->m11 * fixed_scale); |
|
5427 |
const int fdy = (int)(data->m12 * fixed_scale); |
|
5428 |
||
5429 |
while (count--) { |
|
5430 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5431 |
if (coverage == 0) { |
|
5432 |
++spans; |
|
5433 |
continue; |
|
5434 |
} |
|
5435 |
||
5436 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
5437 |
+ spans->x; |
|
5438 |
const qreal cx = spans->x + qreal(0.5); |
|
5439 |
const qreal cy = spans->y + qreal(0.5); |
|
5440 |
int x = int((data->m21 * cy |
|
5441 |
+ data->m11 * cx + data->dx) * fixed_scale) - half_point; |
|
5442 |
int y = int((data->m22 * cy |
|
5443 |
+ data->m12 * cx + data->dy) * fixed_scale) - half_point; |
|
5444 |
int length = spans->len; |
|
5445 |
||
5446 |
while (length) { |
|
5447 |
const int l = qMin(length, buffer_size); |
|
5448 |
||
5449 |
const SRC *end = buffer + l; |
|
5450 |
SRC *b = buffer; |
|
5451 |
while (b < end) { |
|
5452 |
int x1 = (x >> 16); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5453 |
int x2; |
0 | 5454 |
int y1 = (y >> 16); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5455 |
int y2; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5456 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5457 |
const int distx = (x & 0x0000ffff) >> 8; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5458 |
const int disty = (y & 0x0000ffff) >> 8; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5459 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5460 |
if (x1 < src_minx) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5461 |
x2 = x1 = src_minx; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5462 |
} else if (x1 >= src_maxx) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5463 |
x2 = x1 = src_maxx; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5464 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5465 |
x2 = x1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5466 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5467 |
if (y1 < src_miny) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5468 |
y2 = y1 = src_miny; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5469 |
} else if (y1 >= src_maxy) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5470 |
y2 = y1 = src_maxy; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5471 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5472 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5473 |
} |
0 | 5474 |
#if 0 |
5475 |
if (x1 == x2) { |
|
5476 |
if (y1 == y2) { |
|
5477 |
*b = ((SRC*)data->texture.scanLine(y1))[x1]; |
|
5478 |
} else { |
|
5479 |
*b = ((SRC*)data->texture.scanLine(y1))[x1]; |
|
5480 |
const SRC t = data->texture.scanLine(y2)[x1]; |
|
5481 |
interpolate_pixel(*b, SRC::ialpha(disty), |
|
5482 |
t, SRC::alpha(disty)); |
|
5483 |
} |
|
5484 |
} else if (y1 == y2) { |
|
5485 |
*b = ((SRC*)data->texture.scanLine(y1))[x1]; |
|
5486 |
const SRC t = ((SRC*)data->texture.scanLine(y1))[x2]; |
|
5487 |
interpolate_pixel(*b, SRC::ialpha(distx), |
|
5488 |
t, SRC::alpha(distx)); |
|
5489 |
} else |
|
5490 |
#endif |
|
5491 |
{ |
|
5492 |
const SRC *src1 = (SRC*)data->texture.scanLine(y1); |
|
5493 |
const SRC *src2 = (SRC*)data->texture.scanLine(y2); |
|
5494 |
SRC tl = src1[x1]; |
|
5495 |
const SRC tr = src1[x2]; |
|
5496 |
SRC bl = src2[x1]; |
|
5497 |
const SRC br = src2[x2]; |
|
5498 |
const quint8 ax = SRC::alpha(distx); |
|
5499 |
const quint8 iax = SRC::ialpha(distx); |
|
5500 |
||
5501 |
interpolate_pixel(tl, iax, tr, ax); |
|
5502 |
interpolate_pixel(bl, iax, br, ax); |
|
5503 |
interpolate_pixel(tl, SRC::ialpha(disty), |
|
5504 |
bl, SRC::alpha(disty)); |
|
5505 |
*b = tl; |
|
5506 |
} |
|
5507 |
++b; |
|
5508 |
||
5509 |
x += fdx; |
|
5510 |
y += fdy; |
|
5511 |
} |
|
5512 |
||
5513 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
5514 |
qt_memconvert(dest, buffer, l); |
|
5515 |
} else if (sizeof(DST) == 3 && l >= 4 && |
|
5516 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
5517 |
{ |
|
5518 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
5519 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
5520 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
5521 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
5522 |
} else { |
|
5523 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
5524 |
} |
|
5525 |
||
5526 |
dest += l; |
|
5527 |
length -= l; |
|
5528 |
} |
|
5529 |
++spans; |
|
5530 |
} |
|
5531 |
} else { |
|
5532 |
const qreal fdx = data->m11; |
|
5533 |
const qreal fdy = data->m12; |
|
5534 |
const qreal fdw = data->m13; |
|
5535 |
||
5536 |
while (count--) { |
|
5537 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5538 |
if (coverage == 0) { |
|
5539 |
++spans; |
|
5540 |
continue; |
|
5541 |
} |
|
5542 |
||
5543 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
5544 |
+ spans->x; |
|
5545 |
||
5546 |
const qreal cx = spans->x + qreal(0.5); |
|
5547 |
const qreal cy = spans->y + qreal(0.5); |
|
5548 |
||
5549 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
5550 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
5551 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
5552 |
||
5553 |
int length = spans->len; |
|
5554 |
while (length) { |
|
5555 |
const int l = qMin(length, buffer_size); |
|
5556 |
const SRC *end = buffer + l; |
|
5557 |
SRC *b = buffer; |
|
5558 |
while (b < end) { |
|
5559 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
5560 |
const qreal px = x * iw - qreal(0.5); |
|
5561 |
const qreal py = y * iw - qreal(0.5); |
|
5562 |
||
5563 |
int x1 = int(px) - (px < 0); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5564 |
int x2; |
0 | 5565 |
int y1 = int(py) - (py < 0); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5566 |
int y2; |
0 | 5567 |
|
5568 |
const int distx = int((px - x1) * 256); |
|
5569 |
const int disty = int((py - y1) * 256); |
|
5570 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5571 |
if (x1 < src_minx) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5572 |
x2 = x1 = src_minx; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5573 |
} else if (x1 >= src_maxx) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5574 |
x2 = x1 = src_maxx; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5575 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5576 |
x2 = x1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5577 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5578 |
if (y1 < src_miny) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5579 |
y2 = y1 = src_miny; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5580 |
} else if (y1 >= src_maxy) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5581 |
y2 = y1 = src_maxy; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5582 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5583 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5584 |
} |
0 | 5585 |
|
5586 |
const SRC *src1 = (SRC*)data->texture.scanLine(y1); |
|
5587 |
const SRC *src2 = (SRC*)data->texture.scanLine(y2); |
|
5588 |
SRC tl = src1[x1]; |
|
5589 |
const SRC tr = src1[x2]; |
|
5590 |
SRC bl = src2[x1]; |
|
5591 |
const SRC br = src2[x2]; |
|
5592 |
const quint8 ax = SRC::alpha(distx); |
|
5593 |
const quint8 iax = SRC::ialpha(distx); |
|
5594 |
||
5595 |
interpolate_pixel(tl, iax, tr, ax); |
|
5596 |
interpolate_pixel(bl, iax, br, ax); |
|
5597 |
interpolate_pixel(tl, SRC::ialpha(disty), |
|
5598 |
bl, SRC::alpha(disty)); |
|
5599 |
*b = tl; |
|
5600 |
++b; |
|
5601 |
||
5602 |
x += fdx; |
|
5603 |
y += fdy; |
|
5604 |
w += fdw; |
|
5605 |
} |
|
5606 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
5607 |
qt_memconvert(dest, buffer, l); |
|
5608 |
} else if (sizeof(DST) == 3 && l >= 4 && |
|
5609 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
5610 |
{ |
|
5611 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
5612 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
5613 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
5614 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
5615 |
} else { |
|
5616 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
5617 |
} |
|
5618 |
||
5619 |
dest += l; |
|
5620 |
length -= l; |
|
5621 |
} |
|
5622 |
++spans; |
|
5623 |
} |
|
5624 |
} |
|
5625 |
} |
|
5626 |
||
5627 |
static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, void *userData) |
|
5628 |
{ |
|
5629 |
#if defined(QT_QWS_DEPTH_24) |
|
5630 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5631 |
||
5632 |
if (data->texture.format == QImage::Format_RGB888) |
|
5633 |
blendTransformedBilinear<qrgb888, qrgb888>(count, spans, userData); |
|
5634 |
else |
|
5635 |
#endif |
|
5636 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5637 |
} |
|
5638 |
||
5639 |
static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, void *userData) |
|
5640 |
{ |
|
5641 |
#if defined(QT_QWS_DEPTH_18) |
|
5642 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5643 |
||
5644 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
5645 |
blendTransformedBilinear<qargb6666, qargb6666>(count, spans, userData); |
|
5646 |
else if (data->texture.format == QImage::Format_RGB666) |
|
5647 |
blendTransformedBilinear<qargb6666, qrgb666>(count, spans, userData); |
|
5648 |
else |
|
5649 |
#endif |
|
5650 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5651 |
} |
|
5652 |
||
5653 |
static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, void *userData) |
|
5654 |
{ |
|
5655 |
#if defined(QT_QWS_DEPTH_18) |
|
5656 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5657 |
||
5658 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
5659 |
blendTransformedBilinear<qrgb666, qargb6666>(count, spans, userData); |
|
5660 |
else if (data->texture.format == QImage::Format_RGB666) |
|
5661 |
blendTransformedBilinear<qrgb666, qrgb666>(count, spans, userData); |
|
5662 |
else |
|
5663 |
#endif |
|
5664 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5665 |
} |
|
5666 |
||
5667 |
static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, void *userData) |
|
5668 |
{ |
|
5669 |
#if defined(QT_QWS_DEPTH_16) |
|
5670 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5671 |
||
5672 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
5673 |
blendTransformedBilinear<qargb8565, qargb8565>(count, spans, userData); |
|
5674 |
else if (data->texture.format == QImage::Format_RGB16) |
|
5675 |
blendTransformedBilinear<qargb8565, qrgb565>(count, spans, userData); |
|
5676 |
else |
|
5677 |
#endif |
|
5678 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5679 |
} |
|
5680 |
||
5681 |
static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans, |
|
5682 |
void *userData) |
|
5683 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5684 |
#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) |
0 | 5685 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
5686 |
||
5687 |
if (data->texture.format == QImage::Format_RGB16) |
|
5688 |
blendTransformedBilinear<qrgb565, qrgb565>(count, spans, userData); |
|
5689 |
else if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
5690 |
blendTransformedBilinear<qrgb565, qargb8565>(count, spans, userData); |
|
5691 |
else |
|
5692 |
#endif |
|
5693 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5694 |
} |
|
5695 |
||
5696 |
static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, void *userData) |
|
5697 |
{ |
|
5698 |
#if defined(QT_QWS_DEPTH_15) |
|
5699 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5700 |
||
5701 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
5702 |
blendTransformedBilinear<qargb8555, qargb8555>(count, spans, userData); |
|
5703 |
else if (data->texture.format == QImage::Format_RGB555) |
|
5704 |
blendTransformedBilinear<qargb8555, qrgb555>(count, spans, userData); |
|
5705 |
else |
|
5706 |
#endif |
|
5707 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5708 |
} |
|
5709 |
||
5710 |
static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, void *userData) |
|
5711 |
{ |
|
5712 |
#if defined(QT_QWS_DEPTH_15) |
|
5713 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5714 |
||
5715 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
5716 |
blendTransformedBilinear<qrgb555, qargb8555>(count, spans, userData); |
|
5717 |
else if (data->texture.format == QImage::Format_RGB555) |
|
5718 |
blendTransformedBilinear<qrgb555, qrgb555>(count, spans, userData); |
|
5719 |
else |
|
5720 |
#endif |
|
5721 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5722 |
} |
|
5723 |
||
5724 |
static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, void *userData) |
|
5725 |
{ |
|
5726 |
#if defined(QT_QWS_DEPTH_12) |
|
5727 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5728 |
||
5729 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
5730 |
blendTransformedBilinear<qargb4444, qargb4444>(count, spans, userData); |
|
5731 |
else if (data->texture.format == QImage::Format_RGB444) |
|
5732 |
blendTransformedBilinear<qargb4444, qrgb444>(count, spans, userData); |
|
5733 |
else |
|
5734 |
#endif |
|
5735 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5736 |
} |
|
5737 |
||
5738 |
static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, void *userData) |
|
5739 |
{ |
|
5740 |
#if defined(QT_QWS_DEPTH_12) |
|
5741 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5742 |
||
5743 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
5744 |
blendTransformedBilinear<qrgb444, qargb4444>(count, spans, userData); |
|
5745 |
else if (data->texture.format == QImage::Format_RGB444) |
|
5746 |
blendTransformedBilinear<qrgb444, qrgb444>(count, spans, userData); |
|
5747 |
else |
|
5748 |
#endif |
|
5749 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5750 |
} |
|
5751 |
||
5752 |
template <SpanMethod spanMethod> |
|
5753 |
Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_argb(int count, const QSpan *spans, void *userData) |
|
5754 |
{ |
|
5755 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5756 |
if (data->texture.format != QImage::Format_ARGB32_Premultiplied |
|
5757 |
&& data->texture.format != QImage::Format_RGB32) { |
|
5758 |
blend_src_generic<spanMethod>(count, spans, userData); |
|
5759 |
return; |
|
5760 |
} |
|
5761 |
||
5762 |
CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; |
|
5763 |
uint buffer[buffer_size]; |
|
5764 |
||
5765 |
int image_width = data->texture.width; |
|
5766 |
int image_height = data->texture.height; |
|
5767 |
const int scanline_offset = data->texture.bytesPerLine / 4; |
|
5768 |
||
5769 |
if (data->fast_matrix) { |
|
5770 |
// The increment pr x in the scanline |
|
5771 |
int fdx = (int)(data->m11 * fixed_scale); |
|
5772 |
int fdy = (int)(data->m12 * fixed_scale); |
|
5773 |
||
5774 |
while (count--) { |
|
5775 |
void *t = data->rasterBuffer->scanLine(spans->y); |
|
5776 |
||
5777 |
uint *target = ((uint *)t) + spans->x; |
|
5778 |
uint *image_bits = (uint *)data->texture.imageData; |
|
5779 |
||
5780 |
const qreal cx = spans->x + 0.5; |
|
5781 |
const qreal cy = spans->y + 0.5; |
|
5782 |
||
5783 |
int x = int((data->m21 * cy |
|
5784 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
5785 |
int y = int((data->m22 * cy |
|
5786 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
5787 |
||
5788 |
int length = spans->len; |
|
5789 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
5790 |
while (length) { |
|
5791 |
int l = qMin(length, buffer_size); |
|
5792 |
const uint *end = buffer + l; |
|
5793 |
uint *b = buffer; |
|
5794 |
while (b < end) { |
|
5795 |
int px = x >> 16; |
|
5796 |
int py = y >> 16; |
|
5797 |
||
5798 |
bool out = (px < 0) || (px >= image_width) |
|
5799 |
|| (py < 0) || (py >= image_height); |
|
5800 |
||
5801 |
int y_offset = py * scanline_offset; |
|
5802 |
*b = out ? uint(0) : image_bits[y_offset + px]; |
|
5803 |
x += fdx; |
|
5804 |
y += fdy; |
|
5805 |
++b; |
|
5806 |
} |
|
5807 |
if (spanMethod == RegularSpans) |
|
5808 |
func(target, buffer, l, coverage); |
|
5809 |
else |
|
5810 |
drawBufferSpan(data, buffer, buffer_size, |
|
5811 |
spans->x + spans->len - length, |
|
5812 |
spans->y, l, coverage); |
|
5813 |
target += l; |
|
5814 |
length -= l; |
|
5815 |
} |
|
5816 |
++spans; |
|
5817 |
} |
|
5818 |
} else { |
|
5819 |
const qreal fdx = data->m11; |
|
5820 |
const qreal fdy = data->m12; |
|
5821 |
const qreal fdw = data->m13; |
|
5822 |
while (count--) { |
|
5823 |
void *t = data->rasterBuffer->scanLine(spans->y); |
|
5824 |
||
5825 |
uint *target = ((uint *)t) + spans->x; |
|
5826 |
uint *image_bits = (uint *)data->texture.imageData; |
|
5827 |
||
5828 |
const qreal cx = spans->x + 0.5; |
|
5829 |
const qreal cy = spans->y + 0.5; |
|
5830 |
||
5831 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
5832 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
5833 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
5834 |
||
5835 |
int length = spans->len; |
|
5836 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
5837 |
while (length) { |
|
5838 |
int l = qMin(length, buffer_size); |
|
5839 |
const uint *end = buffer + l; |
|
5840 |
uint *b = buffer; |
|
5841 |
while (b < end) { |
|
5842 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
5843 |
const qreal tx = x * iw; |
|
5844 |
const qreal ty = y * iw; |
|
5845 |
const int px = int(tx) - (tx < 0); |
|
5846 |
const int py = int(ty) - (ty < 0); |
|
5847 |
||
5848 |
bool out = (px < 0) || (px >= image_width) |
|
5849 |
|| (py < 0) || (py >= image_height); |
|
5850 |
||
5851 |
int y_offset = py * scanline_offset; |
|
5852 |
*b = out ? uint(0) : image_bits[y_offset + px]; |
|
5853 |
x += fdx; |
|
5854 |
y += fdy; |
|
5855 |
w += fdw; |
|
5856 |
||
5857 |
++b; |
|
5858 |
} |
|
5859 |
if (spanMethod == RegularSpans) |
|
5860 |
func(target, buffer, l, coverage); |
|
5861 |
else |
|
5862 |
drawBufferSpan(data, buffer, buffer_size, |
|
5863 |
spans->x + spans->len - length, |
|
5864 |
spans->y, l, coverage); |
|
5865 |
target += l; |
|
5866 |
length -= l; |
|
5867 |
} |
|
5868 |
++spans; |
|
5869 |
} |
|
5870 |
} |
|
5871 |
} |
|
5872 |
||
5873 |
template <class DST, class SRC> |
|
5874 |
Q_STATIC_TEMPLATE_FUNCTION void blendTransformed(int count, const QSpan *spans, void *userData) |
|
5875 |
{ |
|
5876 |
QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
5877 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
5878 |
||
5879 |
if (mode != QPainter::CompositionMode_SourceOver) { |
|
5880 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5881 |
return; |
|
5882 |
} |
|
5883 |
||
5884 |
SRC buffer[buffer_size]; |
|
5885 |
const int image_width = data->texture.width; |
|
5886 |
const int image_height = data->texture.height; |
|
5887 |
||
5888 |
if (data->fast_matrix) { |
|
5889 |
// The increment pr x in the scanline |
|
5890 |
const int fdx = (int)(data->m11 * fixed_scale); |
|
5891 |
const int fdy = (int)(data->m12 * fixed_scale); |
|
5892 |
||
5893 |
while (count--) { |
|
5894 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5895 |
if (coverage == 0) { |
|
5896 |
++spans; |
|
5897 |
continue; |
|
5898 |
} |
|
5899 |
||
5900 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
5901 |
+ spans->x; |
|
5902 |
const qreal cx = spans->x + qreal(0.5); |
|
5903 |
const qreal cy = spans->y + qreal(0.5); |
|
5904 |
int x = int((data->m21 * cy |
|
5905 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
5906 |
int y = int((data->m22 * cy |
|
5907 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
5908 |
int length = spans->len; |
|
5909 |
||
5910 |
while (length) { |
|
5911 |
const int l = qMin(length, buffer_size); |
|
5912 |
||
5913 |
const SRC *end = buffer + l; |
|
5914 |
SRC *b = buffer; |
|
5915 |
while (b < end) { |
|
5916 |
const int px = (x >> 16); |
|
5917 |
const int py = (y >> 16); |
|
5918 |
||
5919 |
if ((px < 0) || (px >= image_width) || |
|
5920 |
(py < 0) || (py >= image_height)) |
|
5921 |
{ |
|
5922 |
*b = 0; |
|
5923 |
} else { |
|
5924 |
*b = ((SRC*)data->texture.scanLine(py))[px]; |
|
5925 |
} |
|
5926 |
++b; |
|
5927 |
||
5928 |
x += fdx; |
|
5929 |
y += fdy; |
|
5930 |
} |
|
5931 |
||
5932 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
5933 |
qt_memconvert(dest, buffer, l); |
|
5934 |
} else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && |
|
5935 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
5936 |
{ |
|
5937 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
5938 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
5939 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
5940 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
5941 |
} else { |
|
5942 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
5943 |
} |
|
5944 |
||
5945 |
dest += l; |
|
5946 |
length -= l; |
|
5947 |
} |
|
5948 |
++spans; |
|
5949 |
} |
|
5950 |
} else { |
|
5951 |
const qreal fdx = data->m11; |
|
5952 |
const qreal fdy = data->m12; |
|
5953 |
const qreal fdw = data->m13; |
|
5954 |
||
5955 |
while (count--) { |
|
5956 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5957 |
if (coverage == 0) { |
|
5958 |
++spans; |
|
5959 |
continue; |
|
5960 |
} |
|
5961 |
||
5962 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
5963 |
+ spans->x; |
|
5964 |
||
5965 |
const qreal cx = spans->x + qreal(0.5); |
|
5966 |
const qreal cy = spans->y + qreal(0.5); |
|
5967 |
||
5968 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
5969 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
5970 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
5971 |
||
5972 |
int length = spans->len; |
|
5973 |
while (length) { |
|
5974 |
const int l = qMin(length, buffer_size); |
|
5975 |
const SRC *end = buffer + l; |
|
5976 |
SRC *b = buffer; |
|
5977 |
while (b < end) { |
|
5978 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
5979 |
const qreal tx = x * iw; |
|
5980 |
const qreal ty = y * iw; |
|
5981 |
||
5982 |
const int px = int(tx) - (tx < 0); |
|
5983 |
const int py = int(ty) - (ty < 0); |
|
5984 |
||
5985 |
if ((px < 0) || (px >= image_width) || |
|
5986 |
(py < 0) || (py >= image_height)) |
|
5987 |
{ |
|
5988 |
*b = 0; |
|
5989 |
} else { |
|
5990 |
*b = ((SRC*)data->texture.scanLine(py))[px]; |
|
5991 |
} |
|
5992 |
++b; |
|
5993 |
||
5994 |
x += fdx; |
|
5995 |
y += fdy; |
|
5996 |
w += fdw; |
|
5997 |
} |
|
5998 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
5999 |
qt_memconvert(dest, buffer, l); |
|
6000 |
} else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && |
|
6001 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
6002 |
{ |
|
6003 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
6004 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
6005 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
6006 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
6007 |
} else { |
|
6008 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
6009 |
} |
|
6010 |
||
6011 |
dest += l; |
|
6012 |
length -= l; |
|
6013 |
} |
|
6014 |
++spans; |
|
6015 |
} |
|
6016 |
} |
|
6017 |
} |
|
6018 |
||
6019 |
static void blend_transformed_rgb888(int count, const QSpan *spans, |
|
6020 |
void *userData) |
|
6021 |
{ |
|
6022 |
#if defined(QT_QWS_DEPTH_24) |
|
6023 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6024 |
||
6025 |
if (data->texture.format == QImage::Format_RGB888) |
|
6026 |
blendTransformed<qrgb888, qrgb888>(count, spans, userData); |
|
6027 |
else |
|
6028 |
#endif |
|
6029 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6030 |
} |
|
6031 |
||
6032 |
static void blend_transformed_argb6666(int count, const QSpan *spans, |
|
6033 |
void *userData) |
|
6034 |
{ |
|
6035 |
#if defined(QT_QWS_DEPTH_18) |
|
6036 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6037 |
||
6038 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
6039 |
blendTransformed<qargb6666, qargb6666>(count, spans, userData); |
|
6040 |
else if (data->texture.format == QImage::Format_RGB666) |
|
6041 |
blendTransformed<qargb6666, qrgb666>(count, spans, userData); |
|
6042 |
else |
|
6043 |
#endif |
|
6044 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6045 |
} |
|
6046 |
||
6047 |
static void blend_transformed_rgb666(int count, const QSpan *spans, |
|
6048 |
void *userData) |
|
6049 |
{ |
|
6050 |
#if defined(QT_QWS_DEPTH_18) |
|
6051 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6052 |
||
6053 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
6054 |
blendTransformed<qrgb666, qargb6666>(count, spans, userData); |
|
6055 |
else if (data->texture.format == QImage::Format_RGB666) |
|
6056 |
blendTransformed<qrgb666, qrgb666>(count, spans, userData); |
|
6057 |
else |
|
6058 |
#endif |
|
6059 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6060 |
} |
|
6061 |
||
6062 |
static void blend_transformed_argb8565(int count, const QSpan *spans, |
|
6063 |
void *userData) |
|
6064 |
{ |
|
6065 |
#if defined(QT_QWS_DEPTH_16) |
|
6066 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6067 |
||
6068 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
6069 |
blendTransformed<qargb8565, qargb8565>(count, spans, userData); |
|
6070 |
else if (data->texture.format == QImage::Format_RGB16) |
|
6071 |
blendTransformed<qargb8565, qrgb565>(count, spans, userData); |
|
6072 |
else |
|
6073 |
#endif |
|
6074 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6075 |
} |
|
6076 |
||
6077 |
static void blend_transformed_rgb565(int count, const QSpan *spans, |
|
6078 |
void *userData) |
|
6079 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6080 |
#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) |
0 | 6081 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
6082 |
||
6083 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
6084 |
blendTransformed<qrgb565, qargb8565>(count, spans, userData); |
|
6085 |
else if (data->texture.format == QImage::Format_RGB16) |
|
6086 |
blendTransformed<qrgb565, qrgb565>(count, spans, userData); |
|
6087 |
else |
|
6088 |
#endif |
|
6089 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6090 |
} |
|
6091 |
||
6092 |
static void blend_transformed_argb8555(int count, const QSpan *spans, |
|
6093 |
void *userData) |
|
6094 |
{ |
|
6095 |
#if defined(QT_QWS_DEPTH_15) |
|
6096 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6097 |
||
6098 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
6099 |
blendTransformed<qargb8555, qargb8555>(count, spans, userData); |
|
6100 |
else if (data->texture.format == QImage::Format_RGB555) |
|
6101 |
blendTransformed<qargb8555, qrgb555>(count, spans, userData); |
|
6102 |
else |
|
6103 |
#endif |
|
6104 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6105 |
} |
|
6106 |
||
6107 |
static void blend_transformed_rgb555(int count, const QSpan *spans, |
|
6108 |
void *userData) |
|
6109 |
{ |
|
6110 |
#if defined(QT_QWS_DEPTH_15) |
|
6111 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6112 |
||
6113 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
6114 |
blendTransformed<qrgb555, qargb8555>(count, spans, userData); |
|
6115 |
else if (data->texture.format == QImage::Format_RGB555) |
|
6116 |
blendTransformed<qrgb555, qrgb555>(count, spans, userData); |
|
6117 |
else |
|
6118 |
#endif |
|
6119 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6120 |
} |
|
6121 |
||
6122 |
static void blend_transformed_argb4444(int count, const QSpan *spans, |
|
6123 |
void *userData) |
|
6124 |
{ |
|
6125 |
#if defined(QT_QWS_DEPTH_12) |
|
6126 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6127 |
||
6128 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
6129 |
blendTransformed<qargb4444, qargb4444>(count, spans, userData); |
|
6130 |
else if (data->texture.format == QImage::Format_RGB444) |
|
6131 |
blendTransformed<qargb4444, qrgb444>(count, spans, userData); |
|
6132 |
else |
|
6133 |
#endif |
|
6134 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6135 |
} |
|
6136 |
||
6137 |
static void blend_transformed_rgb444(int count, const QSpan *spans, |
|
6138 |
void *userData) |
|
6139 |
{ |
|
6140 |
#if defined(QT_QWS_DEPTH_12) |
|
6141 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6142 |
||
6143 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
6144 |
blendTransformed<qrgb444, qargb4444>(count, spans, userData); |
|
6145 |
else if (data->texture.format == QImage::Format_RGB444) |
|
6146 |
blendTransformed<qrgb444, qrgb444>(count, spans, userData); |
|
6147 |
else |
|
6148 |
#endif |
|
6149 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6150 |
} |
|
6151 |
||
6152 |
template <SpanMethod spanMethod> |
|
6153 |
Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_tiled_argb(int count, const QSpan *spans, void *userData) |
|
6154 |
{ |
|
6155 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6156 |
if (data->texture.format != QImage::Format_ARGB32_Premultiplied |
|
6157 |
&& data->texture.format != QImage::Format_RGB32) { |
|
6158 |
blend_src_generic<spanMethod>(count, spans, userData); |
|
6159 |
return; |
|
6160 |
} |
|
6161 |
||
6162 |
CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; |
|
6163 |
uint buffer[buffer_size]; |
|
6164 |
||
6165 |
int image_width = data->texture.width; |
|
6166 |
int image_height = data->texture.height; |
|
6167 |
const int scanline_offset = data->texture.bytesPerLine / 4; |
|
6168 |
||
6169 |
if (data->fast_matrix) { |
|
6170 |
// The increment pr x in the scanline |
|
6171 |
int fdx = (int)(data->m11 * fixed_scale); |
|
6172 |
int fdy = (int)(data->m12 * fixed_scale); |
|
6173 |
||
6174 |
while (count--) { |
|
6175 |
void *t = data->rasterBuffer->scanLine(spans->y); |
|
6176 |
||
6177 |
uint *target = ((uint *)t) + spans->x; |
|
6178 |
uint *image_bits = (uint *)data->texture.imageData; |
|
6179 |
||
6180 |
const qreal cx = spans->x + 0.5; |
|
6181 |
const qreal cy = spans->y + 0.5; |
|
6182 |
||
6183 |
int x = int((data->m21 * cy |
|
6184 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
6185 |
int y = int((data->m22 * cy |
|
6186 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
6187 |
||
6188 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
6189 |
int length = spans->len; |
|
6190 |
while (length) { |
|
6191 |
int l = qMin(length, buffer_size); |
|
6192 |
const uint *end = buffer + l; |
|
6193 |
uint *b = buffer; |
|
6194 |
while (b < end) { |
|
6195 |
int px = x >> 16; |
|
6196 |
int py = y >> 16; |
|
6197 |
px %= image_width; |
|
6198 |
py %= image_height; |
|
6199 |
if (px < 0) px += image_width; |
|
6200 |
if (py < 0) py += image_height; |
|
6201 |
int y_offset = py * scanline_offset; |
|
6202 |
||
6203 |
Q_ASSERT(px >= 0 && px < image_width); |
|
6204 |
Q_ASSERT(py >= 0 && py < image_height); |
|
6205 |
||
6206 |
*b = image_bits[y_offset + px]; |
|
6207 |
x += fdx; |
|
6208 |
y += fdy; |
|
6209 |
++b; |
|
6210 |
} |
|
6211 |
if (spanMethod == RegularSpans) |
|
6212 |
func(target, buffer, l, coverage); |
|
6213 |
else |
|
6214 |
drawBufferSpan(data, buffer, buffer_size, |
|
6215 |
spans->x + spans->len - length, |
|
6216 |
spans->y, l, coverage); |
|
6217 |
target += l; |
|
6218 |
length -= l; |
|
6219 |
} |
|
6220 |
++spans; |
|
6221 |
} |
|
6222 |
} else { |
|
6223 |
const qreal fdx = data->m11; |
|
6224 |
const qreal fdy = data->m12; |
|
6225 |
const qreal fdw = data->m13; |
|
6226 |
while (count--) { |
|
6227 |
void *t = data->rasterBuffer->scanLine(spans->y); |
|
6228 |
||
6229 |
uint *target = ((uint *)t) + spans->x; |
|
6230 |
uint *image_bits = (uint *)data->texture.imageData; |
|
6231 |
||
6232 |
const qreal cx = spans->x + 0.5; |
|
6233 |
const qreal cy = spans->y + 0.5; |
|
6234 |
||
6235 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
6236 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
6237 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
6238 |
||
6239 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
6240 |
int length = spans->len; |
|
6241 |
while (length) { |
|
6242 |
int l = qMin(length, buffer_size); |
|
6243 |
const uint *end = buffer + l; |
|
6244 |
uint *b = buffer; |
|
6245 |
while (b < end) { |
|
6246 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
6247 |
const qreal tx = x * iw; |
|
6248 |
const qreal ty = y * iw; |
|
6249 |
int px = int(tx) - (tx < 0); |
|
6250 |
int py = int(ty) - (ty < 0); |
|
6251 |
||
6252 |
px %= image_width; |
|
6253 |
py %= image_height; |
|
6254 |
if (px < 0) px += image_width; |
|
6255 |
if (py < 0) py += image_height; |
|
6256 |
int y_offset = py * scanline_offset; |
|
6257 |
||
6258 |
Q_ASSERT(px >= 0 && px < image_width); |
|
6259 |
Q_ASSERT(py >= 0 && py < image_height); |
|
6260 |
||
6261 |
*b = image_bits[y_offset + px]; |
|
6262 |
x += fdx; |
|
6263 |
y += fdy; |
|
6264 |
w += fdw; |
|
6265 |
//force increment to avoid /0 |
|
6266 |
if (!w) { |
|
6267 |
w += fdw; |
|
6268 |
} |
|
6269 |
++b; |
|
6270 |
} |
|
6271 |
if (spanMethod == RegularSpans) |
|
6272 |
func(target, buffer, l, coverage); |
|
6273 |
else |
|
6274 |
drawBufferSpan(data, buffer, buffer_size, |
|
6275 |
spans->x + spans->len - length, |
|
6276 |
spans->y, l, coverage); |
|
6277 |
target += l; |
|
6278 |
length -= l; |
|
6279 |
} |
|
6280 |
++spans; |
|
6281 |
} |
|
6282 |
} |
|
6283 |
} |
|
6284 |
||
6285 |
template <class DST, class SRC> |
|
6286 |
Q_STATIC_TEMPLATE_FUNCTION void blendTransformedTiled(int count, const QSpan *spans, void *userData) |
|
6287 |
{ |
|
6288 |
QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
6289 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
6290 |
||
6291 |
if (mode != QPainter::CompositionMode_SourceOver) { |
|
6292 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6293 |
return; |
|
6294 |
} |
|
6295 |
||
6296 |
SRC buffer[buffer_size]; |
|
6297 |
const int image_width = data->texture.width; |
|
6298 |
const int image_height = data->texture.height; |
|
6299 |
||
6300 |
if (data->fast_matrix) { |
|
6301 |
// The increment pr x in the scanline |
|
6302 |
const int fdx = (int)(data->m11 * fixed_scale); |
|
6303 |
const int fdy = (int)(data->m12 * fixed_scale); |
|
6304 |
||
6305 |
while (count--) { |
|
6306 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
6307 |
if (coverage == 0) { |
|
6308 |
++spans; |
|
6309 |
continue; |
|
6310 |
} |
|
6311 |
||
6312 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
6313 |
+ spans->x; |
|
6314 |
const qreal cx = spans->x + qreal(0.5); |
|
6315 |
const qreal cy = spans->y + qreal(0.5); |
|
6316 |
int x = int((data->m21 * cy |
|
6317 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
6318 |
int y = int((data->m22 * cy |
|
6319 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
6320 |
int length = spans->len; |
|
6321 |
||
6322 |
while (length) { |
|
6323 |
const int l = qMin(length, buffer_size); |
|
6324 |
||
6325 |
const SRC *end = buffer + l; |
|
6326 |
SRC *b = buffer; |
|
6327 |
while (b < end) { |
|
6328 |
int px = (x >> 16) % image_width; |
|
6329 |
int py = (y >> 16) % image_height; |
|
6330 |
||
6331 |
if (px < 0) |
|
6332 |
px += image_width; |
|
6333 |
if (py < 0) |
|
6334 |
py += image_height; |
|
6335 |
||
6336 |
*b = ((SRC*)data->texture.scanLine(py))[px]; |
|
6337 |
++b; |
|
6338 |
||
6339 |
x += fdx; |
|
6340 |
y += fdy; |
|
6341 |
} |
|
6342 |
||
6343 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
6344 |
qt_memconvert(dest, buffer, l); |
|
6345 |
} else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && |
|
6346 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
6347 |
{ |
|
6348 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
6349 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
6350 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
6351 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
6352 |
} else { |
|
6353 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
6354 |
} |
|
6355 |
||
6356 |
dest += l; |
|
6357 |
length -= l; |
|
6358 |
} |
|
6359 |
++spans; |
|
6360 |
} |
|
6361 |
} else { |
|
6362 |
const qreal fdx = data->m11; |
|
6363 |
const qreal fdy = data->m12; |
|
6364 |
const qreal fdw = data->m13; |
|
6365 |
||
6366 |
while (count--) { |
|
6367 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
6368 |
if (coverage == 0) { |
|
6369 |
++spans; |
|
6370 |
continue; |
|
6371 |
} |
|
6372 |
||
6373 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
6374 |
+ spans->x; |
|
6375 |
||
6376 |
const qreal cx = spans->x + qreal(0.5); |
|
6377 |
const qreal cy = spans->y + qreal(0.5); |
|
6378 |
||
6379 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
6380 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
6381 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
6382 |
||
6383 |
int length = spans->len; |
|
6384 |
while (length) { |
|
6385 |
const int l = qMin(length, buffer_size); |
|
6386 |
const SRC *end = buffer + l; |
|
6387 |
SRC *b = buffer; |
|
6388 |
while (b < end) { |
|
6389 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
6390 |
const qreal tx = x * iw; |
|
6391 |
const qreal ty = y * iw; |
|
6392 |
||
6393 |
int px = int(tx) - (tx < 0); |
|
6394 |
int py = int(ty) - (ty < 0); |
|
6395 |
||
6396 |
if (px < 0) |
|
6397 |
px += image_width; |
|
6398 |
if (py < 0) |
|
6399 |
py += image_height; |
|
6400 |
||
6401 |
*b = ((SRC*)data->texture.scanLine(py))[px]; |
|
6402 |
++b; |
|
6403 |
||
6404 |
x += fdx; |
|
6405 |
y += fdy; |
|
6406 |
w += fdw; |
|
6407 |
// force increment to avoid /0 |
|
6408 |
if (!w) |
|
6409 |
w += fdw; |
|
6410 |
} |
|
6411 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
6412 |
qt_memconvert(dest, buffer, l); |
|
6413 |
} else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && |
|
6414 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
6415 |
{ |
|
6416 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
6417 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
6418 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
6419 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
6420 |
} else { |
|
6421 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
6422 |
} |
|
6423 |
||
6424 |
dest += l; |
|
6425 |
length -= l; |
|
6426 |
} |
|
6427 |
++spans; |
|
6428 |
} |
|
6429 |
} |
|
6430 |
} |
|
6431 |
||
6432 |
static void blend_transformed_tiled_rgb888(int count, const QSpan *spans, |
|
6433 |
void *userData) |
|
6434 |
{ |
|
6435 |
#if defined(QT_QWS_DEPTH_24) |
|
6436 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6437 |
||
6438 |
if (data->texture.format == QImage::Format_RGB888) |
|
6439 |
blendTransformedTiled<qrgb888, qrgb888>(count, spans, userData); |
|
6440 |
else |
|
6441 |
#endif |
|
6442 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6443 |
} |
|
6444 |
||
6445 |
static void blend_transformed_tiled_argb6666(int count, const QSpan *spans, |
|
6446 |
void *userData) |
|
6447 |
{ |
|
6448 |
#if defined(QT_QWS_DEPTH_18) |
|
6449 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6450 |
||
6451 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
6452 |
blendTransformedTiled<qargb6666, qargb6666>(count, spans, userData); |
|
6453 |
else if (data->texture.format == QImage::Format_RGB666) |
|
6454 |
blendTransformedTiled<qargb6666, qrgb666>(count, spans, userData); |
|
6455 |
else |
|
6456 |
#endif |
|
6457 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6458 |
} |
|
6459 |
||
6460 |
static void blend_transformed_tiled_rgb666(int count, const QSpan *spans, |
|
6461 |
void *userData) |
|
6462 |
{ |
|
6463 |
#if defined(QT_QWS_DEPTH_18) |
|
6464 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6465 |
||
6466 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
6467 |
blendTransformedTiled<qrgb666, qargb6666>(count, spans, userData); |
|
6468 |
else if (data->texture.format == QImage::Format_RGB666) |
|
6469 |
blendTransformedTiled<qrgb666, qrgb666>(count, spans, userData); |
|
6470 |
else |
|
6471 |
#endif |
|
6472 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6473 |
} |
|
6474 |
||
6475 |
static void blend_transformed_tiled_argb8565(int count, const QSpan *spans, |
|
6476 |
void *userData) |
|
6477 |
{ |
|
6478 |
#if defined(QT_QWS_DEPTH_16) |
|
6479 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6480 |
||
6481 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
6482 |
blendTransformedTiled<qargb8565, qargb8565>(count, spans, userData); |
|
6483 |
else if (data->texture.format == QImage::Format_RGB16) |
|
6484 |
blendTransformedTiled<qargb8565, qrgb565>(count, spans, userData); |
|
6485 |
else |
|
6486 |
#endif |
|
6487 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6488 |
} |
|
6489 |
||
6490 |
static void blend_transformed_tiled_rgb565(int count, const QSpan *spans, |
|
6491 |
void *userData) |
|
6492 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6493 |
#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) |
0 | 6494 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
6495 |
||
6496 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
6497 |
blendTransformedTiled<qrgb565, qargb8565>(count, spans, userData); |
|
6498 |
else if (data->texture.format == QImage::Format_RGB16) |
|
6499 |
blendTransformedTiled<qrgb565, qrgb565>(count, spans, userData); |
|
6500 |
else |
|
6501 |
#endif |
|
6502 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6503 |
} |
|
6504 |
||
6505 |
static void blend_transformed_tiled_argb8555(int count, const QSpan *spans, |
|
6506 |
void *userData) |
|
6507 |
{ |
|
6508 |
#if defined(QT_QWS_DEPTH_15) |
|
6509 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6510 |
||
6511 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
6512 |
blendTransformedTiled<qargb8555, qargb8555>(count, spans, userData); |
|
6513 |
else if (data->texture.format == QImage::Format_RGB555) |
|
6514 |
blendTransformedTiled<qargb8555, qrgb555>(count, spans, userData); |
|
6515 |
else |
|
6516 |
#endif |
|
6517 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6518 |
} |
|
6519 |
||
6520 |
static void blend_transformed_tiled_rgb555(int count, const QSpan *spans, |
|
6521 |
void *userData) |
|
6522 |
{ |
|
6523 |
#if defined(QT_QWS_DEPTH_15) |
|
6524 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6525 |
||
6526 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
6527 |
blendTransformedTiled<qrgb555, qargb8555>(count, spans, userData); |
|
6528 |
else if (data->texture.format == QImage::Format_RGB555) |
|
6529 |
blendTransformedTiled<qrgb555, qrgb555>(count, spans, userData); |
|
6530 |
else |
|
6531 |
#endif |
|
6532 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6533 |
} |
|
6534 |
||
6535 |
static void blend_transformed_tiled_argb4444(int count, const QSpan *spans, |
|
6536 |
void *userData) |
|
6537 |
{ |
|
6538 |
#if defined(QT_QWS_DEPTH_12) |
|
6539 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6540 |
||
6541 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
6542 |
blendTransformedTiled<qargb4444, qargb4444>(count, spans, userData); |
|
6543 |
else if (data->texture.format == QImage::Format_RGB444) |
|
6544 |
blendTransformedTiled<qargb4444, qrgb444>(count, spans, userData); |
|
6545 |
else |
|
6546 |
#endif |
|
6547 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6548 |
} |
|
6549 |
||
6550 |
static void blend_transformed_tiled_rgb444(int count, const QSpan *spans, |
|
6551 |
void *userData) |
|
6552 |
{ |
|
6553 |
#if defined(QT_QWS_DEPTH_12) |
|
6554 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6555 |
||
6556 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
6557 |
blendTransformedTiled<qrgb444, qargb4444>(count, spans, userData); |
|
6558 |
else if (data->texture.format == QImage::Format_RGB444) |
|
6559 |
blendTransformedTiled<qrgb444, qrgb444>(count, spans, userData); |
|
6560 |
else |
|
6561 |
#endif |
|
6562 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6563 |
} |
|
6564 |
||
6565 |
# define SPANFUNC_POINTER(Name, Arg) Name<Arg> |
|
6566 |
||
6567 |
||
6568 |
/* Image formats here are target formats */ |
|
6569 |
static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats] = { |
|
6570 |
// Untransformed |
|
6571 |
{ |
|
6572 |
0, // Invalid |
|
6573 |
SPANFUNC_POINTER(blend_untransformed_generic, RegularSpans), // Mono |
|
6574 |
SPANFUNC_POINTER(blend_untransformed_generic, RegularSpans), // MonoLsb |
|
6575 |
SPANFUNC_POINTER(blend_untransformed_generic, RegularSpans), // Indexed8 |
|
6576 |
SPANFUNC_POINTER(blend_untransformed_generic, RegularSpans), // RGB32 |
|
6577 |
SPANFUNC_POINTER(blend_untransformed_generic, RegularSpans), // ARGB32 |
|
6578 |
SPANFUNC_POINTER(blend_untransformed_argb, RegularSpans), // ARGB32_Premultiplied |
|
6579 |
blend_untransformed_rgb565, |
|
6580 |
blend_untransformed_argb8565, |
|
6581 |
blend_untransformed_rgb666, |
|
6582 |
blend_untransformed_argb6666, |
|
6583 |
blend_untransformed_rgb555, |
|
6584 |
blend_untransformed_argb8555, |
|
6585 |
blend_untransformed_rgb888, |
|
6586 |
blend_untransformed_rgb444, |
|
6587 |
blend_untransformed_argb4444, |
|
6588 |
}, |
|
6589 |
// Tiled |
|
6590 |
{ |
|
6591 |
0, // Invalid |
|
6592 |
SPANFUNC_POINTER(blend_tiled_generic, RegularSpans), // Mono |
|
6593 |
SPANFUNC_POINTER(blend_tiled_generic, RegularSpans), // MonoLsb |
|
6594 |
SPANFUNC_POINTER(blend_tiled_generic, RegularSpans), // Indexed8 |
|
6595 |
SPANFUNC_POINTER(blend_tiled_generic, RegularSpans), // RGB32 |
|
6596 |
SPANFUNC_POINTER(blend_tiled_generic, RegularSpans), // ARGB32 |
|
6597 |
SPANFUNC_POINTER(blend_tiled_argb, RegularSpans), // ARGB32_Premultiplied |
|
6598 |
blend_tiled_rgb565, |
|
6599 |
blend_tiled_argb8565, |
|
6600 |
blend_tiled_rgb666, |
|
6601 |
blend_tiled_argb6666, |
|
6602 |
blend_tiled_rgb555, |
|
6603 |
blend_tiled_argb8555, |
|
6604 |
blend_tiled_rgb888, |
|
6605 |
blend_tiled_rgb444, |
|
6606 |
blend_tiled_argb4444, |
|
6607 |
}, |
|
6608 |
// Transformed |
|
6609 |
{ |
|
6610 |
0, // Invalid |
|
6611 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Mono |
|
6612 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // MonoLsb |
|
6613 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8 |
|
6614 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32 |
|
6615 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32 |
|
6616 |
SPANFUNC_POINTER(blend_transformed_argb, RegularSpans), // ARGB32_Premultiplied |
|
6617 |
blend_transformed_rgb565, |
|
6618 |
blend_transformed_argb8565, |
|
6619 |
blend_transformed_rgb666, |
|
6620 |
blend_transformed_argb6666, |
|
6621 |
blend_transformed_rgb555, |
|
6622 |
blend_transformed_argb8555, |
|
6623 |
blend_transformed_rgb888, |
|
6624 |
blend_transformed_rgb444, |
|
6625 |
blend_transformed_argb4444, |
|
6626 |
}, |
|
6627 |
// TransformedTiled |
|
6628 |
{ |
|
6629 |
0, |
|
6630 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Mono |
|
6631 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // MonoLsb |
|
6632 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8 |
|
6633 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32 |
|
6634 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32 |
|
6635 |
SPANFUNC_POINTER(blend_transformed_tiled_argb, RegularSpans), // ARGB32_Premultiplied |
|
6636 |
blend_transformed_tiled_rgb565, |
|
6637 |
blend_transformed_tiled_argb8565, |
|
6638 |
blend_transformed_tiled_rgb666, |
|
6639 |
blend_transformed_tiled_argb6666, |
|
6640 |
blend_transformed_tiled_rgb555, |
|
6641 |
blend_transformed_tiled_argb8555, |
|
6642 |
blend_transformed_tiled_rgb888, |
|
6643 |
blend_transformed_tiled_rgb444, |
|
6644 |
blend_transformed_tiled_argb4444 |
|
6645 |
}, |
|
6646 |
// Bilinear |
|
6647 |
{ |
|
6648 |
0, |
|
6649 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Mono |
|
6650 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // MonoLsb |
|
6651 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8 |
|
6652 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32 |
|
6653 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6654 |
blend_transformed_bilinear_argb<RegularSpans, BlendTransformedBilinear>, // ARGB32_Premultiplied |
0 | 6655 |
blend_transformed_bilinear_rgb565, |
6656 |
blend_transformed_bilinear_argb8565, |
|
6657 |
blend_transformed_bilinear_rgb666, |
|
6658 |
blend_transformed_bilinear_argb6666, |
|
6659 |
blend_transformed_bilinear_rgb555, |
|
6660 |
blend_transformed_bilinear_argb8555, |
|
6661 |
blend_transformed_bilinear_rgb888, |
|
6662 |
blend_transformed_bilinear_rgb444, |
|
6663 |
blend_transformed_bilinear_argb4444, |
|
6664 |
}, |
|
6665 |
// BilinearTiled |
|
6666 |
{ |
|
6667 |
0, |
|
6668 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Mono |
|
6669 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // MonoLsb |
|
6670 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8 |
|
6671 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32 |
|
6672 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6673 |
blend_transformed_bilinear_argb<RegularSpans, BlendTransformedBilinearTiled>, // ARGB32_Premultiplied |
0 | 6674 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB16 |
6675 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB8565_Premultiplied |
|
6676 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB666 |
|
6677 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB6666_Premultiplied |
|
6678 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB555 |
|
6679 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB8555_Premultiplied |
|
6680 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB888 |
|
6681 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB444 |
|
6682 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB4444_Premultiplied |
|
6683 |
} |
|
6684 |
}; |
|
6685 |
||
6686 |
#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS) |
|
6687 |
static const ProcessSpans processTextureSpansCallback[NBlendTypes][QImage::NImageFormats] = { |
|
6688 |
// Untransformed |
|
6689 |
{ |
|
6690 |
0, // Invalid |
|
6691 |
blend_untransformed_generic<CallbackSpans>, // Mono |
|
6692 |
blend_untransformed_generic<CallbackSpans>, // MonoLsb |
|
6693 |
blend_untransformed_generic<CallbackSpans>, // Indexed8 |
|
6694 |
blend_untransformed_generic<CallbackSpans>, // RGB32 |
|
6695 |
blend_untransformed_generic<CallbackSpans>, // ARGB32 |
|
6696 |
blend_untransformed_argb<CallbackSpans>, // ARGB32_Premultiplied |
|
6697 |
blend_untransformed_generic<CallbackSpans>, // RGB16 |
|
6698 |
blend_untransformed_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6699 |
blend_untransformed_generic<CallbackSpans>, // RGB666 |
|
6700 |
blend_untransformed_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6701 |
blend_untransformed_generic<CallbackSpans>, // RGB555 |
|
6702 |
blend_untransformed_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6703 |
blend_untransformed_generic<CallbackSpans>, // RGB888 |
|
6704 |
blend_untransformed_generic<CallbackSpans>, // RGB444 |
|
6705 |
blend_untransformed_generic<CallbackSpans> // ARGB4444_Premultiplied |
|
6706 |
}, |
|
6707 |
// Tiled |
|
6708 |
{ |
|
6709 |
0, // Invalid |
|
6710 |
blend_tiled_generic<CallbackSpans>, // Mono |
|
6711 |
blend_tiled_generic<CallbackSpans>, // MonoLsb |
|
6712 |
blend_tiled_generic<CallbackSpans>, // Indexed8 |
|
6713 |
blend_tiled_generic<CallbackSpans>, // RGB32 |
|
6714 |
blend_tiled_generic<CallbackSpans>, // ARGB32 |
|
6715 |
blend_tiled_argb<CallbackSpans>, // ARGB32_Premultiplied |
|
6716 |
blend_tiled_generic<CallbackSpans>, // RGB16 |
|
6717 |
blend_tiled_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6718 |
blend_tiled_generic<CallbackSpans>, // RGB666 |
|
6719 |
blend_tiled_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6720 |
blend_tiled_generic<CallbackSpans>, // RGB555 |
|
6721 |
blend_tiled_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6722 |
blend_tiled_generic<CallbackSpans>, // RGB888 |
|
6723 |
blend_tiled_generic<CallbackSpans>, // RGB444 |
|
6724 |
blend_tiled_generic<CallbackSpans> // ARGB4444_Premultiplied |
|
6725 |
}, |
|
6726 |
// Transformed |
|
6727 |
{ |
|
6728 |
0, // Invalid |
|
6729 |
blend_src_generic<CallbackSpans>, // Mono |
|
6730 |
blend_src_generic<CallbackSpans>, // MonoLsb |
|
6731 |
blend_src_generic<CallbackSpans>, // Indexed8 |
|
6732 |
blend_src_generic<CallbackSpans>, // RGB32 |
|
6733 |
blend_src_generic<CallbackSpans>, // ARGB32 |
|
6734 |
blend_transformed_argb<CallbackSpans>, // ARGB32_Premultiplied |
|
6735 |
blend_src_generic<CallbackSpans>, // RGB16 |
|
6736 |
blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6737 |
blend_src_generic<CallbackSpans>, // RGB666 |
|
6738 |
blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6739 |
blend_src_generic<CallbackSpans>, // RGB555 |
|
6740 |
blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6741 |
blend_src_generic<CallbackSpans>, // RGB888 |
|
6742 |
blend_src_generic<CallbackSpans>, // RGB444 |
|
6743 |
blend_src_generic<CallbackSpans>, // ARGB4444_Premultiplied |
|
6744 |
}, |
|
6745 |
// TransformedTiled |
|
6746 |
{ |
|
6747 |
0, |
|
6748 |
blend_src_generic<CallbackSpans>, // Mono |
|
6749 |
blend_src_generic<CallbackSpans>, // MonoLsb |
|
6750 |
blend_src_generic<CallbackSpans>, // Indexed8 |
|
6751 |
blend_src_generic<CallbackSpans>, // RGB32 |
|
6752 |
blend_src_generic<CallbackSpans>, // ARGB32 |
|
6753 |
blend_transformed_tiled_argb<CallbackSpans>, // ARGB32_Premultiplied |
|
6754 |
blend_src_generic<CallbackSpans>, // RGB16 |
|
6755 |
blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6756 |
blend_src_generic<CallbackSpans>, // RGB666 |
|
6757 |
blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6758 |
blend_src_generic<CallbackSpans>, // RGB555 |
|
6759 |
blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6760 |
blend_src_generic<CallbackSpans>, // RGB888 |
|
6761 |
blend_src_generic<CallbackSpans>, // RGB444 |
|
6762 |
blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied |
|
6763 |
}, |
|
6764 |
// Bilinear |
|
6765 |
{ |
|
6766 |
0, |
|
6767 |
blend_src_generic<CallbackSpans>, // Mono |
|
6768 |
blend_src_generic<CallbackSpans>, // MonoLsb |
|
6769 |
blend_src_generic<CallbackSpans>, // Indexed8 |
|
6770 |
blend_src_generic<CallbackSpans>, // RGB32 |
|
6771 |
blend_src_generic<CallbackSpans>, // ARGB32 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6772 |
blend_transformed_bilinear_argb<CallbackSpans, BlendTransformedBilinear>, // ARGB32_Premultiplied |
0 | 6773 |
blend_src_generic<CallbackSpans>, // RGB16 |
6774 |
blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6775 |
blend_src_generic<CallbackSpans>, // RGB666 |
|
6776 |
blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6777 |
blend_src_generic<CallbackSpans>, // RGB555 |
|
6778 |
blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6779 |
blend_src_generic<CallbackSpans>, // RGB888 |
|
6780 |
blend_src_generic<CallbackSpans>, // RGB444 |
|
6781 |
blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied |
|
6782 |
}, |
|
6783 |
// BilinearTiled |
|
6784 |
{ |
|
6785 |
0, |
|
6786 |
blend_src_generic<CallbackSpans>, // Mono |
|
6787 |
blend_src_generic<CallbackSpans>, // MonoLsb |
|
6788 |
blend_src_generic<CallbackSpans>, // Indexed8 |
|
6789 |
blend_src_generic<CallbackSpans>, // RGB32 |
|
6790 |
blend_src_generic<CallbackSpans>, // ARGB32 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6791 |
blend_transformed_bilinear_argb<CallbackSpans, BlendTransformedBilinearTiled>, // ARGB32_Premultiplied |
0 | 6792 |
blend_src_generic<CallbackSpans>, // RGB16 |
6793 |
blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6794 |
blend_src_generic<CallbackSpans>, // RGB666 |
|
6795 |
blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6796 |
blend_src_generic<CallbackSpans>, // RGB555 |
|
6797 |
blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6798 |
blend_src_generic<CallbackSpans>, // RGB888 |
|
6799 |
blend_src_generic<CallbackSpans>, // RGB444 |
|
6800 |
blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied |
|
6801 |
} |
|
6802 |
}; |
|
6803 |
#endif // QT_NO_RASTERCALLBACKS |
|
6804 |
||
6805 |
void qBlendTexture(int count, const QSpan *spans, void *userData) |
|
6806 |
{ |
|
6807 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6808 |
ProcessSpans proc = processTextureSpans[getBlendType(data)][data->rasterBuffer->format]; |
|
6809 |
proc(count, spans, userData); |
|
6810 |
} |
|
6811 |
||
6812 |
#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS) |
|
6813 |
void qBlendTextureCallback(int count, const QSpan *spans, void *userData) |
|
6814 |
{ |
|
6815 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6816 |
ProcessSpans proc = processTextureSpansCallback[getBlendType(data)][data->rasterBuffer->format]; |
|
6817 |
proc(count, spans, userData); |
|
6818 |
} |
|
6819 |
#endif // QT_NO_RASTERCALLBACKS |
|
6820 |
||
6821 |
template <class DST> |
|
6822 |
inline void qt_bitmapblit_template(QRasterBuffer *rasterBuffer, |
|
6823 |
int x, int y, quint32 color, |
|
6824 |
const uchar *map, |
|
6825 |
int mapWidth, int mapHeight, int mapStride, |
|
6826 |
DST dummy = 0) |
|
6827 |
{ |
|
6828 |
Q_UNUSED(dummy); |
|
6829 |
const DST c = qt_colorConvert<DST, quint32>(color, 0); |
|
6830 |
DST *dest = reinterpret_cast<DST*>(rasterBuffer->scanLine(y)) + x; |
|
6831 |
const int destStride = rasterBuffer->bytesPerLine() / sizeof(DST); |
|
6832 |
||
6833 |
if (mapWidth > 8) { |
|
6834 |
while (mapHeight--) { |
|
6835 |
int x0 = 0; |
|
6836 |
int n = 0; |
|
6837 |
for (int x = 0; x < mapWidth; x += 8) { |
|
6838 |
uchar s = map[x >> 3]; |
|
6839 |
for (int i = 0; i < 8; ++i) { |
|
6840 |
if (s & 0x80) { |
|
6841 |
++n; |
|
6842 |
} else { |
|
6843 |
if (n) { |
|
6844 |
qt_memfill(dest + x0, c, n); |
|
6845 |
x0 += n + 1; |
|
6846 |
n = 0; |
|
6847 |
} else { |
|
6848 |
++x0; |
|
6849 |
} |
|
6850 |
if (!s) { |
|
6851 |
x0 += 8 - 1 - i; |
|
6852 |
break; |
|
6853 |
} |
|
6854 |
} |
|
6855 |
s <<= 1; |
|
6856 |
} |
|
6857 |
} |
|
6858 |
if (n) |
|
6859 |
qt_memfill(dest + x0, c, n); |
|
6860 |
dest += destStride; |
|
6861 |
map += mapStride; |
|
6862 |
} |
|
6863 |
} else { |
|
6864 |
while (mapHeight--) { |
|
6865 |
int x0 = 0; |
|
6866 |
int n = 0; |
|
6867 |
for (uchar s = *map; s; s <<= 1) { |
|
6868 |
if (s & 0x80) { |
|
6869 |
++n; |
|
6870 |
} else if (n) { |
|
6871 |
qt_memfill(dest + x0, c, n); |
|
6872 |
x0 += n + 1; |
|
6873 |
n = 0; |
|
6874 |
} else { |
|
6875 |
++x0; |
|
6876 |
} |
|
6877 |
} |
|
6878 |
if (n) |
|
6879 |
qt_memfill(dest + x0, c, n); |
|
6880 |
dest += destStride; |
|
6881 |
map += mapStride; |
|
6882 |
} |
|
6883 |
} |
|
6884 |
} |
|
6885 |
||
6886 |
static void qt_gradient_quint32(int count, const QSpan *spans, void *userData) |
|
6887 |
{ |
|
6888 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6889 |
||
6890 |
bool isVerticalGradient = |
|
6891 |
data->txop <= QTransform::TxScale && |
|
6892 |
data->type == QSpanData::LinearGradient && |
|
6893 |
data->gradient.linear.end.x == data->gradient.linear.origin.x; |
|
6894 |
||
6895 |
if (isVerticalGradient) { |
|
6896 |
LinearGradientValues linear; |
|
6897 |
getLinearGradientValues(&linear, data); |
|
6898 |
||
6899 |
CompositionFunctionSolid funcSolid = |
|
6900 |
functionForModeSolid[data->rasterBuffer->compositionMode]; |
|
6901 |
||
6902 |
/* |
|
6903 |
The logic for vertical gradient calculations is a mathematically |
|
6904 |
reduced copy of that in fetchLinearGradient() - which is basically: |
|
6905 |
||
6906 |
qreal ry = data->m22 * (y + 0.5) + data->dy; |
|
6907 |
qreal t = linear.dy*ry + linear.off; |
|
6908 |
t *= (GRADIENT_STOPTABLE_SIZE - 1); |
|
6909 |
quint32 color = |
|
6910 |
qt_gradient_pixel_fixed(&data->gradient, |
|
6911 |
int(t * FIXPT_SIZE)); |
|
6912 |
||
6913 |
This has then been converted to fixed point to improve performance. |
|
6914 |
*/ |
|
6915 |
const int gss = GRADIENT_STOPTABLE_SIZE - 1; |
|
6916 |
int yinc = int((linear.dy * data->m22 * gss) * FIXPT_SIZE); |
|
6917 |
int off = int((((linear.dy * (data->m22 * 0.5 + data->dy) + linear.off) * gss) * FIXPT_SIZE)); |
|
6918 |
||
6919 |
while (count--) { |
|
6920 |
int y = spans->y; |
|
6921 |
int x = spans->x; |
|
6922 |
||
6923 |
quint32 *dst = (quint32 *)(data->rasterBuffer->scanLine(y)) + x; |
|
6924 |
quint32 color = |
|
6925 |
qt_gradient_pixel_fixed(&data->gradient, yinc * y + off); |
|
6926 |
||
6927 |
funcSolid(dst, spans->len, color, spans->coverage); |
|
6928 |
++spans; |
|
6929 |
} |
|
6930 |
||
6931 |
} else { |
|
6932 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6933 |
} |
|
6934 |
} |
|
6935 |
||
6936 |
static void qt_gradient_quint16(int count, const QSpan *spans, void *userData) |
|
6937 |
{ |
|
6938 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6939 |
||
6940 |
bool isVerticalGradient = |
|
6941 |
data->txop <= QTransform::TxScale && |
|
6942 |
data->type == QSpanData::LinearGradient && |
|
6943 |
data->gradient.linear.end.x == data->gradient.linear.origin.x; |
|
6944 |
||
6945 |
if (isVerticalGradient) { |
|
6946 |
||
6947 |
LinearGradientValues linear; |
|
6948 |
getLinearGradientValues(&linear, data); |
|
6949 |
||
6950 |
/* |
|
6951 |
The logic for vertical gradient calculations is a mathematically |
|
6952 |
reduced copy of that in fetchLinearGradient() - which is basically: |
|
6953 |
||
6954 |
qreal ry = data->m22 * (y + 0.5) + data->dy; |
|
6955 |
qreal t = linear.dy*ry + linear.off; |
|
6956 |
t *= (GRADIENT_STOPTABLE_SIZE - 1); |
|
6957 |
quint32 color = |
|
6958 |
qt_gradient_pixel_fixed(&data->gradient, |
|
6959 |
int(t * FIXPT_SIZE)); |
|
6960 |
||
6961 |
This has then been converted to fixed point to improve performance. |
|
6962 |
*/ |
|
6963 |
const int gss = GRADIENT_STOPTABLE_SIZE - 1; |
|
6964 |
int yinc = int((linear.dy * data->m22 * gss) * FIXPT_SIZE); |
|
6965 |
int off = int((((linear.dy * (data->m22 * 0.5 + data->dy) + linear.off) * gss) * FIXPT_SIZE)); |
|
6966 |
||
6967 |
uint oldColor = data->solid.color; |
|
6968 |
while (count--) { |
|
6969 |
int y = spans->y; |
|
6970 |
||
6971 |
quint32 color = qt_gradient_pixel_fixed(&data->gradient, yinc * y + off); |
|
6972 |
||
6973 |
data->solid.color = color; |
|
6974 |
blend_color_rgb16(1, spans, userData); |
|
6975 |
++spans; |
|
6976 |
} |
|
6977 |
data->solid.color = oldColor; |
|
6978 |
||
6979 |
} else { |
|
6980 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6981 |
} |
|
6982 |
} |
|
6983 |
||
6984 |
inline static void qt_bitmapblit_quint32(QRasterBuffer *rasterBuffer, |
|
6985 |
int x, int y, quint32 color, |
|
6986 |
const uchar *map, |
|
6987 |
int mapWidth, int mapHeight, int mapStride) |
|
6988 |
{ |
|
6989 |
qt_bitmapblit_template<quint32>(rasterBuffer, x, y, color, |
|
6990 |
map, mapWidth, mapHeight, mapStride); |
|
6991 |
} |
|
6992 |
||
6993 |
inline static void qt_bitmapblit_quint16(QRasterBuffer *rasterBuffer, |
|
6994 |
int x, int y, quint32 color, |
|
6995 |
const uchar *map, |
|
6996 |
int mapWidth, int mapHeight, int mapStride) |
|
6997 |
{ |
|
6998 |
qt_bitmapblit_template<quint16>(rasterBuffer, x, y, color, |
|
6999 |
map, mapWidth, mapHeight, mapStride); |
|
7000 |
} |
|
7001 |
||
7002 |
||
7003 |
uchar qt_pow_rgb_gamma[256]; |
|
7004 |
uchar qt_pow_rgb_invgamma[256]; |
|
7005 |
||
7006 |
uint qt_pow_gamma[256]; |
|
7007 |
uchar qt_pow_invgamma[2048]; |
|
7008 |
||
7009 |
static void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer, |
|
7010 |
int x, int y, quint32 color, |
|
7011 |
const uchar *map, |
|
7012 |
int mapWidth, int mapHeight, int mapStride, |
|
7013 |
const QClipData *) |
|
7014 |
{ |
|
7015 |
const quint16 c = qt_colorConvert<quint16, quint32>(color, 0); |
|
7016 |
quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x; |
|
7017 |
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16); |
|
7018 |
||
7019 |
while (mapHeight--) { |
|
7020 |
for (int i = 0; i < mapWidth; ++i) { |
|
7021 |
const int coverage = map[i]; |
|
7022 |
||
7023 |
if (coverage == 0) { |
|
7024 |
// nothing |
|
7025 |
} else if (coverage == 255) { |
|
7026 |
dest[i] = c; |
|
7027 |
} else { |
|
7028 |
int ialpha = 255 - coverage; |
|
7029 |
dest[i] = BYTE_MUL_RGB16(c, coverage) |
|
7030 |
+ BYTE_MUL_RGB16(dest[i], ialpha); |
|
7031 |
} |
|
7032 |
} |
|
7033 |
dest += destStride; |
|
7034 |
map += mapStride; |
|
7035 |
} |
|
7036 |
} |
|
7037 |
||
7038 |
void qt_build_pow_tables() { |
|
7039 |
qreal smoothing = qreal(1.7); |
|
7040 |
||
7041 |
#ifdef Q_WS_MAC |
|
7042 |
// decided by testing a few things on an iMac, should probably get this from the |
|
7043 |
// system... |
|
7044 |
smoothing = 2.0; |
|
7045 |
#endif |
|
7046 |
||
7047 |
#ifdef Q_WS_WIN |
|
7048 |
int winSmooth; |
|
7049 |
if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) |
|
7050 |
smoothing = winSmooth / 1000.0; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7051 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7052 |
// Safeguard ourselves against corrupt registry values... |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7053 |
if (smoothing > 5 || smoothing < 1) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7054 |
smoothing = 1.4; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7055 |
|
0 | 7056 |
#endif |
7057 |
||
7058 |
#ifdef Q_WS_X11 |
|
7059 |
Q_UNUSED(smoothing); |
|
7060 |
for (int i=0; i<256; ++i) { |
|
7061 |
qt_pow_rgb_gamma[i] = uchar(i); |
|
7062 |
qt_pow_rgb_invgamma[i] = uchar(i); |
|
7063 |
} |
|
7064 |
#else |
|
7065 |
for (int i=0; i<256; ++i) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7066 |
qt_pow_rgb_gamma[i] = uchar(qRound(qPow(i / qreal(255.0), smoothing) * 255)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7067 |
qt_pow_rgb_invgamma[i] = uchar(qRound(qPow(i / qreal(255.), 1 / smoothing) * 255)); |
0 | 7068 |
} |
7069 |
#endif |
|
7070 |
||
7071 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
7072 |
const qreal gray_gamma = 2.31; |
|
7073 |
for (int i=0; i<256; ++i) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7074 |
qt_pow_gamma[i] = uint(qRound(qPow(i / qreal(255.), gray_gamma) * 2047)); |
0 | 7075 |
for (int i=0; i<2048; ++i) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7076 |
qt_pow_invgamma[i] = uchar(qRound(qPow(i / 2047.0, 1 / gray_gamma) * 255)); |
0 | 7077 |
#endif |
7078 |
} |
|
7079 |
||
7080 |
static inline void rgbBlendPixel(quint32 *dst, int coverage, int sr, int sg, int sb) |
|
7081 |
{ |
|
7082 |
// Do a gray alphablend... |
|
7083 |
int da = qAlpha(*dst); |
|
7084 |
int dr = qRed(*dst); |
|
7085 |
int dg = qGreen(*dst); |
|
7086 |
int db = qBlue(*dst); |
|
7087 |
||
7088 |
if (da != 255 |
|
7089 |
#if defined (Q_WS_WIN) |
|
7090 |
// Work around GDI messing up alpha channel |
|
7091 |
&& qRed(*dst) <= da && qBlue(*dst) <= da && qGreen(*dst) <= da |
|
7092 |
#endif |
|
7093 |
) { |
|
7094 |
||
7095 |
int a = qGray(coverage); |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
7096 |
sr = qt_div_255(qt_pow_rgb_invgamma[sr] * a); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
7097 |
sg = qt_div_255(qt_pow_rgb_invgamma[sg] * a); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
7098 |
sb = qt_div_255(qt_pow_rgb_invgamma[sb] * a); |
0 | 7099 |
|
7100 |
int ia = 255 - a; |
|
7101 |
dr = qt_div_255(dr * ia); |
|
7102 |
dg = qt_div_255(dg * ia); |
|
7103 |
db = qt_div_255(db * ia); |
|
7104 |
||
7105 |
*dst = ((a + qt_div_255((255 - a) * da)) << 24) |
|
7106 |
| ((sr + dr) << 16) |
|
7107 |
| ((sg + dg) << 8) |
|
7108 |
| ((sb + db)); |
|
7109 |
return; |
|
7110 |
} |
|
7111 |
||
7112 |
int mr = qRed(coverage); |
|
7113 |
int mg = qGreen(coverage); |
|
7114 |
int mb = qBlue(coverage); |
|
7115 |
||
7116 |
dr = qt_pow_rgb_gamma[dr]; |
|
7117 |
dg = qt_pow_rgb_gamma[dg]; |
|
7118 |
db = qt_pow_rgb_gamma[db]; |
|
7119 |
||
7120 |
int nr = qt_div_255((sr - dr) * mr) + dr; |
|
7121 |
int ng = qt_div_255((sg - dg) * mg) + dg; |
|
7122 |
int nb = qt_div_255((sb - db) * mb) + db; |
|
7123 |
||
7124 |
nr = qt_pow_rgb_invgamma[nr]; |
|
7125 |
ng = qt_pow_rgb_invgamma[ng]; |
|
7126 |
nb = qt_pow_rgb_invgamma[nb]; |
|
7127 |
||
7128 |
*dst = qRgb(nr, ng, nb); |
|
7129 |
} |
|
7130 |
||
7131 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
7132 |
static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, int sb) |
|
7133 |
{ |
|
7134 |
// Do a gammacorrected gray alphablend... |
|
7135 |
int dr = qRed(*dst); |
|
7136 |
int dg = qGreen(*dst); |
|
7137 |
int db = qBlue(*dst); |
|
7138 |
||
7139 |
dr = qt_pow_gamma[dr]; |
|
7140 |
dg = qt_pow_gamma[dg]; |
|
7141 |
db = qt_pow_gamma[db]; |
|
7142 |
||
7143 |
int alpha = coverage; |
|
7144 |
int ialpha = 255 - alpha; |
|
7145 |
int nr = (sr * alpha + ialpha * dr) / 255; |
|
7146 |
int ng = (sg * alpha + ialpha * dg) / 255; |
|
7147 |
int nb = (sb * alpha + ialpha * db) / 255; |
|
7148 |
||
7149 |
nr = qt_pow_invgamma[nr]; |
|
7150 |
ng = qt_pow_invgamma[ng]; |
|
7151 |
nb = qt_pow_invgamma[nb]; |
|
7152 |
||
7153 |
*dst = qRgb(nr, ng, nb); |
|
7154 |
} |
|
7155 |
#endif |
|
7156 |
||
7157 |
static void qt_alphamapblit_quint32(QRasterBuffer *rasterBuffer, |
|
7158 |
int x, int y, quint32 color, |
|
7159 |
const uchar *map, |
|
7160 |
int mapWidth, int mapHeight, int mapStride, |
|
7161 |
const QClipData *clip) |
|
7162 |
{ |
|
7163 |
const quint32 c = color; |
|
7164 |
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32); |
|
7165 |
||
7166 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
7167 |
int sr = qRed(color); |
|
7168 |
int sg = qGreen(color); |
|
7169 |
int sb = qBlue(color); |
|
7170 |
||
7171 |
sr = qt_pow_gamma[sr]; |
|
7172 |
sg = qt_pow_gamma[sg]; |
|
7173 |
sb = qt_pow_gamma[sb]; |
|
7174 |
bool opaque_src = (qAlpha(color) == 255); |
|
7175 |
#endif |
|
7176 |
||
7177 |
if (!clip) { |
|
7178 |
quint32 *dest = reinterpret_cast<quint32*>(rasterBuffer->scanLine(y)) + x; |
|
7179 |
while (mapHeight--) { |
|
7180 |
for (int i = 0; i < mapWidth; ++i) { |
|
7181 |
const int coverage = map[i]; |
|
7182 |
||
7183 |
if (coverage == 0) { |
|
7184 |
// nothing |
|
7185 |
} else if (coverage == 255) { |
|
7186 |
dest[i] = c; |
|
7187 |
} else { |
|
7188 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
7189 |
if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && opaque_src |
|
7190 |
&& qAlpha(dest[i]) == 255) { |
|
7191 |
grayBlendPixel(dest+i, coverage, sr, sg, sb); |
|
7192 |
} else |
|
7193 |
#endif |
|
7194 |
{ |
|
7195 |
int ialpha = 255 - coverage; |
|
7196 |
dest[i] = INTERPOLATE_PIXEL_255(c, coverage, dest[i], ialpha); |
|
7197 |
} |
|
7198 |
} |
|
7199 |
} |
|
7200 |
dest += destStride; |
|
7201 |
map += mapStride; |
|
7202 |
} |
|
7203 |
} else { |
|
7204 |
int bottom = qMin(y + mapHeight, rasterBuffer->height()); |
|
7205 |
||
7206 |
int top = qMax(y, 0); |
|
7207 |
map += (top - y) * mapStride; |
|
7208 |
||
7209 |
const_cast<QClipData *>(clip)->initialize(); |
|
7210 |
for (int yp = top; yp<bottom; ++yp) { |
|
7211 |
const QClipData::ClipLine &line = clip->m_clipLines[yp]; |
|
7212 |
||
7213 |
quint32 *dest = reinterpret_cast<quint32 *>(rasterBuffer->scanLine(yp)); |
|
7214 |
||
7215 |
for (int i=0; i<line.count; ++i) { |
|
7216 |
const QSpan &clip = line.spans[i]; |
|
7217 |
||
7218 |
int start = qMax<int>(x, clip.x); |
|
7219 |
int end = qMin<int>(x + mapWidth, clip.x + clip.len); |
|
7220 |
||
7221 |
for (int xp=start; xp<end; ++xp) { |
|
7222 |
const int coverage = map[xp - x]; |
|
7223 |
||
7224 |
if (coverage == 0) { |
|
7225 |
// nothing |
|
7226 |
} else if (coverage == 255) { |
|
7227 |
dest[xp] = c; |
|
7228 |
} else { |
|
7229 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
7230 |
if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && opaque_src |
|
7231 |
&& qAlpha(dest[xp]) == 255) { |
|
7232 |
grayBlendPixel(dest+xp, coverage, sr, sg, sb); |
|
7233 |
} else |
|
7234 |
#endif |
|
7235 |
{ |
|
7236 |
int ialpha = 255 - coverage; |
|
7237 |
dest[xp] = INTERPOLATE_PIXEL_255(c, coverage, dest[xp], ialpha); |
|
7238 |
} |
|
7239 |
} |
|
7240 |
||
7241 |
} // for (i -> line.count) |
|
7242 |
} // for (yp -> bottom) |
|
7243 |
map += mapStride; |
|
7244 |
} |
|
7245 |
} |
|
7246 |
} |
|
7247 |
||
7248 |
static void qt_alphargbblit_quint32(QRasterBuffer *rasterBuffer, |
|
7249 |
int x, int y, quint32 color, |
|
7250 |
const uint *src, int mapWidth, int mapHeight, int srcStride, |
|
7251 |
const QClipData *clip) |
|
7252 |
{ |
|
7253 |
const quint32 c = color; |
|
7254 |
||
7255 |
int sr = qRed(color); |
|
7256 |
int sg = qGreen(color); |
|
7257 |
int sb = qBlue(color); |
|
7258 |
int sa = qAlpha(color); |
|
7259 |
||
7260 |
sr = qt_pow_rgb_gamma[sr]; |
|
7261 |
sg = qt_pow_rgb_gamma[sg]; |
|
7262 |
sb = qt_pow_rgb_gamma[sb]; |
|
7263 |
||
7264 |
if (sa == 0) |
|
7265 |
return; |
|
7266 |
||
7267 |
if (!clip) { |
|
7268 |
quint32 *dst = reinterpret_cast<quint32*>(rasterBuffer->scanLine(y)) + x; |
|
7269 |
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32); |
|
7270 |
while (mapHeight--) { |
|
7271 |
for (int i = 0; i < mapWidth; ++i) { |
|
7272 |
const uint coverage = src[i]; |
|
7273 |
if (coverage == 0xffffffff) { |
|
7274 |
dst[i] = c; |
|
7275 |
} else if (coverage != 0xff000000) { |
|
7276 |
rgbBlendPixel(dst+i, coverage, sr, sg, sb); |
|
7277 |
} |
|
7278 |
} |
|
7279 |
||
7280 |
dst += destStride; |
|
7281 |
src += srcStride; |
|
7282 |
} |
|
7283 |
} else { |
|
7284 |
int bottom = qMin(y + mapHeight, rasterBuffer->height()); |
|
7285 |
||
7286 |
int top = qMax(y, 0); |
|
7287 |
src += (top - y) * srcStride; |
|
7288 |
||
7289 |
const_cast<QClipData *>(clip)->initialize(); |
|
7290 |
for (int yp = top; yp<bottom; ++yp) { |
|
7291 |
const QClipData::ClipLine &line = clip->m_clipLines[yp]; |
|
7292 |
||
7293 |
quint32 *dst = reinterpret_cast<quint32 *>(rasterBuffer->scanLine(yp)); |
|
7294 |
||
7295 |
for (int i=0; i<line.count; ++i) { |
|
7296 |
const QSpan &clip = line.spans[i]; |
|
7297 |
||
7298 |
int start = qMax<int>(x, clip.x); |
|
7299 |
int end = qMin<int>(x + mapWidth, clip.x + clip.len); |
|
7300 |
||
7301 |
for (int xp=start; xp<end; ++xp) { |
|
7302 |
const uint coverage = src[xp - x]; |
|
7303 |
if (coverage == 0xffffffff) { |
|
7304 |
dst[xp] = c; |
|
7305 |
} else if (coverage != 0xff000000) { |
|
7306 |
rgbBlendPixel(dst+xp, coverage, sr, sg, sb); |
|
7307 |
} |
|
7308 |
} |
|
7309 |
} // for (i -> line.count) |
|
7310 |
src += srcStride; |
|
7311 |
} // for (yp -> bottom) |
|
7312 |
||
7313 |
} |
|
7314 |
} |
|
7315 |
||
7316 |
template <class T> |
|
7317 |
inline void qt_rectfill_template(QRasterBuffer *rasterBuffer, |
|
7318 |
int x, int y, int width, int height, |
|
7319 |
quint32 color, T dummy = 0) |
|
7320 |
{ |
|
7321 |
Q_UNUSED(dummy); |
|
7322 |
||
7323 |
qt_rectfill<T>(reinterpret_cast<T*>(rasterBuffer->buffer()), |
|
7324 |
qt_colorConvert<T, quint32p>(quint32p::fromRawData(color), 0), |
|
7325 |
x, y, width, height, rasterBuffer->bytesPerLine()); |
|
7326 |
} |
|
7327 |
||
7328 |
#define QT_RECTFILL(T) \ |
|
7329 |
inline static void qt_rectfill_##T(QRasterBuffer *rasterBuffer, \ |
|
7330 |
int x, int y, int width, int height, \ |
|
7331 |
quint32 color) \ |
|
7332 |
{ \ |
|
7333 |
qt_rectfill_template<T>(rasterBuffer, x, y, width, height, color); \ |
|
7334 |
} |
|
7335 |
||
7336 |
QT_RECTFILL(quint32) |
|
7337 |
QT_RECTFILL(quint16) |
|
7338 |
QT_RECTFILL(qargb8565) |
|
7339 |
QT_RECTFILL(qrgb666) |
|
7340 |
QT_RECTFILL(qargb6666) |
|
7341 |
QT_RECTFILL(qrgb555) |
|
7342 |
QT_RECTFILL(qargb8555) |
|
7343 |
QT_RECTFILL(qrgb888) |
|
7344 |
QT_RECTFILL(qrgb444) |
|
7345 |
QT_RECTFILL(qargb4444) |
|
7346 |
#undef QT_RECTFILL |
|
7347 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7348 |
inline static void qt_rectfill_nonpremul_quint32(QRasterBuffer *rasterBuffer, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7349 |
int x, int y, int width, int height, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7350 |
quint32 color) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7351 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7352 |
qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()), |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7353 |
INV_PREMUL(color), x, y, width, height, rasterBuffer->bytesPerLine()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7354 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7355 |
|
0 | 7356 |
|
7357 |
// Map table for destination image format. Contains function pointers |
|
7358 |
// for blends of various types unto the destination |
|
7359 |
||
7360 |
DrawHelper qDrawHelper[QImage::NImageFormats] = |
|
7361 |
{ |
|
7362 |
// Format_Invalid, |
|
7363 |
{ 0, 0, 0, 0, 0, 0 }, |
|
7364 |
// Format_Mono, |
|
7365 |
{ |
|
7366 |
blend_color_generic, |
|
7367 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7368 |
0, 0, 0, 0 |
|
7369 |
}, |
|
7370 |
// Format_MonoLSB, |
|
7371 |
{ |
|
7372 |
blend_color_generic, |
|
7373 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7374 |
0, 0, 0, 0 |
|
7375 |
}, |
|
7376 |
// Format_Indexed8, |
|
7377 |
{ |
|
7378 |
blend_color_generic, |
|
7379 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7380 |
0, 0, 0, 0 |
|
7381 |
}, |
|
7382 |
// Format_RGB32, |
|
7383 |
{ |
|
7384 |
blend_color_argb, |
|
7385 |
qt_gradient_quint32, |
|
7386 |
qt_bitmapblit_quint32, |
|
7387 |
qt_alphamapblit_quint32, |
|
7388 |
qt_alphargbblit_quint32, |
|
7389 |
qt_rectfill_quint32 |
|
7390 |
}, |
|
7391 |
// Format_ARGB32, |
|
7392 |
{ |
|
7393 |
blend_color_generic, |
|
7394 |
qt_gradient_quint32, |
|
7395 |
qt_bitmapblit_quint32, |
|
7396 |
qt_alphamapblit_quint32, |
|
7397 |
qt_alphargbblit_quint32, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7398 |
qt_rectfill_nonpremul_quint32 |
0 | 7399 |
}, |
7400 |
// Format_ARGB32_Premultiplied |
|
7401 |
{ |
|
7402 |
blend_color_argb, |
|
7403 |
qt_gradient_quint32, |
|
7404 |
qt_bitmapblit_quint32, |
|
7405 |
qt_alphamapblit_quint32, |
|
7406 |
qt_alphargbblit_quint32, |
|
7407 |
qt_rectfill_quint32 |
|
7408 |
}, |
|
7409 |
// Format_RGB16 |
|
7410 |
{ |
|
7411 |
blend_color_rgb16, |
|
7412 |
qt_gradient_quint16, |
|
7413 |
qt_bitmapblit_quint16, |
|
7414 |
qt_alphamapblit_quint16, |
|
7415 |
0, |
|
7416 |
qt_rectfill_quint16 |
|
7417 |
}, |
|
7418 |
// Format_ARGB8565_Premultiplied |
|
7419 |
{ |
|
7420 |
SPANFUNC_POINTER_BLENDCOLOR(qargb8565), |
|
7421 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7422 |
0, 0, 0, |
|
7423 |
qt_rectfill_qargb8565 |
|
7424 |
}, |
|
7425 |
// Format_RGB666 |
|
7426 |
{ |
|
7427 |
SPANFUNC_POINTER_BLENDCOLOR(qrgb666), |
|
7428 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7429 |
0, 0, 0, |
|
7430 |
qt_rectfill_qrgb666 |
|
7431 |
}, |
|
7432 |
// Format_ARGB6666_Premultiplied |
|
7433 |
{ |
|
7434 |
SPANFUNC_POINTER_BLENDCOLOR(qargb6666), |
|
7435 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7436 |
0, 0, 0, |
|
7437 |
qt_rectfill_qargb6666 |
|
7438 |
}, |
|
7439 |
// Format_RGB555 |
|
7440 |
{ |
|
7441 |
SPANFUNC_POINTER_BLENDCOLOR(qrgb555), |
|
7442 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7443 |
0, 0, 0, |
|
7444 |
qt_rectfill_qrgb555 |
|
7445 |
}, |
|
7446 |
// Format_ARGB8555_Premultiplied |
|
7447 |
{ |
|
7448 |
SPANFUNC_POINTER_BLENDCOLOR(qargb8555), |
|
7449 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7450 |
0, 0, 0, |
|
7451 |
qt_rectfill_qargb8555 |
|
7452 |
}, |
|
7453 |
// Format_RGB888 |
|
7454 |
{ |
|
7455 |
SPANFUNC_POINTER_BLENDCOLOR(qrgb888), |
|
7456 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7457 |
0, 0, 0, |
|
7458 |
qt_rectfill_qrgb888 |
|
7459 |
}, |
|
7460 |
// Format_RGB444 |
|
7461 |
{ |
|
7462 |
SPANFUNC_POINTER_BLENDCOLOR(qrgb444), |
|
7463 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7464 |
0, 0, 0, |
|
7465 |
qt_rectfill_qrgb444 |
|
7466 |
}, |
|
7467 |
// Format_ARGB4444_Premultiplied |
|
7468 |
{ |
|
7469 |
SPANFUNC_POINTER_BLENDCOLOR(qargb4444), |
|
7470 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7471 |
0, 0, 0, |
|
7472 |
qt_rectfill_qargb4444 |
|
7473 |
} |
|
7474 |
}; |
|
7475 |
||
7476 |
#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS) |
|
7477 |
DrawHelper qDrawHelperCallback[QImage::NImageFormats] = |
|
7478 |
{ |
|
7479 |
// Format_Invalid, |
|
7480 |
{ 0, 0, 0, 0, 0, 0 }, |
|
7481 |
// Format_Mono, |
|
7482 |
{ |
|
7483 |
blend_color_generic_callback, |
|
7484 |
blend_src_generic<CallbackSpans>, |
|
7485 |
0, 0, 0, 0 |
|
7486 |
}, |
|
7487 |
// Format_MonoLSB, |
|
7488 |
{ |
|
7489 |
blend_color_generic_callback, |
|
7490 |
blend_src_generic<CallbackSpans>, |
|
7491 |
0, 0, 0, 0 |
|
7492 |
}, |
|
7493 |
// Format_Indexed8, |
|
7494 |
{ |
|
7495 |
blend_color_generic_callback, |
|
7496 |
blend_src_generic<CallbackSpans>, |
|
7497 |
0, 0, 0, 0 |
|
7498 |
}, |
|
7499 |
// Format_RGB32, |
|
7500 |
{ |
|
7501 |
blend_color_generic_callback, |
|
7502 |
blend_src_generic<CallbackSpans>, |
|
7503 |
0, 0, 0, 0 |
|
7504 |
}, |
|
7505 |
// Format_ARGB32, |
|
7506 |
{ |
|
7507 |
blend_color_generic_callback, |
|
7508 |
blend_src_generic<CallbackSpans>, |
|
7509 |
0, 0, 0, 0 |
|
7510 |
}, |
|
7511 |
// Format_ARGB32_Premultiplied |
|
7512 |
{ |
|
7513 |
blend_color_generic_callback, |
|
7514 |
blend_src_generic<CallbackSpans>, |
|
7515 |
0, 0, 0, 0 |
|
7516 |
}, |
|
7517 |
// Format_RGB16 |
|
7518 |
{ |
|
7519 |
blend_color_generic_callback, |
|
7520 |
blend_src_generic<CallbackSpans>, |
|
7521 |
0, 0, 0, 0 |
|
7522 |
}, |
|
7523 |
// Format_ARGB8565_Premultiplied |
|
7524 |
{ |
|
7525 |
blend_color_generic_callback, |
|
7526 |
blend_src_generic<CallbackSpans>, |
|
7527 |
0, 0, 0, 0 |
|
7528 |
}, |
|
7529 |
// Format_RGB666 |
|
7530 |
{ |
|
7531 |
blend_color_generic_callback, |
|
7532 |
blend_src_generic<CallbackSpans>, |
|
7533 |
0, 0, 0, 0 |
|
7534 |
}, |
|
7535 |
// Format_ARGB6666_Premultiplied |
|
7536 |
{ |
|
7537 |
blend_color_generic_callback, |
|
7538 |
blend_src_generic<CallbackSpans>, |
|
7539 |
0, 0, 0, 0 |
|
7540 |
}, |
|
7541 |
// Format_RGB555 |
|
7542 |
{ |
|
7543 |
blend_color_generic_callback, |
|
7544 |
blend_src_generic<CallbackSpans>, |
|
7545 |
0, 0, 0, 0 |
|
7546 |
}, |
|
7547 |
// Format_ARGB8555_Premultiplied |
|
7548 |
{ |
|
7549 |
blend_color_generic_callback, |
|
7550 |
blend_src_generic<CallbackSpans>, |
|
7551 |
0, 0, 0, 0 |
|
7552 |
}, |
|
7553 |
// Format_RGB888 |
|
7554 |
{ |
|
7555 |
blend_color_generic_callback, |
|
7556 |
blend_src_generic<CallbackSpans>, |
|
7557 |
0, 0, 0, 0 |
|
7558 |
}, |
|
7559 |
// Format_RGB444 |
|
7560 |
{ |
|
7561 |
blend_color_generic_callback, |
|
7562 |
blend_src_generic<CallbackSpans>, |
|
7563 |
0, 0, 0, 0 |
|
7564 |
}, |
|
7565 |
// Format_ARGB4444_Premultiplied |
|
7566 |
{ |
|
7567 |
blend_color_generic_callback, |
|
7568 |
blend_src_generic<CallbackSpans>, |
|
7569 |
0, 0, 0, 0 |
|
7570 |
} |
|
7571 |
}; |
|
7572 |
#endif |
|
7573 |
||
7574 |
||
7575 |
||
7576 |
#if defined(Q_CC_MSVC) && !defined(_MIPS_) |
|
7577 |
template <class DST, class SRC> |
|
7578 |
inline void qt_memfill_template(DST *dest, SRC color, int count) |
|
7579 |
{ |
|
7580 |
const DST c = qt_colorConvert<DST, SRC>(color, 0); |
|
7581 |
while (count--) |
|
7582 |
*dest++ = c; |
|
7583 |
} |
|
7584 |
||
7585 |
#else |
|
7586 |
||
7587 |
template <class DST, class SRC> |
|
7588 |
inline void qt_memfill_template(DST *dest, SRC color, int count) |
|
7589 |
{ |
|
7590 |
const DST c = qt_colorConvert<DST, SRC>(color, 0); |
|
7591 |
int n = (count + 7) / 8; |
|
7592 |
switch (count & 0x07) |
|
7593 |
{ |
|
7594 |
case 0: do { *dest++ = c; |
|
7595 |
case 7: *dest++ = c; |
|
7596 |
case 6: *dest++ = c; |
|
7597 |
case 5: *dest++ = c; |
|
7598 |
case 4: *dest++ = c; |
|
7599 |
case 3: *dest++ = c; |
|
7600 |
case 2: *dest++ = c; |
|
7601 |
case 1: *dest++ = c; |
|
7602 |
} while (--n > 0); |
|
7603 |
} |
|
7604 |
} |
|
7605 |
||
7606 |
template <> |
|
7607 |
inline void qt_memfill_template(quint16 *dest, quint16 value, int count) |
|
7608 |
{ |
|
7609 |
if (count < 3) { |
|
7610 |
switch (count) { |
|
7611 |
case 2: *dest++ = value; |
|
7612 |
case 1: *dest = value; |
|
7613 |
} |
|
7614 |
return; |
|
7615 |
} |
|
7616 |
||
7617 |
const int align = (quintptr)(dest) & 0x3; |
|
7618 |
switch (align) { |
|
7619 |
case 2: *dest++ = value; --count; |
|
7620 |
} |
|
7621 |
||
7622 |
const quint32 value32 = (value << 16) | value; |
|
7623 |
qt_memfill(reinterpret_cast<quint32*>(dest), value32, count / 2); |
|
7624 |
if (count & 0x1) |
|
7625 |
dest[count - 1] = value; |
|
7626 |
} |
|
7627 |
#endif |
|
7628 |
||
7629 |
static void qt_memfill_quint16(quint16 *dest, quint16 color, int count) |
|
7630 |
{ |
|
7631 |
qt_memfill_template<quint16, quint16>(dest, color, count); |
|
7632 |
} |
|
7633 |
||
7634 |
typedef void (*qt_memfill32_func)(quint32 *dest, quint32 value, int count); |
|
7635 |
typedef void (*qt_memfill16_func)(quint16 *dest, quint16 value, int count); |
|
7636 |
static void qt_memfill32_setup(quint32 *dest, quint32 value, int count); |
|
7637 |
static void qt_memfill16_setup(quint16 *dest, quint16 value, int count); |
|
7638 |
||
7639 |
qt_memfill32_func qt_memfill32 = qt_memfill32_setup; |
|
7640 |
qt_memfill16_func qt_memfill16 = qt_memfill16_setup; |
|
7641 |
||
7642 |
#if defined(Q_CC_RVCT) && defined(QT_HAVE_ARMV6) |
|
7643 |
// Move these to qdrawhelper_arm.c when all |
|
7644 |
// functions are implemented using arm assembly. |
|
7645 |
static CompositionFunctionSolid qt_functionForModeSolid_ARMv6[numCompositionFunctions] = { |
|
7646 |
comp_func_solid_SourceOver, |
|
7647 |
comp_func_solid_DestinationOver, |
|
7648 |
comp_func_solid_Clear, |
|
7649 |
comp_func_solid_Source, |
|
7650 |
comp_func_solid_Destination, |
|
7651 |
comp_func_solid_SourceIn, |
|
7652 |
comp_func_solid_DestinationIn, |
|
7653 |
comp_func_solid_SourceOut, |
|
7654 |
comp_func_solid_DestinationOut, |
|
7655 |
comp_func_solid_SourceAtop, |
|
7656 |
comp_func_solid_DestinationAtop, |
|
7657 |
comp_func_solid_XOR, |
|
7658 |
comp_func_solid_Plus, |
|
7659 |
comp_func_solid_Multiply, |
|
7660 |
comp_func_solid_Screen, |
|
7661 |
comp_func_solid_Overlay, |
|
7662 |
comp_func_solid_Darken, |
|
7663 |
comp_func_solid_Lighten, |
|
7664 |
comp_func_solid_ColorDodge, |
|
7665 |
comp_func_solid_ColorBurn, |
|
7666 |
comp_func_solid_HardLight, |
|
7667 |
comp_func_solid_SoftLight, |
|
7668 |
comp_func_solid_Difference, |
|
7669 |
comp_func_solid_Exclusion, |
|
7670 |
rasterop_solid_SourceOrDestination, |
|
7671 |
rasterop_solid_SourceAndDestination, |
|
7672 |
rasterop_solid_SourceXorDestination, |
|
7673 |
rasterop_solid_NotSourceAndNotDestination, |
|
7674 |
rasterop_solid_NotSourceOrNotDestination, |
|
7675 |
rasterop_solid_NotSourceXorDestination, |
|
7676 |
rasterop_solid_NotSource, |
|
7677 |
rasterop_solid_NotSourceAndDestination, |
|
7678 |
rasterop_solid_SourceAndNotDestination |
|
7679 |
}; |
|
7680 |
||
7681 |
static CompositionFunction qt_functionForMode_ARMv6[numCompositionFunctions] = { |
|
7682 |
comp_func_SourceOver_armv6, |
|
7683 |
comp_func_DestinationOver, |
|
7684 |
comp_func_Clear, |
|
7685 |
comp_func_Source_armv6, |
|
7686 |
comp_func_Destination, |
|
7687 |
comp_func_SourceIn, |
|
7688 |
comp_func_DestinationIn, |
|
7689 |
comp_func_SourceOut, |
|
7690 |
comp_func_DestinationOut, |
|
7691 |
comp_func_SourceAtop, |
|
7692 |
comp_func_DestinationAtop, |
|
7693 |
comp_func_XOR, |
|
7694 |
comp_func_Plus, |
|
7695 |
comp_func_Multiply, |
|
7696 |
comp_func_Screen, |
|
7697 |
comp_func_Overlay, |
|
7698 |
comp_func_Darken, |
|
7699 |
comp_func_Lighten, |
|
7700 |
comp_func_ColorDodge, |
|
7701 |
comp_func_ColorBurn, |
|
7702 |
comp_func_HardLight, |
|
7703 |
comp_func_SoftLight, |
|
7704 |
comp_func_Difference, |
|
7705 |
comp_func_Exclusion, |
|
7706 |
rasterop_SourceOrDestination, |
|
7707 |
rasterop_SourceAndDestination, |
|
7708 |
rasterop_SourceXorDestination, |
|
7709 |
rasterop_NotSourceAndNotDestination, |
|
7710 |
rasterop_NotSourceOrNotDestination, |
|
7711 |
rasterop_NotSourceXorDestination, |
|
7712 |
rasterop_NotSource, |
|
7713 |
rasterop_NotSourceAndDestination, |
|
7714 |
rasterop_SourceAndNotDestination |
|
7715 |
}; |
|
7716 |
||
7717 |
static void qt_blend_color_argb_armv6(int count, const QSpan *spans, void *userData) |
|
7718 |
{ |
|
7719 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
7720 |
||
7721 |
CompositionFunctionSolid func = qt_functionForModeSolid_ARMv6[data->rasterBuffer->compositionMode]; |
|
7722 |
while (count--) { |
|
7723 |
uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
7724 |
func(target, spans->len, data->solid.color, spans->coverage); |
|
7725 |
++spans; |
|
7726 |
} |
|
7727 |
} |
|
7728 |
||
7729 |
#endif // Q_CC_RVCT && QT_HAVE_ARMV6 |
|
7730 |
||
7731 |
||
7732 |
void qInitDrawhelperAsm() |
|
7733 |
{ |
|
7734 |
||
7735 |
qt_memfill32 = qt_memfill_template<quint32, quint32>; |
|
7736 |
qt_memfill16 = qt_memfill_quint16; //qt_memfill_template<quint16, quint16>; |
|
7737 |
||
7738 |
CompositionFunction *functionForModeAsm = 0; |
|
7739 |
CompositionFunctionSolid *functionForModeSolidAsm = 0; |
|
7740 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7741 |
const uint features = qDetectCPUFeatures(); |
0 | 7742 |
if (false) { |
7743 |
#ifdef QT_HAVE_SSE2 |
|
7744 |
} else if (features & SSE2) { |
|
7745 |
qt_memfill32 = qt_memfill32_sse2; |
|
7746 |
qt_memfill16 = qt_memfill16_sse2; |
|
7747 |
qDrawHelper[QImage::Format_RGB32].bitmapBlit = qt_bitmapblit32_sse2; |
|
7748 |
qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_sse2; |
|
7749 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2; |
|
7750 |
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse2; |
|
7751 |
#endif |
|
7752 |
#ifdef QT_HAVE_SSE |
|
7753 |
} else if (features & SSE) { |
|
7754 |
// qt_memfill32 = qt_memfill32_sse; |
|
7755 |
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse; |
|
7756 |
#ifdef QT_HAVE_3DNOW |
|
7757 |
if (features & MMX3DNOW) { |
|
7758 |
qt_memfill32 = qt_memfill32_sse3dnow; |
|
7759 |
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse3dnow; |
|
7760 |
} |
|
7761 |
#endif |
|
7762 |
#endif // SSE |
|
7763 |
#if defined(QT_HAVE_MMXEXT) && defined(QT_HAVE_SSE) |
|
7764 |
} else if (features & MMXEXT) { |
|
7765 |
qt_memfill32 = qt_memfill32_sse; |
|
7766 |
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse; |
|
7767 |
# ifdef QT_HAVE_3DNOW |
|
7768 |
if (features & MMX3DNOW) { |
|
7769 |
qt_memfill32 = qt_memfill32_sse3dnow; |
|
7770 |
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse3dnow; |
|
7771 |
} |
|
7772 |
# endif // 3DNOW |
|
7773 |
#endif // MMXEXT |
|
7774 |
} |
|
7775 |
#ifdef QT_HAVE_MMX |
|
7776 |
if (features & MMX) { |
|
7777 |
functionForModeAsm = qt_functionForMode_MMX; |
|
7778 |
functionForModeSolidAsm = qt_functionForModeSolid_MMX; |
|
7779 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_mmx; |
|
7780 |
#ifdef QT_HAVE_3DNOW |
|
7781 |
if (features & MMX3DNOW) { |
|
7782 |
functionForModeAsm = qt_functionForMode_MMX3DNOW; |
|
7783 |
functionForModeSolidAsm = qt_functionForModeSolid_MMX3DNOW; |
|
7784 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_mmx3dnow; |
|
7785 |
} |
|
7786 |
#endif // 3DNOW |
|
7787 |
||
7788 |
extern void qt_blend_rgb32_on_rgb32_mmx(uchar *destPixels, int dbpl, |
|
7789 |
const uchar *srcPixels, int sbpl, |
|
7790 |
int w, int h, |
|
7791 |
int const_alpha); |
|
7792 |
extern void qt_blend_argb32_on_argb32_mmx(uchar *destPixels, int dbpl, |
|
7793 |
const uchar *srcPixels, int sbpl, |
|
7794 |
int w, int h, |
|
7795 |
int const_alpha); |
|
7796 |
||
7797 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mmx; |
|
7798 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mmx; |
|
7799 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_mmx; |
|
7800 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_mmx; |
|
7801 |
||
7802 |
} |
|
7803 |
#endif // MMX |
|
7804 |
||
7805 |
#ifdef QT_HAVE_SSE |
|
7806 |
if (features & SSE) { |
|
7807 |
functionForModeAsm = qt_functionForMode_SSE; |
|
7808 |
functionForModeSolidAsm = qt_functionForModeSolid_SSE; |
|
7809 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_sse; |
|
7810 |
#ifdef QT_HAVE_3DNOW |
|
7811 |
if (features & MMX3DNOW) { |
|
7812 |
functionForModeAsm = qt_functionForMode_SSE3DNOW; |
|
7813 |
functionForModeSolidAsm = qt_functionForModeSolid_SSE3DNOW; |
|
7814 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_sse3dnow; |
|
7815 |
} |
|
7816 |
#endif // 3DNOW |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7817 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7818 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7819 |
#ifdef QT_HAVE_SSE2 |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7820 |
if (features & SSE2) { |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7821 |
extern void QT_FASTCALL comp_func_SourceOver_sse2(uint *destPixels, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7822 |
const uint *srcPixels, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7823 |
int length, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7824 |
uint const_alpha); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7825 |
extern void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, uint color, uint const_alpha); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7826 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7827 |
functionForModeAsm[0] = comp_func_SourceOver_sse2; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7828 |
functionForModeSolidAsm[0] = comp_func_solid_SourceOver_sse2; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7829 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7830 |
extern void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7831 |
const uchar *srcPixels, int sbpl, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7832 |
int w, int h, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7833 |
int const_alpha); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7834 |
extern void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7835 |
const uchar *srcPixels, int sbpl, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7836 |
int w, int h, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7837 |
int const_alpha); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7838 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7839 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7840 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7841 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7842 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7843 |
} else |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7844 |
#endif |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7845 |
{ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7846 |
extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7847 |
const uchar *srcPixels, int sbpl, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7848 |
int w, int h, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7849 |
int const_alpha); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7850 |
extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7851 |
const uchar *srcPixels, int sbpl, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7852 |
int w, int h, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7853 |
int const_alpha); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7854 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7855 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7856 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7857 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7858 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7859 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7860 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7861 |
} |
0 | 7862 |
#endif // SSE |
7863 |
||
7864 |
#ifdef QT_HAVE_IWMMXT |
|
7865 |
if (features & IWMMXT) { |
|
7866 |
functionForModeAsm = qt_functionForMode_IWMMXT; |
|
7867 |
functionForModeSolidAsm = qt_functionForModeSolid_IWMMXT; |
|
7868 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_iwmmxt; |
|
7869 |
} |
|
7870 |
#endif // IWMMXT |
|
7871 |
||
7872 |
#if defined(Q_CC_RVCT) && defined(QT_HAVE_ARMV6) |
|
7873 |
functionForModeAsm = qt_functionForMode_ARMv6; |
|
7874 |
functionForModeSolidAsm = qt_functionForModeSolid_ARMv6; |
|
7875 |
||
7876 |
qt_memfill32 = qt_memfill32_armv6; |
|
7877 |
||
7878 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_armv6; |
|
7879 |
||
7880 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_armv6; |
|
7881 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_armv6; |
|
7882 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_armv6; |
|
7883 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_armv6; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7884 |
#elif defined(QT_HAVE_NEON) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7885 |
if (features & NEON) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7886 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7887 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7888 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_neon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7889 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_neon; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7890 |
qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16_neon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7891 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB16] = qt_blend_rgb16_on_argb32_neon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7892 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7893 |
qScaleFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_rgb16_neon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7894 |
qScaleFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_scale_image_rgb16_on_rgb16_neon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7895 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7896 |
qTransformFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_rgb16_neon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7897 |
qTransformFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_transform_image_rgb16_on_rgb16_neon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7898 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7899 |
qDrawHelper[QImage::Format_RGB16].alphamapBlit = qt_alphamapblit_quint16_neon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7900 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7901 |
functionForMode_C[QPainter::CompositionMode_SourceOver] = qt_blend_argb32_on_argb32_scanline_neon; |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7902 |
functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_neon; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7903 |
destFetchProc[QImage::Format_RGB16] = qt_destFetchRGB16_neon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7904 |
destStoreProc[QImage::Format_RGB16] = qt_destStoreRGB16_neon; |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7905 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7906 |
qMemRotateFunctions[QImage::Format_RGB16][0] = qt_memrotate90_16_neon; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7907 |
qMemRotateFunctions[QImage::Format_RGB16][2] = qt_memrotate270_16_neon; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7908 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7909 |
#endif |
0 | 7910 |
|
7911 |
if (functionForModeSolidAsm) { |
|
7912 |
const int destinationMode = QPainter::CompositionMode_Destination; |
|
7913 |
functionForModeSolidAsm[destinationMode] = functionForModeSolid_C[destinationMode]; |
|
7914 |
||
7915 |
// use the default qdrawhelper implementation for the |
|
7916 |
// extended composition modes |
|
7917 |
for (int mode = 12; mode < 24; ++mode) |
|
7918 |
functionForModeSolidAsm[mode] = functionForModeSolid_C[mode]; |
|
7919 |
||
7920 |
functionForModeSolid = functionForModeSolidAsm; |
|
7921 |
} |
|
7922 |
if (functionForModeAsm) { |
|
7923 |
const int destinationMode = QPainter::CompositionMode_Destination; |
|
7924 |
functionForModeAsm[destinationMode] = functionForMode_C[destinationMode]; |
|
7925 |
||
7926 |
// use the default qdrawhelper implementation for the |
|
7927 |
// extended composition modes |
|
7928 |
for (int mode = 12; mode < numCompositionFunctions; ++mode) |
|
7929 |
functionForModeAsm[mode] = functionForMode_C[mode]; |
|
7930 |
||
7931 |
functionForMode = functionForModeAsm; |
|
7932 |
} |
|
7933 |
||
7934 |
qt_build_pow_tables(); |
|
7935 |
} |
|
7936 |
||
7937 |
static void qt_memfill32_setup(quint32 *dest, quint32 value, int count) |
|
7938 |
{ |
|
7939 |
qInitDrawhelperAsm(); |
|
7940 |
qt_memfill32(dest, value, count); |
|
7941 |
} |
|
7942 |
||
7943 |
static void qt_memfill16_setup(quint16 *dest, quint16 value, int count) |
|
7944 |
{ |
|
7945 |
qInitDrawhelperAsm(); |
|
7946 |
qt_memfill16(dest, value, count); |
|
7947 |
} |
|
7948 |
||
7949 |
#ifdef QT_QWS_DEPTH_GENERIC |
|
7950 |
||
7951 |
int qrgb::bpp = 0; |
|
7952 |
int qrgb::len_red = 0; |
|
7953 |
int qrgb::len_green = 0; |
|
7954 |
int qrgb::len_blue = 0; |
|
7955 |
int qrgb::len_alpha = 0; |
|
7956 |
int qrgb::off_red = 0; |
|
7957 |
int qrgb::off_green = 0; |
|
7958 |
int qrgb::off_blue = 0; |
|
7959 |
int qrgb::off_alpha = 0; |
|
7960 |
||
7961 |
template <typename SRC> |
|
7962 |
Q_STATIC_TEMPLATE_FUNCTION inline void qt_rectconvert_rgb(qrgb *dest, const SRC *src, |
|
7963 |
int x, int y, int width, int height, |
|
7964 |
int dstStride, int srcStride) |
|
7965 |
{ |
|
7966 |
quint8 *dest8 = reinterpret_cast<quint8*>(dest) |
|
7967 |
+ y * dstStride + x * qrgb::bpp; |
|
7968 |
||
7969 |
srcStride = srcStride / sizeof(SRC) - width; |
|
7970 |
dstStride -= (width * qrgb::bpp); |
|
7971 |
||
7972 |
for (int j = 0; j < height; ++j) { |
|
7973 |
for (int i = 0; i < width; ++i) { |
|
7974 |
const quint32 v = qt_convertToRgb<SRC>(*src++); |
|
7975 |
#if Q_BYTE_ORDER == Q_BIG_ENDIAN |
|
7976 |
for (int j = qrgb::bpp - 1; j >= 0; --j) |
|
7977 |
*dest8++ = (v >> (8 * j)) & 0xff; |
|
7978 |
#else |
|
7979 |
for (int j = 0; j < qrgb::bpp; ++j) |
|
7980 |
*dest8++ = (v >> (8 * j)) & 0xff; |
|
7981 |
#endif |
|
7982 |
} |
|
7983 |
||
7984 |
dest8 += dstStride; |
|
7985 |
src += srcStride; |
|
7986 |
} |
|
7987 |
} |
|
7988 |
||
7989 |
template <> |
|
7990 |
void qt_rectconvert(qrgb *dest, const quint32 *src, |
|
7991 |
int x, int y, int width, int height, |
|
7992 |
int dstStride, int srcStride) |
|
7993 |
{ |
|
7994 |
qt_rectconvert_rgb<quint32>(dest, src, x, y, width, height, |
|
7995 |
dstStride, srcStride); |
|
7996 |
} |
|
7997 |
||
7998 |
template <> |
|
7999 |
void qt_rectconvert(qrgb *dest, const quint16 *src, |
|
8000 |
int x, int y, int width, int height, |
|
8001 |
int dstStride, int srcStride) |
|
8002 |
{ |
|
8003 |
qt_rectconvert_rgb<quint16>(dest, src, x, y, width, height, |
|
8004 |
dstStride, srcStride); |
|
8005 |
} |
|
8006 |
||
8007 |
#endif // QT_QWS_DEPTH_GENERIC |
|
8008 |
||
8009 |
QT_END_NAMESPACE |