/src/qtbase/src/gui/painting/qblendfunctions.cpp
Line | Count | Source |
1 | | // Copyright (C) 2016 The Qt Company Ltd. |
2 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #include <qmath.h> |
6 | | #include "qblendfunctions_p.h" |
7 | | |
8 | | QT_BEGIN_NAMESPACE |
9 | | |
10 | | struct SourceOnlyAlpha |
11 | | { |
12 | 0 | inline uchar alpha(uchar src) const { return src; } |
13 | 0 | inline quint16 bytemul(quint16 spix) const { return spix; } |
14 | | }; |
15 | | |
16 | | |
17 | | struct SourceAndConstAlpha |
18 | | { |
19 | 0 | SourceAndConstAlpha(int a) : m_alpha256(a) { |
20 | 0 | m_alpha255 = (m_alpha256 * 255) >> 8; |
21 | 0 | }; |
22 | 0 | inline uchar alpha(uchar src) const { return (src * m_alpha256) >> 8; } |
23 | 0 | inline quint16 bytemul(quint16 x) const { |
24 | 0 | uint t = (((x & 0x07e0)*m_alpha255) >> 8) & 0x07e0; |
25 | 0 | t |= (((x & 0xf81f)*(m_alpha255>>2)) >> 6) & 0xf81f; |
26 | 0 | return t; |
27 | 0 | } |
28 | | int m_alpha255; |
29 | | int m_alpha256; |
30 | | }; |
31 | | |
32 | | |
33 | | /************************************************************************ |
34 | | RGB16 (565) format target format |
35 | | ************************************************************************/ |
36 | | |
37 | | struct Blend_RGB16_on_RGB16_NoAlpha { |
38 | 0 | inline void write(quint16 *dst, quint16 src) { *dst = src; } |
39 | | |
40 | 0 | inline void flush(void *) {} |
41 | | }; |
42 | | |
43 | | struct Blend_RGB16_on_RGB16_ConstAlpha { |
44 | 0 | inline Blend_RGB16_on_RGB16_ConstAlpha(quint32 alpha) { |
45 | 0 | m_alpha = (alpha * 255) >> 8; |
46 | 0 | m_ialpha = 255 - m_alpha; |
47 | 0 | } |
48 | | |
49 | 0 | inline void write(quint16 *dst, quint16 src) { |
50 | 0 | *dst = BYTE_MUL_RGB16(src, m_alpha) + BYTE_MUL_RGB16(*dst, m_ialpha); |
51 | 0 | } |
52 | | |
53 | 0 | inline void flush(void *) {} |
54 | | |
55 | | quint32 m_alpha; |
56 | | quint32 m_ialpha; |
57 | | }; |
58 | | |
59 | | struct Blend_ARGB32_on_RGB16_SourceAlpha { |
60 | 0 | inline void write(quint16 *dst, quint32 src) { |
61 | 0 | const quint8 alpha = qAlpha(src); |
62 | 0 | if (alpha) { |
63 | 0 | quint16 s = qConvertRgb32To16(src); |
64 | 0 | if (alpha < 255) |
65 | 0 | s += BYTE_MUL_RGB16(*dst, 255 - alpha); |
66 | 0 | *dst = s; |
67 | 0 | } |
68 | 0 | } |
69 | | |
70 | 0 | inline void flush(void *) {} |
71 | | }; |
72 | | |
73 | | struct Blend_ARGB32_on_RGB16_SourceAndConstAlpha { |
74 | 0 | inline Blend_ARGB32_on_RGB16_SourceAndConstAlpha(quint32 alpha) { |
75 | 0 | m_alpha = (alpha * 255) >> 8; |
76 | 0 | } |
77 | | |
78 | 0 | inline void write(quint16 *dst, quint32 src) { |
79 | 0 | src = BYTE_MUL(src, m_alpha); |
80 | 0 | const quint8 alpha = qAlpha(src); |
81 | 0 | if (alpha) { |
82 | 0 | quint16 s = qConvertRgb32To16(src); |
83 | 0 | if (alpha < 255) |
84 | 0 | s += BYTE_MUL_RGB16(*dst, 255 - alpha); |
85 | 0 | *dst = s; |
86 | 0 | } |
87 | 0 | } |
88 | | |
89 | 0 | inline void flush(void *) {} |
90 | | |
91 | | quint32 m_alpha; |
92 | | }; |
93 | | |
94 | | void qt_scale_image_rgb16_on_rgb16(uchar *destPixels, int dbpl, |
95 | | const uchar *srcPixels, int sbpl, int srch, |
96 | | const QRectF &targetRect, |
97 | | const QRectF &sourceRect, |
98 | | const QRect &clip, |
99 | | int const_alpha) |
100 | 0 | { |
101 | | #ifdef QT_DEBUG_DRAW |
102 | | printf("qt_scale_rgb16_on_rgb16: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n", |
103 | | destPixels, dbpl, srcPixels, sbpl, |
104 | | targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), |
105 | | sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(), |
106 | | const_alpha); |
107 | | #endif |
108 | 0 | if (const_alpha == 256) { |
109 | 0 | Blend_RGB16_on_RGB16_NoAlpha noAlpha; |
110 | 0 | qt_scale_image_16bit<quint16>(destPixels, dbpl, srcPixels, sbpl, srch, |
111 | 0 | targetRect, sourceRect, clip, noAlpha); |
112 | 0 | } else { |
113 | 0 | Blend_RGB16_on_RGB16_ConstAlpha constAlpha(const_alpha); |
114 | 0 | qt_scale_image_16bit<quint16>(destPixels, dbpl, srcPixels, sbpl, srch, |
115 | 0 | targetRect, sourceRect, clip, constAlpha); |
116 | 0 | } |
117 | 0 | } |
118 | | |
119 | | void qt_scale_image_argb32_on_rgb16(uchar *destPixels, int dbpl, |
120 | | const uchar *srcPixels, int sbpl, int srch, |
121 | | const QRectF &targetRect, |
122 | | const QRectF &sourceRect, |
123 | | const QRect &clip, |
124 | | int const_alpha) |
125 | 0 | { |
126 | | #ifdef QT_DEBUG_DRAW |
127 | | printf("qt_scale_argb32_on_rgb16: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n", |
128 | | destPixels, dbpl, srcPixels, sbpl, |
129 | | targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), |
130 | | sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(), |
131 | | const_alpha); |
132 | | #endif |
133 | 0 | if (const_alpha == 256) { |
134 | 0 | Blend_ARGB32_on_RGB16_SourceAlpha noAlpha; |
135 | 0 | qt_scale_image_16bit<quint32>(destPixels, dbpl, srcPixels, sbpl, srch, |
136 | 0 | targetRect, sourceRect, clip, noAlpha); |
137 | 0 | } else { |
138 | 0 | Blend_ARGB32_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha); |
139 | 0 | qt_scale_image_16bit<quint32>(destPixels, dbpl, srcPixels, sbpl, srch, |
140 | 0 | targetRect, sourceRect, clip, constAlpha); |
141 | 0 | } |
142 | 0 | } |
143 | | |
144 | | void qt_blend_rgb16_on_rgb16(uchar *dst, int dbpl, |
145 | | const uchar *src, int sbpl, |
146 | | int w, int h, |
147 | | int const_alpha) |
148 | 0 | { |
149 | | #ifdef QT_DEBUG_DRAW |
150 | | printf("qt_blend_rgb16_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n", |
151 | | dst, dbpl, src, sbpl, w, h, const_alpha); |
152 | | #endif |
153 | |
|
154 | 0 | if (const_alpha == 256) { |
155 | 0 | int length = w << 1; |
156 | 0 | while (--h >= 0) { |
157 | 0 | memcpy(dst, src, length); |
158 | 0 | dst += dbpl; |
159 | 0 | src += sbpl; |
160 | 0 | } |
161 | 0 | } else if (const_alpha != 0) { |
162 | 0 | quint16 *d = (quint16 *) dst; |
163 | 0 | const quint16 *s = (const quint16 *) src; |
164 | 0 | quint8 a = (255 * const_alpha) >> 8; |
165 | 0 | quint8 ia = 255 - a; |
166 | 0 | while (--h >= 0) { |
167 | 0 | for (int x=0; x<w; ++x) { |
168 | 0 | d[x] = BYTE_MUL_RGB16(s[x], a) + BYTE_MUL_RGB16(d[x], ia); |
169 | 0 | } |
170 | 0 | d = (quint16 *)(((uchar *) d) + dbpl); |
171 | 0 | s = (const quint16 *)(((const uchar *) s) + sbpl); |
172 | 0 | } |
173 | 0 | } |
174 | 0 | } |
175 | | |
176 | | |
177 | | void qt_blend_argb32_on_rgb16_const_alpha(uchar *destPixels, int dbpl, |
178 | | const uchar *srcPixels, int sbpl, |
179 | | int w, int h, |
180 | | int const_alpha) |
181 | 0 | { |
182 | 0 | quint16 *dst = (quint16 *) destPixels; |
183 | 0 | const quint32 *src = (const quint32 *) srcPixels; |
184 | |
|
185 | 0 | const_alpha = (const_alpha * 255) >> 8; |
186 | 0 | for (int y=0; y<h; ++y) { |
187 | 0 | for (int i = 0; i < w; ++i) { |
188 | 0 | uint s = src[i]; |
189 | 0 | s = BYTE_MUL(s, const_alpha); |
190 | 0 | int alpha = qAlpha(s); |
191 | 0 | s = qConvertRgb32To16(s); |
192 | 0 | s += BYTE_MUL_RGB16(dst[i], 255 - alpha); |
193 | 0 | dst[i] = s; |
194 | 0 | } |
195 | 0 | dst = (quint16 *)(((uchar *) dst) + dbpl); |
196 | 0 | src = (const quint32 *)(((const uchar *) src) + sbpl); |
197 | 0 | } |
198 | 0 | } |
199 | | |
200 | | static void qt_blend_argb32_on_rgb16(uchar *destPixels, int dbpl, |
201 | | const uchar *srcPixels, int sbpl, |
202 | | int w, int h, |
203 | | int const_alpha) |
204 | 0 | { |
205 | 0 | if (const_alpha != 256) { |
206 | 0 | qt_blend_argb32_on_rgb16_const_alpha(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); |
207 | 0 | return; |
208 | 0 | } |
209 | | |
210 | 0 | quint16 *dst = (quint16 *) destPixels; |
211 | 0 | const quint32 *src = (const quint32 *) srcPixels; |
212 | |
|
213 | 0 | for (int y=0; y<h; ++y) { |
214 | 0 | for (int x=0; x<w; ++x) { |
215 | |
|
216 | 0 | quint32 spix = src[x]; |
217 | 0 | quint32 alpha = spix >> 24; |
218 | |
|
219 | 0 | if (alpha == 255) { |
220 | 0 | dst[x] = qConvertRgb32To16(spix); |
221 | 0 | } else if (alpha != 0) { |
222 | 0 | quint32 dpix = dst[x]; |
223 | |
|
224 | 0 | quint32 sia = 255 - alpha; |
225 | |
|
226 | 0 | quint32 sr = (spix >> 8) & 0xf800; |
227 | 0 | quint32 sg = (spix >> 5) & 0x07e0; |
228 | 0 | quint32 sb = (spix >> 3) & 0x001f; |
229 | |
|
230 | 0 | quint32 dr = (dpix & 0x0000f800); |
231 | 0 | quint32 dg = (dpix & 0x000007e0); |
232 | 0 | quint32 db = (dpix & 0x0000001f); |
233 | |
|
234 | 0 | quint32 siar = dr * sia; |
235 | 0 | quint32 siag = dg * sia; |
236 | 0 | quint32 siab = db * sia; |
237 | |
|
238 | 0 | quint32 rr = sr + ((siar + (siar>>8) + (0x80 << 8)) >> 8); |
239 | 0 | quint32 rg = sg + ((siag + (siag>>8) + (0x80 << 3)) >> 8); |
240 | 0 | quint32 rb = sb + ((siab + (siab>>8) + (0x80 >> 3)) >> 8); |
241 | |
|
242 | 0 | dst[x] = (rr & 0xf800) |
243 | 0 | | (rg & 0x07e0) |
244 | 0 | | (rb); |
245 | 0 | } |
246 | 0 | } |
247 | 0 | dst = (quint16 *) (((uchar *) dst) + dbpl); |
248 | 0 | src = (const quint32 *) (((const uchar *) src) + sbpl); |
249 | 0 | } |
250 | 0 | } |
251 | | |
252 | | |
253 | | static void qt_blend_rgb32_on_rgb16(uchar *destPixels, int dbpl, |
254 | | const uchar *srcPixels, int sbpl, |
255 | | int w, int h, |
256 | | int const_alpha) |
257 | 0 | { |
258 | | #ifdef QT_DEBUG_DRAW |
259 | | printf("qt_blend_rgb32_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n", |
260 | | destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); |
261 | | #endif |
262 | |
|
263 | 0 | if (const_alpha != 256) { |
264 | 0 | qt_blend_argb32_on_rgb16(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); |
265 | 0 | return; |
266 | 0 | } |
267 | | |
268 | 0 | const quint32 *src = (const quint32 *) srcPixels; |
269 | 0 | int srcExtraStride = (sbpl >> 2) - w; |
270 | |
|
271 | 0 | int dstJPL = dbpl / 2; |
272 | |
|
273 | 0 | quint16 *dst = (quint16 *) destPixels; |
274 | 0 | quint16 *dstEnd = dst + dstJPL * h; |
275 | |
|
276 | 0 | int dstExtraStride = dstJPL - w; |
277 | |
|
278 | 0 | while (dst < dstEnd) { |
279 | 0 | const quint32 *srcEnd = src + w; |
280 | 0 | while (src < srcEnd) { |
281 | 0 | *dst = qConvertRgb32To16(*src); |
282 | 0 | ++dst; |
283 | 0 | ++src; |
284 | 0 | } |
285 | 0 | dst += dstExtraStride; |
286 | 0 | src += srcExtraStride; |
287 | 0 | } |
288 | 0 | } |
289 | | |
290 | | |
291 | | |
292 | | /************************************************************************ |
293 | | RGB32 (-888) format target format |
294 | | ************************************************************************/ |
295 | | |
296 | | static void qt_blend_argb32_on_argb32(uchar *destPixels, int dbpl, |
297 | | const uchar *srcPixels, int sbpl, |
298 | | int w, int h, |
299 | | int const_alpha) |
300 | 0 | { |
301 | | #ifdef QT_DEBUG_DRAW |
302 | | fprintf(stdout, "qt_blend_argb32_on_argb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n", |
303 | | destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); |
304 | | fflush(stdout); |
305 | | #endif |
306 | |
|
307 | 0 | const uint *src = (const uint *) srcPixels; |
308 | 0 | uint *dst = (uint *) destPixels; |
309 | 0 | if (const_alpha == 256) { |
310 | 0 | for (int y=0; y<h; ++y) { |
311 | 0 | for (int x=0; x<w; ++x) { |
312 | 0 | uint s = src[x]; |
313 | 0 | if (s >= 0xff000000) |
314 | 0 | dst[x] = s; |
315 | 0 | else if (s != 0) |
316 | 0 | dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); |
317 | 0 | } |
318 | 0 | dst = (quint32 *)(((uchar *) dst) + dbpl); |
319 | 0 | src = (const quint32 *)(((const uchar *) src) + sbpl); |
320 | 0 | } |
321 | 0 | } else if (const_alpha != 0) { |
322 | 0 | const_alpha = (const_alpha * 255) >> 8; |
323 | 0 | for (int y=0; y<h; ++y) { |
324 | 0 | for (int x=0; x<w; ++x) { |
325 | 0 | uint s = BYTE_MUL(src[x], const_alpha); |
326 | 0 | dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); |
327 | 0 | } |
328 | 0 | dst = (quint32 *)(((uchar *) dst) + dbpl); |
329 | 0 | src = (const quint32 *)(((const uchar *) src) + sbpl); |
330 | 0 | } |
331 | 0 | } |
332 | 0 | } |
333 | | |
334 | | |
335 | | void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl, |
336 | | const uchar *srcPixels, int sbpl, |
337 | | int w, int h, |
338 | | int const_alpha) |
339 | 0 | { |
340 | | #ifdef QT_DEBUG_DRAW |
341 | | fprintf(stdout, "qt_blend_rgb32_on_rgb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n", |
342 | | destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); |
343 | | fflush(stdout); |
344 | | #endif |
345 | 0 | const uint *src = (const uint *) srcPixels; |
346 | 0 | uint *dst = (uint *) destPixels; |
347 | 0 | if (const_alpha == 256) { |
348 | 0 | const int len = w * 4; |
349 | 0 | for (int y = 0; y < h; ++y) { |
350 | 0 | memcpy(dst, src, len); |
351 | 0 | dst = (quint32 *)(((uchar *) dst) + dbpl); |
352 | 0 | src = (const quint32 *)(((const uchar *) src) + sbpl); |
353 | 0 | } |
354 | 0 | return; |
355 | 0 | } else if (const_alpha != 0) { |
356 | 0 | const_alpha = (const_alpha * 255) >> 8; |
357 | 0 | int ialpha = 255 - const_alpha; |
358 | 0 | for (int y=0; y<h; ++y) { |
359 | 0 | for (int x=0; x<w; ++x) |
360 | 0 | dst[x] = INTERPOLATE_PIXEL_255(dst[x], ialpha, src[x], const_alpha); |
361 | 0 | dst = (quint32 *)(((uchar *) dst) + dbpl); |
362 | 0 | src = (const quint32 *)(((const uchar *) src) + sbpl); |
363 | 0 | } |
364 | 0 | } |
365 | 0 | } |
366 | | |
367 | | struct Blend_RGB32_on_RGB32_NoAlpha { |
368 | 0 | inline void write(quint32 *dst, quint32 src) { *dst = src; } |
369 | | |
370 | 0 | inline void flush(void *) {} |
371 | | }; |
372 | | |
373 | | struct Blend_RGB32_on_RGB32_ConstAlpha { |
374 | 0 | inline Blend_RGB32_on_RGB32_ConstAlpha(quint32 alpha) { |
375 | 0 | m_alpha = (alpha * 255) >> 8; |
376 | 0 | m_ialpha = 255 - m_alpha; |
377 | 0 | } |
378 | | |
379 | 0 | inline void write(quint32 *dst, quint32 src) { |
380 | 0 | *dst = INTERPOLATE_PIXEL_255(src, m_alpha, *dst, m_ialpha); |
381 | 0 | } |
382 | | |
383 | 0 | inline void flush(void *) {} |
384 | | |
385 | | quint32 m_alpha; |
386 | | quint32 m_ialpha; |
387 | | }; |
388 | | |
389 | | struct Blend_ARGB32_on_ARGB32_SourceAlpha { |
390 | | inline void write(quint32 *dst, quint32 src) |
391 | 0 | { |
392 | 0 | blend_pixel(*dst, src); |
393 | 0 | } |
394 | | |
395 | 0 | inline void flush(void *) {} |
396 | | }; |
397 | | |
398 | | struct Blend_ARGB32_on_ARGB32_SourceAndConstAlpha { |
399 | | inline Blend_ARGB32_on_ARGB32_SourceAndConstAlpha(quint32 alpha) |
400 | 0 | { |
401 | 0 | m_alpha = (alpha * 255) >> 8; |
402 | 0 | } |
403 | | |
404 | | inline void write(quint32 *dst, quint32 src) |
405 | 0 | { |
406 | 0 | blend_pixel(*dst, src, m_alpha); |
407 | 0 | } |
408 | | |
409 | 0 | inline void flush(void *) {} |
410 | | |
411 | | quint32 m_alpha; |
412 | | }; |
413 | | |
414 | | void qt_scale_image_rgb32_on_rgb32(uchar *destPixels, int dbpl, |
415 | | const uchar *srcPixels, int sbpl, int srch, |
416 | | const QRectF &targetRect, |
417 | | const QRectF &sourceRect, |
418 | | const QRect &clip, |
419 | | int const_alpha) |
420 | 0 | { |
421 | | #ifdef QT_DEBUG_DRAW |
422 | | printf("qt_scale_rgb32_on_rgb32: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n", |
423 | | destPixels, dbpl, srcPixels, sbpl, |
424 | | targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), |
425 | | sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(), |
426 | | const_alpha); |
427 | | #endif |
428 | 0 | if (const_alpha == 256) { |
429 | 0 | Blend_RGB32_on_RGB32_NoAlpha noAlpha; |
430 | 0 | qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch, |
431 | 0 | targetRect, sourceRect, clip, noAlpha); |
432 | 0 | } else { |
433 | 0 | Blend_RGB32_on_RGB32_ConstAlpha constAlpha(const_alpha); |
434 | 0 | qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch, |
435 | 0 | targetRect, sourceRect, clip, constAlpha); |
436 | 0 | } |
437 | 0 | } |
438 | | |
439 | | void qt_scale_image_argb32_on_argb32(uchar *destPixels, int dbpl, |
440 | | const uchar *srcPixels, int sbpl, int srch, |
441 | | const QRectF &targetRect, |
442 | | const QRectF &sourceRect, |
443 | | const QRect &clip, |
444 | | int const_alpha) |
445 | 0 | { |
446 | | #ifdef QT_DEBUG_DRAW |
447 | | printf("qt_scale_argb32_on_argb32: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n", |
448 | | destPixels, dbpl, srcPixels, sbpl, |
449 | | targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), |
450 | | sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(), |
451 | | const_alpha); |
452 | | #endif |
453 | 0 | if (const_alpha == 256) { |
454 | 0 | Blend_ARGB32_on_ARGB32_SourceAlpha sourceAlpha; |
455 | 0 | qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch, |
456 | 0 | targetRect, sourceRect, clip, sourceAlpha); |
457 | 0 | } else { |
458 | 0 | Blend_ARGB32_on_ARGB32_SourceAndConstAlpha constAlpha(const_alpha); |
459 | 0 | qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch, |
460 | 0 | targetRect, sourceRect, clip, constAlpha); |
461 | 0 | } |
462 | 0 | } |
463 | | |
464 | | void qt_transform_image_rgb16_on_rgb16(uchar *destPixels, int dbpl, |
465 | | const uchar *srcPixels, int sbpl, |
466 | | const QRectF &targetRect, |
467 | | const QRectF &sourceRect, |
468 | | const QRect &clip, |
469 | | const QTransform &targetRectTransform, |
470 | | int const_alpha) |
471 | 0 | { |
472 | 0 | if (const_alpha == 256) { |
473 | 0 | Blend_RGB16_on_RGB16_NoAlpha noAlpha; |
474 | 0 | qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl, |
475 | 0 | reinterpret_cast<const quint16 *>(srcPixels), sbpl, |
476 | 0 | targetRect, sourceRect, clip, targetRectTransform, noAlpha); |
477 | 0 | } else { |
478 | 0 | Blend_RGB16_on_RGB16_ConstAlpha constAlpha(const_alpha); |
479 | 0 | qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl, |
480 | 0 | reinterpret_cast<const quint16 *>(srcPixels), sbpl, |
481 | 0 | targetRect, sourceRect, clip, targetRectTransform, constAlpha); |
482 | 0 | } |
483 | 0 | } |
484 | | |
485 | | void qt_transform_image_argb32_on_rgb16(uchar *destPixels, int dbpl, |
486 | | const uchar *srcPixels, int sbpl, |
487 | | const QRectF &targetRect, |
488 | | const QRectF &sourceRect, |
489 | | const QRect &clip, |
490 | | const QTransform &targetRectTransform, |
491 | | int const_alpha) |
492 | 0 | { |
493 | 0 | if (const_alpha == 256) { |
494 | 0 | Blend_ARGB32_on_RGB16_SourceAlpha noAlpha; |
495 | 0 | qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl, |
496 | 0 | reinterpret_cast<const quint32 *>(srcPixels), sbpl, |
497 | 0 | targetRect, sourceRect, clip, targetRectTransform, noAlpha); |
498 | 0 | } else { |
499 | 0 | Blend_ARGB32_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha); |
500 | 0 | qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl, |
501 | 0 | reinterpret_cast<const quint32 *>(srcPixels), sbpl, |
502 | 0 | targetRect, sourceRect, clip, targetRectTransform, constAlpha); |
503 | 0 | } |
504 | 0 | } |
505 | | |
506 | | |
507 | | void qt_transform_image_rgb32_on_rgb32(uchar *destPixels, int dbpl, |
508 | | const uchar *srcPixels, int sbpl, |
509 | | const QRectF &targetRect, |
510 | | const QRectF &sourceRect, |
511 | | const QRect &clip, |
512 | | const QTransform &targetRectTransform, |
513 | | int const_alpha) |
514 | 0 | { |
515 | 0 | if (const_alpha == 256) { |
516 | 0 | Blend_RGB32_on_RGB32_NoAlpha noAlpha; |
517 | 0 | qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl, |
518 | 0 | reinterpret_cast<const quint32 *>(srcPixels), sbpl, |
519 | 0 | targetRect, sourceRect, clip, targetRectTransform, noAlpha); |
520 | 0 | } else { |
521 | 0 | Blend_RGB32_on_RGB32_ConstAlpha constAlpha(const_alpha); |
522 | 0 | qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl, |
523 | 0 | reinterpret_cast<const quint32 *>(srcPixels), sbpl, |
524 | 0 | targetRect, sourceRect, clip, targetRectTransform, constAlpha); |
525 | 0 | } |
526 | 0 | } |
527 | | |
528 | | void qt_transform_image_argb32_on_argb32(uchar *destPixels, int dbpl, |
529 | | const uchar *srcPixels, int sbpl, |
530 | | const QRectF &targetRect, |
531 | | const QRectF &sourceRect, |
532 | | const QRect &clip, |
533 | | const QTransform &targetRectTransform, |
534 | | int const_alpha) |
535 | 0 | { |
536 | 0 | if (const_alpha == 256) { |
537 | 0 | Blend_ARGB32_on_ARGB32_SourceAlpha sourceAlpha; |
538 | 0 | qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl, |
539 | 0 | reinterpret_cast<const quint32 *>(srcPixels), sbpl, |
540 | 0 | targetRect, sourceRect, clip, targetRectTransform, sourceAlpha); |
541 | 0 | } else { |
542 | 0 | Blend_ARGB32_on_ARGB32_SourceAndConstAlpha constAlpha(const_alpha); |
543 | 0 | qt_transform_image(reinterpret_cast<quint32 *>(destPixels), dbpl, |
544 | 0 | reinterpret_cast<const quint32 *>(srcPixels), sbpl, |
545 | 0 | targetRect, sourceRect, clip, targetRectTransform, constAlpha); |
546 | 0 | } |
547 | 0 | } |
548 | | |
549 | | SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats]; |
550 | | SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats]; |
551 | | SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats]; |
552 | | |
553 | | void qInitBlendFunctions() |
554 | 32 | { |
555 | 32 | qScaleFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_scale_image_rgb32_on_rgb32; |
556 | 32 | qScaleFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32; |
557 | 32 | qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_scale_image_rgb32_on_rgb32; |
558 | 32 | qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32; |
559 | 32 | qScaleFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_rgb16; |
560 | 32 | qScaleFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_scale_image_rgb16_on_rgb16; |
561 | 32 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
562 | 32 | qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_scale_image_rgb32_on_rgb32; |
563 | 32 | qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32; |
564 | 32 | qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_scale_image_rgb32_on_rgb32; |
565 | 32 | qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32; |
566 | 32 | #endif |
567 | | |
568 | 32 | qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32; |
569 | 32 | qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32; |
570 | 32 | qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32; |
571 | 32 | qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32; |
572 | 32 | qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb16; |
573 | 32 | qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16; |
574 | 32 | qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16; |
575 | 32 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
576 | 32 | qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32; |
577 | 32 | qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32; |
578 | 32 | qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32; |
579 | 32 | qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32; |
580 | 32 | #endif |
581 | | |
582 | 32 | qTransformFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_transform_image_rgb32_on_rgb32; |
583 | 32 | qTransformFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_argb32; |
584 | 32 | qTransformFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_transform_image_rgb32_on_rgb32; |
585 | 32 | qTransformFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_argb32; |
586 | 32 | qTransformFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_rgb16; |
587 | 32 | qTransformFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_transform_image_rgb16_on_rgb16; |
588 | 32 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
589 | 32 | qTransformFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_transform_image_rgb32_on_rgb32; |
590 | 32 | qTransformFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_transform_image_argb32_on_argb32; |
591 | 32 | qTransformFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_transform_image_rgb32_on_rgb32; |
592 | 32 | qTransformFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_transform_image_argb32_on_argb32; |
593 | 32 | #endif |
594 | 32 | } |
595 | | |
596 | | QT_END_NAMESPACE |