Coverage Report

Created: 2026-02-14 07:09

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