author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 33 | 3e2da88830cd |
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> |
49 |
#include <qmath.h> |
|
50 |
||
51 |
QT_BEGIN_NAMESPACE |
|
52 |
||
53 |
||
54 |
#define MASK(src, a) src = BYTE_MUL(src, a) |
|
55 |
||
56 |
#if defined(Q_OS_IRIX) && defined(Q_CC_GNU) && __GNUC__ == 3 && __GNUC__ < 4 && QT_POINTER_SIZE == 8 |
|
57 |
#define Q_IRIX_GCC3_3_WORKAROUND |
|
58 |
// |
|
59 |
// work around http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14484 |
|
60 |
// |
|
61 |
static uint gccBug(uint value) __attribute__((noinline)); |
|
62 |
static uint gccBug(uint value) |
|
63 |
{ |
|
64 |
return value; |
|
65 |
} |
|
66 |
#endif |
|
67 |
||
68 |
/* |
|
69 |
constants and structures |
|
70 |
*/ |
|
71 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
72 |
enum { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
73 |
fixed_scale = 1 << 16, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
74 |
half_point = 1 << 15 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
75 |
}; |
0 | 76 |
static const int buffer_size = 2048; |
77 |
||
78 |
struct LinearGradientValues |
|
79 |
{ |
|
80 |
qreal dx; |
|
81 |
qreal dy; |
|
82 |
qreal l; |
|
83 |
qreal off; |
|
84 |
}; |
|
85 |
||
86 |
struct RadialGradientValues |
|
87 |
{ |
|
88 |
qreal dx; |
|
89 |
qreal dy; |
|
90 |
qreal a; |
|
91 |
}; |
|
92 |
||
93 |
struct Operator; |
|
94 |
typedef uint* (QT_FASTCALL *DestFetchProc)(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length); |
|
95 |
typedef void (QT_FASTCALL *DestStoreProc)(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length); |
|
96 |
typedef const uint* (QT_FASTCALL *SourceFetchProc)(uint *buffer, const Operator *o, const QSpanData *data, int y, int x, int length); |
|
97 |
||
98 |
||
99 |
struct Operator |
|
100 |
{ |
|
101 |
QPainter::CompositionMode mode; |
|
102 |
DestFetchProc dest_fetch; |
|
103 |
DestStoreProc dest_store; |
|
104 |
SourceFetchProc src_fetch; |
|
105 |
CompositionFunctionSolid funcSolid; |
|
106 |
CompositionFunction func; |
|
107 |
union { |
|
108 |
LinearGradientValues linear; |
|
109 |
RadialGradientValues radial; |
|
110 |
// TextureValues texture; |
|
111 |
}; |
|
112 |
}; |
|
113 |
||
114 |
/* |
|
115 |
Destination fetch. This is simple as we don't have to do bounds checks or |
|
116 |
transformations |
|
117 |
*/ |
|
118 |
||
119 |
static uint * QT_FASTCALL destFetchMono(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) |
|
120 |
{ |
|
121 |
uchar *data = (uchar *)rasterBuffer->scanLine(y); |
|
122 |
uint *start = buffer; |
|
123 |
const uint *end = buffer + length; |
|
124 |
while (buffer < end) { |
|
125 |
*buffer = data[x>>3] & (0x80 >> (x & 7)) ? rasterBuffer->destColor1 : rasterBuffer->destColor0; |
|
126 |
++buffer; |
|
127 |
++x; |
|
128 |
} |
|
129 |
return start; |
|
130 |
} |
|
131 |
||
132 |
static uint * QT_FASTCALL destFetchMonoLsb(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) |
|
133 |
{ |
|
134 |
uchar *data = (uchar *)rasterBuffer->scanLine(y); |
|
135 |
uint *start = buffer; |
|
136 |
const uint *end = buffer + length; |
|
137 |
while (buffer < end) { |
|
138 |
*buffer = data[x>>3] & (0x1 << (x & 7)) ? rasterBuffer->destColor1 : rasterBuffer->destColor0; |
|
139 |
++buffer; |
|
140 |
++x; |
|
141 |
} |
|
142 |
return start; |
|
143 |
} |
|
144 |
||
145 |
static uint * QT_FASTCALL destFetchARGB32(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) |
|
146 |
{ |
|
147 |
const uint *data = (const uint *)rasterBuffer->scanLine(y) + x; |
|
148 |
for (int i = 0; i < length; ++i) |
|
149 |
buffer[i] = PREMUL(data[i]); |
|
150 |
return buffer; |
|
151 |
} |
|
152 |
||
153 |
static uint * QT_FASTCALL destFetchARGB32P(uint *, QRasterBuffer *rasterBuffer, int x, int y, int) |
|
154 |
{ |
|
155 |
return (uint *)rasterBuffer->scanLine(y) + x; |
|
156 |
} |
|
157 |
||
158 |
static uint * QT_FASTCALL destFetchRGB16(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) |
|
159 |
{ |
|
160 |
const ushort *data = (const ushort *)rasterBuffer->scanLine(y) + x; |
|
161 |
for (int i = 0; i < length; ++i) |
|
162 |
buffer[i] = qConvertRgb16To32(data[i]); |
|
163 |
return buffer; |
|
164 |
} |
|
165 |
||
166 |
template <class DST> |
|
167 |
Q_STATIC_TEMPLATE_FUNCTION uint * QT_FASTCALL destFetch(uint *buffer, QRasterBuffer *rasterBuffer, |
|
168 |
int x, int y, int length) |
|
169 |
{ |
|
170 |
const DST *src = reinterpret_cast<DST*>(rasterBuffer->scanLine(y)) + x; |
|
171 |
quint32 *dest = reinterpret_cast<quint32*>(buffer); |
|
172 |
while (length--) |
|
173 |
*dest++ = *src++; |
|
174 |
return buffer; |
|
175 |
} |
|
176 |
||
177 |
# define SPANFUNC_POINTER_DESTFETCH(Arg) destFetch<Arg> |
|
178 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
179 |
static DestFetchProc destFetchProc[QImage::NImageFormats] = |
0 | 180 |
{ |
181 |
0, // Format_Invalid |
|
182 |
destFetchMono, // Format_Mono, |
|
183 |
destFetchMonoLsb, // Format_MonoLSB |
|
184 |
0, // Format_Indexed8 |
|
185 |
destFetchARGB32P, // Format_RGB32 |
|
186 |
destFetchARGB32, // Format_ARGB32, |
|
187 |
destFetchARGB32P, // Format_ARGB32_Premultiplied |
|
188 |
destFetchRGB16, // Format_RGB16 |
|
189 |
SPANFUNC_POINTER_DESTFETCH(qargb8565), // Format_ARGB8565_Premultiplied |
|
190 |
SPANFUNC_POINTER_DESTFETCH(qrgb666), // Format_RGB666 |
|
191 |
SPANFUNC_POINTER_DESTFETCH(qargb6666), // Format_ARGB6666_Premultiplied |
|
192 |
SPANFUNC_POINTER_DESTFETCH(qrgb555), // Format_RGB555 |
|
193 |
SPANFUNC_POINTER_DESTFETCH(qargb8555), // Format_ARGB8555_Premultiplied |
|
194 |
SPANFUNC_POINTER_DESTFETCH(qrgb888), // Format_RGB888 |
|
195 |
SPANFUNC_POINTER_DESTFETCH(qrgb444), // Format_RGB444 |
|
196 |
SPANFUNC_POINTER_DESTFETCH(qargb4444) // Format_ARGB4444_Premultiplied |
|
197 |
}; |
|
198 |
||
199 |
/* |
|
200 |
Returns the color in the mono destination color table |
|
201 |
that is the "nearest" to /color/. |
|
202 |
*/ |
|
203 |
static inline QRgb findNearestColor(QRgb color, QRasterBuffer *rbuf) |
|
204 |
{ |
|
205 |
QRgb color_0 = PREMUL(rbuf->destColor0); |
|
206 |
QRgb color_1 = PREMUL(rbuf->destColor1); |
|
207 |
color = PREMUL(color); |
|
208 |
||
209 |
int r = qRed(color); |
|
210 |
int g = qGreen(color); |
|
211 |
int b = qBlue(color); |
|
212 |
int rx, gx, bx; |
|
213 |
int dist_0, dist_1; |
|
214 |
||
215 |
rx = r - qRed(color_0); |
|
216 |
gx = g - qGreen(color_0); |
|
217 |
bx = b - qBlue(color_0); |
|
218 |
dist_0 = rx*rx + gx*gx + bx*bx; |
|
219 |
||
220 |
rx = r - qRed(color_1); |
|
221 |
gx = g - qGreen(color_1); |
|
222 |
bx = b - qBlue(color_1); |
|
223 |
dist_1 = rx*rx + gx*gx + bx*bx; |
|
224 |
||
225 |
if (dist_0 < dist_1) |
|
226 |
return color_0; |
|
227 |
return color_1; |
|
228 |
} |
|
229 |
||
230 |
/* |
|
231 |
Destination store. |
|
232 |
*/ |
|
233 |
||
234 |
static void QT_FASTCALL destStoreMono(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) |
|
235 |
{ |
|
236 |
uchar *data = (uchar *)rasterBuffer->scanLine(y); |
|
237 |
if (rasterBuffer->monoDestinationWithClut) { |
|
238 |
for (int i = 0; i < length; ++i) { |
|
239 |
if (buffer[i] == rasterBuffer->destColor0) { |
|
240 |
data[x >> 3] &= ~(0x80 >> (x & 7)); |
|
241 |
} else if (buffer[i] == rasterBuffer->destColor1) { |
|
242 |
data[x >> 3] |= 0x80 >> (x & 7); |
|
243 |
} else if (findNearestColor(buffer[i], rasterBuffer) == rasterBuffer->destColor0) { |
|
244 |
data[x >> 3] &= ~(0x80 >> (x & 7)); |
|
245 |
} else { |
|
246 |
data[x >> 3] |= 0x80 >> (x & 7); |
|
247 |
} |
|
248 |
++x; |
|
249 |
} |
|
250 |
} else { |
|
251 |
for (int i = 0; i < length; ++i) { |
|
252 |
if (qGray(buffer[i]) < int(qt_bayer_matrix[y & 15][x & 15])) |
|
253 |
data[x >> 3] |= 0x80 >> (x & 7); |
|
254 |
else |
|
255 |
data[x >> 3] &= ~(0x80 >> (x & 7)); |
|
256 |
++x; |
|
257 |
} |
|
258 |
} |
|
259 |
} |
|
260 |
||
261 |
static void QT_FASTCALL destStoreMonoLsb(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) |
|
262 |
{ |
|
263 |
uchar *data = (uchar *)rasterBuffer->scanLine(y); |
|
264 |
if (rasterBuffer->monoDestinationWithClut) { |
|
265 |
for (int i = 0; i < length; ++i) { |
|
266 |
if (buffer[i] == rasterBuffer->destColor0) { |
|
267 |
data[x >> 3] &= ~(1 << (x & 7)); |
|
268 |
} else if (buffer[i] == rasterBuffer->destColor1) { |
|
269 |
data[x >> 3] |= 1 << (x & 7); |
|
270 |
} else if (findNearestColor(buffer[i], rasterBuffer) == rasterBuffer->destColor0) { |
|
271 |
data[x >> 3] &= ~(1 << (x & 7)); |
|
272 |
} else { |
|
273 |
data[x >> 3] |= 1 << (x & 7); |
|
274 |
} |
|
275 |
++x; |
|
276 |
} |
|
277 |
} else { |
|
278 |
for (int i = 0; i < length; ++i) { |
|
279 |
if (qGray(buffer[i]) < int(qt_bayer_matrix[y & 15][x & 15])) |
|
280 |
data[x >> 3] |= 1 << (x & 7); |
|
281 |
else |
|
282 |
data[x >> 3] &= ~(1 << (x & 7)); |
|
283 |
++x; |
|
284 |
} |
|
285 |
} |
|
286 |
} |
|
287 |
||
288 |
static void QT_FASTCALL destStoreARGB32(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) |
|
289 |
{ |
|
290 |
uint *data = (uint *)rasterBuffer->scanLine(y) + x; |
|
291 |
for (int i = 0; i < length; ++i) { |
|
292 |
int p = buffer[i]; |
|
293 |
int alpha = qAlpha(p); |
|
294 |
if (alpha == 255) |
|
295 |
data[i] = p; |
|
296 |
else if (alpha == 0) |
|
297 |
data[i] = 0; |
|
298 |
else { |
|
299 |
int inv_alpha = 0xff0000/qAlpha(buffer[i]); |
|
300 |
data[i] = (p & 0xff000000) |
|
301 |
| ((qRed(p)*inv_alpha) & 0xff0000) |
|
302 |
| (((qGreen(p)*inv_alpha) >> 8) & 0xff00) |
|
303 |
| ((qBlue(p)*inv_alpha) >> 16); |
|
304 |
} |
|
305 |
} |
|
306 |
} |
|
307 |
||
308 |
static void QT_FASTCALL destStoreRGB16(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) |
|
309 |
{ |
|
310 |
quint16 *data = (quint16*)rasterBuffer->scanLine(y) + x; |
|
311 |
qt_memconvert<quint16, quint32>(data, buffer, length); |
|
312 |
} |
|
313 |
||
314 |
template <class DST> |
|
315 |
Q_STATIC_TEMPLATE_FUNCTION void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer, |
|
316 |
int x, int y, |
|
317 |
const uint *buffer, int length) |
|
318 |
{ |
|
319 |
DST *dest = reinterpret_cast<DST*>(rasterBuffer->scanLine(y)) + x; |
|
320 |
const quint32p *src = reinterpret_cast<const quint32p*>(buffer); |
|
321 |
while (length--) |
|
322 |
*dest++ = DST(*src++); |
|
323 |
} |
|
324 |
||
325 |
# define SPANFUNC_POINTER_DESTSTORE(DEST) destStore<DEST> |
|
326 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
327 |
static DestStoreProc destStoreProc[QImage::NImageFormats] = |
0 | 328 |
{ |
329 |
0, // Format_Invalid |
|
330 |
destStoreMono, // Format_Mono, |
|
331 |
destStoreMonoLsb, // Format_MonoLSB |
|
332 |
0, // Format_Indexed8 |
|
333 |
0, // Format_RGB32 |
|
334 |
destStoreARGB32, // Format_ARGB32, |
|
335 |
0, // Format_ARGB32_Premultiplied |
|
336 |
destStoreRGB16, // Format_RGB16 |
|
337 |
SPANFUNC_POINTER_DESTSTORE(qargb8565), // Format_ARGB8565_Premultiplied |
|
338 |
SPANFUNC_POINTER_DESTSTORE(qrgb666), // Format_RGB666 |
|
339 |
SPANFUNC_POINTER_DESTSTORE(qargb6666), // Format_ARGB6666_Premultiplied |
|
340 |
SPANFUNC_POINTER_DESTSTORE(qrgb555), // Format_RGB555 |
|
341 |
SPANFUNC_POINTER_DESTSTORE(qargb8555), // Format_ARGB8555_Premultiplied |
|
342 |
SPANFUNC_POINTER_DESTSTORE(qrgb888), // Format_RGB888 |
|
343 |
SPANFUNC_POINTER_DESTSTORE(qrgb444), // Format_RGB444 |
|
344 |
SPANFUNC_POINTER_DESTSTORE(qargb4444) // Format_ARGB4444_Premultiplied |
|
345 |
}; |
|
346 |
||
347 |
/* |
|
348 |
Source fetches |
|
349 |
||
350 |
This is a bit more complicated, as we need several fetch routines for every surface type |
|
351 |
||
352 |
We need 5 fetch methods per surface type: |
|
353 |
untransformed |
|
354 |
transformed (tiled and not tiled) |
|
355 |
transformed bilinear (tiled and not tiled) |
|
356 |
||
357 |
We don't need bounds checks for untransformed, but we need them for the other ones. |
|
358 |
||
359 |
The generic implementation does pixel by pixel fetches |
|
360 |
*/ |
|
361 |
||
362 |
template <QImage::Format format> |
|
363 |
Q_STATIC_TEMPLATE_FUNCTION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, const QVector<QRgb> *rgb); |
|
364 |
||
365 |
template<> |
|
366 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
367 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_Mono>(const uchar *scanLine, |
|
368 |
int x, const QVector<QRgb> *rgb) |
|
369 |
{ |
|
370 |
bool pixel = scanLine[x>>3] & (0x80 >> (x & 7)); |
|
371 |
if (rgb) return PREMUL(rgb->at(pixel ? 1 : 0)); |
|
372 |
return pixel ? 0xff000000 : 0xffffffff; |
|
373 |
} |
|
374 |
||
375 |
template<> |
|
376 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
377 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_MonoLSB>(const uchar *scanLine, |
|
378 |
int x, const QVector<QRgb> *rgb) |
|
379 |
{ |
|
380 |
bool pixel = scanLine[x>>3] & (0x1 << (x & 7)); |
|
381 |
if (rgb) return PREMUL(rgb->at(pixel ? 1 : 0)); |
|
382 |
return pixel ? 0xff000000 : 0xffffffff; |
|
383 |
} |
|
384 |
||
385 |
template<> |
|
386 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
387 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_Indexed8>(const uchar *scanLine, |
|
388 |
int x, const QVector<QRgb> *rgb) |
|
389 |
{ |
|
390 |
return PREMUL(rgb->at(scanLine[x])); |
|
391 |
} |
|
392 |
||
393 |
template<> |
|
394 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
395 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB32>(const uchar *scanLine, |
|
396 |
int x, const QVector<QRgb> *) |
|
397 |
{ |
|
398 |
return PREMUL(((const uint *)scanLine)[x]); |
|
399 |
} |
|
400 |
||
401 |
template<> |
|
402 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
403 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB32_Premultiplied>(const uchar *scanLine, |
|
404 |
int x, const QVector<QRgb> *) |
|
405 |
{ |
|
406 |
return ((const uint *)scanLine)[x]; |
|
407 |
} |
|
408 |
||
409 |
template<> |
|
410 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
411 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB16>(const uchar *scanLine, |
|
412 |
int x, const QVector<QRgb> *) |
|
413 |
{ |
|
414 |
return qConvertRgb16To32(((const ushort *)scanLine)[x]); |
|
415 |
} |
|
416 |
||
417 |
template<> |
|
418 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
419 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB8565_Premultiplied>(const uchar *scanLine, |
|
420 |
int x, |
|
421 |
const QVector<QRgb> *) |
|
422 |
{ |
|
423 |
const qargb8565 color = reinterpret_cast<const qargb8565*>(scanLine)[x]; |
|
424 |
return qt_colorConvert<quint32, qargb8565>(color, 0); |
|
425 |
} |
|
426 |
||
427 |
template<> |
|
428 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
429 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB666>(const uchar *scanLine, |
|
430 |
int x, |
|
431 |
const QVector<QRgb> *) |
|
432 |
{ |
|
433 |
const qrgb666 color = reinterpret_cast<const qrgb666*>(scanLine)[x]; |
|
434 |
return qt_colorConvert<quint32, qrgb666>(color, 0); |
|
435 |
} |
|
436 |
||
437 |
template<> |
|
438 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
439 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB6666_Premultiplied>(const uchar *scanLine, |
|
440 |
int x, |
|
441 |
const QVector<QRgb> *) |
|
442 |
{ |
|
443 |
const qargb6666 color = reinterpret_cast<const qargb6666*>(scanLine)[x]; |
|
444 |
return qt_colorConvert<quint32, qargb6666>(color, 0); |
|
445 |
} |
|
446 |
||
447 |
template<> |
|
448 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
449 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB555>(const uchar *scanLine, |
|
450 |
int x, |
|
451 |
const QVector<QRgb> *) |
|
452 |
{ |
|
453 |
const qrgb555 color = reinterpret_cast<const qrgb555*>(scanLine)[x]; |
|
454 |
return qt_colorConvert<quint32, qrgb555>(color, 0); |
|
455 |
} |
|
456 |
||
457 |
template<> |
|
458 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
459 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB8555_Premultiplied>(const uchar *scanLine, |
|
460 |
int x, |
|
461 |
const QVector<QRgb> *) |
|
462 |
{ |
|
463 |
const qargb8555 color = reinterpret_cast<const qargb8555*>(scanLine)[x]; |
|
464 |
return qt_colorConvert<quint32, qargb8555>(color, 0); |
|
465 |
} |
|
466 |
||
467 |
template<> |
|
468 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
469 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB888>(const uchar *scanLine, |
|
470 |
int x, |
|
471 |
const QVector<QRgb> *) |
|
472 |
{ |
|
473 |
const qrgb888 color = reinterpret_cast<const qrgb888*>(scanLine)[x]; |
|
474 |
return qt_colorConvert<quint32, qrgb888>(color, 0); |
|
475 |
} |
|
476 |
||
477 |
template<> |
|
478 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
479 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_RGB444>(const uchar *scanLine, |
|
480 |
int x, |
|
481 |
const QVector<QRgb> *) |
|
482 |
{ |
|
483 |
const qrgb444 color = reinterpret_cast<const qrgb444*>(scanLine)[x]; |
|
484 |
return qt_colorConvert<quint32, qrgb444>(color, 0); |
|
485 |
} |
|
486 |
||
487 |
template<> |
|
488 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
489 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_ARGB4444_Premultiplied>(const uchar *scanLine, |
|
490 |
int x, |
|
491 |
const QVector<QRgb> *) |
|
492 |
{ |
|
493 |
const qargb4444 color = reinterpret_cast<const qargb4444*>(scanLine)[x]; |
|
494 |
return qt_colorConvert<quint32, qargb4444>(color, 0); |
|
495 |
} |
|
496 |
||
497 |
template<> |
|
498 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
499 |
uint QT_FASTCALL qt_fetchPixel<QImage::Format_Invalid>(const uchar *, |
|
500 |
int , |
|
501 |
const QVector<QRgb> *) |
|
502 |
{ |
|
503 |
return 0; |
|
504 |
} |
|
505 |
||
506 |
typedef uint (QT_FASTCALL *FetchPixelProc)(const uchar *scanLine, int x, const QVector<QRgb> *); |
|
507 |
||
508 |
#define SPANFUNC_POINTER_FETCHPIXEL(Arg) qt_fetchPixel<QImage::Arg> |
|
509 |
||
510 |
||
511 |
static const FetchPixelProc fetchPixelProc[QImage::NImageFormats] = |
|
512 |
{ |
|
513 |
0, |
|
514 |
SPANFUNC_POINTER_FETCHPIXEL(Format_Mono), |
|
515 |
SPANFUNC_POINTER_FETCHPIXEL(Format_MonoLSB), |
|
516 |
SPANFUNC_POINTER_FETCHPIXEL(Format_Indexed8), |
|
517 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB32_Premultiplied), |
|
518 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB32), |
|
519 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB32_Premultiplied), |
|
520 |
SPANFUNC_POINTER_FETCHPIXEL(Format_RGB16), |
|
521 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB8565_Premultiplied), |
|
522 |
SPANFUNC_POINTER_FETCHPIXEL(Format_RGB666), |
|
523 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB6666_Premultiplied), |
|
524 |
SPANFUNC_POINTER_FETCHPIXEL(Format_RGB555), |
|
525 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB8555_Premultiplied), |
|
526 |
SPANFUNC_POINTER_FETCHPIXEL(Format_RGB888), |
|
527 |
SPANFUNC_POINTER_FETCHPIXEL(Format_RGB444), |
|
528 |
SPANFUNC_POINTER_FETCHPIXEL(Format_ARGB4444_Premultiplied) |
|
529 |
}; |
|
530 |
||
531 |
enum TextureBlendType { |
|
532 |
BlendUntransformed, |
|
533 |
BlendTiled, |
|
534 |
BlendTransformed, |
|
535 |
BlendTransformedTiled, |
|
536 |
BlendTransformedBilinear, |
|
537 |
BlendTransformedBilinearTiled, |
|
538 |
NBlendTypes |
|
539 |
}; |
|
540 |
||
541 |
template <QImage::Format format> |
|
542 |
Q_STATIC_TEMPLATE_FUNCTION const uint * QT_FASTCALL qt_fetchUntransformed(uint *buffer, const Operator *, const QSpanData *data, |
|
543 |
int y, int x, int length) |
|
544 |
{ |
|
545 |
const uchar *scanLine = data->texture.scanLine(y); |
|
546 |
for (int i = 0; i < length; ++i) |
|
547 |
buffer[i] = qt_fetchPixel<format>(scanLine, x + i, data->texture.colorTable); |
|
548 |
return buffer; |
|
549 |
} |
|
550 |
||
551 |
template <> |
|
552 |
Q_STATIC_TEMPLATE_SPECIALIZATION const uint * QT_FASTCALL |
|
553 |
qt_fetchUntransformed<QImage::Format_ARGB32_Premultiplied>(uint *, const Operator *, |
|
554 |
const QSpanData *data, |
|
555 |
int y, int x, int) |
|
556 |
{ |
|
557 |
const uchar *scanLine = data->texture.scanLine(y); |
|
558 |
return ((const uint *)scanLine) + x; |
|
559 |
} |
|
560 |
||
561 |
template<TextureBlendType blendType> /* either BlendTransformed or BlendTransformedTiled */ |
|
562 |
Q_STATIC_TEMPLATE_FUNCTION |
|
563 |
const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data, |
|
564 |
int y, int x, int length) |
|
565 |
{ |
|
566 |
FetchPixelProc fetch = fetchPixelProc[data->texture.format]; |
|
567 |
||
568 |
int image_width = data->texture.width; |
|
569 |
int image_height = data->texture.height; |
|
570 |
||
571 |
const qreal cx = x + 0.5; |
|
572 |
const qreal cy = y + 0.5; |
|
573 |
||
574 |
const uint *end = buffer + length; |
|
575 |
uint *b = buffer; |
|
576 |
if (data->fast_matrix) { |
|
577 |
// The increment pr x in the scanline |
|
578 |
int fdx = (int)(data->m11 * fixed_scale); |
|
579 |
int fdy = (int)(data->m12 * fixed_scale); |
|
580 |
||
581 |
int fx = int((data->m21 * cy |
|
582 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
583 |
int fy = int((data->m22 * cy |
|
584 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
585 |
||
586 |
while (b < end) { |
|
587 |
int px = fx >> 16; |
|
588 |
int py = fy >> 16; |
|
589 |
||
590 |
if (blendType == BlendTransformedTiled) { |
|
591 |
px %= image_width; |
|
592 |
py %= image_height; |
|
593 |
if (px < 0) px += image_width; |
|
594 |
if (py < 0) py += image_height; |
|
595 |
||
596 |
const uchar *scanLine = data->texture.scanLine(py); |
|
597 |
*b = fetch(scanLine, px, data->texture.colorTable); |
|
598 |
} else { |
|
599 |
if ((px < 0) || (px >= image_width) |
|
600 |
|| (py < 0) || (py >= image_height)) { |
|
601 |
*b = uint(0); |
|
602 |
} else { |
|
603 |
const uchar *scanLine = data->texture.scanLine(py); |
|
604 |
*b = fetch(scanLine, px, data->texture.colorTable); |
|
605 |
} |
|
606 |
} |
|
607 |
fx += fdx; |
|
608 |
fy += fdy; |
|
609 |
++b; |
|
610 |
} |
|
611 |
} else { |
|
612 |
const qreal fdx = data->m11; |
|
613 |
const qreal fdy = data->m12; |
|
614 |
const qreal fdw = data->m13; |
|
615 |
||
616 |
qreal fx = data->m21 * cy + data->m11 * cx + data->dx; |
|
617 |
qreal fy = data->m22 * cy + data->m12 * cx + data->dy; |
|
618 |
qreal fw = data->m23 * cy + data->m13 * cx + data->m33; |
|
619 |
||
620 |
while (b < end) { |
|
621 |
const qreal iw = fw == 0 ? 1 : 1 / fw; |
|
622 |
const qreal tx = fx * iw; |
|
623 |
const qreal ty = fy * iw; |
|
624 |
int px = int(tx) - (tx < 0); |
|
625 |
int py = int(ty) - (ty < 0); |
|
626 |
||
627 |
if (blendType == BlendTransformedTiled) { |
|
628 |
px %= image_width; |
|
629 |
py %= image_height; |
|
630 |
if (px < 0) px += image_width; |
|
631 |
if (py < 0) py += image_height; |
|
632 |
||
633 |
const uchar *scanLine = data->texture.scanLine(py); |
|
634 |
*b = fetch(scanLine, px, data->texture.colorTable); |
|
635 |
} else { |
|
636 |
if ((px < 0) || (px >= image_width) |
|
637 |
|| (py < 0) || (py >= image_height)) { |
|
638 |
*b = uint(0); |
|
639 |
} else { |
|
640 |
const uchar *scanLine = data->texture.scanLine(py); |
|
641 |
*b = fetch(scanLine, px, data->texture.colorTable); |
|
642 |
} |
|
643 |
} |
|
644 |
fx += fdx; |
|
645 |
fy += fdy; |
|
646 |
fw += fdw; |
|
647 |
//force increment to avoid /0 |
|
648 |
if (!fw) { |
|
649 |
fw += fdw; |
|
650 |
} |
|
651 |
++b; |
|
652 |
} |
|
653 |
} |
|
654 |
||
655 |
return buffer; |
|
656 |
} |
|
657 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
658 |
/** \internal |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
659 |
interpolate 4 argb pixels with the distx and disty factor. |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
660 |
distx and disty bust be between 0 and 16 |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
661 |
*/ |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
662 |
static inline uint interpolate_4_pixels_16(uint tl, uint tr, uint bl, uint br, int distx, int disty, int idistx, int idisty) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
663 |
{ |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
664 |
uint tlrb = ((tl & 0x00ff00ff) * idistx * idisty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
665 |
uint tlag = (((tl & 0xff00ff00) >> 8) * idistx * idisty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
666 |
uint trrb = ((tr & 0x00ff00ff) * distx * idisty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
667 |
uint trag = (((tr & 0xff00ff00) >> 8) * distx * idisty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
668 |
uint blrb = ((bl & 0x00ff00ff) * idistx * disty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
669 |
uint blag = (((bl & 0xff00ff00) >> 8) * idistx * disty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
670 |
uint brrb = ((br & 0x00ff00ff) * distx * disty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
671 |
uint brag = (((br & 0xff00ff00) >> 8) * distx * disty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
672 |
return (((tlrb + trrb + blrb + brrb) >> 8) & 0x00ff00ff) | ((tlag + trag + blag + brag) & 0xff00ff00); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
673 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
674 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
675 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
676 |
template<TextureBlendType blendType> |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
677 |
Q_STATIC_TEMPLATE_FUNCTION inline void fetchTransformedBilinear_pixelBounds(int max, int l1, int l2, int &v1, int &v2) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
678 |
{ |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
679 |
if (blendType == BlendTransformedBilinearTiled) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
680 |
v1 %= max; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
681 |
if (v1 < 0) v1 += max; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
682 |
v2 = v1 + 1; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
683 |
v2 %= max; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
684 |
} else { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
685 |
if (v1 < l1) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
686 |
v2 = v1 = l1; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
687 |
} else if (v1 >= l2) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
688 |
v2 = v1 = l2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
689 |
} else { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
690 |
v2 = v1 + 1; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
691 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
692 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
693 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
694 |
Q_ASSERT(v1 >= 0 && v1 < max); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
695 |
Q_ASSERT(v2 >= 0 && v2 < max); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
696 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
697 |
|
0 | 698 |
template<TextureBlendType blendType, QImage::Format format> /* blendType = BlendTransformedBilinear or BlendTransformedBilinearTiled */ |
699 |
Q_STATIC_TEMPLATE_FUNCTION |
|
700 |
const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, const QSpanData *data, |
|
701 |
int y, int x, int length) |
|
702 |
{ |
|
703 |
#ifdef Q_CC_RVCT // needed to avoid compiler crash in RVCT 2.2 |
|
704 |
FetchPixelProc fetch; |
|
705 |
if (format != QImage::Format_Invalid) |
|
706 |
fetch = qt_fetchPixel<format>; |
|
707 |
else |
|
708 |
fetch = fetchPixelProc[data->texture.format]; |
|
709 |
#else |
|
710 |
FetchPixelProc fetch = (format != QImage::Format_Invalid) ? FetchPixelProc(qt_fetchPixel<format>) : fetchPixelProc[data->texture.format]; |
|
711 |
#endif |
|
712 |
||
713 |
int image_width = data->texture.width; |
|
714 |
int image_height = data->texture.height; |
|
715 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
716 |
int image_x1 = data->texture.x1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
717 |
int image_y1 = data->texture.y1; |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
718 |
int image_x2 = data->texture.x2 - 1; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
719 |
int image_y2 = data->texture.y2 - 1; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
720 |
|
0 | 721 |
const qreal cx = x + 0.5; |
722 |
const qreal cy = y + 0.5; |
|
723 |
||
724 |
const uint *end = buffer + length; |
|
725 |
uint *b = buffer; |
|
726 |
if (data->fast_matrix) { |
|
727 |
// The increment pr x in the scanline |
|
728 |
int fdx = (int)(data->m11 * fixed_scale); |
|
729 |
int fdy = (int)(data->m12 * fixed_scale); |
|
730 |
||
731 |
int fx = int((data->m21 * cy |
|
732 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
733 |
int fy = int((data->m22 * cy |
|
734 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
735 |
||
736 |
fx -= half_point; |
|
737 |
fy -= half_point; |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
738 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
739 |
if (fdy == 0) { //simple scale, no rotation |
0 | 740 |
int y1 = (fy >> 16); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
741 |
int y2; |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
742 |
fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
743 |
const uchar *s1 = data->texture.scanLine(y1); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
744 |
const uchar *s2 = data->texture.scanLine(y2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
745 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
746 |
if (fdx <= fixed_scale && fdx > 0) { // scale up on X |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
747 |
int disty = (fy & 0x0000ffff) >> 8; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
748 |
int idisty = 256 - disty; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
749 |
int x = fx >> 16; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
750 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
751 |
// The idea is first to do the interpolation between the row s1 and the row s2 |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
752 |
// into an intermediate buffer, then we interpolate between two pixel of this buffer. |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
753 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
754 |
// intermediate_buffer[0] is a buffer of red-blue component of the pixel, in the form 0x00RR00BB |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
755 |
// intermediate_buffer[1] is the alpha-green component of the pixel, in the form 0x00AA00GG |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
756 |
quint32 intermediate_buffer[2][buffer_size + 2]; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
757 |
// count is the size used in the intermediate_buffer. |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
758 |
int count = qCeil(length * data->m11) + 2; //+1 for the last pixel to interpolate with, and +1 for rounding errors. |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
759 |
Q_ASSERT(count <= buffer_size + 2); //length is supposed to be <= buffer_size and data->m11 < 1 in this case |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
760 |
int f = 0; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
761 |
int lim = count; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
762 |
if (blendType == BlendTransformedBilinearTiled) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
763 |
x %= image_width; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
764 |
if (x < 0) x += image_width; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
765 |
} else { |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
766 |
lim = qMin(count, image_x2-x+1); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
767 |
if (x < image_x1) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
768 |
Q_ASSERT(x <= image_x2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
769 |
uint t = fetch(s1, image_x1, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
770 |
uint b = fetch(s2, image_x1, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
771 |
quint32 rb = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
772 |
quint32 ag = ((((t>>8) & 0xff00ff) * idisty + ((b>>8) & 0xff00ff) * disty) >> 8) & 0xff00ff; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
773 |
do { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
774 |
intermediate_buffer[0][f] = rb; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
775 |
intermediate_buffer[1][f] = ag; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
776 |
f++; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
777 |
x++; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
778 |
} while (x < image_x1 && f < lim); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
779 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
780 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
781 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
782 |
#if defined(QT_ALWAYS_HAVE_SSE2) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
783 |
if (blendType != BlendTransformedBilinearTiled && |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
784 |
(format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32)) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
785 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
786 |
const __m128i disty_ = _mm_set1_epi16(disty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
787 |
const __m128i idisty_ = _mm_set1_epi16(idisty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
788 |
const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
789 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
790 |
lim -= 3; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
791 |
for (; f < lim; x += 4, f += 4) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
792 |
// Load 4 pixels from s1, and split the alpha-green and red-blue component |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
793 |
__m128i top = _mm_loadu_si128((__m128i*)((const uint *)(s1)+x)); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
794 |
__m128i topAG = _mm_srli_epi16(top, 8); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
795 |
__m128i topRB = _mm_and_si128(top, colorMask); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
796 |
// Multiplies each colour component by idisty |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
797 |
topAG = _mm_mullo_epi16 (topAG, idisty_); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
798 |
topRB = _mm_mullo_epi16 (topRB, idisty_); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
799 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
800 |
// Same for the s2 vector |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
801 |
__m128i bottom = _mm_loadu_si128((__m128i*)((const uint *)(s2)+x)); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
802 |
__m128i bottomAG = _mm_srli_epi16(bottom, 8); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
803 |
__m128i bottomRB = _mm_and_si128(bottom, colorMask); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
804 |
bottomAG = _mm_mullo_epi16 (bottomAG, disty_); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
805 |
bottomRB = _mm_mullo_epi16 (bottomRB, disty_); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
806 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
807 |
// Add the values, and shift to only keep 8 significant bits per colors |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
808 |
__m128i rAG =_mm_add_epi16(topAG, bottomAG); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
809 |
rAG = _mm_srli_epi16(rAG, 8); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
810 |
_mm_storeu_si128((__m128i*)(&intermediate_buffer[1][f]), rAG); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
811 |
__m128i rRB =_mm_add_epi16(topRB, bottomRB); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
812 |
rRB = _mm_srli_epi16(rRB, 8); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
813 |
_mm_storeu_si128((__m128i*)(&intermediate_buffer[0][f]), rRB); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
814 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
815 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
816 |
#endif |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
817 |
for (; f < count; f++) { // Same as above but without sse2 |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
818 |
if (blendType == BlendTransformedBilinearTiled) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
819 |
if (x >= image_width) x -= image_width; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
820 |
} else { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
821 |
x = qMin(x, image_x2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
822 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
823 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
824 |
uint t = fetch(s1, x, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
825 |
uint b = fetch(s2, x, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
826 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
827 |
intermediate_buffer[0][f] = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
828 |
intermediate_buffer[1][f] = ((((t>>8) & 0xff00ff) * idisty + ((b>>8) & 0xff00ff) * disty) >> 8) & 0xff00ff; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
829 |
x++; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
830 |
} |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
831 |
// Now interpolate the values from the intermediate_buffer to get the final result. |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
832 |
fx &= fixed_scale - 1; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
833 |
Q_ASSERT((fx >> 16) == 0); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
834 |
while (b < end) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
835 |
register int x1 = (fx >> 16); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
836 |
register int x2 = x1 + 1; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
837 |
Q_ASSERT(x1 >= 0); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
838 |
Q_ASSERT(x2 < count); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
839 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
840 |
register int distx = (fx & 0x0000ffff) >> 8; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
841 |
register int idistx = 256 - distx; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
842 |
int rb = ((intermediate_buffer[0][x1] * idistx + intermediate_buffer[0][x2] * distx) >> 8) & 0xff00ff; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
843 |
int ag = (intermediate_buffer[1][x1] * idistx + intermediate_buffer[1][x2] * distx) & 0xff00ff00; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
844 |
*b = rb | ag; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
845 |
b++; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
846 |
fx += fdx; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
847 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
848 |
} else if ((fdx < 0 && fdx > -(fixed_scale / 8)) || fabs(data->m22) < (1./8.)) { // scale up more than 8x |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
849 |
int y1 = (fy >> 16); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
850 |
int y2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
851 |
fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
852 |
const uchar *s1 = data->texture.scanLine(y1); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
853 |
const uchar *s2 = data->texture.scanLine(y2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
854 |
int disty = (fy & 0x0000ffff) >> 8; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
855 |
int idisty = 256 - disty; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
856 |
while (b < end) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
857 |
int x1 = (fx >> 16); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
858 |
int x2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
859 |
fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
860 |
uint tl = fetch(s1, x1, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
861 |
uint tr = fetch(s1, x2, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
862 |
uint bl = fetch(s2, x1, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
863 |
uint br = fetch(s2, x2, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
864 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
865 |
int distx = (fx & 0x0000ffff) >> 8; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
866 |
int idistx = 256 - distx; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
867 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
868 |
uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
869 |
uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
870 |
*b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
871 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
872 |
fx += fdx; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
873 |
++b; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
874 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
875 |
} else { //scale down |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
876 |
int y1 = (fy >> 16); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
877 |
int y2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
878 |
fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
879 |
const uchar *s1 = data->texture.scanLine(y1); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
880 |
const uchar *s2 = data->texture.scanLine(y2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
881 |
int disty = (fy & 0x0000ffff) >> 12; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
882 |
int idisty = 16 - disty; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
883 |
while (b < end) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
884 |
int x1 = (fx >> 16); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
885 |
int x2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
886 |
fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
887 |
uint tl = fetch(s1, x1, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
888 |
uint tr = fetch(s1, x2, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
889 |
uint bl = fetch(s2, x1, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
890 |
uint br = fetch(s2, x2, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
891 |
int distx = (fx & 0x0000ffff) >> 12; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
892 |
int idistx = 16 - distx; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
893 |
*b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty, idistx, idisty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
894 |
fx += fdx; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
895 |
++b; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
896 |
} |
0 | 897 |
} |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
898 |
} else { //rotation |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
899 |
if (fabs(data->m11) > 8 || fabs(data->m22) > 8) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
900 |
//if we are zooming more than 8 times, we use 8bit precision for the position. |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
901 |
while (b < end) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
902 |
int x1 = (fx >> 16); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
903 |
int x2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
904 |
int y1 = (fy >> 16); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
905 |
int y2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
906 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
907 |
fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
908 |
fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
909 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
910 |
const uchar *s1 = data->texture.scanLine(y1); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
911 |
const uchar *s2 = data->texture.scanLine(y2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
912 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
913 |
uint tl = fetch(s1, x1, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
914 |
uint tr = fetch(s1, x2, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
915 |
uint bl = fetch(s2, x1, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
916 |
uint br = fetch(s2, x2, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
917 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
918 |
int distx = (fx & 0x0000ffff) >> 8; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
919 |
int disty = (fy & 0x0000ffff) >> 8; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
920 |
int idistx = 256 - distx; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
921 |
int idisty = 256 - disty; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
922 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
923 |
uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
924 |
uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
925 |
*b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
926 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
927 |
fx += fdx; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
928 |
fy += fdy; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
929 |
++b; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
930 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
931 |
} else { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
932 |
//we are zooming less than 8x, use 4bit precision |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
933 |
while (b < end) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
934 |
int x1 = (fx >> 16); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
935 |
int x2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
936 |
int y1 = (fy >> 16); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
937 |
int y2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
938 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
939 |
fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
940 |
fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
941 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
942 |
const uchar *s1 = data->texture.scanLine(y1); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
943 |
const uchar *s2 = data->texture.scanLine(y2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
944 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
945 |
uint tl = fetch(s1, x1, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
946 |
uint tr = fetch(s1, x2, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
947 |
uint bl = fetch(s2, x1, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
948 |
uint br = fetch(s2, x2, data->texture.colorTable); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
949 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
950 |
int distx = (fx & 0x0000ffff) >> 12; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
951 |
int disty = (fy & 0x0000ffff) >> 12; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
952 |
int idistx = 16 - distx; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
953 |
int idisty = 16 - disty; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
954 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
955 |
*b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty, idistx, idisty); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
956 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
957 |
fx += fdx; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
958 |
fy += fdy; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
959 |
++b; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
960 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
961 |
} |
0 | 962 |
} |
963 |
} else { |
|
964 |
const qreal fdx = data->m11; |
|
965 |
const qreal fdy = data->m12; |
|
966 |
const qreal fdw = data->m13; |
|
967 |
||
968 |
qreal fx = data->m21 * cy + data->m11 * cx + data->dx; |
|
969 |
qreal fy = data->m22 * cy + data->m12 * cx + data->dy; |
|
970 |
qreal fw = data->m23 * cy + data->m13 * cx + data->m33; |
|
971 |
||
972 |
while (b < end) { |
|
973 |
const qreal iw = fw == 0 ? 1 : 1 / fw; |
|
974 |
const qreal px = fx * iw - 0.5; |
|
975 |
const qreal py = fy * iw - 0.5; |
|
976 |
||
977 |
int x1 = int(px) - (px < 0); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
978 |
int x2; |
0 | 979 |
int y1 = int(py) - (py < 0); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
980 |
int y2; |
0 | 981 |
|
982 |
int distx = int((px - x1) * 256); |
|
983 |
int disty = int((py - y1) * 256); |
|
984 |
int idistx = 256 - distx; |
|
985 |
int idisty = 256 - disty; |
|
986 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
987 |
fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
988 |
fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
989 |
|
0 | 990 |
const uchar *s1 = data->texture.scanLine(y1); |
991 |
const uchar *s2 = data->texture.scanLine(y2); |
|
992 |
||
993 |
uint tl = fetch(s1, x1, data->texture.colorTable); |
|
994 |
uint tr = fetch(s1, x2, data->texture.colorTable); |
|
995 |
uint bl = fetch(s2, x1, data->texture.colorTable); |
|
996 |
uint br = fetch(s2, x2, data->texture.colorTable); |
|
997 |
||
998 |
uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); |
|
999 |
uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); |
|
1000 |
*b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); |
|
1001 |
||
1002 |
fx += fdx; |
|
1003 |
fy += fdy; |
|
1004 |
fw += fdw; |
|
1005 |
//force increment to avoid /0 |
|
1006 |
if (!fw) { |
|
1007 |
fw += fdw; |
|
1008 |
} |
|
1009 |
++b; |
|
1010 |
} |
|
1011 |
} |
|
1012 |
||
1013 |
return buffer; |
|
1014 |
} |
|
1015 |
||
1016 |
#define SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Arg) qt_fetchUntransformed<QImage::Arg> |
|
1017 |
||
1018 |
static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { |
|
1019 |
// Untransformed |
|
1020 |
{ |
|
1021 |
0, // Invalid |
|
1022 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_Mono), // Mono |
|
1023 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_MonoLSB), // MonoLsb |
|
1024 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_Indexed8), // Indexed8 |
|
1025 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32_Premultiplied), // RGB32 |
|
1026 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32), // ARGB32 |
|
1027 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32_Premultiplied), // ARGB32_Premultiplied |
|
1028 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB16), // RGB16 |
|
1029 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB8565_Premultiplied),// ARGB8565_Premultiplied |
|
1030 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB666), // RGB666 |
|
1031 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB6666_Premultiplied),// ARGB6666_Premultiplied |
|
1032 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB555), // RGB555 |
|
1033 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB8555_Premultiplied),// ARGB8555_Premultiplied |
|
1034 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB888), // RGB888 |
|
1035 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB444), // RGB444 |
|
1036 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB4444_Premultiplied) // ARGB4444_Premultiplied |
|
1037 |
}, |
|
1038 |
// Tiled |
|
1039 |
{ |
|
1040 |
0, // Invalid |
|
1041 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_Mono), // Mono |
|
1042 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_MonoLSB), // MonoLsb |
|
1043 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_Indexed8), // Indexed8 |
|
1044 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32_Premultiplied), // RGB32 |
|
1045 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32), // ARGB32 |
|
1046 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB32_Premultiplied), // ARGB32_Premultiplied |
|
1047 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB16), // RGB16 |
|
1048 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB8565_Premultiplied),// ARGB8565_Premultiplied |
|
1049 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB666), // RGB666 |
|
1050 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB6666_Premultiplied),// ARGB6666_Premultiplied |
|
1051 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB555), // RGB555 |
|
1052 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB8555_Premultiplied),// ARGB8555_Premultiplied |
|
1053 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB888), // RGB888 |
|
1054 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_RGB444), // RGB444 |
|
1055 |
SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Format_ARGB4444_Premultiplied) // ARGB4444_Premultiplied |
|
1056 |
}, |
|
1057 |
// Transformed |
|
1058 |
{ |
|
1059 |
0, // Invalid |
|
1060 |
fetchTransformed<BlendTransformed>, // Mono |
|
1061 |
fetchTransformed<BlendTransformed>, // MonoLsb |
|
1062 |
fetchTransformed<BlendTransformed>, // Indexed8 |
|
1063 |
fetchTransformed<BlendTransformed>, // RGB32 |
|
1064 |
fetchTransformed<BlendTransformed>, // ARGB32 |
|
1065 |
fetchTransformed<BlendTransformed>, // ARGB32_Premultiplied |
|
1066 |
fetchTransformed<BlendTransformed>, // RGB16 |
|
1067 |
fetchTransformed<BlendTransformed>, // ARGB8565_Premultiplied |
|
1068 |
fetchTransformed<BlendTransformed>, // RGB666 |
|
1069 |
fetchTransformed<BlendTransformed>, // ARGB6666_Premultiplied |
|
1070 |
fetchTransformed<BlendTransformed>, // RGB555 |
|
1071 |
fetchTransformed<BlendTransformed>, // ARGB8555_Premultiplied |
|
1072 |
fetchTransformed<BlendTransformed>, // RGB888 |
|
1073 |
fetchTransformed<BlendTransformed>, // RGB444 |
|
1074 |
fetchTransformed<BlendTransformed>, // ARGB4444_Premultiplied |
|
1075 |
}, |
|
1076 |
{ |
|
1077 |
0, // TransformedTiled |
|
1078 |
fetchTransformed<BlendTransformedTiled>, // Mono |
|
1079 |
fetchTransformed<BlendTransformedTiled>, // MonoLsb |
|
1080 |
fetchTransformed<BlendTransformedTiled>, // Indexed8 |
|
1081 |
fetchTransformed<BlendTransformedTiled>, // RGB32 |
|
1082 |
fetchTransformed<BlendTransformedTiled>, // ARGB32 |
|
1083 |
fetchTransformed<BlendTransformedTiled>, // ARGB32_Premultiplied |
|
1084 |
fetchTransformed<BlendTransformedTiled>, // RGB16 |
|
1085 |
fetchTransformed<BlendTransformedTiled>, // ARGB8565_Premultiplied |
|
1086 |
fetchTransformed<BlendTransformedTiled>, // RGB666 |
|
1087 |
fetchTransformed<BlendTransformedTiled>, // ARGB6666_Premultiplied |
|
1088 |
fetchTransformed<BlendTransformedTiled>, // RGB555 |
|
1089 |
fetchTransformed<BlendTransformedTiled>, // ARGB8555_Premultiplied |
|
1090 |
fetchTransformed<BlendTransformedTiled>, // RGB888 |
|
1091 |
fetchTransformed<BlendTransformedTiled>, // RGB444 |
|
1092 |
fetchTransformed<BlendTransformedTiled>, // ARGB4444_Premultiplied |
|
1093 |
}, |
|
1094 |
{ |
|
1095 |
0, // Bilinear |
|
1096 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // Mono |
|
1097 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // MonoLsb |
|
1098 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // Indexed8 |
|
1099 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_ARGB32_Premultiplied>, // RGB32 |
|
1100 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_ARGB32>, // ARGB32 |
|
1101 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_ARGB32_Premultiplied>, // ARGB32_Premultiplied |
|
1102 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB16 |
|
1103 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // ARGB8565_Premultiplied |
|
1104 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB666 |
|
1105 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // ARGB6666_Premultiplied |
|
1106 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB555 |
|
1107 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // ARGB8555_Premultiplied |
|
1108 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB888 |
|
1109 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid>, // RGB444 |
|
1110 |
fetchTransformedBilinear<BlendTransformedBilinear, QImage::Format_Invalid> // ARGB4444_Premultiplied |
|
1111 |
}, |
|
1112 |
{ |
|
1113 |
0, // BilinearTiled |
|
1114 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // Mono |
|
1115 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // MonoLsb |
|
1116 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // Indexed8 |
|
1117 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_ARGB32_Premultiplied>, // RGB32 |
|
1118 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_ARGB32>, // ARGB32 |
|
1119 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_ARGB32_Premultiplied>, // ARGB32_Premultiplied |
|
1120 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB16 |
|
1121 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // ARGB8565_Premultiplied |
|
1122 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB666 |
|
1123 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // ARGB6666_Premultiplied |
|
1124 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB555 |
|
1125 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // ARGB8555_Premultiplied |
|
1126 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB888 |
|
1127 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid>, // RGB444 |
|
1128 |
fetchTransformedBilinear<BlendTransformedBilinearTiled, QImage::Format_Invalid> // ARGB4444_Premultiplied |
|
1129 |
}, |
|
1130 |
}; |
|
1131 |
||
1132 |
||
1133 |
static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos) |
|
1134 |
{ |
|
1135 |
int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + 0.5); |
|
1136 |
||
1137 |
// calculate the actual offset. |
|
1138 |
if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) { |
|
1139 |
if (data->spread == QGradient::RepeatSpread) { |
|
1140 |
ipos = ipos % GRADIENT_STOPTABLE_SIZE; |
|
1141 |
ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos; |
|
1142 |
||
1143 |
} else if (data->spread == QGradient::ReflectSpread) { |
|
1144 |
const int limit = GRADIENT_STOPTABLE_SIZE * 2 - 1; |
|
1145 |
ipos = ipos % limit; |
|
1146 |
ipos = ipos < 0 ? limit + ipos : ipos; |
|
1147 |
ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos; |
|
1148 |
||
1149 |
} else { |
|
1150 |
if (ipos < 0) ipos = 0; |
|
1151 |
else if (ipos >= GRADIENT_STOPTABLE_SIZE) ipos = GRADIENT_STOPTABLE_SIZE-1; |
|
1152 |
} |
|
1153 |
} |
|
1154 |
||
1155 |
Q_ASSERT(ipos >= 0); |
|
1156 |
Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE); |
|
1157 |
||
1158 |
return data->colorTable[ipos]; |
|
1159 |
} |
|
1160 |
||
1161 |
#define FIXPT_BITS 8 |
|
1162 |
#define FIXPT_SIZE (1<<FIXPT_BITS) |
|
1163 |
||
1164 |
static uint qt_gradient_pixel_fixed(const QGradientData *data, int fixed_pos) |
|
1165 |
{ |
|
1166 |
int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS; |
|
1167 |
||
1168 |
// calculate the actual offset. |
|
1169 |
if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) { |
|
1170 |
if (data->spread == QGradient::RepeatSpread) { |
|
1171 |
ipos = ipos % GRADIENT_STOPTABLE_SIZE; |
|
1172 |
ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos; |
|
1173 |
||
1174 |
} else if (data->spread == QGradient::ReflectSpread) { |
|
1175 |
const int limit = GRADIENT_STOPTABLE_SIZE * 2 - 1; |
|
1176 |
ipos = ipos % limit; |
|
1177 |
ipos = ipos < 0 ? limit + ipos : ipos; |
|
1178 |
ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos; |
|
1179 |
||
1180 |
} else { |
|
1181 |
if (ipos < 0) ipos = 0; |
|
1182 |
else if (ipos >= GRADIENT_STOPTABLE_SIZE) ipos = GRADIENT_STOPTABLE_SIZE-1; |
|
1183 |
} |
|
1184 |
} |
|
1185 |
||
1186 |
Q_ASSERT(ipos >= 0); |
|
1187 |
Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE); |
|
1188 |
||
1189 |
return data->colorTable[ipos]; |
|
1190 |
} |
|
1191 |
||
1192 |
static void QT_FASTCALL getLinearGradientValues(LinearGradientValues *v, const QSpanData *data) |
|
1193 |
{ |
|
1194 |
v->dx = data->gradient.linear.end.x - data->gradient.linear.origin.x; |
|
1195 |
v->dy = data->gradient.linear.end.y - data->gradient.linear.origin.y; |
|
1196 |
v->l = v->dx * v->dx + v->dy * v->dy; |
|
1197 |
v->off = 0; |
|
1198 |
if (v->l != 0) { |
|
1199 |
v->dx /= v->l; |
|
1200 |
v->dy /= v->l; |
|
1201 |
v->off = -v->dx * data->gradient.linear.origin.x - v->dy * data->gradient.linear.origin.y; |
|
1202 |
} |
|
1203 |
} |
|
1204 |
||
1205 |
static const uint * QT_FASTCALL fetchLinearGradient(uint *buffer, const Operator *op, const QSpanData *data, |
|
1206 |
int y, int x, int length) |
|
1207 |
{ |
|
1208 |
const uint *b = buffer; |
|
1209 |
qreal t, inc; |
|
1210 |
||
1211 |
bool affine = true; |
|
1212 |
qreal rx=0, ry=0; |
|
1213 |
if (op->linear.l == 0) { |
|
1214 |
t = inc = 0; |
|
1215 |
} else { |
|
1216 |
rx = data->m21 * (y + 0.5) + data->m11 * (x + 0.5) + data->dx; |
|
1217 |
ry = data->m22 * (y + 0.5) + data->m12 * (x + 0.5) + data->dy; |
|
1218 |
t = op->linear.dx*rx + op->linear.dy*ry + op->linear.off; |
|
1219 |
inc = op->linear.dx * data->m11 + op->linear.dy * data->m12; |
|
1220 |
affine = !data->m13 && !data->m23; |
|
1221 |
||
1222 |
if (affine) { |
|
1223 |
t *= (GRADIENT_STOPTABLE_SIZE - 1); |
|
1224 |
inc *= (GRADIENT_STOPTABLE_SIZE - 1); |
|
1225 |
} |
|
1226 |
} |
|
1227 |
||
1228 |
const uint *end = buffer + length; |
|
1229 |
if (affine) { |
|
1230 |
if (inc > -1e-5 && inc < 1e-5) { |
|
1231 |
QT_MEMFILL_UINT(buffer, length, qt_gradient_pixel_fixed(&data->gradient, int(t * FIXPT_SIZE))); |
|
1232 |
} else { |
|
1233 |
if (t+inc*length < qreal(INT_MAX >> (FIXPT_BITS + 1)) && |
|
1234 |
t+inc*length > qreal(INT_MIN >> (FIXPT_BITS + 1))) { |
|
1235 |
// we can use fixed point math |
|
1236 |
int t_fixed = int(t * FIXPT_SIZE); |
|
1237 |
int inc_fixed = int(inc * FIXPT_SIZE); |
|
1238 |
while (buffer < end) { |
|
1239 |
*buffer = qt_gradient_pixel_fixed(&data->gradient, t_fixed); |
|
1240 |
t_fixed += inc_fixed; |
|
1241 |
++buffer; |
|
1242 |
} |
|
1243 |
} else { |
|
1244 |
// we have to fall back to float math |
|
1245 |
while (buffer < end) { |
|
1246 |
*buffer = qt_gradient_pixel(&data->gradient, t/GRADIENT_STOPTABLE_SIZE); |
|
1247 |
t += inc; |
|
1248 |
++buffer; |
|
1249 |
} |
|
1250 |
} |
|
1251 |
} |
|
1252 |
} else { // fall back to float math here as well |
|
1253 |
qreal rw = data->m23 * (y + 0.5) + data->m13 * (x + 0.5) + data->m33; |
|
1254 |
while (buffer < end) { |
|
1255 |
qreal x = rx/rw; |
|
1256 |
qreal y = ry/rw; |
|
1257 |
t = (op->linear.dx*x + op->linear.dy *y) + op->linear.off; |
|
1258 |
||
1259 |
*buffer = qt_gradient_pixel(&data->gradient, t); |
|
1260 |
rx += data->m11; |
|
1261 |
ry += data->m12; |
|
1262 |
rw += data->m13; |
|
1263 |
if (!rw) { |
|
1264 |
rw += data->m13; |
|
1265 |
} |
|
1266 |
++buffer; |
|
1267 |
} |
|
1268 |
} |
|
1269 |
||
1270 |
return b; |
|
1271 |
} |
|
1272 |
||
1273 |
static inline qreal determinant(qreal a, qreal b, qreal c) |
|
1274 |
{ |
|
1275 |
return (b * b) - (4 * a * c); |
|
1276 |
} |
|
1277 |
||
1278 |
// function to evaluate real roots |
|
1279 |
static inline qreal realRoots(qreal a, qreal b, qreal detSqrt) |
|
1280 |
{ |
|
1281 |
return (-b + detSqrt)/(2 * a); |
|
1282 |
} |
|
1283 |
||
1284 |
static inline qreal qSafeSqrt(qreal x) |
|
1285 |
{ |
|
1286 |
return x > 0 ? qSqrt(x) : 0; |
|
1287 |
} |
|
1288 |
||
1289 |
static void QT_FASTCALL getRadialGradientValues(RadialGradientValues *v, const QSpanData *data) |
|
1290 |
{ |
|
1291 |
v->dx = data->gradient.radial.center.x - data->gradient.radial.focal.x; |
|
1292 |
v->dy = data->gradient.radial.center.y - data->gradient.radial.focal.y; |
|
1293 |
v->a = data->gradient.radial.radius*data->gradient.radial.radius - v->dx*v->dx - v->dy*v->dy; |
|
1294 |
} |
|
1295 |
||
1296 |
static const uint * QT_FASTCALL fetchRadialGradient(uint *buffer, const Operator *op, const QSpanData *data, |
|
1297 |
int y, int x, int length) |
|
1298 |
{ |
|
1299 |
const uint *b = buffer; |
|
1300 |
qreal rx = data->m21 * (y + 0.5) |
|
1301 |
+ data->dx + data->m11 * (x + 0.5); |
|
1302 |
qreal ry = data->m22 * (y + 0.5) |
|
1303 |
+ data->dy + data->m12 * (x + 0.5); |
|
1304 |
bool affine = !data->m13 && !data->m23; |
|
1305 |
//qreal r = data->gradient.radial.radius; |
|
1306 |
||
1307 |
const uint *end = buffer + length; |
|
1308 |
if (affine) { |
|
1309 |
rx -= data->gradient.radial.focal.x; |
|
1310 |
ry -= data->gradient.radial.focal.y; |
|
1311 |
||
1312 |
qreal inv_a = 1 / qreal(2 * op->radial.a); |
|
1313 |
||
1314 |
const qreal delta_rx = data->m11; |
|
1315 |
const qreal delta_ry = data->m12; |
|
1316 |
||
1317 |
qreal b = 2*(rx * op->radial.dx + ry * op->radial.dy); |
|
1318 |
qreal delta_b = 2*(delta_rx * op->radial.dx + delta_ry * op->radial.dy); |
|
1319 |
const qreal b_delta_b = 2 * b * delta_b; |
|
1320 |
const qreal delta_b_delta_b = 2 * delta_b * delta_b; |
|
1321 |
||
1322 |
const qreal bb = b * b; |
|
1323 |
const qreal delta_bb = delta_b * delta_b; |
|
1324 |
||
1325 |
b *= inv_a; |
|
1326 |
delta_b *= inv_a; |
|
1327 |
||
1328 |
const qreal rxrxryry = rx * rx + ry * ry; |
|
1329 |
const qreal delta_rxrxryry = delta_rx * delta_rx + delta_ry * delta_ry; |
|
1330 |
const qreal rx_plus_ry = 2*(rx * delta_rx + ry * delta_ry); |
|
1331 |
const qreal delta_rx_plus_ry = 2 * delta_rxrxryry; |
|
1332 |
||
1333 |
inv_a *= inv_a; |
|
1334 |
||
1335 |
qreal det = (bb + 4 * op->radial.a * rxrxryry) * inv_a; |
|
1336 |
qreal delta_det = (b_delta_b + delta_bb + 4 * op->radial.a * (rx_plus_ry + delta_rxrxryry)) * inv_a; |
|
1337 |
const qreal delta_delta_det = (delta_b_delta_b + 4 * op->radial.a * delta_rx_plus_ry) * inv_a; |
|
1338 |
||
1339 |
while (buffer < end) { |
|
1340 |
*buffer = qt_gradient_pixel(&data->gradient, qSafeSqrt(det) - b); |
|
1341 |
||
1342 |
det += delta_det; |
|
1343 |
delta_det += delta_delta_det; |
|
1344 |
b += delta_b; |
|
1345 |
||
1346 |
++buffer; |
|
1347 |
} |
|
1348 |
} else { |
|
1349 |
qreal rw = data->m23 * (y + 0.5) |
|
1350 |
+ data->m33 + data->m13 * (x + 0.5); |
|
1351 |
if (!rw) |
|
1352 |
rw = 1; |
|
1353 |
while (buffer < end) { |
|
1354 |
qreal gx = rx/rw - data->gradient.radial.focal.x; |
|
1355 |
qreal gy = ry/rw - data->gradient.radial.focal.y; |
|
1356 |
qreal b = 2*(gx*op->radial.dx + gy*op->radial.dy); |
|
1357 |
qreal det = determinant(op->radial.a, b , -(gx*gx + gy*gy)); |
|
1358 |
qreal s = realRoots(op->radial.a, b, qSafeSqrt(det)); |
|
1359 |
||
1360 |
*buffer = qt_gradient_pixel(&data->gradient, s); |
|
1361 |
||
1362 |
rx += data->m11; |
|
1363 |
ry += data->m12; |
|
1364 |
rw += data->m13; |
|
1365 |
if (!rw) { |
|
1366 |
rw += data->m13; |
|
1367 |
} |
|
1368 |
++buffer; |
|
1369 |
} |
|
1370 |
} |
|
1371 |
||
1372 |
return b; |
|
1373 |
} |
|
1374 |
||
1375 |
static const uint * QT_FASTCALL fetchConicalGradient(uint *buffer, const Operator *, const QSpanData *data, |
|
1376 |
int y, int x, int length) |
|
1377 |
{ |
|
1378 |
const uint *b = buffer; |
|
1379 |
qreal rx = data->m21 * (y + 0.5) |
|
1380 |
+ data->dx + data->m11 * (x + 0.5); |
|
1381 |
qreal ry = data->m22 * (y + 0.5) |
|
1382 |
+ data->dy + data->m12 * (x + 0.5); |
|
1383 |
bool affine = !data->m13 && !data->m23; |
|
1384 |
||
1385 |
const uint *end = buffer + length; |
|
1386 |
if (affine) { |
|
1387 |
rx -= data->gradient.conical.center.x; |
|
1388 |
ry -= data->gradient.conical.center.y; |
|
1389 |
while (buffer < end) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1390 |
qreal angle = qAtan2(ry, rx) + data->gradient.conical.angle; |
0 | 1391 |
|
1392 |
*buffer = qt_gradient_pixel(&data->gradient, 1 - angle / (2*Q_PI)); |
|
1393 |
||
1394 |
rx += data->m11; |
|
1395 |
ry += data->m12; |
|
1396 |
++buffer; |
|
1397 |
} |
|
1398 |
} else { |
|
1399 |
qreal rw = data->m23 * (y + 0.5) |
|
1400 |
+ data->m33 + data->m13 * (x + 0.5); |
|
1401 |
if (!rw) |
|
1402 |
rw = 1; |
|
1403 |
while (buffer < end) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1404 |
qreal angle = qAtan2(ry/rw - data->gradient.conical.center.x, |
0 | 1405 |
rx/rw - data->gradient.conical.center.y) |
1406 |
+ data->gradient.conical.angle; |
|
1407 |
||
1408 |
*buffer = qt_gradient_pixel(&data->gradient, 1. - angle / (2*Q_PI)); |
|
1409 |
||
1410 |
rx += data->m11; |
|
1411 |
ry += data->m12; |
|
1412 |
rw += data->m13; |
|
1413 |
if (!rw) { |
|
1414 |
rw += data->m13; |
|
1415 |
} |
|
1416 |
++buffer; |
|
1417 |
} |
|
1418 |
} |
|
1419 |
return b; |
|
1420 |
} |
|
1421 |
||
1422 |
#if defined(Q_CC_RVCT) |
|
1423 |
// Force ARM code generation for comp_func_* -methods |
|
1424 |
# pragma push |
|
1425 |
# pragma arm |
|
1426 |
# if defined(QT_HAVE_ARMV6) |
|
1427 |
static __forceinline void preload(const uint *start) |
|
1428 |
{ |
|
1429 |
asm( "pld [start]" ); |
|
1430 |
} |
|
1431 |
static const uint L2CacheLineLength = 32; |
|
1432 |
static const uint L2CacheLineLengthInInts = L2CacheLineLength/sizeof(uint); |
|
1433 |
# define PRELOAD_INIT(x) preload(x); |
|
1434 |
# define PRELOAD_INIT2(x,y) PRELOAD_INIT(x) PRELOAD_INIT(y) |
|
1435 |
# define PRELOAD_COND(x) if (((uint)&x[i])%L2CacheLineLength == 0) preload(&x[i] + L2CacheLineLengthInInts); |
|
1436 |
// Two consecutive preloads stall, so space them out a bit by using different modulus. |
|
1437 |
# define PRELOAD_COND2(x,y) if (((uint)&x[i])%L2CacheLineLength == 0) preload(&x[i] + L2CacheLineLengthInInts); \ |
|
1438 |
if (((uint)&y[i])%L2CacheLineLength == 16) preload(&y[i] + L2CacheLineLengthInInts); |
|
1439 |
# endif // QT_HAVE_ARMV6 |
|
1440 |
#endif // Q_CC_RVCT |
|
1441 |
||
1442 |
#if !defined(Q_CC_RVCT) || !defined(QT_HAVE_ARMV6) |
|
1443 |
# define PRELOAD_INIT(x) |
|
1444 |
# define PRELOAD_INIT2(x,y) |
|
1445 |
# define PRELOAD_COND(x) |
|
1446 |
# define PRELOAD_COND2(x,y) |
|
1447 |
#endif |
|
1448 |
||
1449 |
/* The constant alpha factor describes an alpha factor that gets applied |
|
1450 |
to the result of the composition operation combining it with the destination. |
|
1451 |
||
1452 |
The intent is that if const_alpha == 0. we get back dest, and if const_alpha == 1. |
|
1453 |
we get the unmodified operation |
|
1454 |
||
1455 |
result = src op dest |
|
1456 |
dest = result * const_alpha + dest * (1. - const_alpha) |
|
1457 |
||
1458 |
This means that in the comments below, the first line is the const_alpha==255 case, the |
|
1459 |
second line the general one. |
|
1460 |
||
1461 |
In the lines below: |
|
1462 |
s == src, sa == alpha(src), sia = 1 - alpha(src) |
|
1463 |
d == dest, da == alpha(dest), dia = 1 - alpha(dest) |
|
1464 |
ca = const_alpha, cia = 1 - const_alpha |
|
1465 |
||
1466 |
The methods exist in two variants. One where we have a constant source, the other |
|
1467 |
where the source is an array of pixels. |
|
1468 |
*/ |
|
1469 |
||
1470 |
/* |
|
1471 |
result = 0 |
|
1472 |
d = d * cia |
|
1473 |
*/ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1474 |
#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
|
1475 |
{\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1476 |
if (const_alpha == 255) {\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1477 |
QT_MEMFILL_UINT(dest, length, 0);\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1478 |
} else {\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1479 |
int ialpha = 255 - const_alpha;\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1480 |
PRELOAD_INIT(dest)\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1481 |
for (int i = 0; i < length; ++i) {\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1482 |
PRELOAD_COND(dest)\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1483 |
dest[i] = BYTE_MUL(dest[i], ialpha);\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1484 |
}\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1485 |
}\ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1486 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1487 |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1488 |
void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha) |
0 | 1489 |
{ |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1490 |
comp_func_Clear_impl(dest, length, const_alpha); |
0 | 1491 |
} |
1492 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1493 |
void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha) |
0 | 1494 |
{ |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1495 |
comp_func_Clear_impl(dest, length, const_alpha); |
0 | 1496 |
} |
1497 |
||
1498 |
/* |
|
1499 |
result = s |
|
1500 |
dest = s * ca + d * cia |
|
1501 |
*/ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1502 |
void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint const_alpha) |
0 | 1503 |
{ |
1504 |
if (const_alpha == 255) { |
|
1505 |
QT_MEMFILL_UINT(dest, length, color); |
|
1506 |
} else { |
|
1507 |
int ialpha = 255 - const_alpha; |
|
1508 |
color = BYTE_MUL(color, const_alpha); |
|
1509 |
PRELOAD_INIT(dest) |
|
1510 |
for (int i = 0; i < length; ++i) { |
|
1511 |
PRELOAD_COND(dest) |
|
1512 |
dest[i] = color + BYTE_MUL(dest[i], ialpha); |
|
1513 |
} |
|
1514 |
} |
|
1515 |
} |
|
1516 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1517 |
void QT_FASTCALL comp_func_Source(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1518 |
{ |
1519 |
if (const_alpha == 255) { |
|
1520 |
::memcpy(dest, src, length * sizeof(uint)); |
|
1521 |
} else { |
|
1522 |
int ialpha = 255 - const_alpha; |
|
1523 |
PRELOAD_INIT2(dest, src) |
|
1524 |
for (int i = 0; i < length; ++i) { |
|
1525 |
PRELOAD_COND2(dest, src) |
|
1526 |
dest[i] = INTERPOLATE_PIXEL_255(src[i], const_alpha, dest[i], ialpha); |
|
1527 |
} |
|
1528 |
} |
|
1529 |
} |
|
1530 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1531 |
void QT_FASTCALL comp_func_solid_Destination(uint *, int, uint, uint) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1532 |
{ |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1533 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1534 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1535 |
void QT_FASTCALL comp_func_Destination(uint *, const uint *, int, uint) |
0 | 1536 |
{ |
1537 |
} |
|
1538 |
||
1539 |
/* |
|
1540 |
result = s + d * sia |
|
1541 |
dest = (s + d * sia) * ca + d * cia |
|
1542 |
= s * ca + d * (sia * ca + cia) |
|
1543 |
= s * ca + d * (1 - sa*ca) |
|
1544 |
*/ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1545 |
void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha) |
0 | 1546 |
{ |
1547 |
if ((const_alpha & qAlpha(color)) == 255) { |
|
1548 |
QT_MEMFILL_UINT(dest, length, color); |
|
1549 |
} else { |
|
1550 |
if (const_alpha != 255) |
|
1551 |
color = BYTE_MUL(color, const_alpha); |
|
1552 |
PRELOAD_INIT(dest) |
|
1553 |
for (int i = 0; i < length; ++i) { |
|
1554 |
PRELOAD_COND(dest) |
|
1555 |
dest[i] = color + BYTE_MUL(dest[i], qAlpha(~color)); |
|
1556 |
} |
|
1557 |
} |
|
1558 |
} |
|
1559 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1560 |
void QT_FASTCALL comp_func_SourceOver(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1561 |
{ |
1562 |
PRELOAD_INIT2(dest, src) |
|
1563 |
if (const_alpha == 255) { |
|
1564 |
for (int i = 0; i < length; ++i) { |
|
1565 |
PRELOAD_COND2(dest, src) |
|
1566 |
uint s = src[i]; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1567 |
if (s >= 0xff000000) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1568 |
dest[i] = s; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1569 |
else if (s != 0) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1570 |
dest[i] = s + BYTE_MUL(dest[i], qAlpha(~s)); |
0 | 1571 |
} |
1572 |
} else { |
|
1573 |
for (int i = 0; i < length; ++i) { |
|
1574 |
PRELOAD_COND2(dest, src) |
|
1575 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1576 |
dest[i] = s + BYTE_MUL(dest[i], qAlpha(~s)); |
|
1577 |
} |
|
1578 |
} |
|
1579 |
} |
|
1580 |
||
1581 |
/* |
|
1582 |
result = d + s * dia |
|
1583 |
dest = (d + s * dia) * ca + d * cia |
|
1584 |
= d + s * dia * ca |
|
1585 |
*/ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1586 |
void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha) |
0 | 1587 |
{ |
1588 |
if (const_alpha != 255) |
|
1589 |
color = BYTE_MUL(color, const_alpha); |
|
1590 |
PRELOAD_INIT(dest) |
|
1591 |
for (int i = 0; i < length; ++i) { |
|
1592 |
PRELOAD_COND(dest) |
|
1593 |
uint d = dest[i]; |
|
1594 |
dest[i] = d + BYTE_MUL(color, qAlpha(~d)); |
|
1595 |
} |
|
1596 |
} |
|
1597 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1598 |
void QT_FASTCALL comp_func_DestinationOver(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1599 |
{ |
1600 |
PRELOAD_INIT2(dest, src) |
|
1601 |
if (const_alpha == 255) { |
|
1602 |
for (int i = 0; i < length; ++i) { |
|
1603 |
PRELOAD_COND2(dest, src) |
|
1604 |
uint d = dest[i]; |
|
1605 |
dest[i] = d + BYTE_MUL(src[i], qAlpha(~d)); |
|
1606 |
} |
|
1607 |
} else { |
|
1608 |
for (int i = 0; i < length; ++i) { |
|
1609 |
PRELOAD_COND2(dest, src) |
|
1610 |
uint d = dest[i]; |
|
1611 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1612 |
dest[i] = d + BYTE_MUL(s, qAlpha(~d)); |
|
1613 |
} |
|
1614 |
} |
|
1615 |
} |
|
1616 |
||
1617 |
/* |
|
1618 |
result = s * da |
|
1619 |
dest = s * da * ca + d * cia |
|
1620 |
*/ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1621 |
void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, uint const_alpha) |
0 | 1622 |
{ |
1623 |
PRELOAD_INIT(dest) |
|
1624 |
if (const_alpha == 255) { |
|
1625 |
for (int i = 0; i < length; ++i) { |
|
1626 |
PRELOAD_COND(dest) |
|
1627 |
dest[i] = BYTE_MUL(color, qAlpha(dest[i])); |
|
1628 |
} |
|
1629 |
} else { |
|
1630 |
color = BYTE_MUL(color, const_alpha); |
|
1631 |
uint cia = 255 - const_alpha; |
|
1632 |
for (int i = 0; i < length; ++i) { |
|
1633 |
PRELOAD_COND(dest) |
|
1634 |
uint d = dest[i]; |
|
1635 |
dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(d), d, cia); |
|
1636 |
} |
|
1637 |
} |
|
1638 |
} |
|
1639 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1640 |
void QT_FASTCALL comp_func_SourceIn(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1641 |
{ |
1642 |
PRELOAD_INIT2(dest, src) |
|
1643 |
if (const_alpha == 255) { |
|
1644 |
for (int i = 0; i < length; ++i) { |
|
1645 |
PRELOAD_COND2(dest, src) |
|
1646 |
dest[i] = BYTE_MUL(src[i], qAlpha(dest[i])); |
|
1647 |
} |
|
1648 |
} else { |
|
1649 |
uint cia = 255 - const_alpha; |
|
1650 |
for (int i = 0; i < length; ++i) { |
|
1651 |
PRELOAD_COND2(dest, src) |
|
1652 |
uint d = dest[i]; |
|
1653 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1654 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, cia); |
|
1655 |
} |
|
1656 |
} |
|
1657 |
} |
|
1658 |
||
1659 |
/* |
|
1660 |
result = d * sa |
|
1661 |
dest = d * sa * ca + d * cia |
|
1662 |
= d * (sa * ca + cia) |
|
1663 |
*/ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1664 |
void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha) |
0 | 1665 |
{ |
1666 |
uint a = qAlpha(color); |
|
1667 |
if (const_alpha != 255) { |
|
1668 |
a = BYTE_MUL(a, const_alpha) + 255 - const_alpha; |
|
1669 |
} |
|
1670 |
PRELOAD_INIT(dest) |
|
1671 |
for (int i = 0; i < length; ++i) { |
|
1672 |
PRELOAD_COND(dest) |
|
1673 |
dest[i] = BYTE_MUL(dest[i], a); |
|
1674 |
} |
|
1675 |
} |
|
1676 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1677 |
void QT_FASTCALL comp_func_DestinationIn(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1678 |
{ |
1679 |
PRELOAD_INIT2(dest, src) |
|
1680 |
if (const_alpha == 255) { |
|
1681 |
for (int i = 0; i < length; ++i) { |
|
1682 |
PRELOAD_COND2(dest, src) |
|
1683 |
dest[i] = BYTE_MUL(dest[i], qAlpha(src[i])); |
|
1684 |
} |
|
1685 |
} else { |
|
1686 |
int cia = 255 - const_alpha; |
|
1687 |
for (int i = 0; i < length; ++i) { |
|
1688 |
PRELOAD_COND2(dest, src) |
|
1689 |
uint a = BYTE_MUL(qAlpha(src[i]), const_alpha) + cia; |
|
1690 |
dest[i] = BYTE_MUL(dest[i], a); |
|
1691 |
} |
|
1692 |
} |
|
1693 |
} |
|
1694 |
||
1695 |
/* |
|
1696 |
result = s * dia |
|
1697 |
dest = s * dia * ca + d * cia |
|
1698 |
*/ |
|
1699 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1700 |
void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, uint const_alpha) |
0 | 1701 |
{ |
1702 |
PRELOAD_INIT(dest) |
|
1703 |
if (const_alpha == 255) { |
|
1704 |
for (int i = 0; i < length; ++i) { |
|
1705 |
PRELOAD_COND(dest) |
|
1706 |
dest[i] = BYTE_MUL(color, qAlpha(~dest[i])); |
|
1707 |
} |
|
1708 |
} else { |
|
1709 |
color = BYTE_MUL(color, const_alpha); |
|
1710 |
int cia = 255 - const_alpha; |
|
1711 |
for (int i = 0; i < length; ++i) { |
|
1712 |
PRELOAD_COND(dest) |
|
1713 |
uint d = dest[i]; |
|
1714 |
dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(~d), d, cia); |
|
1715 |
} |
|
1716 |
} |
|
1717 |
} |
|
1718 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1719 |
void QT_FASTCALL comp_func_SourceOut(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1720 |
{ |
1721 |
PRELOAD_INIT2(dest, src) |
|
1722 |
if (const_alpha == 255) { |
|
1723 |
for (int i = 0; i < length; ++i) { |
|
1724 |
PRELOAD_COND2(dest, src) |
|
1725 |
dest[i] = BYTE_MUL(src[i], qAlpha(~dest[i])); |
|
1726 |
} |
|
1727 |
} else { |
|
1728 |
int cia = 255 - const_alpha; |
|
1729 |
for (int i = 0; i < length; ++i) { |
|
1730 |
PRELOAD_COND2(dest, src) |
|
1731 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1732 |
uint d = dest[i]; |
|
1733 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, cia); |
|
1734 |
} |
|
1735 |
} |
|
1736 |
} |
|
1737 |
||
1738 |
/* |
|
1739 |
result = d * sia |
|
1740 |
dest = d * sia * ca + d * cia |
|
1741 |
= d * (sia * ca + cia) |
|
1742 |
*/ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1743 |
void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha) |
0 | 1744 |
{ |
1745 |
uint a = qAlpha(~color); |
|
1746 |
if (const_alpha != 255) |
|
1747 |
a = BYTE_MUL(a, const_alpha) + 255 - const_alpha; |
|
1748 |
PRELOAD_INIT(dest) |
|
1749 |
for (int i = 0; i < length; ++i) { |
|
1750 |
PRELOAD_COND(dest) |
|
1751 |
dest[i] = BYTE_MUL(dest[i], a); |
|
1752 |
} |
|
1753 |
} |
|
1754 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1755 |
void QT_FASTCALL comp_func_DestinationOut(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1756 |
{ |
1757 |
PRELOAD_INIT2(dest, src) |
|
1758 |
if (const_alpha == 255) { |
|
1759 |
for (int i = 0; i < length; ++i) { |
|
1760 |
PRELOAD_COND2(dest, src) |
|
1761 |
dest[i] = BYTE_MUL(dest[i], qAlpha(~src[i])); |
|
1762 |
} |
|
1763 |
} else { |
|
1764 |
int cia = 255 - const_alpha; |
|
1765 |
for (int i = 0; i < length; ++i) { |
|
1766 |
PRELOAD_COND2(dest, src) |
|
1767 |
uint sia = BYTE_MUL(qAlpha(~src[i]), const_alpha) + cia; |
|
1768 |
dest[i] = BYTE_MUL(dest[i], sia); |
|
1769 |
} |
|
1770 |
} |
|
1771 |
} |
|
1772 |
||
1773 |
/* |
|
1774 |
result = s*da + d*sia |
|
1775 |
dest = s*da*ca + d*sia*ca + d *cia |
|
1776 |
= s*ca * da + d * (sia*ca + cia) |
|
1777 |
= s*ca * da + d * (1 - sa*ca) |
|
1778 |
*/ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1779 |
void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, uint const_alpha) |
0 | 1780 |
{ |
1781 |
if (const_alpha != 255) { |
|
1782 |
color = BYTE_MUL(color, const_alpha); |
|
1783 |
} |
|
1784 |
uint sia = qAlpha(~color); |
|
1785 |
PRELOAD_INIT(dest) |
|
1786 |
for (int i = 0; i < length; ++i) { |
|
1787 |
PRELOAD_COND(dest) |
|
1788 |
dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(dest[i]), dest[i], sia); |
|
1789 |
} |
|
1790 |
} |
|
1791 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1792 |
void QT_FASTCALL comp_func_SourceAtop(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1793 |
{ |
1794 |
PRELOAD_INIT2(dest, src) |
|
1795 |
if (const_alpha == 255) { |
|
1796 |
for (int i = 0; i < length; ++i) { |
|
1797 |
PRELOAD_COND2(dest, src) |
|
1798 |
uint s = src[i]; |
|
1799 |
uint d = dest[i]; |
|
1800 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, qAlpha(~s)); |
|
1801 |
} |
|
1802 |
} else { |
|
1803 |
for (int i = 0; i < length; ++i) { |
|
1804 |
PRELOAD_COND2(dest, src) |
|
1805 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1806 |
uint d = dest[i]; |
|
1807 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(d), d, qAlpha(~s)); |
|
1808 |
} |
|
1809 |
} |
|
1810 |
} |
|
1811 |
||
1812 |
/* |
|
1813 |
result = d*sa + s*dia |
|
1814 |
dest = d*sa*ca + s*dia*ca + d *cia |
|
1815 |
= s*ca * dia + d * (sa*ca + cia) |
|
1816 |
*/ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1817 |
void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint color, uint const_alpha) |
0 | 1818 |
{ |
1819 |
uint a = qAlpha(color); |
|
1820 |
if (const_alpha != 255) { |
|
1821 |
color = BYTE_MUL(color, const_alpha); |
|
1822 |
a = qAlpha(color) + 255 - const_alpha; |
|
1823 |
} |
|
1824 |
PRELOAD_INIT(dest) |
|
1825 |
for (int i = 0; i < length; ++i) { |
|
1826 |
PRELOAD_COND(dest) |
|
1827 |
uint d = dest[i]; |
|
1828 |
dest[i] = INTERPOLATE_PIXEL_255(d, a, color, qAlpha(~d)); |
|
1829 |
} |
|
1830 |
} |
|
1831 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1832 |
void QT_FASTCALL comp_func_DestinationAtop(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1833 |
{ |
1834 |
PRELOAD_INIT2(dest, src) |
|
1835 |
if (const_alpha == 255) { |
|
1836 |
for (int i = 0; i < length; ++i) { |
|
1837 |
PRELOAD_COND2(dest, src) |
|
1838 |
uint s = src[i]; |
|
1839 |
uint d = dest[i]; |
|
1840 |
dest[i] = INTERPOLATE_PIXEL_255(d, qAlpha(s), s, qAlpha(~d)); |
|
1841 |
} |
|
1842 |
} else { |
|
1843 |
int cia = 255 - const_alpha; |
|
1844 |
for (int i = 0; i < length; ++i) { |
|
1845 |
PRELOAD_COND2(dest, src) |
|
1846 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1847 |
uint d = dest[i]; |
|
1848 |
uint a = qAlpha(s) + cia; |
|
1849 |
dest[i] = INTERPOLATE_PIXEL_255(d, a, s, qAlpha(~d)); |
|
1850 |
} |
|
1851 |
} |
|
1852 |
} |
|
1853 |
||
1854 |
/* |
|
1855 |
result = d*sia + s*dia |
|
1856 |
dest = d*sia*ca + s*dia*ca + d *cia |
|
1857 |
= s*ca * dia + d * (sia*ca + cia) |
|
1858 |
= s*ca * dia + d * (1 - sa*ca) |
|
1859 |
*/ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1860 |
void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint const_alpha) |
0 | 1861 |
{ |
1862 |
if (const_alpha != 255) |
|
1863 |
color = BYTE_MUL(color, const_alpha); |
|
1864 |
uint sia = qAlpha(~color); |
|
1865 |
||
1866 |
PRELOAD_INIT(dest) |
|
1867 |
for (int i = 0; i < length; ++i) { |
|
1868 |
PRELOAD_COND(dest) |
|
1869 |
uint d = dest[i]; |
|
1870 |
dest[i] = INTERPOLATE_PIXEL_255(color, qAlpha(~d), d, sia); |
|
1871 |
} |
|
1872 |
} |
|
1873 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1874 |
void QT_FASTCALL comp_func_XOR(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1875 |
{ |
1876 |
PRELOAD_INIT2(dest, src) |
|
1877 |
if (const_alpha == 255) { |
|
1878 |
for (int i = 0; i < length; ++i) { |
|
1879 |
PRELOAD_COND2(dest, src) |
|
1880 |
uint d = dest[i]; |
|
1881 |
uint s = src[i]; |
|
1882 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, qAlpha(~s)); |
|
1883 |
} |
|
1884 |
} else { |
|
1885 |
for (int i = 0; i < length; ++i) { |
|
1886 |
PRELOAD_COND2(dest, src) |
|
1887 |
uint d = dest[i]; |
|
1888 |
uint s = BYTE_MUL(src[i], const_alpha); |
|
1889 |
dest[i] = INTERPOLATE_PIXEL_255(s, qAlpha(~d), d, qAlpha(~s)); |
|
1890 |
} |
|
1891 |
} |
|
1892 |
} |
|
1893 |
||
1894 |
struct QFullCoverage { |
|
1895 |
inline void store(uint *dest, const uint src) const |
|
1896 |
{ |
|
1897 |
*dest = src; |
|
1898 |
} |
|
1899 |
}; |
|
1900 |
||
1901 |
struct QPartialCoverage { |
|
1902 |
inline QPartialCoverage(uint const_alpha) |
|
1903 |
: ca(const_alpha) |
|
1904 |
, ica(255 - const_alpha) |
|
1905 |
{ |
|
1906 |
} |
|
1907 |
||
1908 |
inline void store(uint *dest, const uint src) const |
|
1909 |
{ |
|
1910 |
*dest = INTERPOLATE_PIXEL_255(src, ca, *dest, ica); |
|
1911 |
} |
|
1912 |
||
1913 |
private: |
|
1914 |
const uint ca; |
|
1915 |
const uint ica; |
|
1916 |
}; |
|
1917 |
||
1918 |
static inline int mix_alpha(int da, int sa) |
|
1919 |
{ |
|
1920 |
return 255 - ((255 - sa) * (255 - da) >> 8); |
|
1921 |
} |
|
1922 |
||
1923 |
/* |
|
1924 |
Dca' = Sca.Da + Dca.Sa + Sca.(1 - Da) + Dca.(1 - Sa) |
|
1925 |
= Sca + Dca |
|
1926 |
*/ |
|
1927 |
template <typename T> |
|
1928 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Plus_impl(uint *dest, int length, uint color, const T &coverage) |
|
1929 |
{ |
|
1930 |
uint s = color; |
|
1931 |
||
1932 |
PRELOAD_INIT(dest) |
|
1933 |
for (int i = 0; i < length; ++i) { |
|
1934 |
PRELOAD_COND(dest) |
|
1935 |
uint d = dest[i]; |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1936 |
d = comp_func_Plus_one_pixel(d, s); |
0 | 1937 |
coverage.store(&dest[i], d); |
1938 |
} |
|
1939 |
} |
|
1940 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1941 |
void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint const_alpha) |
0 | 1942 |
{ |
1943 |
if (const_alpha == 255) |
|
1944 |
comp_func_solid_Plus_impl(dest, length, color, QFullCoverage()); |
|
1945 |
else |
|
1946 |
comp_func_solid_Plus_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
1947 |
} |
|
1948 |
||
1949 |
template <typename T> |
|
1950 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Plus_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
1951 |
{ |
|
1952 |
PRELOAD_INIT2(dest, src) |
|
1953 |
for (int i = 0; i < length; ++i) { |
|
1954 |
PRELOAD_COND2(dest, src) |
|
1955 |
uint d = dest[i]; |
|
1956 |
uint s = src[i]; |
|
1957 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1958 |
d = comp_func_Plus_one_pixel(d, s); |
0 | 1959 |
|
1960 |
coverage.store(&dest[i], d); |
|
1961 |
} |
|
1962 |
} |
|
1963 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1964 |
void QT_FASTCALL comp_func_Plus(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 1965 |
{ |
1966 |
if (const_alpha == 255) |
|
1967 |
comp_func_Plus_impl(dest, src, length, QFullCoverage()); |
|
1968 |
else |
|
1969 |
comp_func_Plus_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
1970 |
} |
|
1971 |
||
1972 |
/* |
|
1973 |
Dca' = Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) |
|
1974 |
*/ |
|
1975 |
static inline int multiply_op(int dst, int src, int da, int sa) |
|
1976 |
{ |
|
1977 |
return qt_div_255(src * dst + src * (255 - da) + dst * (255 - sa)); |
|
1978 |
} |
|
1979 |
||
1980 |
template <typename T> |
|
1981 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(uint *dest, int length, uint color, const T &coverage) |
|
1982 |
{ |
|
1983 |
int sa = qAlpha(color); |
|
1984 |
int sr = qRed(color); |
|
1985 |
int sg = qGreen(color); |
|
1986 |
int sb = qBlue(color); |
|
1987 |
||
1988 |
PRELOAD_INIT(dest) |
|
1989 |
for (int i = 0; i < length; ++i) { |
|
1990 |
PRELOAD_COND(dest) |
|
1991 |
uint d = dest[i]; |
|
1992 |
int da = qAlpha(d); |
|
1993 |
||
1994 |
#define OP(a, b) multiply_op(a, b, da, sa) |
|
1995 |
int r = OP( qRed(d), sr); |
|
1996 |
int b = OP( qBlue(d), sb); |
|
1997 |
int g = OP(qGreen(d), sg); |
|
1998 |
int a = mix_alpha(da, sa); |
|
1999 |
#undef OP |
|
2000 |
||
2001 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2002 |
} |
|
2003 |
} |
|
2004 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2005 |
void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha) |
0 | 2006 |
{ |
2007 |
if (const_alpha == 255) |
|
2008 |
comp_func_solid_Multiply_impl(dest, length, color, QFullCoverage()); |
|
2009 |
else |
|
2010 |
comp_func_solid_Multiply_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2011 |
} |
|
2012 |
||
2013 |
template <typename T> |
|
2014 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Multiply_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2015 |
{ |
|
2016 |
PRELOAD_INIT2(dest, src) |
|
2017 |
for (int i = 0; i < length; ++i) { |
|
2018 |
PRELOAD_COND2(dest, src) |
|
2019 |
uint d = dest[i]; |
|
2020 |
uint s = src[i]; |
|
2021 |
||
2022 |
int da = qAlpha(d); |
|
2023 |
int sa = qAlpha(s); |
|
2024 |
||
2025 |
#define OP(a, b) multiply_op(a, b, da, sa) |
|
2026 |
int r = OP( qRed(d), qRed(s)); |
|
2027 |
int b = OP( qBlue(d), qBlue(s)); |
|
2028 |
int g = OP(qGreen(d), qGreen(s)); |
|
2029 |
int a = mix_alpha(da, sa); |
|
2030 |
#undef OP |
|
2031 |
||
2032 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2033 |
} |
|
2034 |
} |
|
2035 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2036 |
void QT_FASTCALL comp_func_Multiply(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2037 |
{ |
2038 |
if (const_alpha == 255) |
|
2039 |
comp_func_Multiply_impl(dest, src, length, QFullCoverage()); |
|
2040 |
else |
|
2041 |
comp_func_Multiply_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2042 |
} |
|
2043 |
||
2044 |
/* |
|
2045 |
Dca' = (Sca.Da + Dca.Sa - Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2046 |
= Sca + Dca - Sca.Dca |
|
2047 |
*/ |
|
2048 |
template <typename T> |
|
2049 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Screen_impl(uint *dest, int length, uint color, const T &coverage) |
|
2050 |
{ |
|
2051 |
int sa = qAlpha(color); |
|
2052 |
int sr = qRed(color); |
|
2053 |
int sg = qGreen(color); |
|
2054 |
int sb = qBlue(color); |
|
2055 |
||
2056 |
PRELOAD_INIT(dest) |
|
2057 |
for (int i = 0; i < length; ++i) { |
|
2058 |
PRELOAD_COND(dest) |
|
2059 |
uint d = dest[i]; |
|
2060 |
int da = qAlpha(d); |
|
2061 |
||
2062 |
#define OP(a, b) 255 - qt_div_255((255-a) * (255-b)) |
|
2063 |
int r = OP( qRed(d), sr); |
|
2064 |
int b = OP( qBlue(d), sb); |
|
2065 |
int g = OP(qGreen(d), sg); |
|
2066 |
int a = mix_alpha(da, sa); |
|
2067 |
#undef OP |
|
2068 |
||
2069 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2070 |
} |
|
2071 |
} |
|
2072 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2073 |
void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha) |
0 | 2074 |
{ |
2075 |
if (const_alpha == 255) |
|
2076 |
comp_func_solid_Screen_impl(dest, length, color, QFullCoverage()); |
|
2077 |
else |
|
2078 |
comp_func_solid_Screen_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2079 |
} |
|
2080 |
||
2081 |
template <typename T> |
|
2082 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Screen_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2083 |
{ |
|
2084 |
PRELOAD_INIT2(dest, src) |
|
2085 |
for (int i = 0; i < length; ++i) { |
|
2086 |
PRELOAD_COND2(dest, src) |
|
2087 |
uint d = dest[i]; |
|
2088 |
uint s = src[i]; |
|
2089 |
||
2090 |
int da = qAlpha(d); |
|
2091 |
int sa = qAlpha(s); |
|
2092 |
||
2093 |
#define OP(a, b) 255 - (((255-a) * (255-b)) >> 8) |
|
2094 |
int r = OP( qRed(d), qRed(s)); |
|
2095 |
int b = OP( qBlue(d), qBlue(s)); |
|
2096 |
int g = OP(qGreen(d), qGreen(s)); |
|
2097 |
int a = mix_alpha(da, sa); |
|
2098 |
#undef OP |
|
2099 |
||
2100 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2101 |
} |
|
2102 |
} |
|
2103 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2104 |
void QT_FASTCALL comp_func_Screen(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2105 |
{ |
2106 |
if (const_alpha == 255) |
|
2107 |
comp_func_Screen_impl(dest, src, length, QFullCoverage()); |
|
2108 |
else |
|
2109 |
comp_func_Screen_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2110 |
} |
|
2111 |
||
2112 |
/* |
|
2113 |
if 2.Dca < Da |
|
2114 |
Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2115 |
otherwise |
|
2116 |
Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2117 |
*/ |
|
2118 |
static inline int overlay_op(int dst, int src, int da, int sa) |
|
2119 |
{ |
|
2120 |
const int temp = src * (255 - da) + dst * (255 - sa); |
|
2121 |
if (2 * dst < da) |
|
2122 |
return qt_div_255(2 * src * dst + temp); |
|
2123 |
else |
|
2124 |
return qt_div_255(sa * da - 2 * (da - dst) * (sa - src) + temp); |
|
2125 |
} |
|
2126 |
||
2127 |
template <typename T> |
|
2128 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(uint *dest, int length, uint color, const T &coverage) |
|
2129 |
{ |
|
2130 |
int sa = qAlpha(color); |
|
2131 |
int sr = qRed(color); |
|
2132 |
int sg = qGreen(color); |
|
2133 |
int sb = qBlue(color); |
|
2134 |
||
2135 |
PRELOAD_INIT(dest) |
|
2136 |
for (int i = 0; i < length; ++i) { |
|
2137 |
PRELOAD_COND(dest) |
|
2138 |
uint d = dest[i]; |
|
2139 |
int da = qAlpha(d); |
|
2140 |
||
2141 |
#define OP(a, b) overlay_op(a, b, da, sa) |
|
2142 |
int r = OP( qRed(d), sr); |
|
2143 |
int b = OP( qBlue(d), sb); |
|
2144 |
int g = OP(qGreen(d), sg); |
|
2145 |
int a = mix_alpha(da, sa); |
|
2146 |
#undef OP |
|
2147 |
||
2148 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2149 |
} |
|
2150 |
} |
|
2151 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2152 |
void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha) |
0 | 2153 |
{ |
2154 |
if (const_alpha == 255) |
|
2155 |
comp_func_solid_Overlay_impl(dest, length, color, QFullCoverage()); |
|
2156 |
else |
|
2157 |
comp_func_solid_Overlay_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2158 |
} |
|
2159 |
||
2160 |
template <typename T> |
|
2161 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Overlay_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2162 |
{ |
|
2163 |
PRELOAD_INIT2(dest, src) |
|
2164 |
for (int i = 0; i < length; ++i) { |
|
2165 |
PRELOAD_COND2(dest, src) |
|
2166 |
uint d = dest[i]; |
|
2167 |
uint s = src[i]; |
|
2168 |
||
2169 |
int da = qAlpha(d); |
|
2170 |
int sa = qAlpha(s); |
|
2171 |
||
2172 |
#define OP(a, b) overlay_op(a, b, da, sa) |
|
2173 |
int r = OP( qRed(d), qRed(s)); |
|
2174 |
int b = OP( qBlue(d), qBlue(s)); |
|
2175 |
int g = OP(qGreen(d), qGreen(s)); |
|
2176 |
int a = mix_alpha(da, sa); |
|
2177 |
#undef OP |
|
2178 |
||
2179 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2180 |
} |
|
2181 |
} |
|
2182 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2183 |
void QT_FASTCALL comp_func_Overlay(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2184 |
{ |
2185 |
if (const_alpha == 255) |
|
2186 |
comp_func_Overlay_impl(dest, src, length, QFullCoverage()); |
|
2187 |
else |
|
2188 |
comp_func_Overlay_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2189 |
} |
|
2190 |
||
2191 |
/* |
|
2192 |
Dca' = min(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2193 |
Da' = Sa + Da - Sa.Da |
|
2194 |
*/ |
|
2195 |
static inline int darken_op(int dst, int src, int da, int sa) |
|
2196 |
{ |
|
2197 |
return qt_div_255(qMin(src * da, dst * sa) + src * (255 - da) + dst * (255 - sa)); |
|
2198 |
} |
|
2199 |
||
2200 |
template <typename T> |
|
2201 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(uint *dest, int length, uint color, const T &coverage) |
|
2202 |
{ |
|
2203 |
int sa = qAlpha(color); |
|
2204 |
int sr = qRed(color); |
|
2205 |
int sg = qGreen(color); |
|
2206 |
int sb = qBlue(color); |
|
2207 |
||
2208 |
PRELOAD_INIT(dest) |
|
2209 |
for (int i = 0; i < length; ++i) { |
|
2210 |
PRELOAD_COND(dest) |
|
2211 |
uint d = dest[i]; |
|
2212 |
int da = qAlpha(d); |
|
2213 |
||
2214 |
#define OP(a, b) darken_op(a, b, da, sa) |
|
2215 |
int r = OP( qRed(d), sr); |
|
2216 |
int b = OP( qBlue(d), sb); |
|
2217 |
int g = OP(qGreen(d), sg); |
|
2218 |
int a = mix_alpha(da, sa); |
|
2219 |
#undef OP |
|
2220 |
||
2221 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2222 |
} |
|
2223 |
} |
|
2224 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2225 |
void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha) |
0 | 2226 |
{ |
2227 |
if (const_alpha == 255) |
|
2228 |
comp_func_solid_Darken_impl(dest, length, color, QFullCoverage()); |
|
2229 |
else |
|
2230 |
comp_func_solid_Darken_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2231 |
} |
|
2232 |
||
2233 |
template <typename T> |
|
2234 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Darken_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2235 |
{ |
|
2236 |
PRELOAD_INIT2(dest, src) |
|
2237 |
for (int i = 0; i < length; ++i) { |
|
2238 |
PRELOAD_COND2(dest, src) |
|
2239 |
uint d = dest[i]; |
|
2240 |
uint s = src[i]; |
|
2241 |
||
2242 |
int da = qAlpha(d); |
|
2243 |
int sa = qAlpha(s); |
|
2244 |
||
2245 |
#define OP(a, b) darken_op(a, b, da, sa) |
|
2246 |
int r = OP( qRed(d), qRed(s)); |
|
2247 |
int b = OP( qBlue(d), qBlue(s)); |
|
2248 |
int g = OP(qGreen(d), qGreen(s)); |
|
2249 |
int a = mix_alpha(da, sa); |
|
2250 |
#undef OP |
|
2251 |
||
2252 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2253 |
} |
|
2254 |
} |
|
2255 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2256 |
void QT_FASTCALL comp_func_Darken(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2257 |
{ |
2258 |
if (const_alpha == 255) |
|
2259 |
comp_func_Darken_impl(dest, src, length, QFullCoverage()); |
|
2260 |
else |
|
2261 |
comp_func_Darken_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2262 |
} |
|
2263 |
||
2264 |
/* |
|
2265 |
Dca' = max(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2266 |
Da' = Sa + Da - Sa.Da |
|
2267 |
*/ |
|
2268 |
static inline int lighten_op(int dst, int src, int da, int sa) |
|
2269 |
{ |
|
2270 |
return qt_div_255(qMax(src * da, dst * sa) + src * (255 - da) + dst * (255 - sa)); |
|
2271 |
} |
|
2272 |
||
2273 |
template <typename T> |
|
2274 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(uint *dest, int length, uint color, const T &coverage) |
|
2275 |
{ |
|
2276 |
int sa = qAlpha(color); |
|
2277 |
int sr = qRed(color); |
|
2278 |
int sg = qGreen(color); |
|
2279 |
int sb = qBlue(color); |
|
2280 |
||
2281 |
PRELOAD_INIT(dest) |
|
2282 |
for (int i = 0; i < length; ++i) { |
|
2283 |
PRELOAD_COND(dest) |
|
2284 |
uint d = dest[i]; |
|
2285 |
int da = qAlpha(d); |
|
2286 |
||
2287 |
#define OP(a, b) lighten_op(a, b, da, sa) |
|
2288 |
int r = OP( qRed(d), sr); |
|
2289 |
int b = OP( qBlue(d), sb); |
|
2290 |
int g = OP(qGreen(d), sg); |
|
2291 |
int a = mix_alpha(da, sa); |
|
2292 |
#undef OP |
|
2293 |
||
2294 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2295 |
} |
|
2296 |
} |
|
2297 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2298 |
void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha) |
0 | 2299 |
{ |
2300 |
if (const_alpha == 255) |
|
2301 |
comp_func_solid_Lighten_impl(dest, length, color, QFullCoverage()); |
|
2302 |
else |
|
2303 |
comp_func_solid_Lighten_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2304 |
} |
|
2305 |
||
2306 |
template <typename T> |
|
2307 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Lighten_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2308 |
{ |
|
2309 |
PRELOAD_INIT2(dest, src) |
|
2310 |
for (int i = 0; i < length; ++i) { |
|
2311 |
PRELOAD_COND2(dest, src) |
|
2312 |
uint d = dest[i]; |
|
2313 |
uint s = src[i]; |
|
2314 |
||
2315 |
int da = qAlpha(d); |
|
2316 |
int sa = qAlpha(s); |
|
2317 |
||
2318 |
#define OP(a, b) lighten_op(a, b, da, sa) |
|
2319 |
int r = OP( qRed(d), qRed(s)); |
|
2320 |
int b = OP( qBlue(d), qBlue(s)); |
|
2321 |
int g = OP(qGreen(d), qGreen(s)); |
|
2322 |
int a = mix_alpha(da, sa); |
|
2323 |
#undef OP |
|
2324 |
||
2325 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2326 |
} |
|
2327 |
} |
|
2328 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2329 |
void QT_FASTCALL comp_func_Lighten(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2330 |
{ |
2331 |
if (const_alpha == 255) |
|
2332 |
comp_func_Lighten_impl(dest, src, length, QFullCoverage()); |
|
2333 |
else |
|
2334 |
comp_func_Lighten_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2335 |
} |
|
2336 |
||
2337 |
/* |
|
2338 |
if Sca.Da + Dca.Sa >= Sa.Da |
|
2339 |
Dca' = Sa.Da + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2340 |
otherwise |
|
2341 |
Dca' = Dca.Sa/(1-Sca/Sa) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2342 |
*/ |
|
2343 |
static inline int color_dodge_op(int dst, int src, int da, int sa) |
|
2344 |
{ |
|
2345 |
const int sa_da = sa * da; |
|
2346 |
const int dst_sa = dst * sa; |
|
2347 |
const int src_da = src * da; |
|
2348 |
||
2349 |
const int temp = src * (255 - da) + dst * (255 - sa); |
|
2350 |
if (src_da + dst_sa >= sa_da) |
|
2351 |
return qt_div_255(sa_da + temp); |
|
2352 |
else |
|
2353 |
return qt_div_255(255 * dst_sa / (255 - 255 * src / sa) + temp); |
|
2354 |
} |
|
2355 |
||
2356 |
template <typename T> |
|
2357 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(uint *dest, int length, uint color, const T &coverage) |
|
2358 |
{ |
|
2359 |
int sa = qAlpha(color); |
|
2360 |
int sr = qRed(color); |
|
2361 |
int sg = qGreen(color); |
|
2362 |
int sb = qBlue(color); |
|
2363 |
||
2364 |
PRELOAD_INIT(dest) |
|
2365 |
for (int i = 0; i < length; ++i) { |
|
2366 |
PRELOAD_COND(dest) |
|
2367 |
uint d = dest[i]; |
|
2368 |
int da = qAlpha(d); |
|
2369 |
||
2370 |
#define OP(a,b) color_dodge_op(a, b, da, sa) |
|
2371 |
int r = OP( qRed(d), sr); |
|
2372 |
int b = OP( qBlue(d), sb); |
|
2373 |
int g = OP(qGreen(d), sg); |
|
2374 |
int a = mix_alpha(da, sa); |
|
2375 |
#undef OP |
|
2376 |
||
2377 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2378 |
} |
|
2379 |
} |
|
2380 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2381 |
void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha) |
0 | 2382 |
{ |
2383 |
if (const_alpha == 255) |
|
2384 |
comp_func_solid_ColorDodge_impl(dest, length, color, QFullCoverage()); |
|
2385 |
else |
|
2386 |
comp_func_solid_ColorDodge_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2387 |
} |
|
2388 |
||
2389 |
template <typename T> |
|
2390 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorDodge_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2391 |
{ |
|
2392 |
PRELOAD_INIT2(dest, src) |
|
2393 |
for (int i = 0; i < length; ++i) { |
|
2394 |
PRELOAD_COND2(dest, src) |
|
2395 |
uint d = dest[i]; |
|
2396 |
uint s = src[i]; |
|
2397 |
||
2398 |
int da = qAlpha(d); |
|
2399 |
int sa = qAlpha(s); |
|
2400 |
||
2401 |
#define OP(a, b) color_dodge_op(a, b, da, sa) |
|
2402 |
int r = OP( qRed(d), qRed(s)); |
|
2403 |
int b = OP( qBlue(d), qBlue(s)); |
|
2404 |
int g = OP(qGreen(d), qGreen(s)); |
|
2405 |
int a = mix_alpha(da, sa); |
|
2406 |
#undef OP |
|
2407 |
||
2408 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2409 |
} |
|
2410 |
} |
|
2411 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2412 |
void QT_FASTCALL comp_func_ColorDodge(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2413 |
{ |
2414 |
if (const_alpha == 255) |
|
2415 |
comp_func_ColorDodge_impl(dest, src, length, QFullCoverage()); |
|
2416 |
else |
|
2417 |
comp_func_ColorDodge_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2418 |
} |
|
2419 |
||
2420 |
/* |
|
2421 |
if Sca.Da + Dca.Sa <= Sa.Da |
|
2422 |
Dca' = Sca.(1 - Da) + Dca.(1 - Sa) |
|
2423 |
otherwise |
|
2424 |
Dca' = Sa.(Sca.Da + Dca.Sa - Sa.Da)/Sca + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2425 |
*/ |
|
2426 |
static inline int color_burn_op(int dst, int src, int da, int sa) |
|
2427 |
{ |
|
2428 |
const int src_da = src * da; |
|
2429 |
const int dst_sa = dst * sa; |
|
2430 |
const int sa_da = sa * da; |
|
2431 |
||
2432 |
const int temp = src * (255 - da) + dst * (255 - sa); |
|
2433 |
||
2434 |
if (src == 0 || src_da + dst_sa <= sa_da) |
|
2435 |
return qt_div_255(temp); |
|
2436 |
return qt_div_255(sa * (src_da + dst_sa - sa_da) / src + temp); |
|
2437 |
} |
|
2438 |
||
2439 |
template <typename T> |
|
2440 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(uint *dest, int length, uint color, const T &coverage) |
|
2441 |
{ |
|
2442 |
int sa = qAlpha(color); |
|
2443 |
int sr = qRed(color); |
|
2444 |
int sg = qGreen(color); |
|
2445 |
int sb = qBlue(color); |
|
2446 |
||
2447 |
PRELOAD_INIT(dest) |
|
2448 |
for (int i = 0; i < length; ++i) { |
|
2449 |
PRELOAD_COND(dest) |
|
2450 |
uint d = dest[i]; |
|
2451 |
int da = qAlpha(d); |
|
2452 |
||
2453 |
#define OP(a, b) color_burn_op(a, b, da, sa) |
|
2454 |
int r = OP( qRed(d), sr); |
|
2455 |
int b = OP( qBlue(d), sb); |
|
2456 |
int g = OP(qGreen(d), sg); |
|
2457 |
int a = mix_alpha(da, sa); |
|
2458 |
#undef OP |
|
2459 |
||
2460 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2461 |
} |
|
2462 |
} |
|
2463 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2464 |
void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha) |
0 | 2465 |
{ |
2466 |
if (const_alpha == 255) |
|
2467 |
comp_func_solid_ColorBurn_impl(dest, length, color, QFullCoverage()); |
|
2468 |
else |
|
2469 |
comp_func_solid_ColorBurn_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2470 |
} |
|
2471 |
||
2472 |
template <typename T> |
|
2473 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorBurn_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2474 |
{ |
|
2475 |
PRELOAD_INIT2(dest, src) |
|
2476 |
for (int i = 0; i < length; ++i) { |
|
2477 |
PRELOAD_COND2(dest, src) |
|
2478 |
uint d = dest[i]; |
|
2479 |
uint s = src[i]; |
|
2480 |
||
2481 |
int da = qAlpha(d); |
|
2482 |
int sa = qAlpha(s); |
|
2483 |
||
2484 |
#define OP(a, b) color_burn_op(a, b, da, sa) |
|
2485 |
int r = OP( qRed(d), qRed(s)); |
|
2486 |
int b = OP( qBlue(d), qBlue(s)); |
|
2487 |
int g = OP(qGreen(d), qGreen(s)); |
|
2488 |
int a = mix_alpha(da, sa); |
|
2489 |
#undef OP |
|
2490 |
||
2491 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2492 |
} |
|
2493 |
} |
|
2494 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2495 |
void QT_FASTCALL comp_func_ColorBurn(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2496 |
{ |
2497 |
if (const_alpha == 255) |
|
2498 |
comp_func_ColorBurn_impl(dest, src, length, QFullCoverage()); |
|
2499 |
else |
|
2500 |
comp_func_ColorBurn_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2501 |
} |
|
2502 |
||
2503 |
/* |
|
2504 |
if 2.Sca < Sa |
|
2505 |
Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2506 |
otherwise |
|
2507 |
Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2508 |
*/ |
|
2509 |
static inline uint hardlight_op(int dst, int src, int da, int sa) |
|
2510 |
{ |
|
2511 |
const uint temp = src * (255 - da) + dst * (255 - sa); |
|
2512 |
||
2513 |
if (2 * src < sa) |
|
2514 |
return qt_div_255(2 * src * dst + temp); |
|
2515 |
else |
|
2516 |
return qt_div_255(sa * da - 2 * (da - dst) * (sa - src) + temp); |
|
2517 |
} |
|
2518 |
||
2519 |
template <typename T> |
|
2520 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(uint *dest, int length, uint color, const T &coverage) |
|
2521 |
{ |
|
2522 |
int sa = qAlpha(color); |
|
2523 |
int sr = qRed(color); |
|
2524 |
int sg = qGreen(color); |
|
2525 |
int sb = qBlue(color); |
|
2526 |
||
2527 |
PRELOAD_INIT(dest) |
|
2528 |
for (int i = 0; i < length; ++i) { |
|
2529 |
PRELOAD_COND(dest) |
|
2530 |
uint d = dest[i]; |
|
2531 |
int da = qAlpha(d); |
|
2532 |
||
2533 |
#define OP(a, b) hardlight_op(a, b, da, sa) |
|
2534 |
int r = OP( qRed(d), sr); |
|
2535 |
int b = OP( qBlue(d), sb); |
|
2536 |
int g = OP(qGreen(d), sg); |
|
2537 |
int a = mix_alpha(da, sa); |
|
2538 |
#undef OP |
|
2539 |
||
2540 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2541 |
} |
|
2542 |
} |
|
2543 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2544 |
void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha) |
0 | 2545 |
{ |
2546 |
if (const_alpha == 255) |
|
2547 |
comp_func_solid_HardLight_impl(dest, length, color, QFullCoverage()); |
|
2548 |
else |
|
2549 |
comp_func_solid_HardLight_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2550 |
} |
|
2551 |
||
2552 |
template <typename T> |
|
2553 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_HardLight_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2554 |
{ |
|
2555 |
PRELOAD_INIT2(dest, src) |
|
2556 |
for (int i = 0; i < length; ++i) { |
|
2557 |
PRELOAD_COND2(dest, src) |
|
2558 |
uint d = dest[i]; |
|
2559 |
uint s = src[i]; |
|
2560 |
||
2561 |
int da = qAlpha(d); |
|
2562 |
int sa = qAlpha(s); |
|
2563 |
||
2564 |
#define OP(a, b) hardlight_op(a, b, da, sa) |
|
2565 |
int r = OP( qRed(d), qRed(s)); |
|
2566 |
int b = OP( qBlue(d), qBlue(s)); |
|
2567 |
int g = OP(qGreen(d), qGreen(s)); |
|
2568 |
int a = mix_alpha(da, sa); |
|
2569 |
#undef OP |
|
2570 |
||
2571 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2572 |
} |
|
2573 |
} |
|
2574 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2575 |
void QT_FASTCALL comp_func_HardLight(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2576 |
{ |
2577 |
if (const_alpha == 255) |
|
2578 |
comp_func_HardLight_impl(dest, src, length, QFullCoverage()); |
|
2579 |
else |
|
2580 |
comp_func_HardLight_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2581 |
} |
|
2582 |
||
2583 |
/* |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2584 |
if 2.Sca <= Sa |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2585 |
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
|
2586 |
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
|
2587 |
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
|
2588 |
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
|
2589 |
Dca' = Dca.Sa + Da.(2.Sca - Sa).((Dca/Da)^0.5 - Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa) |
0 | 2590 |
*/ |
2591 |
static inline int soft_light_op(int dst, int src, int da, int sa) |
|
2592 |
{ |
|
2593 |
const int src2 = src << 1; |
|
2594 |
const int dst_np = da != 0 ? (255 * dst) / da : 0; |
|
2595 |
const int temp = (src * (255 - da) + dst * (255 - sa)) * 255; |
|
2596 |
||
2597 |
if (src2 < sa) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2598 |
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
|
2599 |
else if (4 * dst <= da) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2600 |
return (dst * sa * 255 + da * (src2 - sa) * ((((16 * dst_np - 12 * 255) * dst_np + 3 * 65025) * dst_np) / 65025) + temp) / 65025; |
0 | 2601 |
else { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2602 |
# 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
|
2603 |
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
|
2604 |
# else |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2605 |
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
|
2606 |
# endif |
0 | 2607 |
} |
2608 |
} |
|
2609 |
||
2610 |
template <typename T> |
|
2611 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage) |
|
2612 |
{ |
|
2613 |
int sa = qAlpha(color); |
|
2614 |
int sr = qRed(color); |
|
2615 |
int sg = qGreen(color); |
|
2616 |
int sb = qBlue(color); |
|
2617 |
||
2618 |
PRELOAD_INIT(dest) |
|
2619 |
for (int i = 0; i < length; ++i) { |
|
2620 |
PRELOAD_COND(dest) |
|
2621 |
uint d = dest[i]; |
|
2622 |
int da = qAlpha(d); |
|
2623 |
||
2624 |
#define OP(a, b) soft_light_op(a, b, da, sa) |
|
2625 |
int r = OP( qRed(d), sr); |
|
2626 |
int b = OP( qBlue(d), sb); |
|
2627 |
int g = OP(qGreen(d), sg); |
|
2628 |
int a = mix_alpha(da, sa); |
|
2629 |
#undef OP |
|
2630 |
||
2631 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2632 |
} |
|
2633 |
} |
|
2634 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2635 |
void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha) |
0 | 2636 |
{ |
2637 |
if (const_alpha == 255) |
|
2638 |
comp_func_solid_SoftLight_impl(dest, length, color, QFullCoverage()); |
|
2639 |
else |
|
2640 |
comp_func_solid_SoftLight_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2641 |
} |
|
2642 |
||
2643 |
template <typename T> |
|
2644 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_SoftLight_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2645 |
{ |
|
2646 |
PRELOAD_INIT2(dest, src) |
|
2647 |
for (int i = 0; i < length; ++i) { |
|
2648 |
PRELOAD_COND2(dest, src) |
|
2649 |
uint d = dest[i]; |
|
2650 |
uint s = src[i]; |
|
2651 |
||
2652 |
int da = qAlpha(d); |
|
2653 |
int sa = qAlpha(s); |
|
2654 |
||
2655 |
#define OP(a, b) soft_light_op(a, b, da, sa) |
|
2656 |
int r = OP( qRed(d), qRed(s)); |
|
2657 |
int b = OP( qBlue(d), qBlue(s)); |
|
2658 |
int g = OP(qGreen(d), qGreen(s)); |
|
2659 |
int a = mix_alpha(da, sa); |
|
2660 |
#undef OP |
|
2661 |
||
2662 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2663 |
} |
|
2664 |
} |
|
2665 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2666 |
void QT_FASTCALL comp_func_SoftLight(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2667 |
{ |
2668 |
if (const_alpha == 255) |
|
2669 |
comp_func_SoftLight_impl(dest, src, length, QFullCoverage()); |
|
2670 |
else |
|
2671 |
comp_func_SoftLight_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2672 |
} |
|
2673 |
||
2674 |
/* |
|
2675 |
Dca' = abs(Dca.Sa - Sca.Da) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2676 |
= Sca + Dca - 2.min(Sca.Da, Dca.Sa) |
|
2677 |
*/ |
|
2678 |
static inline int difference_op(int dst, int src, int da, int sa) |
|
2679 |
{ |
|
2680 |
return src + dst - qt_div_255(2 * qMin(src * da, dst * sa)); |
|
2681 |
} |
|
2682 |
||
2683 |
template <typename T> |
|
2684 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(uint *dest, int length, uint color, const T &coverage) |
|
2685 |
{ |
|
2686 |
int sa = qAlpha(color); |
|
2687 |
int sr = qRed(color); |
|
2688 |
int sg = qGreen(color); |
|
2689 |
int sb = qBlue(color); |
|
2690 |
||
2691 |
PRELOAD_INIT(dest) |
|
2692 |
for (int i = 0; i < length; ++i) { |
|
2693 |
PRELOAD_COND(dest) |
|
2694 |
uint d = dest[i]; |
|
2695 |
int da = qAlpha(d); |
|
2696 |
||
2697 |
#define OP(a, b) difference_op(a, b, da, sa) |
|
2698 |
int r = OP( qRed(d), sr); |
|
2699 |
int b = OP( qBlue(d), sb); |
|
2700 |
int g = OP(qGreen(d), sg); |
|
2701 |
int a = mix_alpha(da, sa); |
|
2702 |
#undef OP |
|
2703 |
||
2704 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2705 |
} |
|
2706 |
} |
|
2707 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2708 |
void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha) |
0 | 2709 |
{ |
2710 |
if (const_alpha == 255) |
|
2711 |
comp_func_solid_Difference_impl(dest, length, color, QFullCoverage()); |
|
2712 |
else |
|
2713 |
comp_func_solid_Difference_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2714 |
} |
|
2715 |
||
2716 |
template <typename T> |
|
2717 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Difference_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2718 |
{ |
|
2719 |
PRELOAD_INIT2(dest, src) |
|
2720 |
for (int i = 0; i < length; ++i) { |
|
2721 |
PRELOAD_COND2(dest, src) |
|
2722 |
uint d = dest[i]; |
|
2723 |
uint s = src[i]; |
|
2724 |
||
2725 |
int da = qAlpha(d); |
|
2726 |
int sa = qAlpha(s); |
|
2727 |
||
2728 |
#define OP(a, b) difference_op(a, b, da, sa) |
|
2729 |
int r = OP( qRed(d), qRed(s)); |
|
2730 |
int b = OP( qBlue(d), qBlue(s)); |
|
2731 |
int g = OP(qGreen(d), qGreen(s)); |
|
2732 |
int a = mix_alpha(da, sa); |
|
2733 |
#undef OP |
|
2734 |
||
2735 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2736 |
} |
|
2737 |
} |
|
2738 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2739 |
void QT_FASTCALL comp_func_Difference(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2740 |
{ |
2741 |
if (const_alpha == 255) |
|
2742 |
comp_func_Difference_impl(dest, src, length, QFullCoverage()); |
|
2743 |
else |
|
2744 |
comp_func_Difference_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2745 |
} |
|
2746 |
||
2747 |
/* |
|
2748 |
Dca' = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa) |
|
2749 |
*/ |
|
2750 |
template <typename T> |
|
2751 |
Q_STATIC_TEMPLATE_FUNCTION inline void QT_FASTCALL comp_func_solid_Exclusion_impl(uint *dest, int length, uint color, const T &coverage) |
|
2752 |
{ |
|
2753 |
int sa = qAlpha(color); |
|
2754 |
int sr = qRed(color); |
|
2755 |
int sg = qGreen(color); |
|
2756 |
int sb = qBlue(color); |
|
2757 |
||
2758 |
PRELOAD_INIT(dest) |
|
2759 |
for (int i = 0; i < length; ++i) { |
|
2760 |
PRELOAD_COND(dest) |
|
2761 |
uint d = dest[i]; |
|
2762 |
int da = qAlpha(d); |
|
2763 |
||
2764 |
#define OP(a, b) (a + b - qt_div_255(2*(a*b))) |
|
2765 |
int r = OP( qRed(d), sr); |
|
2766 |
int b = OP( qBlue(d), sb); |
|
2767 |
int g = OP(qGreen(d), sg); |
|
2768 |
int a = mix_alpha(da, sa); |
|
2769 |
#undef OP |
|
2770 |
||
2771 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2772 |
} |
|
2773 |
} |
|
2774 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2775 |
void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha) |
0 | 2776 |
{ |
2777 |
if (const_alpha == 255) |
|
2778 |
comp_func_solid_Exclusion_impl(dest, length, color, QFullCoverage()); |
|
2779 |
else |
|
2780 |
comp_func_solid_Exclusion_impl(dest, length, color, QPartialCoverage(const_alpha)); |
|
2781 |
} |
|
2782 |
||
2783 |
template <typename T> |
|
2784 |
Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Exclusion_impl(uint *dest, const uint *src, int length, const T &coverage) |
|
2785 |
{ |
|
2786 |
PRELOAD_INIT2(dest, src) |
|
2787 |
for (int i = 0; i < length; ++i) { |
|
2788 |
PRELOAD_COND2(dest, src) |
|
2789 |
uint d = dest[i]; |
|
2790 |
uint s = src[i]; |
|
2791 |
||
2792 |
int da = qAlpha(d); |
|
2793 |
int sa = qAlpha(s); |
|
2794 |
||
2795 |
#define OP(a, b) (a + b - ((a*b) >> 7)) |
|
2796 |
int r = OP( qRed(d), qRed(s)); |
|
2797 |
int b = OP( qBlue(d), qBlue(s)); |
|
2798 |
int g = OP(qGreen(d), qGreen(s)); |
|
2799 |
int a = mix_alpha(da, sa); |
|
2800 |
#undef OP |
|
2801 |
||
2802 |
coverage.store(&dest[i], qRgba(r, g, b, a)); |
|
2803 |
} |
|
2804 |
} |
|
2805 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2806 |
void QT_FASTCALL comp_func_Exclusion(uint *dest, const uint *src, int length, uint const_alpha) |
0 | 2807 |
{ |
2808 |
if (const_alpha == 255) |
|
2809 |
comp_func_Exclusion_impl(dest, src, length, QFullCoverage()); |
|
2810 |
else |
|
2811 |
comp_func_Exclusion_impl(dest, src, length, QPartialCoverage(const_alpha)); |
|
2812 |
} |
|
2813 |
||
2814 |
#if defined(Q_CC_RVCT) |
|
2815 |
// Restore pragma state from previous #pragma arm |
|
2816 |
# pragma pop |
|
2817 |
#endif |
|
2818 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2819 |
void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2820 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2821 |
uint color, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2822 |
uint const_alpha) |
0 | 2823 |
{ |
2824 |
Q_UNUSED(const_alpha); |
|
2825 |
while (length--) |
|
2826 |
*dest++ |= color; |
|
2827 |
} |
|
2828 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2829 |
void QT_FASTCALL rasterop_SourceOrDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2830 |
const uint *src, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2831 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2832 |
uint const_alpha) |
0 | 2833 |
{ |
2834 |
Q_UNUSED(const_alpha); |
|
2835 |
while (length--) |
|
2836 |
*dest++ |= *src++; |
|
2837 |
} |
|
2838 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2839 |
void QT_FASTCALL rasterop_solid_SourceAndDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2840 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2841 |
uint color, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2842 |
uint const_alpha) |
0 | 2843 |
{ |
2844 |
Q_UNUSED(const_alpha); |
|
2845 |
color |= 0xff000000; |
|
2846 |
while (length--) |
|
2847 |
*dest++ &= color; |
|
2848 |
} |
|
2849 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2850 |
void QT_FASTCALL rasterop_SourceAndDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2851 |
const uint *src, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2852 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2853 |
uint const_alpha) |
0 | 2854 |
{ |
2855 |
Q_UNUSED(const_alpha); |
|
2856 |
while (length--) { |
|
2857 |
*dest = (*src & *dest) | 0xff000000; |
|
2858 |
++dest; ++src; |
|
2859 |
} |
|
2860 |
} |
|
2861 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2862 |
void QT_FASTCALL rasterop_solid_SourceXorDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2863 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2864 |
uint color, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2865 |
uint const_alpha) |
0 | 2866 |
{ |
2867 |
Q_UNUSED(const_alpha); |
|
2868 |
color &= 0x00ffffff; |
|
2869 |
while (length--) |
|
2870 |
*dest++ ^= color; |
|
2871 |
} |
|
2872 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2873 |
void QT_FASTCALL rasterop_SourceXorDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2874 |
const uint *src, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2875 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2876 |
uint const_alpha) |
0 | 2877 |
{ |
2878 |
Q_UNUSED(const_alpha); |
|
2879 |
while (length--) { |
|
2880 |
*dest = (*src ^ *dest) | 0xff000000; |
|
2881 |
++dest; ++src; |
|
2882 |
} |
|
2883 |
} |
|
2884 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2885 |
void QT_FASTCALL rasterop_solid_NotSourceAndNotDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2886 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2887 |
uint color, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2888 |
uint const_alpha) |
0 | 2889 |
{ |
2890 |
Q_UNUSED(const_alpha); |
|
2891 |
color = ~color; |
|
2892 |
while (length--) { |
|
2893 |
*dest = (color & ~(*dest)) | 0xff000000; |
|
2894 |
++dest; |
|
2895 |
} |
|
2896 |
} |
|
2897 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2898 |
void QT_FASTCALL rasterop_NotSourceAndNotDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2899 |
const uint *src, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2900 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2901 |
uint const_alpha) |
0 | 2902 |
{ |
2903 |
Q_UNUSED(const_alpha); |
|
2904 |
while (length--) { |
|
2905 |
*dest = (~(*src) & ~(*dest)) | 0xff000000; |
|
2906 |
++dest; ++src; |
|
2907 |
} |
|
2908 |
} |
|
2909 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2910 |
void QT_FASTCALL rasterop_solid_NotSourceOrNotDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2911 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2912 |
uint color, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2913 |
uint const_alpha) |
0 | 2914 |
{ |
2915 |
Q_UNUSED(const_alpha); |
|
2916 |
color = ~color | 0xff000000; |
|
2917 |
while (length--) { |
|
2918 |
*dest = color | ~(*dest); |
|
2919 |
++dest; |
|
2920 |
} |
|
2921 |
} |
|
2922 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2923 |
void QT_FASTCALL rasterop_NotSourceOrNotDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2924 |
const uint *src, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2925 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2926 |
uint const_alpha) |
0 | 2927 |
{ |
2928 |
Q_UNUSED(const_alpha); |
|
2929 |
while (length--) { |
|
2930 |
*dest = ~(*src) | ~(*dest) | 0xff000000; |
|
2931 |
++dest; ++src; |
|
2932 |
} |
|
2933 |
} |
|
2934 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2935 |
void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2936 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2937 |
uint color, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2938 |
uint const_alpha) |
0 | 2939 |
{ |
2940 |
Q_UNUSED(const_alpha); |
|
2941 |
color = ~color & 0x00ffffff; |
|
2942 |
while (length--) { |
|
2943 |
*dest = color ^ (*dest); |
|
2944 |
++dest; |
|
2945 |
} |
|
2946 |
} |
|
2947 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2948 |
void QT_FASTCALL rasterop_NotSourceXorDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2949 |
const uint *src, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2950 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2951 |
uint const_alpha) |
0 | 2952 |
{ |
2953 |
Q_UNUSED(const_alpha); |
|
2954 |
while (length--) { |
|
2955 |
*dest = ((~(*src)) ^ (*dest)) | 0xff000000; |
|
2956 |
++dest; ++src; |
|
2957 |
} |
|
2958 |
} |
|
2959 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2960 |
void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2961 |
uint color, uint const_alpha) |
0 | 2962 |
{ |
2963 |
Q_UNUSED(const_alpha); |
|
2964 |
qt_memfill(dest, ~color | 0xff000000, length); |
|
2965 |
} |
|
2966 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2967 |
void QT_FASTCALL rasterop_NotSource(uint *dest, const uint *src, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2968 |
int length, uint const_alpha) |
0 | 2969 |
{ |
2970 |
Q_UNUSED(const_alpha); |
|
2971 |
while (length--) |
|
2972 |
*dest++ = ~(*src++) | 0xff000000; |
|
2973 |
} |
|
2974 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2975 |
void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2976 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2977 |
uint color, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2978 |
uint const_alpha) |
0 | 2979 |
{ |
2980 |
Q_UNUSED(const_alpha); |
|
2981 |
color = ~color | 0xff000000; |
|
2982 |
while (length--) { |
|
2983 |
*dest = color & *dest; |
|
2984 |
++dest; |
|
2985 |
} |
|
2986 |
} |
|
2987 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2988 |
void QT_FASTCALL rasterop_NotSourceAndDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2989 |
const uint *src, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2990 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2991 |
uint const_alpha) |
0 | 2992 |
{ |
2993 |
Q_UNUSED(const_alpha); |
|
2994 |
while (length--) { |
|
2995 |
*dest = (~(*src) & *dest) | 0xff000000; |
|
2996 |
++dest; ++src; |
|
2997 |
} |
|
2998 |
} |
|
2999 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3000 |
void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3001 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3002 |
uint color, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3003 |
uint const_alpha) |
0 | 3004 |
{ |
3005 |
Q_UNUSED(const_alpha); |
|
3006 |
while (length--) { |
|
3007 |
*dest = (color & ~(*dest)) | 0xff000000; |
|
3008 |
++dest; |
|
3009 |
} |
|
3010 |
} |
|
3011 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3012 |
void QT_FASTCALL rasterop_SourceAndNotDestination(uint *dest, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3013 |
const uint *src, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3014 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
3015 |
uint const_alpha) |
0 | 3016 |
{ |
3017 |
Q_UNUSED(const_alpha); |
|
3018 |
while (length--) { |
|
3019 |
*dest = (*src & ~(*dest)) | 0xff000000; |
|
3020 |
++dest; ++src; |
|
3021 |
} |
|
3022 |
} |
|
3023 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3024 |
static CompositionFunctionSolid functionForModeSolid_C[] = { |
0 | 3025 |
comp_func_solid_SourceOver, |
3026 |
comp_func_solid_DestinationOver, |
|
3027 |
comp_func_solid_Clear, |
|
3028 |
comp_func_solid_Source, |
|
3029 |
comp_func_solid_Destination, |
|
3030 |
comp_func_solid_SourceIn, |
|
3031 |
comp_func_solid_DestinationIn, |
|
3032 |
comp_func_solid_SourceOut, |
|
3033 |
comp_func_solid_DestinationOut, |
|
3034 |
comp_func_solid_SourceAtop, |
|
3035 |
comp_func_solid_DestinationAtop, |
|
3036 |
comp_func_solid_XOR, |
|
3037 |
comp_func_solid_Plus, |
|
3038 |
comp_func_solid_Multiply, |
|
3039 |
comp_func_solid_Screen, |
|
3040 |
comp_func_solid_Overlay, |
|
3041 |
comp_func_solid_Darken, |
|
3042 |
comp_func_solid_Lighten, |
|
3043 |
comp_func_solid_ColorDodge, |
|
3044 |
comp_func_solid_ColorBurn, |
|
3045 |
comp_func_solid_HardLight, |
|
3046 |
comp_func_solid_SoftLight, |
|
3047 |
comp_func_solid_Difference, |
|
3048 |
comp_func_solid_Exclusion, |
|
3049 |
rasterop_solid_SourceOrDestination, |
|
3050 |
rasterop_solid_SourceAndDestination, |
|
3051 |
rasterop_solid_SourceXorDestination, |
|
3052 |
rasterop_solid_NotSourceAndNotDestination, |
|
3053 |
rasterop_solid_NotSourceOrNotDestination, |
|
3054 |
rasterop_solid_NotSourceXorDestination, |
|
3055 |
rasterop_solid_NotSource, |
|
3056 |
rasterop_solid_NotSourceAndDestination, |
|
3057 |
rasterop_solid_SourceAndNotDestination |
|
3058 |
}; |
|
3059 |
||
3060 |
static const CompositionFunctionSolid *functionForModeSolid = functionForModeSolid_C; |
|
3061 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3062 |
static CompositionFunction functionForMode_C[] = { |
0 | 3063 |
comp_func_SourceOver, |
3064 |
comp_func_DestinationOver, |
|
3065 |
comp_func_Clear, |
|
3066 |
comp_func_Source, |
|
3067 |
comp_func_Destination, |
|
3068 |
comp_func_SourceIn, |
|
3069 |
comp_func_DestinationIn, |
|
3070 |
comp_func_SourceOut, |
|
3071 |
comp_func_DestinationOut, |
|
3072 |
comp_func_SourceAtop, |
|
3073 |
comp_func_DestinationAtop, |
|
3074 |
comp_func_XOR, |
|
3075 |
comp_func_Plus, |
|
3076 |
comp_func_Multiply, |
|
3077 |
comp_func_Screen, |
|
3078 |
comp_func_Overlay, |
|
3079 |
comp_func_Darken, |
|
3080 |
comp_func_Lighten, |
|
3081 |
comp_func_ColorDodge, |
|
3082 |
comp_func_ColorBurn, |
|
3083 |
comp_func_HardLight, |
|
3084 |
comp_func_SoftLight, |
|
3085 |
comp_func_Difference, |
|
3086 |
comp_func_Exclusion, |
|
3087 |
rasterop_SourceOrDestination, |
|
3088 |
rasterop_SourceAndDestination, |
|
3089 |
rasterop_SourceXorDestination, |
|
3090 |
rasterop_NotSourceAndNotDestination, |
|
3091 |
rasterop_NotSourceOrNotDestination, |
|
3092 |
rasterop_NotSourceXorDestination, |
|
3093 |
rasterop_NotSource, |
|
3094 |
rasterop_NotSourceAndDestination, |
|
3095 |
rasterop_SourceAndNotDestination |
|
3096 |
}; |
|
3097 |
||
3098 |
static const CompositionFunction *functionForMode = functionForMode_C; |
|
3099 |
||
3100 |
static TextureBlendType getBlendType(const QSpanData *data) |
|
3101 |
{ |
|
3102 |
TextureBlendType ft; |
|
3103 |
if (data->txop <= QTransform::TxTranslate) |
|
3104 |
if (data->texture.type == QTextureData::Tiled) |
|
3105 |
ft = BlendTiled; |
|
3106 |
else |
|
3107 |
ft = BlendUntransformed; |
|
3108 |
else if (data->bilinear) |
|
3109 |
if (data->texture.type == QTextureData::Tiled) |
|
3110 |
ft = BlendTransformedBilinearTiled; |
|
3111 |
else |
|
3112 |
ft = BlendTransformedBilinear; |
|
3113 |
else |
|
3114 |
if (data->texture.type == QTextureData::Tiled) |
|
3115 |
ft = BlendTransformedTiled; |
|
3116 |
else |
|
3117 |
ft = BlendTransformed; |
|
3118 |
return ft; |
|
3119 |
} |
|
3120 |
||
3121 |
static inline Operator getOperator(const QSpanData *data, const QSpan *spans, int spanCount) |
|
3122 |
{ |
|
3123 |
Operator op; |
|
3124 |
bool solidSource = false; |
|
3125 |
||
3126 |
switch(data->type) { |
|
3127 |
case QSpanData::Solid: |
|
3128 |
solidSource = (qAlpha(data->solid.color) == 255); |
|
3129 |
break; |
|
3130 |
case QSpanData::LinearGradient: |
|
3131 |
solidSource = !data->gradient.alphaColor; |
|
3132 |
getLinearGradientValues(&op.linear, data); |
|
3133 |
op.src_fetch = fetchLinearGradient; |
|
3134 |
break; |
|
3135 |
case QSpanData::RadialGradient: |
|
3136 |
solidSource = !data->gradient.alphaColor; |
|
3137 |
getRadialGradientValues(&op.radial, data); |
|
3138 |
op.src_fetch = fetchRadialGradient; |
|
3139 |
break; |
|
3140 |
case QSpanData::ConicalGradient: |
|
3141 |
solidSource = !data->gradient.alphaColor; |
|
3142 |
op.src_fetch = fetchConicalGradient; |
|
3143 |
break; |
|
3144 |
case QSpanData::Texture: |
|
3145 |
op.src_fetch = sourceFetch[getBlendType(data)][data->texture.format]; |
|
3146 |
solidSource = !data->texture.hasAlpha; |
|
3147 |
default: |
|
3148 |
break; |
|
3149 |
} |
|
3150 |
||
3151 |
op.mode = data->rasterBuffer->compositionMode; |
|
3152 |
if (op.mode == QPainter::CompositionMode_SourceOver && solidSource) |
|
3153 |
op.mode = QPainter::CompositionMode_Source; |
|
3154 |
||
3155 |
op.dest_fetch = destFetchProc[data->rasterBuffer->format]; |
|
3156 |
if (op.mode == QPainter::CompositionMode_Source) { |
|
3157 |
switch (data->rasterBuffer->format) { |
|
3158 |
case QImage::Format_RGB32: |
|
3159 |
case QImage::Format_ARGB32_Premultiplied: |
|
3160 |
// don't clear dest_fetch as it sets up the pointer correctly to save one copy |
|
3161 |
break; |
|
3162 |
default: { |
|
3163 |
const QSpan *lastSpan = spans + spanCount; |
|
3164 |
bool alphaSpans = false; |
|
3165 |
while (spans < lastSpan) { |
|
3166 |
if (spans->coverage != 255) { |
|
3167 |
alphaSpans = true; |
|
3168 |
break; |
|
3169 |
} |
|
3170 |
++spans; |
|
3171 |
} |
|
3172 |
if (!alphaSpans) |
|
3173 |
op.dest_fetch = 0; |
|
3174 |
} |
|
3175 |
} |
|
3176 |
} |
|
3177 |
||
3178 |
op.dest_store = destStoreProc[data->rasterBuffer->format]; |
|
3179 |
||
3180 |
op.funcSolid = functionForModeSolid[op.mode]; |
|
3181 |
op.func = functionForMode[op.mode]; |
|
3182 |
||
3183 |
return op; |
|
3184 |
} |
|
3185 |
||
3186 |
||
3187 |
||
3188 |
// -------------------- blend methods --------------------- |
|
3189 |
||
3190 |
enum SpanMethod { |
|
3191 |
RegularSpans, |
|
3192 |
CallbackSpans |
|
3193 |
}; |
|
3194 |
||
3195 |
#if !defined(Q_CC_SUN) |
|
3196 |
static |
|
3197 |
#endif |
|
3198 |
void drawBufferSpan(QSpanData *data, const uint *buffer, int bufsize, |
|
3199 |
int x, int y, int length, uint const_alpha) |
|
3200 |
{ |
|
3201 |
#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS) |
|
3202 |
data->rasterEngine->drawBufferSpan(buffer, bufsize, x, y, length, const_alpha); |
|
3203 |
#else |
|
3204 |
Q_UNUSED(data); |
|
3205 |
Q_UNUSED(buffer); |
|
3206 |
Q_UNUSED(bufsize); |
|
3207 |
Q_UNUSED(x); |
|
3208 |
Q_UNUSED(y); |
|
3209 |
Q_UNUSED(length); |
|
3210 |
Q_UNUSED(const_alpha); |
|
3211 |
#endif |
|
3212 |
} |
|
3213 |
||
3214 |
#if !defined(Q_CC_SUN) |
|
3215 |
static |
|
3216 |
#endif |
|
3217 |
void blend_color_generic(int count, const QSpan *spans, void *userData) |
|
3218 |
{ |
|
3219 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3220 |
uint buffer[buffer_size]; |
|
3221 |
Operator op = getOperator(data, spans, count); |
|
3222 |
||
3223 |
while (count--) { |
|
3224 |
int x = spans->x; |
|
3225 |
int length = spans->len; |
|
3226 |
while (length) { |
|
3227 |
int l = qMin(buffer_size, length); |
|
3228 |
uint *dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer; |
|
3229 |
op.funcSolid(dest, l, data->solid.color, spans->coverage); |
|
3230 |
if (op.dest_store) |
|
3231 |
op.dest_store(data->rasterBuffer, x, spans->y, dest, l); |
|
3232 |
length -= l; |
|
3233 |
x += l; |
|
3234 |
} |
|
3235 |
++spans; |
|
3236 |
} |
|
3237 |
} |
|
3238 |
||
3239 |
#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS) |
|
3240 |
static void blend_color_generic_callback(int count, const QSpan *spans, void *userData) |
|
3241 |
{ |
|
3242 |
// ### Falcon |
|
3243 |
Q_UNUSED(count); |
|
3244 |
Q_UNUSED(spans); |
|
3245 |
Q_UNUSED(userData); |
|
3246 |
// QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
3247 |
// data->rasterEngine->drawColorSpans(spans, count, data->solid.color); |
|
3248 |
} |
|
3249 |
#endif // QT_NO_RASTERCALLBACKS |
|
3250 |
||
3251 |
static void blend_color_argb(int count, const QSpan *spans, void *userData) |
|
3252 |
{ |
|
3253 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3254 |
||
3255 |
Operator op = getOperator(data, spans, count); |
|
3256 |
||
3257 |
if (op.mode == QPainter::CompositionMode_Source) { |
|
3258 |
// inline for performance |
|
3259 |
while (count--) { |
|
3260 |
uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
3261 |
if (spans->coverage == 255) { |
|
3262 |
QT_MEMFILL_UINT(target, spans->len, data->solid.color); |
|
3263 |
} else { |
|
3264 |
uint c = BYTE_MUL(data->solid.color, spans->coverage); |
|
3265 |
int ialpha = 255 - spans->coverage; |
|
3266 |
for (int i = 0; i < spans->len; ++i) |
|
3267 |
target[i] = c + BYTE_MUL(target[i], ialpha); |
|
3268 |
} |
|
3269 |
++spans; |
|
3270 |
} |
|
3271 |
return; |
|
3272 |
} |
|
3273 |
||
3274 |
while (count--) { |
|
3275 |
uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
3276 |
op.funcSolid(target, spans->len, data->solid.color, spans->coverage); |
|
3277 |
++spans; |
|
3278 |
} |
|
3279 |
} |
|
3280 |
||
3281 |
template <class T> |
|
3282 |
Q_STATIC_TEMPLATE_FUNCTION void blendColor(int count, const QSpan *spans, void *userData) |
|
3283 |
{ |
|
3284 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3285 |
Operator op = getOperator(data, spans, count); |
|
3286 |
||
3287 |
if (op.mode == QPainter::CompositionMode_Source) { |
|
3288 |
const T c = qt_colorConvert<T, quint32p>(quint32p::fromRawData(data->solid.color), 0); |
|
3289 |
while (count--) { |
|
3290 |
T *target = ((T*)data->rasterBuffer->scanLine(spans->y)) |
|
3291 |
+ spans->x; |
|
3292 |
if (spans->coverage == 255) { |
|
3293 |
qt_memfill(target, c, spans->len); |
|
3294 |
} else { |
|
3295 |
const quint8 alpha = T::alpha(spans->coverage); |
|
3296 |
const T color = c.byte_mul(alpha); |
|
3297 |
const int ialpha = T::ialpha(spans->coverage); |
|
3298 |
const T *end = target + spans->len; |
|
3299 |
while (target < end) { |
|
3300 |
*target = color + target->byte_mul(ialpha); |
|
3301 |
++target; |
|
3302 |
} |
|
3303 |
} |
|
3304 |
++spans; |
|
3305 |
} |
|
3306 |
return; |
|
3307 |
} |
|
3308 |
||
3309 |
if (op.mode == QPainter::CompositionMode_SourceOver) { |
|
3310 |
while (count--) { |
|
3311 |
const quint32 color = BYTE_MUL(data->solid.color, spans->coverage); |
|
3312 |
const T c = qt_colorConvert<T, quint32p>(quint32p::fromRawData(color), 0); |
|
3313 |
const quint8 ialpha = T::alpha(qAlpha(~color)); |
|
3314 |
T *target = ((T*)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
3315 |
const T *end = target + spans->len; |
|
3316 |
while (target != end) { |
|
3317 |
*target = c + target->byte_mul(ialpha); |
|
3318 |
++target; |
|
3319 |
} |
|
3320 |
++spans; |
|
3321 |
} |
|
3322 |
return; |
|
3323 |
} |
|
3324 |
||
3325 |
blend_color_generic(count, spans, userData); |
|
3326 |
} |
|
3327 |
||
3328 |
#define SPANFUNC_POINTER_BLENDCOLOR(DST) blendColor<DST> |
|
3329 |
||
3330 |
static void blend_color_rgb16(int count, const QSpan *spans, void *userData) |
|
3331 |
{ |
|
3332 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3333 |
||
3334 |
/* |
|
3335 |
We duplicate a little logic from getOperator() and calculate the |
|
3336 |
composition mode directly. This allows blend_color_rgb16 to be used |
|
3337 |
from qt_gradient_quint16 with minimal overhead. |
|
3338 |
*/ |
|
3339 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
3340 |
if (mode == QPainter::CompositionMode_SourceOver && |
|
3341 |
qAlpha(data->solid.color) == 255) |
|
3342 |
mode = QPainter::CompositionMode_Source; |
|
3343 |
||
3344 |
if (mode == QPainter::CompositionMode_Source) { |
|
3345 |
// inline for performance |
|
3346 |
ushort c = qConvertRgb32To16(data->solid.color); |
|
3347 |
while (count--) { |
|
3348 |
ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
3349 |
if (spans->coverage == 255) { |
|
3350 |
QT_MEMFILL_USHORT(target, spans->len, c); |
|
3351 |
} else { |
|
3352 |
ushort color = BYTE_MUL_RGB16(c, spans->coverage); |
|
3353 |
int ialpha = 255 - spans->coverage; |
|
3354 |
const ushort *end = target + spans->len; |
|
3355 |
while (target < end) { |
|
3356 |
*target = color + BYTE_MUL_RGB16(*target, ialpha); |
|
3357 |
++target; |
|
3358 |
} |
|
3359 |
} |
|
3360 |
++spans; |
|
3361 |
} |
|
3362 |
return; |
|
3363 |
} |
|
3364 |
||
3365 |
if (mode == QPainter::CompositionMode_SourceOver) { |
|
3366 |
while (count--) { |
|
3367 |
uint color = BYTE_MUL(data->solid.color, spans->coverage); |
|
3368 |
int ialpha = qAlpha(~color); |
|
3369 |
ushort c = qConvertRgb32To16(color); |
|
3370 |
ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
3371 |
int len = spans->len; |
|
3372 |
bool pre = (((quintptr)target) & 0x3) != 0; |
|
3373 |
bool post = false; |
|
3374 |
if (pre) { |
|
3375 |
// skip to word boundary |
|
3376 |
*target = c + BYTE_MUL_RGB16(*target, ialpha); |
|
3377 |
++target; |
|
3378 |
--len; |
|
3379 |
} |
|
3380 |
if (len & 0x1) { |
|
3381 |
post = true; |
|
3382 |
--len; |
|
3383 |
} |
|
3384 |
uint *target32 = (uint*)target; |
|
3385 |
uint c32 = c | (c<<16); |
|
3386 |
len >>= 1; |
|
3387 |
uint salpha = (ialpha+1) >> 3; // calculate here rather than in loop |
|
3388 |
while (len--) { |
|
3389 |
// blend full words |
|
3390 |
*target32 = c32 + BYTE_MUL_RGB16_32(*target32, salpha); |
|
3391 |
++target32; |
|
3392 |
target += 2; |
|
3393 |
} |
|
3394 |
if (post) { |
|
3395 |
// one last pixel beyond a full word |
|
3396 |
*target = c + BYTE_MUL_RGB16(*target, ialpha); |
|
3397 |
} |
|
3398 |
++spans; |
|
3399 |
} |
|
3400 |
return; |
|
3401 |
} |
|
3402 |
||
3403 |
blend_color_generic(count, spans, userData); |
|
3404 |
} |
|
3405 |
||
3406 |
template <typename T> |
|
3407 |
void handleSpans(int count, const QSpan *spans, const QSpanData *data, T &handler) |
|
3408 |
{ |
|
3409 |
uint const_alpha = 256; |
|
3410 |
if (data->type == QSpanData::Texture) |
|
3411 |
const_alpha = data->texture.const_alpha; |
|
3412 |
||
3413 |
int coverage = 0; |
|
3414 |
while (count) { |
|
3415 |
int x = spans->x; |
|
3416 |
const int y = spans->y; |
|
3417 |
int right = x + spans->len; |
|
3418 |
||
3419 |
// compute length of adjacent spans |
|
3420 |
for (int i = 1; i < count && spans[i].y == y && spans[i].x == right; ++i) |
|
3421 |
right += spans[i].len; |
|
3422 |
int length = right - x; |
|
3423 |
||
3424 |
while (length) { |
|
3425 |
int l = qMin(buffer_size, length); |
|
3426 |
length -= l; |
|
3427 |
||
3428 |
int process_length = l; |
|
3429 |
int process_x = x; |
|
3430 |
||
3431 |
const uint *src = handler.fetch(process_x, y, process_length); |
|
3432 |
int offset = 0; |
|
3433 |
while (l > 0) { |
|
3434 |
if (x == spans->x) // new span? |
|
3435 |
coverage = (spans->coverage * const_alpha) >> 8; |
|
3436 |
||
3437 |
int right = spans->x + spans->len; |
|
3438 |
int len = qMin(l, right - x); |
|
3439 |
||
3440 |
handler.process(x, y, len, coverage, src, offset); |
|
3441 |
||
3442 |
l -= len; |
|
3443 |
x += len; |
|
3444 |
offset += len; |
|
3445 |
||
3446 |
if (x == right) { // done with current span? |
|
3447 |
++spans; |
|
3448 |
--count; |
|
3449 |
} |
|
3450 |
} |
|
3451 |
handler.store(process_x, y, process_length); |
|
3452 |
} |
|
3453 |
} |
|
3454 |
} |
|
3455 |
||
3456 |
struct QBlendBase |
|
3457 |
{ |
|
3458 |
QBlendBase(QSpanData *d, Operator o) |
|
3459 |
: data(d) |
|
3460 |
, op(o) |
|
3461 |
, dest(0) |
|
3462 |
{ |
|
3463 |
} |
|
3464 |
||
3465 |
QSpanData *data; |
|
3466 |
Operator op; |
|
3467 |
||
3468 |
uint *dest; |
|
3469 |
||
3470 |
uint buffer[buffer_size]; |
|
3471 |
uint src_buffer[buffer_size]; |
|
3472 |
}; |
|
3473 |
||
3474 |
template <SpanMethod spanMethod> |
|
3475 |
class BlendSrcGeneric : public QBlendBase |
|
3476 |
{ |
|
3477 |
public: |
|
3478 |
BlendSrcGeneric(QSpanData *d, Operator o) |
|
3479 |
: QBlendBase(d, o) |
|
3480 |
{ |
|
3481 |
} |
|
3482 |
||
3483 |
const uint *fetch(int x, int y, int len) |
|
3484 |
{ |
|
3485 |
if (spanMethod == RegularSpans) |
|
3486 |
dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, y, len) : buffer; |
|
3487 |
||
3488 |
return op.src_fetch(src_buffer, &op, data, y, x, len); |
|
3489 |
} |
|
3490 |
||
3491 |
void process(int x, int y, int len, int coverage, const uint *src, int offset) |
|
3492 |
{ |
|
3493 |
if (spanMethod == RegularSpans) |
|
3494 |
op.func(dest + offset, src + offset, len, coverage); |
|
3495 |
else |
|
3496 |
drawBufferSpan(data, src + offset, len, x, y, len, coverage); |
|
3497 |
} |
|
3498 |
||
3499 |
void store(int x, int y, int len) |
|
3500 |
{ |
|
3501 |
if (spanMethod == RegularSpans && op.dest_store) { |
|
3502 |
op.dest_store(data->rasterBuffer, x, y, dest, len); |
|
3503 |
} |
|
3504 |
} |
|
3505 |
}; |
|
3506 |
||
3507 |
template <SpanMethod spanMethod> |
|
3508 |
Q_STATIC_TEMPLATE_FUNCTION void blend_src_generic(int count, const QSpan *spans, void *userData) |
|
3509 |
{ |
|
3510 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3511 |
BlendSrcGeneric<spanMethod> blend(data, getOperator(data, spans, count)); |
|
3512 |
handleSpans(count, spans, data, blend); |
|
3513 |
} |
|
3514 |
||
3515 |
template <SpanMethod spanMethod> |
|
3516 |
Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_generic(int count, const QSpan *spans, void *userData) |
|
3517 |
{ |
|
3518 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3519 |
||
3520 |
uint buffer[buffer_size]; |
|
3521 |
uint src_buffer[buffer_size]; |
|
3522 |
Operator op = getOperator(data, spans, count); |
|
3523 |
||
3524 |
const int image_width = data->texture.width; |
|
3525 |
const int image_height = data->texture.height; |
|
3526 |
int xoff = -qRound(-data->dx); |
|
3527 |
int yoff = -qRound(-data->dy); |
|
3528 |
||
3529 |
while (count--) { |
|
3530 |
int x = spans->x; |
|
3531 |
int length = spans->len; |
|
3532 |
int sx = xoff + x; |
|
3533 |
int sy = yoff + spans->y; |
|
3534 |
if (sy >= 0 && sy < image_height && sx < image_width) { |
|
3535 |
if (sx < 0) { |
|
3536 |
x -= sx; |
|
3537 |
length += sx; |
|
3538 |
sx = 0; |
|
3539 |
} |
|
3540 |
if (sx + length > image_width) |
|
3541 |
length = image_width - sx; |
|
3542 |
if (length > 0) { |
|
3543 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
3544 |
while (length) { |
|
3545 |
int l = qMin(buffer_size, length); |
|
3546 |
const uint *src = op.src_fetch(src_buffer, &op, data, sy, sx, l); |
|
3547 |
if (spanMethod == RegularSpans) { |
|
3548 |
uint *dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer; |
|
3549 |
op.func(dest, src, l, coverage); |
|
3550 |
if (op.dest_store) |
|
3551 |
op.dest_store(data->rasterBuffer, x, spans->y, dest, l); |
|
3552 |
} else { |
|
3553 |
drawBufferSpan(data, src, l, x, spans->y, |
|
3554 |
l, coverage); |
|
3555 |
} |
|
3556 |
x += l; |
|
3557 |
sx += l; |
|
3558 |
length -= l; |
|
3559 |
} |
|
3560 |
} |
|
3561 |
} |
|
3562 |
++spans; |
|
3563 |
} |
|
3564 |
} |
|
3565 |
||
3566 |
template <SpanMethod spanMethod> |
|
3567 |
Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_argb(int count, const QSpan *spans, void *userData) |
|
3568 |
{ |
|
3569 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
3570 |
if (data->texture.format != QImage::Format_ARGB32_Premultiplied |
|
3571 |
&& data->texture.format != QImage::Format_RGB32) { |
|
3572 |
blend_untransformed_generic<spanMethod>(count, spans, userData); |
|
3573 |
return; |
|
3574 |
} |
|
3575 |
||
3576 |
Operator op = getOperator(data, spans, count); |
|
3577 |
||
3578 |
const int image_width = data->texture.width; |
|
3579 |
const int image_height = data->texture.height; |
|
3580 |
int xoff = -qRound(-data->dx); |
|
3581 |
int yoff = -qRound(-data->dy); |
|
3582 |
||
3583 |
while (count--) { |
|
3584 |
int x = spans->x; |
|
3585 |
int length = spans->len; |
|
3586 |
int sx = xoff + x; |
|
3587 |
int sy = yoff + spans->y; |
|
3588 |
if (sy >= 0 && sy < image_height && sx < image_width) { |
|
3589 |
if (sx < 0) { |
|
3590 |
x -= sx; |
|
3591 |
length += sx; |
|
3592 |
sx = 0; |
|
3593 |
} |
|
3594 |
if (sx + length > image_width) |
|
3595 |
length = image_width - sx; |
|
3596 |
if (length > 0) { |
|
3597 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
3598 |
const uint *src = (uint *)data->texture.scanLine(sy) + sx; |
|
3599 |
if (spanMethod == RegularSpans) { |
|
3600 |
uint *dest = ((uint *)data->rasterBuffer->scanLine(spans->y)) + x; |
|
3601 |
op.func(dest, src, length, coverage); |
|
3602 |
} else { |
|
3603 |
drawBufferSpan(data, src, length, x, |
|
3604 |
spans->y, length, coverage); |
|
3605 |
} |
|
3606 |
} |
|
3607 |
} |
|
3608 |
++spans; |
|
3609 |
} |
|
3610 |
} |
|
3611 |
||
3612 |
static inline quint16 interpolate_pixel_rgb16_255(quint16 x, quint8 a, |
|
3613 |
quint16 y, quint8 b) |
|
3614 |
{ |
|
3615 |
quint16 t = ((((x & 0x07e0) * a) + ((y & 0x07e0) * b)) >> 5) & 0x07e0; |
|
3616 |
t |= ((((x & 0xf81f) * a) + ((y & 0xf81f) * b)) >> 5) & 0xf81f; |
|
3617 |
||
3618 |
return t; |
|
3619 |
} |
|
3620 |
||
3621 |
static inline quint32 interpolate_pixel_rgb16x2_255(quint32 x, quint8 a, |
|
3622 |
quint32 y, quint8 b) |
|
3623 |
{ |
|
3624 |
uint t; |
|
3625 |
t = ((((x & 0xf81f07e0) >> 5) * a) + (((y & 0xf81f07e0) >> 5) * b)) & 0xf81f07e0; |
|
3626 |
t |= ((((x & 0x07e0f81f) * a) + ((y & 0x07e0f81f) * b)) >> 5) & 0x07e0f81f; |
|
3627 |
return t; |
|
3628 |
} |
|
3629 |
||
3630 |
static inline void blend_sourceOver_rgb16_rgb16(quint16 *dest, |
|
3631 |
const quint16 *src, |
|
3632 |
int length, |
|
3633 |
const quint8 alpha, |
|
3634 |
const quint8 ialpha) |
|
3635 |
{ |
|
3636 |
const int dstAlign = ((quintptr)dest) & 0x3; |
|
3637 |
if (dstAlign) { |
|
3638 |
*dest = interpolate_pixel_rgb16_255(*src, alpha, *dest, ialpha); |
|
3639 |
++dest; |
|
3640 |
++src; |
|
3641 |
--length; |
|
3642 |
} |
|
3643 |
const int srcAlign = ((quintptr)src) & 0x3; |
|
3644 |
int length32 = length >> 1; |
|
3645 |
if (length32 && srcAlign == 0) { |
|
3646 |
while (length32--) { |
|
3647 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
3648 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
3649 |
*dest32 = interpolate_pixel_rgb16x2_255(*src32, alpha, |
|
3650 |
*dest32, ialpha); |
|
3651 |
dest += 2; |
|
3652 |
src += 2; |
|
3653 |
} |
|
3654 |
length &= 0x1; |
|
3655 |
} |
|
3656 |
while (length--) { |
|
3657 |
*dest = interpolate_pixel_rgb16_255(*src, alpha, *dest, ialpha); |
|
3658 |
++dest; |
|
3659 |
++src; |
|
3660 |
} |
|
3661 |
} |
|
3662 |
||
3663 |
template <class DST, class SRC> |
|
3664 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3665 |
inline void madd_2(DST *dest, const quint16 alpha, const SRC *src) |
|
3666 |
{ |
|
3667 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
|
3668 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3669 |
dest[0] = dest[0].byte_mul(alpha >> 8) + DST(src[0]); |
|
3670 |
dest[1] = dest[1].byte_mul(alpha & 0xff) + DST(src[1]); |
|
3671 |
} |
|
3672 |
||
3673 |
template <class DST, class SRC> |
|
3674 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3675 |
inline void madd_4(DST *dest, const quint32 alpha, const SRC *src) |
|
3676 |
{ |
|
3677 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
|
3678 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3679 |
dest[0] = dest[0].byte_mul(alpha >> 24) + DST(src[0]); |
|
3680 |
dest[1] = dest[1].byte_mul((alpha >> 16) & 0xff) + DST(src[1]); |
|
3681 |
dest[2] = dest[2].byte_mul((alpha >> 8) & 0xff) + DST(src[2]); |
|
3682 |
dest[3] = dest[3].byte_mul(alpha & 0xff) + DST(src[3]); |
|
3683 |
} |
|
3684 |
||
3685 |
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
|
3686 |
template <> |
|
3687 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3688 |
inline void madd_4(qargb8565 *dest, const quint32 a, const qargb8565 *src) |
|
3689 |
{ |
|
3690 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
|
3691 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3692 |
||
3693 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
3694 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
3695 |
quint32 x, y, t; |
|
3696 |
quint8 a8; |
|
3697 |
||
3698 |
{ |
|
3699 |
x = dest32[0]; |
|
3700 |
y = src32[0]; |
|
3701 |
||
3702 |
a8 = a >> 24; |
|
3703 |
||
3704 |
// a0,g0 |
|
3705 |
t = ((((x & 0x0007e0ff) * a8) >> 5) & 0x0007e0ff) + (y & 0x0007c0f8); |
|
3706 |
||
3707 |
// r0,b0 |
|
3708 |
t |= ((((x & 0x00f81f00) * a8) >> 5) & 0x00f81f00) + (y & 0x00f81f00); |
|
3709 |
||
3710 |
a8 = (a >> 16) & 0xff; |
|
3711 |
||
3712 |
// a1 |
|
3713 |
t |= ((((x & 0xff000000) >> 5) * a8) & 0xff000000) + (y & 0xf8000000); |
|
3714 |
||
3715 |
dest32[0] = t; |
|
3716 |
} |
|
3717 |
{ |
|
3718 |
x = dest32[1]; |
|
3719 |
y = src32[1]; |
|
3720 |
||
3721 |
// r1,b1 |
|
3722 |
t = ((((x & 0x0000f81f) * a8) >> 5) & 0x0000f81f) + (y & 0x0000f81f); |
|
3723 |
||
3724 |
// g1 |
|
3725 |
t |= ((((x & 0x000007e0) * a8) >> 5) & 0x000007e0) + (y & 0x000007c0); |
|
3726 |
||
3727 |
a8 = (a >> 8) & 0xff; |
|
3728 |
||
3729 |
// a2 |
|
3730 |
t |= ((((x & 0x00ff0000) * a8) >> 5) & 0x00ff0000) + (y & 0x00f80000); |
|
3731 |
||
3732 |
{ |
|
3733 |
// rgb2 |
|
3734 |
quint16 x16 = (x >> 24) | ((dest32[2] & 0x000000ff) << 8); |
|
3735 |
quint16 y16 = (y >> 24) | ((src32[2] & 0x000000ff) << 8); |
|
3736 |
quint16 t16; |
|
3737 |
||
3738 |
t16 = ((((x16 & 0xf81f) * a8) >> 5) & 0xf81f) + (y16 & 0xf81f); |
|
3739 |
t16 |= ((((x16 & 0x07e0) * a8) >> 5) & 0x07e0) + (y16 & 0x07c0); |
|
3740 |
||
3741 |
// rg2 |
|
3742 |
t |= ((t16 & 0x00ff) << 24); |
|
3743 |
||
3744 |
dest32[1] = t; |
|
3745 |
||
3746 |
x = dest32[2]; |
|
3747 |
y = src32[2]; |
|
3748 |
||
3749 |
// gb2 |
|
3750 |
t = (t16 >> 8); |
|
3751 |
} |
|
3752 |
} |
|
3753 |
{ |
|
3754 |
a8 = a & 0xff; |
|
3755 |
||
3756 |
// g3,a3 |
|
3757 |
t |= ((((x & 0x07e0ff00) * a8) >> 5) & 0x07e0ff00) + (y & 0x07c0f800); |
|
3758 |
||
3759 |
// r3,b3 |
|
3760 |
t |= ((((x & 0xf81f0000) >> 5) * a8) & 0xf81f0000)+ (y & 0xf81f0000); |
|
3761 |
||
3762 |
dest32[2] = t; |
|
3763 |
} |
|
3764 |
} |
|
3765 |
#endif |
|
3766 |
||
3767 |
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
|
3768 |
template <> |
|
3769 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3770 |
inline void madd_4(qargb8555 *dest, const quint32 a, const qargb8555 *src) |
|
3771 |
{ |
|
3772 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
|
3773 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3774 |
||
3775 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
3776 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
3777 |
quint32 x, y, t; |
|
3778 |
quint8 a8; |
|
3779 |
||
3780 |
{ |
|
3781 |
x = dest32[0]; |
|
3782 |
y = src32[0]; |
|
3783 |
||
3784 |
a8 = a >> 24; |
|
3785 |
||
3786 |
// a0,g0 |
|
3787 |
t = ((((x & 0x0003e0ff) * a8) >> 5) & 0x0003e0ff) + (y & 0x0003e0f8); |
|
3788 |
||
3789 |
// r0,b0 |
|
3790 |
t |= ((((x & 0x007c1f00) * a8) >> 5) & 0x007c1f00) + (y & 0x007c1f00); |
|
3791 |
||
3792 |
a8 = (a >> 16) & 0xff; |
|
3793 |
||
3794 |
// a1 |
|
3795 |
t |= ((((x & 0xff000000) >> 5) * a8) & 0xff000000) + (y & 0xf8000000); |
|
3796 |
||
3797 |
dest32[0] = t; |
|
3798 |
} |
|
3799 |
{ |
|
3800 |
x = dest32[1]; |
|
3801 |
y = src32[1]; |
|
3802 |
||
3803 |
// r1,b1 |
|
3804 |
t = ((((x & 0x00007c1f) * a8) >> 5) & 0x00007c1f) + (y & 0x00007c1f); |
|
3805 |
||
3806 |
// g1 |
|
3807 |
t |= ((((x & 0x000003e0) * a8) >> 5) & 0x000003e0) + (y & 0x000003e0); |
|
3808 |
||
3809 |
a8 = (a >> 8) & 0xff; |
|
3810 |
||
3811 |
// a2 |
|
3812 |
t |= ((((x & 0x00ff0000) * a8) >> 5) & 0x00ff0000) + (y & 0x00f80000); |
|
3813 |
||
3814 |
{ |
|
3815 |
// rgb2 |
|
3816 |
quint16 x16 = (x >> 24) | ((dest32[2] & 0x000000ff) << 8); |
|
3817 |
quint16 y16 = (y >> 24) | ((src32[2] & 0x000000ff) << 8); |
|
3818 |
quint16 t16; |
|
3819 |
||
3820 |
t16 = ((((x16 & 0x7c1f) * a8) >> 5) & 0x7c1f) + (y16 & 0x7c1f); |
|
3821 |
t16 |= ((((x16 & 0x03e0) * a8) >> 5) & 0x03e0) + (y16 & 0x03e0); |
|
3822 |
||
3823 |
// rg2 |
|
3824 |
t |= ((t16 & 0x00ff) << 24); |
|
3825 |
||
3826 |
dest32[1] = t; |
|
3827 |
||
3828 |
x = dest32[2]; |
|
3829 |
y = src32[2]; |
|
3830 |
||
3831 |
// gb2 |
|
3832 |
t = (t16 >> 8); |
|
3833 |
} |
|
3834 |
} |
|
3835 |
{ |
|
3836 |
a8 = a & 0xff; |
|
3837 |
||
3838 |
// g3,a3 |
|
3839 |
t |= ((((x & 0x03e0ff00) * a8) >> 5) & 0x03e0ff00) + (y & 0x03e0f800); |
|
3840 |
||
3841 |
// r3,b3 |
|
3842 |
t |= ((((x & 0x7c1f0000) >> 5) * a8) & 0x7c1f0000)+ (y & 0x7c1f0000); |
|
3843 |
||
3844 |
dest32[2] = t; |
|
3845 |
} |
|
3846 |
} |
|
3847 |
#endif |
|
3848 |
||
3849 |
template <class T> |
|
3850 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3851 |
inline quint16 alpha_2(const T *src) |
|
3852 |
{ |
|
3853 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3854 |
||
3855 |
if (T::hasAlpha()) |
|
3856 |
return (src[0].alpha() << 8) | src[1].alpha(); |
|
3857 |
else |
|
3858 |
return 0xffff; |
|
3859 |
} |
|
3860 |
||
3861 |
template <class T> |
|
3862 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3863 |
inline quint32 alpha_4(const T *src) |
|
3864 |
{ |
|
3865 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
|
3866 |
||
3867 |
if (T::hasAlpha()) { |
|
3868 |
return (src[0].alpha() << 24) | (src[1].alpha() << 16) |
|
3869 |
| (src[2].alpha() << 8) | src[3].alpha(); |
|
3870 |
} else { |
|
3871 |
return 0xffffffff; |
|
3872 |
} |
|
3873 |
} |
|
3874 |
||
3875 |
template <> |
|
3876 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3877 |
inline quint32 alpha_4(const qargb8565 *src) |
|
3878 |
{ |
|
3879 |
const quint8 *src8 = reinterpret_cast<const quint8*>(src); |
|
3880 |
return src8[0] << 24 | src8[3] << 16 | src8[6] << 8 | src8[9]; |
|
3881 |
} |
|
3882 |
||
3883 |
template <> |
|
3884 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3885 |
inline quint32 alpha_4(const qargb6666 *src) |
|
3886 |
{ |
|
3887 |
const quint8 *src8 = reinterpret_cast<const quint8*>(src); |
|
3888 |
return ((src8[2] & 0xfc) | (src8[2] >> 6)) << 24 |
|
3889 |
| ((src8[5] & 0xfc) | (src8[5] >> 6)) << 16 |
|
3890 |
| ((src8[8] & 0xfc) | (src8[8] >> 6)) << 8 |
|
3891 |
| ((src8[11] & 0xfc) | (src8[11] >> 6)); |
|
3892 |
} |
|
3893 |
||
3894 |
template <> |
|
3895 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3896 |
inline quint32 alpha_4(const qargb8555 *src) |
|
3897 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
3898 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 3899 |
const quint8 *src8 = reinterpret_cast<const quint8*>(src); |
3900 |
return src8[0] << 24 | src8[3] << 16 | src8[6] << 8 | src8[9]; |
|
3901 |
} |
|
3902 |
||
3903 |
template <> |
|
3904 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3905 |
inline quint16 alpha_2(const qargb4444 *src) |
|
3906 |
{ |
|
3907 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
3908 |
const quint32 t = (*src32 & 0xf000f000) | |
|
3909 |
((*src32 & 0xf000f000) >> 4); |
|
3910 |
return (t >> 24) | (t & 0xff00); |
|
3911 |
} |
|
3912 |
||
3913 |
template <class T> |
|
3914 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3915 |
inline quint16 eff_alpha_2(quint16 alpha, const T*) |
|
3916 |
{ |
|
3917 |
return (T::alpha((alpha >> 8) & 0xff) << 8) |
|
3918 |
| T::alpha(alpha & 0xff); |
|
3919 |
} |
|
3920 |
||
3921 |
template <> |
|
3922 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3923 |
inline quint16 eff_alpha_2(quint16 a, const qrgb565*) |
|
3924 |
{ |
|
3925 |
return ((((a & 0xff00) + 0x0100) >> 3) & 0xff00) |
|
3926 |
| ((((a & 0x00ff) + 0x0001) >> 3) & 0x00ff); |
|
3927 |
} |
|
3928 |
||
3929 |
template <> |
|
3930 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3931 |
inline quint16 eff_alpha_2(quint16 a, const qrgb444*) |
|
3932 |
{ |
|
3933 |
return (((a & 0x00ff) + 0x0001) >> 4) |
|
3934 |
| ((((a & 0xff00) + 0x0100) >> 4) & 0xff00); |
|
3935 |
} |
|
3936 |
||
3937 |
template <> |
|
3938 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3939 |
inline quint16 eff_alpha_2(quint16 a, const qargb4444*) |
|
3940 |
{ |
|
3941 |
return (((a & 0x00ff) + 0x0001) >> 4) |
|
3942 |
| ((((a & 0xff00) + 0x0100) >> 4) & 0xff00); |
|
3943 |
} |
|
3944 |
||
3945 |
template <class T> |
|
3946 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3947 |
inline quint16 eff_ialpha_2(quint16 alpha, const T*) |
|
3948 |
{ |
|
3949 |
return (T::ialpha((alpha >> 8) & 0xff) << 8) |
|
3950 |
| T::ialpha(alpha & 0xff); |
|
3951 |
} |
|
3952 |
||
3953 |
template <> |
|
3954 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3955 |
inline quint16 eff_ialpha_2(quint16 a, const qrgb565 *dummy) |
|
3956 |
{ |
|
3957 |
return 0x2020 - eff_alpha_2(a, dummy); |
|
3958 |
} |
|
3959 |
||
3960 |
template <> |
|
3961 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3962 |
inline quint16 eff_ialpha_2(quint16 a, const qargb4444 *dummy) |
|
3963 |
{ |
|
3964 |
return 0x1010 - eff_alpha_2(a, dummy); |
|
3965 |
} |
|
3966 |
||
3967 |
template <> |
|
3968 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3969 |
inline quint16 eff_ialpha_2(quint16 a, const qrgb444 *dummy) |
|
3970 |
{ |
|
3971 |
return 0x1010 - eff_alpha_2(a, dummy); |
|
3972 |
} |
|
3973 |
||
3974 |
template <class T> |
|
3975 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3976 |
inline quint32 eff_alpha_4(quint32 alpha, const T*) |
|
3977 |
{ |
|
3978 |
return (T::alpha(alpha >> 24) << 24) |
|
3979 |
| (T::alpha((alpha >> 16) & 0xff) << 16) |
|
3980 |
| (T::alpha((alpha >> 8) & 0xff) << 8) |
|
3981 |
| T::alpha(alpha & 0xff); |
|
3982 |
} |
|
3983 |
||
3984 |
template <> |
|
3985 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3986 |
inline quint32 eff_alpha_4(quint32 a, const qrgb888*) |
|
3987 |
{ |
|
3988 |
return a; |
|
3989 |
} |
|
3990 |
||
3991 |
template <> |
|
3992 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
3993 |
inline quint32 eff_alpha_4(quint32 a, const qargb8565*) |
|
3994 |
{ |
|
3995 |
return ((((a & 0xff00ff00) + 0x01000100) >> 3) & 0xff00ff00) |
|
3996 |
| ((((a & 0x00ff00ff) + 0x00010001) >> 3) & 0x00ff00ff); |
|
3997 |
} |
|
3998 |
||
3999 |
template <> |
|
4000 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4001 |
inline quint32 eff_alpha_4(quint32 a, const qargb6666*) |
|
4002 |
{ |
|
4003 |
return ((((a & 0xff00ff00) >> 2) + 0x00400040) & 0xff00ff00) |
|
4004 |
| ((((a & 0x00ff00ff) + 0x00010001) >> 2) & 0x00ff00ff); |
|
4005 |
} |
|
4006 |
||
4007 |
template <> |
|
4008 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4009 |
inline quint32 eff_alpha_4(quint32 a, const qrgb666*) |
|
4010 |
{ |
|
4011 |
return ((((a & 0xff00ff00) >> 2) + 0x00400040) & 0xff00ff00) |
|
4012 |
| ((((a & 0x00ff00ff) + 0x00010001) >> 2) & 0x00ff00ff); |
|
4013 |
} |
|
4014 |
||
4015 |
template <> |
|
4016 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4017 |
inline quint32 eff_alpha_4(quint32 a, const qargb8555*) |
|
4018 |
{ |
|
4019 |
return ((((a & 0xff00ff00) + 0x01000100) >> 3) & 0xff00ff00) |
|
4020 |
| ((((a & 0x00ff00ff) + 0x00010001) >> 3) & 0x00ff00ff); |
|
4021 |
} |
|
4022 |
||
4023 |
template <class T> |
|
4024 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4025 |
inline quint32 eff_ialpha_4(quint32 alpha, const T*) |
|
4026 |
{ |
|
4027 |
return (T::ialpha(alpha >> 24) << 24) |
|
4028 |
| (T::ialpha((alpha >> 16) & 0xff) << 16) |
|
4029 |
| (T::ialpha((alpha >> 8) & 0xff) << 8) |
|
4030 |
| T::ialpha(alpha & 0xff); |
|
4031 |
} |
|
4032 |
||
4033 |
template <> |
|
4034 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4035 |
inline quint32 eff_ialpha_4(quint32 a, const qrgb888*) |
|
4036 |
{ |
|
4037 |
return ~a; |
|
4038 |
} |
|
4039 |
||
4040 |
template <> |
|
4041 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4042 |
inline quint32 eff_ialpha_4(quint32 a, const qargb8565 *dummy) |
|
4043 |
{ |
|
4044 |
return 0x20202020 - eff_alpha_4(a, dummy); |
|
4045 |
} |
|
4046 |
||
4047 |
template <> |
|
4048 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4049 |
inline quint32 eff_ialpha_4(quint32 a, const qargb6666 *dummy) |
|
4050 |
{ |
|
4051 |
return 0x40404040 - eff_alpha_4(a, dummy); |
|
4052 |
} |
|
4053 |
||
4054 |
template <> |
|
4055 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4056 |
inline quint32 eff_ialpha_4(quint32 a, const qrgb666 *dummy) |
|
4057 |
{ |
|
4058 |
return 0x40404040 - eff_alpha_4(a, dummy); |
|
4059 |
} |
|
4060 |
||
4061 |
template <> |
|
4062 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4063 |
inline quint32 eff_ialpha_4(quint32 a, const qargb8555 *dummy) |
|
4064 |
{ |
|
4065 |
return 0x20202020 - eff_alpha_4(a, dummy); |
|
4066 |
} |
|
4067 |
||
4068 |
template <class DST, class SRC> |
|
4069 |
inline void interpolate_pixel_unaligned_2(DST *dest, const SRC *src, |
|
4070 |
quint16 alpha) |
|
4071 |
{ |
|
4072 |
const quint16 a = eff_alpha_2(alpha, dest); |
|
4073 |
const quint16 ia = eff_ialpha_2(alpha, dest); |
|
4074 |
dest[0] = DST(src[0]).byte_mul(a >> 8) + dest[0].byte_mul(ia >> 8); |
|
4075 |
dest[1] = DST(src[1]).byte_mul(a & 0xff) + dest[1].byte_mul(ia & 0xff); |
|
4076 |
} |
|
4077 |
||
4078 |
template <class DST, class SRC> |
|
4079 |
inline void interpolate_pixel_2(DST *dest, const SRC *src, quint16 alpha) |
|
4080 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4081 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4082 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4083 |
|
4084 |
const quint16 a = eff_alpha_2(alpha, dest); |
|
4085 |
const quint16 ia = eff_ialpha_2(alpha, dest); |
|
4086 |
||
4087 |
dest[0] = DST(src[0]).byte_mul(a >> 8) + dest[0].byte_mul(ia >> 8); |
|
4088 |
dest[1] = DST(src[1]).byte_mul(a & 0xff) + dest[1].byte_mul(ia & 0xff); |
|
4089 |
} |
|
4090 |
||
4091 |
template <class DST, class SRC> |
|
4092 |
inline void interpolate_pixel(DST &dest, quint8 a, const SRC &src, quint8 b) |
|
4093 |
{ |
|
4094 |
if (SRC::hasAlpha() && !DST::hasAlpha()) |
|
4095 |
interpolate_pixel(dest, a, DST(src), b); |
|
4096 |
else |
|
4097 |
dest = dest.byte_mul(a) + DST(src).byte_mul(b); |
|
4098 |
} |
|
4099 |
||
4100 |
template <> |
|
4101 |
inline void interpolate_pixel(qargb8565 &dest, quint8 a, |
|
4102 |
const qargb8565 &src, quint8 b) |
|
4103 |
{ |
|
4104 |
quint8 *d = reinterpret_cast<quint8*>(&dest); |
|
4105 |
const quint8 *s = reinterpret_cast<const quint8*>(&src); |
|
4106 |
d[0] = (d[0] * a + s[0] * b) >> 5; |
|
4107 |
||
4108 |
const quint16 x = (d[2] << 8) | d[1]; |
|
4109 |
const quint16 y = (s[2] << 8) | s[1]; |
|
4110 |
quint16 t = (((x & 0x07e0) * a + (y & 0x07e0) * b) >> 5) & 0x07e0; |
|
4111 |
t |= (((x & 0xf81f) * a + (y & 0xf81f) * b) >> 5) & 0xf81f; |
|
4112 |
||
4113 |
d[1] = t & 0xff; |
|
4114 |
d[2] = t >> 8; |
|
4115 |
} |
|
4116 |
||
4117 |
template <> |
|
4118 |
inline void interpolate_pixel(qrgb565 &dest, quint8 a, |
|
4119 |
const qrgb565 &src, quint8 b) |
|
4120 |
{ |
|
4121 |
const quint16 x = dest.rawValue(); |
|
4122 |
const quint16 y = src.rawValue(); |
|
4123 |
quint16 t = (((x & 0x07e0) * a + (y & 0x07e0) * b) >> 5) & 0x07e0; |
|
4124 |
t |= (((x & 0xf81f) * a + (y & 0xf81f) * b) >> 5) & 0xf81f; |
|
4125 |
dest = t; |
|
4126 |
} |
|
4127 |
||
4128 |
template <> |
|
4129 |
inline void interpolate_pixel(qrgb555 &dest, quint8 a, |
|
4130 |
const qrgb555 &src, quint8 b) |
|
4131 |
{ |
|
4132 |
const quint16 x = dest.rawValue(); |
|
4133 |
const quint16 y = src.rawValue(); |
|
4134 |
quint16 t = (((x & 0x03e0) * a + (y & 0x03e0) * b) >> 5) & 0x03e0; |
|
4135 |
t |= ((((x & 0x7c1f) * a) + ((y & 0x7c1f) * b)) >> 5) & 0x7c1f; |
|
4136 |
dest = t; |
|
4137 |
} |
|
4138 |
||
4139 |
template <> |
|
4140 |
inline void interpolate_pixel(qrgb444 &dest, quint8 a, |
|
4141 |
const qrgb444 &src, quint8 b) |
|
4142 |
{ |
|
4143 |
const quint16 x = dest.rawValue(); |
|
4144 |
const quint16 y = src.rawValue(); |
|
4145 |
quint16 t = ((x & 0x00f0) * a + (y & 0x00f0) * b) & 0x0f00; |
|
4146 |
t |= ((x & 0x0f0f) * a + (y & 0x0f0f) * b) & 0xf0f0; |
|
4147 |
quint16 *d = reinterpret_cast<quint16*>(&dest); |
|
4148 |
*d = (t >> 4); |
|
4149 |
} |
|
4150 |
||
4151 |
template <class DST, class SRC> |
|
4152 |
inline void interpolate_pixel_2(DST *dest, quint8 a, |
|
4153 |
const SRC *src, quint8 b) |
|
4154 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4155 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4156 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4157 |
|
4158 |
Q_ASSERT(!SRC::hasAlpha()); |
|
4159 |
||
4160 |
dest[0] = dest[0].byte_mul(a) + DST(src[0]).byte_mul(b); |
|
4161 |
dest[1] = dest[1].byte_mul(a) + DST(src[1]).byte_mul(b); |
|
4162 |
} |
|
4163 |
||
4164 |
template <> |
|
4165 |
inline void interpolate_pixel_2(qrgb565 *dest, quint8 a, |
|
4166 |
const qrgb565 *src, quint8 b) |
|
4167 |
{ |
|
4168 |
quint32 *x = reinterpret_cast<quint32*>(dest); |
|
4169 |
const quint32 *y = reinterpret_cast<const quint32*>(src); |
|
4170 |
quint32 t = (((*x & 0xf81f07e0) >> 5) * a + |
|
4171 |
((*y & 0xf81f07e0) >> 5) * b) & 0xf81f07e0; |
|
4172 |
t |= (((*x & 0x07e0f81f) * a |
|
4173 |
+ (*y & 0x07e0f81f) * b) >> 5) & 0x07e0f81f; |
|
4174 |
*x = t; |
|
4175 |
} |
|
4176 |
||
4177 |
template <> |
|
4178 |
inline void interpolate_pixel_2(qrgb555 *dest, quint8 a, |
|
4179 |
const qrgb555 *src, quint8 b) |
|
4180 |
{ |
|
4181 |
quint32 *x = reinterpret_cast<quint32*>(dest); |
|
4182 |
const quint32 *y = reinterpret_cast<const quint32*>(src); |
|
4183 |
quint32 t = (((*x & 0x7c1f03e0) >> 5) * a + |
|
4184 |
((*y & 0x7c1f03e0) >> 5) * b) & 0x7c1f03e0; |
|
4185 |
t |= (((*x & 0x03e07c1f) * a |
|
4186 |
+ (*y & 0x03e07c1f) * b) >> 5) & 0x03e07c1f; |
|
4187 |
*x = t; |
|
4188 |
} |
|
4189 |
||
4190 |
template <> |
|
4191 |
inline void interpolate_pixel_2(qrgb444 *dest, quint8 a, |
|
4192 |
const qrgb444 *src, quint8 b) |
|
4193 |
{ |
|
4194 |
quint32 *x = reinterpret_cast<quint32*>(dest); |
|
4195 |
const quint32 *y = reinterpret_cast<const quint32*>(src); |
|
4196 |
quint32 t = ((*x & 0x0f0f0f0f) * a + (*y & 0x0f0f0f0f) * b) & 0xf0f0f0f0; |
|
4197 |
t |= ((*x & 0x00f000f0) * a + (*y & 0x00f000f0) * b) & 0x0f000f00; |
|
4198 |
*x = t >> 4; |
|
4199 |
} |
|
4200 |
||
4201 |
template <class DST, class SRC> |
|
4202 |
inline void interpolate_pixel_4(DST *dest, const SRC *src, quint32 alpha) |
|
4203 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4204 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4205 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4206 |
|
4207 |
const quint32 a = eff_alpha_4(alpha, dest); |
|
4208 |
const quint32 ia = eff_ialpha_4(alpha, dest); |
|
4209 |
dest[0] = DST(src[0]).byte_mul(a >> 24) |
|
4210 |
+ dest[0].byte_mul(ia >> 24); |
|
4211 |
dest[1] = DST(src[1]).byte_mul((a >> 16) & 0xff) |
|
4212 |
+ dest[1].byte_mul((ia >> 16) & 0xff); |
|
4213 |
dest[2] = DST(src[2]).byte_mul((a >> 8) & 0xff) |
|
4214 |
+ dest[2].byte_mul((ia >> 8) & 0xff); |
|
4215 |
dest[3] = DST(src[3]).byte_mul(a & 0xff) |
|
4216 |
+ dest[3].byte_mul(ia & 0xff); |
|
4217 |
} |
|
4218 |
||
4219 |
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
|
4220 |
template <> |
|
4221 |
inline void interpolate_pixel_4(qargb8565 *dest, const qargb8565 *src, |
|
4222 |
quint32 alpha) |
|
4223 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4224 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4225 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4226 |
|
4227 |
const quint32 a = eff_alpha_4(alpha, dest); |
|
4228 |
const quint32 ia = eff_ialpha_4(alpha, dest); |
|
4229 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
4230 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
4231 |
||
4232 |
quint32 x, y, t; |
|
4233 |
quint8 a8, ia8; |
|
4234 |
{ |
|
4235 |
x = src32[0]; |
|
4236 |
y = dest32[0]; |
|
4237 |
||
4238 |
a8 = a >> 24; |
|
4239 |
ia8 = ia >> 24; |
|
4240 |
||
4241 |
// a0,g0 |
|
4242 |
t = (((x & 0x0007e0ff) * a8 + (y & 0x0007e0ff) * ia8) >> 5) |
|
4243 |
& 0x0007e0ff; |
|
4244 |
||
4245 |
// r0,b0 |
|
4246 |
t |= (((x & 0x00f81f00) * a8 + (y & 0x00f81f00) * ia8) >> 5) |
|
4247 |
& 0x00f81f00; |
|
4248 |
||
4249 |
a8 = (a >> 16) & 0xff; |
|
4250 |
ia8 = (ia >> 16) & 0xff; |
|
4251 |
||
4252 |
// a1 |
|
4253 |
t |= (((x & 0xff000000) >> 5) * a8 + ((y & 0xff000000) >> 5) * ia8) |
|
4254 |
& 0xff000000; |
|
4255 |
||
4256 |
dest32[0] = t; |
|
4257 |
} |
|
4258 |
{ |
|
4259 |
x = src32[1]; |
|
4260 |
y = dest32[1]; |
|
4261 |
||
4262 |
// r1,b1 |
|
4263 |
t = (((x & 0x0000f81f) * a8 + (y & 0x0000f81f) * ia8) >> 5) |
|
4264 |
& 0x0000f81f; |
|
4265 |
||
4266 |
// g1 |
|
4267 |
t |= (((x & 0x000007e0) * a8 + (y & 0x000007e0) * ia8) >> 5) |
|
4268 |
& 0x000007e0; |
|
4269 |
||
4270 |
a8 = (a >> 8) & 0xff; |
|
4271 |
ia8 = (ia >> 8) & 0xff; |
|
4272 |
||
4273 |
// a2 |
|
4274 |
t |= (((x & 0x00ff0000) * a8 + (y & 0x00ff0000) * ia8) >> 5) |
|
4275 |
& 0x00ff0000; |
|
4276 |
||
4277 |
{ |
|
4278 |
// rgb2 |
|
4279 |
quint16 x16 = (x >> 24) | ((src32[2] & 0x000000ff) << 8); |
|
4280 |
quint16 y16 = (y >> 24) | ((dest32[2] & 0x000000ff) << 8); |
|
4281 |
quint16 t16; |
|
4282 |
||
4283 |
t16 = (((x16 & 0xf81f) * a8 + (y16 & 0xf81f) * ia8) >> 5) & 0xf81f; |
|
4284 |
t16 |= (((x16 & 0x07e0) * a8 + (y16 & 0x07e0) * ia8) >> 5) & 0x07e0; |
|
4285 |
||
4286 |
// rg2 |
|
4287 |
t |= ((t16 & 0x00ff) << 24); |
|
4288 |
||
4289 |
dest32[1] = t; |
|
4290 |
||
4291 |
x = src32[2]; |
|
4292 |
y = dest32[2]; |
|
4293 |
||
4294 |
// gb2 |
|
4295 |
t = (t16 >> 8); |
|
4296 |
} |
|
4297 |
} |
|
4298 |
{ |
|
4299 |
a8 = a & 0xff; |
|
4300 |
ia8 = ia & 0xff; |
|
4301 |
||
4302 |
// g3,a3 |
|
4303 |
t |= (((x & 0x07e0ff00) * a8 + (y & 0x07e0ff00) * ia8) >> 5) |
|
4304 |
& 0x07e0ff00; |
|
4305 |
||
4306 |
// r3,b3 |
|
4307 |
t |= (((x & 0xf81f0000) >> 5) * a8 + ((y & 0xf81f0000) >> 5) * ia8) |
|
4308 |
& 0xf81f0000; |
|
4309 |
||
4310 |
dest32[2] = t; |
|
4311 |
} |
|
4312 |
} |
|
4313 |
#endif |
|
4314 |
||
4315 |
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
|
4316 |
template <> |
|
4317 |
inline void interpolate_pixel_4(qargb8555 *dest, const qargb8555 *src, |
|
4318 |
quint32 alpha) |
|
4319 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4320 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4321 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4322 |
|
4323 |
||
4324 |
const quint32 a = eff_alpha_4(alpha, dest); |
|
4325 |
const quint32 ia = eff_ialpha_4(alpha, dest); |
|
4326 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
4327 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
4328 |
||
4329 |
quint32 x, y, t; |
|
4330 |
quint8 a8, ia8; |
|
4331 |
{ |
|
4332 |
x = src32[0]; |
|
4333 |
y = dest32[0]; |
|
4334 |
||
4335 |
a8 = a >> 24; |
|
4336 |
ia8 = ia >> 24; |
|
4337 |
||
4338 |
// a0,g0 |
|
4339 |
t = (((x & 0x0003e0ff) * a8 + (y & 0x0003e0ff) * ia8) >> 5) |
|
4340 |
& 0x0003e0ff; |
|
4341 |
||
4342 |
// r0,b0 |
|
4343 |
t |= (((x & 0x007c1f00) * a8 + (y & 0x007c1f00) * ia8) >> 5) |
|
4344 |
& 0x007c1f00; |
|
4345 |
||
4346 |
a8 = (a >> 16) & 0xff; |
|
4347 |
ia8 = (ia >> 16) & 0xff; |
|
4348 |
||
4349 |
// a1 |
|
4350 |
t |= (((x & 0xff000000) >> 5) * a8 + ((y & 0xff000000) >> 5) * ia8) |
|
4351 |
& 0xff000000; |
|
4352 |
||
4353 |
dest32[0] = t; |
|
4354 |
} |
|
4355 |
{ |
|
4356 |
x = src32[1]; |
|
4357 |
y = dest32[1]; |
|
4358 |
||
4359 |
// r1,b1 |
|
4360 |
t = (((x & 0x00007c1f) * a8 + (y & 0x00007c1f) * ia8) >> 5) |
|
4361 |
& 0x00007c1f; |
|
4362 |
||
4363 |
// g1 |
|
4364 |
t |= (((x & 0x000003e0) * a8 + (y & 0x000003e0) * ia8) >> 5) |
|
4365 |
& 0x000003e0; |
|
4366 |
||
4367 |
a8 = (a >> 8) & 0xff; |
|
4368 |
ia8 = (ia >> 8) & 0xff; |
|
4369 |
||
4370 |
// a2 |
|
4371 |
t |= (((x & 0x00ff0000) * a8 + (y & 0x00ff0000) * ia8) >> 5) |
|
4372 |
& 0x00ff0000; |
|
4373 |
||
4374 |
{ |
|
4375 |
// rgb2 |
|
4376 |
quint16 x16 = (x >> 24) | ((src32[2] & 0x000000ff) << 8); |
|
4377 |
quint16 y16 = (y >> 24) | ((dest32[2] & 0x000000ff) << 8); |
|
4378 |
quint16 t16; |
|
4379 |
||
4380 |
t16 = (((x16 & 0x7c1f) * a8 + (y16 & 0x7c1f) * ia8) >> 5) & 0x7c1f; |
|
4381 |
t16 |= (((x16 & 0x03e0) * a8 + (y16 & 0x03e0) * ia8) >> 5) & 0x03e0; |
|
4382 |
||
4383 |
// rg2 |
|
4384 |
t |= ((t16 & 0x00ff) << 24); |
|
4385 |
||
4386 |
dest32[1] = t; |
|
4387 |
||
4388 |
x = src32[2]; |
|
4389 |
y = dest32[2]; |
|
4390 |
||
4391 |
// gb2 |
|
4392 |
t = (t16 >> 8); |
|
4393 |
} |
|
4394 |
} |
|
4395 |
{ |
|
4396 |
a8 = a & 0xff; |
|
4397 |
ia8 = ia & 0xff; |
|
4398 |
||
4399 |
// g3,a3 |
|
4400 |
t |= (((x & 0x03e0ff00) * a8 + (y & 0x03e0ff00) * ia8) >> 5) |
|
4401 |
& 0x03e0ff00; |
|
4402 |
||
4403 |
// r3,b3 |
|
4404 |
t |= (((x & 0x7c1f0000) >> 5) * a8 + ((y & 0x7c1f0000) >> 5) * ia8) |
|
4405 |
& 0x7c1f0000; |
|
4406 |
||
4407 |
dest32[2] = t; |
|
4408 |
} |
|
4409 |
} |
|
4410 |
#endif |
|
4411 |
||
4412 |
template <> |
|
4413 |
inline void interpolate_pixel_4(qrgb888 *dest, const qrgb888 *src, |
|
4414 |
quint32 alpha) |
|
4415 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4416 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4417 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4418 |
|
4419 |
const quint32 a = eff_alpha_4(alpha, dest); |
|
4420 |
const quint32 ia = eff_ialpha_4(alpha, dest); |
|
4421 |
const quint32 *src32 = reinterpret_cast<const quint32*>(src); |
|
4422 |
quint32 *dest32 = reinterpret_cast<quint32*>(dest); |
|
4423 |
||
4424 |
{ |
|
4425 |
quint32 x = src32[0]; |
|
4426 |
quint32 y = dest32[0]; |
|
4427 |
||
4428 |
quint32 t; |
|
4429 |
t = ((x >> 8) & 0xff00ff) * (a >> 24) |
|
4430 |
+ ((y >> 8) & 0xff00ff) * (ia >> 24); |
|
4431 |
t = (t + ((t >> 8) & 0xff00ff) + 0x800080); |
|
4432 |
t &= 0xff00ff00; |
|
4433 |
||
4434 |
x = (x & 0xff0000) * (a >> 24) |
|
4435 |
+ (x & 0x0000ff) * ((a >> 16) & 0xff) |
|
4436 |
+ (y & 0xff0000) * (ia >> 24) |
|
4437 |
+ (y & 0x0000ff) * ((ia >> 16) & 0xff); |
|
4438 |
x = (x + ((x >> 8) & 0xff00ff) + 0x800080) >> 8; |
|
4439 |
x &= 0x00ff00ff; |
|
4440 |
||
4441 |
dest32[0] = x | t; |
|
4442 |
} |
|
4443 |
{ |
|
4444 |
quint32 x = src32[1]; |
|
4445 |
quint32 y = dest32[1]; |
|
4446 |
||
4447 |
quint32 t; |
|
4448 |
t = ((x >> 8) & 0xff0000) * ((a >> 16) & 0xff) |
|
4449 |
+ ((x >> 8) & 0x0000ff) * ((a >> 8) & 0xff) |
|
4450 |
+ ((y >> 8) & 0xff0000) * ((ia >> 16) & 0xff) |
|
4451 |
+ ((y >> 8) & 0x0000ff) * ((ia >> 8) & 0xff); |
|
4452 |
t = (t + ((t >> 8) & 0xff00ff) + 0x800080); |
|
4453 |
t &= 0xff00ff00; |
|
4454 |
||
4455 |
x = (x & 0xff0000) * ((a >> 16) & 0xff) |
|
4456 |
+ (x & 0x0000ff) * ((a >> 8) & 0xff) |
|
4457 |
+ (y & 0xff0000) * ((ia >> 16) & 0xff) |
|
4458 |
+ (y & 0x0000ff) * ((ia >> 8) & 0xff); |
|
4459 |
x = (x + ((x >> 8) & 0xff00ff) + 0x800080) >> 8; |
|
4460 |
x &= 0x00ff00ff; |
|
4461 |
||
4462 |
dest32[1] = x | t; |
|
4463 |
} |
|
4464 |
{ |
|
4465 |
quint32 x = src32[2]; |
|
4466 |
quint32 y = dest32[2]; |
|
4467 |
||
4468 |
quint32 t; |
|
4469 |
t = ((x >> 8) & 0xff0000) * ((a >> 8) & 0xff) |
|
4470 |
+ ((x >> 8) & 0x0000ff) * (a & 0xff) |
|
4471 |
+ ((y >> 8) & 0xff0000) * ((ia >> 8) & 0xff) |
|
4472 |
+ ((y >> 8) & 0x0000ff) * (ia & 0xff); |
|
4473 |
t = (t + ((t >> 8) & 0xff00ff) + 0x800080); |
|
4474 |
t &= 0xff00ff00; |
|
4475 |
||
4476 |
x = (x & 0xff00ff) * (a & 0xff) |
|
4477 |
+ (y & 0xff00ff) * (ia & 0xff); |
|
4478 |
x = (x + ((x >> 8) & 0xff00ff) + 0x800080) >> 8; |
|
4479 |
x &= 0x00ff00ff; |
|
4480 |
||
4481 |
dest32[2] = x | t; |
|
4482 |
} |
|
4483 |
} |
|
4484 |
||
4485 |
template <class DST, class SRC> |
|
4486 |
inline void interpolate_pixel_4(DST *dest, quint8 a, |
|
4487 |
const SRC *src, quint8 b) |
|
4488 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4489 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4490 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4491 |
|
4492 |
dest[0] = dest[0].byte_mul(a) + DST(src[0]).byte_mul(b); |
|
4493 |
dest[1] = dest[1].byte_mul(a) + DST(src[1]).byte_mul(b); |
|
4494 |
dest[2] = dest[2].byte_mul(a) + DST(src[2]).byte_mul(b); |
|
4495 |
dest[3] = dest[3].byte_mul(a) + DST(src[3]).byte_mul(b); |
|
4496 |
} |
|
4497 |
||
4498 |
template <class DST, class SRC> |
|
4499 |
inline void blend_sourceOver_4(DST *dest, const SRC *src) |
|
4500 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4501 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4502 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4503 |
|
4504 |
const quint32 a = alpha_4(src); |
|
4505 |
if (a == 0xffffffff) { |
|
4506 |
qt_memconvert(dest, src, 4); |
|
4507 |
} else if (a > 0) { |
|
4508 |
quint32 buf[3]; // array of quint32 to get correct alignment |
|
4509 |
qt_memconvert((DST*)(void*)buf, src, 4); |
|
4510 |
madd_4(dest, eff_ialpha_4(a, dest), (DST*)(void*)buf); |
|
4511 |
} |
|
4512 |
} |
|
4513 |
||
4514 |
template <> |
|
4515 |
inline void blend_sourceOver_4(qargb8565 *dest, const qargb8565 *src) |
|
4516 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4517 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4518 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4519 |
|
4520 |
const quint32 a = alpha_4(src); |
|
4521 |
if (a == 0xffffffff) { |
|
4522 |
qt_memconvert(dest, src, 4); |
|
4523 |
} else if (a > 0) { |
|
4524 |
madd_4(dest, eff_ialpha_4(a, dest), src); |
|
4525 |
} |
|
4526 |
} |
|
4527 |
||
4528 |
template <> |
|
4529 |
inline void blend_sourceOver_4(qargb8555 *dest, const qargb8555 *src) |
|
4530 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4531 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4532 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4533 |
|
4534 |
const quint32 a = alpha_4(src); |
|
4535 |
if (a == 0xffffffff) { |
|
4536 |
qt_memconvert(dest, src, 4); |
|
4537 |
} else if (a > 0) { |
|
4538 |
madd_4(dest, eff_ialpha_4(a, dest), src); |
|
4539 |
} |
|
4540 |
} |
|
4541 |
||
4542 |
template <> |
|
4543 |
inline void blend_sourceOver_4(qargb6666 *dest, const qargb6666 *src) |
|
4544 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4545 |
Q_ASSERT((quintptr(dest) & 0x3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4546 |
Q_ASSERT((quintptr(src) & 0x3) == 0); |
0 | 4547 |
|
4548 |
const quint32 a = alpha_4(src); |
|
4549 |
if (a == 0xffffffff) { |
|
4550 |
qt_memconvert(dest, src, 4); |
|
4551 |
} else if (a > 0) { |
|
4552 |
madd_4(dest, eff_ialpha_4(a, dest), src); |
|
4553 |
} |
|
4554 |
} |
|
4555 |
||
4556 |
template <class DST, class SRC> |
|
4557 |
void QT_FASTCALL blendUntransformed_unaligned(DST *dest, const SRC *src, |
|
4558 |
quint8 coverage, int length) |
|
4559 |
{ |
|
4560 |
Q_ASSERT(coverage > 0); |
|
4561 |
||
4562 |
if (coverage < 255) { |
|
4563 |
if (SRC::hasAlpha()) { |
|
4564 |
for (int i = 0; i < length; ++i) { |
|
4565 |
if (src[i].alpha()) { |
|
4566 |
const quint8 alpha = qt_div_255(int(src[i].alpha()) * int(coverage)); |
|
4567 |
interpolate_pixel(dest[i], DST::ialpha(alpha), |
|
4568 |
src[i], DST::alpha(alpha)); |
|
4569 |
} |
|
4570 |
} |
|
4571 |
} else { |
|
4572 |
const quint8 alpha = DST::alpha(coverage); |
|
4573 |
const quint8 ialpha = DST::ialpha(coverage); |
|
4574 |
if (alpha) { |
|
4575 |
for (int i = 0; i < length; ++i) |
|
4576 |
interpolate_pixel(dest[i], ialpha, src[i], alpha); |
|
4577 |
} |
|
4578 |
} |
|
4579 |
return; |
|
4580 |
} |
|
4581 |
||
4582 |
Q_ASSERT(coverage == 0xff); |
|
4583 |
Q_ASSERT(SRC::hasAlpha()); |
|
4584 |
||
4585 |
if (SRC::hasAlpha()) { |
|
4586 |
for (int i = 0; i < length; ++i) { |
|
4587 |
const quint8 a = src->alpha(); |
|
4588 |
if (a == 0xff) |
|
4589 |
*dest = DST(*src); |
|
4590 |
else if (a > 0) { |
|
4591 |
if (DST::hasAlpha()) |
|
4592 |
*dest = DST(*src).truncedAlpha() + dest->byte_mul(DST::ialpha(a)); |
|
4593 |
else |
|
4594 |
*dest = DST(SRC(*src).truncedAlpha()) + dest->byte_mul(DST::ialpha(a)); |
|
4595 |
} |
|
4596 |
++src; |
|
4597 |
++dest; |
|
4598 |
} |
|
4599 |
} |
|
4600 |
} |
|
4601 |
||
4602 |
template <class DST, class SRC> |
|
4603 |
void QT_FASTCALL blendUntransformed_dest16(DST *dest, const SRC *src, |
|
4604 |
quint8 coverage, int length) |
|
4605 |
{ |
|
4606 |
Q_ASSERT(sizeof(DST) == 2); |
|
4607 |
Q_ASSERT(sizeof(SRC) == 2); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4608 |
Q_ASSERT((quintptr(dest) & 0x3) == (quintptr(src) & 0x3)); |
0 | 4609 |
Q_ASSERT(coverage > 0); |
4610 |
||
4611 |
const int align = quintptr(dest) & 0x3; |
|
4612 |
||
4613 |
if (coverage < 255) { |
|
4614 |
// align |
|
4615 |
if (align) { |
|
4616 |
const quint8 alpha = SRC::hasAlpha() |
|
4617 |
? qt_div_255(int(src->alpha()) * int(coverage)) |
|
4618 |
: coverage; |
|
4619 |
if (alpha) { |
|
4620 |
interpolate_pixel(*dest, DST::ialpha(alpha), |
|
4621 |
*src, DST::alpha(alpha)); |
|
4622 |
} |
|
4623 |
++dest; |
|
4624 |
++src; |
|
4625 |
--length; |
|
4626 |
} |
|
4627 |
||
4628 |
if (SRC::hasAlpha()) { |
|
4629 |
while (length >= 2) { |
|
4630 |
const quint16 alpha16 = BYTE_MUL(uint(alpha_2(src)), uint(coverage)); |
|
4631 |
interpolate_pixel_2(dest, src, alpha16); |
|
4632 |
length -= 2; |
|
4633 |
src += 2; |
|
4634 |
dest += 2; |
|
4635 |
} |
|
4636 |
} else { |
|
4637 |
const quint8 alpha = DST::alpha(coverage); |
|
4638 |
const quint8 ialpha = DST::ialpha(coverage); |
|
4639 |
||
4640 |
while (length >= 2) { |
|
4641 |
interpolate_pixel_2(dest, ialpha, src, alpha); |
|
4642 |
length -= 2; |
|
4643 |
src += 2; |
|
4644 |
dest += 2; |
|
4645 |
} |
|
4646 |
} |
|
4647 |
||
4648 |
// tail |
|
4649 |
if (length) { |
|
4650 |
const quint8 alpha = SRC::hasAlpha() |
|
4651 |
? qt_div_255(int(src->alpha()) * int(coverage)) |
|
4652 |
: coverage; |
|
4653 |
if (alpha) { |
|
4654 |
interpolate_pixel(*dest, DST::ialpha(alpha), |
|
4655 |
*src, DST::alpha(alpha)); |
|
4656 |
} |
|
4657 |
} |
|
4658 |
||
4659 |
return; |
|
4660 |
} |
|
4661 |
||
4662 |
Q_ASSERT(SRC::hasAlpha()); |
|
4663 |
if (SRC::hasAlpha()) { |
|
4664 |
if (align) { |
|
4665 |
const quint8 alpha = src->alpha(); |
|
4666 |
if (alpha == 0xff) |
|
4667 |
*dest = DST(*src); |
|
4668 |
else if (alpha > 0) |
|
4669 |
*dest = DST(*src).truncedAlpha() + dest->byte_mul(DST::ialpha(alpha)); |
|
4670 |
++dest; |
|
4671 |
++src; |
|
4672 |
--length; |
|
4673 |
} |
|
4674 |
||
4675 |
while (length >= 2) { |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4676 |
Q_ASSERT((quintptr(dest) & 3) == 0); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4677 |
Q_ASSERT((quintptr(src) & 3) == 0); |
0 | 4678 |
|
4679 |
const quint16 a = alpha_2(src); |
|
4680 |
if (a == 0xffff) { |
|
4681 |
qt_memconvert(dest, src, 2); |
|
4682 |
} else if (a > 0) { |
|
4683 |
quint32 buf; |
|
4684 |
if (sizeof(DST) == 2) |
|
4685 |
qt_memconvert((DST*)(void*)&buf, src, 2); |
|
4686 |
madd_2(dest, eff_ialpha_2(a, dest), (DST*)(void*)&buf); |
|
4687 |
} |
|
4688 |
||
4689 |
length -= 2; |
|
4690 |
src += 2; |
|
4691 |
dest += 2; |
|
4692 |
} |
|
4693 |
||
4694 |
if (length) { |
|
4695 |
const quint8 alpha = src->alpha(); |
|
4696 |
if (alpha == 0xff) |
|
4697 |
*dest = DST(*src); |
|
4698 |
else if (alpha > 0) |
|
4699 |
*dest = DST(*src).truncedAlpha() + dest->byte_mul(DST::ialpha(alpha)); |
|
4700 |
} |
|
4701 |
} |
|
4702 |
} |
|
4703 |
||
4704 |
template <class DST, class SRC> |
|
4705 |
void QT_FASTCALL blendUntransformed_dest24(DST *dest, const SRC *src, |
|
4706 |
quint8 coverage, int length) |
|
4707 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4708 |
Q_ASSERT((quintptr(dest) & 0x3) == (quintptr(src) & 0x3)); |
0 | 4709 |
Q_ASSERT(sizeof(DST) == 3); |
4710 |
Q_ASSERT(coverage > 0); |
|
4711 |
||
4712 |
const int align = quintptr(dest) & 0x3; |
|
4713 |
||
4714 |
if (coverage < 255) { |
|
4715 |
// align |
|
4716 |
for (int i = 0; i < align; ++i) { |
|
4717 |
if (SRC::hasAlpha()) { |
|
4718 |
const quint8 alpha = qt_div_255(int(src->alpha()) * int(coverage)); |
|
4719 |
if (alpha) |
|
4720 |
interpolate_pixel(*dest, DST::ialpha(alpha), |
|
4721 |
*src, DST::alpha(alpha)); |
|
4722 |
} else { |
|
4723 |
interpolate_pixel(*dest, DST::ialpha(coverage), |
|
4724 |
*src, DST::alpha(coverage)); |
|
4725 |
} |
|
4726 |
++dest; |
|
4727 |
++src; |
|
4728 |
--length; |
|
4729 |
} |
|
4730 |
||
4731 |
if (SRC::hasAlpha()) { |
|
4732 |
while (length >= 4) { |
|
4733 |
const quint32 alpha = BYTE_MUL(uint(alpha_4(src)), uint(coverage)); |
|
4734 |
if (alpha) |
|
4735 |
interpolate_pixel_4(dest, src, alpha); |
|
4736 |
length -= 4; |
|
4737 |
src += 4; |
|
4738 |
dest += 4; |
|
4739 |
} |
|
4740 |
} else { |
|
4741 |
const quint8 alpha = DST::alpha(coverage); |
|
4742 |
const quint8 ialpha = DST::ialpha(coverage); |
|
4743 |
while (length >= 4) { |
|
4744 |
interpolate_pixel_4(dest, ialpha, src, alpha); |
|
4745 |
length -= 4; |
|
4746 |
src += 4; |
|
4747 |
dest += 4; |
|
4748 |
} |
|
4749 |
} |
|
4750 |
||
4751 |
// tail |
|
4752 |
while (length--) { |
|
4753 |
if (SRC::hasAlpha()) { |
|
4754 |
const quint8 alpha = qt_div_255(int(src->alpha()) * int(coverage)); |
|
4755 |
if (alpha) |
|
4756 |
interpolate_pixel(*dest, DST::ialpha(alpha), |
|
4757 |
*src, DST::alpha(alpha)); |
|
4758 |
} else { |
|
4759 |
interpolate_pixel(*dest, DST::ialpha(coverage), |
|
4760 |
*src, DST::alpha(coverage)); |
|
4761 |
} |
|
4762 |
++dest; |
|
4763 |
++src; |
|
4764 |
} |
|
4765 |
||
4766 |
return; |
|
4767 |
} |
|
4768 |
||
4769 |
||
4770 |
Q_ASSERT(coverage == 255); |
|
4771 |
Q_ASSERT(SRC::hasAlpha()); |
|
4772 |
||
4773 |
if (SRC::hasAlpha()) { |
|
4774 |
// align |
|
4775 |
for (int i = 0; i < align; ++i) { |
|
4776 |
const quint8 a = src->alpha(); |
|
4777 |
if (a == 0xff) { |
|
4778 |
*dest = DST(*src); |
|
4779 |
} else if (a > 0) { |
|
4780 |
*dest = DST(*src).truncedAlpha() + dest->byte_mul(DST::ialpha(a)); |
|
4781 |
} |
|
4782 |
++dest; |
|
4783 |
++src; |
|
4784 |
--length; |
|
4785 |
} |
|
4786 |
||
4787 |
while (length >= 4) { |
|
4788 |
blend_sourceOver_4(dest, src); |
|
4789 |
length -= 4; |
|
4790 |
src += 4; |
|
4791 |
dest += 4; |
|
4792 |
} |
|
4793 |
||
4794 |
// tail |
|
4795 |
while (length--) { |
|
4796 |
const quint8 a = src->alpha(); |
|
4797 |
if (a == 0xff) { |
|
4798 |
*dest = DST(*src); |
|
4799 |
} else if (a > 0) { |
|
4800 |
*dest = DST(*src).truncedAlpha() + dest->byte_mul(DST::ialpha(a)); |
|
4801 |
} |
|
4802 |
++dest; |
|
4803 |
++src; |
|
4804 |
} |
|
4805 |
} |
|
4806 |
} |
|
4807 |
||
4808 |
template <class DST, class SRC> |
|
4809 |
Q_STATIC_TEMPLATE_SPECIALIZATION |
|
4810 |
void QT_FASTCALL blendUntransformed(int count, const QSpan *spans, void *userData) |
|
4811 |
{ |
|
4812 |
QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
4813 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
4814 |
||
4815 |
if (mode != QPainter::CompositionMode_SourceOver && |
|
4816 |
mode != QPainter::CompositionMode_Source) |
|
4817 |
{ |
|
4818 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
4819 |
return; |
|
4820 |
} |
|
4821 |
||
4822 |
const bool modeSource = !SRC::hasAlpha() || |
|
4823 |
mode == QPainter::CompositionMode_Source; |
|
4824 |
const int image_width = data->texture.width; |
|
4825 |
const int image_height = data->texture.height; |
|
4826 |
int xoff = -qRound(-data->dx); |
|
4827 |
int yoff = -qRound(-data->dy); |
|
4828 |
||
4829 |
while (count--) { |
|
4830 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
4831 |
if (coverage == 0) { |
|
4832 |
++spans; |
|
4833 |
continue; |
|
4834 |
} |
|
4835 |
||
4836 |
int x = spans->x; |
|
4837 |
int length = spans->len; |
|
4838 |
int sx = xoff + x; |
|
4839 |
int sy = yoff + spans->y; |
|
4840 |
if (sy >= 0 && sy < image_height && sx < image_width) { |
|
4841 |
if (sx < 0) { |
|
4842 |
x -= sx; |
|
4843 |
length += sx; |
|
4844 |
sx = 0; |
|
4845 |
} |
|
4846 |
if (sx + length > image_width) |
|
4847 |
length = image_width - sx; |
|
4848 |
if (length > 0) { |
|
4849 |
DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x; |
|
4850 |
const SRC *src = (SRC*)data->texture.scanLine(sy) + sx; |
|
4851 |
if (modeSource && coverage == 255) { |
|
4852 |
qt_memconvert<DST, SRC>(dest, src, length); |
|
4853 |
} else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && length >= 3 && |
|
4854 |
(quintptr(dest) & 3) == (quintptr(src) & 3)) |
|
4855 |
{ |
|
4856 |
blendUntransformed_dest24(dest, src, coverage, length); |
|
4857 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && length >= 3 && |
|
4858 |
(quintptr(dest) & 3) == (quintptr(src) & 3)) |
|
4859 |
{ |
|
4860 |
blendUntransformed_dest16(dest, src, coverage, length); |
|
4861 |
} else { |
|
4862 |
blendUntransformed_unaligned(dest, src, coverage, length); |
|
4863 |
} |
|
4864 |
} |
|
4865 |
} |
|
4866 |
++spans; |
|
4867 |
} |
|
4868 |
} |
|
4869 |
||
4870 |
static void blend_untransformed_rgb888(int count, const QSpan *spans, |
|
4871 |
void *userData) |
|
4872 |
{ |
|
4873 |
#if defined(QT_QWS_DEPTH_24) |
|
4874 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4875 |
||
4876 |
if (data->texture.format == QImage::Format_RGB888) |
|
4877 |
blendUntransformed<qrgb888, qrgb888>(count, spans, userData); |
|
4878 |
else |
|
4879 |
#endif |
|
4880 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4881 |
} |
|
4882 |
||
4883 |
static void blend_untransformed_argb6666(int count, const QSpan *spans, |
|
4884 |
void *userData) |
|
4885 |
{ |
|
4886 |
#if defined(QT_QWS_DEPTH_18) |
|
4887 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4888 |
||
4889 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
4890 |
blendUntransformed<qargb6666, qargb6666>(count, spans, userData); |
|
4891 |
else if (data->texture.format == QImage::Format_RGB666) |
|
4892 |
blendUntransformed<qargb6666, qrgb666>(count, spans, userData); |
|
4893 |
else |
|
4894 |
#endif |
|
4895 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4896 |
} |
|
4897 |
||
4898 |
static void blend_untransformed_rgb666(int count, const QSpan *spans, |
|
4899 |
void *userData) |
|
4900 |
{ |
|
4901 |
#if defined(QT_QWS_DEPTH_18) |
|
4902 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4903 |
||
4904 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
4905 |
blendUntransformed<qrgb666, qargb6666>(count, spans, userData); |
|
4906 |
else if (data->texture.format == QImage::Format_RGB666) |
|
4907 |
blendUntransformed<qrgb666, qrgb666>(count, spans, userData); |
|
4908 |
else |
|
4909 |
#endif |
|
4910 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4911 |
} |
|
4912 |
||
4913 |
static void blend_untransformed_argb8565(int count, const QSpan *spans, |
|
4914 |
void *userData) |
|
4915 |
{ |
|
4916 |
#if defined(QT_QWS_DEPTH_16) |
|
4917 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4918 |
||
4919 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
4920 |
blendUntransformed<qargb8565, qargb8565>(count, spans, userData); |
|
4921 |
else if (data->texture.format == QImage::Format_RGB16) |
|
4922 |
blendUntransformed<qargb8565, qrgb565>(count, spans, userData); |
|
4923 |
else |
|
4924 |
#endif |
|
4925 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4926 |
} |
|
4927 |
||
4928 |
static void blend_untransformed_rgb565(int count, const QSpan *spans, |
|
4929 |
void *userData) |
|
4930 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
4931 |
#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) |
0 | 4932 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
4933 |
||
4934 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
4935 |
blendUntransformed<qrgb565, qargb8565>(count, spans, userData); |
|
4936 |
else if (data->texture.format == QImage::Format_RGB16) |
|
4937 |
blendUntransformed<qrgb565, qrgb565>(count, spans, userData); |
|
4938 |
else |
|
4939 |
#endif |
|
4940 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4941 |
} |
|
4942 |
||
4943 |
static void blend_untransformed_argb8555(int count, const QSpan *spans, |
|
4944 |
void *userData) |
|
4945 |
{ |
|
4946 |
#if defined(QT_QWS_DEPTH_15) |
|
4947 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4948 |
||
4949 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
4950 |
blendUntransformed<qargb8555, qargb8555>(count, spans, userData); |
|
4951 |
else if (data->texture.format == QImage::Format_RGB555) |
|
4952 |
blendUntransformed<qargb8555, qrgb555>(count, spans, userData); |
|
4953 |
else |
|
4954 |
#endif |
|
4955 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4956 |
} |
|
4957 |
||
4958 |
static void blend_untransformed_rgb555(int count, const QSpan *spans, |
|
4959 |
void *userData) |
|
4960 |
{ |
|
4961 |
#if defined(QT_QWS_DEPTH_15) |
|
4962 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4963 |
||
4964 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
4965 |
blendUntransformed<qrgb555, qargb8555>(count, spans, userData); |
|
4966 |
else if (data->texture.format == QImage::Format_RGB555) |
|
4967 |
blendUntransformed<qrgb555, qrgb555>(count, spans, userData); |
|
4968 |
else |
|
4969 |
#endif |
|
4970 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4971 |
} |
|
4972 |
||
4973 |
static void blend_untransformed_argb4444(int count, const QSpan *spans, |
|
4974 |
void *userData) |
|
4975 |
{ |
|
4976 |
#if defined(QT_QWS_DEPTH_12) |
|
4977 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4978 |
||
4979 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
4980 |
blendUntransformed<qargb4444, qargb4444>(count, spans, userData); |
|
4981 |
else if (data->texture.format == QImage::Format_RGB444) |
|
4982 |
blendUntransformed<qargb4444, qrgb444>(count, spans, userData); |
|
4983 |
else |
|
4984 |
#endif |
|
4985 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
4986 |
} |
|
4987 |
||
4988 |
static void blend_untransformed_rgb444(int count, const QSpan *spans, |
|
4989 |
void *userData) |
|
4990 |
{ |
|
4991 |
#if defined(QT_QWS_DEPTH_12) |
|
4992 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
4993 |
||
4994 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
4995 |
blendUntransformed<qrgb444, qargb4444>(count, spans, userData); |
|
4996 |
else if (data->texture.format == QImage::Format_RGB444) |
|
4997 |
blendUntransformed<qrgb444, qrgb444>(count, spans, userData); |
|
4998 |
else |
|
4999 |
#endif |
|
5000 |
blend_untransformed_generic<RegularSpans>(count, spans, userData); |
|
5001 |
} |
|
5002 |
||
5003 |
template <SpanMethod spanMethod> |
|
5004 |
Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_generic(int count, const QSpan *spans, void *userData) |
|
5005 |
{ |
|
5006 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5007 |
||
5008 |
uint buffer[buffer_size]; |
|
5009 |
uint src_buffer[buffer_size]; |
|
5010 |
Operator op = getOperator(data, spans, count); |
|
5011 |
||
5012 |
const int image_width = data->texture.width; |
|
5013 |
const int image_height = data->texture.height; |
|
5014 |
int xoff = -qRound(-data->dx) % image_width; |
|
5015 |
int yoff = -qRound(-data->dy) % image_height; |
|
5016 |
||
5017 |
if (xoff < 0) |
|
5018 |
xoff += image_width; |
|
5019 |
if (yoff < 0) |
|
5020 |
yoff += image_height; |
|
5021 |
||
5022 |
while (count--) { |
|
5023 |
int x = spans->x; |
|
5024 |
int length = spans->len; |
|
5025 |
int sx = (xoff + spans->x) % image_width; |
|
5026 |
int sy = (spans->y + yoff) % image_height; |
|
5027 |
if (sx < 0) |
|
5028 |
sx += image_width; |
|
5029 |
if (sy < 0) |
|
5030 |
sy += image_height; |
|
5031 |
||
5032 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
5033 |
while (length) { |
|
5034 |
int l = qMin(image_width - sx, length); |
|
5035 |
if (buffer_size < l) |
|
5036 |
l = buffer_size; |
|
5037 |
const uint *src = op.src_fetch(src_buffer, &op, data, sy, sx, l); |
|
5038 |
if (spanMethod == RegularSpans) { |
|
5039 |
uint *dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer; |
|
5040 |
op.func(dest, src, l, coverage); |
|
5041 |
if (op.dest_store) |
|
5042 |
op.dest_store(data->rasterBuffer, x, spans->y, dest, l); |
|
5043 |
} else { |
|
5044 |
drawBufferSpan(data, src, l, x, spans->y, l, |
|
5045 |
coverage); |
|
5046 |
} |
|
5047 |
x += l; |
|
5048 |
sx += l; |
|
5049 |
length -= l; |
|
5050 |
if (sx >= image_width) |
|
5051 |
sx = 0; |
|
5052 |
} |
|
5053 |
++spans; |
|
5054 |
} |
|
5055 |
} |
|
5056 |
||
5057 |
template <SpanMethod spanMethod> |
|
5058 |
Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_argb(int count, const QSpan *spans, void *userData) |
|
5059 |
{ |
|
5060 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5061 |
if (data->texture.format != QImage::Format_ARGB32_Premultiplied |
|
5062 |
&& data->texture.format != QImage::Format_RGB32) { |
|
5063 |
blend_tiled_generic<spanMethod>(count, spans, userData); |
|
5064 |
return; |
|
5065 |
} |
|
5066 |
||
5067 |
Operator op = getOperator(data, spans, count); |
|
5068 |
||
5069 |
int image_width = data->texture.width; |
|
5070 |
int image_height = data->texture.height; |
|
5071 |
int xoff = -qRound(-data->dx) % image_width; |
|
5072 |
int yoff = -qRound(-data->dy) % image_height; |
|
5073 |
||
5074 |
if (xoff < 0) |
|
5075 |
xoff += image_width; |
|
5076 |
if (yoff < 0) |
|
5077 |
yoff += image_height; |
|
5078 |
||
5079 |
while (count--) { |
|
5080 |
int x = spans->x; |
|
5081 |
int length = spans->len; |
|
5082 |
int sx = (xoff + spans->x) % image_width; |
|
5083 |
int sy = (spans->y + yoff) % image_height; |
|
5084 |
if (sx < 0) |
|
5085 |
sx += image_width; |
|
5086 |
if (sy < 0) |
|
5087 |
sy += image_height; |
|
5088 |
||
5089 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
5090 |
while (length) { |
|
5091 |
int l = qMin(image_width - sx, length); |
|
5092 |
if (buffer_size < l) |
|
5093 |
l = buffer_size; |
|
5094 |
const uint *src = (uint *)data->texture.scanLine(sy) + sx; |
|
5095 |
if (spanMethod == RegularSpans) { |
|
5096 |
uint *dest = ((uint *)data->rasterBuffer->scanLine(spans->y)) + x; |
|
5097 |
op.func(dest, src, l, coverage); |
|
5098 |
} else { |
|
5099 |
drawBufferSpan(data, src, buffer_size, |
|
5100 |
x, spans->y, l, coverage); |
|
5101 |
} |
|
5102 |
x += l; |
|
5103 |
length -= l; |
|
5104 |
sx = 0; |
|
5105 |
} |
|
5106 |
++spans; |
|
5107 |
} |
|
5108 |
} |
|
5109 |
||
5110 |
template <class DST, class SRC> |
|
5111 |
Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void *userData) |
|
5112 |
{ |
|
5113 |
QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
5114 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
5115 |
||
5116 |
if (mode != QPainter::CompositionMode_SourceOver && |
|
5117 |
mode != QPainter::CompositionMode_Source) |
|
5118 |
{ |
|
5119 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5120 |
return; |
|
5121 |
} |
|
5122 |
||
5123 |
const bool modeSource = !SRC::hasAlpha() || |
|
5124 |
mode == QPainter::CompositionMode_Source; |
|
5125 |
const int image_width = data->texture.width; |
|
5126 |
const int image_height = data->texture.height; |
|
5127 |
int xoff = -qRound(-data->dx) % image_width; |
|
5128 |
int yoff = -qRound(-data->dy) % image_height; |
|
5129 |
||
5130 |
if (xoff < 0) |
|
5131 |
xoff += image_width; |
|
5132 |
if (yoff < 0) |
|
5133 |
yoff += image_height; |
|
5134 |
||
5135 |
while (count--) { |
|
5136 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5137 |
if (coverage == 0) { |
|
5138 |
++spans; |
|
5139 |
continue; |
|
5140 |
} |
|
5141 |
||
5142 |
int x = spans->x; |
|
5143 |
int length = spans->len; |
|
5144 |
int sx = (xoff + spans->x) % image_width; |
|
5145 |
int sy = (spans->y + yoff) % image_height; |
|
5146 |
if (sx < 0) |
|
5147 |
sx += image_width; |
|
5148 |
if (sy < 0) |
|
5149 |
sy += image_height; |
|
5150 |
||
5151 |
if (modeSource && coverage == 255) { |
|
5152 |
// Copy the first texture block |
|
5153 |
length = qMin(image_width,length); |
|
5154 |
int tx = x; |
|
5155 |
while (length) { |
|
5156 |
int l = qMin(image_width - sx, length); |
|
5157 |
if (buffer_size < l) |
|
5158 |
l = buffer_size; |
|
5159 |
DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + tx; |
|
5160 |
const SRC *src = (SRC*)data->texture.scanLine(sy) + sx; |
|
5161 |
||
5162 |
qt_memconvert<DST, SRC>(dest, src, l); |
|
5163 |
length -= l; |
|
5164 |
tx += l; |
|
5165 |
sx = 0; |
|
5166 |
} |
|
5167 |
||
5168 |
// Now use the rasterBuffer as the source of the texture, |
|
5169 |
// We can now progressively copy larger blocks |
|
5170 |
// - Less cpu time in code figuring out what to copy |
|
5171 |
// We are dealing with one block of data |
|
5172 |
// - More likely to fit in the cache |
|
5173 |
// - can use memcpy |
|
5174 |
int copy_image_width = qMin(image_width, int(spans->len)); |
|
5175 |
length = spans->len - copy_image_width; |
|
5176 |
DST *src = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x; |
|
5177 |
DST *dest = src + copy_image_width; |
|
5178 |
while (copy_image_width < length) { |
|
5179 |
qt_memconvert(dest, src, copy_image_width); |
|
5180 |
dest += copy_image_width; |
|
5181 |
length -= copy_image_width; |
|
5182 |
copy_image_width *= 2; |
|
5183 |
} |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5184 |
if (length > 0) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5185 |
qt_memconvert(dest, src, length); |
0 | 5186 |
} else { |
5187 |
while (length) { |
|
5188 |
int l = qMin(image_width - sx, length); |
|
5189 |
if (buffer_size < l) |
|
5190 |
l = buffer_size; |
|
5191 |
DST *dest = ((DST*)data->rasterBuffer->scanLine(spans->y)) + x; |
|
5192 |
const SRC *src = (SRC*)data->texture.scanLine(sy) + sx; |
|
5193 |
if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && |
|
5194 |
(quintptr(dest) & 3) == (quintptr(src) & 3)) |
|
5195 |
{ |
|
5196 |
blendUntransformed_dest24(dest, src, coverage, l); |
|
5197 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
5198 |
(quintptr(dest) & 3) == (quintptr(src) & 3)) |
|
5199 |
{ |
|
5200 |
blendUntransformed_dest16(dest, src, coverage, l); |
|
5201 |
} else { |
|
5202 |
blendUntransformed_unaligned(dest, src, coverage, l); |
|
5203 |
} |
|
5204 |
||
5205 |
x += l; |
|
5206 |
length -= l; |
|
5207 |
sx = 0; |
|
5208 |
} |
|
5209 |
} |
|
5210 |
++spans; |
|
5211 |
} |
|
5212 |
} |
|
5213 |
||
5214 |
static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData) |
|
5215 |
{ |
|
5216 |
#if defined(QT_QWS_DEPTH_24) |
|
5217 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5218 |
||
5219 |
if (data->texture.format == QImage::Format_RGB888) |
|
5220 |
blendTiled<qrgb888, qrgb888>(count, spans, userData); |
|
5221 |
else |
|
5222 |
#endif |
|
5223 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5224 |
} |
|
5225 |
||
5226 |
static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData) |
|
5227 |
{ |
|
5228 |
#if defined(QT_QWS_DEPTH_18) |
|
5229 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5230 |
||
5231 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
5232 |
blendTiled<qargb6666, qargb6666>(count, spans, userData); |
|
5233 |
else if (data->texture.format == QImage::Format_RGB666) |
|
5234 |
blendTiled<qargb6666, qrgb666>(count, spans, userData); |
|
5235 |
else |
|
5236 |
#endif |
|
5237 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5238 |
} |
|
5239 |
||
5240 |
static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData) |
|
5241 |
{ |
|
5242 |
#if defined(QT_QWS_DEPTH_18) |
|
5243 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5244 |
||
5245 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
5246 |
blendTiled<qrgb666, qargb6666>(count, spans, userData); |
|
5247 |
else if (data->texture.format == QImage::Format_RGB666) |
|
5248 |
blendTiled<qrgb666, qrgb666>(count, spans, userData); |
|
5249 |
else |
|
5250 |
#endif |
|
5251 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5252 |
} |
|
5253 |
||
5254 |
static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData) |
|
5255 |
{ |
|
5256 |
#if defined(QT_QWS_DEPTH_16) |
|
5257 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5258 |
||
5259 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
5260 |
blendTiled<qargb8565, qargb8565>(count, spans, userData); |
|
5261 |
else if (data->texture.format == QImage::Format_RGB16) |
|
5262 |
blendTiled<qargb8565, qrgb565>(count, spans, userData); |
|
5263 |
else |
|
5264 |
#endif |
|
5265 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5266 |
} |
|
5267 |
||
5268 |
static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) |
|
5269 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5270 |
#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) |
0 | 5271 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
5272 |
||
5273 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
5274 |
blendTiled<qrgb565, qargb8565>(count, spans, userData); |
|
5275 |
else if (data->texture.format == QImage::Format_RGB16) |
|
5276 |
blendTiled<qrgb565, qrgb565>(count, spans, userData); |
|
5277 |
else |
|
5278 |
#endif |
|
5279 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5280 |
} |
|
5281 |
||
5282 |
static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData) |
|
5283 |
{ |
|
5284 |
#if defined(QT_QWS_DEPTH_15) |
|
5285 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5286 |
||
5287 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
5288 |
blendTiled<qargb8555, qargb8555>(count, spans, userData); |
|
5289 |
else if (data->texture.format == QImage::Format_RGB555) |
|
5290 |
blendTiled<qargb8555, qrgb555>(count, spans, userData); |
|
5291 |
else |
|
5292 |
#endif |
|
5293 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5294 |
} |
|
5295 |
||
5296 |
static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData) |
|
5297 |
{ |
|
5298 |
#if defined(QT_QWS_DEPTH_15) |
|
5299 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5300 |
||
5301 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
5302 |
blendTiled<qrgb555, qargb8555>(count, spans, userData); |
|
5303 |
else if (data->texture.format == QImage::Format_RGB555) |
|
5304 |
blendTiled<qrgb555, qrgb555>(count, spans, userData); |
|
5305 |
else |
|
5306 |
#endif |
|
5307 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5308 |
} |
|
5309 |
||
5310 |
static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData) |
|
5311 |
{ |
|
5312 |
#if defined(QT_QWS_DEPTH_12) |
|
5313 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5314 |
||
5315 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
5316 |
blendTiled<qargb4444, qargb4444>(count, spans, userData); |
|
5317 |
else if (data->texture.format == QImage::Format_RGB444) |
|
5318 |
blendTiled<qargb4444, qrgb444>(count, spans, userData); |
|
5319 |
else |
|
5320 |
#endif |
|
5321 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5322 |
} |
|
5323 |
||
5324 |
static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData) |
|
5325 |
{ |
|
5326 |
#if defined(QT_QWS_DEPTH_12) |
|
5327 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5328 |
||
5329 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
5330 |
blendTiled<qrgb444, qargb4444>(count, spans, userData); |
|
5331 |
else if (data->texture.format == QImage::Format_RGB444) |
|
5332 |
blendTiled<qrgb444, qrgb444>(count, spans, userData); |
|
5333 |
else |
|
5334 |
#endif |
|
5335 |
blend_tiled_generic<RegularSpans>(count, spans, userData); |
|
5336 |
} |
|
5337 |
||
5338 |
template <class DST, class SRC> |
|
5339 |
Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan *spans, |
|
5340 |
void *userData) |
|
5341 |
{ |
|
5342 |
QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
5343 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
5344 |
||
5345 |
||
5346 |
if (mode != QPainter::CompositionMode_SourceOver) { |
|
5347 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5348 |
return; |
|
5349 |
} |
|
5350 |
||
5351 |
SRC buffer[buffer_size]; |
|
5352 |
||
5353 |
const int src_minx = data->texture.x1; |
|
5354 |
const int src_miny = data->texture.y1; |
|
5355 |
const int src_maxx = data->texture.x2 - 1; |
|
5356 |
const int src_maxy = data->texture.y2 - 1; |
|
5357 |
||
5358 |
if (data->fast_matrix) { |
|
5359 |
// The increment pr x in the scanline |
|
5360 |
const int fdx = (int)(data->m11 * fixed_scale); |
|
5361 |
const int fdy = (int)(data->m12 * fixed_scale); |
|
5362 |
||
5363 |
while (count--) { |
|
5364 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5365 |
if (coverage == 0) { |
|
5366 |
++spans; |
|
5367 |
continue; |
|
5368 |
} |
|
5369 |
||
5370 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
5371 |
+ spans->x; |
|
5372 |
const qreal cx = spans->x + qreal(0.5); |
|
5373 |
const qreal cy = spans->y + qreal(0.5); |
|
5374 |
int x = int((data->m21 * cy |
|
5375 |
+ data->m11 * cx + data->dx) * fixed_scale) - half_point; |
|
5376 |
int y = int((data->m22 * cy |
|
5377 |
+ data->m12 * cx + data->dy) * fixed_scale) - half_point; |
|
5378 |
int length = spans->len; |
|
5379 |
||
5380 |
while (length) { |
|
5381 |
const int l = qMin(length, buffer_size); |
|
5382 |
||
5383 |
const SRC *end = buffer + l; |
|
5384 |
SRC *b = buffer; |
|
5385 |
while (b < end) { |
|
5386 |
int x1 = (x >> 16); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5387 |
int x2; |
0 | 5388 |
int y1 = (y >> 16); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5389 |
int y2; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5390 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5391 |
const int distx = (x & 0x0000ffff) >> 8; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5392 |
const int disty = (y & 0x0000ffff) >> 8; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5393 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5394 |
if (x1 < src_minx) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5395 |
x2 = x1 = src_minx; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5396 |
} else if (x1 >= src_maxx) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5397 |
x2 = x1 = src_maxx; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5398 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5399 |
x2 = x1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5400 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5401 |
if (y1 < src_miny) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5402 |
y2 = y1 = src_miny; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5403 |
} else if (y1 >= src_maxy) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5404 |
y2 = y1 = src_maxy; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5405 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5406 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5407 |
} |
0 | 5408 |
#if 0 |
5409 |
if (x1 == x2) { |
|
5410 |
if (y1 == y2) { |
|
5411 |
*b = ((SRC*)data->texture.scanLine(y1))[x1]; |
|
5412 |
} else { |
|
5413 |
*b = ((SRC*)data->texture.scanLine(y1))[x1]; |
|
5414 |
const SRC t = data->texture.scanLine(y2)[x1]; |
|
5415 |
interpolate_pixel(*b, SRC::ialpha(disty), |
|
5416 |
t, SRC::alpha(disty)); |
|
5417 |
} |
|
5418 |
} else if (y1 == y2) { |
|
5419 |
*b = ((SRC*)data->texture.scanLine(y1))[x1]; |
|
5420 |
const SRC t = ((SRC*)data->texture.scanLine(y1))[x2]; |
|
5421 |
interpolate_pixel(*b, SRC::ialpha(distx), |
|
5422 |
t, SRC::alpha(distx)); |
|
5423 |
} else |
|
5424 |
#endif |
|
5425 |
{ |
|
5426 |
const SRC *src1 = (SRC*)data->texture.scanLine(y1); |
|
5427 |
const SRC *src2 = (SRC*)data->texture.scanLine(y2); |
|
5428 |
SRC tl = src1[x1]; |
|
5429 |
const SRC tr = src1[x2]; |
|
5430 |
SRC bl = src2[x1]; |
|
5431 |
const SRC br = src2[x2]; |
|
5432 |
const quint8 ax = SRC::alpha(distx); |
|
5433 |
const quint8 iax = SRC::ialpha(distx); |
|
5434 |
||
5435 |
interpolate_pixel(tl, iax, tr, ax); |
|
5436 |
interpolate_pixel(bl, iax, br, ax); |
|
5437 |
interpolate_pixel(tl, SRC::ialpha(disty), |
|
5438 |
bl, SRC::alpha(disty)); |
|
5439 |
*b = tl; |
|
5440 |
} |
|
5441 |
++b; |
|
5442 |
||
5443 |
x += fdx; |
|
5444 |
y += fdy; |
|
5445 |
} |
|
5446 |
||
5447 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
5448 |
qt_memconvert(dest, buffer, l); |
|
5449 |
} else if (sizeof(DST) == 3 && l >= 4 && |
|
5450 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
5451 |
{ |
|
5452 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
5453 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
5454 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
5455 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
5456 |
} else { |
|
5457 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
5458 |
} |
|
5459 |
||
5460 |
dest += l; |
|
5461 |
length -= l; |
|
5462 |
} |
|
5463 |
++spans; |
|
5464 |
} |
|
5465 |
} else { |
|
5466 |
const qreal fdx = data->m11; |
|
5467 |
const qreal fdy = data->m12; |
|
5468 |
const qreal fdw = data->m13; |
|
5469 |
||
5470 |
while (count--) { |
|
5471 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5472 |
if (coverage == 0) { |
|
5473 |
++spans; |
|
5474 |
continue; |
|
5475 |
} |
|
5476 |
||
5477 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
5478 |
+ spans->x; |
|
5479 |
||
5480 |
const qreal cx = spans->x + qreal(0.5); |
|
5481 |
const qreal cy = spans->y + qreal(0.5); |
|
5482 |
||
5483 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
5484 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
5485 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
5486 |
||
5487 |
int length = spans->len; |
|
5488 |
while (length) { |
|
5489 |
const int l = qMin(length, buffer_size); |
|
5490 |
const SRC *end = buffer + l; |
|
5491 |
SRC *b = buffer; |
|
5492 |
while (b < end) { |
|
5493 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
5494 |
const qreal px = x * iw - qreal(0.5); |
|
5495 |
const qreal py = y * iw - qreal(0.5); |
|
5496 |
||
5497 |
int x1 = int(px) - (px < 0); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5498 |
int x2; |
0 | 5499 |
int y1 = int(py) - (py < 0); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5500 |
int y2; |
0 | 5501 |
|
5502 |
const int distx = int((px - x1) * 256); |
|
5503 |
const int disty = int((py - y1) * 256); |
|
5504 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5505 |
if (x1 < src_minx) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5506 |
x2 = x1 = src_minx; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5507 |
} else if (x1 >= src_maxx) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5508 |
x2 = x1 = src_maxx; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5509 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5510 |
x2 = x1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5511 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5512 |
if (y1 < src_miny) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5513 |
y2 = y1 = src_miny; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5514 |
} else if (y1 >= src_maxy) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5515 |
y2 = y1 = src_maxy; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5516 |
} else { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5517 |
y2 = y1 + 1; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5518 |
} |
0 | 5519 |
|
5520 |
const SRC *src1 = (SRC*)data->texture.scanLine(y1); |
|
5521 |
const SRC *src2 = (SRC*)data->texture.scanLine(y2); |
|
5522 |
SRC tl = src1[x1]; |
|
5523 |
const SRC tr = src1[x2]; |
|
5524 |
SRC bl = src2[x1]; |
|
5525 |
const SRC br = src2[x2]; |
|
5526 |
const quint8 ax = SRC::alpha(distx); |
|
5527 |
const quint8 iax = SRC::ialpha(distx); |
|
5528 |
||
5529 |
interpolate_pixel(tl, iax, tr, ax); |
|
5530 |
interpolate_pixel(bl, iax, br, ax); |
|
5531 |
interpolate_pixel(tl, SRC::ialpha(disty), |
|
5532 |
bl, SRC::alpha(disty)); |
|
5533 |
*b = tl; |
|
5534 |
++b; |
|
5535 |
||
5536 |
x += fdx; |
|
5537 |
y += fdy; |
|
5538 |
w += fdw; |
|
5539 |
} |
|
5540 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
5541 |
qt_memconvert(dest, buffer, l); |
|
5542 |
} else if (sizeof(DST) == 3 && l >= 4 && |
|
5543 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
5544 |
{ |
|
5545 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
5546 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
5547 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
5548 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
5549 |
} else { |
|
5550 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
5551 |
} |
|
5552 |
||
5553 |
dest += l; |
|
5554 |
length -= l; |
|
5555 |
} |
|
5556 |
++spans; |
|
5557 |
} |
|
5558 |
} |
|
5559 |
} |
|
5560 |
||
5561 |
static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, void *userData) |
|
5562 |
{ |
|
5563 |
#if defined(QT_QWS_DEPTH_24) |
|
5564 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5565 |
||
5566 |
if (data->texture.format == QImage::Format_RGB888) |
|
5567 |
blendTransformedBilinear<qrgb888, qrgb888>(count, spans, userData); |
|
5568 |
else |
|
5569 |
#endif |
|
5570 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5571 |
} |
|
5572 |
||
5573 |
static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, void *userData) |
|
5574 |
{ |
|
5575 |
#if defined(QT_QWS_DEPTH_18) |
|
5576 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5577 |
||
5578 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
5579 |
blendTransformedBilinear<qargb6666, qargb6666>(count, spans, userData); |
|
5580 |
else if (data->texture.format == QImage::Format_RGB666) |
|
5581 |
blendTransformedBilinear<qargb6666, qrgb666>(count, spans, userData); |
|
5582 |
else |
|
5583 |
#endif |
|
5584 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5585 |
} |
|
5586 |
||
5587 |
static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, void *userData) |
|
5588 |
{ |
|
5589 |
#if defined(QT_QWS_DEPTH_18) |
|
5590 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5591 |
||
5592 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
5593 |
blendTransformedBilinear<qrgb666, qargb6666>(count, spans, userData); |
|
5594 |
else if (data->texture.format == QImage::Format_RGB666) |
|
5595 |
blendTransformedBilinear<qrgb666, qrgb666>(count, spans, userData); |
|
5596 |
else |
|
5597 |
#endif |
|
5598 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5599 |
} |
|
5600 |
||
5601 |
static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, void *userData) |
|
5602 |
{ |
|
5603 |
#if defined(QT_QWS_DEPTH_16) |
|
5604 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5605 |
||
5606 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
5607 |
blendTransformedBilinear<qargb8565, qargb8565>(count, spans, userData); |
|
5608 |
else if (data->texture.format == QImage::Format_RGB16) |
|
5609 |
blendTransformedBilinear<qargb8565, qrgb565>(count, spans, userData); |
|
5610 |
else |
|
5611 |
#endif |
|
5612 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5613 |
} |
|
5614 |
||
5615 |
static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans, |
|
5616 |
void *userData) |
|
5617 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
5618 |
#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) |
0 | 5619 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
5620 |
||
5621 |
if (data->texture.format == QImage::Format_RGB16) |
|
5622 |
blendTransformedBilinear<qrgb565, qrgb565>(count, spans, userData); |
|
5623 |
else if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
5624 |
blendTransformedBilinear<qrgb565, qargb8565>(count, spans, userData); |
|
5625 |
else |
|
5626 |
#endif |
|
5627 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5628 |
} |
|
5629 |
||
5630 |
static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, void *userData) |
|
5631 |
{ |
|
5632 |
#if defined(QT_QWS_DEPTH_15) |
|
5633 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5634 |
||
5635 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
5636 |
blendTransformedBilinear<qargb8555, qargb8555>(count, spans, userData); |
|
5637 |
else if (data->texture.format == QImage::Format_RGB555) |
|
5638 |
blendTransformedBilinear<qargb8555, qrgb555>(count, spans, userData); |
|
5639 |
else |
|
5640 |
#endif |
|
5641 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5642 |
} |
|
5643 |
||
5644 |
static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, void *userData) |
|
5645 |
{ |
|
5646 |
#if defined(QT_QWS_DEPTH_15) |
|
5647 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5648 |
||
5649 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
5650 |
blendTransformedBilinear<qrgb555, qargb8555>(count, spans, userData); |
|
5651 |
else if (data->texture.format == QImage::Format_RGB555) |
|
5652 |
blendTransformedBilinear<qrgb555, qrgb555>(count, spans, userData); |
|
5653 |
else |
|
5654 |
#endif |
|
5655 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5656 |
} |
|
5657 |
||
5658 |
static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, void *userData) |
|
5659 |
{ |
|
5660 |
#if defined(QT_QWS_DEPTH_12) |
|
5661 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5662 |
||
5663 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
5664 |
blendTransformedBilinear<qargb4444, qargb4444>(count, spans, userData); |
|
5665 |
else if (data->texture.format == QImage::Format_RGB444) |
|
5666 |
blendTransformedBilinear<qargb4444, qrgb444>(count, spans, userData); |
|
5667 |
else |
|
5668 |
#endif |
|
5669 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5670 |
} |
|
5671 |
||
5672 |
static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, void *userData) |
|
5673 |
{ |
|
5674 |
#if defined(QT_QWS_DEPTH_12) |
|
5675 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5676 |
||
5677 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
5678 |
blendTransformedBilinear<qrgb444, qargb4444>(count, spans, userData); |
|
5679 |
else if (data->texture.format == QImage::Format_RGB444) |
|
5680 |
blendTransformedBilinear<qrgb444, qrgb444>(count, spans, userData); |
|
5681 |
else |
|
5682 |
#endif |
|
5683 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5684 |
} |
|
5685 |
||
5686 |
template <SpanMethod spanMethod> |
|
5687 |
Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_argb(int count, const QSpan *spans, void *userData) |
|
5688 |
{ |
|
5689 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5690 |
if (data->texture.format != QImage::Format_ARGB32_Premultiplied |
|
5691 |
&& data->texture.format != QImage::Format_RGB32) { |
|
5692 |
blend_src_generic<spanMethod>(count, spans, userData); |
|
5693 |
return; |
|
5694 |
} |
|
5695 |
||
5696 |
CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; |
|
5697 |
uint buffer[buffer_size]; |
|
5698 |
||
5699 |
int image_width = data->texture.width; |
|
5700 |
int image_height = data->texture.height; |
|
5701 |
const int scanline_offset = data->texture.bytesPerLine / 4; |
|
5702 |
||
5703 |
if (data->fast_matrix) { |
|
5704 |
// The increment pr x in the scanline |
|
5705 |
int fdx = (int)(data->m11 * fixed_scale); |
|
5706 |
int fdy = (int)(data->m12 * fixed_scale); |
|
5707 |
||
5708 |
while (count--) { |
|
5709 |
void *t = data->rasterBuffer->scanLine(spans->y); |
|
5710 |
||
5711 |
uint *target = ((uint *)t) + spans->x; |
|
5712 |
uint *image_bits = (uint *)data->texture.imageData; |
|
5713 |
||
5714 |
const qreal cx = spans->x + 0.5; |
|
5715 |
const qreal cy = spans->y + 0.5; |
|
5716 |
||
5717 |
int x = int((data->m21 * cy |
|
5718 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
5719 |
int y = int((data->m22 * cy |
|
5720 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
5721 |
||
5722 |
int length = spans->len; |
|
5723 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
5724 |
while (length) { |
|
5725 |
int l = qMin(length, buffer_size); |
|
5726 |
const uint *end = buffer + l; |
|
5727 |
uint *b = buffer; |
|
5728 |
while (b < end) { |
|
5729 |
int px = x >> 16; |
|
5730 |
int py = y >> 16; |
|
5731 |
||
5732 |
bool out = (px < 0) || (px >= image_width) |
|
5733 |
|| (py < 0) || (py >= image_height); |
|
5734 |
||
5735 |
int y_offset = py * scanline_offset; |
|
5736 |
*b = out ? uint(0) : image_bits[y_offset + px]; |
|
5737 |
x += fdx; |
|
5738 |
y += fdy; |
|
5739 |
++b; |
|
5740 |
} |
|
5741 |
if (spanMethod == RegularSpans) |
|
5742 |
func(target, buffer, l, coverage); |
|
5743 |
else |
|
5744 |
drawBufferSpan(data, buffer, buffer_size, |
|
5745 |
spans->x + spans->len - length, |
|
5746 |
spans->y, l, coverage); |
|
5747 |
target += l; |
|
5748 |
length -= l; |
|
5749 |
} |
|
5750 |
++spans; |
|
5751 |
} |
|
5752 |
} else { |
|
5753 |
const qreal fdx = data->m11; |
|
5754 |
const qreal fdy = data->m12; |
|
5755 |
const qreal fdw = data->m13; |
|
5756 |
while (count--) { |
|
5757 |
void *t = data->rasterBuffer->scanLine(spans->y); |
|
5758 |
||
5759 |
uint *target = ((uint *)t) + spans->x; |
|
5760 |
uint *image_bits = (uint *)data->texture.imageData; |
|
5761 |
||
5762 |
const qreal cx = spans->x + 0.5; |
|
5763 |
const qreal cy = spans->y + 0.5; |
|
5764 |
||
5765 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
5766 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
5767 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
5768 |
||
5769 |
int length = spans->len; |
|
5770 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
5771 |
while (length) { |
|
5772 |
int l = qMin(length, buffer_size); |
|
5773 |
const uint *end = buffer + l; |
|
5774 |
uint *b = buffer; |
|
5775 |
while (b < end) { |
|
5776 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
5777 |
const qreal tx = x * iw; |
|
5778 |
const qreal ty = y * iw; |
|
5779 |
const int px = int(tx) - (tx < 0); |
|
5780 |
const int py = int(ty) - (ty < 0); |
|
5781 |
||
5782 |
bool out = (px < 0) || (px >= image_width) |
|
5783 |
|| (py < 0) || (py >= image_height); |
|
5784 |
||
5785 |
int y_offset = py * scanline_offset; |
|
5786 |
*b = out ? uint(0) : image_bits[y_offset + px]; |
|
5787 |
x += fdx; |
|
5788 |
y += fdy; |
|
5789 |
w += fdw; |
|
5790 |
||
5791 |
++b; |
|
5792 |
} |
|
5793 |
if (spanMethod == RegularSpans) |
|
5794 |
func(target, buffer, l, coverage); |
|
5795 |
else |
|
5796 |
drawBufferSpan(data, buffer, buffer_size, |
|
5797 |
spans->x + spans->len - length, |
|
5798 |
spans->y, l, coverage); |
|
5799 |
target += l; |
|
5800 |
length -= l; |
|
5801 |
} |
|
5802 |
++spans; |
|
5803 |
} |
|
5804 |
} |
|
5805 |
} |
|
5806 |
||
5807 |
template <class DST, class SRC> |
|
5808 |
Q_STATIC_TEMPLATE_FUNCTION void blendTransformed(int count, const QSpan *spans, void *userData) |
|
5809 |
{ |
|
5810 |
QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
5811 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
5812 |
||
5813 |
if (mode != QPainter::CompositionMode_SourceOver) { |
|
5814 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5815 |
return; |
|
5816 |
} |
|
5817 |
||
5818 |
SRC buffer[buffer_size]; |
|
5819 |
const int image_width = data->texture.width; |
|
5820 |
const int image_height = data->texture.height; |
|
5821 |
||
5822 |
if (data->fast_matrix) { |
|
5823 |
// The increment pr x in the scanline |
|
5824 |
const int fdx = (int)(data->m11 * fixed_scale); |
|
5825 |
const int fdy = (int)(data->m12 * fixed_scale); |
|
5826 |
||
5827 |
while (count--) { |
|
5828 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5829 |
if (coverage == 0) { |
|
5830 |
++spans; |
|
5831 |
continue; |
|
5832 |
} |
|
5833 |
||
5834 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
5835 |
+ spans->x; |
|
5836 |
const qreal cx = spans->x + qreal(0.5); |
|
5837 |
const qreal cy = spans->y + qreal(0.5); |
|
5838 |
int x = int((data->m21 * cy |
|
5839 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
5840 |
int y = int((data->m22 * cy |
|
5841 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
5842 |
int length = spans->len; |
|
5843 |
||
5844 |
while (length) { |
|
5845 |
const int l = qMin(length, buffer_size); |
|
5846 |
||
5847 |
const SRC *end = buffer + l; |
|
5848 |
SRC *b = buffer; |
|
5849 |
while (b < end) { |
|
5850 |
const int px = (x >> 16); |
|
5851 |
const int py = (y >> 16); |
|
5852 |
||
5853 |
if ((px < 0) || (px >= image_width) || |
|
5854 |
(py < 0) || (py >= image_height)) |
|
5855 |
{ |
|
5856 |
*b = 0; |
|
5857 |
} else { |
|
5858 |
*b = ((SRC*)data->texture.scanLine(py))[px]; |
|
5859 |
} |
|
5860 |
++b; |
|
5861 |
||
5862 |
x += fdx; |
|
5863 |
y += fdy; |
|
5864 |
} |
|
5865 |
||
5866 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
5867 |
qt_memconvert(dest, buffer, l); |
|
5868 |
} else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && |
|
5869 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
5870 |
{ |
|
5871 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
5872 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
5873 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
5874 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
5875 |
} else { |
|
5876 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
5877 |
} |
|
5878 |
||
5879 |
dest += l; |
|
5880 |
length -= l; |
|
5881 |
} |
|
5882 |
++spans; |
|
5883 |
} |
|
5884 |
} else { |
|
5885 |
const qreal fdx = data->m11; |
|
5886 |
const qreal fdy = data->m12; |
|
5887 |
const qreal fdw = data->m13; |
|
5888 |
||
5889 |
while (count--) { |
|
5890 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
5891 |
if (coverage == 0) { |
|
5892 |
++spans; |
|
5893 |
continue; |
|
5894 |
} |
|
5895 |
||
5896 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
5897 |
+ spans->x; |
|
5898 |
||
5899 |
const qreal cx = spans->x + qreal(0.5); |
|
5900 |
const qreal cy = spans->y + qreal(0.5); |
|
5901 |
||
5902 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
5903 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
5904 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
5905 |
||
5906 |
int length = spans->len; |
|
5907 |
while (length) { |
|
5908 |
const int l = qMin(length, buffer_size); |
|
5909 |
const SRC *end = buffer + l; |
|
5910 |
SRC *b = buffer; |
|
5911 |
while (b < end) { |
|
5912 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
5913 |
const qreal tx = x * iw; |
|
5914 |
const qreal ty = y * iw; |
|
5915 |
||
5916 |
const int px = int(tx) - (tx < 0); |
|
5917 |
const int py = int(ty) - (ty < 0); |
|
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 |
w += fdw; |
|
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 |
} |
|
5951 |
} |
|
5952 |
||
5953 |
static void blend_transformed_rgb888(int count, const QSpan *spans, |
|
5954 |
void *userData) |
|
5955 |
{ |
|
5956 |
#if defined(QT_QWS_DEPTH_24) |
|
5957 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5958 |
||
5959 |
if (data->texture.format == QImage::Format_RGB888) |
|
5960 |
blendTransformed<qrgb888, qrgb888>(count, spans, userData); |
|
5961 |
else |
|
5962 |
#endif |
|
5963 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5964 |
} |
|
5965 |
||
5966 |
static void blend_transformed_argb6666(int count, const QSpan *spans, |
|
5967 |
void *userData) |
|
5968 |
{ |
|
5969 |
#if defined(QT_QWS_DEPTH_18) |
|
5970 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5971 |
||
5972 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
5973 |
blendTransformed<qargb6666, qargb6666>(count, spans, userData); |
|
5974 |
else if (data->texture.format == QImage::Format_RGB666) |
|
5975 |
blendTransformed<qargb6666, qrgb666>(count, spans, userData); |
|
5976 |
else |
|
5977 |
#endif |
|
5978 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5979 |
} |
|
5980 |
||
5981 |
static void blend_transformed_rgb666(int count, const QSpan *spans, |
|
5982 |
void *userData) |
|
5983 |
{ |
|
5984 |
#if defined(QT_QWS_DEPTH_18) |
|
5985 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
5986 |
||
5987 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
5988 |
blendTransformed<qrgb666, qargb6666>(count, spans, userData); |
|
5989 |
else if (data->texture.format == QImage::Format_RGB666) |
|
5990 |
blendTransformed<qrgb666, qrgb666>(count, spans, userData); |
|
5991 |
else |
|
5992 |
#endif |
|
5993 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
5994 |
} |
|
5995 |
||
5996 |
static void blend_transformed_argb8565(int count, const QSpan *spans, |
|
5997 |
void *userData) |
|
5998 |
{ |
|
5999 |
#if defined(QT_QWS_DEPTH_16) |
|
6000 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6001 |
||
6002 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
6003 |
blendTransformed<qargb8565, qargb8565>(count, spans, userData); |
|
6004 |
else if (data->texture.format == QImage::Format_RGB16) |
|
6005 |
blendTransformed<qargb8565, qrgb565>(count, spans, userData); |
|
6006 |
else |
|
6007 |
#endif |
|
6008 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6009 |
} |
|
6010 |
||
6011 |
static void blend_transformed_rgb565(int count, const QSpan *spans, |
|
6012 |
void *userData) |
|
6013 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6014 |
#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) |
0 | 6015 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
6016 |
||
6017 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
6018 |
blendTransformed<qrgb565, qargb8565>(count, spans, userData); |
|
6019 |
else if (data->texture.format == QImage::Format_RGB16) |
|
6020 |
blendTransformed<qrgb565, qrgb565>(count, spans, userData); |
|
6021 |
else |
|
6022 |
#endif |
|
6023 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6024 |
} |
|
6025 |
||
6026 |
static void blend_transformed_argb8555(int count, const QSpan *spans, |
|
6027 |
void *userData) |
|
6028 |
{ |
|
6029 |
#if defined(QT_QWS_DEPTH_15) |
|
6030 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6031 |
||
6032 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
6033 |
blendTransformed<qargb8555, qargb8555>(count, spans, userData); |
|
6034 |
else if (data->texture.format == QImage::Format_RGB555) |
|
6035 |
blendTransformed<qargb8555, qrgb555>(count, spans, userData); |
|
6036 |
else |
|
6037 |
#endif |
|
6038 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6039 |
} |
|
6040 |
||
6041 |
static void blend_transformed_rgb555(int count, const QSpan *spans, |
|
6042 |
void *userData) |
|
6043 |
{ |
|
6044 |
#if defined(QT_QWS_DEPTH_15) |
|
6045 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6046 |
||
6047 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
6048 |
blendTransformed<qrgb555, qargb8555>(count, spans, userData); |
|
6049 |
else if (data->texture.format == QImage::Format_RGB555) |
|
6050 |
blendTransformed<qrgb555, qrgb555>(count, spans, userData); |
|
6051 |
else |
|
6052 |
#endif |
|
6053 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6054 |
} |
|
6055 |
||
6056 |
static void blend_transformed_argb4444(int count, const QSpan *spans, |
|
6057 |
void *userData) |
|
6058 |
{ |
|
6059 |
#if defined(QT_QWS_DEPTH_12) |
|
6060 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6061 |
||
6062 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
6063 |
blendTransformed<qargb4444, qargb4444>(count, spans, userData); |
|
6064 |
else if (data->texture.format == QImage::Format_RGB444) |
|
6065 |
blendTransformed<qargb4444, qrgb444>(count, spans, userData); |
|
6066 |
else |
|
6067 |
#endif |
|
6068 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6069 |
} |
|
6070 |
||
6071 |
static void blend_transformed_rgb444(int count, const QSpan *spans, |
|
6072 |
void *userData) |
|
6073 |
{ |
|
6074 |
#if defined(QT_QWS_DEPTH_12) |
|
6075 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6076 |
||
6077 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
6078 |
blendTransformed<qrgb444, qargb4444>(count, spans, userData); |
|
6079 |
else if (data->texture.format == QImage::Format_RGB444) |
|
6080 |
blendTransformed<qrgb444, qrgb444>(count, spans, userData); |
|
6081 |
else |
|
6082 |
#endif |
|
6083 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6084 |
} |
|
6085 |
||
6086 |
template <SpanMethod spanMethod> |
|
6087 |
Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_tiled_argb(int count, const QSpan *spans, void *userData) |
|
6088 |
{ |
|
6089 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6090 |
if (data->texture.format != QImage::Format_ARGB32_Premultiplied |
|
6091 |
&& data->texture.format != QImage::Format_RGB32) { |
|
6092 |
blend_src_generic<spanMethod>(count, spans, userData); |
|
6093 |
return; |
|
6094 |
} |
|
6095 |
||
6096 |
CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; |
|
6097 |
uint buffer[buffer_size]; |
|
6098 |
||
6099 |
int image_width = data->texture.width; |
|
6100 |
int image_height = data->texture.height; |
|
6101 |
const int scanline_offset = data->texture.bytesPerLine / 4; |
|
6102 |
||
6103 |
if (data->fast_matrix) { |
|
6104 |
// The increment pr x in the scanline |
|
6105 |
int fdx = (int)(data->m11 * fixed_scale); |
|
6106 |
int fdy = (int)(data->m12 * fixed_scale); |
|
6107 |
||
6108 |
while (count--) { |
|
6109 |
void *t = data->rasterBuffer->scanLine(spans->y); |
|
6110 |
||
6111 |
uint *target = ((uint *)t) + spans->x; |
|
6112 |
uint *image_bits = (uint *)data->texture.imageData; |
|
6113 |
||
6114 |
const qreal cx = spans->x + 0.5; |
|
6115 |
const qreal cy = spans->y + 0.5; |
|
6116 |
||
6117 |
int x = int((data->m21 * cy |
|
6118 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
6119 |
int y = int((data->m22 * cy |
|
6120 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
6121 |
||
6122 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
6123 |
int length = spans->len; |
|
6124 |
while (length) { |
|
6125 |
int l = qMin(length, buffer_size); |
|
6126 |
const uint *end = buffer + l; |
|
6127 |
uint *b = buffer; |
|
6128 |
while (b < end) { |
|
6129 |
int px = x >> 16; |
|
6130 |
int py = y >> 16; |
|
6131 |
px %= image_width; |
|
6132 |
py %= image_height; |
|
6133 |
if (px < 0) px += image_width; |
|
6134 |
if (py < 0) py += image_height; |
|
6135 |
int y_offset = py * scanline_offset; |
|
6136 |
||
6137 |
Q_ASSERT(px >= 0 && px < image_width); |
|
6138 |
Q_ASSERT(py >= 0 && py < image_height); |
|
6139 |
||
6140 |
*b = image_bits[y_offset + px]; |
|
6141 |
x += fdx; |
|
6142 |
y += fdy; |
|
6143 |
++b; |
|
6144 |
} |
|
6145 |
if (spanMethod == RegularSpans) |
|
6146 |
func(target, buffer, l, coverage); |
|
6147 |
else |
|
6148 |
drawBufferSpan(data, buffer, buffer_size, |
|
6149 |
spans->x + spans->len - length, |
|
6150 |
spans->y, l, coverage); |
|
6151 |
target += l; |
|
6152 |
length -= l; |
|
6153 |
} |
|
6154 |
++spans; |
|
6155 |
} |
|
6156 |
} else { |
|
6157 |
const qreal fdx = data->m11; |
|
6158 |
const qreal fdy = data->m12; |
|
6159 |
const qreal fdw = data->m13; |
|
6160 |
while (count--) { |
|
6161 |
void *t = data->rasterBuffer->scanLine(spans->y); |
|
6162 |
||
6163 |
uint *target = ((uint *)t) + spans->x; |
|
6164 |
uint *image_bits = (uint *)data->texture.imageData; |
|
6165 |
||
6166 |
const qreal cx = spans->x + 0.5; |
|
6167 |
const qreal cy = spans->y + 0.5; |
|
6168 |
||
6169 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
6170 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
6171 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
6172 |
||
6173 |
const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; |
|
6174 |
int length = spans->len; |
|
6175 |
while (length) { |
|
6176 |
int l = qMin(length, buffer_size); |
|
6177 |
const uint *end = buffer + l; |
|
6178 |
uint *b = buffer; |
|
6179 |
while (b < end) { |
|
6180 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
6181 |
const qreal tx = x * iw; |
|
6182 |
const qreal ty = y * iw; |
|
6183 |
int px = int(tx) - (tx < 0); |
|
6184 |
int py = int(ty) - (ty < 0); |
|
6185 |
||
6186 |
px %= image_width; |
|
6187 |
py %= image_height; |
|
6188 |
if (px < 0) px += image_width; |
|
6189 |
if (py < 0) py += image_height; |
|
6190 |
int y_offset = py * scanline_offset; |
|
6191 |
||
6192 |
Q_ASSERT(px >= 0 && px < image_width); |
|
6193 |
Q_ASSERT(py >= 0 && py < image_height); |
|
6194 |
||
6195 |
*b = image_bits[y_offset + px]; |
|
6196 |
x += fdx; |
|
6197 |
y += fdy; |
|
6198 |
w += fdw; |
|
6199 |
//force increment to avoid /0 |
|
6200 |
if (!w) { |
|
6201 |
w += fdw; |
|
6202 |
} |
|
6203 |
++b; |
|
6204 |
} |
|
6205 |
if (spanMethod == RegularSpans) |
|
6206 |
func(target, buffer, l, coverage); |
|
6207 |
else |
|
6208 |
drawBufferSpan(data, buffer, buffer_size, |
|
6209 |
spans->x + spans->len - length, |
|
6210 |
spans->y, l, coverage); |
|
6211 |
target += l; |
|
6212 |
length -= l; |
|
6213 |
} |
|
6214 |
++spans; |
|
6215 |
} |
|
6216 |
} |
|
6217 |
} |
|
6218 |
||
6219 |
template <class DST, class SRC> |
|
6220 |
Q_STATIC_TEMPLATE_FUNCTION void blendTransformedTiled(int count, const QSpan *spans, void *userData) |
|
6221 |
{ |
|
6222 |
QSpanData *data = reinterpret_cast<QSpanData*>(userData); |
|
6223 |
QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; |
|
6224 |
||
6225 |
if (mode != QPainter::CompositionMode_SourceOver) { |
|
6226 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6227 |
return; |
|
6228 |
} |
|
6229 |
||
6230 |
SRC buffer[buffer_size]; |
|
6231 |
const int image_width = data->texture.width; |
|
6232 |
const int image_height = data->texture.height; |
|
6233 |
||
6234 |
if (data->fast_matrix) { |
|
6235 |
// The increment pr x in the scanline |
|
6236 |
const int fdx = (int)(data->m11 * fixed_scale); |
|
6237 |
const int fdy = (int)(data->m12 * fixed_scale); |
|
6238 |
||
6239 |
while (count--) { |
|
6240 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
6241 |
if (coverage == 0) { |
|
6242 |
++spans; |
|
6243 |
continue; |
|
6244 |
} |
|
6245 |
||
6246 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
6247 |
+ spans->x; |
|
6248 |
const qreal cx = spans->x + qreal(0.5); |
|
6249 |
const qreal cy = spans->y + qreal(0.5); |
|
6250 |
int x = int((data->m21 * cy |
|
6251 |
+ data->m11 * cx + data->dx) * fixed_scale); |
|
6252 |
int y = int((data->m22 * cy |
|
6253 |
+ data->m12 * cx + data->dy) * fixed_scale); |
|
6254 |
int length = spans->len; |
|
6255 |
||
6256 |
while (length) { |
|
6257 |
const int l = qMin(length, buffer_size); |
|
6258 |
||
6259 |
const SRC *end = buffer + l; |
|
6260 |
SRC *b = buffer; |
|
6261 |
while (b < end) { |
|
6262 |
int px = (x >> 16) % image_width; |
|
6263 |
int py = (y >> 16) % image_height; |
|
6264 |
||
6265 |
if (px < 0) |
|
6266 |
px += image_width; |
|
6267 |
if (py < 0) |
|
6268 |
py += image_height; |
|
6269 |
||
6270 |
*b = ((SRC*)data->texture.scanLine(py))[px]; |
|
6271 |
++b; |
|
6272 |
||
6273 |
x += fdx; |
|
6274 |
y += fdy; |
|
6275 |
} |
|
6276 |
||
6277 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
6278 |
qt_memconvert(dest, buffer, l); |
|
6279 |
} else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && |
|
6280 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
6281 |
{ |
|
6282 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
6283 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
6284 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
6285 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
6286 |
} else { |
|
6287 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
6288 |
} |
|
6289 |
||
6290 |
dest += l; |
|
6291 |
length -= l; |
|
6292 |
} |
|
6293 |
++spans; |
|
6294 |
} |
|
6295 |
} else { |
|
6296 |
const qreal fdx = data->m11; |
|
6297 |
const qreal fdy = data->m12; |
|
6298 |
const qreal fdw = data->m13; |
|
6299 |
||
6300 |
while (count--) { |
|
6301 |
const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; |
|
6302 |
if (coverage == 0) { |
|
6303 |
++spans; |
|
6304 |
continue; |
|
6305 |
} |
|
6306 |
||
6307 |
DST *dest = (DST*)data->rasterBuffer->scanLine(spans->y) |
|
6308 |
+ spans->x; |
|
6309 |
||
6310 |
const qreal cx = spans->x + qreal(0.5); |
|
6311 |
const qreal cy = spans->y + qreal(0.5); |
|
6312 |
||
6313 |
qreal x = data->m21 * cy + data->m11 * cx + data->dx; |
|
6314 |
qreal y = data->m22 * cy + data->m12 * cx + data->dy; |
|
6315 |
qreal w = data->m23 * cy + data->m13 * cx + data->m33; |
|
6316 |
||
6317 |
int length = spans->len; |
|
6318 |
while (length) { |
|
6319 |
const int l = qMin(length, buffer_size); |
|
6320 |
const SRC *end = buffer + l; |
|
6321 |
SRC *b = buffer; |
|
6322 |
while (b < end) { |
|
6323 |
const qreal iw = w == 0 ? 1 : 1 / w; |
|
6324 |
const qreal tx = x * iw; |
|
6325 |
const qreal ty = y * iw; |
|
6326 |
||
6327 |
int px = int(tx) - (tx < 0); |
|
6328 |
int py = int(ty) - (ty < 0); |
|
6329 |
||
6330 |
if (px < 0) |
|
6331 |
px += image_width; |
|
6332 |
if (py < 0) |
|
6333 |
py += image_height; |
|
6334 |
||
6335 |
*b = ((SRC*)data->texture.scanLine(py))[px]; |
|
6336 |
++b; |
|
6337 |
||
6338 |
x += fdx; |
|
6339 |
y += fdy; |
|
6340 |
w += fdw; |
|
6341 |
// force increment to avoid /0 |
|
6342 |
if (!w) |
|
6343 |
w += fdw; |
|
6344 |
} |
|
6345 |
if (!SRC::hasAlpha() && coverage == 255) { |
|
6346 |
qt_memconvert(dest, buffer, l); |
|
6347 |
} else if (sizeof(DST) == 3 && sizeof(SRC) == 3 && l >= 4 && |
|
6348 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) |
|
6349 |
{ |
|
6350 |
blendUntransformed_dest24(dest, buffer, coverage, l); |
|
6351 |
} else if (sizeof(DST) == 2 && sizeof(SRC) == 2 && l >= 2 && |
|
6352 |
(quintptr(dest) & 3) == (quintptr(buffer) & 3)) { |
|
6353 |
blendUntransformed_dest16(dest, buffer, coverage, l); |
|
6354 |
} else { |
|
6355 |
blendUntransformed_unaligned(dest, buffer, coverage, l); |
|
6356 |
} |
|
6357 |
||
6358 |
dest += l; |
|
6359 |
length -= l; |
|
6360 |
} |
|
6361 |
++spans; |
|
6362 |
} |
|
6363 |
} |
|
6364 |
} |
|
6365 |
||
6366 |
static void blend_transformed_tiled_rgb888(int count, const QSpan *spans, |
|
6367 |
void *userData) |
|
6368 |
{ |
|
6369 |
#if defined(QT_QWS_DEPTH_24) |
|
6370 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6371 |
||
6372 |
if (data->texture.format == QImage::Format_RGB888) |
|
6373 |
blendTransformedTiled<qrgb888, qrgb888>(count, spans, userData); |
|
6374 |
else |
|
6375 |
#endif |
|
6376 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6377 |
} |
|
6378 |
||
6379 |
static void blend_transformed_tiled_argb6666(int count, const QSpan *spans, |
|
6380 |
void *userData) |
|
6381 |
{ |
|
6382 |
#if defined(QT_QWS_DEPTH_18) |
|
6383 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6384 |
||
6385 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
6386 |
blendTransformedTiled<qargb6666, qargb6666>(count, spans, userData); |
|
6387 |
else if (data->texture.format == QImage::Format_RGB666) |
|
6388 |
blendTransformedTiled<qargb6666, qrgb666>(count, spans, userData); |
|
6389 |
else |
|
6390 |
#endif |
|
6391 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6392 |
} |
|
6393 |
||
6394 |
static void blend_transformed_tiled_rgb666(int count, const QSpan *spans, |
|
6395 |
void *userData) |
|
6396 |
{ |
|
6397 |
#if defined(QT_QWS_DEPTH_18) |
|
6398 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6399 |
||
6400 |
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) |
|
6401 |
blendTransformedTiled<qrgb666, qargb6666>(count, spans, userData); |
|
6402 |
else if (data->texture.format == QImage::Format_RGB666) |
|
6403 |
blendTransformedTiled<qrgb666, qrgb666>(count, spans, userData); |
|
6404 |
else |
|
6405 |
#endif |
|
6406 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6407 |
} |
|
6408 |
||
6409 |
static void blend_transformed_tiled_argb8565(int count, const QSpan *spans, |
|
6410 |
void *userData) |
|
6411 |
{ |
|
6412 |
#if defined(QT_QWS_DEPTH_16) |
|
6413 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6414 |
||
6415 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
6416 |
blendTransformedTiled<qargb8565, qargb8565>(count, spans, userData); |
|
6417 |
else if (data->texture.format == QImage::Format_RGB16) |
|
6418 |
blendTransformedTiled<qargb8565, qrgb565>(count, spans, userData); |
|
6419 |
else |
|
6420 |
#endif |
|
6421 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6422 |
} |
|
6423 |
||
6424 |
static void blend_transformed_tiled_rgb565(int count, const QSpan *spans, |
|
6425 |
void *userData) |
|
6426 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6427 |
#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) |
0 | 6428 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
6429 |
||
6430 |
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) |
|
6431 |
blendTransformedTiled<qrgb565, qargb8565>(count, spans, userData); |
|
6432 |
else if (data->texture.format == QImage::Format_RGB16) |
|
6433 |
blendTransformedTiled<qrgb565, qrgb565>(count, spans, userData); |
|
6434 |
else |
|
6435 |
#endif |
|
6436 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6437 |
} |
|
6438 |
||
6439 |
static void blend_transformed_tiled_argb8555(int count, const QSpan *spans, |
|
6440 |
void *userData) |
|
6441 |
{ |
|
6442 |
#if defined(QT_QWS_DEPTH_15) |
|
6443 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6444 |
||
6445 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
6446 |
blendTransformedTiled<qargb8555, qargb8555>(count, spans, userData); |
|
6447 |
else if (data->texture.format == QImage::Format_RGB555) |
|
6448 |
blendTransformedTiled<qargb8555, qrgb555>(count, spans, userData); |
|
6449 |
else |
|
6450 |
#endif |
|
6451 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6452 |
} |
|
6453 |
||
6454 |
static void blend_transformed_tiled_rgb555(int count, const QSpan *spans, |
|
6455 |
void *userData) |
|
6456 |
{ |
|
6457 |
#if defined(QT_QWS_DEPTH_15) |
|
6458 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6459 |
||
6460 |
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) |
|
6461 |
blendTransformedTiled<qrgb555, qargb8555>(count, spans, userData); |
|
6462 |
else if (data->texture.format == QImage::Format_RGB555) |
|
6463 |
blendTransformedTiled<qrgb555, qrgb555>(count, spans, userData); |
|
6464 |
else |
|
6465 |
#endif |
|
6466 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6467 |
} |
|
6468 |
||
6469 |
static void blend_transformed_tiled_argb4444(int count, const QSpan *spans, |
|
6470 |
void *userData) |
|
6471 |
{ |
|
6472 |
#if defined(QT_QWS_DEPTH_12) |
|
6473 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6474 |
||
6475 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
6476 |
blendTransformedTiled<qargb4444, qargb4444>(count, spans, userData); |
|
6477 |
else if (data->texture.format == QImage::Format_RGB444) |
|
6478 |
blendTransformedTiled<qargb4444, qrgb444>(count, spans, userData); |
|
6479 |
else |
|
6480 |
#endif |
|
6481 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6482 |
} |
|
6483 |
||
6484 |
static void blend_transformed_tiled_rgb444(int count, const QSpan *spans, |
|
6485 |
void *userData) |
|
6486 |
{ |
|
6487 |
#if defined(QT_QWS_DEPTH_12) |
|
6488 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6489 |
||
6490 |
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) |
|
6491 |
blendTransformedTiled<qrgb444, qargb4444>(count, spans, userData); |
|
6492 |
else if (data->texture.format == QImage::Format_RGB444) |
|
6493 |
blendTransformedTiled<qrgb444, qrgb444>(count, spans, userData); |
|
6494 |
else |
|
6495 |
#endif |
|
6496 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6497 |
} |
|
6498 |
||
6499 |
# define SPANFUNC_POINTER(Name, Arg) Name<Arg> |
|
6500 |
||
6501 |
||
6502 |
/* Image formats here are target formats */ |
|
6503 |
static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats] = { |
|
6504 |
// Untransformed |
|
6505 |
{ |
|
6506 |
0, // Invalid |
|
6507 |
SPANFUNC_POINTER(blend_untransformed_generic, RegularSpans), // Mono |
|
6508 |
SPANFUNC_POINTER(blend_untransformed_generic, RegularSpans), // MonoLsb |
|
6509 |
SPANFUNC_POINTER(blend_untransformed_generic, RegularSpans), // Indexed8 |
|
6510 |
SPANFUNC_POINTER(blend_untransformed_generic, RegularSpans), // RGB32 |
|
6511 |
SPANFUNC_POINTER(blend_untransformed_generic, RegularSpans), // ARGB32 |
|
6512 |
SPANFUNC_POINTER(blend_untransformed_argb, RegularSpans), // ARGB32_Premultiplied |
|
6513 |
blend_untransformed_rgb565, |
|
6514 |
blend_untransformed_argb8565, |
|
6515 |
blend_untransformed_rgb666, |
|
6516 |
blend_untransformed_argb6666, |
|
6517 |
blend_untransformed_rgb555, |
|
6518 |
blend_untransformed_argb8555, |
|
6519 |
blend_untransformed_rgb888, |
|
6520 |
blend_untransformed_rgb444, |
|
6521 |
blend_untransformed_argb4444, |
|
6522 |
}, |
|
6523 |
// Tiled |
|
6524 |
{ |
|
6525 |
0, // Invalid |
|
6526 |
SPANFUNC_POINTER(blend_tiled_generic, RegularSpans), // Mono |
|
6527 |
SPANFUNC_POINTER(blend_tiled_generic, RegularSpans), // MonoLsb |
|
6528 |
SPANFUNC_POINTER(blend_tiled_generic, RegularSpans), // Indexed8 |
|
6529 |
SPANFUNC_POINTER(blend_tiled_generic, RegularSpans), // RGB32 |
|
6530 |
SPANFUNC_POINTER(blend_tiled_generic, RegularSpans), // ARGB32 |
|
6531 |
SPANFUNC_POINTER(blend_tiled_argb, RegularSpans), // ARGB32_Premultiplied |
|
6532 |
blend_tiled_rgb565, |
|
6533 |
blend_tiled_argb8565, |
|
6534 |
blend_tiled_rgb666, |
|
6535 |
blend_tiled_argb6666, |
|
6536 |
blend_tiled_rgb555, |
|
6537 |
blend_tiled_argb8555, |
|
6538 |
blend_tiled_rgb888, |
|
6539 |
blend_tiled_rgb444, |
|
6540 |
blend_tiled_argb4444, |
|
6541 |
}, |
|
6542 |
// Transformed |
|
6543 |
{ |
|
6544 |
0, // Invalid |
|
6545 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Mono |
|
6546 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // MonoLsb |
|
6547 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8 |
|
6548 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32 |
|
6549 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32 |
|
6550 |
SPANFUNC_POINTER(blend_transformed_argb, RegularSpans), // ARGB32_Premultiplied |
|
6551 |
blend_transformed_rgb565, |
|
6552 |
blend_transformed_argb8565, |
|
6553 |
blend_transformed_rgb666, |
|
6554 |
blend_transformed_argb6666, |
|
6555 |
blend_transformed_rgb555, |
|
6556 |
blend_transformed_argb8555, |
|
6557 |
blend_transformed_rgb888, |
|
6558 |
blend_transformed_rgb444, |
|
6559 |
blend_transformed_argb4444, |
|
6560 |
}, |
|
6561 |
// TransformedTiled |
|
6562 |
{ |
|
6563 |
0, |
|
6564 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Mono |
|
6565 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // MonoLsb |
|
6566 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8 |
|
6567 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32 |
|
6568 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32 |
|
6569 |
SPANFUNC_POINTER(blend_transformed_tiled_argb, RegularSpans), // ARGB32_Premultiplied |
|
6570 |
blend_transformed_tiled_rgb565, |
|
6571 |
blend_transformed_tiled_argb8565, |
|
6572 |
blend_transformed_tiled_rgb666, |
|
6573 |
blend_transformed_tiled_argb6666, |
|
6574 |
blend_transformed_tiled_rgb555, |
|
6575 |
blend_transformed_tiled_argb8555, |
|
6576 |
blend_transformed_tiled_rgb888, |
|
6577 |
blend_transformed_tiled_rgb444, |
|
6578 |
blend_transformed_tiled_argb4444 |
|
6579 |
}, |
|
6580 |
// Bilinear |
|
6581 |
{ |
|
6582 |
0, |
|
6583 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Mono |
|
6584 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // MonoLsb |
|
6585 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8 |
|
6586 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32 |
|
6587 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32 |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6588 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32_Premultiplied |
0 | 6589 |
blend_transformed_bilinear_rgb565, |
6590 |
blend_transformed_bilinear_argb8565, |
|
6591 |
blend_transformed_bilinear_rgb666, |
|
6592 |
blend_transformed_bilinear_argb6666, |
|
6593 |
blend_transformed_bilinear_rgb555, |
|
6594 |
blend_transformed_bilinear_argb8555, |
|
6595 |
blend_transformed_bilinear_rgb888, |
|
6596 |
blend_transformed_bilinear_rgb444, |
|
6597 |
blend_transformed_bilinear_argb4444, |
|
6598 |
}, |
|
6599 |
// BilinearTiled |
|
6600 |
{ |
|
6601 |
0, |
|
6602 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Mono |
|
6603 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // MonoLsb |
|
6604 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8 |
|
6605 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32 |
|
6606 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32 |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6607 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32_Premultiplied |
0 | 6608 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB16 |
6609 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB8565_Premultiplied |
|
6610 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB666 |
|
6611 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB6666_Premultiplied |
|
6612 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB555 |
|
6613 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB8555_Premultiplied |
|
6614 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB888 |
|
6615 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB444 |
|
6616 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB4444_Premultiplied |
|
6617 |
} |
|
6618 |
}; |
|
6619 |
||
6620 |
#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS) |
|
6621 |
static const ProcessSpans processTextureSpansCallback[NBlendTypes][QImage::NImageFormats] = { |
|
6622 |
// Untransformed |
|
6623 |
{ |
|
6624 |
0, // Invalid |
|
6625 |
blend_untransformed_generic<CallbackSpans>, // Mono |
|
6626 |
blend_untransformed_generic<CallbackSpans>, // MonoLsb |
|
6627 |
blend_untransformed_generic<CallbackSpans>, // Indexed8 |
|
6628 |
blend_untransformed_generic<CallbackSpans>, // RGB32 |
|
6629 |
blend_untransformed_generic<CallbackSpans>, // ARGB32 |
|
6630 |
blend_untransformed_argb<CallbackSpans>, // ARGB32_Premultiplied |
|
6631 |
blend_untransformed_generic<CallbackSpans>, // RGB16 |
|
6632 |
blend_untransformed_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6633 |
blend_untransformed_generic<CallbackSpans>, // RGB666 |
|
6634 |
blend_untransformed_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6635 |
blend_untransformed_generic<CallbackSpans>, // RGB555 |
|
6636 |
blend_untransformed_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6637 |
blend_untransformed_generic<CallbackSpans>, // RGB888 |
|
6638 |
blend_untransformed_generic<CallbackSpans>, // RGB444 |
|
6639 |
blend_untransformed_generic<CallbackSpans> // ARGB4444_Premultiplied |
|
6640 |
}, |
|
6641 |
// Tiled |
|
6642 |
{ |
|
6643 |
0, // Invalid |
|
6644 |
blend_tiled_generic<CallbackSpans>, // Mono |
|
6645 |
blend_tiled_generic<CallbackSpans>, // MonoLsb |
|
6646 |
blend_tiled_generic<CallbackSpans>, // Indexed8 |
|
6647 |
blend_tiled_generic<CallbackSpans>, // RGB32 |
|
6648 |
blend_tiled_generic<CallbackSpans>, // ARGB32 |
|
6649 |
blend_tiled_argb<CallbackSpans>, // ARGB32_Premultiplied |
|
6650 |
blend_tiled_generic<CallbackSpans>, // RGB16 |
|
6651 |
blend_tiled_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6652 |
blend_tiled_generic<CallbackSpans>, // RGB666 |
|
6653 |
blend_tiled_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6654 |
blend_tiled_generic<CallbackSpans>, // RGB555 |
|
6655 |
blend_tiled_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6656 |
blend_tiled_generic<CallbackSpans>, // RGB888 |
|
6657 |
blend_tiled_generic<CallbackSpans>, // RGB444 |
|
6658 |
blend_tiled_generic<CallbackSpans> // ARGB4444_Premultiplied |
|
6659 |
}, |
|
6660 |
// Transformed |
|
6661 |
{ |
|
6662 |
0, // Invalid |
|
6663 |
blend_src_generic<CallbackSpans>, // Mono |
|
6664 |
blend_src_generic<CallbackSpans>, // MonoLsb |
|
6665 |
blend_src_generic<CallbackSpans>, // Indexed8 |
|
6666 |
blend_src_generic<CallbackSpans>, // RGB32 |
|
6667 |
blend_src_generic<CallbackSpans>, // ARGB32 |
|
6668 |
blend_transformed_argb<CallbackSpans>, // ARGB32_Premultiplied |
|
6669 |
blend_src_generic<CallbackSpans>, // RGB16 |
|
6670 |
blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6671 |
blend_src_generic<CallbackSpans>, // RGB666 |
|
6672 |
blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6673 |
blend_src_generic<CallbackSpans>, // RGB555 |
|
6674 |
blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6675 |
blend_src_generic<CallbackSpans>, // RGB888 |
|
6676 |
blend_src_generic<CallbackSpans>, // RGB444 |
|
6677 |
blend_src_generic<CallbackSpans>, // ARGB4444_Premultiplied |
|
6678 |
}, |
|
6679 |
// TransformedTiled |
|
6680 |
{ |
|
6681 |
0, |
|
6682 |
blend_src_generic<CallbackSpans>, // Mono |
|
6683 |
blend_src_generic<CallbackSpans>, // MonoLsb |
|
6684 |
blend_src_generic<CallbackSpans>, // Indexed8 |
|
6685 |
blend_src_generic<CallbackSpans>, // RGB32 |
|
6686 |
blend_src_generic<CallbackSpans>, // ARGB32 |
|
6687 |
blend_transformed_tiled_argb<CallbackSpans>, // ARGB32_Premultiplied |
|
6688 |
blend_src_generic<CallbackSpans>, // RGB16 |
|
6689 |
blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6690 |
blend_src_generic<CallbackSpans>, // RGB666 |
|
6691 |
blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6692 |
blend_src_generic<CallbackSpans>, // RGB555 |
|
6693 |
blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6694 |
blend_src_generic<CallbackSpans>, // RGB888 |
|
6695 |
blend_src_generic<CallbackSpans>, // RGB444 |
|
6696 |
blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied |
|
6697 |
}, |
|
6698 |
// Bilinear |
|
6699 |
{ |
|
6700 |
0, |
|
6701 |
blend_src_generic<CallbackSpans>, // Mono |
|
6702 |
blend_src_generic<CallbackSpans>, // MonoLsb |
|
6703 |
blend_src_generic<CallbackSpans>, // Indexed8 |
|
6704 |
blend_src_generic<CallbackSpans>, // RGB32 |
|
6705 |
blend_src_generic<CallbackSpans>, // ARGB32 |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6706 |
blend_src_generic<CallbackSpans>, // ARGB32_Premultiplied |
0 | 6707 |
blend_src_generic<CallbackSpans>, // RGB16 |
6708 |
blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6709 |
blend_src_generic<CallbackSpans>, // RGB666 |
|
6710 |
blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6711 |
blend_src_generic<CallbackSpans>, // RGB555 |
|
6712 |
blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6713 |
blend_src_generic<CallbackSpans>, // RGB888 |
|
6714 |
blend_src_generic<CallbackSpans>, // RGB444 |
|
6715 |
blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied |
|
6716 |
}, |
|
6717 |
// BilinearTiled |
|
6718 |
{ |
|
6719 |
0, |
|
6720 |
blend_src_generic<CallbackSpans>, // Mono |
|
6721 |
blend_src_generic<CallbackSpans>, // MonoLsb |
|
6722 |
blend_src_generic<CallbackSpans>, // Indexed8 |
|
6723 |
blend_src_generic<CallbackSpans>, // RGB32 |
|
6724 |
blend_src_generic<CallbackSpans>, // ARGB32 |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
6725 |
blend_src_generic<CallbackSpans>, // ARGB32_Premultiplied |
0 | 6726 |
blend_src_generic<CallbackSpans>, // RGB16 |
6727 |
blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied |
|
6728 |
blend_src_generic<CallbackSpans>, // RGB666 |
|
6729 |
blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied |
|
6730 |
blend_src_generic<CallbackSpans>, // RGB555 |
|
6731 |
blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied |
|
6732 |
blend_src_generic<CallbackSpans>, // RGB888 |
|
6733 |
blend_src_generic<CallbackSpans>, // RGB444 |
|
6734 |
blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied |
|
6735 |
} |
|
6736 |
}; |
|
6737 |
#endif // QT_NO_RASTERCALLBACKS |
|
6738 |
||
6739 |
void qBlendTexture(int count, const QSpan *spans, void *userData) |
|
6740 |
{ |
|
6741 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6742 |
ProcessSpans proc = processTextureSpans[getBlendType(data)][data->rasterBuffer->format]; |
|
6743 |
proc(count, spans, userData); |
|
6744 |
} |
|
6745 |
||
6746 |
#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS) |
|
6747 |
void qBlendTextureCallback(int count, const QSpan *spans, void *userData) |
|
6748 |
{ |
|
6749 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6750 |
ProcessSpans proc = processTextureSpansCallback[getBlendType(data)][data->rasterBuffer->format]; |
|
6751 |
proc(count, spans, userData); |
|
6752 |
} |
|
6753 |
#endif // QT_NO_RASTERCALLBACKS |
|
6754 |
||
6755 |
template <class DST> |
|
6756 |
inline void qt_bitmapblit_template(QRasterBuffer *rasterBuffer, |
|
6757 |
int x, int y, quint32 color, |
|
6758 |
const uchar *map, |
|
6759 |
int mapWidth, int mapHeight, int mapStride, |
|
6760 |
DST dummy = 0) |
|
6761 |
{ |
|
6762 |
Q_UNUSED(dummy); |
|
6763 |
const DST c = qt_colorConvert<DST, quint32>(color, 0); |
|
6764 |
DST *dest = reinterpret_cast<DST*>(rasterBuffer->scanLine(y)) + x; |
|
6765 |
const int destStride = rasterBuffer->bytesPerLine() / sizeof(DST); |
|
6766 |
||
6767 |
if (mapWidth > 8) { |
|
6768 |
while (mapHeight--) { |
|
6769 |
int x0 = 0; |
|
6770 |
int n = 0; |
|
6771 |
for (int x = 0; x < mapWidth; x += 8) { |
|
6772 |
uchar s = map[x >> 3]; |
|
6773 |
for (int i = 0; i < 8; ++i) { |
|
6774 |
if (s & 0x80) { |
|
6775 |
++n; |
|
6776 |
} else { |
|
6777 |
if (n) { |
|
6778 |
qt_memfill(dest + x0, c, n); |
|
6779 |
x0 += n + 1; |
|
6780 |
n = 0; |
|
6781 |
} else { |
|
6782 |
++x0; |
|
6783 |
} |
|
6784 |
if (!s) { |
|
6785 |
x0 += 8 - 1 - i; |
|
6786 |
break; |
|
6787 |
} |
|
6788 |
} |
|
6789 |
s <<= 1; |
|
6790 |
} |
|
6791 |
} |
|
6792 |
if (n) |
|
6793 |
qt_memfill(dest + x0, c, n); |
|
6794 |
dest += destStride; |
|
6795 |
map += mapStride; |
|
6796 |
} |
|
6797 |
} else { |
|
6798 |
while (mapHeight--) { |
|
6799 |
int x0 = 0; |
|
6800 |
int n = 0; |
|
6801 |
for (uchar s = *map; s; s <<= 1) { |
|
6802 |
if (s & 0x80) { |
|
6803 |
++n; |
|
6804 |
} else if (n) { |
|
6805 |
qt_memfill(dest + x0, c, n); |
|
6806 |
x0 += n + 1; |
|
6807 |
n = 0; |
|
6808 |
} else { |
|
6809 |
++x0; |
|
6810 |
} |
|
6811 |
} |
|
6812 |
if (n) |
|
6813 |
qt_memfill(dest + x0, c, n); |
|
6814 |
dest += destStride; |
|
6815 |
map += mapStride; |
|
6816 |
} |
|
6817 |
} |
|
6818 |
} |
|
6819 |
||
6820 |
static void qt_gradient_quint32(int count, const QSpan *spans, void *userData) |
|
6821 |
{ |
|
6822 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6823 |
||
6824 |
bool isVerticalGradient = |
|
6825 |
data->txop <= QTransform::TxScale && |
|
6826 |
data->type == QSpanData::LinearGradient && |
|
6827 |
data->gradient.linear.end.x == data->gradient.linear.origin.x; |
|
6828 |
||
6829 |
if (isVerticalGradient) { |
|
6830 |
LinearGradientValues linear; |
|
6831 |
getLinearGradientValues(&linear, data); |
|
6832 |
||
6833 |
CompositionFunctionSolid funcSolid = |
|
6834 |
functionForModeSolid[data->rasterBuffer->compositionMode]; |
|
6835 |
||
6836 |
/* |
|
6837 |
The logic for vertical gradient calculations is a mathematically |
|
6838 |
reduced copy of that in fetchLinearGradient() - which is basically: |
|
6839 |
||
6840 |
qreal ry = data->m22 * (y + 0.5) + data->dy; |
|
6841 |
qreal t = linear.dy*ry + linear.off; |
|
6842 |
t *= (GRADIENT_STOPTABLE_SIZE - 1); |
|
6843 |
quint32 color = |
|
6844 |
qt_gradient_pixel_fixed(&data->gradient, |
|
6845 |
int(t * FIXPT_SIZE)); |
|
6846 |
||
6847 |
This has then been converted to fixed point to improve performance. |
|
6848 |
*/ |
|
6849 |
const int gss = GRADIENT_STOPTABLE_SIZE - 1; |
|
6850 |
int yinc = int((linear.dy * data->m22 * gss) * FIXPT_SIZE); |
|
6851 |
int off = int((((linear.dy * (data->m22 * 0.5 + data->dy) + linear.off) * gss) * FIXPT_SIZE)); |
|
6852 |
||
6853 |
while (count--) { |
|
6854 |
int y = spans->y; |
|
6855 |
int x = spans->x; |
|
6856 |
||
6857 |
quint32 *dst = (quint32 *)(data->rasterBuffer->scanLine(y)) + x; |
|
6858 |
quint32 color = |
|
6859 |
qt_gradient_pixel_fixed(&data->gradient, yinc * y + off); |
|
6860 |
||
6861 |
funcSolid(dst, spans->len, color, spans->coverage); |
|
6862 |
++spans; |
|
6863 |
} |
|
6864 |
||
6865 |
} else { |
|
6866 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6867 |
} |
|
6868 |
} |
|
6869 |
||
6870 |
static void qt_gradient_quint16(int count, const QSpan *spans, void *userData) |
|
6871 |
{ |
|
6872 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
6873 |
||
6874 |
bool isVerticalGradient = |
|
6875 |
data->txop <= QTransform::TxScale && |
|
6876 |
data->type == QSpanData::LinearGradient && |
|
6877 |
data->gradient.linear.end.x == data->gradient.linear.origin.x; |
|
6878 |
||
6879 |
if (isVerticalGradient) { |
|
6880 |
||
6881 |
LinearGradientValues linear; |
|
6882 |
getLinearGradientValues(&linear, data); |
|
6883 |
||
6884 |
/* |
|
6885 |
The logic for vertical gradient calculations is a mathematically |
|
6886 |
reduced copy of that in fetchLinearGradient() - which is basically: |
|
6887 |
||
6888 |
qreal ry = data->m22 * (y + 0.5) + data->dy; |
|
6889 |
qreal t = linear.dy*ry + linear.off; |
|
6890 |
t *= (GRADIENT_STOPTABLE_SIZE - 1); |
|
6891 |
quint32 color = |
|
6892 |
qt_gradient_pixel_fixed(&data->gradient, |
|
6893 |
int(t * FIXPT_SIZE)); |
|
6894 |
||
6895 |
This has then been converted to fixed point to improve performance. |
|
6896 |
*/ |
|
6897 |
const int gss = GRADIENT_STOPTABLE_SIZE - 1; |
|
6898 |
int yinc = int((linear.dy * data->m22 * gss) * FIXPT_SIZE); |
|
6899 |
int off = int((((linear.dy * (data->m22 * 0.5 + data->dy) + linear.off) * gss) * FIXPT_SIZE)); |
|
6900 |
||
6901 |
uint oldColor = data->solid.color; |
|
6902 |
while (count--) { |
|
6903 |
int y = spans->y; |
|
6904 |
||
6905 |
quint32 color = qt_gradient_pixel_fixed(&data->gradient, yinc * y + off); |
|
6906 |
||
6907 |
data->solid.color = color; |
|
6908 |
blend_color_rgb16(1, spans, userData); |
|
6909 |
++spans; |
|
6910 |
} |
|
6911 |
data->solid.color = oldColor; |
|
6912 |
||
6913 |
} else { |
|
6914 |
blend_src_generic<RegularSpans>(count, spans, userData); |
|
6915 |
} |
|
6916 |
} |
|
6917 |
||
6918 |
inline static void qt_bitmapblit_quint32(QRasterBuffer *rasterBuffer, |
|
6919 |
int x, int y, quint32 color, |
|
6920 |
const uchar *map, |
|
6921 |
int mapWidth, int mapHeight, int mapStride) |
|
6922 |
{ |
|
6923 |
qt_bitmapblit_template<quint32>(rasterBuffer, x, y, color, |
|
6924 |
map, mapWidth, mapHeight, mapStride); |
|
6925 |
} |
|
6926 |
||
6927 |
inline static void qt_bitmapblit_quint16(QRasterBuffer *rasterBuffer, |
|
6928 |
int x, int y, quint32 color, |
|
6929 |
const uchar *map, |
|
6930 |
int mapWidth, int mapHeight, int mapStride) |
|
6931 |
{ |
|
6932 |
qt_bitmapblit_template<quint16>(rasterBuffer, x, y, color, |
|
6933 |
map, mapWidth, mapHeight, mapStride); |
|
6934 |
} |
|
6935 |
||
6936 |
||
6937 |
uchar qt_pow_rgb_gamma[256]; |
|
6938 |
uchar qt_pow_rgb_invgamma[256]; |
|
6939 |
||
6940 |
uint qt_pow_gamma[256]; |
|
6941 |
uchar qt_pow_invgamma[2048]; |
|
6942 |
||
6943 |
static void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer, |
|
6944 |
int x, int y, quint32 color, |
|
6945 |
const uchar *map, |
|
6946 |
int mapWidth, int mapHeight, int mapStride, |
|
6947 |
const QClipData *) |
|
6948 |
{ |
|
6949 |
const quint16 c = qt_colorConvert<quint16, quint32>(color, 0); |
|
6950 |
quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x; |
|
6951 |
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16); |
|
6952 |
||
6953 |
while (mapHeight--) { |
|
6954 |
for (int i = 0; i < mapWidth; ++i) { |
|
6955 |
const int coverage = map[i]; |
|
6956 |
||
6957 |
if (coverage == 0) { |
|
6958 |
// nothing |
|
6959 |
} else if (coverage == 255) { |
|
6960 |
dest[i] = c; |
|
6961 |
} else { |
|
6962 |
int ialpha = 255 - coverage; |
|
6963 |
dest[i] = BYTE_MUL_RGB16(c, coverage) |
|
6964 |
+ BYTE_MUL_RGB16(dest[i], ialpha); |
|
6965 |
} |
|
6966 |
} |
|
6967 |
dest += destStride; |
|
6968 |
map += mapStride; |
|
6969 |
} |
|
6970 |
} |
|
6971 |
||
6972 |
void qt_build_pow_tables() { |
|
6973 |
qreal smoothing = qreal(1.7); |
|
6974 |
||
6975 |
#ifdef Q_WS_MAC |
|
6976 |
// decided by testing a few things on an iMac, should probably get this from the |
|
6977 |
// system... |
|
6978 |
smoothing = 2.0; |
|
6979 |
#endif |
|
6980 |
||
6981 |
#ifdef Q_WS_WIN |
|
6982 |
int winSmooth; |
|
6983 |
if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) |
|
6984 |
smoothing = winSmooth / 1000.0; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6985 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6986 |
// Safeguard ourselves against corrupt registry values... |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6987 |
if (smoothing > 5 || smoothing < 1) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6988 |
smoothing = 1.4; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
6989 |
|
0 | 6990 |
#endif |
6991 |
||
6992 |
#ifdef Q_WS_X11 |
|
6993 |
Q_UNUSED(smoothing); |
|
6994 |
for (int i=0; i<256; ++i) { |
|
6995 |
qt_pow_rgb_gamma[i] = uchar(i); |
|
6996 |
qt_pow_rgb_invgamma[i] = uchar(i); |
|
6997 |
} |
|
6998 |
#else |
|
6999 |
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
|
7000 |
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
|
7001 |
qt_pow_rgb_invgamma[i] = uchar(qRound(qPow(i / qreal(255.), 1 / smoothing) * 255)); |
0 | 7002 |
} |
7003 |
#endif |
|
7004 |
||
7005 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
7006 |
const qreal gray_gamma = 2.31; |
|
7007 |
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
|
7008 |
qt_pow_gamma[i] = uint(qRound(qPow(i / qreal(255.), gray_gamma) * 2047)); |
0 | 7009 |
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
|
7010 |
qt_pow_invgamma[i] = uchar(qRound(qPow(i / 2047.0, 1 / gray_gamma) * 255)); |
0 | 7011 |
#endif |
7012 |
} |
|
7013 |
||
7014 |
static inline void rgbBlendPixel(quint32 *dst, int coverage, int sr, int sg, int sb) |
|
7015 |
{ |
|
7016 |
// Do a gray alphablend... |
|
7017 |
int da = qAlpha(*dst); |
|
7018 |
int dr = qRed(*dst); |
|
7019 |
int dg = qGreen(*dst); |
|
7020 |
int db = qBlue(*dst); |
|
7021 |
||
7022 |
if (da != 255 |
|
7023 |
#if defined (Q_WS_WIN) |
|
7024 |
// Work around GDI messing up alpha channel |
|
7025 |
&& qRed(*dst) <= da && qBlue(*dst) <= da && qGreen(*dst) <= da |
|
7026 |
#endif |
|
7027 |
) { |
|
7028 |
||
7029 |
int a = qGray(coverage); |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
7030 |
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
|
7031 |
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
|
7032 |
sb = qt_div_255(qt_pow_rgb_invgamma[sb] * a); |
0 | 7033 |
|
7034 |
int ia = 255 - a; |
|
7035 |
dr = qt_div_255(dr * ia); |
|
7036 |
dg = qt_div_255(dg * ia); |
|
7037 |
db = qt_div_255(db * ia); |
|
7038 |
||
7039 |
*dst = ((a + qt_div_255((255 - a) * da)) << 24) |
|
7040 |
| ((sr + dr) << 16) |
|
7041 |
| ((sg + dg) << 8) |
|
7042 |
| ((sb + db)); |
|
7043 |
return; |
|
7044 |
} |
|
7045 |
||
7046 |
int mr = qRed(coverage); |
|
7047 |
int mg = qGreen(coverage); |
|
7048 |
int mb = qBlue(coverage); |
|
7049 |
||
7050 |
dr = qt_pow_rgb_gamma[dr]; |
|
7051 |
dg = qt_pow_rgb_gamma[dg]; |
|
7052 |
db = qt_pow_rgb_gamma[db]; |
|
7053 |
||
7054 |
int nr = qt_div_255((sr - dr) * mr) + dr; |
|
7055 |
int ng = qt_div_255((sg - dg) * mg) + dg; |
|
7056 |
int nb = qt_div_255((sb - db) * mb) + db; |
|
7057 |
||
7058 |
nr = qt_pow_rgb_invgamma[nr]; |
|
7059 |
ng = qt_pow_rgb_invgamma[ng]; |
|
7060 |
nb = qt_pow_rgb_invgamma[nb]; |
|
7061 |
||
7062 |
*dst = qRgb(nr, ng, nb); |
|
7063 |
} |
|
7064 |
||
7065 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
7066 |
static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, int sb) |
|
7067 |
{ |
|
7068 |
// Do a gammacorrected gray alphablend... |
|
7069 |
int dr = qRed(*dst); |
|
7070 |
int dg = qGreen(*dst); |
|
7071 |
int db = qBlue(*dst); |
|
7072 |
||
7073 |
dr = qt_pow_gamma[dr]; |
|
7074 |
dg = qt_pow_gamma[dg]; |
|
7075 |
db = qt_pow_gamma[db]; |
|
7076 |
||
7077 |
int alpha = coverage; |
|
7078 |
int ialpha = 255 - alpha; |
|
7079 |
int nr = (sr * alpha + ialpha * dr) / 255; |
|
7080 |
int ng = (sg * alpha + ialpha * dg) / 255; |
|
7081 |
int nb = (sb * alpha + ialpha * db) / 255; |
|
7082 |
||
7083 |
nr = qt_pow_invgamma[nr]; |
|
7084 |
ng = qt_pow_invgamma[ng]; |
|
7085 |
nb = qt_pow_invgamma[nb]; |
|
7086 |
||
7087 |
*dst = qRgb(nr, ng, nb); |
|
7088 |
} |
|
7089 |
#endif |
|
7090 |
||
7091 |
static void qt_alphamapblit_quint32(QRasterBuffer *rasterBuffer, |
|
7092 |
int x, int y, quint32 color, |
|
7093 |
const uchar *map, |
|
7094 |
int mapWidth, int mapHeight, int mapStride, |
|
7095 |
const QClipData *clip) |
|
7096 |
{ |
|
7097 |
const quint32 c = color; |
|
7098 |
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32); |
|
7099 |
||
7100 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
7101 |
int sr = qRed(color); |
|
7102 |
int sg = qGreen(color); |
|
7103 |
int sb = qBlue(color); |
|
7104 |
||
7105 |
sr = qt_pow_gamma[sr]; |
|
7106 |
sg = qt_pow_gamma[sg]; |
|
7107 |
sb = qt_pow_gamma[sb]; |
|
7108 |
bool opaque_src = (qAlpha(color) == 255); |
|
7109 |
#endif |
|
7110 |
||
7111 |
if (!clip) { |
|
7112 |
quint32 *dest = reinterpret_cast<quint32*>(rasterBuffer->scanLine(y)) + x; |
|
7113 |
while (mapHeight--) { |
|
7114 |
for (int i = 0; i < mapWidth; ++i) { |
|
7115 |
const int coverage = map[i]; |
|
7116 |
||
7117 |
if (coverage == 0) { |
|
7118 |
// nothing |
|
7119 |
} else if (coverage == 255) { |
|
7120 |
dest[i] = c; |
|
7121 |
} else { |
|
7122 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
7123 |
if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && opaque_src |
|
7124 |
&& qAlpha(dest[i]) == 255) { |
|
7125 |
grayBlendPixel(dest+i, coverage, sr, sg, sb); |
|
7126 |
} else |
|
7127 |
#endif |
|
7128 |
{ |
|
7129 |
int ialpha = 255 - coverage; |
|
7130 |
dest[i] = INTERPOLATE_PIXEL_255(c, coverage, dest[i], ialpha); |
|
7131 |
} |
|
7132 |
} |
|
7133 |
} |
|
7134 |
dest += destStride; |
|
7135 |
map += mapStride; |
|
7136 |
} |
|
7137 |
} else { |
|
7138 |
int bottom = qMin(y + mapHeight, rasterBuffer->height()); |
|
7139 |
||
7140 |
int top = qMax(y, 0); |
|
7141 |
map += (top - y) * mapStride; |
|
7142 |
||
7143 |
const_cast<QClipData *>(clip)->initialize(); |
|
7144 |
for (int yp = top; yp<bottom; ++yp) { |
|
7145 |
const QClipData::ClipLine &line = clip->m_clipLines[yp]; |
|
7146 |
||
7147 |
quint32 *dest = reinterpret_cast<quint32 *>(rasterBuffer->scanLine(yp)); |
|
7148 |
||
7149 |
for (int i=0; i<line.count; ++i) { |
|
7150 |
const QSpan &clip = line.spans[i]; |
|
7151 |
||
7152 |
int start = qMax<int>(x, clip.x); |
|
7153 |
int end = qMin<int>(x + mapWidth, clip.x + clip.len); |
|
7154 |
||
7155 |
for (int xp=start; xp<end; ++xp) { |
|
7156 |
const int coverage = map[xp - x]; |
|
7157 |
||
7158 |
if (coverage == 0) { |
|
7159 |
// nothing |
|
7160 |
} else if (coverage == 255) { |
|
7161 |
dest[xp] = c; |
|
7162 |
} else { |
|
7163 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
7164 |
if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && opaque_src |
|
7165 |
&& qAlpha(dest[xp]) == 255) { |
|
7166 |
grayBlendPixel(dest+xp, coverage, sr, sg, sb); |
|
7167 |
} else |
|
7168 |
#endif |
|
7169 |
{ |
|
7170 |
int ialpha = 255 - coverage; |
|
7171 |
dest[xp] = INTERPOLATE_PIXEL_255(c, coverage, dest[xp], ialpha); |
|
7172 |
} |
|
7173 |
} |
|
7174 |
||
7175 |
} // for (i -> line.count) |
|
7176 |
} // for (yp -> bottom) |
|
7177 |
map += mapStride; |
|
7178 |
} |
|
7179 |
} |
|
7180 |
} |
|
7181 |
||
7182 |
static void qt_alphargbblit_quint32(QRasterBuffer *rasterBuffer, |
|
7183 |
int x, int y, quint32 color, |
|
7184 |
const uint *src, int mapWidth, int mapHeight, int srcStride, |
|
7185 |
const QClipData *clip) |
|
7186 |
{ |
|
7187 |
const quint32 c = color; |
|
7188 |
||
7189 |
int sr = qRed(color); |
|
7190 |
int sg = qGreen(color); |
|
7191 |
int sb = qBlue(color); |
|
7192 |
int sa = qAlpha(color); |
|
7193 |
||
7194 |
sr = qt_pow_rgb_gamma[sr]; |
|
7195 |
sg = qt_pow_rgb_gamma[sg]; |
|
7196 |
sb = qt_pow_rgb_gamma[sb]; |
|
7197 |
||
7198 |
if (sa == 0) |
|
7199 |
return; |
|
7200 |
||
7201 |
if (!clip) { |
|
7202 |
quint32 *dst = reinterpret_cast<quint32*>(rasterBuffer->scanLine(y)) + x; |
|
7203 |
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32); |
|
7204 |
while (mapHeight--) { |
|
7205 |
for (int i = 0; i < mapWidth; ++i) { |
|
7206 |
const uint coverage = src[i]; |
|
7207 |
if (coverage == 0xffffffff) { |
|
7208 |
dst[i] = c; |
|
7209 |
} else if (coverage != 0xff000000) { |
|
7210 |
rgbBlendPixel(dst+i, coverage, sr, sg, sb); |
|
7211 |
} |
|
7212 |
} |
|
7213 |
||
7214 |
dst += destStride; |
|
7215 |
src += srcStride; |
|
7216 |
} |
|
7217 |
} else { |
|
7218 |
int bottom = qMin(y + mapHeight, rasterBuffer->height()); |
|
7219 |
||
7220 |
int top = qMax(y, 0); |
|
7221 |
src += (top - y) * srcStride; |
|
7222 |
||
7223 |
const_cast<QClipData *>(clip)->initialize(); |
|
7224 |
for (int yp = top; yp<bottom; ++yp) { |
|
7225 |
const QClipData::ClipLine &line = clip->m_clipLines[yp]; |
|
7226 |
||
7227 |
quint32 *dst = reinterpret_cast<quint32 *>(rasterBuffer->scanLine(yp)); |
|
7228 |
||
7229 |
for (int i=0; i<line.count; ++i) { |
|
7230 |
const QSpan &clip = line.spans[i]; |
|
7231 |
||
7232 |
int start = qMax<int>(x, clip.x); |
|
7233 |
int end = qMin<int>(x + mapWidth, clip.x + clip.len); |
|
7234 |
||
7235 |
for (int xp=start; xp<end; ++xp) { |
|
7236 |
const uint coverage = src[xp - x]; |
|
7237 |
if (coverage == 0xffffffff) { |
|
7238 |
dst[xp] = c; |
|
7239 |
} else if (coverage != 0xff000000) { |
|
7240 |
rgbBlendPixel(dst+xp, coverage, sr, sg, sb); |
|
7241 |
} |
|
7242 |
} |
|
7243 |
} // for (i -> line.count) |
|
7244 |
src += srcStride; |
|
7245 |
} // for (yp -> bottom) |
|
7246 |
||
7247 |
} |
|
7248 |
} |
|
7249 |
||
7250 |
template <class T> |
|
7251 |
inline void qt_rectfill_template(QRasterBuffer *rasterBuffer, |
|
7252 |
int x, int y, int width, int height, |
|
7253 |
quint32 color, T dummy = 0) |
|
7254 |
{ |
|
7255 |
Q_UNUSED(dummy); |
|
7256 |
||
7257 |
qt_rectfill<T>(reinterpret_cast<T*>(rasterBuffer->buffer()), |
|
7258 |
qt_colorConvert<T, quint32p>(quint32p::fromRawData(color), 0), |
|
7259 |
x, y, width, height, rasterBuffer->bytesPerLine()); |
|
7260 |
} |
|
7261 |
||
7262 |
#define QT_RECTFILL(T) \ |
|
7263 |
inline static void qt_rectfill_##T(QRasterBuffer *rasterBuffer, \ |
|
7264 |
int x, int y, int width, int height, \ |
|
7265 |
quint32 color) \ |
|
7266 |
{ \ |
|
7267 |
qt_rectfill_template<T>(rasterBuffer, x, y, width, height, color); \ |
|
7268 |
} |
|
7269 |
||
7270 |
QT_RECTFILL(quint32) |
|
7271 |
QT_RECTFILL(quint16) |
|
7272 |
QT_RECTFILL(qargb8565) |
|
7273 |
QT_RECTFILL(qrgb666) |
|
7274 |
QT_RECTFILL(qargb6666) |
|
7275 |
QT_RECTFILL(qrgb555) |
|
7276 |
QT_RECTFILL(qargb8555) |
|
7277 |
QT_RECTFILL(qrgb888) |
|
7278 |
QT_RECTFILL(qrgb444) |
|
7279 |
QT_RECTFILL(qargb4444) |
|
7280 |
#undef QT_RECTFILL |
|
7281 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7282 |
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
|
7283 |
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
|
7284 |
quint32 color) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7285 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7286 |
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
|
7287 |
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
|
7288 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7289 |
|
0 | 7290 |
|
7291 |
// Map table for destination image format. Contains function pointers |
|
7292 |
// for blends of various types unto the destination |
|
7293 |
||
7294 |
DrawHelper qDrawHelper[QImage::NImageFormats] = |
|
7295 |
{ |
|
7296 |
// Format_Invalid, |
|
7297 |
{ 0, 0, 0, 0, 0, 0 }, |
|
7298 |
// Format_Mono, |
|
7299 |
{ |
|
7300 |
blend_color_generic, |
|
7301 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7302 |
0, 0, 0, 0 |
|
7303 |
}, |
|
7304 |
// Format_MonoLSB, |
|
7305 |
{ |
|
7306 |
blend_color_generic, |
|
7307 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7308 |
0, 0, 0, 0 |
|
7309 |
}, |
|
7310 |
// Format_Indexed8, |
|
7311 |
{ |
|
7312 |
blend_color_generic, |
|
7313 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7314 |
0, 0, 0, 0 |
|
7315 |
}, |
|
7316 |
// Format_RGB32, |
|
7317 |
{ |
|
7318 |
blend_color_argb, |
|
7319 |
qt_gradient_quint32, |
|
7320 |
qt_bitmapblit_quint32, |
|
7321 |
qt_alphamapblit_quint32, |
|
7322 |
qt_alphargbblit_quint32, |
|
7323 |
qt_rectfill_quint32 |
|
7324 |
}, |
|
7325 |
// Format_ARGB32, |
|
7326 |
{ |
|
7327 |
blend_color_generic, |
|
7328 |
qt_gradient_quint32, |
|
7329 |
qt_bitmapblit_quint32, |
|
7330 |
qt_alphamapblit_quint32, |
|
7331 |
qt_alphargbblit_quint32, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7332 |
qt_rectfill_nonpremul_quint32 |
0 | 7333 |
}, |
7334 |
// Format_ARGB32_Premultiplied |
|
7335 |
{ |
|
7336 |
blend_color_argb, |
|
7337 |
qt_gradient_quint32, |
|
7338 |
qt_bitmapblit_quint32, |
|
7339 |
qt_alphamapblit_quint32, |
|
7340 |
qt_alphargbblit_quint32, |
|
7341 |
qt_rectfill_quint32 |
|
7342 |
}, |
|
7343 |
// Format_RGB16 |
|
7344 |
{ |
|
7345 |
blend_color_rgb16, |
|
7346 |
qt_gradient_quint16, |
|
7347 |
qt_bitmapblit_quint16, |
|
7348 |
qt_alphamapblit_quint16, |
|
7349 |
0, |
|
7350 |
qt_rectfill_quint16 |
|
7351 |
}, |
|
7352 |
// Format_ARGB8565_Premultiplied |
|
7353 |
{ |
|
7354 |
SPANFUNC_POINTER_BLENDCOLOR(qargb8565), |
|
7355 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7356 |
0, 0, 0, |
|
7357 |
qt_rectfill_qargb8565 |
|
7358 |
}, |
|
7359 |
// Format_RGB666 |
|
7360 |
{ |
|
7361 |
SPANFUNC_POINTER_BLENDCOLOR(qrgb666), |
|
7362 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7363 |
0, 0, 0, |
|
7364 |
qt_rectfill_qrgb666 |
|
7365 |
}, |
|
7366 |
// Format_ARGB6666_Premultiplied |
|
7367 |
{ |
|
7368 |
SPANFUNC_POINTER_BLENDCOLOR(qargb6666), |
|
7369 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7370 |
0, 0, 0, |
|
7371 |
qt_rectfill_qargb6666 |
|
7372 |
}, |
|
7373 |
// Format_RGB555 |
|
7374 |
{ |
|
7375 |
SPANFUNC_POINTER_BLENDCOLOR(qrgb555), |
|
7376 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7377 |
0, 0, 0, |
|
7378 |
qt_rectfill_qrgb555 |
|
7379 |
}, |
|
7380 |
// Format_ARGB8555_Premultiplied |
|
7381 |
{ |
|
7382 |
SPANFUNC_POINTER_BLENDCOLOR(qargb8555), |
|
7383 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7384 |
0, 0, 0, |
|
7385 |
qt_rectfill_qargb8555 |
|
7386 |
}, |
|
7387 |
// Format_RGB888 |
|
7388 |
{ |
|
7389 |
SPANFUNC_POINTER_BLENDCOLOR(qrgb888), |
|
7390 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7391 |
0, 0, 0, |
|
7392 |
qt_rectfill_qrgb888 |
|
7393 |
}, |
|
7394 |
// Format_RGB444 |
|
7395 |
{ |
|
7396 |
SPANFUNC_POINTER_BLENDCOLOR(qrgb444), |
|
7397 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7398 |
0, 0, 0, |
|
7399 |
qt_rectfill_qrgb444 |
|
7400 |
}, |
|
7401 |
// Format_ARGB4444_Premultiplied |
|
7402 |
{ |
|
7403 |
SPANFUNC_POINTER_BLENDCOLOR(qargb4444), |
|
7404 |
SPANFUNC_POINTER(blend_src_generic, RegularSpans), |
|
7405 |
0, 0, 0, |
|
7406 |
qt_rectfill_qargb4444 |
|
7407 |
} |
|
7408 |
}; |
|
7409 |
||
7410 |
#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS) |
|
7411 |
DrawHelper qDrawHelperCallback[QImage::NImageFormats] = |
|
7412 |
{ |
|
7413 |
// Format_Invalid, |
|
7414 |
{ 0, 0, 0, 0, 0, 0 }, |
|
7415 |
// Format_Mono, |
|
7416 |
{ |
|
7417 |
blend_color_generic_callback, |
|
7418 |
blend_src_generic<CallbackSpans>, |
|
7419 |
0, 0, 0, 0 |
|
7420 |
}, |
|
7421 |
// Format_MonoLSB, |
|
7422 |
{ |
|
7423 |
blend_color_generic_callback, |
|
7424 |
blend_src_generic<CallbackSpans>, |
|
7425 |
0, 0, 0, 0 |
|
7426 |
}, |
|
7427 |
// Format_Indexed8, |
|
7428 |
{ |
|
7429 |
blend_color_generic_callback, |
|
7430 |
blend_src_generic<CallbackSpans>, |
|
7431 |
0, 0, 0, 0 |
|
7432 |
}, |
|
7433 |
// Format_RGB32, |
|
7434 |
{ |
|
7435 |
blend_color_generic_callback, |
|
7436 |
blend_src_generic<CallbackSpans>, |
|
7437 |
0, 0, 0, 0 |
|
7438 |
}, |
|
7439 |
// Format_ARGB32, |
|
7440 |
{ |
|
7441 |
blend_color_generic_callback, |
|
7442 |
blend_src_generic<CallbackSpans>, |
|
7443 |
0, 0, 0, 0 |
|
7444 |
}, |
|
7445 |
// Format_ARGB32_Premultiplied |
|
7446 |
{ |
|
7447 |
blend_color_generic_callback, |
|
7448 |
blend_src_generic<CallbackSpans>, |
|
7449 |
0, 0, 0, 0 |
|
7450 |
}, |
|
7451 |
// Format_RGB16 |
|
7452 |
{ |
|
7453 |
blend_color_generic_callback, |
|
7454 |
blend_src_generic<CallbackSpans>, |
|
7455 |
0, 0, 0, 0 |
|
7456 |
}, |
|
7457 |
// Format_ARGB8565_Premultiplied |
|
7458 |
{ |
|
7459 |
blend_color_generic_callback, |
|
7460 |
blend_src_generic<CallbackSpans>, |
|
7461 |
0, 0, 0, 0 |
|
7462 |
}, |
|
7463 |
// Format_RGB666 |
|
7464 |
{ |
|
7465 |
blend_color_generic_callback, |
|
7466 |
blend_src_generic<CallbackSpans>, |
|
7467 |
0, 0, 0, 0 |
|
7468 |
}, |
|
7469 |
// Format_ARGB6666_Premultiplied |
|
7470 |
{ |
|
7471 |
blend_color_generic_callback, |
|
7472 |
blend_src_generic<CallbackSpans>, |
|
7473 |
0, 0, 0, 0 |
|
7474 |
}, |
|
7475 |
// Format_RGB555 |
|
7476 |
{ |
|
7477 |
blend_color_generic_callback, |
|
7478 |
blend_src_generic<CallbackSpans>, |
|
7479 |
0, 0, 0, 0 |
|
7480 |
}, |
|
7481 |
// Format_ARGB8555_Premultiplied |
|
7482 |
{ |
|
7483 |
blend_color_generic_callback, |
|
7484 |
blend_src_generic<CallbackSpans>, |
|
7485 |
0, 0, 0, 0 |
|
7486 |
}, |
|
7487 |
// Format_RGB888 |
|
7488 |
{ |
|
7489 |
blend_color_generic_callback, |
|
7490 |
blend_src_generic<CallbackSpans>, |
|
7491 |
0, 0, 0, 0 |
|
7492 |
}, |
|
7493 |
// Format_RGB444 |
|
7494 |
{ |
|
7495 |
blend_color_generic_callback, |
|
7496 |
blend_src_generic<CallbackSpans>, |
|
7497 |
0, 0, 0, 0 |
|
7498 |
}, |
|
7499 |
// Format_ARGB4444_Premultiplied |
|
7500 |
{ |
|
7501 |
blend_color_generic_callback, |
|
7502 |
blend_src_generic<CallbackSpans>, |
|
7503 |
0, 0, 0, 0 |
|
7504 |
} |
|
7505 |
}; |
|
7506 |
#endif |
|
7507 |
||
7508 |
||
7509 |
||
7510 |
#if defined(Q_CC_MSVC) && !defined(_MIPS_) |
|
7511 |
template <class DST, class SRC> |
|
7512 |
inline void qt_memfill_template(DST *dest, SRC color, int count) |
|
7513 |
{ |
|
7514 |
const DST c = qt_colorConvert<DST, SRC>(color, 0); |
|
7515 |
while (count--) |
|
7516 |
*dest++ = c; |
|
7517 |
} |
|
7518 |
||
7519 |
#else |
|
7520 |
||
7521 |
template <class DST, class SRC> |
|
7522 |
inline void qt_memfill_template(DST *dest, SRC color, int count) |
|
7523 |
{ |
|
7524 |
const DST c = qt_colorConvert<DST, SRC>(color, 0); |
|
7525 |
int n = (count + 7) / 8; |
|
7526 |
switch (count & 0x07) |
|
7527 |
{ |
|
7528 |
case 0: do { *dest++ = c; |
|
7529 |
case 7: *dest++ = c; |
|
7530 |
case 6: *dest++ = c; |
|
7531 |
case 5: *dest++ = c; |
|
7532 |
case 4: *dest++ = c; |
|
7533 |
case 3: *dest++ = c; |
|
7534 |
case 2: *dest++ = c; |
|
7535 |
case 1: *dest++ = c; |
|
7536 |
} while (--n > 0); |
|
7537 |
} |
|
7538 |
} |
|
7539 |
||
7540 |
template <> |
|
7541 |
inline void qt_memfill_template(quint16 *dest, quint16 value, int count) |
|
7542 |
{ |
|
7543 |
if (count < 3) { |
|
7544 |
switch (count) { |
|
7545 |
case 2: *dest++ = value; |
|
7546 |
case 1: *dest = value; |
|
7547 |
} |
|
7548 |
return; |
|
7549 |
} |
|
7550 |
||
7551 |
const int align = (quintptr)(dest) & 0x3; |
|
7552 |
switch (align) { |
|
7553 |
case 2: *dest++ = value; --count; |
|
7554 |
} |
|
7555 |
||
7556 |
const quint32 value32 = (value << 16) | value; |
|
7557 |
qt_memfill(reinterpret_cast<quint32*>(dest), value32, count / 2); |
|
7558 |
if (count & 0x1) |
|
7559 |
dest[count - 1] = value; |
|
7560 |
} |
|
7561 |
#endif |
|
7562 |
||
7563 |
static void qt_memfill_quint16(quint16 *dest, quint16 color, int count) |
|
7564 |
{ |
|
7565 |
qt_memfill_template<quint16, quint16>(dest, color, count); |
|
7566 |
} |
|
7567 |
||
7568 |
typedef void (*qt_memfill32_func)(quint32 *dest, quint32 value, int count); |
|
7569 |
typedef void (*qt_memfill16_func)(quint16 *dest, quint16 value, int count); |
|
7570 |
static void qt_memfill32_setup(quint32 *dest, quint32 value, int count); |
|
7571 |
static void qt_memfill16_setup(quint16 *dest, quint16 value, int count); |
|
7572 |
||
7573 |
qt_memfill32_func qt_memfill32 = qt_memfill32_setup; |
|
7574 |
qt_memfill16_func qt_memfill16 = qt_memfill16_setup; |
|
7575 |
||
7576 |
#if defined(Q_CC_RVCT) && defined(QT_HAVE_ARMV6) |
|
7577 |
// Move these to qdrawhelper_arm.c when all |
|
7578 |
// functions are implemented using arm assembly. |
|
7579 |
static CompositionFunctionSolid qt_functionForModeSolid_ARMv6[numCompositionFunctions] = { |
|
7580 |
comp_func_solid_SourceOver, |
|
7581 |
comp_func_solid_DestinationOver, |
|
7582 |
comp_func_solid_Clear, |
|
7583 |
comp_func_solid_Source, |
|
7584 |
comp_func_solid_Destination, |
|
7585 |
comp_func_solid_SourceIn, |
|
7586 |
comp_func_solid_DestinationIn, |
|
7587 |
comp_func_solid_SourceOut, |
|
7588 |
comp_func_solid_DestinationOut, |
|
7589 |
comp_func_solid_SourceAtop, |
|
7590 |
comp_func_solid_DestinationAtop, |
|
7591 |
comp_func_solid_XOR, |
|
7592 |
comp_func_solid_Plus, |
|
7593 |
comp_func_solid_Multiply, |
|
7594 |
comp_func_solid_Screen, |
|
7595 |
comp_func_solid_Overlay, |
|
7596 |
comp_func_solid_Darken, |
|
7597 |
comp_func_solid_Lighten, |
|
7598 |
comp_func_solid_ColorDodge, |
|
7599 |
comp_func_solid_ColorBurn, |
|
7600 |
comp_func_solid_HardLight, |
|
7601 |
comp_func_solid_SoftLight, |
|
7602 |
comp_func_solid_Difference, |
|
7603 |
comp_func_solid_Exclusion, |
|
7604 |
rasterop_solid_SourceOrDestination, |
|
7605 |
rasterop_solid_SourceAndDestination, |
|
7606 |
rasterop_solid_SourceXorDestination, |
|
7607 |
rasterop_solid_NotSourceAndNotDestination, |
|
7608 |
rasterop_solid_NotSourceOrNotDestination, |
|
7609 |
rasterop_solid_NotSourceXorDestination, |
|
7610 |
rasterop_solid_NotSource, |
|
7611 |
rasterop_solid_NotSourceAndDestination, |
|
7612 |
rasterop_solid_SourceAndNotDestination |
|
7613 |
}; |
|
7614 |
||
7615 |
static CompositionFunction qt_functionForMode_ARMv6[numCompositionFunctions] = { |
|
7616 |
comp_func_SourceOver_armv6, |
|
7617 |
comp_func_DestinationOver, |
|
7618 |
comp_func_Clear, |
|
7619 |
comp_func_Source_armv6, |
|
7620 |
comp_func_Destination, |
|
7621 |
comp_func_SourceIn, |
|
7622 |
comp_func_DestinationIn, |
|
7623 |
comp_func_SourceOut, |
|
7624 |
comp_func_DestinationOut, |
|
7625 |
comp_func_SourceAtop, |
|
7626 |
comp_func_DestinationAtop, |
|
7627 |
comp_func_XOR, |
|
7628 |
comp_func_Plus, |
|
7629 |
comp_func_Multiply, |
|
7630 |
comp_func_Screen, |
|
7631 |
comp_func_Overlay, |
|
7632 |
comp_func_Darken, |
|
7633 |
comp_func_Lighten, |
|
7634 |
comp_func_ColorDodge, |
|
7635 |
comp_func_ColorBurn, |
|
7636 |
comp_func_HardLight, |
|
7637 |
comp_func_SoftLight, |
|
7638 |
comp_func_Difference, |
|
7639 |
comp_func_Exclusion, |
|
7640 |
rasterop_SourceOrDestination, |
|
7641 |
rasterop_SourceAndDestination, |
|
7642 |
rasterop_SourceXorDestination, |
|
7643 |
rasterop_NotSourceAndNotDestination, |
|
7644 |
rasterop_NotSourceOrNotDestination, |
|
7645 |
rasterop_NotSourceXorDestination, |
|
7646 |
rasterop_NotSource, |
|
7647 |
rasterop_NotSourceAndDestination, |
|
7648 |
rasterop_SourceAndNotDestination |
|
7649 |
}; |
|
7650 |
||
7651 |
static void qt_blend_color_argb_armv6(int count, const QSpan *spans, void *userData) |
|
7652 |
{ |
|
7653 |
QSpanData *data = reinterpret_cast<QSpanData *>(userData); |
|
7654 |
||
7655 |
CompositionFunctionSolid func = qt_functionForModeSolid_ARMv6[data->rasterBuffer->compositionMode]; |
|
7656 |
while (count--) { |
|
7657 |
uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; |
|
7658 |
func(target, spans->len, data->solid.color, spans->coverage); |
|
7659 |
++spans; |
|
7660 |
} |
|
7661 |
} |
|
7662 |
||
7663 |
#endif // Q_CC_RVCT && QT_HAVE_ARMV6 |
|
7664 |
||
7665 |
||
7666 |
void qInitDrawhelperAsm() |
|
7667 |
{ |
|
7668 |
||
7669 |
qt_memfill32 = qt_memfill_template<quint32, quint32>; |
|
7670 |
qt_memfill16 = qt_memfill_quint16; //qt_memfill_template<quint16, quint16>; |
|
7671 |
||
7672 |
CompositionFunction *functionForModeAsm = 0; |
|
7673 |
CompositionFunctionSolid *functionForModeSolidAsm = 0; |
|
7674 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7675 |
const uint features = qDetectCPUFeatures(); |
0 | 7676 |
if (false) { |
7677 |
#ifdef QT_HAVE_SSE2 |
|
7678 |
} else if (features & SSE2) { |
|
7679 |
qt_memfill32 = qt_memfill32_sse2; |
|
7680 |
qt_memfill16 = qt_memfill16_sse2; |
|
7681 |
qDrawHelper[QImage::Format_RGB32].bitmapBlit = qt_bitmapblit32_sse2; |
|
7682 |
qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_sse2; |
|
7683 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2; |
|
7684 |
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse2; |
|
7685 |
#endif |
|
7686 |
#ifdef QT_HAVE_SSE |
|
7687 |
} else if (features & SSE) { |
|
7688 |
// qt_memfill32 = qt_memfill32_sse; |
|
7689 |
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse; |
|
7690 |
#ifdef QT_HAVE_3DNOW |
|
7691 |
if (features & MMX3DNOW) { |
|
7692 |
qt_memfill32 = qt_memfill32_sse3dnow; |
|
7693 |
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse3dnow; |
|
7694 |
} |
|
7695 |
#endif |
|
7696 |
#endif // SSE |
|
7697 |
#if defined(QT_HAVE_MMXEXT) && defined(QT_HAVE_SSE) |
|
7698 |
} else if (features & MMXEXT) { |
|
7699 |
qt_memfill32 = qt_memfill32_sse; |
|
7700 |
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse; |
|
7701 |
# ifdef QT_HAVE_3DNOW |
|
7702 |
if (features & MMX3DNOW) { |
|
7703 |
qt_memfill32 = qt_memfill32_sse3dnow; |
|
7704 |
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse3dnow; |
|
7705 |
} |
|
7706 |
# endif // 3DNOW |
|
7707 |
#endif // MMXEXT |
|
7708 |
} |
|
7709 |
#ifdef QT_HAVE_MMX |
|
7710 |
if (features & MMX) { |
|
7711 |
functionForModeAsm = qt_functionForMode_MMX; |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7712 |
|
0 | 7713 |
functionForModeSolidAsm = qt_functionForModeSolid_MMX; |
7714 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_mmx; |
|
7715 |
#ifdef QT_HAVE_3DNOW |
|
7716 |
if (features & MMX3DNOW) { |
|
7717 |
functionForModeAsm = qt_functionForMode_MMX3DNOW; |
|
7718 |
functionForModeSolidAsm = qt_functionForModeSolid_MMX3DNOW; |
|
7719 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_mmx3dnow; |
|
7720 |
} |
|
7721 |
#endif // 3DNOW |
|
7722 |
||
7723 |
extern void qt_blend_rgb32_on_rgb32_mmx(uchar *destPixels, int dbpl, |
|
7724 |
const uchar *srcPixels, int sbpl, |
|
7725 |
int w, int h, |
|
7726 |
int const_alpha); |
|
7727 |
extern void qt_blend_argb32_on_argb32_mmx(uchar *destPixels, int dbpl, |
|
7728 |
const uchar *srcPixels, int sbpl, |
|
7729 |
int w, int h, |
|
7730 |
int const_alpha); |
|
7731 |
||
7732 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mmx; |
|
7733 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mmx; |
|
7734 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_mmx; |
|
7735 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_mmx; |
|
7736 |
||
7737 |
} |
|
7738 |
#endif // MMX |
|
7739 |
||
7740 |
#ifdef QT_HAVE_SSE |
|
7741 |
if (features & SSE) { |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7742 |
extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7743 |
const uchar *srcPixels, int sbpl, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7744 |
int w, int h, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7745 |
int const_alpha); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7746 |
extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7747 |
const uchar *srcPixels, int sbpl, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7748 |
int w, int h, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7749 |
int const_alpha); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7750 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7751 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7752 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7753 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7754 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7755 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7756 |
#endif // SSE |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7757 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7758 |
#ifdef QT_HAVE_SSE2 |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7759 |
if (features & SSE2) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7760 |
extern void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7761 |
const uchar *srcPixels, int sbpl, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7762 |
int w, int h, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7763 |
int const_alpha); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7764 |
extern void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7765 |
const uchar *srcPixels, int sbpl, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7766 |
int w, int h, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7767 |
int const_alpha); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7768 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7769 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7770 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7771 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7772 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7773 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7774 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7775 |
#ifdef QT_HAVE_SSSE3 |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7776 |
if (features & SSSE3) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7777 |
extern void qt_blend_argb32_on_argb32_ssse3(uchar *destPixels, int dbpl, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7778 |
const uchar *srcPixels, int sbpl, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7779 |
int w, int h, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7780 |
int const_alpha); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7781 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7782 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7783 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7784 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7785 |
#endif // SSSE3 |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7786 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7787 |
#endif // SSE2 |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7788 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7789 |
#ifdef QT_HAVE_SSE |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7790 |
if (features & SSE) { |
0 | 7791 |
functionForModeAsm = qt_functionForMode_SSE; |
7792 |
functionForModeSolidAsm = qt_functionForModeSolid_SSE; |
|
7793 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_sse; |
|
7794 |
#ifdef QT_HAVE_3DNOW |
|
7795 |
if (features & MMX3DNOW) { |
|
7796 |
functionForModeAsm = qt_functionForMode_SSE3DNOW; |
|
7797 |
functionForModeSolidAsm = qt_functionForModeSolid_SSE3DNOW; |
|
7798 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_sse3dnow; |
|
7799 |
} |
|
7800 |
#endif // 3DNOW |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7801 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7802 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7803 |
#ifdef QT_HAVE_SSE2 |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7804 |
if (features & SSE2) { |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7805 |
extern void QT_FASTCALL comp_func_SourceOver_sse2(uint *destPixels, |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7806 |
const uint *srcPixels, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7807 |
int length, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7808 |
uint const_alpha); |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7809 |
extern void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, uint color, uint const_alpha); |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7810 |
extern void QT_FASTCALL comp_func_Plus_sse2(uint *dst, const uint *src, int length, uint const_alpha); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7811 |
extern void QT_FASTCALL comp_func_Source_sse2(uint *dst, const uint *src, int length, uint const_alpha); |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7812 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7813 |
functionForModeAsm[0] = comp_func_SourceOver_sse2; |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7814 |
functionForModeAsm[QPainter::CompositionMode_Source] = comp_func_Source_sse2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7815 |
functionForModeAsm[QPainter::CompositionMode_Plus] = comp_func_Plus_sse2; |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7816 |
functionForModeSolidAsm[0] = comp_func_solid_SourceOver_sse2; |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7817 |
} |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
7818 |
#endif |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7819 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7820 |
#elif defined(QT_HAVE_SSE2) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7821 |
// this is the special case when SSE2 is usable but MMX/SSE is not usable (e.g.: Windows x64 + visual studio) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7822 |
if (features & SSE2) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7823 |
functionForModeAsm = qt_functionForMode_onlySSE2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7824 |
functionForModeSolidAsm = qt_functionForModeSolid_onlySSE2; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7825 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7826 |
#endif |
0 | 7827 |
|
7828 |
#ifdef QT_HAVE_IWMMXT |
|
7829 |
if (features & IWMMXT) { |
|
7830 |
functionForModeAsm = qt_functionForMode_IWMMXT; |
|
7831 |
functionForModeSolidAsm = qt_functionForModeSolid_IWMMXT; |
|
7832 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_iwmmxt; |
|
7833 |
} |
|
7834 |
#endif // IWMMXT |
|
7835 |
||
7836 |
#if defined(Q_CC_RVCT) && defined(QT_HAVE_ARMV6) |
|
7837 |
functionForModeAsm = qt_functionForMode_ARMv6; |
|
7838 |
functionForModeSolidAsm = qt_functionForModeSolid_ARMv6; |
|
7839 |
||
7840 |
qt_memfill32 = qt_memfill32_armv6; |
|
7841 |
||
7842 |
qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_armv6; |
|
7843 |
||
7844 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_armv6; |
|
7845 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_armv6; |
|
7846 |
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_armv6; |
|
7847 |
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
|
7848 |
#elif defined(QT_HAVE_NEON) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7849 |
if (features & NEON) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7850 |
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
|
7851 |
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
|
7852 |
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
|
7853 |
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
|
7854 |
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
|
7855 |
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB16] = qt_blend_rgb16_on_argb32_neon; |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7856 |
qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_neon; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7857 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7858 |
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
|
7859 |
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
|
7860 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7861 |
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
|
7862 |
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
|
7863 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7864 |
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
|
7865 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7866 |
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
|
7867 |
functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_neon; |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7868 |
functionForMode_C[QPainter::CompositionMode_Plus] = comp_func_Plus_neon; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7869 |
destFetchProc[QImage::Format_RGB16] = qt_destFetchRGB16_neon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
7870 |
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
|
7871 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
7872 |
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
|
7873 |
qMemRotateFunctions[QImage::Format_RGB16][2] = qt_memrotate270_16_neon; |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7874 |
qt_memfill32 = qt_memfill32_neon; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7875 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7876 |
#endif |
0 | 7877 |
|
7878 |
if (functionForModeSolidAsm) { |
|
7879 |
const int destinationMode = QPainter::CompositionMode_Destination; |
|
7880 |
functionForModeSolidAsm[destinationMode] = functionForModeSolid_C[destinationMode]; |
|
7881 |
||
7882 |
// use the default qdrawhelper implementation for the |
|
7883 |
// extended composition modes |
|
7884 |
for (int mode = 12; mode < 24; ++mode) |
|
7885 |
functionForModeSolidAsm[mode] = functionForModeSolid_C[mode]; |
|
7886 |
||
7887 |
functionForModeSolid = functionForModeSolidAsm; |
|
7888 |
} |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
7889 |
if (functionForModeAsm) |
0 | 7890 |
functionForMode = functionForModeAsm; |
7891 |
||
7892 |
qt_build_pow_tables(); |
|
7893 |
} |
|
7894 |
||
7895 |
static void qt_memfill32_setup(quint32 *dest, quint32 value, int count) |
|
7896 |
{ |
|
7897 |
qInitDrawhelperAsm(); |
|
7898 |
qt_memfill32(dest, value, count); |
|
7899 |
} |
|
7900 |
||
7901 |
static void qt_memfill16_setup(quint16 *dest, quint16 value, int count) |
|
7902 |
{ |
|
7903 |
qInitDrawhelperAsm(); |
|
7904 |
qt_memfill16(dest, value, count); |
|
7905 |
} |
|
7906 |
||
7907 |
#ifdef QT_QWS_DEPTH_GENERIC |
|
7908 |
||
7909 |
int qrgb::bpp = 0; |
|
7910 |
int qrgb::len_red = 0; |
|
7911 |
int qrgb::len_green = 0; |
|
7912 |
int qrgb::len_blue = 0; |
|
7913 |
int qrgb::len_alpha = 0; |
|
7914 |
int qrgb::off_red = 0; |
|
7915 |
int qrgb::off_green = 0; |
|
7916 |
int qrgb::off_blue = 0; |
|
7917 |
int qrgb::off_alpha = 0; |
|
7918 |
||
7919 |
template <typename SRC> |
|
7920 |
Q_STATIC_TEMPLATE_FUNCTION inline void qt_rectconvert_rgb(qrgb *dest, const SRC *src, |
|
7921 |
int x, int y, int width, int height, |
|
7922 |
int dstStride, int srcStride) |
|
7923 |
{ |
|
7924 |
quint8 *dest8 = reinterpret_cast<quint8*>(dest) |
|
7925 |
+ y * dstStride + x * qrgb::bpp; |
|
7926 |
||
7927 |
srcStride = srcStride / sizeof(SRC) - width; |
|
7928 |
dstStride -= (width * qrgb::bpp); |
|
7929 |
||
7930 |
for (int j = 0; j < height; ++j) { |
|
7931 |
for (int i = 0; i < width; ++i) { |
|
7932 |
const quint32 v = qt_convertToRgb<SRC>(*src++); |
|
7933 |
#if Q_BYTE_ORDER == Q_BIG_ENDIAN |
|
7934 |
for (int j = qrgb::bpp - 1; j >= 0; --j) |
|
7935 |
*dest8++ = (v >> (8 * j)) & 0xff; |
|
7936 |
#else |
|
7937 |
for (int j = 0; j < qrgb::bpp; ++j) |
|
7938 |
*dest8++ = (v >> (8 * j)) & 0xff; |
|
7939 |
#endif |
|
7940 |
} |
|
7941 |
||
7942 |
dest8 += dstStride; |
|
7943 |
src += srcStride; |
|
7944 |
} |
|
7945 |
} |
|
7946 |
||
7947 |
template <> |
|
7948 |
void qt_rectconvert(qrgb *dest, const quint32 *src, |
|
7949 |
int x, int y, int width, int height, |
|
7950 |
int dstStride, int srcStride) |
|
7951 |
{ |
|
7952 |
qt_rectconvert_rgb<quint32>(dest, src, x, y, width, height, |
|
7953 |
dstStride, srcStride); |
|
7954 |
} |
|
7955 |
||
7956 |
template <> |
|
7957 |
void qt_rectconvert(qrgb *dest, const quint16 *src, |
|
7958 |
int x, int y, int width, int height, |
|
7959 |
int dstStride, int srcStride) |
|
7960 |
{ |
|
7961 |
qt_rectconvert_rgb<quint16>(dest, src, x, y, width, height, |
|
7962 |
dstStride, srcStride); |
|
7963 |
} |
|
7964 |
||
7965 |
#endif // QT_QWS_DEPTH_GENERIC |
|
7966 |
||
7967 |
QT_END_NAMESPACE |