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