| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qimagescale.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 | #include <private/qimagescale_p.h> | - | ||||||||||||||||||
| 40 | #include <private/qdrawhelper_p.h> | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | #include "qimage.h" | - | ||||||||||||||||||
| 43 | #include "qcolor.h" | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | /* | - | ||||||||||||||||||
| 48 | * Copyright (C) 2004, 2005 Daniel M. Duley | - | ||||||||||||||||||
| 49 | * | - | ||||||||||||||||||
| 50 | * Redistribution and use in source and binary forms, with or without | - | ||||||||||||||||||
| 51 | * modification, are permitted provided that the following conditions | - | ||||||||||||||||||
| 52 | * are met: | - | ||||||||||||||||||
| 53 | * | - | ||||||||||||||||||
| 54 | * 1. Redistributions of source code must retain the above copyright | - | ||||||||||||||||||
| 55 | * notice, this list of conditions and the following disclaimer. | - | ||||||||||||||||||
| 56 | * 2. Redistributions in binary form must reproduce the above copyright | - | ||||||||||||||||||
| 57 | * notice, this list of conditions and the following disclaimer in the | - | ||||||||||||||||||
| 58 | * documentation and/or other materials provided with the distribution. | - | ||||||||||||||||||
| 59 | * | - | ||||||||||||||||||
| 60 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | - | ||||||||||||||||||
| 61 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | - | ||||||||||||||||||
| 62 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | - | ||||||||||||||||||
| 63 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | - | ||||||||||||||||||
| 64 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | - | ||||||||||||||||||
| 65 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | - | ||||||||||||||||||
| 66 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | - | ||||||||||||||||||
| 67 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | - | ||||||||||||||||||
| 68 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | - | ||||||||||||||||||
| 69 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | - | ||||||||||||||||||
| 70 | * | - | ||||||||||||||||||
| 71 | */ | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | /* OTHER CREDITS: | - | ||||||||||||||||||
| 74 | * | - | ||||||||||||||||||
| 75 | * This is the normal smoothscale method, based on Imlib2's smoothscale. | - | ||||||||||||||||||
| 76 | * | - | ||||||||||||||||||
| 77 | * Originally I took the algorithm used in NetPBM and Qt and added MMX/3dnow | - | ||||||||||||||||||
| 78 | * optimizations. It ran in about 1/2 the time as Qt. Then I ported Imlib's | - | ||||||||||||||||||
| 79 | * C algorithm and it ran at about the same speed as my MMX optimized one... | - | ||||||||||||||||||
| 80 | * Finally I ported Imlib's MMX version and it ran in less than half the | - | ||||||||||||||||||
| 81 | * time as my MMX algorithm, (taking only a quarter of the time Qt does). | - | ||||||||||||||||||
| 82 | * After further optimization it seems to run at around 1/6th. | - | ||||||||||||||||||
| 83 | * | - | ||||||||||||||||||
| 84 | * Changes include formatting, namespaces and other C++'ings, removal of old | - | ||||||||||||||||||
| 85 | * #ifdef'ed code, and removal of unneeded border calculation code. | - | ||||||||||||||||||
| 86 | * Later the code has been refactored, an SSE4.1 optimizated path have been | - | ||||||||||||||||||
| 87 | * added instead of the removed MMX assembler, and scaling of clipped area | - | ||||||||||||||||||
| 88 | * removed. | - | ||||||||||||||||||
| 89 | * | - | ||||||||||||||||||
| 90 | * Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code | - | ||||||||||||||||||
| 91 | * is by Willem Monsuwe <willem@stack.nl>. All other modifications are | - | ||||||||||||||||||
| 92 | * (C) Daniel M. Duley. | - | ||||||||||||||||||
| 93 | */ | - | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | namespace QImageScale { | - | ||||||||||||||||||
| 97 | const unsigned int** qimageCalcYPoints(const unsigned int *src, int sw, int sh, int dh); | - | ||||||||||||||||||
| 98 | int* qimageCalcXPoints(int sw, int dw); | - | ||||||||||||||||||
| 99 | int* qimageCalcApoints(int s, int d, int up); | - | ||||||||||||||||||
| 100 | QImageScaleInfo* qimageFreeScaleInfo(QImageScaleInfo *isi); | - | ||||||||||||||||||
| 101 | QImageScaleInfo *qimageCalcScaleInfo(const QImage &img, int sw, int sh, | - | ||||||||||||||||||
| 102 | int dw, int dh, char aa); | - | ||||||||||||||||||
| 103 | } | - | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | using namespace QImageScale; | - | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | // | - | ||||||||||||||||||
| 108 | // Code ported from Imlib... | - | ||||||||||||||||||
| 109 | // | - | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | const unsigned int** QImageScale::qimageCalcYPoints(const unsigned int *src, | - | ||||||||||||||||||
| 112 | int sw, int sh, int dh) | - | ||||||||||||||||||
| 113 | { | - | ||||||||||||||||||
| 114 | const unsigned int **p; | - | ||||||||||||||||||
| 115 | int j = 0, rv = 0; | - | ||||||||||||||||||
| 116 | qint64 val, inc; | - | ||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 | if (dh < 0) { 
 | 0 | ||||||||||||||||||
| 119 | dh = -dh; | - | ||||||||||||||||||
| 120 | rv = 1; | - | ||||||||||||||||||
| 121 | } never executed:  end of block | 0 | ||||||||||||||||||
| 122 | p = new const unsigned int* [dh+1]; | - | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | int up = qAbs(dh) >= sh; | - | ||||||||||||||||||
| 125 | val = up ? 0x8000 * sh / dh - 0x8000 : 0; 
 | 0 | ||||||||||||||||||
| 126 | inc = (((qint64)sh) << 16) / dh; | - | ||||||||||||||||||
| 127 | for (int i = 0; i < dh; i++) { 
 | 0 | ||||||||||||||||||
| 128 | p[j++] = src + qMax(0LL, val >> 16) * sw; | - | ||||||||||||||||||
| 129 | val += inc; | - | ||||||||||||||||||
| 130 | } never executed:  end of block | 0 | ||||||||||||||||||
| 131 | if (rv) { 
 | 0 | ||||||||||||||||||
| 132 | for (int i = dh / 2; --i >= 0; ) { 
 | 0 | ||||||||||||||||||
| 133 | const unsigned int *tmp = p[i]; | - | ||||||||||||||||||
| 134 | p[i] = p[dh - i - 1]; | - | ||||||||||||||||||
| 135 | p[dh - i - 1] = tmp; | - | ||||||||||||||||||
| 136 | } never executed:  end of block | 0 | ||||||||||||||||||
| 137 | } never executed:  end of block | 0 | ||||||||||||||||||
| 138 | return(p); never executed:  return(p); | 0 | ||||||||||||||||||
| 139 | } | - | ||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | int* QImageScale::qimageCalcXPoints(int sw, int dw) | - | ||||||||||||||||||
| 142 | { | - | ||||||||||||||||||
| 143 | int *p, j = 0, rv = 0; | - | ||||||||||||||||||
| 144 | qint64 val, inc; | - | ||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | if (dw < 0) { 
 | 0 | ||||||||||||||||||
| 147 | dw = -dw; | - | ||||||||||||||||||
| 148 | rv = 1; | - | ||||||||||||||||||
| 149 | } never executed:  end of block | 0 | ||||||||||||||||||
| 150 | p = new int[dw+1]; | - | ||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | int up = qAbs(dw) >= sw; | - | ||||||||||||||||||
| 153 | val = up ? 0x8000 * sw / dw - 0x8000 : 0; 
 | 0 | ||||||||||||||||||
| 154 | inc = (((qint64)sw) << 16) / dw; | - | ||||||||||||||||||
| 155 | for (int i = 0; i < dw; i++) { 
 | 0 | ||||||||||||||||||
| 156 | p[j++] = qMax(0LL, val >> 16); | - | ||||||||||||||||||
| 157 | val += inc; | - | ||||||||||||||||||
| 158 | } never executed:  end of block | 0 | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | if (rv) { 
 | 0 | ||||||||||||||||||
| 161 | for (int i = dw / 2; --i >= 0; ) { 
 | 0 | ||||||||||||||||||
| 162 | int tmp = p[i]; | - | ||||||||||||||||||
| 163 | p[i] = p[dw - i - 1]; | - | ||||||||||||||||||
| 164 | p[dw - i - 1] = tmp; | - | ||||||||||||||||||
| 165 | } never executed:  end of block | 0 | ||||||||||||||||||
| 166 | } never executed:  end of block | 0 | ||||||||||||||||||
| 167 | return p; never executed:  return p; | 0 | ||||||||||||||||||
| 168 | } | - | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | int* QImageScale::qimageCalcApoints(int s, int d, int up) | - | ||||||||||||||||||
| 171 | { | - | ||||||||||||||||||
| 172 | int *p, j = 0, rv = 0; | - | ||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | if (d < 0) { 
 | 0 | ||||||||||||||||||
| 175 | rv = 1; | - | ||||||||||||||||||
| 176 | d = -d; | - | ||||||||||||||||||
| 177 | } never executed:  end of block | 0 | ||||||||||||||||||
| 178 | p = new int[d]; | - | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | if (up) { 
 | 0 | ||||||||||||||||||
| 181 | /* scaling up */ | - | ||||||||||||||||||
| 182 | qint64 val = 0x8000 * s / d - 0x8000; | - | ||||||||||||||||||
| 183 | qint64 inc = (((qint64)s) << 16) / d; | - | ||||||||||||||||||
| 184 | for (int i = 0; i < d; i++) { 
 | 0 | ||||||||||||||||||
| 185 | int pos = val >> 16; | - | ||||||||||||||||||
| 186 | if (pos < 0) 
 | 0 | ||||||||||||||||||
| 187 | p[j++] = 0; never executed:  p[j++] = 0; | 0 | ||||||||||||||||||
| 188 | else if (pos >= (s - 1)) 
 | 0 | ||||||||||||||||||
| 189 | p[j++] = 0; never executed:  p[j++] = 0; | 0 | ||||||||||||||||||
| 190 | else | - | ||||||||||||||||||
| 191 | p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00); never executed:  p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00); | 0 | ||||||||||||||||||
| 192 | val += inc; | - | ||||||||||||||||||
| 193 | } never executed:  end of block | 0 | ||||||||||||||||||
| 194 | } else { never executed:  end of block | 0 | ||||||||||||||||||
| 195 | /* scaling down */ | - | ||||||||||||||||||
| 196 | qint64 val = 0; | - | ||||||||||||||||||
| 197 | qint64 inc = (((qint64)s) << 16) / d; | - | ||||||||||||||||||
| 198 | int Cp = (((d << 14) + s - 1) / s); | - | ||||||||||||||||||
| 199 | for (int i = 0; i < d; i++) { 
 | 0 | ||||||||||||||||||
| 200 | int ap = ((0x10000 - (val & 0xffff)) * Cp) >> 16; | - | ||||||||||||||||||
| 201 | p[j] = ap | (Cp << 16); | - | ||||||||||||||||||
| 202 | j++; | - | ||||||||||||||||||
| 203 | val += inc; | - | ||||||||||||||||||
| 204 | } never executed:  end of block | 0 | ||||||||||||||||||
| 205 | } never executed:  end of block | 0 | ||||||||||||||||||
| 206 | if (rv) { 
 | 0 | ||||||||||||||||||
| 207 | int tmp; | - | ||||||||||||||||||
| 208 | for (int i = d / 2; --i >= 0; ) { 
 | 0 | ||||||||||||||||||
| 209 | tmp = p[i]; | - | ||||||||||||||||||
| 210 | p[i] = p[d - i - 1]; | - | ||||||||||||||||||
| 211 | p[d - i - 1] = tmp; | - | ||||||||||||||||||
| 212 | } never executed:  end of block | 0 | ||||||||||||||||||
| 213 | } never executed:  end of block | 0 | ||||||||||||||||||
| 214 | return p; never executed:  return p; | 0 | ||||||||||||||||||
| 215 | } | - | ||||||||||||||||||
| 216 | - | |||||||||||||||||||
| 217 | QImageScaleInfo* QImageScale::qimageFreeScaleInfo(QImageScaleInfo *isi) | - | ||||||||||||||||||
| 218 | { | - | ||||||||||||||||||
| 219 | if (isi) { 
 | 0 | ||||||||||||||||||
| 220 | delete[] isi->xpoints; | - | ||||||||||||||||||
| 221 | delete[] isi->ypoints; | - | ||||||||||||||||||
| 222 | delete[] isi->xapoints; | - | ||||||||||||||||||
| 223 | delete[] isi->yapoints; | - | ||||||||||||||||||
| 224 | delete isi; | - | ||||||||||||||||||
| 225 | } never executed:  end of block | 0 | ||||||||||||||||||
| 226 | return 0; never executed:  return 0; | 0 | ||||||||||||||||||
| 227 | } | - | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img, | - | ||||||||||||||||||
| 230 | int sw, int sh, | - | ||||||||||||||||||
| 231 | int dw, int dh, char aa) | - | ||||||||||||||||||
| 232 | { | - | ||||||||||||||||||
| 233 | QImageScaleInfo *isi; | - | ||||||||||||||||||
| 234 | int scw, sch; | - | ||||||||||||||||||
| 235 | - | |||||||||||||||||||
| 236 | scw = dw * qlonglong(img.width()) / sw; | - | ||||||||||||||||||
| 237 | sch = dh * qlonglong(img.height()) / sh; | - | ||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | isi = new QImageScaleInfo; | - | ||||||||||||||||||
| 240 | if (!isi) 
 | 0 | ||||||||||||||||||
| 241 | return 0; never executed:  return 0; | 0 | ||||||||||||||||||
| 242 | memset(isi, 0, sizeof(QImageScaleInfo)); | - | ||||||||||||||||||
| 243 | - | |||||||||||||||||||
| 244 | isi->xup_yup = (qAbs(dw) >= sw) + ((qAbs(dh) >= sh) << 1); | - | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | isi->xpoints = qimageCalcXPoints(img.width(), scw); | - | ||||||||||||||||||
| 247 | if (!isi->xpoints) 
 | 0 | ||||||||||||||||||
| 248 | return qimageFreeScaleInfo(isi); never executed:  return qimageFreeScaleInfo(isi); | 0 | ||||||||||||||||||
| 249 | isi->ypoints = qimageCalcYPoints((const unsigned int *)img.scanLine(0), | - | ||||||||||||||||||
| 250 | img.bytesPerLine() / 4, img.height(), sch); | - | ||||||||||||||||||
| 251 | if (!isi->ypoints) 
 | 0 | ||||||||||||||||||
| 252 | return qimageFreeScaleInfo(isi); never executed:  return qimageFreeScaleInfo(isi); | 0 | ||||||||||||||||||
| 253 | if (aa) { 
 | 0 | ||||||||||||||||||
| 254 | isi->xapoints = qimageCalcApoints(img.width(), scw, isi->xup_yup & 1); | - | ||||||||||||||||||
| 255 | if (!isi->xapoints) 
 | 0 | ||||||||||||||||||
| 256 | return qimageFreeScaleInfo(isi); never executed:  return qimageFreeScaleInfo(isi); | 0 | ||||||||||||||||||
| 257 | isi->yapoints = qimageCalcApoints(img.height(), sch, isi->xup_yup & 2); | - | ||||||||||||||||||
| 258 | if (!isi->yapoints) 
 | 0 | ||||||||||||||||||
| 259 | return qimageFreeScaleInfo(isi); never executed:  return qimageFreeScaleInfo(isi); | 0 | ||||||||||||||||||
| 260 | } never executed:  end of block | 0 | ||||||||||||||||||
| 261 | return isi; never executed:  return isi; | 0 | ||||||||||||||||||
| 262 | } | - | ||||||||||||||||||
| 263 | - | |||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 266 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | static void qt_qimageScaleAARGBA_down_x_up_y(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 269 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 270 | - | |||||||||||||||||||
| 271 | static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 272 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 273 | - | |||||||||||||||||||
| 274 | #if defined(QT_COMPILER_SUPPORTS_SSE4_1) | - | ||||||||||||||||||
| 275 | template<bool RGB> | - | ||||||||||||||||||
| 276 | void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 277 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 278 | template<bool RGB> | - | ||||||||||||||||||
| 279 | void qt_qimageScaleAARGBA_down_x_up_y_sse4(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 280 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 281 | template<bool RGB> | - | ||||||||||||||||||
| 282 | void qt_qimageScaleAARGBA_down_xy_sse4(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 283 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 284 | #endif | - | ||||||||||||||||||
| 285 | - | |||||||||||||||||||
| 286 | #if defined(__ARM_NEON__) | - | ||||||||||||||||||
| 287 | template<bool RGB> | - | ||||||||||||||||||
| 288 | void qt_qimageScaleAARGBA_up_x_down_y_neon(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 289 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 290 | template<bool RGB> | - | ||||||||||||||||||
| 291 | void qt_qimageScaleAARGBA_down_x_up_y_neon(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 292 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 293 | template<bool RGB> | - | ||||||||||||||||||
| 294 | void qt_qimageScaleAARGBA_down_xy_neon(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 295 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 296 | #endif | - | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 299 | int dw, int dh, int dow, int sow) | - | ||||||||||||||||||
| 300 | { | - | ||||||||||||||||||
| 301 | const unsigned int **ypoints = isi->ypoints; | - | ||||||||||||||||||
| 302 | int *xpoints = isi->xpoints; | - | ||||||||||||||||||
| 303 | int *xapoints = isi->xapoints; | - | ||||||||||||||||||
| 304 | int *yapoints = isi->yapoints; | - | ||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | /* go through every scanline in the output buffer */ | - | ||||||||||||||||||
| 307 | for (int y = 0; y < dh; y++) { 
 | 0 | ||||||||||||||||||
| 308 | /* calculate the source line we'll scan from */ | - | ||||||||||||||||||
| 309 | const unsigned int *sptr = ypoints[y]; | - | ||||||||||||||||||
| 310 | unsigned int *dptr = dest + (y * dow); | - | ||||||||||||||||||
| 311 | const int yap = yapoints[y]; | - | ||||||||||||||||||
| 312 | if (yap > 0) { 
 | 0 | ||||||||||||||||||
| 313 | for (int x = 0; x < dw; x++) { 
 | 0 | ||||||||||||||||||
| 314 | const unsigned int *pix = sptr + xpoints[x]; | - | ||||||||||||||||||
| 315 | const int xap = xapoints[x]; | - | ||||||||||||||||||
| 316 | if (xap > 0) 
 | 0 | ||||||||||||||||||
| 317 | *dptr = interpolate_4_pixels(pix, pix + sow, xap, yap); never executed:  *dptr = interpolate_4_pixels(pix, pix + sow, xap, yap); | 0 | ||||||||||||||||||
| 318 | else | - | ||||||||||||||||||
| 319 | *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - yap, pix[sow], yap); never executed:  *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - yap, pix[sow], yap); | 0 | ||||||||||||||||||
| 320 | dptr++; | - | ||||||||||||||||||
| 321 | } never executed:  end of block | 0 | ||||||||||||||||||
| 322 | } else { never executed:  end of block | 0 | ||||||||||||||||||
| 323 | for (int x = 0; x < dw; x++) { 
 | 0 | ||||||||||||||||||
| 324 | const unsigned int *pix = sptr + xpoints[x]; | - | ||||||||||||||||||
| 325 | const int xap = xapoints[x]; | - | ||||||||||||||||||
| 326 | if (xap > 0) 
 | 0 | ||||||||||||||||||
| 327 | *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap); never executed:  *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap); | 0 | ||||||||||||||||||
| 328 | else | - | ||||||||||||||||||
| 329 | *dptr = pix[0]; never executed:  *dptr = pix[0]; | 0 | ||||||||||||||||||
| 330 | dptr++; | - | ||||||||||||||||||
| 331 | } never executed:  end of block | 0 | ||||||||||||||||||
| 332 | } never executed:  end of block | 0 | ||||||||||||||||||
| 333 | } | - | ||||||||||||||||||
| 334 | } never executed:  end of block | 0 | ||||||||||||||||||
| 335 | - | |||||||||||||||||||
| 336 | /* scale by area sampling */ | - | ||||||||||||||||||
| 337 | static void qt_qimageScaleAARGBA(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 338 | int dw, int dh, int dow, int sow) | - | ||||||||||||||||||
| 339 | { | - | ||||||||||||||||||
| 340 | /* scaling up both ways */ | - | ||||||||||||||||||
| 341 | if (isi->xup_yup == 3) { 
 | 0 | ||||||||||||||||||
| 342 | qt_qimageScaleAARGBA_up_xy(isi, dest, dw, dh, dow, sow); | - | ||||||||||||||||||
| 343 | } never executed:  end of block | 0 | ||||||||||||||||||
| 344 | /* if we're scaling down vertically */ | - | ||||||||||||||||||
| 345 | else if (isi->xup_yup == 1) { 
 | 0 | ||||||||||||||||||
| 346 | #ifdef QT_COMPILER_SUPPORTS_SSE4_1 | - | ||||||||||||||||||
| 347 | if (qCpuHasFeature(SSE4_1)) 
 
 | 0 | ||||||||||||||||||
| 348 | qt_qimageScaleAARGBA_up_x_down_y_sse4<false>(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGBA_up_x_down_y_sse4<false>(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 349 | else | - | ||||||||||||||||||
| 350 | #elif defined(__ARM_NEON__) | - | ||||||||||||||||||
| 351 | if (qCpuHasFeature(NEON)) | - | ||||||||||||||||||
| 352 | qt_qimageScaleAARGBA_up_x_down_y_neon<false>(isi, dest, dw, dh, dow, sow); | - | ||||||||||||||||||
| 353 | else | - | ||||||||||||||||||
| 354 | #endif | - | ||||||||||||||||||
| 355 | qt_qimageScaleAARGBA_up_x_down_y(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGBA_up_x_down_y(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 356 | } | - | ||||||||||||||||||
| 357 | /* if we're scaling down horizontally */ | - | ||||||||||||||||||
| 358 | else if (isi->xup_yup == 2) { 
 | 0 | ||||||||||||||||||
| 359 | #ifdef QT_COMPILER_SUPPORTS_SSE4_1 | - | ||||||||||||||||||
| 360 | if (qCpuHasFeature(SSE4_1)) 
 
 | 0 | ||||||||||||||||||
| 361 | qt_qimageScaleAARGBA_down_x_up_y_sse4<false>(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGBA_down_x_up_y_sse4<false>(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 362 | else | - | ||||||||||||||||||
| 363 | #elif defined(__ARM_NEON__) | - | ||||||||||||||||||
| 364 | if (qCpuHasFeature(NEON)) | - | ||||||||||||||||||
| 365 | qt_qimageScaleAARGBA_down_x_up_y_neon<false>(isi, dest, dw, dh, dow, sow); | - | ||||||||||||||||||
| 366 | else | - | ||||||||||||||||||
| 367 | #endif | - | ||||||||||||||||||
| 368 | qt_qimageScaleAARGBA_down_x_up_y(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGBA_down_x_up_y(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 369 | } | - | ||||||||||||||||||
| 370 | /* if we're scaling down horizontally & vertically */ | - | ||||||||||||||||||
| 371 | else { | - | ||||||||||||||||||
| 372 | #ifdef QT_COMPILER_SUPPORTS_SSE4_1 | - | ||||||||||||||||||
| 373 | if (qCpuHasFeature(SSE4_1)) 
 
 | 0 | ||||||||||||||||||
| 374 | qt_qimageScaleAARGBA_down_xy_sse4<false>(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGBA_down_xy_sse4<false>(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 375 | else | - | ||||||||||||||||||
| 376 | #elif defined(__ARM_NEON__) | - | ||||||||||||||||||
| 377 | if (qCpuHasFeature(NEON)) | - | ||||||||||||||||||
| 378 | qt_qimageScaleAARGBA_down_xy_neon<false>(isi, dest, dw, dh, dow, sow); | - | ||||||||||||||||||
| 379 | else | - | ||||||||||||||||||
| 380 | #endif | - | ||||||||||||||||||
| 381 | qt_qimageScaleAARGBA_down_xy(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGBA_down_xy(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 382 | } | - | ||||||||||||||||||
| 383 | } | - | ||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | inline static void qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap, int Cxy, int step, int &r, int &g, int &b, int &a) | - | ||||||||||||||||||
| 386 | { | - | ||||||||||||||||||
| 387 | r = qRed(*pix) * xyap; | - | ||||||||||||||||||
| 388 | g = qGreen(*pix) * xyap; | - | ||||||||||||||||||
| 389 | b = qBlue(*pix) * xyap; | - | ||||||||||||||||||
| 390 | a = qAlpha(*pix) * xyap; | - | ||||||||||||||||||
| 391 | int j; | - | ||||||||||||||||||
| 392 | for (j = (1 << 14) - xyap; j > Cxy; j -= Cxy) { 
 | 0 | ||||||||||||||||||
| 393 | pix += step; | - | ||||||||||||||||||
| 394 | r += qRed(*pix) * Cxy; | - | ||||||||||||||||||
| 395 | g += qGreen(*pix) * Cxy; | - | ||||||||||||||||||
| 396 | b += qBlue(*pix) * Cxy; | - | ||||||||||||||||||
| 397 | a += qAlpha(*pix) * Cxy; | - | ||||||||||||||||||
| 398 | } never executed:  end of block | 0 | ||||||||||||||||||
| 399 | pix += step; | - | ||||||||||||||||||
| 400 | r += qRed(*pix) * j; | - | ||||||||||||||||||
| 401 | g += qGreen(*pix) * j; | - | ||||||||||||||||||
| 402 | b += qBlue(*pix) * j; | - | ||||||||||||||||||
| 403 | a += qAlpha(*pix) * j; | - | ||||||||||||||||||
| 404 | } never executed:  end of block | 0 | ||||||||||||||||||
| 405 | - | |||||||||||||||||||
| 406 | static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 407 | int dw, int dh, int dow, int sow) | - | ||||||||||||||||||
| 408 | { | - | ||||||||||||||||||
| 409 | const unsigned int **ypoints = isi->ypoints; | - | ||||||||||||||||||
| 410 | int *xpoints = isi->xpoints; | - | ||||||||||||||||||
| 411 | int *xapoints = isi->xapoints; | - | ||||||||||||||||||
| 412 | int *yapoints = isi->yapoints; | - | ||||||||||||||||||
| 413 | - | |||||||||||||||||||
| 414 | /* go through every scanline in the output buffer */ | - | ||||||||||||||||||
| 415 | for (int y = 0; y < dh; y++) { 
 | 0 | ||||||||||||||||||
| 416 | int Cy = yapoints[y] >> 16; | - | ||||||||||||||||||
| 417 | int yap = yapoints[y] & 0xffff; | - | ||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | unsigned int *dptr = dest + (y * dow); | - | ||||||||||||||||||
| 420 | for (int x = 0; x < dw; x++) { 
 | 0 | ||||||||||||||||||
| 421 | const unsigned int *sptr = ypoints[y] + xpoints[x]; | - | ||||||||||||||||||
| 422 | int r, g, b, a; | - | ||||||||||||||||||
| 423 | qt_qimageScaleAARGBA_helper(sptr, yap, Cy, sow, r, g, b, a); | - | ||||||||||||||||||
| 424 | - | |||||||||||||||||||
| 425 | int xap = xapoints[x]; | - | ||||||||||||||||||
| 426 | if (xap > 0) { 
 | 0 | ||||||||||||||||||
| 427 | int rr, gg, bb, aa; | - | ||||||||||||||||||
| 428 | qt_qimageScaleAARGBA_helper(sptr + 1, yap, Cy, sow, rr, gg, bb, aa); | - | ||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | r = r * (256 - xap); | - | ||||||||||||||||||
| 431 | g = g * (256 - xap); | - | ||||||||||||||||||
| 432 | b = b * (256 - xap); | - | ||||||||||||||||||
| 433 | a = a * (256 - xap); | - | ||||||||||||||||||
| 434 | r = (r + (rr * xap)) >> 8; | - | ||||||||||||||||||
| 435 | g = (g + (gg * xap)) >> 8; | - | ||||||||||||||||||
| 436 | b = (b + (bb * xap)) >> 8; | - | ||||||||||||||||||
| 437 | a = (a + (aa * xap)) >> 8; | - | ||||||||||||||||||
| 438 | } never executed:  end of block | 0 | ||||||||||||||||||
| 439 | *dptr++ = qRgba(r >> 14, g >> 14, b >> 14, a >> 14); | - | ||||||||||||||||||
| 440 | } never executed:  end of block | 0 | ||||||||||||||||||
| 441 | } never executed:  end of block | 0 | ||||||||||||||||||
| 442 | } never executed:  end of block | 0 | ||||||||||||||||||
| 443 | - | |||||||||||||||||||
| 444 | static void qt_qimageScaleAARGBA_down_x_up_y(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 445 | int dw, int dh, int dow, int sow) | - | ||||||||||||||||||
| 446 | { | - | ||||||||||||||||||
| 447 | const unsigned int **ypoints = isi->ypoints; | - | ||||||||||||||||||
| 448 | int *xpoints = isi->xpoints; | - | ||||||||||||||||||
| 449 | int *xapoints = isi->xapoints; | - | ||||||||||||||||||
| 450 | int *yapoints = isi->yapoints; | - | ||||||||||||||||||
| 451 | - | |||||||||||||||||||
| 452 | /* go through every scanline in the output buffer */ | - | ||||||||||||||||||
| 453 | for (int y = 0; y < dh; y++) { 
 | 0 | ||||||||||||||||||
| 454 | unsigned int *dptr = dest + (y * dow); | - | ||||||||||||||||||
| 455 | for (int x = 0; x < dw; x++) { 
 | 0 | ||||||||||||||||||
| 456 | int Cx = xapoints[x] >> 16; | - | ||||||||||||||||||
| 457 | int xap = xapoints[x] & 0xffff; | - | ||||||||||||||||||
| 458 | - | |||||||||||||||||||
| 459 | const unsigned int *sptr = ypoints[y] + xpoints[x]; | - | ||||||||||||||||||
| 460 | int r, g, b, a; | - | ||||||||||||||||||
| 461 | qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, r, g, b, a); | - | ||||||||||||||||||
| 462 | - | |||||||||||||||||||
| 463 | int yap = yapoints[y]; | - | ||||||||||||||||||
| 464 | if (yap > 0) { 
 | 0 | ||||||||||||||||||
| 465 | int rr, gg, bb, aa; | - | ||||||||||||||||||
| 466 | qt_qimageScaleAARGBA_helper(sptr + sow, xap, Cx, 1, rr, gg, bb, aa); | - | ||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | r = r * (256 - yap); | - | ||||||||||||||||||
| 469 | g = g * (256 - yap); | - | ||||||||||||||||||
| 470 | b = b * (256 - yap); | - | ||||||||||||||||||
| 471 | a = a * (256 - yap); | - | ||||||||||||||||||
| 472 | r = (r + (rr * yap)) >> 8; | - | ||||||||||||||||||
| 473 | g = (g + (gg * yap)) >> 8; | - | ||||||||||||||||||
| 474 | b = (b + (bb * yap)) >> 8; | - | ||||||||||||||||||
| 475 | a = (a + (aa * yap)) >> 8; | - | ||||||||||||||||||
| 476 | } never executed:  end of block | 0 | ||||||||||||||||||
| 477 | *dptr = qRgba(r >> 14, g >> 14, b >> 14, a >> 14); | - | ||||||||||||||||||
| 478 | dptr++; | - | ||||||||||||||||||
| 479 | } never executed:  end of block | 0 | ||||||||||||||||||
| 480 | } never executed:  end of block | 0 | ||||||||||||||||||
| 481 | } never executed:  end of block | 0 | ||||||||||||||||||
| 482 | - | |||||||||||||||||||
| 483 | static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 484 | int dw, int dh, int dow, int sow) | - | ||||||||||||||||||
| 485 | { | - | ||||||||||||||||||
| 486 | const unsigned int **ypoints = isi->ypoints; | - | ||||||||||||||||||
| 487 | int *xpoints = isi->xpoints; | - | ||||||||||||||||||
| 488 | int *xapoints = isi->xapoints; | - | ||||||||||||||||||
| 489 | int *yapoints = isi->yapoints; | - | ||||||||||||||||||
| 490 | - | |||||||||||||||||||
| 491 | for (int y = 0; y < dh; y++) { 
 | 0 | ||||||||||||||||||
| 492 | int Cy = (yapoints[y]) >> 16; | - | ||||||||||||||||||
| 493 | int yap = (yapoints[y]) & 0xffff; | - | ||||||||||||||||||
| 494 | - | |||||||||||||||||||
| 495 | unsigned int *dptr = dest + (y * dow); | - | ||||||||||||||||||
| 496 | for (int x = 0; x < dw; x++) { 
 | 0 | ||||||||||||||||||
| 497 | int Cx = xapoints[x] >> 16; | - | ||||||||||||||||||
| 498 | int xap = xapoints[x] & 0xffff; | - | ||||||||||||||||||
| 499 | - | |||||||||||||||||||
| 500 | const unsigned int *sptr = ypoints[y] + xpoints[x]; | - | ||||||||||||||||||
| 501 | int rx, gx, bx, ax; | - | ||||||||||||||||||
| 502 | qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, rx, gx, bx, ax); | - | ||||||||||||||||||
| 503 | - | |||||||||||||||||||
| 504 | int r = ((rx>>4) * yap); | - | ||||||||||||||||||
| 505 | int g = ((gx>>4) * yap); | - | ||||||||||||||||||
| 506 | int b = ((bx>>4) * yap); | - | ||||||||||||||||||
| 507 | int a = ((ax>>4) * yap); | - | ||||||||||||||||||
| 508 | - | |||||||||||||||||||
| 509 | int j; | - | ||||||||||||||||||
| 510 | for (j = (1 << 14) - yap; j > Cy; j -= Cy) { 
 | 0 | ||||||||||||||||||
| 511 | sptr += sow; | - | ||||||||||||||||||
| 512 | qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, rx, gx, bx, ax); | - | ||||||||||||||||||
| 513 | r += ((rx>>4) * Cy); | - | ||||||||||||||||||
| 514 | g += ((gx>>4) * Cy); | - | ||||||||||||||||||
| 515 | b += ((bx>>4) * Cy); | - | ||||||||||||||||||
| 516 | a += ((ax>>4) * Cy); | - | ||||||||||||||||||
| 517 | } never executed:  end of block | 0 | ||||||||||||||||||
| 518 | sptr += sow; | - | ||||||||||||||||||
| 519 | qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, rx, gx, bx, ax); | - | ||||||||||||||||||
| 520 | - | |||||||||||||||||||
| 521 | r += ((rx>>4) * j); | - | ||||||||||||||||||
| 522 | g += ((gx>>4) * j); | - | ||||||||||||||||||
| 523 | b += ((bx>>4) * j); | - | ||||||||||||||||||
| 524 | a += ((ax>>4) * j); | - | ||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | *dptr = qRgba(r >> 24, g >> 24, b >> 24, a >> 24); | - | ||||||||||||||||||
| 527 | dptr++; | - | ||||||||||||||||||
| 528 | } never executed:  end of block | 0 | ||||||||||||||||||
| 529 | } never executed:  end of block | 0 | ||||||||||||||||||
| 530 | } never executed:  end of block | 0 | ||||||||||||||||||
| 531 | - | |||||||||||||||||||
| 532 | static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 533 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 534 | - | |||||||||||||||||||
| 535 | static void qt_qimageScaleAARGB_down_x_up_y(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 536 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 537 | - | |||||||||||||||||||
| 538 | static void qt_qimageScaleAARGB_down_xy(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 539 | int dw, int dh, int dow, int sow); | - | ||||||||||||||||||
| 540 | - | |||||||||||||||||||
| 541 | /* scale by area sampling - IGNORE the ALPHA byte*/ | - | ||||||||||||||||||
| 542 | static void qt_qimageScaleAARGB(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 543 | int dw, int dh, int dow, int sow) | - | ||||||||||||||||||
| 544 | { | - | ||||||||||||||||||
| 545 | /* scaling up both ways */ | - | ||||||||||||||||||
| 546 | if (isi->xup_yup == 3) { 
 | 0 | ||||||||||||||||||
| 547 | qt_qimageScaleAARGBA_up_xy(isi, dest, dw, dh, dow, sow); | - | ||||||||||||||||||
| 548 | } never executed:  end of block | 0 | ||||||||||||||||||
| 549 | /* if we're scaling down vertically */ | - | ||||||||||||||||||
| 550 | else if (isi->xup_yup == 1) { 
 | 0 | ||||||||||||||||||
| 551 | #ifdef QT_COMPILER_SUPPORTS_SSE4_1 | - | ||||||||||||||||||
| 552 | if (qCpuHasFeature(SSE4_1)) 
 
 | 0 | ||||||||||||||||||
| 553 | qt_qimageScaleAARGBA_up_x_down_y_sse4<true>(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGBA_up_x_down_y_sse4<true>(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 554 | else | - | ||||||||||||||||||
| 555 | #elif defined(__ARM_NEON__) | - | ||||||||||||||||||
| 556 | if (qCpuHasFeature(NEON)) | - | ||||||||||||||||||
| 557 | qt_qimageScaleAARGBA_up_x_down_y_neon<true>(isi, dest, dw, dh, dow, sow); | - | ||||||||||||||||||
| 558 | else | - | ||||||||||||||||||
| 559 | #endif | - | ||||||||||||||||||
| 560 | qt_qimageScaleAARGB_up_x_down_y(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGB_up_x_down_y(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 561 | } | - | ||||||||||||||||||
| 562 | /* if we're scaling down horizontally */ | - | ||||||||||||||||||
| 563 | else if (isi->xup_yup == 2) { 
 | 0 | ||||||||||||||||||
| 564 | #ifdef QT_COMPILER_SUPPORTS_SSE4_1 | - | ||||||||||||||||||
| 565 | if (qCpuHasFeature(SSE4_1)) 
 
 | 0 | ||||||||||||||||||
| 566 | qt_qimageScaleAARGBA_down_x_up_y_sse4<true>(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGBA_down_x_up_y_sse4<true>(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 567 | else | - | ||||||||||||||||||
| 568 | #elif defined(__ARM_NEON__) | - | ||||||||||||||||||
| 569 | if (qCpuHasFeature(NEON)) | - | ||||||||||||||||||
| 570 | qt_qimageScaleAARGBA_down_x_up_y_neon<true>(isi, dest, dw, dh, dow, sow); | - | ||||||||||||||||||
| 571 | else | - | ||||||||||||||||||
| 572 | #endif | - | ||||||||||||||||||
| 573 | qt_qimageScaleAARGB_down_x_up_y(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGB_down_x_up_y(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 574 | } | - | ||||||||||||||||||
| 575 | /* if we're scaling down horizontally & vertically */ | - | ||||||||||||||||||
| 576 | else { | - | ||||||||||||||||||
| 577 | #ifdef QT_COMPILER_SUPPORTS_SSE4_1 | - | ||||||||||||||||||
| 578 | if (qCpuHasFeature(SSE4_1)) 
 
 | 0 | ||||||||||||||||||
| 579 | qt_qimageScaleAARGBA_down_xy_sse4<true>(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGBA_down_xy_sse4<true>(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 580 | else | - | ||||||||||||||||||
| 581 | #elif defined(__ARM_NEON__) | - | ||||||||||||||||||
| 582 | if (qCpuHasFeature(NEON)) | - | ||||||||||||||||||
| 583 | qt_qimageScaleAARGBA_down_xy_neon<true>(isi, dest, dw, dh, dow, sow); | - | ||||||||||||||||||
| 584 | else | - | ||||||||||||||||||
| 585 | #endif | - | ||||||||||||||||||
| 586 | qt_qimageScaleAARGB_down_xy(isi, dest, dw, dh, dow, sow); never executed:  qt_qimageScaleAARGB_down_xy(isi, dest, dw, dh, dow, sow); | 0 | ||||||||||||||||||
| 587 | } | - | ||||||||||||||||||
| 588 | } | - | ||||||||||||||||||
| 589 | - | |||||||||||||||||||
| 590 | - | |||||||||||||||||||
| 591 | inline static void qt_qimageScaleAARGB_helper(const unsigned int *pix, int xyap, int Cxy, int step, int &r, int &g, int &b) | - | ||||||||||||||||||
| 592 | { | - | ||||||||||||||||||
| 593 | r = qRed(*pix) * xyap; | - | ||||||||||||||||||
| 594 | g = qGreen(*pix) * xyap; | - | ||||||||||||||||||
| 595 | b = qBlue(*pix) * xyap; | - | ||||||||||||||||||
| 596 | int j; | - | ||||||||||||||||||
| 597 | for (j = (1 << 14) - xyap; j > Cxy; j -= Cxy) { 
 | 0 | ||||||||||||||||||
| 598 | pix += step; | - | ||||||||||||||||||
| 599 | r += qRed(*pix) * Cxy; | - | ||||||||||||||||||
| 600 | g += qGreen(*pix) * Cxy; | - | ||||||||||||||||||
| 601 | b += qBlue(*pix) * Cxy; | - | ||||||||||||||||||
| 602 | } never executed:  end of block | 0 | ||||||||||||||||||
| 603 | pix += step; | - | ||||||||||||||||||
| 604 | r += qRed(*pix) * j; | - | ||||||||||||||||||
| 605 | g += qGreen(*pix) * j; | - | ||||||||||||||||||
| 606 | b += qBlue(*pix) * j; | - | ||||||||||||||||||
| 607 | } never executed:  end of block | 0 | ||||||||||||||||||
| 608 | - | |||||||||||||||||||
| 609 | static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 610 | int dw, int dh, int dow, int sow) | - | ||||||||||||||||||
| 611 | { | - | ||||||||||||||||||
| 612 | const unsigned int **ypoints = isi->ypoints; | - | ||||||||||||||||||
| 613 | int *xpoints = isi->xpoints; | - | ||||||||||||||||||
| 614 | int *xapoints = isi->xapoints; | - | ||||||||||||||||||
| 615 | int *yapoints = isi->yapoints; | - | ||||||||||||||||||
| 616 | - | |||||||||||||||||||
| 617 | /* go through every scanline in the output buffer */ | - | ||||||||||||||||||
| 618 | for (int y = 0; y < dh; y++) { 
 | 0 | ||||||||||||||||||
| 619 | int Cy = yapoints[y] >> 16; | - | ||||||||||||||||||
| 620 | int yap = yapoints[y] & 0xffff; | - | ||||||||||||||||||
| 621 | - | |||||||||||||||||||
| 622 | unsigned int *dptr = dest + (y * dow); | - | ||||||||||||||||||
| 623 | for (int x = 0; x < dw; x++) { 
 | 0 | ||||||||||||||||||
| 624 | const unsigned int *sptr = ypoints[y] + xpoints[x]; | - | ||||||||||||||||||
| 625 | int r, g, b; | - | ||||||||||||||||||
| 626 | qt_qimageScaleAARGB_helper(sptr, yap, Cy, sow, r, g, b); | - | ||||||||||||||||||
| 627 | - | |||||||||||||||||||
| 628 | int xap = xapoints[x]; | - | ||||||||||||||||||
| 629 | if (xap > 0) { 
 | 0 | ||||||||||||||||||
| 630 | int rr, bb, gg; | - | ||||||||||||||||||
| 631 | qt_qimageScaleAARGB_helper(sptr + 1, yap, Cy, sow, rr, gg, bb); | - | ||||||||||||||||||
| 632 | - | |||||||||||||||||||
| 633 | r = r * (256 - xap); | - | ||||||||||||||||||
| 634 | g = g * (256 - xap); | - | ||||||||||||||||||
| 635 | b = b * (256 - xap); | - | ||||||||||||||||||
| 636 | r = (r + (rr * xap)) >> 8; | - | ||||||||||||||||||
| 637 | g = (g + (gg * xap)) >> 8; | - | ||||||||||||||||||
| 638 | b = (b + (bb * xap)) >> 8; | - | ||||||||||||||||||
| 639 | } never executed:  end of block | 0 | ||||||||||||||||||
| 640 | *dptr++ = qRgb(r >> 14, g >> 14, b >> 14); | - | ||||||||||||||||||
| 641 | } never executed:  end of block | 0 | ||||||||||||||||||
| 642 | } never executed:  end of block | 0 | ||||||||||||||||||
| 643 | } never executed:  end of block | 0 | ||||||||||||||||||
| 644 | - | |||||||||||||||||||
| 645 | static void qt_qimageScaleAARGB_down_x_up_y(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 646 | int dw, int dh, int dow, int sow) | - | ||||||||||||||||||
| 647 | { | - | ||||||||||||||||||
| 648 | const unsigned int **ypoints = isi->ypoints; | - | ||||||||||||||||||
| 649 | int *xpoints = isi->xpoints; | - | ||||||||||||||||||
| 650 | int *xapoints = isi->xapoints; | - | ||||||||||||||||||
| 651 | int *yapoints = isi->yapoints; | - | ||||||||||||||||||
| 652 | - | |||||||||||||||||||
| 653 | /* go through every scanline in the output buffer */ | - | ||||||||||||||||||
| 654 | for (int y = 0; y < dh; y++) { 
 | 0 | ||||||||||||||||||
| 655 | unsigned int *dptr = dest + (y * dow); | - | ||||||||||||||||||
| 656 | for (int x = 0; x < dw; x++) { 
 | 0 | ||||||||||||||||||
| 657 | int Cx = xapoints[x] >> 16; | - | ||||||||||||||||||
| 658 | int xap = xapoints[x] & 0xffff; | - | ||||||||||||||||||
| 659 | - | |||||||||||||||||||
| 660 | const unsigned int *sptr = ypoints[y] + xpoints[x]; | - | ||||||||||||||||||
| 661 | int r, g, b; | - | ||||||||||||||||||
| 662 | qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, r, g, b); | - | ||||||||||||||||||
| 663 | - | |||||||||||||||||||
| 664 | int yap = yapoints[y]; | - | ||||||||||||||||||
| 665 | if (yap > 0) { 
 | 0 | ||||||||||||||||||
| 666 | int rr, bb, gg; | - | ||||||||||||||||||
| 667 | qt_qimageScaleAARGB_helper(sptr + sow, xap, Cx, 1, rr, gg, bb); | - | ||||||||||||||||||
| 668 | - | |||||||||||||||||||
| 669 | r = r * (256 - yap); | - | ||||||||||||||||||
| 670 | g = g * (256 - yap); | - | ||||||||||||||||||
| 671 | b = b * (256 - yap); | - | ||||||||||||||||||
| 672 | r = (r + (rr * yap)) >> 8; | - | ||||||||||||||||||
| 673 | g = (g + (gg * yap)) >> 8; | - | ||||||||||||||||||
| 674 | b = (b + (bb * yap)) >> 8; | - | ||||||||||||||||||
| 675 | } never executed:  end of block | 0 | ||||||||||||||||||
| 676 | *dptr++ = qRgb(r >> 14, g >> 14, b >> 14); | - | ||||||||||||||||||
| 677 | } never executed:  end of block | 0 | ||||||||||||||||||
| 678 | } never executed:  end of block | 0 | ||||||||||||||||||
| 679 | } never executed:  end of block | 0 | ||||||||||||||||||
| 680 | - | |||||||||||||||||||
| 681 | static void qt_qimageScaleAARGB_down_xy(QImageScaleInfo *isi, unsigned int *dest, | - | ||||||||||||||||||
| 682 | int dw, int dh, int dow, int sow) | - | ||||||||||||||||||
| 683 | { | - | ||||||||||||||||||
| 684 | const unsigned int **ypoints = isi->ypoints; | - | ||||||||||||||||||
| 685 | int *xpoints = isi->xpoints; | - | ||||||||||||||||||
| 686 | int *xapoints = isi->xapoints; | - | ||||||||||||||||||
| 687 | int *yapoints = isi->yapoints; | - | ||||||||||||||||||
| 688 | - | |||||||||||||||||||
| 689 | for (int y = 0; y < dh; y++) { 
 | 0 | ||||||||||||||||||
| 690 | int Cy = yapoints[y] >> 16; | - | ||||||||||||||||||
| 691 | int yap = yapoints[y] & 0xffff; | - | ||||||||||||||||||
| 692 | - | |||||||||||||||||||
| 693 | unsigned int *dptr = dest + (y * dow); | - | ||||||||||||||||||
| 694 | for (int x = 0; x < dw; x++) { 
 | 0 | ||||||||||||||||||
| 695 | int Cx = xapoints[x] >> 16; | - | ||||||||||||||||||
| 696 | int xap = xapoints[x] & 0xffff; | - | ||||||||||||||||||
| 697 | - | |||||||||||||||||||
| 698 | const unsigned int *sptr = ypoints[y] + xpoints[x]; | - | ||||||||||||||||||
| 699 | int rx, gx, bx; | - | ||||||||||||||||||
| 700 | qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, rx, gx, bx); | - | ||||||||||||||||||
| 701 | - | |||||||||||||||||||
| 702 | int r = (rx >> 4) * yap; | - | ||||||||||||||||||
| 703 | int g = (gx >> 4) * yap; | - | ||||||||||||||||||
| 704 | int b = (bx >> 4) * yap; | - | ||||||||||||||||||
| 705 | - | |||||||||||||||||||
| 706 | int j; | - | ||||||||||||||||||
| 707 | for (j = (1 << 14) - yap; j > Cy; j -= Cy) { 
 | 0 | ||||||||||||||||||
| 708 | sptr += sow; | - | ||||||||||||||||||
| 709 | qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, rx, gx, bx); | - | ||||||||||||||||||
| 710 | - | |||||||||||||||||||
| 711 | r += (rx >> 4) * Cy; | - | ||||||||||||||||||
| 712 | g += (gx >> 4) * Cy; | - | ||||||||||||||||||
| 713 | b += (bx >> 4) * Cy; | - | ||||||||||||||||||
| 714 | } never executed:  end of block | 0 | ||||||||||||||||||
| 715 | sptr += sow; | - | ||||||||||||||||||
| 716 | qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, rx, gx, bx); | - | ||||||||||||||||||
| 717 | - | |||||||||||||||||||
| 718 | r += (rx >> 4) * j; | - | ||||||||||||||||||
| 719 | g += (gx >> 4) * j; | - | ||||||||||||||||||
| 720 | b += (bx >> 4) * j; | - | ||||||||||||||||||
| 721 | - | |||||||||||||||||||
| 722 | *dptr = qRgb(r >> 24, g >> 24, b >> 24); | - | ||||||||||||||||||
| 723 | dptr++; | - | ||||||||||||||||||
| 724 | } never executed:  end of block | 0 | ||||||||||||||||||
| 725 | } never executed:  end of block | 0 | ||||||||||||||||||
| 726 | } never executed:  end of block | 0 | ||||||||||||||||||
| 727 | - | |||||||||||||||||||
| 728 | QImage qSmoothScaleImage(const QImage &src, int dw, int dh) | - | ||||||||||||||||||
| 729 | { | - | ||||||||||||||||||
| 730 | QImage buffer; | - | ||||||||||||||||||
| 731 | if (src.isNull() || dw <= 0 || dh <= 0) 
 
 
 | 0 | ||||||||||||||||||
| 732 | return buffer; never executed:  return buffer; | 0 | ||||||||||||||||||
| 733 | - | |||||||||||||||||||
| 734 | int w = src.width(); | - | ||||||||||||||||||
| 735 | int h = src.height(); | - | ||||||||||||||||||
| 736 | QImageScaleInfo *scaleinfo = | - | ||||||||||||||||||
| 737 | qimageCalcScaleInfo(src, w, h, dw, dh, true); | - | ||||||||||||||||||
| 738 | if (!scaleinfo) 
 | 0 | ||||||||||||||||||
| 739 | return buffer; never executed:  return buffer; | 0 | ||||||||||||||||||
| 740 | - | |||||||||||||||||||
| 741 | buffer = QImage(dw, dh, src.format()); | - | ||||||||||||||||||
| 742 | if (buffer.isNull()) { 
 | 0 | ||||||||||||||||||
| 743 | qWarning("QImage: out of memory, returning null"); | - | ||||||||||||||||||
| 744 | qimageFreeScaleInfo(scaleinfo); | - | ||||||||||||||||||
| 745 | return QImage(); never executed:  return QImage(); | 0 | ||||||||||||||||||
| 746 | } | - | ||||||||||||||||||
| 747 | - | |||||||||||||||||||
| 748 | if (src.hasAlphaChannel()) 
 | 0 | ||||||||||||||||||
| 749 | qt_qimageScaleAARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0), never executed:  qt_qimageScaleAARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0), dw, dh, dw, src.bytesPerLine() / 4); | 0 | ||||||||||||||||||
| 750 | dw, dh, dw, src.bytesPerLine() / 4); never executed:  qt_qimageScaleAARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0), dw, dh, dw, src.bytesPerLine() / 4); | 0 | ||||||||||||||||||
| 751 | else | - | ||||||||||||||||||
| 752 | qt_qimageScaleAARGB(scaleinfo, (unsigned int *)buffer.scanLine(0), never executed:  qt_qimageScaleAARGB(scaleinfo, (unsigned int *)buffer.scanLine(0), dw, dh, dw, src.bytesPerLine() / 4); | 0 | ||||||||||||||||||
| 753 | dw, dh, dw, src.bytesPerLine() / 4); never executed:  qt_qimageScaleAARGB(scaleinfo, (unsigned int *)buffer.scanLine(0), dw, dh, dw, src.bytesPerLine() / 4); | 0 | ||||||||||||||||||
| 754 | - | |||||||||||||||||||
| 755 | qimageFreeScaleInfo(scaleinfo); | - | ||||||||||||||||||
| 756 | return buffer; never executed:  return buffer; | 0 | ||||||||||||||||||
| 757 | } | - | ||||||||||||||||||
| 758 | - | |||||||||||||||||||
| 759 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |