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