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