Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | #include <qglobal.h> | - |
42 | | - |
43 | #include <qstylehints.h> | - |
44 | #include <qguiapplication.h> | - |
45 | #include <qatomic.h> | - |
46 | #include <private/qdrawhelper_p.h> | - |
47 | #include <private/qpaintengine_raster_p.h> | - |
48 | #include <private/qpainter_p.h> | - |
49 | #include <private/qdrawhelper_x86_p.h> | - |
50 | #include <private/qdrawingprimitive_sse2_p.h> | - |
51 | #include <private/qdrawhelper_neon_p.h> | - |
52 | #if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) || defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) | - |
53 | #include <private/qdrawhelper_mips_dsp_p.h> | - |
54 | #endif | - |
55 | #include <private/qguiapplication_p.h> | - |
56 | #include <private/qrgba64_p.h> | - |
57 | #include <qmath.h> | - |
58 | | - |
59 | QT_BEGIN_NAMESPACE | - |
60 | | - |
61 | #define MASK(src, a) src = BYTE_MUL(src, a) | - |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | | - |
67 | enum { | - |
68 | fixed_scale = 1 << 16, | - |
69 | half_point = 1 << 15 | - |
70 | }; | - |
71 | | - |
72 | | - |
73 | static const int buffer_size = 2048; | - |
74 | | - |
75 | template<QImage::Format> Q_DECL_CONSTEXPR uint redWidth(); | - |
76 | template<QImage::Format> Q_DECL_CONSTEXPR uint redShift(); | - |
77 | template<QImage::Format> Q_DECL_CONSTEXPR uint greenWidth(); | - |
78 | template<QImage::Format> Q_DECL_CONSTEXPR uint greenShift(); | - |
79 | template<QImage::Format> Q_DECL_CONSTEXPR uint blueWidth(); | - |
80 | template<QImage::Format> Q_DECL_CONSTEXPR uint blueShift(); | - |
81 | template<QImage::Format> Q_DECL_CONSTEXPR uint alphaWidth(); | - |
82 | template<QImage::Format> Q_DECL_CONSTEXPR uint alphaShift(); | - |
83 | | - |
84 | template<> Q_DECL_CONSTEXPR uint redWidth<QImage::Format_RGB16>() { return 5; } | - |
85 | template<> Q_DECL_CONSTEXPR uint redWidth<QImage::Format_RGB444>() { return 4; } | - |
86 | template<> Q_DECL_CONSTEXPR uint redWidth<QImage::Format_RGB555>() { return 5; } | - |
87 | template<> Q_DECL_CONSTEXPR uint redWidth<QImage::Format_RGB666>() { return 6; } | - |
88 | template<> Q_DECL_CONSTEXPR uint redWidth<QImage::Format_RGB888>() { return 8; } | - |
89 | template<> Q_DECL_CONSTEXPR uint redWidth<QImage::Format_ARGB4444_Premultiplied>() { return 4; } | - |
90 | template<> Q_DECL_CONSTEXPR uint redWidth<QImage::Format_ARGB8555_Premultiplied>() { return 5; } | - |
91 | template<> Q_DECL_CONSTEXPR uint redWidth<QImage::Format_ARGB8565_Premultiplied>() { return 5; } | - |
92 | template<> Q_DECL_CONSTEXPR uint redWidth<QImage::Format_ARGB6666_Premultiplied>() { return 6; } | - |
93 | template<> Q_DECL_CONSTEXPR uint redShift<QImage::Format_RGB16>() { return 11; } | - |
94 | template<> Q_DECL_CONSTEXPR uint redShift<QImage::Format_RGB444>() { return 8; } | - |
95 | template<> Q_DECL_CONSTEXPR uint redShift<QImage::Format_RGB555>() { return 10; } | - |
96 | template<> Q_DECL_CONSTEXPR uint redShift<QImage::Format_RGB666>() { return 12; } | - |
97 | template<> Q_DECL_CONSTEXPR uint redShift<QImage::Format_RGB888>() { return 16; } | - |
98 | template<> Q_DECL_CONSTEXPR uint redShift<QImage::Format_ARGB4444_Premultiplied>() { return 8; } | - |
99 | template<> Q_DECL_CONSTEXPR uint redShift<QImage::Format_ARGB8555_Premultiplied>() { return 18; } | - |
100 | template<> Q_DECL_CONSTEXPR uint redShift<QImage::Format_ARGB8565_Premultiplied>() { return 19; } | - |
101 | template<> Q_DECL_CONSTEXPR uint redShift<QImage::Format_ARGB6666_Premultiplied>() { return 12; } | - |
102 | template<> Q_DECL_CONSTEXPR uint greenWidth<QImage::Format_RGB16>() { return 6; } | - |
103 | template<> Q_DECL_CONSTEXPR uint greenWidth<QImage::Format_RGB444>() { return 4; } | - |
104 | template<> Q_DECL_CONSTEXPR uint greenWidth<QImage::Format_RGB555>() { return 5; } | - |
105 | template<> Q_DECL_CONSTEXPR uint greenWidth<QImage::Format_RGB666>() { return 6; } | - |
106 | template<> Q_DECL_CONSTEXPR uint greenWidth<QImage::Format_RGB888>() { return 8; } | - |
107 | template<> Q_DECL_CONSTEXPR uint greenWidth<QImage::Format_ARGB4444_Premultiplied>() { return 4; } | - |
108 | template<> Q_DECL_CONSTEXPR uint greenWidth<QImage::Format_ARGB8555_Premultiplied>() { return 5; } | - |
109 | template<> Q_DECL_CONSTEXPR uint greenWidth<QImage::Format_ARGB8565_Premultiplied>() { return 6; } | - |
110 | template<> Q_DECL_CONSTEXPR uint greenWidth<QImage::Format_ARGB6666_Premultiplied>() { return 6; } | - |
111 | template<> Q_DECL_CONSTEXPR uint greenShift<QImage::Format_RGB16>() { return 5; } | - |
112 | template<> Q_DECL_CONSTEXPR uint greenShift<QImage::Format_RGB444>() { return 4; } | - |
113 | template<> Q_DECL_CONSTEXPR uint greenShift<QImage::Format_RGB555>() { return 5; } | - |
114 | template<> Q_DECL_CONSTEXPR uint greenShift<QImage::Format_RGB666>() { return 6; } | - |
115 | template<> Q_DECL_CONSTEXPR uint greenShift<QImage::Format_RGB888>() { return 8; } | - |
116 | template<> Q_DECL_CONSTEXPR uint greenShift<QImage::Format_ARGB4444_Premultiplied>() { return 4; } | - |
117 | template<> Q_DECL_CONSTEXPR uint greenShift<QImage::Format_ARGB8555_Premultiplied>() { return 13; } | - |
118 | template<> Q_DECL_CONSTEXPR uint greenShift<QImage::Format_ARGB8565_Premultiplied>() { return 13; } | - |
119 | template<> Q_DECL_CONSTEXPR uint greenShift<QImage::Format_ARGB6666_Premultiplied>() { return 6; } | - |
120 | template<> Q_DECL_CONSTEXPR uint blueWidth<QImage::Format_RGB16>() { return 5; } | - |
121 | template<> Q_DECL_CONSTEXPR uint blueWidth<QImage::Format_RGB444>() { return 4; } | - |
122 | template<> Q_DECL_CONSTEXPR uint blueWidth<QImage::Format_RGB555>() { return 5; } | - |
123 | template<> Q_DECL_CONSTEXPR uint blueWidth<QImage::Format_RGB666>() { return 6; } | - |
124 | template<> Q_DECL_CONSTEXPR uint blueWidth<QImage::Format_RGB888>() { return 8; } | - |
125 | template<> Q_DECL_CONSTEXPR uint blueWidth<QImage::Format_ARGB4444_Premultiplied>() { return 4; } | - |
126 | template<> Q_DECL_CONSTEXPR uint blueWidth<QImage::Format_ARGB8555_Premultiplied>() { return 5; } | - |
127 | template<> Q_DECL_CONSTEXPR uint blueWidth<QImage::Format_ARGB8565_Premultiplied>() { return 5; } | - |
128 | template<> Q_DECL_CONSTEXPR uint blueWidth<QImage::Format_ARGB6666_Premultiplied>() { return 6; } | - |
129 | template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_RGB16>() { return 0; } | - |
130 | template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_RGB444>() { return 0; } | - |
131 | template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_RGB555>() { return 0; } | - |
132 | template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_RGB666>() { return 0; } | - |
133 | template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_RGB888>() { return 0; } | - |
134 | template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_ARGB4444_Premultiplied>() { return 0; } | - |
135 | template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_ARGB8555_Premultiplied>() { return 8; } | - |
136 | template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_ARGB8565_Premultiplied>() { return 8; } | - |
137 | template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_ARGB6666_Premultiplied>() { return 0; } | - |
138 | template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_RGB16>() { return 0; } | - |
139 | template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_RGB444>() { return 0; } | - |
140 | template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_RGB555>() { return 0; } | - |
141 | template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_RGB666>() { return 0; } | - |
142 | template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_RGB888>() { return 0; } | - |
143 | template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_ARGB4444_Premultiplied>() { return 4; } | - |
144 | template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_ARGB8555_Premultiplied>() { return 8; } | - |
145 | template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_ARGB8565_Premultiplied>() { return 8; } | - |
146 | template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_ARGB6666_Premultiplied>() { return 6; } | - |
147 | template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_RGB16>() { return 0; } | - |
148 | template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_RGB444>() { return 0; } | - |
149 | template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_RGB555>() { return 0; } | - |
150 | template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_RGB666>() { return 0; } | - |
151 | template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_RGB888>() { return 0; } | - |
152 | template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_ARGB4444_Premultiplied>() { return 12; } | - |
153 | template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_ARGB8555_Premultiplied>() { return 0; } | - |
154 | template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_ARGB8565_Premultiplied>() { return 0; } | - |
155 | template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_ARGB6666_Premultiplied>() { return 18; } | - |
156 | | - |
157 | template<QImage::Format> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel(); | - |
158 | template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_RGB16>() { return QPixelLayout::BPP16; } | - |
159 | template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_RGB444>() { return QPixelLayout::BPP16; } | - |
160 | template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_RGB555>() { return QPixelLayout::BPP16; } | - |
161 | template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_RGB666>() { return QPixelLayout::BPP24; } | - |
162 | template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_RGB888>() { return QPixelLayout::BPP24; } | - |
163 | template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_ARGB4444_Premultiplied>() { return QPixelLayout::BPP16; } | - |
164 | template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_ARGB8555_Premultiplied>() { return QPixelLayout::BPP24; } | - |
165 | template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_ARGB8565_Premultiplied>() { return QPixelLayout::BPP24; } | - |
166 | template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_ARGB6666_Premultiplied>() { return QPixelLayout::BPP24; } | - |
167 | | - |
168 | | - |
169 | template<QImage::Format Format> | - |
170 | static const uint *QT_FASTCALL convertToRGB32(uint *buffer, const uint *src, int count, | - |
171 | const QPixelLayout *, const QRgb *) | - |
172 | { | - |
173 | Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); | - |
174 | Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); | - |
175 | Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1); | - |
176 | | - |
177 | Q_CONSTEXPR uchar redLeftShift = 8 - redWidth<Format>(); | - |
178 | Q_CONSTEXPR uchar greenLeftShift = 8 - greenWidth<Format>(); | - |
179 | Q_CONSTEXPR uchar blueLeftShift = 8 - blueWidth<Format>(); | - |
180 | | - |
181 | Q_CONSTEXPR uchar redRightShift = 2 * redWidth<Format>() - 8; | - |
182 | Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth<Format>() - 8; | - |
183 | Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth<Format>() - 8; | - |
184 | | - |
185 | for (int i = 0; i < count; ++i) { | - |
186 | uint red = (src[i] >> redShift<Format>()) & redMask; | - |
187 | uint green = (src[i] >> greenShift<Format>()) & greenMask; | - |
188 | uint blue = (src[i] >> blueShift<Format>()) & blueMask; | - |
189 | | - |
190 | red = ((red << redLeftShift) | (red >> redRightShift)) << 16; | - |
191 | green = ((green << greenLeftShift) | (green >> greenRightShift)) << 8; | - |
192 | blue = (blue << blueLeftShift) | (blue >> blueRightShift); | - |
193 | buffer[i] = 0xff000000 | red | green | blue; | - |
194 | } | - |
195 | | - |
196 | return buffer; | - |
197 | } | - |
198 | | - |
199 | template<QImage::Format Format> | - |
200 | static const QRgba64 *QT_FASTCALL convertToRGB64(QRgba64 *buffer, const uint *src, int count, | - |
201 | const QPixelLayout *, const QRgb *) | - |
202 | { | - |
203 | Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); | - |
204 | Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); | - |
205 | Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1); | - |
206 | | - |
207 | Q_CONSTEXPR uchar redLeftShift = 8 - redWidth<Format>(); | - |
208 | Q_CONSTEXPR uchar greenLeftShift = 8 - greenWidth<Format>(); | - |
209 | Q_CONSTEXPR uchar blueLeftShift = 8 - blueWidth<Format>(); | - |
210 | | - |
211 | Q_CONSTEXPR uchar redRightShift = 2 * redWidth<Format>() - 8; | - |
212 | Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth<Format>() - 8; | - |
213 | Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth<Format>() - 8; | - |
214 | | - |
215 | for (int i = 0; i < count; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
216 | uint red = (src[i] >> redShift<Format>()) & redMask; | - |
217 | uint green = (src[i] >> greenShift<Format>()) & greenMask; | - |
218 | uint blue = (src[i] >> blueShift<Format>()) & blueMask; | - |
219 | | - |
220 | red = ((red << redLeftShift) | (red >> redRightShift));)) << 16; | - |
221 | green = ((green << greenLeftShift) | (green >> greenRightShift));)) << 8; | - |
222 | blue = (blue << blueLeftShift) | (blue >> blueRightShift); | - |
223 | buffer[i] = QRgba64::fromRgba(red, green, blue, 255); | - |
224 | } never executed: end of block | 0 |
225 | | - |
226 | return buffer; never executed: return buffer; | 0 |
227 | } | - |
228 | | - |
229 | template<QImage::Format Format> | - |
230 | static const uint *QT_FASTCALL convertARGBPMToARGB32PM(uint *buffer, const uint *src, int count, | - |
231 | const QPixelLayout *, const QRgb *) | - |
232 | { | - |
233 | Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth<Format>()) - 1); | - |
234 | Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); | - |
235 | Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); | - |
236 | Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1); | - |
237 | | - |
238 | Q_CONSTEXPR uchar alphaLeftShift = 8 - alphaWidth<Format>(); | - |
239 | Q_CONSTEXPR uchar redLeftShift = 8 - redWidth<Format>(); | - |
240 | Q_CONSTEXPR uchar greenLeftShift = 8 - greenWidth<Format>(); | - |
241 | Q_CONSTEXPR uchar blueLeftShift = 8 - blueWidth<Format>(); | - |
242 | | - |
243 | Q_CONSTEXPR uchar alphaRightShift = 2 * alphaWidth<Format>() - 8; | - |
244 | Q_CONSTEXPR uchar redRightShift = 2 * redWidth<Format>() - 8; | - |
245 | Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth<Format>() - 8; | - |
246 | Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth<Format>() - 8; | - |
247 | | - |
248 | Q_CONSTEXPR bool mustMin = (alphaWidth<Format>() != redWidth<Format>()) || | - |
249 | (alphaWidth<Format>() != greenWidth<Format>()) || | - |
250 | (alphaWidth<Format>() != blueWidth<Format>()); | - |
251 | | - |
252 | if (mustMin) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
253 | for (int i = 0; i < count; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
254 | uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask; | - |
255 | uint red = (src[i] >> redShift<Format>()) & redMask; | - |
256 | uint green = (src[i] >> greenShift<Format>()) & greenMask; | - |
257 | uint blue = (src[i] >> blueShift<Format>()) & blueMask; | - |
258 | | - |
259 | alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); | - |
260 | red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift)); | - |
261 | green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift)); | - |
262 | blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift)); | - |
263 | buffer[i] = (alpha << 24) | (red << 16) | (green << 8) | blue; | - |
264 | } never executed: end of block | 0 |
265 | } else { never executed: end of block | 0 |
266 | for (int i = 0; i < count; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
267 | uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask; | - |
268 | uint red = (src[i] >> redShift<Format>()) & redMask; | - |
269 | uint green = (src[i] >> greenShift<Format>()) & greenMask; | - |
270 | uint blue = (src[i] >> blueShift<Format>()) & blueMask; | - |
271 | | - |
272 | alpha = ((alpha << alphaLeftShift) | (alpha >> alphaRightShift)) << 24; | - |
273 | red = ((red << redLeftShift) | (red >> redRightShift)) << 16; | - |
274 | green = ((green << greenLeftShift) | (green >> greenRightShift)) << 8; | - |
275 | blue = (blue << blueLeftShift) | (blue >> blueRightShift); | - |
276 | buffer[i] = alpha | red | green | blue; | - |
277 | } never executed: end of block | 0 |
278 | } never executed: end of block | 0 |
279 | | - |
280 | return buffer; never executed: return buffer; | 0 |
281 | } | - |
282 | | - |
283 | template<QImage::Format Format> | - |
284 | static const QRgba64 *QT_FASTCALL convertARGBPMToARGB64PM(QRgba64 *buffer, const uint *src, int count, | - |
285 | const QPixelLayout *, const QRgb *) | - |
286 | { | - |
287 | Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth<Format>()) - 1); | - |
288 | Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); | - |
289 | Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); | - |
290 | Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1); | - |
291 | | - |
292 | Q_CONSTEXPR uchar alphaLeftShift = 8 - alphaWidth<Format>(); | - |
293 | Q_CONSTEXPR uchar redLeftShift = 8 - redWidth<Format>(); | - |
294 | Q_CONSTEXPR uchar greenLeftShift = 8 - greenWidth<Format>(); | - |
295 | Q_CONSTEXPR uchar blueLeftShift = 8 - blueWidth<Format>(); | - |
296 | | - |
297 | Q_CONSTEXPR uchar alphaRightShift = 2 * alphaWidth<Format>() - 8; | - |
298 | Q_CONSTEXPR uchar redRightShift = 2 * redWidth<Format>() - 8; | - |
299 | Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth<Format>() - 8; | - |
300 | Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth<Format>() - 8; | - |
301 | | - |
302 | Q_CONSTEXPR bool mustMin = (alphaWidth<Format>() != redWidth<Format>()) || | - |
303 | (alphaWidth<Format>() != greenWidth<Format>()) || | - |
304 | (alphaWidth<Format>() != blueWidth<Format>()); | - |
305 | | - |
306 | if (mustMin) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
307 | for (int i = 0; i < count; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
308 | uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask; | - |
309 | uint red = (src[i] >> redShift<Format>()) & redMask; | - |
310 | uint green = (src[i] >> greenShift<Format>()) & greenMask; | - |
311 | uint blue = (src[i] >> blueShift<Format>()) & blueMask; | - |
312 | | - |
313 | alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); | - |
314 | red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift)); | - |
315 | green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift)); | - |
316 | blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift)); | - |
317 | buffer[i] = QRgba64::fromRgba(red, green, blue, alpha); | - |
318 | } never executed: end of block | 0 |
319 | return buffer;} template<QImage::Format Format> never executed: end of block | 0 |
| static const uint *QT_FASTCALL convertRGBFromARGB32PM(uint *buffer, const uint *src, int count, never executed: end of block | |
| const QPixelLayout *, const QRgb *) never executed: end of block else {never executed: end of block | |
320 | Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
| Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1);TRUE | never evaluated | FALSE | never evaluated |
| |
| Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1);TRUE | never evaluated | FALSE | never evaluated |
| |
| | |
| Q_CONSTEXPR uchar redRightShift = 24 - redWidth<Format>();TRUE | never evaluated | FALSE | never evaluated |
| |
| Q_CONSTEXPR uchar greenRightShift = 16 - greenWidth<Format>();TRUE | never evaluated | FALSE | never evaluated |
| |
| Q_CONSTEXPR uchar blueRightShift = 8 - blueWidth<Format>();TRUE | never evaluated | FALSE | never evaluated |
for (int i = 0; i < count; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| |
321 | constuint coloralpha = qUnpremultiply(src[i]); | - |
| const] >> alphaShift<Format>()) & alphaMask; | |
322 | uint red = ((color(src[i] >> redRightShift) & redMask) <<redShift<Format>(); | - |
| const>()) & redMask; | |
323 | uint green = ((color(src[i] >> greenRightShift) & greenMask) <<greenShift<Format>(); | - |
| const>()) & greenMask; | |
324 | uint blue = ((color >> blueRightShift) & blueMask) << blueShift<Format>(); | - |
| buffer(src[i] = red | green | blue; | |
| } | |
| return buffer; | |
| } | |
| | |
| template<QImage::Format Format> | |
| static const uint *QT_FASTCALL convertRGBFromRGB32(uint *buffer, const uint *src, int count, | |
| const QPixelLayout *, const QRgb *) | |
| { | |
| Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); | |
| Q_CONSTEXPR uint greenMask = ((1 << greenWidth>> blueShift<Format>()) - 1); | |
| Q_CONSTEXPR uint& blueMask; | |
325 | | - |
326 | alpha = ((1(alpha << blueWidth<Format>()) - 1alphaLeftShift) | (alpha >> alphaRightShift); | - |
327 | Q_CONSTEXPR uchar redRightShift = 24 - redWidth<Format>(); | - |
| Q_CONSTEXPR uchar greenRightShift = 16 - greenWidth<Format>(); | |
| Q_CONSTEXPR uchar blueRightShiftred = 8 - blueWidth<Format>(); | |
| | |
| for(int i = 0; i < count; ++ired << redLeftShift) { | |
| const uint| (red = ((src[i]>> redRightShift) & redMask) << redShift<Format>(); | |
| const uint); | |
328 | green = ((src[i](green << greenLeftShift) | (green >> greenRightShift) & greenMask) << greenShift<Format>(); | - |
| const uint); | |
329 | blue = ((src[i](blue << blueLeftShift) | (blue >> blueRightShift) & blueMask) << blueShift<Format>();); | - |
330 | buffer[i] = QRgba64::fromRgba(red|, green|, blue;, alpha); | - |
331 | } never executed: end of block | 0 |
332 | } never executed: end of block | 0 |
333 | | - |
334 | return buffer; never executed: return buffer; | 0 |
335 | } | - |
336 | | - |
337 | template<QImage::Format Format, bool fromRGB> | - |
338 | static const uint *QT_FASTCALL convertARGBPMFromRGB32convertRGBFromARGB32PM(uint *buffer, const uint *src, int count, | - |
339 | const QPixelLayout *, const QRgb *) | - |
340 | { | - |
341 | Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth<Format>()) - 1);Q_CONSTEXPR uint redMaskrMask = ((1 << redWidth<Format>()) - 1); | - |
342 | Q_CONSTEXPR uint greenMaskgMask = ((1 << greenWidth<Format>()) - 1); | - |
343 | Q_CONSTEXPR uint blueMaskbMask = ((1 << blueWidth<Format>()) - 1); | - |
344 | | - |
345 | Q_CONSTEXPR uchar redRightShiftrRightShift = 24 - redWidth<Format>(); | - |
346 | Q_CONSTEXPR uchar greenRightShiftgRightShift = 16 - greenWidth<Format>(); | - |
347 | Q_CONSTEXPR uchar blueRightShiftbRightShift = 8 - blueWidth<Format>(); | - |
348 | | - |
349 | for (int i = 0; i < count; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
350 | Q_CONSTEXPR uint alpha = (0xff & alphaMask) << alphaShift<Format>();const uint redc = ((fromRGB ? src[i] : qUnpremultiply(src[i]); | - |
351 | const uint r = ((c >> redRightShiftrRightShift) & redMaskrMask) << redShift<Format>(); | - |
352 | const uint greeng = ((src[i]c >> greenRightShiftgRightShift) & greenMaskgMask) << greenShift<Format>(); | - |
353 | const uint blueb = ((src[i]c >> blueRightShiftbRightShift) & blueMaskbMask) << blueShift<Format>(); | - |
354 | buffer[i] = alpha | redr | greeng | blueb; | - |
355 | } never executed: end of block | 0 |
356 | return buffer; never executed: return buffer; | 0 |
357 | } | - |
358 | | - |
359 | template<QImage::Format Format, bool fromRGB> | - |
360 | static const uint *QT_FASTCALL convertARGBPMFromARGB32PM(uint *buffer, const uint *src, int count, | - |
361 | const QPixelLayout *, const QRgb *) | - |
362 | { | - |
363 | Q_CONSTEXPR uint alphaMaskaMask = ((1 << alphaWidth<Format>()) - 1); | - |
364 | Q_CONSTEXPR uint redMaskrMask = ((1 << redWidth<Format>()) - 1); | - |
365 | Q_CONSTEXPR uint greenMaskgMask = ((1 << greenWidth<Format>()) - 1); | - |
366 | Q_CONSTEXPR uint blueMaskbMask = ((1 << blueWidth<Format>()) - 1); | - |
367 | | - |
368 | Q_CONSTEXPR uchar alphaRightShiftaRightShift = 32 - alphaWidth<Format>(); | - |
369 | Q_CONSTEXPR uchar redRightShiftrRightShift = 24 - redWidth<Format>(); | - |
370 | Q_CONSTEXPR uchar greenRightShiftgRightShift = 16 - greenWidth<Format>(); | - |
371 | Q_CONSTEXPR uchar blueRightShiftbRightShift = 8 - blueWidth<Format>(); | - |
372 | | - |
373 | Q_CONSTEXPR uint aOpaque = (0xff & aMask) << alphaShift<Format>(); | - |
374 | for (int i = 0; i < count; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
375 | const uint alphac = ((src[i]]; | - |
376 | const uint a = fromRGB ? aOpaque : (((c >> alphaRightShiftaRightShift) & alphaMaskaMask) << alphaShift<Format>();>()); | - |
377 | const uint redr = ((src[i]c >> redRightShiftrRightShift) & redMaskrMask) << redShift<Format>(); | - |
378 | const uint greeng = ((src[i]c >> greenRightShiftgRightShift) & greenMaskgMask) << greenShift<Format>(); | - |
379 | const uint blueb = ((src[i]c >> blueRightShiftbRightShift) & blueMaskbMask) << blueShift<Format>(); | - |
380 | buffer[i] = alphaa | redr | greeng | blueb; | - |
381 | } never executed: end of block | 0 |
382 | return buffer; never executed: return buffer; | 0 |
383 | } | - |
384 | | - |
385 | #ifdef Q_COMPILER_CONSTEXPR | - |
386 | | - |
387 | template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixelLayoutRGB() | - |
388 | { | - |
389 | return QPixelLayout{ | - |
390 | uchar(redWidth<Format>()), uchar(redShift<Format>()), | - |
391 | uchar(greenWidth<Format>()), uchar(greenShift<Format>()), | - |
392 | uchar(blueWidth<Format>()), uchar(blueShift<Format>()), | - |
393 | 0, 0, | - |
394 | false, bitsPerPixel<Format>(), | - |
395 | convertToRGB32<Format>, | - |
396 | convertRGBFromARGB32PM<Format, false>, | - |
397 | convertRGBFromRGB32convertRGBFromARGB32PM<Format, true>, | - |
398 | convertToRGB64<Format> | - |
399 | }; | - |
400 | } | - |
401 | | - |
402 | template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixelLayoutARGBPM() | - |
403 | { | - |
404 | return QPixelLayout{ | - |
405 | uchar(redWidth<Format>()), uchar(redShift<Format>()), | - |
406 | uchar(greenWidth<Format>()), uchar(greenShift<Format>()), | - |
407 | uchar(blueWidth<Format>()), uchar(blueShift<Format>()), | - |
408 | uchar(alphaWidth<Format>()), uchar(alphaShift<Format>()), | - |
409 | true, bitsPerPixel<Format>(), | - |
410 | convertARGBPMToARGB32PM<Format>, | - |
411 | convertARGBPMFromARGB32PM<Format, false>, | - |
412 | convertARGBPMFromRGB32convertARGBPMFromARGB32PM<Format, true>, | - |
413 | convertARGBPMToARGB64PM<Format> | - |
414 | }; | - |
415 | } | - |
416 | | - |
417 | #endif | - |
418 | | - |
419 | | - |
420 | static const uint *QT_FASTCALL convertIndexedToARGB32PM(uint *buffer, const uint *src, int count, | - |
421 | const QPixelLayout *, const QRgb *clut) | - |
422 | { | - |
423 | for (int i = 0; i < count; ++i) | - |
424 | buffer[i] = qPremultiply(clut[src[i]]); | - |
425 | return buffer; | - |
426 | } | - |
427 | | - |
428 | static const QRgba64 *QT_FASTCALL convertIndexedToARGB64PM(QRgba64 *buffer, const uint *src, int count, | - |
429 | const QPixelLayout *, const QRgb *clut) | - |
430 | { | - |
431 | for (int i = 0; i < count; ++i) | - |
432 | buffer[i] = QRgba64::fromArgb32(clut[src[i]]).premultiplied(); | - |
433 | return buffer; | - |
434 | } | - |
435 | | - |
436 | static const uint *QT_FASTCALL convertPassThrough(uint *, const uint *src, int, | - |
437 | const QPixelLayout *, const QRgb *) | - |
438 | { | - |
439 | return src; | - |
440 | } | - |
441 | | - |
442 | static const uint *QT_FASTCALL convertARGB32ToARGB32PM(uint *buffer, const uint *src, int count, | - |
443 | const QPixelLayout *, const QRgb *) | - |
444 | { | - |
445 | return qt_convertARGB32ToARGB32PM(buffer, src, count); | - |
446 | } | - |
447 | | - |
448 | static const uint *QT_FASTCALL convertRGBA8888PMToARGB32PM(uint *buffer, const uint *src, int count, | - |
449 | const QPixelLayout *, const QRgb *) | - |
450 | { | - |
451 | for (int i = 0; i < count; ++i) | - |
452 | buffer[i] = RGBA2ARGB(src[i]); | - |
453 | return buffer; | - |
454 | } | - |
455 | | - |
456 | static const uint *QT_FASTCALL convertRGBA8888ToARGB32PM(uint *buffer, const uint *src, int count, | - |
457 | const QPixelLayout *, const QRgb *) | - |
458 | { | - |
459 | return qt_convertRGBA8888ToARGB32PM(buffer, src, count); | - |
460 | } | - |
461 | | - |
462 | static const uint *QT_FASTCALL convertAlpha8ToRGB32(uint *buffer, const uint *src, int count, | - |
463 | const QPixelLayout *, const QRgb *) | - |
464 | { | - |
465 | for (int i = 0; i < count; ++i) | - |
466 | buffer[i] = qRgba(0, 0, 0, src[i]); | - |
467 | return buffer; | - |
468 | } | - |
469 | | - |
470 | static const uint *QT_FASTCALL convertGrayscale8ToRGB32(uint *buffer, const uint *src, int count, | - |
471 | const QPixelLayout *, const QRgb *) | - |
472 | { | - |
473 | for (int i = 0; i < count; ++i) | - |
474 | buffer[i] = qRgb(src[i], src[i], src[i]); | - |
475 | return buffer; | - |
476 | } | - |
477 | | - |
478 | static const QRgba64 *QT_FASTCALL convertAlpha8ToRGB64(QRgba64 *buffer, const uint *src, int count, | - |
479 | const QPixelLayout *, const QRgb *) | - |
480 | { | - |
481 | for (int i = 0; i < count; ++i) | - |
482 | buffer[i] = QRgba64::fromRgba(0, 0, 0, src[i]); | - |
483 | return buffer; | - |
484 | } | - |
485 | | - |
486 | static const QRgba64 *QT_FASTCALL convertGrayscale8ToRGB64(QRgba64 *buffer, const uint *src, int count, | - |
487 | const QPixelLayout *, const QRgb *) | - |
488 | { | - |
489 | for (int i = 0; i < count; ++i) | - |
490 | buffer[i] = QRgba64::fromRgba(src[i], src[i], src[i], 255); | - |
491 | return buffer; | - |
492 | } | - |
493 | | - |
494 | static const uint *QT_FASTCALL convertARGB32FromARGB32PM(uint *buffer, const uint *src, int count, | - |
495 | const QPixelLayout *, const QRgb *) | - |
496 | { | - |
497 | for (int i = 0; i < count; ++i) | - |
498 | buffer[i] = qUnpremultiply(src[i]); | - |
499 | return buffer; | - |
500 | } | - |
501 | | - |
502 | static const uint *QT_FASTCALL convertRGBA8888PMFromARGB32PM(uint *buffer, const uint *src, int count, | - |
503 | const QPixelLayout *, const QRgb *) | - |
504 | { | - |
505 | for (int i = 0; i < count; ++i) | - |
506 | buffer[i] = ARGB2RGBA(src[i]); | - |
507 | return buffer; | - |
508 | } | - |
509 | | - |
510 | #ifdef __SSE2__ | - |
511 | template<bool RGBA, bool maskAlpha> | - |
512 | static inline void qConvertARGB32PMToARGB64PM_sse2(QRgba64 *buffer, const uint *src, int count) | - |
513 | { | - |
514 | if (count <= 0) | - |
515 | return; | - |
516 | | - |
517 | const __m128i amask = _mm_set1_epi32(0xff000000); | - |
518 | int i = 0; | - |
519 | for (; ((uintptr_t)buffer & 0xf) && i < count; ++i) { | - |
520 | uint s = *src++; | - |
521 | if (RGBA) | - |
522 | s = RGBA2ARGB(s); | - |
523 | *buffer++ = QRgba64::fromArgb32(s); | - |
524 | } | - |
525 | for (; i < count-3; i += 4) { | - |
526 | __m128i vs = _mm_loadu_si128((const __m128i*)src); | - |
527 | if (maskAlpha) | - |
528 | vs = _mm_or_si128(vs, amask); | - |
529 | src += 4; | - |
530 | __m128i v1 = _mm_unpacklo_epi8(vs, vs); | - |
531 | __m128i v2 = _mm_unpackhi_epi8(vs, vs); | - |
532 | if (!RGBA) { | - |
533 | v1 = _mm_shufflelo_epi16(v1, _MM_SHUFFLE(3, 0, 1, 2)); | - |
534 | v2 = _mm_shufflelo_epi16(v2, _MM_SHUFFLE(3, 0, 1, 2)); | - |
535 | v1 = _mm_shufflehi_epi16(v1, _MM_SHUFFLE(3, 0, 1, 2)); | - |
536 | v2 = _mm_shufflehi_epi16(v2, _MM_SHUFFLE(3, 0, 1, 2)); | - |
537 | } | - |
538 | _mm_store_si128((__m128i*)(buffer), v1); | - |
539 | buffer += 2; | - |
540 | _mm_store_si128((__m128i*)(buffer), v2); | - |
541 | buffer += 2; | - |
542 | } | - |
543 | | - |
544 | for (; i < count; ++i) { | - |
545 | uint s = *src++; | - |
546 | if (RGBA) | - |
547 | s = RGBA2ARGB(s); | - |
548 | *buffer++ = QRgba64::fromArgb32(s); | - |
549 | } | - |
550 | } | - |
551 | #endif | - |
552 | | - |
553 | static const QRgba64 *QT_FASTCALL convertRGB32ToRGB64(QRgba64 *buffer, const uint *src, int count, | - |
554 | const QPixelLayout *, const QRgb *) | - |
555 | { | - |
556 | #ifdef __SSE2__ | - |
557 | qConvertARGB32PMToARGB64PM_sse2<false, true>(buffer, src, count); | - |
558 | #else | - |
559 | for (int i = 0; i < count; ++i) | - |
560 | buffer[i] = QRgba64::fromArgb32(0xff000000 | src[i]); | - |
561 | #endif | - |
562 | return buffer; | - |
563 | } | - |
564 | | - |
565 | static const QRgba64 *QT_FASTCALL convertARGB32ToARGB64PM(QRgba64 *buffer, const uint *src, int count, | - |
566 | const QPixelLayout *, const QRgb *) | - |
567 | { | - |
568 | #ifdef __SSE2__ | - |
569 | qConvertARGB32PMToARGB64PM_sse2<false, false>(buffer, src, count); | - |
570 | for (int i = 0; i < count; ++i) | - |
571 | buffer[i] = buffer[i].premultiplied(); | - |
572 | #else | - |
573 | for (int i = 0; i < count; ++i) | - |
574 | buffer[i] = QRgba64::fromArgb32(src[i]).premultiplied(); | - |
575 | #endif | - |
576 | return buffer; | - |
577 | } | - |
578 | | - |
579 | static const QRgba64 *QT_FASTCALL convertARGB32PMToARGB64PM(QRgba64 *buffer, const uint *src, int count, | - |
580 | const QPixelLayout *, const QRgb *) | - |
581 | { | - |
582 | #ifdef __SSE2__ | - |
583 | qConvertARGB32PMToARGB64PM_sse2<false, false>(buffer, src, count); | - |
584 | #else | - |
585 | for (int i = 0; i < count; ++i) | - |
586 | buffer[i] = QRgba64::fromArgb32(src[i]); | - |
587 | #endif | - |
588 | return buffer; | - |
589 | } | - |
590 | | - |
591 | static const QRgba64 *QT_FASTCALL convertRGBA8888ToARGB64PM(QRgba64 *buffer, const uint *src, int count, | - |
592 | const QPixelLayout *, const QRgb *) | - |
593 | { | - |
594 | #ifdef __SSE2__ | - |
595 | qConvertARGB32PMToARGB64PM_sse2<true, false>(buffer, src, count); | - |
596 | for (int i = 0; i < count; ++i) | - |
597 | buffer[i] = buffer[i].premultiplied(); | - |
598 | #else | - |
599 | for (int i = 0; i < count; ++i) | - |
600 | buffer[i] = QRgba64::fromArgb32(RGBA2ARGB(src[i])).premultiplied(); | - |
601 | #endif | - |
602 | return buffer; | - |
603 | } | - |
604 | | - |
605 | static const QRgba64 *QT_FASTCALL convertRGBA8888PMToARGB64PM(QRgba64 *buffer, const uint *src, int count, | - |
606 | const QPixelLayout *, const QRgb *) | - |
607 | { | - |
608 | #ifdef __SSE2__ | - |
609 | qConvertARGB32PMToARGB64PM_sse2<true, false>(buffer, src, count); | - |
610 | #else | - |
611 | for (int i = 0; i < count; ++i) | - |
612 | buffer[i] = QRgba64::fromArgb32(RGBA2ARGB(src[i])); | - |
613 | #endif | - |
614 | return buffer; | - |
615 | } | - |
616 | | - |
617 | static const uint *QT_FASTCALL convertRGBA8888FromARGB32PM(uint *buffer, const uint *src, int count, | - |
618 | const QPixelLayout *, const QRgb *) | - |
619 | { | - |
620 | for (int i = 0; i < count; ++i) | - |
621 | buffer[i] = ARGB2RGBA(qUnpremultiply(src[i])); | - |
622 | return buffer; | - |
623 | } | - |
624 | | - |
625 | static const uint *QT_FASTCALL convertRGBXFromRGB32(uint *buffer, const uint *src, int count, | - |
626 | const QPixelLayout *, const QRgb *) | - |
627 | { | - |
628 | for (int i = 0; i < count; ++i) | - |
629 | buffer[i] = ARGB2RGBA(0xff000000 | src[i]); | - |
630 | return buffer; | - |
631 | } | - |
632 | | - |
633 | static const uint *QT_FASTCALL convertRGBXFromARGB32PM(uint *buffer, const uint *src, int count, | - |
634 | const QPixelLayout *, const QRgb *) | - |
635 | { | - |
636 | for (int i = 0; i < count; ++i) | - |
637 | buffer[i] = ARGB2RGBA(0xff000000 | qUnpremultiply(src[i])); | - |
638 | return buffer; | - |
639 | } | - |
640 | | - |
641 | template<QtPixelOrder PixelOrder> | - |
642 | static const uint *QT_FASTCALL convertA2RGB30PMToARGB32PM(uint *buffer, const uint *src, int count, | - |
643 | const QPixelLayout *, const QRgb *) | - |
644 | { | - |
645 | for (int i = 0; i < count; ++i) | - |
646 | buffer[i] = qConvertA2rgb30ToArgb32<PixelOrder>(src[i]); | - |
647 | return buffer; | - |
648 | } | - |
649 | | - |
650 | #ifdef __SSE2__ | - |
651 | template<QtPixelOrder PixelOrder> | - |
652 | static inline void qConvertA2RGB30PMToARGB64PM_sse2(QRgba64 *buffer, const uint *src, int count) | - |
653 | { | - |
654 | if (count <= 0) | - |
655 | return; | - |
656 | | - |
657 | const __m128i rmask = _mm_set1_epi32(0x3ff00000); | - |
658 | const __m128i gmask = _mm_set1_epi32(0x000ffc00); | - |
659 | const __m128i bmask = _mm_set1_epi32(0x000003ff); | - |
660 | const __m128i afactor = _mm_set1_epi16(0x5555); | - |
661 | int i = 0; | - |
662 | | - |
663 | for (; ((uintptr_t)buffer & 0xf) && i < count; ++i) | - |
664 | *buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++); | - |
665 | | - |
666 | for (; i < count-3; i += 4) { | - |
667 | __m128i vs = _mm_loadu_si128((const __m128i*)src); | - |
668 | src += 4; | - |
669 | __m128i va = _mm_srli_epi32(vs, 30); | - |
670 | __m128i vr = _mm_and_si128(vs, rmask); | - |
671 | __m128i vb = _mm_and_si128(vs, bmask); | - |
672 | __m128i vg = _mm_and_si128(vs, gmask); | - |
673 | va = _mm_mullo_epi16(va, afactor); | - |
674 | vr = _mm_or_si128(_mm_srli_epi32(vr, 14), _mm_srli_epi32(vr, 24)); | - |
675 | vg = _mm_or_si128(_mm_srli_epi32(vg, 4), _mm_srli_epi32(vg, 14)); | - |
676 | vb = _mm_or_si128(_mm_slli_epi32(vb, 6), _mm_srli_epi32(vb, 4)); | - |
677 | __m128i vrb; | - |
678 | if (PixelOrder == PixelOrderRGB) | - |
679 | vrb = _mm_or_si128(vr, _mm_slli_si128(vb, 2)); | - |
680 | else | - |
681 | vrb = _mm_or_si128(vb, _mm_slli_si128(vr, 2)); | - |
682 | __m128i vga = _mm_or_si128(vg, _mm_slli_si128(va, 2)); | - |
683 | _mm_store_si128((__m128i*)(buffer), _mm_unpacklo_epi16(vrb, vga)); | - |
684 | buffer += 2; | - |
685 | _mm_store_si128((__m128i*)(buffer), _mm_unpackhi_epi16(vrb, vga)); | - |
686 | buffer += 2; | - |
687 | } | - |
688 | | - |
689 | for (; i < count; ++i) | - |
690 | *buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++); | - |
691 | } | - |
692 | #endif | - |
693 | | - |
694 | template<QtPixelOrder PixelOrder> | - |
695 | static const QRgba64 *QT_FASTCALL convertA2RGB30PMToARGB64PM(QRgba64 *buffer, const uint *src, int count, | - |
696 | const QPixelLayout *, const QRgb *) | - |
697 | { | - |
698 | #ifdef __SSE2__ | - |
699 | qConvertA2RGB30PMToARGB64PM_sse2<PixelOrder>(buffer, src, count); | - |
700 | #else | - |
701 | for (int i = 0; i < count; ++i) | - |
702 | buffer[i] = qConvertA2rgb30ToRgb64<PixelOrder>(src[i]); | - |
703 | #endif | - |
704 | return buffer; | - |
705 | } | - |
706 | | - |
707 | template<QtPixelOrder PixelOrder> | - |
708 | static const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM(uint *buffer, const uint *src, int count, | - |
709 | const QPixelLayout *, const QRgb *) | - |
710 | { | - |
711 | for (int i = 0; i < count; ++i) | - |
712 | buffer[i] = qConvertArgb32ToA2rgb30<PixelOrder>(src[i]); | - |
713 | return buffer; | - |
714 | } | - |
715 | | - |
716 | template<QtPixelOrder PixelOrder> | - |
717 | static const uint *QT_FASTCALL convertRGB30FromRGB32(uint *buffer, const uint *src, int count, | - |
718 | const QPixelLayout *, const QRgb *) | - |
719 | { | - |
720 | for (int i = 0; i < count; ++i) | - |
721 | buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(src[i]); | - |
722 | return buffer; | - |
723 | } | - |
724 | | - |
725 | template<QtPixelOrder PixelOrder> | - |
726 | static const uint *QT_FASTCALL convertRGB30FromARGB32PM(uint *buffer, const uint *src, int count, | - |
727 | const QPixelLayout *, const QRgb *) | - |
728 | { | - |
729 | for (int i = 0; i < count; ++i) | - |
730 | buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(qUnpremultiply(src[i])); | - |
731 | return buffer; | - |
732 | } | - |
733 | | - |
734 | static const uint *QT_FASTCALL convertAlpha8FromARGB32PM(uint *buffer, const uint *src, int count, | - |
735 | const QPixelLayout *, const QRgb *) | - |
736 | { | - |
737 | for (int i = 0; i < count; ++i) | - |
738 | buffer[i] = qAlpha(src[i]); | - |
739 | return buffer; | - |
740 | } | - |
741 | | - |
742 | static const uint *QT_FASTCALL convertGrayscale8FromRGB32(uint *buffer, const uint *src, int count, | - |
743 | const QPixelLayout *, const QRgb *) | - |
744 | { | - |
745 | for (int i = 0; i < count; ++i) | - |
746 | buffer[i] = qGray(src[i]); | - |
747 | return buffer; | - |
748 | } | - |
749 | | - |
750 | static const uint *QT_FASTCALL convertGrayscale8FromARGB32PM(uint *buffer, const uint *src, int count, | - |
751 | const QPixelLayout *, const QRgb *) | - |
752 | { | - |
753 | for (int i = 0; i < count; ++i) | - |
754 | buffer[i] = qGray(qUnpremultiply(src[i])); | - |
755 | return buffer; | - |
756 | } | - |
757 | | - |
758 | template <QPixelLayout::BPP bpp> static | - |
759 | uint QT_FASTCALL fetchPixel(const uchar *src, int index); | - |
760 | | - |
761 | template <> | - |
762 | inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP1LSB>(const uchar *src, int index) | - |
763 | { | - |
764 | return (src[index >> 3] >> (index & 7)) & 1; | - |
765 | } | - |
766 | | - |
767 | template <> | - |
768 | inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP1MSB>(const uchar *src, int index) | - |
769 | { | - |
770 | return (src[index >> 3] >> (~index & 7)) & 1; | - |
771 | } | - |
772 | | - |
773 | template <> | - |
774 | inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP8>(const uchar *src, int index) | - |
775 | { | - |
776 | return src[index]; | - |
777 | } | - |
778 | | - |
779 | template <> | - |
780 | inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP16>(const uchar *src, int index) | - |
781 | { | - |
782 | return reinterpret_cast<const quint16 *>(src)[index]; | - |
783 | } | - |
784 | | - |
785 | template <> | - |
786 | inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP24>(const uchar *src, int index) | - |
787 | { | - |
788 | return reinterpret_cast<const quint24 *>(src)[index]; | - |
789 | } | - |
790 | | - |
791 | template <> | - |
792 | inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP32>(const uchar *src, int index) | - |
793 | { | - |
794 | return reinterpret_cast<const uint *>(src)[index]; | - |
795 | } | - |
796 | | - |
797 | template <QPixelLayout::BPP bpp> | - |
798 | inline const uint *QT_FASTCALL fetchPixels(uint *buffer, const uchar *src, int index, int count) | - |
799 | { | - |
800 | for (int i = 0; i < count; ++i) | - |
801 | buffer[i] = fetchPixel<bpp>(src, index + i); | - |
802 | return buffer; | - |
803 | } | - |
804 | | - |
805 | template <> | - |
806 | inline const uint *QT_FASTCALL fetchPixels<QPixelLayout::BPP32>(uint *, const uchar *src, int index, int) | - |
807 | { | - |
808 | return reinterpret_cast<const uint *>(src) + index; | - |
809 | } | - |
810 | | - |
811 | template <QPixelLayout::BPP width> static | - |
812 | void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel); | - |
813 | | - |
814 | template <> | - |
815 | inline void QT_FASTCALL storePixel<QPixelLayout::BPP1LSB>(uchar *dest, int index, uint pixel) | - |
816 | { | - |
817 | if (pixel) | - |
818 | dest[index >> 3] |= 1 << (index & 7); | - |
819 | else | - |
820 | dest[index >> 3] &= ~(1 << (index & 7)); | - |
821 | } | - |
822 | | - |
823 | template <> | - |
824 | inline void QT_FASTCALL storePixel<QPixelLayout::BPP1MSB>(uchar *dest, int index, uint pixel) | - |
825 | { | - |
826 | if (pixel) | - |
827 | dest[index >> 3] |= 1 << (~index & 7); | - |
828 | else | - |
829 | dest[index >> 3] &= ~(1 << (~index & 7)); | - |
830 | } | - |
831 | | - |
832 | template <> | - |
833 | inline void QT_FASTCALL storePixel<QPixelLayout::BPP8>(uchar *dest, int index, uint pixel) | - |
834 | { | - |
835 | dest[index] = uchar(pixel); | - |
836 | } | - |
837 | | - |
838 | template <> | - |
839 | inline void QT_FASTCALL storePixel<QPixelLayout::BPP16>(uchar *dest, int index, uint pixel) | - |
840 | { | - |
841 | reinterpret_cast<quint16 *>(dest)[index] = quint16(pixel); | - |
842 | } | - |
843 | | - |
844 | template <> | - |
845 | inline void QT_FASTCALL storePixel<QPixelLayout::BPP24>(uchar *dest, int index, uint pixel) | - |
846 | { | - |
847 | reinterpret_cast<quint24 *>(dest)[index] = quint24(pixel); | - |
848 | } | - |
849 | | - |
850 | template <QPixelLayout::BPP width> | - |
851 | inline void QT_FASTCALL storePixels(uchar *dest, const uint *src, int index, int count) | - |
852 | { | - |
853 | for (int i = 0; i < count; ++i) | - |
854 | storePixel<width>(dest, index + i, src[i]); | - |
855 | } | - |
856 | | - |
857 | template <> | - |
858 | inline void QT_FASTCALL storePixels<QPixelLayout::BPP32>(uchar *dest, const uint *src, int index, int count) | - |
859 | { | - |
860 | memcpy(reinterpret_cast<uint *>(dest) + index, src, count * sizeof(uint)); | - |
861 | } | - |
862 | | - |
863 | | - |
864 | | - |
865 | | - |
866 | | - |
867 | QPixelLayout qPixelLayouts[QImage::NImageFormats] = { | - |
868 | { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPPNone, 0, 0, 0, 0 }, | - |
869 | { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP1MSB, convertIndexedToARGB32PM, 0, 0, convertIndexedToARGB64PM }, | - |
870 | { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP1LSB, convertIndexedToARGB32PM, 0, 0, convertIndexedToARGB64PM }, | - |
871 | { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP8, convertIndexedToARGB32PM, 0, 0, convertIndexedToARGB64PM }, | - |
872 | | - |
873 | | - |
874 | { 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP32, convertPassThrough, convertPassThrough, convertPassThrough, convertRGB32ToRGB64 }, | - |
875 | { 8, 16, 8, 8, 8, 0, 8, 24, false, QPixelLayout::BPP32, convertARGB32ToARGB32PM, convertARGB32FromARGB32PM, convertPassThrough, convertARGB32ToARGB64PM }, | - |
876 | { 8, 16, 8, 8, 8, 0, 8, 24, true, QPixelLayout::BPP32, convertPassThrough, convertPassThrough, convertPassThrough, convertARGB32PMToARGB64PM }, | - |
877 | #ifdef Q_COMPILER_CONSTEXPR | - |
878 | pixelLayoutRGB<QImage::Format_RGB16>(), | - |
879 | pixelLayoutARGBPM<QImage::Format_ARGB8565_Premultiplied>(), | - |
880 | pixelLayoutRGB<QImage::Format_RGB666>(), | - |
881 | pixelLayoutARGBPM<QImage::Format_ARGB6666_Premultiplied>(), | - |
882 | pixelLayoutRGB<QImage::Format_RGB555>(), | - |
883 | pixelLayoutARGBPM<QImage::Format_ARGB8555_Premultiplied>(), | - |
884 | pixelLayoutRGB<QImage::Format_RGB888>(), | - |
885 | pixelLayoutRGB<QImage::Format_RGB444>(), | - |
886 | pixelLayoutARGBPM<QImage::Format_ARGB4444_Premultiplied>(), | - |
887 | #else | - |
888 | { 5, 11, 6, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16, | - |
889 | convertToRGB32<QImage::Format_RGB16>, | - |
890 | convertRGBFromARGB32PM<QImage::Format_RGB16, false>, | - |
891 | convertRGBFromRGB32convertRGBFromARGB32PM<QImage::Format_RGB16, true>, | - |
892 | convertToRGB64<QImage::Format_RGB16>, | - |
893 | }, | - |
894 | { 5, 19, 6, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24, | - |
895 | convertARGBPMToARGB32PM<QImage::Format_ARGB8565_Premultiplied>, | - |
896 | convertARGBPMFromARGB32PM<QImage::Format_ARGB8565_Premultiplied, false>, | - |
897 | convertARGBPMFromRGB32convertARGBPMFromARGB32PM<QImage::Format_ARGB8565_Premultiplied, true>, | - |
898 | convertARGBPMToARGB64PM<QImage::Format_ARGB8565_Premultiplied>, | - |
899 | }, | - |
900 | { 6, 12, 6, 6, 6, 0, 0, 0, false, QPixelLayout::BPP24, | - |
901 | convertToRGB32<QImage::Format_RGB666>, | - |
902 | convertRGBFromARGB32PM<QImage::Format_RGB666, false>, | - |
903 | convertRGBFromRGB32convertRGBFromARGB32PM<QImage::Format_RGB666, true>, | - |
904 | convertToRGB64<QImage::Format_RGB666>, | - |
905 | }, | - |
906 | { 6, 12, 6, 6, 6, 0, 6, 18, true, QPixelLayout::BPP24, | - |
907 | convertARGBPMToARGB32PM<QImage::Format_ARGB6666_Premultiplied>, | - |
908 | convertARGBPMFromARGB32PM<QImage::Format_ARGB6666_Premultiplied, false>, | - |
909 | convertARGBPMFromRGB32convertARGBPMFromARGB32PM<QImage::Format_ARGB6666_Premultiplied, true>, | - |
910 | convertARGBPMToARGB64PM<QImage::Format_ARGB6666_Premultiplied>, | - |
911 | }, | - |
912 | { 5, 10, 5, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16, | - |
913 | convertToRGB32<QImage::Format_RGB555>, | - |
914 | convertRGBFromARGB32PM<QImage::Format_RGB555, false>, | - |
915 | convertRGBFromRGB32convertRGBFromARGB32PM<QImage::Format_RGB555, true>, | - |
916 | convertToRGB64<QImage::Format_RGB555>, | - |
917 | }, | - |
918 | { 5, 18, 5, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24, | - |
919 | convertARGBPMToARGB32PM<QImage::Format_ARGB8555_Premultiplied>, | - |
920 | convertARGBPMFromARGB32PM<QImage::Format_ARGB8555_Premultiplied, false>, | - |
921 | convertARGBPMFromRGB32convertARGBPMFromARGB32PM<QImage::Format_ARGB8555_Premultiplied, true>, | - |
922 | convertARGBPMToARGB64PM<QImage::Format_ARGB8555_Premultiplied>, | - |
923 | }, | - |
924 | { 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP24, | - |
925 | convertToRGB32<QImage::Format_RGB888>, | - |
926 | convertRGBFromARGB32PM<QImage::Format_RGB888, false>, | - |
927 | convertRGBFromRGB32convertRGBFromARGB32PM<QImage::Format_RGB888, true>, | - |
928 | convertToRGB64<QImage::Format_RGB888>, | - |
929 | }, | - |
930 | { 4, 8, 4, 4, 4, 0, 0, 0, false, QPixelLayout::BPP16, | - |
931 | convertToRGB32<QImage::Format_RGB444>, | - |
932 | convertRGBFromARGB32PM<QImage::Format_RGB444, false>, | - |
933 | convertRGBFromRGB32convertRGBFromARGB32PM<QImage::Format_RGB444, true>, | - |
934 | convertToRGB64<QImage::Format_RGB444>, | - |
935 | }, | - |
936 | { 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16, | - |
937 | convertARGBPMToARGB32PM<QImage::Format_ARGB4444_Premultiplied>, | - |
938 | convertARGBPMFromARGB32PM<QImage::Format_ARGB4444_Premultiplied, false>, | - |
939 | convertARGBPMFromRGB32convertARGBPMFromARGB32PM<QImage::Format_ARGB4444_Premultiplied, true>, | - |
940 | convertARGBPMToARGB64PM<QImage::Format_ARGB4444_Premultiplied>, | - |
941 | }, | - |
942 | #endif | - |
943 | #if Q_BYTE_ORDER == Q_BIG_ENDIAN | - |
944 | { 8, 24, 8, 16, 8, 8, 0, 0, false, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBXFromARGB32PM, convertRGBXFromRGB32, convertRGBA8888PMToARGB64PM }, | - |
945 | { 8, 24, 8, 16, 8, 8, 8, 0, false, QPixelLayout::BPP32, convertRGBA8888ToARGB32PM, convertRGBA8888FromARGB32PM, convertRGBXFromRGB32, convertRGBA8888ToARGB64PM }, | - |
946 | { 8, 24, 8, 16, 8, 8, 8, 0, true, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBA8888PMFromARGB32PM, convertRGBXFromRGB32, convertRGBA8888PMToARGB64PM}, | - |
947 | #else | - |
948 | { 8, 0, 8, 8, 8, 16, 0, 24, false, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBXFromARGB32PM, convertRGBXFromRGB32, convertRGBA8888PMToARGB64PM }, | - |
949 | { 8, 0, 8, 8, 8, 16, 8, 24, false, QPixelLayout::BPP32, convertRGBA8888ToARGB32PM, convertRGBA8888FromARGB32PM, convertRGBXFromRGB32, convertRGBA8888ToARGB64PM }, | - |
950 | { 8, 0, 8, 8, 8, 16, 8, 24, true, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBA8888PMFromARGB32PM, convertRGBXFromRGB32, convertRGBA8888PMToARGB64PM }, | - |
951 | #endif | - |
952 | { 10, 20, 10, 10, 10, 0, 0, 30, false, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderBGR>, convertRGB30FromARGB32PM<PixelOrderBGR>, convertRGB30FromRGB32<PixelOrderBGR>, convertA2RGB30PMToARGB64PM<PixelOrderBGR> }, | - |
953 | { 10, 20, 10, 10, 10, 0, 2, 30, true, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderBGR>, convertA2RGB30PMFromARGB32PM<PixelOrderBGR>, convertRGB30FromRGB32<PixelOrderBGR>, convertA2RGB30PMToARGB64PM<PixelOrderBGR> }, | - |
954 | { 10, 0, 10, 10, 10, 20, 0, 30, false, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderRGB>, convertRGB30FromARGB32PM<PixelOrderRGB>, convertRGB30FromRGB32<PixelOrderRGB>, convertA2RGB30PMToARGB64PM<PixelOrderRGB> }, | - |
955 | { 10, 0, 10, 10, 10, 20, 2, 30, true, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderRGB>, convertA2RGB30PMFromARGB32PM<PixelOrderRGB>, convertRGB30FromRGB32<PixelOrderRGB>, convertA2RGB30PMToARGB64PM<PixelOrderRGB> }, | - |
956 | { 0, 0, 0, 0, 0, 0, 8, 0, false, QPixelLayout::BPP8, convertAlpha8ToRGB32, convertAlpha8FromARGB32PM, 0, convertAlpha8ToRGB64 }, | - |
957 | { 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP8, convertGrayscale8ToRGB32, convertGrayscale8FromARGB32PM, convertGrayscale8FromRGB32, convertGrayscale8ToRGB64 } | - |
958 | }; | - |
959 | | - |
960 | const FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = { | - |
961 | 0, | - |
962 | fetchPixels<QPixelLayout::BPP1MSB>, | - |
963 | fetchPixels<QPixelLayout::BPP1LSB>, | - |
964 | fetchPixels<QPixelLayout::BPP8>, | - |
965 | fetchPixels<QPixelLayout::BPP16>, | - |
966 | fetchPixels<QPixelLayout::BPP24>, | - |
967 | fetchPixels<QPixelLayout::BPP32> | - |
968 | }; | - |
969 | | - |
| constStorePixelsFunc qStorePixels[QPixelLayout::BPPCount] = { | |
971 | 0, | - |
972 | storePixels<QPixelLayout::BPP1MSB>, | - |
973 | storePixels<QPixelLayout::BPP1LSB>, | - |
974 | storePixels<QPixelLayout::BPP8>, | - |
975 | storePixels<QPixelLayout::BPP16>, | - |
976 | storePixels<QPixelLayout::BPP24>, | - |
977 | storePixels<QPixelLayout::BPP32> | - |
978 | }; | - |
979 | | - |
980 | typedef uint (QT_FASTCALL *FetchPixelFunc)(const uchar *src, int index); | - |
981 | | - |
982 | static const FetchPixelFunc qFetchPixel[QPixelLayout::BPPCount] = { | - |
983 | 0, | - |
984 | fetchPixel<QPixelLayout::BPP1MSB>, | - |
985 | fetchPixel<QPixelLayout::BPP1LSB>, | - |
986 | fetchPixel<QPixelLayout::BPP8>, | - |
987 | fetchPixel<QPixelLayout::BPP16>, | - |
988 | fetchPixel<QPixelLayout::BPP24>, | - |
989 | fetchPixel<QPixelLayout::BPP32> | - |
990 | }; | - |
991 | | - |
992 | | - |
993 | | - |
994 | | - |
995 | | - |
996 | | - |
997 | static uint * QT_FASTCALL destFetchMono(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) | - |
998 | { | - |
999 | uchar *Q_DECL_RESTRICT data = (uchar *)rasterBuffer->scanLine(y); | - |
1000 | uint *start = buffer; | - |
1001 | const uint *end = buffer + length; | - |
1002 | while (buffer < end) { | - |
1003 | *buffer = data[x>>3] & (0x80 >> (x & 7)) ? rasterBuffer->destColor1 : rasterBuffer->destColor0; | - |
1004 | ++buffer; | - |
1005 | ++x; | - |
1006 | } | - |
1007 | return start; | - |
1008 | } | - |
1009 | | - |
1010 | static uint * QT_FASTCALL destFetchMonoLsb(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) | - |
1011 | { | - |
1012 | uchar *Q_DECL_RESTRICT data = (uchar *)rasterBuffer->scanLine(y); | - |
1013 | uint *start = buffer; | - |
1014 | const uint *end = buffer + length; | - |
1015 | while (buffer < end) { | - |
1016 | *buffer = data[x>>3] & (0x1 << (x & 7)) ? rasterBuffer->destColor1 : rasterBuffer->destColor0; | - |
1017 | ++buffer; | - |
1018 | ++x; | - |
1019 | } | - |
1020 | return start; | - |
1021 | } | - |
1022 | | - |
1023 | static uint * QT_FASTCALL destFetchARGB32P(uint *, QRasterBuffer *rasterBuffer, int x, int y, int) | - |
1024 | { | - |
1025 | return (uint *)rasterBuffer->scanLine(y) + x; | - |
1026 | } | - |
1027 | | - |
1028 | static uint * QT_FASTCALL destFetchRGB16(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) | - |
1029 | { | - |
1030 | const ushort *Q_DECL_RESTRICT data = (const ushort *)rasterBuffer->scanLine(y) + x; | - |
1031 | for (int i = 0; i < length; ++i) | - |
1032 | buffer[i] = qConvertRgb16To32(data[i]); | - |
1033 | return buffer; | - |
1034 | } | - |
1035 | | - |
1036 | static uint *QT_FASTCALL destFetch(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) | - |
1037 | { | - |
1038 | const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format]; | - |
1039 | const uint *ptr = qFetchPixels[layout->bpp](buffer, rasterBuffer->scanLine(y), x, length); | - |
1040 | return const_cast<uint *>(layout->convertToARGB32PM(buffer, ptr, length, layout, 0)); | - |
1041 | } | - |
1042 | | - |
1043 | static QRgba64 *QT_FASTCALL destFetch64(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) | - |
1044 | { | - |
1045 | const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format]; | - |
1046 | uint buffer32[buffer_size]; | - |
1047 | const uint *ptr = qFetchPixels[layout->bpp](buffer32, rasterBuffer->scanLine(y), x, length); | - |
1048 | return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, ptr, length, layout, 0)); | - |
1049 | } | - |
1050 | | - |
1051 | static QRgba64 *QT_FASTCALL destFetch64uint32(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) | - |
1052 | { | - |
1053 | const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format]; | - |
1054 | const uint *src = ((const uint *)rasterBuffer->scanLine(y)) + x; | - |
1055 | return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, src, length, layout, 0)); | - |
1056 | } | - |
1057 | | - |
1058 | static DestFetchProc destFetchProc[QImage::NImageFormats] = | - |
1059 | { | - |
1060 | 0, | - |
1061 | destFetchMono, | - |
1062 | destFetchMonoLsb, | - |
1063 | 0, | - |
1064 | destFetchARGB32P, | - |
1065 | destFetch, | - |
1066 | destFetchARGB32P, | - |
1067 | destFetchRGB16, | - |
1068 | destFetch, | - |
1069 | destFetch, | - |
1070 | destFetch, | - |
1071 | destFetch, | - |
1072 | destFetch, | - |
1073 | destFetch, | - |
1074 | destFetch, | - |
1075 | destFetch, | - |
1076 | destFetch, | - |
1077 | destFetch, | - |
1078 | destFetch, | - |
1079 | destFetch, | - |
1080 | destFetch, | - |
1081 | destFetch, | - |
1082 | destFetch, | - |
1083 | destFetch, | - |
1084 | destFetch, | - |
1085 | }; | - |
1086 | | - |
1087 | static DestFetchProc64 destFetchProc64[QImage::NImageFormats] = | - |
1088 | { | - |
1089 | 0, | - |
1090 | destFetch64, | - |
1091 | destFetch64, | - |
1092 | 0, | - |
1093 | destFetch64uint32, | - |
1094 | destFetch64uint32, | - |
1095 | destFetch64uint32, | - |
1096 | destFetch64, | - |
1097 | destFetch64, | - |
1098 | destFetch64, | - |
1099 | destFetch64, | - |
1100 | destFetch64, | - |
1101 | destFetch64, | - |
1102 | destFetch64, | - |
1103 | destFetch64, | - |
1104 | destFetch64, | - |
1105 | destFetch64uint32, | - |
1106 | destFetch64uint32, | - |
1107 | destFetch64uint32, | - |
1108 | destFetch64uint32, | - |
1109 | destFetch64uint32, | - |
1110 | destFetch64uint32, | - |
1111 | destFetch64uint32, | - |
1112 | destFetch64, | - |
1113 | destFetch64, | - |
1114 | }; | - |
1115 | | - |
1116 | | - |
1117 | | - |
1118 | | - |
1119 | | - |
1120 | static inline QRgb findNearestColor(QRgb color, QRasterBuffer *rbuf) | - |
1121 | { | - |
1122 | QRgb color_0 = qPremultiply(rbuf->destColor0); | - |
1123 | QRgb color_1 = qPremultiply(rbuf->destColor1); | - |
1124 | color = qPremultiply(color); | - |
1125 | | - |
1126 | int r = qRed(color); | - |
1127 | int g = qGreen(color); | - |
1128 | int b = qBlue(color); | - |
1129 | int rx, gx, bx; | - |
1130 | int dist_0, dist_1; | - |
1131 | | - |
1132 | rx = r - qRed(color_0); | - |
1133 | gx = g - qGreen(color_0); | - |
1134 | bx = b - qBlue(color_0); | - |
1135 | dist_0 = rx*rx + gx*gx + bx*bx; | - |
1136 | | - |
1137 | rx = r - qRed(color_1); | - |
1138 | gx = g - qGreen(color_1); | - |
1139 | bx = b - qBlue(color_1); | - |
1140 | dist_1 = rx*rx + gx*gx + bx*bx; | - |
1141 | | - |
1142 | if (dist_0 < dist_1) | - |
1143 | return color_0; | - |
1144 | return color_1; | - |
1145 | } | - |
1146 | | - |
1147 | | - |
1148 | | - |
1149 | | - |
1150 | | - |
1151 | static void QT_FASTCALL destStoreMono(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) | - |
1152 | { | - |
1153 | uchar *Q_DECL_RESTRICT data = (uchar *)rasterBuffer->scanLine(y); | - |
1154 | if (rasterBuffer->monoDestinationWithClut) { | - |
1155 | for (int i = 0; i < length; ++i) { | - |
1156 | if (buffer[i] == rasterBuffer->destColor0) { | - |
1157 | data[x >> 3] &= ~(0x80 >> (x & 7)); | - |
1158 | } else if (buffer[i] == rasterBuffer->destColor1) { | - |
1159 | data[x >> 3] |= 0x80 >> (x & 7); | - |
1160 | } else if (findNearestColor(buffer[i], rasterBuffer) == rasterBuffer->destColor0) { | - |
1161 | data[x >> 3] &= ~(0x80 >> (x & 7)); | - |
1162 | } else { | - |
1163 | data[x >> 3] |= 0x80 >> (x & 7); | - |
1164 | } | - |
1165 | ++x; | - |
1166 | } | - |
1167 | } else { | - |
1168 | for (int i = 0; i < length; ++i) { | - |
1169 | if (qGray(buffer[i]) < int(qt_bayer_matrix[y & 15][x & 15])) | - |
1170 | data[x >> 3] |= 0x80 >> (x & 7); | - |
1171 | else | - |
1172 | data[x >> 3] &= ~(0x80 >> (x & 7)); | - |
1173 | ++x; | - |
1174 | } | - |
1175 | } | - |
1176 | } | - |
1177 | | - |
1178 | static void QT_FASTCALL destStoreMonoLsb(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) | - |
1179 | { | - |
1180 | uchar *Q_DECL_RESTRICT data = (uchar *)rasterBuffer->scanLine(y); | - |
1181 | if (rasterBuffer->monoDestinationWithClut) { | - |
1182 | for (int i = 0; i < length; ++i) { | - |
1183 | if (buffer[i] == rasterBuffer->destColor0) { | - |
1184 | data[x >> 3] &= ~(1 << (x & 7)); | - |
1185 | } else if (buffer[i] == rasterBuffer->destColor1) { | - |
1186 | data[x >> 3] |= 1 << (x & 7); | - |
1187 | } else if (findNearestColor(buffer[i], rasterBuffer) == rasterBuffer->destColor0) { | - |
1188 | data[x >> 3] &= ~(1 << (x & 7)); | - |
1189 | } else { | - |
1190 | data[x >> 3] |= 1 << (x & 7); | - |
1191 | } | - |
1192 | ++x; | - |
1193 | } | - |
1194 | } else { | - |
1195 | for (int i = 0; i < length; ++i) { | - |
1196 | if (qGray(buffer[i]) < int(qt_bayer_matrix[y & 15][x & 15])) | - |
1197 | data[x >> 3] |= 1 << (x & 7); | - |
1198 | else | - |
1199 | data[x >> 3] &= ~(1 << (x & 7)); | - |
1200 | ++x; | - |
1201 | } | - |
1202 | } | - |
1203 | } | - |
1204 | | - |
1205 | static void QT_FASTCALL destStoreRGB16(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) | - |
1206 | { | - |
1207 | quint16 *data = (quint16*)rasterBuffer->scanLine(y) + x; | - |
1208 | for (int i = 0; i < length; ++i) | - |
1209 | data[i] = qConvertRgb32To16(buffer[i]); | - |
1210 | } | - |
1211 | | - |
1212 | static void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length) | - |
1213 | { | - |
1214 | uint buf[buffer_size]; | - |
1215 | const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format]; | - |
1216 | StorePixelsFunc store = qStorePixels[layout->bpp]; | - |
1217 | uchar *dest = rasterBuffer->scanLine(y); | - |
1218 | while (length) { | - |
1219 | int l = qMin(length, buffer_size); | - |
1220 | const uint *ptr = 0; | - |
1221 | if (!layout->premultiplied && !layout->alphaWidth) | - |
1222 | ptr = layout->convertFromRGB32(buf, buffer, l, layout, 0); | - |
1223 | else | - |
1224 | ptr = layout->convertFromARGB32PM(buf, buffer, l, layout, 0); | - |
1225 | store(dest, ptr, x, l); | - |
1226 | length -= l; | - |
1227 | buffer += l; | - |
1228 | x += l; | - |
1229 | } | - |
1230 | } | - |
1231 | | - |
1232 | static void QT_FASTCALL convertFromRgb64(uint *dest, const QRgba64 *src, int length) | - |
1233 | { | - |
1234 | for (int i = 0; i < length; ++i) { | - |
1235 | dest[i] = src[i].toArgb32(); | - |
1236 | } | - |
1237 | } | - |
1238 | | - |
1239 | static void QT_FASTCALL destStore64(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length) | - |
1240 | { | - |
1241 | uint buf[buffer_size]; | - |
1242 | const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format]; | - |
1243 | StorePixelsFunc store = qStorePixels[layout->bpp]; | - |
1244 | uchar *dest = rasterBuffer->scanLine(y); | - |
1245 | while (length) { | - |
1246 | int l = qMin(length, buffer_size); | - |
1247 | const uint *ptr = 0; | - |
1248 | convertFromRgb64(buf, buffer, l); | - |
1249 | if (!layout->premultiplied && !layout->alphaWidth) | - |
1250 | ptr = layout->convertFromRGB32(buf, buf, l, layout, 0); | - |
1251 | else | - |
1252 | ptr = layout->convertFromARGB32PM(buf, buf, l, layout, 0); | - |
1253 | store(dest, ptr, x, l); | - |
1254 | length -= l; | - |
1255 | buffer += l; | - |
1256 | x += l; | - |
1257 | } | - |
1258 | } | - |
1259 | | - |
1260 | #ifdef __SSE2__ | - |
1261 | template<QtPixelOrder PixelOrder> | - |
1262 | static inline void qConvertARGB64PMToA2RGB30PM_sse2(uint *dest, const QRgba64 *buffer, int count) | - |
1263 | { | - |
1264 | const __m128i gmask = _mm_set1_epi32(0x000ffc00); | - |
1265 | const __m128i cmask = _mm_set1_epi32(0x000003ff); | - |
1266 | int i = 0; | - |
1267 | __m128i vr, vg, vb, va; | - |
1268 | for (; i < count && (const uintptr_t)buffer & 0xF; ++i) { | - |
1269 | *dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++); | - |
1270 | } | - |
1271 | | - |
1272 | for (; i < count-15; i += 16) { | - |
1273 | | - |
1274 | | - |
1275 | __m128i vOr = _mm_set1_epi32(0); | - |
1276 | __m128i vAnd = _mm_set1_epi32(0xffffffff); | - |
1277 | for (int j = 0; j < 16; j += 2) { | - |
1278 | __m128i vs = _mm_load_si128((const __m128i*)(buffer + j)); | - |
1279 | vOr = _mm_or_si128(vOr, vs); | - |
1280 | vAnd = _mm_and_si128(vAnd, vs); | - |
1281 | } | - |
1282 | const quint16 orAlpha = ((uint)_mm_extract_epi16(vOr, 3)) | ((uint)_mm_extract_epi16(vOr, 7)); | - |
1283 | const quint16 andAlpha = ((uint)_mm_extract_epi16(vAnd, 3)) & ((uint)_mm_extract_epi16(vAnd, 7)); | - |
1284 | | - |
1285 | if (andAlpha == 0xffff) { | - |
1286 | for (int j = 0; j < 16; j += 2) { | - |
1287 | __m128i vs = _mm_load_si128((const __m128i*)buffer); | - |
1288 | buffer += 2; | - |
1289 | vr = _mm_srli_epi64(vs, 6); | - |
1290 | vg = _mm_srli_epi64(vs, 16 + 6 - 10); | - |
1291 | vb = _mm_srli_epi64(vs, 32 + 6); | - |
1292 | vr = _mm_and_si128(vr, cmask); | - |
1293 | vg = _mm_and_si128(vg, gmask); | - |
1294 | vb = _mm_and_si128(vb, cmask); | - |
1295 | va = _mm_srli_epi64(vs, 48 + 14); | - |
1296 | if (PixelOrder == PixelOrderRGB) | - |
1297 | vr = _mm_slli_epi32(vr, 20); | - |
1298 | else | - |
1299 | vb = _mm_slli_epi32(vb, 20); | - |
1300 | va = _mm_slli_epi32(va, 30); | - |
1301 | __m128i vd = _mm_or_si128(_mm_or_si128(vr, vg), _mm_or_si128(vb, va)); | - |
1302 | vd = _mm_shuffle_epi32(vd, _MM_SHUFFLE(3, 1, 2, 0)); | - |
1303 | _mm_storel_epi64((__m128i*)dest, vd); | - |
1304 | dest += 2; | - |
1305 | } | - |
1306 | } else if (orAlpha == 0) { | - |
1307 | for (int j = 0; j < 16; ++j) { | - |
1308 | *dest++ = 0; | - |
1309 | buffer++; | - |
1310 | } | - |
1311 | } else { | - |
1312 | for (int j = 0; j < 16; ++j) | - |
1313 | *dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++); | - |
1314 | } | - |
1315 | } | - |
1316 | | - |
1317 | for (; i < count; ++i) | - |
1318 | *dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++); | - |
1319 | } | - |
1320 | #endif | - |
1321 | | - |
1322 | static void QT_FASTCALL destStore64ARGB32(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length) | - |
1323 | { | - |
1324 | uint *dest = (uint*)rasterBuffer->scanLine(y) + x; | - |
1325 | for (int i = 0; i < length; ++i) { | - |
1326 | dest[i] = buffer[i].unpremultiplied().toArgb32(); | - |
1327 | } | - |
1328 | } | - |
1329 | | - |
1330 | static void QT_FASTCALL destStore64RGBA8888(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length) | - |
1331 | { | - |
1332 | uint *dest = (uint*)rasterBuffer->scanLine(y) + x; | - |
1333 | for (int i = 0; i < length; ++i) { | - |
1334 | dest[i] = ARGB2RGBA(buffer[i].unpremultiplied().toArgb32()); | - |
1335 | } | - |
1336 | } | - |
1337 | | - |
1338 | template<QtPixelOrder PixelOrder> | - |
1339 | static void QT_FASTCALL destStore64RGB30(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length) | - |
1340 | { | - |
1341 | uint *dest = (uint*)rasterBuffer->scanLine(y) + x; | - |
1342 | #ifdef __SSE2__ | - |
1343 | qConvertARGB64PMToA2RGB30PM_sse2<PixelOrder>(dest, buffer, length); | - |
1344 | #else | - |
1345 | for (int i = 0; i < length; ++i) { | - |
1346 | dest[i] = qConvertRgb64ToRgb30<PixelOrder>(buffer[i]); | - |
1347 | } | - |
1348 | #endif | - |
1349 | } | - |
1350 | | - |
1351 | static DestStoreProc destStoreProc[QImage::NImageFormats] = | - |
1352 | { | - |
1353 | 0, | - |
1354 | destStoreMono, | - |
1355 | destStoreMonoLsb, | - |
1356 | 0, | - |
1357 | 0, | - |
1358 | destStore, | - |
1359 | 0, | - |
1360 | destStoreRGB16, | - |
1361 | destStore, | - |
1362 | destStore, | - |
1363 | destStore, | - |
1364 | destStore, | - |
1365 | destStore, | - |
1366 | destStore, | - |
1367 | destStore, | - |
1368 | destStore, | - |
1369 | destStore, | - |
1370 | destStore, | - |
1371 | destStore, | - |
1372 | destStore, | - |
1373 | destStore, | - |
1374 | destStore, | - |
1375 | destStore, | - |
1376 | destStore, | - |
1377 | destStore, | - |
1378 | }; | - |
1379 | | - |
1380 | static DestStoreProc64 destStoreProc64[QImage::NImageFormats] = | - |
1381 | { | - |
1382 | 0, | - |
1383 | destStore64, | - |
1384 | destStore64, | - |
1385 | 0, | - |
1386 | destStore64, | - |
1387 | destStore64ARGB32, | - |
1388 | destStore64, | - |
1389 | destStore64, | - |
1390 | destStore64, | - |
1391 | destStore64, | - |
1392 | destStore64, | - |
1393 | destStore64, | - |
1394 | destStore64, | - |
1395 | destStore64, | - |
1396 | destStore64, | - |
1397 | destStore64, | - |
1398 | destStore64, | - |
1399 | destStore64RGBA8888, | - |
1400 | destStore64, | - |
1401 | destStore64RGB30<PixelOrderBGR>, | - |
1402 | destStore64RGB30<PixelOrderBGR>, | - |
1403 | destStore64RGB30<PixelOrderRGB>, | - |
1404 | destStore64RGB30<PixelOrderRGB>, | - |
1405 | destStore64, | - |
1406 | destStore64, | - |
1407 | }; | - |
1408 | | - |
1409 | | - |
1410 | | - |
1411 | | - |
1412 | | - |
1413 | | - |
1414 | | - |
1415 | | - |
1416 | | - |
1417 | | - |
1418 | | - |
1419 | | - |
1420 | | - |
1421 | | - |
1422 | | - |
1423 | | - |
1424 | enum TextureBlendType { | - |
1425 | BlendUntransformed, | - |
1426 | BlendTiled, | - |
1427 | BlendTransformed, | - |
1428 | BlendTransformedTiled, | - |
1429 | BlendTransformedBilinear, | - |
1430 | BlendTransformedBilinearTiled, | - |
1431 | NBlendTypes | - |
1432 | }; | - |
1433 | | - |
1434 | static const uint *QT_FASTCALL fetchUntransformed(uint *buffer, const Operator *, | - |
1435 | const QSpanData *data, int y, int x, int length) | - |
1436 | { | - |
1437 | const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; | - |
1438 | const uint *ptr = qFetchPixels[layout->bpp](buffer, data->texture.scanLine(y), x, length); | - |
1439 | const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; | - |
1440 | return layout->convertToARGB32PM(buffer, ptr, length, layout, clut); | - |
1441 | } | - |
1442 | | - |
1443 | static const uint *QT_FASTCALL fetchUntransformedARGB32PM(uint *, const Operator *, | - |
1444 | const QSpanData *data, int y, int x, int) | - |
1445 | { | - |
1446 | const uchar *scanLine = data->texture.scanLine(y); | - |
1447 | return ((const uint *)scanLine) + x; | - |
1448 | } | - |
1449 | | - |
1450 | static const uint *QT_FASTCALL fetchUntransformedRGB16(uint *buffer, const Operator *, | - |
1451 | const QSpanData *data, int y, int x, | - |
1452 | int length) | - |
1453 | { | - |
1454 | const quint16 *scanLine = (const quint16 *)data->texture.scanLine(y) + x; | - |
1455 | #ifdef QT_COMPILER_SUPPORTS_MIPS_DSPR2 | - |
1456 | qConvertRgb16To32_asm_mips_dspr2(buffer, scanLine, length); | - |
1457 | #else | - |
1458 | for (int i = 0; i < length; ++i) | - |
1459 | buffer[i] = qConvertRgb16To32(scanLine[i]); | - |
1460 | #endif | - |
1461 | return buffer; | - |
1462 | } | - |
1463 | | - |
1464 | static const QRgba64 *QT_FASTCALL fetchUntransformed64(QRgba64 *buffer, const Operator *, | - |
1465 | const QSpanData *data, int y, int x, int length) | - |
1466 | { | - |
1467 | const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; | - |
1468 | const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; | - |
1469 | if (layout->bpp != QPixelLayout::BPP32) { | - |
1470 | uint buffer32[buffer_size]; | - |
1471 | const uint *ptr = qFetchPixels[layout->bpp](buffer32, data->texture.scanLine(y), x, length); | - |
1472 | return layout->convertToARGB64PM(buffer, ptr, length, layout, clut); | - |
1473 | } else { | - |
1474 | const uint *src = (const uint *)data->texture.scanLine(y) + x; | - |
1475 | return layout->convertToARGB64PM(buffer, src, length, layout, clut); | - |
1476 | } | - |
1477 | } | - |
1478 | | - |
1479 | | - |
1480 | template<TextureBlendType blendType> | - |
1481 | static const uint *QT_FASTCALL fetchTransformedARGB32PM(uint *buffer, const Operator *, const QSpanData *data, | - |
1482 | int y, int x, int length) | - |
1483 | { | - |
1484 | int image_width = data->texture.width; | - |
1485 | int image_height = data->texture.height; | - |
1486 | | - |
1487 | const qreal cx = x + qreal(0.5); | - |
1488 | const qreal cy = y + qreal(0.5); | - |
1489 | | - |
1490 | const uint *end = buffer + length; | - |
1491 | uint *b = buffer; | - |
1492 | if (data->fast_matrix) { | - |
1493 | | - |
1494 | int fdx = (int)(data->m11 * fixed_scale); | - |
1495 | int fdy = (int)(data->m12 * fixed_scale); | - |
1496 | | - |
1497 | int fx = int((data->m21 * cy | - |
1498 | + data->m11 * cx + data->dx) * fixed_scale); | - |
1499 | int fy = int((data->m22 * cy | - |
1500 | + data->m12 * cx + data->dy) * fixed_scale); | - |
1501 | | - |
1502 | while (b < end) { | - |
1503 | int px = fx >> 16; | - |
1504 | int py = fy >> 16; | - |
1505 | | - |
1506 | if (blendType == BlendTransformedTiled) { | - |
1507 | px %= image_width; | - |
1508 | py %= image_height; | - |
1509 | if (px < 0) px += image_width; | - |
1510 | if (py < 0) py += image_height; | - |
1511 | } else { | - |
1512 | px = qBound(0, px, image_width - 1); | - |
1513 | py = qBound(0, py, image_height - 1); | - |
1514 | } | - |
1515 | *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px]; | - |
1516 | | - |
1517 | fx += fdx; | - |
1518 | fy += fdy; | - |
1519 | ++b; | - |
1520 | } | - |
1521 | } else { | - |
1522 | const qreal fdx = data->m11; | - |
1523 | const qreal fdy = data->m12; | - |
1524 | const qreal fdw = data->m13; | - |
1525 | | - |
1526 | qreal fx = data->m21 * cy + data->m11 * cx + data->dx; | - |
1527 | qreal fy = data->m22 * cy + data->m12 * cx + data->dy; | - |
1528 | qreal fw = data->m23 * cy + data->m13 * cx + data->m33; | - |
1529 | | - |
1530 | while (b < end) { | - |
1531 | const qreal iw = fw == 0 ? 1 : 1 / fw; | - |
1532 | const qreal tx = fx * iw; | - |
1533 | const qreal ty = fy * iw; | - |
1534 | int px = int(tx) - (tx < 0); | - |
1535 | int py = int(ty) - (ty < 0); | - |
1536 | | - |
1537 | if (blendType == BlendTransformedTiled) { | - |
1538 | px %= image_width; | - |
1539 | py %= image_height; | - |
1540 | if (px < 0) px += image_width; | - |
1541 | if (py < 0) py += image_height; | - |
1542 | } else { | - |
1543 | px = qBound(0, px, image_width - 1); | - |
1544 | py = qBound(0, py, image_height - 1); | - |
1545 | } | - |
1546 | *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px]; | - |
1547 | | - |
1548 | fx += fdx; | - |
1549 | fy += fdy; | - |
1550 | fw += fdw; | - |
1551 | | - |
1552 | if (!fw) { | - |
1553 | fw += fdw; | - |
1554 | } | - |
1555 | ++b; | - |
1556 | } | - |
1557 | } | - |
1558 | return buffer; | - |
1559 | } | - |
1560 | | - |
1561 | template<TextureBlendType blendType> | - |
1562 | static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data, | - |
1563 | int y, int x, int length) | - |
1564 | { | - |
1565 | int image_width = data->texture.width; | - |
1566 | int image_height = data->texture.height; | - |
1567 | | - |
1568 | const qreal cx = x + qreal(0.5); | - |
1569 | const qreal cy = y + qreal(0.5); | - |
1570 | | - |
1571 | const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; | - |
1572 | FetchPixelFunc fetch = qFetchPixel[layout->bpp]; | - |
1573 | | - |
1574 | const uint *end = buffer + length; | - |
1575 | uint *b = buffer; | - |
1576 | if (data->fast_matrix) { | - |
1577 | | - |
1578 | int fdx = (int)(data->m11 * fixed_scale); | - |
1579 | int fdy = (int)(data->m12 * fixed_scale); | - |
1580 | | - |
1581 | int fx = int((data->m21 * cy | - |
1582 | + data->m11 * cx + data->dx) * fixed_scale); | - |
1583 | int fy = int((data->m22 * cy | - |
1584 | + data->m12 * cx + data->dy) * fixed_scale); | - |
1585 | | - |
1586 | while (b < end) { | - |
1587 | int px = fx >> 16; | - |
1588 | int py = fy >> 16; | - |
1589 | | - |
1590 | if (blendType == BlendTransformedTiled) { | - |
1591 | px %= image_width; | - |
1592 | py %= image_height; | - |
1593 | if (px < 0) px += image_width; | - |
1594 | if (py < 0) py += image_height; | - |
1595 | } else { | - |
1596 | px = qBound(0, px, image_width - 1); | - |
1597 | py = qBound(0, py, image_height - 1); | - |
1598 | } | - |
1599 | *b = fetch(data->texture.scanLine(py), px); | - |
1600 | | - |
1601 | fx += fdx; | - |
1602 | fy += fdy; | - |
1603 | ++b; | - |
1604 | } | - |
1605 | } else { | - |
1606 | const qreal fdx = data->m11; | - |
1607 | const qreal fdy = data->m12; | - |
1608 | const qreal fdw = data->m13; | - |
1609 | | - |
1610 | qreal fx = data->m21 * cy + data->m11 * cx + data->dx; | - |
1611 | qreal fy = data->m22 * cy + data->m12 * cx + data->dy; | - |
1612 | qreal fw = data->m23 * cy + data->m13 * cx + data->m33; | - |
1613 | | - |
1614 | while (b < end) { | - |
1615 | const qreal iw = fw == 0 ? 1 : 1 / fw; | - |
1616 | const qreal tx = fx * iw; | - |
1617 | const qreal ty = fy * iw; | - |
1618 | int px = int(tx) - (tx < 0); | - |
1619 | int py = int(ty) - (ty < 0); | - |
1620 | | - |
1621 | if (blendType == BlendTransformedTiled) { | - |
1622 | px %= image_width; | - |
1623 | py %= image_height; | - |
1624 | if (px < 0) px += image_width; | - |
1625 | if (py < 0) py += image_height; | - |
1626 | } else { | - |
1627 | px = qBound(0, px, image_width - 1); | - |
1628 | py = qBound(0, py, image_height - 1); | - |
1629 | } | - |
1630 | *b = fetch(data->texture.scanLine(py), px); | - |
1631 | | - |
1632 | fx += fdx; | - |
1633 | fy += fdy; | - |
1634 | fw += fdw; | - |
1635 | | - |
1636 | if (!fw) { | - |
1637 | fw += fdw; | - |
1638 | } | - |
1639 | ++b; | - |
1640 | } | - |
1641 | } | - |
1642 | const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; | - |
1643 | return layout->convertToARGB32PM(buffer, buffer, length, layout, clut); | - |
1644 | } | - |
1645 | | - |
1646 | template<TextureBlendType blendType> | - |
1647 | static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Operator *, const QSpanData *data, | - |
1648 | int y, int x, int length) | - |
1649 | { | - |
1650 | int image_width = data->texture.width; | - |
1651 | int image_height = data->texture.height; | - |
1652 | | - |
1653 | const qreal cx = x + qreal(0.5); | - |
1654 | const qreal cy = y + qreal(0.5); | - |
1655 | | - |
1656 | const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; | - |
1657 | FetchPixelFunc fetch = qFetchPixel[layout->bpp]; | - |
1658 | const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; | - |
1659 | | - |
1660 | uint buffer32[buffer_size]; | - |
1661 | QRgba64 *b = buffer; | - |
1662 | if (data->fast_matrix) { | - |
1663 | | - |
1664 | int fdx = (int)(data->m11 * fixed_scale); | - |
1665 | int fdy = (int)(data->m12 * fixed_scale); | - |
1666 | | - |
1667 | int fx = int((data->m21 * cy | - |
1668 | + data->m11 * cx + data->dx) * fixed_scale); | - |
1669 | int fy = int((data->m22 * cy | - |
1670 | + data->m12 * cx + data->dy) * fixed_scale); | - |
1671 | | - |
1672 | int i = 0, j = 0; | - |
1673 | while (i < length) { | - |
1674 | if (j == buffer_size) { | - |
1675 | layout->convertToARGB64PM(b, buffer32, buffer_size, layout, clut); | - |
1676 | b += buffer_size; | - |
1677 | j = 0; | - |
1678 | } | - |
1679 | int px = fx >> 16; | - |
1680 | int py = fy >> 16; | - |
1681 | | - |
1682 | if (blendType == BlendTransformedTiled) { | - |
1683 | px %= image_width; | - |
1684 | py %= image_height; | - |
1685 | if (px < 0) px += image_width; | - |
1686 | if (py < 0) py += image_height; | - |
1687 | } else { | - |
1688 | px = qBound(0, px, image_width - 1); | - |
1689 | py = qBound(0, py, image_height - 1); | - |
1690 | } | - |
1691 | buffer32[j] = fetch(data->texture.scanLine(py), px); | - |
1692 | | - |
1693 | fx += fdx; | - |
1694 | fy += fdy; | - |
1695 | ++i; ++j; | - |
1696 | } | - |
1697 | if (j > 0) { | - |
1698 | layout->convertToARGB64PM(b, buffer32, j, layout, clut); | - |
1699 | b += j; | - |
1700 | } | - |
1701 | } else { | - |
1702 | const qreal fdx = data->m11; | - |
1703 | const qreal fdy = data->m12; | - |
1704 | const qreal fdw = data->m13; | - |
1705 | | - |
1706 | qreal fx = data->m21 * cy + data->m11 * cx + data->dx; | - |
1707 | qreal fy = data->m22 * cy + data->m12 * cx + data->dy; | - |
1708 | qreal fw = data->m23 * cy + data->m13 * cx + data->m33; | - |
1709 | | - |
1710 | int i = 0, j = 0; | - |
1711 | while (i < length) { | - |
1712 | if (j == buffer_size) { | - |
1713 | layout->convertToARGB64PM(b, buffer32, buffer_size, layout, clut); | - |
1714 | b += buffer_size; | - |
1715 | j = 0; | - |
1716 | } | - |
1717 | const qreal iw = fw == 0 ? 1 : 1 / fw; | - |
1718 | const qreal tx = fx * iw; | - |
1719 | const qreal ty = fy * iw; | - |
1720 | int px = int(tx) - (tx < 0); | - |
1721 | int py = int(ty) - (ty < 0); | - |
1722 | | - |
1723 | if (blendType == BlendTransformedTiled) { | - |
1724 | px %= image_width; | - |
1725 | py %= image_height; | - |
1726 | if (px < 0) px += image_width; | - |
1727 | if (py < 0) py += image_height; | - |
1728 | } else { | - |
1729 | px = qBound(0, px, image_width - 1); | - |
1730 | py = qBound(0, py, image_height - 1); | - |
1731 | } | - |
1732 | buffer32[j] = fetch(data->texture.scanLine(py), px); | - |
1733 | | - |
1734 | fx += fdx; | - |
1735 | fy += fdy; | - |
1736 | fw += fdw; | - |
1737 | | - |
1738 | if (!fw) { | - |
1739 | fw += fdw; | - |
1740 | } | - |
1741 | ++i; ++j; | - |
1742 | } | - |
1743 | if (j > 0) { | - |
1744 | layout->convertToARGB64PM(b, buffer32, j, layout, clut); | - |
1745 | b += j; | - |
1746 | } | - |
1747 | } | - |
1748 | return buffer; | - |
1749 | } | - |
1750 | | - |
1751 | | - |
1752 | | - |
1753 | | - |
1754 | | - |
1755 | static inline uint interpolate_4_pixels_16(uint tl, uint tr, uint bl, uint br, int distx, int disty) | - |
1756 | { | - |
1757 | uint distxy = distx * disty; | - |
1758 | | - |
1759 | | - |
1760 | uint tlrb = (tl & 0x00ff00ff) * (16*16 - 16*distx - 16*disty + distxy); | - |
1761 | uint tlag = ((tl & 0xff00ff00) >> 8) * (16*16 - 16*distx - 16*disty + distxy); | - |
1762 | uint trrb = ((tr & 0x00ff00ff) * (distx*16 - distxy)); | - |
1763 | uint trag = (((tr & 0xff00ff00) >> 8) * (distx*16 - distxy)); | - |
1764 | uint blrb = ((bl & 0x00ff00ff) * (disty*16 - distxy)); | - |
1765 | uint blag = (((bl & 0xff00ff00) >> 8) * (disty*16 - distxy)); | - |
1766 | uint brrb = ((br & 0x00ff00ff) * (distxy)); | - |
1767 | uint brag = (((br & 0xff00ff00) >> 8) * (distxy)); | - |
1768 | return (((tlrb + trrb + blrb + brrb) >> 8) & 0x00ff00ff) | ((tlag + trag + blag + brag) & 0xff00ff00); | - |
1769 | } | - |
1770 | | - |
1771 | #if defined(__SSE2__) | - |
1772 | #define interpolate_4_pixels_16_sse2(tl, tr, bl, br, distx, disty, colorMask, v_256, b) \ | - |
1773 | { \ | - |
1774 | const __m128i dxdy = _mm_mullo_epi16 (distx, disty); \ | - |
1775 | const __m128i distx_ = _mm_slli_epi16(distx, 4); \ | - |
1776 | const __m128i disty_ = _mm_slli_epi16(disty, 4); \ | - |
1777 | const __m128i idxidy = _mm_add_epi16(dxdy, _mm_sub_epi16(v_256, _mm_add_epi16(distx_, disty_))); \ | - |
1778 | const __m128i dxidy = _mm_sub_epi16(distx_, dxdy); \ | - |
1779 | const __m128i idxdy = _mm_sub_epi16(disty_, dxdy); \ | - |
1780 | \ | - |
1781 | __m128i tlAG = _mm_srli_epi16(tl, 8); \ | - |
1782 | __m128i tlRB = _mm_and_si128(tl, colorMask); \ | - |
1783 | __m128i trAG = _mm_srli_epi16(tr, 8); \ | - |
1784 | __m128i trRB = _mm_and_si128(tr, colorMask); \ | - |
1785 | __m128i blAG = _mm_srli_epi16(bl, 8); \ | - |
1786 | __m128i blRB = _mm_and_si128(bl, colorMask); \ | - |
1787 | __m128i brAG = _mm_srli_epi16(br, 8); \ | - |
1788 | __m128i brRB = _mm_and_si128(br, colorMask); \ | - |
1789 | \ | - |
1790 | tlAG = _mm_mullo_epi16(tlAG, idxidy); \ | - |
1791 | tlRB = _mm_mullo_epi16(tlRB, idxidy); \ | - |
1792 | trAG = _mm_mullo_epi16(trAG, dxidy); \ | - |
1793 | trRB = _mm_mullo_epi16(trRB, dxidy); \ | - |
1794 | blAG = _mm_mullo_epi16(blAG, idxdy); \ | - |
1795 | blRB = _mm_mullo_epi16(blRB, idxdy); \ | - |
1796 | brAG = _mm_mullo_epi16(brAG, dxdy); \ | - |
1797 | brRB = _mm_mullo_epi16(brRB, dxdy); \ | - |
1798 | \ | - |
1799 | /* Add the values, and shift to only keep 8 significant bits per colors */ \ | - |
1800 | __m128i rAG =_mm_add_epi16(_mm_add_epi16(tlAG, trAG), _mm_add_epi16(blAG, brAG)); \ | - |
1801 | __m128i rRB =_mm_add_epi16(_mm_add_epi16(tlRB, trRB), _mm_add_epi16(blRB, brRB)); \ | - |
1802 | rAG = _mm_andnot_si128(colorMask, rAG); \ | - |
1803 | rRB = _mm_srli_epi16(rRB, 8); \ | - |
1804 | _mm_storeu_si128((__m128i*)(b), _mm_or_si128(rAG, rRB)); \ | - |
1805 | } | - |
1806 | #endif | - |
1807 | | - |
1808 | #if defined(__ARM_NEON__) | - |
1809 | #define interpolate_4_pixels_16_neon(tl, tr, bl, br, distx, disty, disty_, colorMask, invColorMask, v_256, b) \ | - |
1810 | { \ | - |
1811 | const int16x8_t dxdy = vmulq_s16(distx, disty); \ | - |
1812 | const int16x8_t distx_ = vshlq_n_s16(distx, 4); \ | - |
1813 | const int16x8_t idxidy = vaddq_s16(dxdy, vsubq_s16(v_256, vaddq_s16(distx_, disty_))); \ | - |
1814 | const int16x8_t dxidy = vsubq_s16(distx_, dxdy); \ | - |
1815 | const int16x8_t idxdy = vsubq_s16(disty_, dxdy); \ | - |
1816 | \ | - |
1817 | int16x8_t tlAG = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(tl), 8)); \ | - |
1818 | int16x8_t tlRB = vandq_s16(tl, colorMask); \ | - |
1819 | int16x8_t trAG = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(tr), 8)); \ | - |
1820 | int16x8_t trRB = vandq_s16(tr, colorMask); \ | - |
1821 | int16x8_t blAG = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(bl), 8)); \ | - |
1822 | int16x8_t blRB = vandq_s16(bl, colorMask); \ | - |
1823 | int16x8_t brAG = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(br), 8)); \ | - |
1824 | int16x8_t brRB = vandq_s16(br, colorMask); \ | - |
1825 | \ | - |
1826 | int16x8_t rAG = vmulq_s16(tlAG, idxidy); \ | - |
1827 | int16x8_t rRB = vmulq_s16(tlRB, idxidy); \ | - |
1828 | rAG = vmlaq_s16(rAG, trAG, dxidy); \ | - |
1829 | rRB = vmlaq_s16(rRB, trRB, dxidy); \ | - |
1830 | rAG = vmlaq_s16(rAG, blAG, idxdy); \ | - |
1831 | rRB = vmlaq_s16(rRB, blRB, idxdy); \ | - |
1832 | rAG = vmlaq_s16(rAG, brAG, dxdy); \ | - |
1833 | rRB = vmlaq_s16(rRB, brRB, dxdy); \ | - |
1834 | \ | - |
1835 | rAG = vandq_s16(invColorMask, rAG); \ | - |
1836 | rRB = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(rRB), 8)); \ | - |
1837 | vst1q_s16((int16_t*)(b), vorrq_s16(rAG, rRB)); \ | - |
1838 | } | - |
1839 | #endif | - |
1840 | | - |
1841 | #if defined(__SSE2__) | - |
1842 | static inline QRgba64 interpolate_4_pixels_rgb64(QRgba64 t[], QRgba64 b[], uint distx, uint disty) | - |
1843 | { | - |
1844 | const __m128i vdistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(distx), _MM_SHUFFLE(0, 0, 0, 0)); | - |
1845 | const __m128i vidistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(0x10000 - distx), _MM_SHUFFLE(0, 0, 0, 0)); | - |
1846 | | - |
1847 | __m128i vt = _mm_loadu_si128((const __m128i*)t); | - |
1848 | if (disty) { | - |
1849 | __m128i vb = _mm_loadu_si128((const __m128i*)b); | - |
1850 | vt = _mm_mulhi_epu16(vt, _mm_set1_epi16(0x10000 - disty)); | - |
1851 | vb = _mm_mulhi_epu16(vb, _mm_set1_epi16(disty)); | - |
1852 | vt = _mm_add_epi16(vt, vb); | - |
1853 | } | - |
1854 | vt = _mm_mulhi_epu16(vt, _mm_unpacklo_epi64(vidistx, vdistx)); | - |
1855 | vt = _mm_add_epi16(vt, _mm_srli_si128(vt, 8)); | - |
1856 | #ifdef Q_PROCESSOR_X86_64 | - |
1857 | return QRgba64::fromRgba64(_mm_cvtsi128_si64(vt)); | - |
1858 | #else | - |
1859 | QRgba64 out; | - |
1860 | _mm_storel_epi64((__m128i*)&out, vt); | - |
1861 | return out; | - |
1862 | #endif | - |
1863 | } | - |
1864 | #else | - |
1865 | static inline QRgba64 interpolate_4_pixels_rgb64(QRgba64 t[], QRgba64 b[], uint distx, uint disty) | - |
1866 | { | - |
1867 | const uint dx = distx>>8; | - |
1868 | const uint dy = disty>>8; | - |
1869 | const uint idx = 256 - dx; | - |
1870 | const uint idy = 256 - dy; | - |
1871 | QRgba64 xtop = interpolate256(t[0], idx, t[1], dx); | - |
1872 | QRgba64 xbot = interpolate256(b[0], idx, b[1], dx); | - |
1873 | return interpolate256(xtop, idy, xbot, dy); | - |
1874 | } | - |
1875 | #endif | - |
1876 | | - |
1877 | template<TextureBlendType blendType> | - |
1878 | void fetchTransformedBilinear_pixelBounds(int max, int l1, int l2, int &v1, int &v2); | - |
1879 | | - |
1880 | template<> | - |
1881 | inline void fetchTransformedBilinear_pixelBounds<BlendTransformedBilinearTiled>(int max, int, int, int &v1, int &v2) | - |
1882 | { | - |
1883 | v1 %= max; | - |
1884 | if (v1 < 0) | - |
1885 | v1 += max; | - |
1886 | v2 = v1 + 1; | - |
1887 | if (v2 == max) | - |
1888 | v2 = 0; | - |
1889 | Q_ASSERT(v1 >= 0 && v1 < max); | - |
1890 | Q_ASSERT(v2 >= 0 && v2 < max); | - |
1891 | } | - |
1892 | | - |
1893 | template<> | - |
1894 | inline void fetchTransformedBilinear_pixelBounds<BlendTransformedBilinear>(int, int l1, int l2, int &v1, int &v2) | - |
1895 | { | - |
1896 | if (v1 < l1) | - |
1897 | v2 = v1 = l1; | - |
1898 | else if (v1 >= l2) | - |
1899 | v2 = v1 = l2; | - |
1900 | else | - |
1901 | v2 = v1 + 1; | - |
1902 | Q_ASSERT(v1 >= l1 && v1 <= l2); | - |
1903 | Q_ASSERT(v2 >= l1 && v2 <= l2); | - |
1904 | } | - |
1905 | | - |
1906 | template<TextureBlendType blendType> | - |
1907 | static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, const Operator *, | - |
1908 | const QSpanData *data, int y, int x, | - |
1909 | int length) | - |
1910 | { | - |
1911 | int image_width = data->texture.width; | - |
1912 | int image_height = data->texture.height; | - |
1913 | | - |
1914 | int image_x1 = data->texture.x1; | - |
1915 | int image_y1 = data->texture.y1; | - |
1916 | int image_x2 = data->texture.x2 - 1; | - |
1917 | int image_y2 = data->texture.y2 - 1; | - |
1918 | | - |
1919 | const qreal cx = x + qreal(0.5); | - |
1920 | const qreal cy = y + qreal(0.5); | - |
1921 | | - |
1922 | uint *end = buffer + length; | - |
1923 | uint *b = buffer; | - |
1924 | if (data->fast_matrix) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1925 | | - |
1926 | int fdx = (int)(data->m11 * fixed_scale); | - |
1927 | int fdy = (int)(data->m12 * fixed_scale); | - |
1928 | | - |
1929 | int fx = int((data->m21 * cy | - |
1930 | + data->m11 * cx + data->dx) * fixed_scale); | - |
1931 | int fy = int((data->m22 * cy | - |
1932 | + data->m12 * cx + data->dy) * fixed_scale); | - |
1933 | | - |
1934 | fx -= half_point; | - |
1935 | fy -= half_point; | - |
1936 | | - |
1937 | if (fdy == 0) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1938 | int y1 = (fy >> 16); | - |
1939 | int y2; | - |
1940 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
1941 | const uint *s1 = (const uint *)data->texture.scanLine(y1); | - |
1942 | const uint *s2 = (const uint *)data->texture.scanLine(y2); | - |
1943 | | - |
1944 | if (fdx <= fixed_scale && fdx > 0) { TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1945 | int disty = (fy & 0x0000ffff) >> 8; | - |
1946 | int idisty = 256 - disty; | - |
1947 | int x = fx >> 16; | - |
1948 | | - |
1949 | | - |
1950 | | - |
1951 | | - |
1952 | | - |
1953 | | - |
1954 | | - |
1955 | quint32 intermediate_buffer[2][buffer_size + 2]; | - |
1956 | | - |
1957 | int count = (qint64(length) * fdx + fixed_scale - 1) / fixed_scale + 2; | - |
1958 | Q_ASSERT(count <= buffer_size + 2); | - |
1959 | int f = 0; | - |
1960 | int lim = count; | - |
1961 | if (blendType == BlendTransformedBilinearTiled) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1962 | x %= image_width; | - |
1963 | if (x < 0) x += image_width; never executed: x += image_width; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1964 | } else { never executed: end of block | 0 |
1965 | lim = qMin(count, image_x2-x+1); | - |
1966 | if (x < image_x1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1967 | Q_ASSERT(x <= image_x2); | - |
1968 | uint t = s1[image_x1]; | - |
1969 | uint b = s2[image_x1]; | - |
1970 | quint32 rb = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; | - |
1971 | quint32 ag = ((((t>>8) & 0xff00ff) * idisty + ((b>>8) & 0xff00ff) * disty) >> 8) & 0xff00ff; | - |
1972 | do { | - |
1973 | intermediate_buffer[0][f] = rb; | - |
1974 | intermediate_buffer[1][f] = ag; | - |
1975 | f++; | - |
1976 | x++; | - |
1977 | } while (x < image_x1 && f < lim); never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1978 | } never executed: end of block | 0 |
1979 | } never executed: end of block | 0 |
1980 | | - |
1981 | if (blendType != BlendTransformedBilinearTiled) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1982 | #if defined(__SSE2__) | - |
1983 | const __m128i disty_ = _mm_set1_epi16(disty); | - |
1984 | const __m128i idisty_ = _mm_set1_epi16(idisty); | - |
1985 | const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); | - |
1986 | | - |
1987 | lim -= 3; | - |
1988 | for (; f < lim; x += 4, f += 4) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1989 | | - |
1990 | __m128i top = _mm_loadu_si128((const __m128i*)((const uint *)(s1)+x)); | - |
1991 | __m128i topAG = _mm_srli_epi16(top, 8); | - |
1992 | __m128i topRB = _mm_and_si128(top, colorMask); | - |
1993 | | - |
1994 | topAG = _mm_mullo_epi16 (topAG, idisty_); | - |
1995 | topRB = _mm_mullo_epi16 (topRB, idisty_); | - |
1996 | | - |
1997 | | - |
1998 | __m128i bottom = _mm_loadu_si128((const __m128i*)((const uint *)(s2)+x)); | - |
1999 | __m128i bottomAG = _mm_srli_epi16(bottom, 8); | - |
2000 | __m128i bottomRB = _mm_and_si128(bottom, colorMask); | - |
2001 | bottomAG = _mm_mullo_epi16 (bottomAG, disty_); | - |
2002 | bottomRB = _mm_mullo_epi16 (bottomRB, disty_); | - |
2003 | | - |
2004 | | - |
2005 | __m128i rAG =_mm_add_epi16(topAG, bottomAG); | - |
2006 | rAG = _mm_srli_epi16(rAG, 8); | - |
2007 | _mm_storeu_si128((__m128i*)(&intermediate_buffer[1][f]), rAG); | - |
2008 | __m128i rRB =_mm_add_epi16(topRB, bottomRB); | - |
2009 | rRB = _mm_srli_epi16(rRB, 8); | - |
2010 | _mm_storeu_si128((__m128i*)(&intermediate_buffer[0][f]), rRB); | - |
2011 | } never executed: end of block | 0 |
2012 | #elif defined(__ARM_NEON__) | - |
2013 | const int16x8_t disty_ = vdupq_n_s16(disty); | - |
2014 | const int16x8_t idisty_ = vdupq_n_s16(idisty); | - |
2015 | const int16x8_t colorMask = vdupq_n_s16(0x00ff); | - |
2016 | | - |
2017 | lim -= 3; | - |
2018 | for (; f < lim; x += 4, f += 4) { | - |
2019 | | - |
2020 | int16x8_t top = vld1q_s16((int16_t*)((const uint *)(s1)+x)); | - |
2021 | int16x8_t topAG = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(top), 8)); | - |
2022 | int16x8_t topRB = vandq_s16(top, colorMask); | - |
2023 | | - |
2024 | topAG = vmulq_s16(topAG, idisty_); | - |
2025 | topRB = vmulq_s16(topRB, idisty_); | - |
2026 | | - |
2027 | | - |
2028 | int16x8_t bottom = vld1q_s16((int16_t*)((const uint *)(s2)+x)); | - |
2029 | int16x8_t bottomAG = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(bottom), 8)); | - |
2030 | int16x8_t bottomRB = vandq_s16(bottom, colorMask); | - |
2031 | bottomAG = vmulq_s16(bottomAG, disty_); | - |
2032 | bottomRB = vmulq_s16(bottomRB, disty_); | - |
2033 | | - |
2034 | | - |
2035 | int16x8_t rAG = vaddq_s16(topAG, bottomAG); | - |
2036 | rAG = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(rAG), 8)); | - |
2037 | vst1q_s16((int16_t*)(&intermediate_buffer[1][f]), rAG); | - |
2038 | int16x8_t rRB = vaddq_s16(topRB, bottomRB); | - |
2039 | rRB = vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(rRB), 8)); | - |
2040 | vst1q_s16((int16_t*)(&intermediate_buffer[0][f]), rRB); | - |
2041 | } | - |
2042 | #endif | - |
2043 | } never executed: end of block | 0 |
2044 | for (; f < count; f++) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2045 | if (blendType == BlendTransformedBilinearTiled) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2046 | if (x >= image_width) x -= image_width; never executed: x -= image_width; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2047 | } else { never executed: end of block | 0 |
2048 | x = qMin(x, image_x2); | - |
2049 | } never executed: end of block | 0 |
2050 | | - |
2051 | uint t = s1[x]; | - |
2052 | uint b = s2[x]; | - |
2053 | | - |
2054 | intermediate_buffer[0][f] = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; | - |
2055 | intermediate_buffer[1][f] = ((((t>>8) & 0xff00ff) * idisty + ((b>>8) & 0xff00ff) * disty) >> 8) & 0xff00ff; | - |
2056 | x++; | - |
2057 | } never executed: end of block | 0 |
2058 | | - |
2059 | fx &= fixed_scale - 1; | - |
2060 | Q_ASSERT((fx >> 16) == 0); | - |
2061 | while (b < end) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2062 | int x1 = (fx >> 16); | - |
2063 | int x2 = x1 + 1; | - |
2064 | Q_ASSERT(x1 >= 0); | - |
2065 | Q_ASSERT(x2 < count); | - |
2066 | | - |
2067 | int distx = (fx & 0x0000ffff) >> 8; | - |
2068 | int idistx = 256 - distx; | - |
2069 | int rb = ((intermediate_buffer[0][x1] * idistx + intermediate_buffer[0][x2] * distx) >> 8) & 0xff00ff; | - |
2070 | int ag = (intermediate_buffer[1][x1] * idistx + intermediate_buffer[1][x2] * distx) & 0xff00ff00; | - |
2071 | *b = rb | ag; | - |
2072 | b++; | - |
2073 | fx += fdx; | - |
2074 | } never executed: end of block | 0 |
2075 | } else if ((fdx < 0 && fdx > -(fixed_scale / 8)) || std::abs(data->m22) < (1./8.)) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2076 | int y1 = (fy >> 16); | - |
2077 | int y2; | - |
2078 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2079 | const uint *s1 = (const uint *)data->texture.scanLine(y1); | - |
2080 | const uint *s2 = (const uint *)data->texture.scanLine(y2); | - |
2081 | int disty = (fy & 0x0000ffff) >> 8; | - |
2082 | while (b < end) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2083 | int x1 = (fx >> 16); | - |
2084 | int x2; | - |
2085 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2086 | uint tl = s1[x1]; | - |
2087 | uint tr = s1[x2]; | - |
2088 | uint bl = s2[x1]; | - |
2089 | uint br = s2[x2]; | - |
2090 | int distx = (fx & 0x0000ffff) >> 8; | - |
2091 | *b = interpolate_4_pixels(tl, tr, bl, br, distx, disty); | - |
2092 | | - |
2093 | fx += fdx; | - |
2094 | ++b; | - |
2095 | } never executed: end of block | 0 |
2096 | } else { never executed: end of block | 0 |
2097 | int y1 = (fy >> 16); | - |
2098 | int y2; | - |
2099 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2100 | const uint *s1 = (const uint *)data->texture.scanLine(y1); | - |
2101 | const uint *s2 = (const uint *)data->texture.scanLine(y2); | - |
2102 | int disty = (fy & 0x0000ffff) >> 12; | - |
2103 | | - |
2104 | if (blendType != BlendTransformedBilinearTiled) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2105 | #define BILINEAR_DOWNSCALE_BOUNDS_PROLOG \ | - |
2106 | while (b < end) { \ | - |
2107 | int x1 = (fx >> 16); \ | - |
2108 | int x2; \ | - |
2109 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); \ | - |
2110 | if (x1 != x2) \ | - |
2111 | break; \ | - |
2112 | uint tl = s1[x1]; \ | - |
2113 | uint tr = s1[x2]; \ | - |
2114 | uint bl = s2[x1]; \ | - |
2115 | uint br = s2[x2]; \ | - |
2116 | int distx = (fx & 0x0000ffff) >> 12; \ | - |
2117 | *b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); \ | - |
2118 | fx += fdx; \ | - |
2119 | ++b; \ | - |
2120 | } \ | - |
2121 | uint *boundedEnd; \ | - |
2122 | if (fdx > 0) \ | - |
2123 | boundedEnd = qMin(end, buffer + uint((image_x2 - (fx >> 16)) / data->m11)); \ | - |
2124 | else \ | - |
2125 | boundedEnd = qMin(end, buffer + uint((image_x1 - (fx >> 16)) / data->m11)); \ | - |
2126 | boundedEnd -= 3; | - |
2127 | | - |
2128 | #if defined(__SSE2__) | - |
2129 | BILINEAR_DOWNSCALE_BOUNDS_PROLOG never executed: break; never executed: end of block never executed: boundedEnd = qMin(end, buffer + uint((image_x2 - (fx >> 16)) / data->m11)); never executed: boundedEnd = qMin(end, buffer + uint((image_x1 - (fx >> 16)) / data->m11)); TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2130 | | - |
2131 | const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); | - |
2132 | const __m128i v_256 = _mm_set1_epi16(256); | - |
2133 | const __m128i v_disty = _mm_set1_epi16(disty); | - |
2134 | const __m128i v_fdx = _mm_set1_epi32(fdx*4); | - |
2135 | __m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx); | - |
2136 | | - |
2137 | while (b < boundedEnd) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2138 | __m128i offset = _mm_srli_epi32(v_fx, 16); | - |
2139 | const int offset0 = _mm_cvtsi128_si32(offset); offset = _mm_srli_si128(offset, 4); | - |
2140 | const int offset1 = _mm_cvtsi128_si32(offset); offset = _mm_srli_si128(offset, 4); | - |
2141 | const int offset2 = _mm_cvtsi128_si32(offset); offset = _mm_srli_si128(offset, 4); | - |
2142 | const int offset3 = _mm_cvtsi128_si32(offset); | - |
2143 | const __m128i tl = _mm_setr_epi32(s1[offset0], s1[offset1], s1[offset2], s1[offset3]); | - |
2144 | const __m128i tr = _mm_setr_epi32(s1[offset0 + 1], s1[offset1 + 1], s1[offset2 + 1], s1[offset3 + 1]); | - |
2145 | const __m128i bl = _mm_setr_epi32(s2[offset0], s2[offset1], s2[offset2], s2[offset3]); | - |
2146 | const __m128i br = _mm_setr_epi32(s2[offset0 + 1], s2[offset1 + 1], s2[offset2 + 1], s2[offset3 + 1]); | - |
2147 | | - |
2148 | __m128i v_distx = _mm_srli_epi16(v_fx, 12); | - |
2149 | v_distx = _mm_shufflehi_epi16(v_distx, _MM_SHUFFLE(2,2,0,0)); | - |
2150 | v_distx = _mm_shufflelo_epi16(v_distx, _MM_SHUFFLE(2,2,0,0)); | - |
2151 | | - |
2152 | interpolate_4_pixels_16_sse2(tl, tr, bl, br, v_distx, v_disty, colorMask, v_256, b); | - |
2153 | b += 4; | - |
2154 | v_fx = _mm_add_epi32(v_fx, v_fdx); | - |
2155 | } never executed: end of block | 0 |
2156 | fx = _mm_cvtsi128_si32(v_fx); | - |
2157 | #elif defined(__ARM_NEON__) | - |
2158 | BILINEAR_DOWNSCALE_BOUNDS_PROLOG | - |
2159 | | - |
2160 | const int16x8_t colorMask = vdupq_n_s16(0x00ff); | - |
2161 | const int16x8_t invColorMask = vmvnq_s16(colorMask); | - |
2162 | const int16x8_t v_256 = vdupq_n_s16(256); | - |
2163 | const int16x8_t v_disty = vdupq_n_s16(disty); | - |
2164 | const int16x8_t v_disty_ = vshlq_n_s16(v_disty, 4); | - |
2165 | int32x4_t v_fdx = vdupq_n_s32(fdx*4); | - |
2166 | | - |
2167 | ptrdiff_t secondLine = reinterpret_cast<const uint *>(s2) - reinterpret_cast<const uint *>(s1); | - |
2168 | | - |
2169 | union Vect_buffer { int32x4_t vect; quint32 i[4]; }; | - |
2170 | Vect_buffer v_fx; | - |
2171 | | - |
2172 | for (int i = 0; i < 4; i++) { | - |
2173 | v_fx.i[i] = fx; | - |
2174 | fx += fdx; | - |
2175 | } | - |
2176 | | - |
2177 | const int32x4_t v_ffff_mask = vdupq_n_s32(0x0000ffff); | - |
2178 | | - |
2179 | while (b < boundedEnd) { | - |
2180 | | - |
2181 | Vect_buffer tl, tr, bl, br; | - |
2182 | | - |
2183 | Vect_buffer v_fx_shifted; | - |
2184 | v_fx_shifted.vect = vshrq_n_s32(v_fx.vect, 16); | - |
2185 | | - |
2186 | int32x4_t v_distx = vshrq_n_s32(vandq_s32(v_fx.vect, v_ffff_mask), 12); | - |
2187 | | - |
2188 | for (int i = 0; i < 4; i++) { | - |
2189 | int x1 = v_fx_shifted.i[i]; | - |
2190 | const uint *addr_tl = reinterpret_cast<const uint *>(s1) + x1; | - |
2191 | const uint *addr_tr = addr_tl + 1; | - |
2192 | tl.i[i] = *addr_tl; | - |
2193 | tr.i[i] = *addr_tr; | - |
2194 | bl.i[i] = *(addr_tl+secondLine); | - |
2195 | br.i[i] = *(addr_tr+secondLine); | - |
2196 | } | - |
2197 | | - |
2198 | v_distx = vorrq_s32(v_distx, vshlq_n_s32(v_distx, 16)); | - |
2199 | | - |
2200 | interpolate_4_pixels_16_neon(vreinterpretq_s16_s32(tl.vect), vreinterpretq_s16_s32(tr.vect), vreinterpretq_s16_s32(bl.vect), vreinterpretq_s16_s32(br.vect), vreinterpretq_s16_s32(v_distx), v_disty, v_disty_, colorMask, invColorMask, v_256, b); | - |
2201 | b+=4; | - |
2202 | v_fx.vect = vaddq_s32(v_fx.vect, v_fdx); | - |
2203 | } | - |
2204 | fx = v_fx.i[0]; | - |
2205 | #endif | - |
2206 | } never executed: end of block | 0 |
2207 | | - |
2208 | while (b < end) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2209 | int x1 = (fx >> 16); | - |
2210 | int x2; | - |
2211 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2212 | uint tl = s1[x1]; | - |
2213 | uint tr = s1[x2]; | - |
2214 | uint bl = s2[x1]; | - |
2215 | uint br = s2[x2]; | - |
2216 | int distx = (fx & 0x0000ffff) >> 12; | - |
2217 | *b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); | - |
2218 | fx += fdx; | - |
2219 | ++b; | - |
2220 | } never executed: end of block | 0 |
2221 | } never executed: end of block | 0 |
2222 | } else { | - |
2223 | if (std::abs(data->m11) > 8 || std::abs(data->m22) > 8) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2224 | | - |
2225 | while (b < end) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2226 | int x1 = (fx >> 16); | - |
2227 | int x2; | - |
2228 | int y1 = (fy >> 16); | - |
2229 | int y2; | - |
2230 | | - |
2231 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2232 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2233 | | - |
2234 | const uint *s1 = (const uint *)data->texture.scanLine(y1); | - |
2235 | const uint *s2 = (const uint *)data->texture.scanLine(y2); | - |
2236 | | - |
2237 | uint tl = s1[x1]; | - |
2238 | uint tr = s1[x2]; | - |
2239 | uint bl = s2[x1]; | - |
2240 | uint br = s2[x2]; | - |
2241 | | - |
2242 | int distx = (fx & 0x0000ffff) >> 8; | - |
2243 | int disty = (fy & 0x0000ffff) >> 8; | - |
2244 | | - |
2245 | *b = interpolate_4_pixels(tl, tr, bl, br, distx, disty); | - |
2246 | | - |
2247 | fx += fdx; | - |
2248 | fy += fdy; | - |
2249 | ++b; | - |
2250 | } never executed: end of block | 0 |
2251 | } else { never executed: end of block | 0 |
2252 | | - |
2253 | | - |
2254 | if (blendType != BlendTransformedBilinearTiled) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2255 | #define BILINEAR_ROTATE_BOUNDS_PROLOG \ | - |
2256 | while (b < end) { \ | - |
2257 | int x1 = (fx >> 16); \ | - |
2258 | int x2; \ | - |
2259 | int y1 = (fy >> 16); \ | - |
2260 | int y2; \ | - |
2261 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); \ | - |
2262 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); \ | - |
2263 | if (x1 != x2 && y1 != y2) \ | - |
2264 | break; \ | - |
2265 | const uint *s1 = (const uint *)data->texture.scanLine(y1); \ | - |
2266 | const uint *s2 = (const uint *)data->texture.scanLine(y2); \ | - |
2267 | uint tl = s1[x1]; \ | - |
2268 | uint tr = s1[x2]; \ | - |
2269 | uint bl = s2[x1]; \ | - |
2270 | uint br = s2[x2]; \ | - |
2271 | int distx = (fx & 0x0000ffff) >> 8; \ | - |
2272 | int disty = (fy & 0x0000ffff) >> 8; \ | - |
2273 | *b = interpolate_4_pixels(tl, tr, bl, br, distx, disty); \ | - |
2274 | fx += fdx; \ | - |
2275 | fy += fdy; \ | - |
2276 | ++b; \ | - |
2277 | } \ | - |
2278 | uint *boundedEnd = end - 3; \ | - |
2279 | boundedEnd -= 3; | - |
2280 | | - |
2281 | #if defined(__SSE2__) | - |
2282 | BILINEAR_ROTATE_BOUNDS_PROLOG never executed: break; never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2283 | | - |
2284 | const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); | - |
2285 | const __m128i v_256 = _mm_set1_epi16(256); | - |
2286 | const __m128i v_fdx = _mm_set1_epi32(fdx*4); | - |
2287 | const __m128i v_fdy = _mm_set1_epi32(fdy*4); | - |
2288 | __m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx); | - |
2289 | __m128i v_fy = _mm_setr_epi32(fy, fy + fdy, fy + fdy + fdy, fy + fdy + fdy + fdy); | - |
2290 | | - |
2291 | const uchar *textureData = data->texture.imageData; | - |
2292 | const int bytesPerLine = data->texture.bytesPerLine; | - |
2293 | const __m128i vbpl = _mm_shufflelo_epi16(_mm_cvtsi32_si128(bytesPerLine/4), _MM_SHUFFLE(0, 0, 0, 0)); | - |
2294 | | - |
2295 | while (b < boundedEnd) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2296 | if (fdx > 0 && (short)_mm_extract_epi16(v_fx, 7) >= image_x2)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2297 | break; never executed: break; | 0 |
2298 | if (fdx < 0 && (short)_mm_extract_epi16(v_fx, 7) < image_x1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2299 | break; never executed: break; | 0 |
2300 | if (fdy > 0 && (short)_mm_extract_epi16(v_fy, 7) >= image_y2)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2301 | break; never executed: break; | 0 |
2302 | if (fdy < 0 && (short)_mm_extract_epi16(v_fy, 7) < image_y1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2303 | break; never executed: break; | 0 |
2304 | | - |
2305 | const __m128i vy = _mm_packs_epi32(_mm_srli_epi32(v_fy, 16), _mm_setzero_si128()); | - |
2306 | | - |
2307 | __m128i offset = _mm_unpacklo_epi16(_mm_mullo_epi16(vy, vbpl), _mm_mulhi_epi16(vy, vbpl)); | - |
2308 | offset = _mm_add_epi32(offset, _mm_srli_epi32(v_fx, 16)); | - |
2309 | const int offset0 = _mm_cvtsi128_si32(offset); offset = _mm_srli_si128(offset, 4); | - |
2310 | const int offset1 = _mm_cvtsi128_si32(offset); offset = _mm_srli_si128(offset, 4); | - |
2311 | const int offset2 = _mm_cvtsi128_si32(offset); offset = _mm_srli_si128(offset, 4); | - |
2312 | const int offset3 = _mm_cvtsi128_si32(offset); | - |
2313 | const uint *topData = (const uint *)(textureData); | - |
2314 | const __m128i tl = _mm_setr_epi32(topData[offset0], topData[offset1], topData[offset2], topData[offset3]); | - |
2315 | const __m128i tr = _mm_setr_epi32(topData[offset0 + 1], topData[offset1 + 1], topData[offset2 + 1], topData[offset3 + 1]); | - |
2316 | const uint *bottomData = (const uint *)(textureData + bytesPerLine); | - |
2317 | const __m128i bl = _mm_setr_epi32(bottomData[offset0], bottomData[offset1], bottomData[offset2], bottomData[offset3]); | - |
2318 | const __m128i br = _mm_setr_epi32(bottomData[offset0 + 1], bottomData[offset1 + 1], bottomData[offset2 + 1], bottomData[offset3 + 1]); | - |
2319 | | - |
2320 | __m128i v_distx = _mm_srli_epi16(v_fx, 12); | - |
2321 | __m128i v_disty = _mm_srli_epi16(v_fy, 12); | - |
2322 | v_distx = _mm_shufflehi_epi16(v_distx, _MM_SHUFFLE(2,2,0,0)); | - |
2323 | v_distx = _mm_shufflelo_epi16(v_distx, _MM_SHUFFLE(2,2,0,0)); | - |
2324 | v_disty = _mm_shufflehi_epi16(v_disty, _MM_SHUFFLE(2,2,0,0)); | - |
2325 | v_disty = _mm_shufflelo_epi16(v_disty, _MM_SHUFFLE(2,2,0,0)); | - |
2326 | | - |
2327 | interpolate_4_pixels_16_sse2(tl, tr, bl, br, v_distx, v_disty, colorMask, v_256, b); | - |
2328 | b += 4; | - |
2329 | v_fx = _mm_add_epi32(v_fx, v_fdx); | - |
2330 | v_fy = _mm_add_epi32(v_fy, v_fdy); | - |
2331 | } never executed: end of block | 0 |
2332 | fx = _mm_cvtsi128_si32(v_fx); | - |
2333 | fy = _mm_cvtsi128_si32(v_fy); | - |
2334 | #endif | - |
2335 | } never executed: end of block | 0 |
2336 | | - |
2337 | while (b < end) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2338 | int x1 = (fx >> 16); | - |
2339 | int x2; | - |
2340 | int y1 = (fy >> 16); | - |
2341 | int y2; | - |
2342 | | - |
2343 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2344 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2345 | | - |
2346 | const uint *s1 = (const uint *)data->texture.scanLine(y1); | - |
2347 | const uint *s2 = (const uint *)data->texture.scanLine(y2); | - |
2348 | | - |
2349 | uint tl = s1[x1]; | - |
2350 | uint tr = s1[x2]; | - |
2351 | uint bl = s2[x1]; | - |
2352 | uint br = s2[x2]; | - |
2353 | | - |
2354 | #if defined(__SSE2__) || defined(__ARM_NEON__) | - |
2355 | | - |
2356 | int distx = (fx & 0x0000ffff) >> 8; | - |
2357 | int disty = (fy & 0x0000ffff) >> 8; | - |
2358 | *b = interpolate_4_pixels(tl, tr, bl, br, distx, disty); | - |
2359 | #else | - |
2360 | int distx = (fx & 0x0000ffff) >> 12; | - |
2361 | int disty = (fy & 0x0000ffff) >> 12; | - |
2362 | *b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); | - |
2363 | #endif | - |
2364 | | - |
2365 | fx += fdx; | - |
2366 | fy += fdy; | - |
2367 | ++b; | - |
2368 | } never executed: end of block | 0 |
2369 | } never executed: end of block | 0 |
2370 | } | - |
2371 | } else { | - |
2372 | const qreal fdx = data->m11; | - |
2373 | const qreal fdy = data->m12; | - |
2374 | const qreal fdw = data->m13; | - |
2375 | | - |
2376 | qreal fx = data->m21 * cy + data->m11 * cx + data->dx; | - |
2377 | qreal fy = data->m22 * cy + data->m12 * cx + data->dy; | - |
2378 | qreal fw = data->m23 * cy + data->m13 * cx + data->m33; | - |
2379 | | - |
2380 | while (b < end) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2381 | const qreal iw = fw == 0 ? 1 : 1 / fw; | - |
2382 | const qreal px = fx * iw - qreal(0.5); | - |
2383 | const qreal py = fy * iw - qreal(0.5); | - |
2384 | | - |
2385 | int x1 = int(px) - (px < 0); | - |
2386 | int x2; | - |
2387 | int y1 = int(py) - (py < 0); | - |
2388 | int y2; | - |
2389 | | - |
2390 | int distx = int((px - x1) * 256); | - |
2391 | int disty = int((py - y1) * 256); | - |
2392 | | - |
2393 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2394 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2395 | | - |
2396 | const uint *s1 = (const uint *)data->texture.scanLine(y1); | - |
2397 | const uint *s2 = (const uint *)data->texture.scanLine(y2); | - |
2398 | | - |
2399 | uint tl = s1[x1]; | - |
2400 | uint tr = s1[x2]; | - |
2401 | uint bl = s2[x1]; | - |
2402 | uint br = s2[x2]; | - |
2403 | | - |
2404 | *b = interpolate_4_pixels(tl, tr, bl, br, distx, disty); | - |
2405 | | - |
2406 | fx += fdx; | - |
2407 | fy += fdy; | - |
2408 | fw += fdw; | - |
2409 | | - |
2410 | if (!fw) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2411 | fw += fdw; | - |
2412 | } never executed: end of block | 0 |
2413 | ++b; | - |
2414 | } never executed: end of block | 0 |
2415 | } never executed: end of block | 0 |
2416 | | - |
2417 | return buffer; never executed: return buffer; | 0 |
2418 | } | - |
2419 | | - |
2420 | | - |
2421 | template<TextureBlendType blendType> | - |
2422 | static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, | - |
2423 | const QSpanData *data, int y, int x, int length) | - |
2424 | { | - |
2425 | const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; | - |
2426 | const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; | - |
2427 | | - |
2428 | int image_width = data->texture.width; | - |
2429 | int image_height = data->texture.height; | - |
2430 | | - |
2431 | int image_x1 = data->texture.x1; | - |
2432 | int image_y1 = data->texture.y1; | - |
2433 | int image_x2 = data->texture.x2 - 1; | - |
2434 | int image_y2 = data->texture.y2 - 1; | - |
2435 | | - |
2436 | const qreal cx = x + qreal(0.5); | - |
2437 | const qreal cy = y + qreal(0.5); | - |
2438 | | - |
2439 | if (data->fast_matrix) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2440 | | - |
2441 | int fdx = (int)(data->m11 * fixed_scale); | - |
2442 | int fdy = (int)(data->m12 * fixed_scale); | - |
2443 | | - |
2444 | int fx = int((data->m21 * cy + data->m11 * cx + data->dx) * fixed_scale); | - |
2445 | int fy = int((data->m22 * cy + data->m12 * cx + data->dy) * fixed_scale); | - |
2446 | | - |
2447 | fx -= half_point; | - |
2448 | fy -= half_point; | - |
2449 | | - |
2450 | if (fdy == 0) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2451 | int y1 = (fy >> 16); | - |
2452 | int y2; | - |
2453 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2454 | const uchar *s1 = data->texture.scanLine(y1); | - |
2455 | const uchar *s2 = data->texture.scanLine(y2); | - |
2456 | | - |
2457 | if (fdx <= fixed_scale && fdx > 0) { TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2458 | int disty = (fy & 0x0000ffff) >> 8; | - |
2459 | int idisty = 256 - disty; | - |
2460 | int x = fx >> 16; | - |
2461 | | - |
2462 | | - |
2463 | | - |
2464 | FetchPixelsFunc fetch = qFetchPixels[layout->bpp]; | - |
2465 | | - |
2466 | uint buf1[buffer_size + 2]; | - |
2467 | uint buf2[buffer_size + 2]; | - |
2468 | const uint *ptr1; | - |
2469 | const uint *ptr2; | - |
2470 | | - |
2471 | int count = (qint64(length) * fdx + fixed_scale - 1) / fixed_scale + 2; | - |
2472 | Q_ASSERT(count <= buffer_size + 2); | - |
2473 | | - |
2474 | if (blendType == BlendTransformedBilinearTiled) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2475 | x %= image_width; | - |
2476 | if (x < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2477 | x += image_width; never executed: x += image_width; | 0 |
2478 | int len1 = qMin(count, image_width - x); | - |
2479 | int len2 = qMin(x, count - len1); | - |
2480 | | - |
2481 | ptr1 = fetch(buf1, s1, x, len1); | - |
2482 | ptr1 = layout->convertToARGB32PM(buf1, ptr1, len1, layout, clut); | - |
2483 | ptr2 = fetch(buf2, s2, x, len1); | - |
2484 | ptr2 = layout->convertToARGB32PM(buf2, ptr2, len1, layout, clut); | - |
2485 | for (int i = 0; i < len1; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2486 | uint t = ptr1[i]; | - |
2487 | uint b = ptr2[i]; | - |
2488 | buf1[i] = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; | - |
2489 | buf2[i] = ((((t >> 8) & 0xff00ff) * idisty + ((b >> 8) & 0xff00ff) * disty) >> 8) & 0xff00ff; | - |
2490 | } never executed: end of block | 0 |
2491 | | - |
2492 | if (len2) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2493 | ptr1 = fetch(buf1 + len1, s1, 0, len2); | - |
2494 | ptr1 = layout->convertToARGB32PM(buf1 + len1, ptr1, len2, layout, clut); | - |
2495 | ptr2 = fetch(buf2 + len1, s2, 0, len2); | - |
2496 | ptr2 = layout->convertToARGB32PM(buf2 + len1, ptr2, len2, layout, clut); | - |
2497 | for (int i = 0; i < len2; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2498 | uint t = ptr1[i]; | - |
2499 | uint b = ptr2[i]; | - |
2500 | buf1[i + len1] = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; | - |
2501 | buf2[i + len1] = ((((t >> 8) & 0xff00ff) * idisty + ((b >> 8) & 0xff00ff) * disty) >> 8) & 0xff00ff; | - |
2502 | } never executed: end of block | 0 |
2503 | } never executed: end of block | 0 |
2504 | for (int i = image_width; i < count; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2505 | buf1[i] = buf1[i - image_width]; | - |
2506 | buf2[i] = buf2[i - image_width]; | - |
2507 | } never executed: end of block | 0 |
2508 | } else { never executed: end of block | 0 |
2509 | int start = qMax(x, image_x1); | - |
2510 | int end = qMin(x + count, image_x2 + 1); | - |
2511 | int len = qMax(1, end - start); | - |
2512 | int leading = start - x; | - |
2513 | | - |
2514 | ptr1 = fetch(buf1 + leading, s1, start, len); | - |
2515 | ptr1 = layout->convertToARGB32PM(buf1 + leading, ptr1, len, layout, clut); | - |
2516 | ptr2 = fetch(buf2 + leading, s2, start, len); | - |
2517 | ptr2 = layout->convertToARGB32PM(buf2 + leading, ptr2, len, layout, clut); | - |
2518 | | - |
2519 | for (int i = 0; i < len; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2520 | uint t = ptr1[i]; | - |
2521 | uint b = ptr2[i]; | - |
2522 | buf1[i + leading] = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; | - |
2523 | buf2[i + leading] = ((((t >> 8) & 0xff00ff) * idisty + ((b >> 8) & 0xff00ff) * disty) >> 8) & 0xff00ff; | - |
2524 | } never executed: end of block | 0 |
2525 | | - |
2526 | for (int i = 0; i < leading; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2527 | buf1[i] = buf1[leading]; | - |
2528 | buf2[i] = buf2[leading]; | - |
2529 | } never executed: end of block | 0 |
2530 | for (int i = leading + len; i < count; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2531 | buf1[i] = buf1[i - 1]; | - |
2532 | buf2[i] = buf2[i - 1]; | - |
2533 | } never executed: end of block | 0 |
2534 | } never executed: end of block | 0 |
2535 | | - |
2536 | | - |
2537 | fx &= fixed_scale - 1; | - |
2538 | Q_ASSERT((fx >> 16) == 0); | - |
2539 | for (int i = 0; i < length; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2540 | int x1 = (fx >> 16); | - |
2541 | int x2 = x1 + 1; | - |
2542 | Q_ASSERT(x1 >= 0); | - |
2543 | Q_ASSERT(x2 < count); | - |
2544 | | - |
2545 | int distx = (fx & 0x0000ffff) >> 8; | - |
2546 | int idistx = 256 - distx; | - |
2547 | int rb = ((buf1[x1] * idistx + buf1[x2] * distx) >> 8) & 0xff00ff; | - |
2548 | int ag = (buf2[x1] * idistx + buf2[x2] * distx) & 0xff00ff00; | - |
2549 | buffer[i] = rb | ag; | - |
2550 | fx += fdx; | - |
2551 | } never executed: end of block | 0 |
2552 | } else { never executed: end of block | 0 |
2553 | FetchPixelFunc fetch = qFetchPixel[layout->bpp]; | - |
2554 | uint buf1[buffer_size]; | - |
2555 | uint buf2[buffer_size]; | - |
2556 | uint *b = buffer; | - |
2557 | while (length) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2558 | int len = qMin(length, buffer_size / 2); | - |
2559 | int fracX = fx; | - |
2560 | for (int i = 0; i < len; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2561 | int x1 = (fx >> 16); | - |
2562 | int x2; | - |
2563 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2564 | | - |
2565 | if (layout->bpp == QPixelLayout::BPP32) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2566 | buf1[i * 2 + 0] = ((const uint*)s1)[x1]; | - |
2567 | buf1[i * 2 + 1] = ((const uint*)s1)[x2]; | - |
2568 | buf2[i * 2 + 0] = ((const uint*)s2)[x1]; | - |
2569 | buf2[i * 2 + 1] = ((const uint*)s2)[x2]; | - |
2570 | } else { never executed: end of block | 0 |
2571 | buf1[i * 2 + 0] = fetch(s1, x1); | - |
2572 | buf1[i * 2 + 1] = fetch(s1, x2); | - |
2573 | buf2[i * 2 + 0] = fetch(s2, x1); | - |
2574 | buf2[i * 2 + 1] = fetch(s2, x2); | - |
2575 | } never executed: end of block | 0 |
2576 | | - |
2577 | fx += fdx; | - |
2578 | } never executed: end of block | 0 |
2579 | layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut); | - |
2580 | layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut); | - |
2581 | | - |
2582 | if ((fdx < 0 && fdx > -(fixed_scale / 8)) || std::abs(data->m22) < (1./8.)) { TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2583 | int disty = (fy & 0x0000ffff) >> 8; | - |
2584 | for (int i = 0; i < len; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2585 | uint tl = buf1[i * 2 + 0]; | - |
| uint tr = buf1[i * 2 + 1]; | |
| uint bl = buf2[i * 2 + 0]; | |
| uint br = buf2[i * 2 + 1];int distx = (fracX & 0x0000ffff) >> 8; | |
2586 | b[i] = interpolate_4_pixels(tl, tr, blbuf1 + i * 2, brbuf2 + i * 2, distx, disty); | - |
2587 | fracX += fdx; | - |
2588 | } never executed: end of block | 0 |
2589 | } else { never executed: end of block | 0 |
2590 | int disty = (fy & 0x0000ffff) >> 12; | - |
2591 | for (int i = 0; i < len; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2592 | uint tl = buf1[i * 2 + 0]; | - |
2593 | uint tr = buf1[i * 2 + 1]; | - |
2594 | uint bl = buf2[i * 2 + 0]; | - |
2595 | uint br = buf2[i * 2 + 1]; | - |
2596 | int distx = (fracX & 0x0000ffff) >> 12; | - |
2597 | b[i] = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); | - |
2598 | fracX += fdx; | - |
2599 | } never executed: end of block | 0 |
2600 | } never executed: end of block | 0 |
2601 | length -= len; | - |
2602 | b += len; | - |
2603 | } never executed: end of block | 0 |
2604 | } never executed: end of block | 0 |
2605 | } else { | - |
2606 | FetchPixelFunc fetch = qFetchPixel[layout->bpp]; | - |
2607 | uint buf1[buffer_size]; | - |
2608 | uint buf2[buffer_size]; | - |
2609 | uint *b = buffer; | - |
2610 | | - |
2611 | while (length) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2612 | int len = qMin(length, buffer_size / 2); | - |
2613 | int fracX = fx; | - |
2614 | int fracY = fy; | - |
2615 | for (int i = 0; i < len; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2616 | int x1 = (fx >> 16); | - |
2617 | int x2; | - |
2618 | int y1 = (fy >> 16); | - |
2619 | int y2; | - |
2620 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2621 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2622 | | - |
2623 | const uchar *s1 = data->texture.scanLine(y1); | - |
2624 | const uchar *s2 = data->texture.scanLine(y2); | - |
2625 | | - |
2626 | if (layout->bpp == QPixelLayout::BPP32) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2627 | buf1[i * 2 + 0] = ((const uint*)s1)[x1]; | - |
2628 | buf1[i * 2 + 1] = ((const uint*)s1)[x2]; | - |
2629 | buf2[i * 2 + 0] = ((const uint*)s2)[x1]; | - |
2630 | buf2[i * 2 + 1] = ((const uint*)s2)[x2]; | - |
2631 | } else { never executed: end of block | 0 |
2632 | buf1[i * 2 + 0] = fetch(s1, x1); | - |
2633 | buf1[i * 2 + 1] = fetch(s1, x2); | - |
2634 | buf2[i * 2 + 0] = fetch(s2, x1); | - |
2635 | buf2[i * 2 + 1] = fetch(s2, x2); | - |
2636 | } never executed: end of block | 0 |
2637 | | - |
2638 | fx += fdx; | - |
2639 | fy += fdy; | - |
2640 | } never executed: end of block | 0 |
2641 | layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut); | - |
2642 | layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut); | - |
2643 | | - |
2644 | if (std::abs(data->m11) > 8 || std::abs(data->m22) > 8) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2645 | | - |
2646 | for (int i = 0; i < len; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2647 | uint tl = buf1[i * 2 + 0]; | - |
| uint tr = buf1[i * 2 + 1]; | |
| uint bl = buf2[i * 2 + 0]; | |
| uint br = buf2[i * 2 + 1];int distx = (fracX & 0x0000ffff) >> 8; | |
2648 | int disty = (fracY & 0x0000ffff) >> 8; | - |
2649 | | - |
2650 | b[i] = interpolate_4_pixels(tl, tr, blbuf1 + i * 2, brbuf2 + i * 2, distx, disty); | - |
2651 | fracX += fdx; | - |
2652 | fracY += fdy; | - |
2653 | } never executed: end of block | 0 |
2654 | } else { never executed: end of block | 0 |
2655 | | - |
2656 | for (int i = 0; i < len; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2657 | uint tl = buf1[i * 2 + 0]; | - |
2658 | uint tr = buf1[i * 2 + 1]; | - |
2659 | uint bl = buf2[i * 2 + 0]; | - |
2660 | uint br = buf2[i * 2 + 1]; | - |
2661 | | - |
2662 | int distx = (fracX & 0x0000ffff) >> 12; | - |
2663 | int disty = (fracY & 0x0000ffff) >> 12; | - |
2664 | | - |
2665 | b[i] = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); | - |
2666 | fracX += fdx; | - |
2667 | fracY += fdy; | - |
2668 | } never executed: end of block | 0 |
2669 | } never executed: end of block | 0 |
2670 | | - |
2671 | length -= len; | - |
2672 | b += len; | - |
2673 | } never executed: end of block | 0 |
2674 | } never executed: end of block | 0 |
2675 | } else { | - |
2676 | const qreal fdx = data->m11; | - |
2677 | const qreal fdy = data->m12; | - |
2678 | const qreal fdw = data->m13; | - |
2679 | | - |
2680 | qreal fx = data->m21 * cy + data->m11 * cx + data->dx; | - |
2681 | qreal fy = data->m22 * cy + data->m12 * cx + data->dy; | - |
2682 | qreal fw = data->m23 * cy + data->m13 * cx + data->m33; | - |
2683 | | - |
2684 | FetchPixelFunc fetch = qFetchPixel[layout->bpp]; | - |
2685 | uint buf1[buffer_size]; | - |
2686 | uint buf2[buffer_size]; | - |
2687 | uint *b = buffer; | - |
2688 | | - |
2689 | int distxs[buffer_size / 2]; | - |
2690 | int distys[buffer_size / 2]; | - |
2691 | | - |
2692 | while (length) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2693 | int len = qMin(length, buffer_size / 2); | - |
2694 | for (int i = 0; i < len; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2695 | const qreal iw = fw == 0 ? 1 : 1 / fw; | - |
2696 | const qreal px = fx * iw - qreal(0.5); | - |
2697 | const qreal py = fy * iw - qreal(0.5); | - |
2698 | | - |
2699 | int x1 = int(px) - (px < 0); | - |
2700 | int x2; | - |
2701 | int y1 = int(py) - (py < 0); | - |
2702 | int y2; | - |
2703 | | - |
2704 | distxs[i] = int((px - x1) * 256); | - |
2705 | distys[i] = int((py - y1) * 256); | - |
2706 | | - |
2707 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2708 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2709 | | - |
2710 | const uchar *s1 = data->texture.scanLine(y1); | - |
2711 | const uchar *s2 = data->texture.scanLine(y2); | - |
2712 | | - |
2713 | if (layout->bpp == QPixelLayout::BPP32) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2714 | buf1[i * 2 + 0] = ((const uint*)s1)[x1]; | - |
2715 | buf1[i * 2 + 1] = ((const uint*)s1)[x2]; | - |
2716 | buf2[i * 2 + 0] = ((const uint*)s2)[x1]; | - |
2717 | buf2[i * 2 + 1] = ((const uint*)s2)[x2]; | - |
2718 | } else { never executed: end of block | 0 |
2719 | buf1[i * 2 + 0] = fetch(s1, x1); | - |
2720 | buf1[i * 2 + 1] = fetch(s1, x2); | - |
2721 | buf2[i * 2 + 0] = fetch(s2, x1); | - |
2722 | buf2[i * 2 + 1] = fetch(s2, x2); | - |
2723 | } never executed: end of block | 0 |
2724 | | - |
2725 | fx += fdx; | - |
2726 | fy += fdy; | - |
2727 | fw += fdw; | - |
2728 | | - |
2729 | if (!fw)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2730 | fw += fdw; never executed: fw += fdw; | 0 |
2731 | } never executed: end of block | 0 |
2732 | | - |
2733 | layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut); | - |
2734 | layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut); | - |
2735 | | - |
2736 | for (int i = 0; i < len; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2737 | int distx = distxs[i]; | - |
2738 | int disty = distys[i]; | - |
2739 | | - |
2740 | uint tl = buf1b[i* 2 + 0]; | - |
| uint tr] = interpolate_4_pixels(buf1 [i * 2+ 1]; | |
| uint bl = buf2[i * 2+ 0]; | |
| uint br =, buf2 [+ i * 2+ 1]; | |
| | |
| b[i] = interpolate_4_pixels(tl, tr, bl, br, distx, disty); | |
2741 | } never executed: end of block | 0 |
2742 | length -= len; | - |
2743 | b += len; | - |
2744 | } never executed: end of block | 0 |
2745 | } never executed: end of block | 0 |
2746 | | - |
2747 | return buffer; never executed: return buffer; | 0 |
2748 | } | - |
2749 | | - |
2750 | template<TextureBlendType blendType> | - |
2751 | static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, const Operator *, | - |
2752 | const QSpanData *data, int y, int x, int length) | - |
2753 | { | - |
2754 | const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; | - |
2755 | const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; | - |
2756 | | - |
2757 | int image_width = data->texture.width; | - |
2758 | int image_height = data->texture.height; | - |
2759 | | - |
2760 | int image_x1 = data->texture.x1; | - |
2761 | int image_y1 = data->texture.y1; | - |
2762 | int image_x2 = data->texture.x2 - 1; | - |
2763 | int image_y2 = data->texture.y2 - 1; | - |
2764 | | - |
2765 | const qreal cx = x + qreal(0.5); | - |
2766 | const qreal cy = y + qreal(0.5); | - |
2767 | | - |
2768 | const qreal fdx = data->m11; | - |
2769 | const qreal fdy = data->m12; | - |
2770 | const qreal fdw = data->m13; | - |
2771 | | - |
2772 | if (data->fast_matrix) { | - |
2773 | | - |
2774 | int fdx = (int)(data->m11 * fixed_scale); | - |
2775 | int fdy = (int)(data->m12 * fixed_scale); | - |
2776 | | - |
2777 | int fx = int((data->m21 * cy + data->m11 * cx + data->dx) * fixed_scale); | - |
2778 | int fy = int((data->m22 * cy + data->m12 * cx + data->dy) * fixed_scale); | - |
2779 | | - |
2780 | fx -= half_point; | - |
2781 | fy -= half_point; | - |
2782 | | - |
2783 | if (fdy == 0) { | - |
2784 | int y1 = (fy >> 16); | - |
2785 | int y2; | - |
2786 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2787 | const uchar *s1 = data->texture.scanLine(y1); | - |
2788 | const uchar *s2 = data->texture.scanLine(y2); | - |
2789 | | - |
2790 | FetchPixelFunc fetch = qFetchPixel[layout->bpp]; | - |
2791 | uint sbuf1[buffer_size]; | - |
2792 | uint sbuf2[buffer_size]; | - |
2793 | QRgba64 buf1[buffer_size]; | - |
2794 | QRgba64 buf2[buffer_size]; | - |
2795 | QRgba64 *b = buffer; | - |
2796 | while (length) { | - |
2797 | int len = qMin(length, buffer_size / 2); | - |
2798 | int fracX = fx; | - |
2799 | int i = 0; | - |
2800 | int disty = (fy & 0x0000ffff); | - |
2801 | #if defined(__SSE2__) | - |
2802 | const __m128i vdy = _mm_set1_epi16(disty); | - |
2803 | const __m128i vidy = _mm_set1_epi16(0x10000 - disty); | - |
2804 | if (blendType != BlendTransformedBilinearTiled && layout->bpp == QPixelLayout::BPP32) { | - |
2805 | for (; i < len; ++i) { | - |
2806 | int x1 = (fx >> 16); | - |
2807 | int x2; | - |
2808 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2809 | if (x1 != x2) | - |
2810 | break; | - |
2811 | sbuf1[i * 2 + 0] = ((const uint*)s1)[x1]; | - |
2812 | sbuf1[i * 2 + 1] = ((const uint*)s1)[x2]; | - |
2813 | sbuf2[i * 2 + 0] = ((const uint*)s2)[x1]; | - |
2814 | sbuf2[i * 2 + 1] = ((const uint*)s2)[x2]; | - |
2815 | fx += fdx; | - |
2816 | } | - |
2817 | int fastLen; | - |
2818 | if (fdx > 0) | - |
2819 | fastLen = qMin(len, int((image_x2 - (fx >> 16)) / data->m11)); | - |
2820 | else | - |
2821 | fastLen = qMin(len, int((image_x1 - (fx >> 16)) / data->m11)); | - |
2822 | fastLen -= 3; | - |
2823 | | - |
2824 | const __m128i v_fdx = _mm_set1_epi32(fdx*4); | - |
2825 | __m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx); | - |
2826 | for (; i < fastLen; i += 4) { | - |
2827 | int offset = _mm_extract_epi16(v_fx, 1); | - |
2828 | sbuf1[i * 2 + 0] = ((const uint*)s1)[offset]; | - |
2829 | sbuf1[i * 2 + 1] = ((const uint*)s1)[offset + 1]; | - |
2830 | sbuf2[i * 2 + 0] = ((const uint*)s2)[offset]; | - |
2831 | sbuf2[i * 2 + 1] = ((const uint*)s2)[offset + 1]; | - |
2832 | offset = _mm_extract_epi16(v_fx, 3); | - |
2833 | sbuf1[i * 2 + 2] = ((const uint*)s1)[offset]; | - |
2834 | sbuf1[i * 2 + 3] = ((const uint*)s1)[offset + 1]; | - |
2835 | sbuf2[i * 2 + 2] = ((const uint*)s2)[offset]; | - |
2836 | sbuf2[i * 2 + 3] = ((const uint*)s2)[offset + 1]; | - |
2837 | offset = _mm_extract_epi16(v_fx, 5); | - |
2838 | sbuf1[i * 2 + 4] = ((const uint*)s1)[offset]; | - |
2839 | sbuf1[i * 2 + 5] = ((const uint*)s1)[offset + 1]; | - |
2840 | sbuf2[i * 2 + 4] = ((const uint*)s2)[offset]; | - |
2841 | sbuf2[i * 2 + 5] = ((const uint*)s2)[offset + 1]; | - |
2842 | offset = _mm_extract_epi16(v_fx, 7); | - |
2843 | sbuf1[i * 2 + 6] = ((const uint*)s1)[offset]; | - |
2844 | sbuf1[i * 2 + 7] = ((const uint*)s1)[offset + 1]; | - |
2845 | sbuf2[i * 2 + 6] = ((const uint*)s2)[offset]; | - |
2846 | sbuf2[i * 2 + 7] = ((const uint*)s2)[offset + 1]; | - |
2847 | v_fx = _mm_add_epi32(v_fx, v_fdx); | - |
2848 | } | - |
2849 | fx = _mm_cvtsi128_si32(v_fx); | - |
2850 | } | - |
2851 | #endif | - |
2852 | for (; i < len; ++i) { | - |
2853 | int x1 = (fx >> 16); | - |
2854 | int x2; | - |
2855 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2856 | | - |
2857 | if (layout->bpp == QPixelLayout::BPP32) { | - |
2858 | sbuf1[i * 2 + 0] = ((const uint*)s1)[x1]; | - |
2859 | sbuf1[i * 2 + 1] = ((const uint*)s1)[x2]; | - |
2860 | sbuf2[i * 2 + 0] = ((const uint*)s2)[x1]; | - |
2861 | sbuf2[i * 2 + 1] = ((const uint*)s2)[x2]; | - |
2862 | | - |
2863 | } else { | - |
2864 | sbuf1[i * 2 + 0] = fetch(s1, x1); | - |
2865 | sbuf1[i * 2 + 1] = fetch(s1, x2); | - |
2866 | sbuf2[i * 2 + 0] = fetch(s2, x1); | - |
2867 | sbuf2[i * 2 + 1] = fetch(s2, x2); | - |
2868 | } | - |
2869 | | - |
2870 | fx += fdx; | - |
2871 | } | - |
2872 | layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut); | - |
2873 | if (disty) | - |
2874 | layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut); | - |
2875 | | - |
2876 | for (int i = 0; i < len; ++i) { | - |
2877 | int distx = (fracX & 0x0000ffff); | - |
2878 | #if defined(__SSE2__) | - |
2879 | const __m128i vdistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(distx), _MM_SHUFFLE(0, 0, 0, 0)); | - |
2880 | const __m128i vidistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(0x10000 - distx), _MM_SHUFFLE(0, 0, 0, 0)); | - |
2881 | __m128i vt = _mm_loadu_si128((const __m128i*)(buf1 + i*2)); | - |
2882 | if (disty) { | - |
2883 | __m128i vb = _mm_loadu_si128((const __m128i*)(buf2 + i*2)); | - |
2884 | vt = _mm_mulhi_epu16(vt, vidy); | - |
2885 | vb = _mm_mulhi_epu16(vb, vdy); | - |
2886 | vt = _mm_add_epi16(vt, vb); | - |
2887 | } | - |
2888 | vt = _mm_mulhi_epu16(vt, _mm_unpacklo_epi64(vidistx, vdistx)); | - |
2889 | vt = _mm_add_epi16(vt, _mm_srli_si128(vt, 8)); | - |
2890 | _mm_storel_epi64((__m128i*)(b+i), vt); | - |
2891 | #else | - |
2892 | b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); | - |
2893 | #endif | - |
2894 | fracX += fdx; | - |
2895 | } | - |
2896 | length -= len; | - |
2897 | b += len; | - |
2898 | } | - |
2899 | } else { | - |
2900 | FetchPixelFunc fetch = qFetchPixel[layout->bpp]; | - |
2901 | uint sbuf1[buffer_size]; | - |
2902 | uint sbuf2[buffer_size]; | - |
2903 | QRgba64 buf1[buffer_size]; | - |
2904 | QRgba64 buf2[buffer_size]; | - |
2905 | QRgba64 *end = buffer + length; | - |
2906 | QRgba64 *b = buffer; | - |
2907 | | - |
2908 | while (b < end) { | - |
2909 | int len = qMin(length, buffer_size / 2); | - |
2910 | int fracX = fx; | - |
2911 | int fracY = fy; | - |
2912 | int i = 0; | - |
2913 | #if defined(__SSE2__) | - |
2914 | if (blendType != BlendTransformedBilinearTiled && layout->bpp == QPixelLayout::BPP32) { | - |
2915 | for (; i < len; ++i) { | - |
2916 | int x1 = (fx >> 16); | - |
2917 | int x2; | - |
2918 | int y1 = (fy >> 16); | - |
2919 | int y2; | - |
2920 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2921 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2922 | if (x1 != x2 && y1 != y2) | - |
2923 | break; | - |
2924 | const uchar *s1 = data->texture.scanLine(y1); | - |
2925 | const uchar *s2 = data->texture.scanLine(y2); | - |
2926 | sbuf1[i * 2 + 0] = ((const uint*)s1)[x1]; | - |
2927 | sbuf1[i * 2 + 1] = ((const uint*)s1)[x2]; | - |
2928 | sbuf2[i * 2 + 0] = ((const uint*)s2)[x1]; | - |
2929 | sbuf2[i * 2 + 1] = ((const uint*)s2)[x2]; | - |
2930 | fx += fdx; | - |
2931 | fy += fdy; | - |
2932 | } | - |
2933 | | - |
2934 | const __m128i v_fdx = _mm_set1_epi32(fdx*4); | - |
2935 | const __m128i v_fdy = _mm_set1_epi32(fdy*4); | - |
2936 | __m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx); | - |
2937 | __m128i v_fy = _mm_setr_epi32(fy, fy + fdy, fy + fdy + fdy, fy + fdy + fdy + fdy); | - |
2938 | const int bytesPerLine = data->texture.bytesPerLine; | - |
2939 | const uchar *s1 = data->texture.imageData; | - |
2940 | const uchar *s2 = s1 + bytesPerLine; | - |
2941 | const __m128i vbpl = _mm_shufflelo_epi16(_mm_cvtsi32_si128(bytesPerLine/4), _MM_SHUFFLE(0, 0, 0, 0)); | - |
2942 | for (; i < len-3; i+=4) { | - |
2943 | if (fdx > 0 && (short)_mm_extract_epi16(v_fx, 7) >= image_x2) | - |
2944 | break; | - |
2945 | if (fdx < 0 && (short)_mm_extract_epi16(v_fx, 7) < image_x1) | - |
2946 | break; | - |
2947 | if (fdy > 0 && (short)_mm_extract_epi16(v_fy, 7) >= image_y2) | - |
2948 | break; | - |
2949 | if (fdy < 0 && (short)_mm_extract_epi16(v_fy, 7) < image_y1) | - |
2950 | break; | - |
2951 | const __m128i vy = _mm_packs_epi32(_mm_srai_epi32(v_fy, 16), _mm_setzero_si128()); | - |
2952 | __m128i voffset = _mm_unpacklo_epi16(_mm_mullo_epi16(vy, vbpl), _mm_mulhi_epu16(vy, vbpl)); | - |
2953 | voffset = _mm_add_epi32(voffset, _mm_srli_epi32(v_fx, 16)); | - |
2954 | | - |
2955 | int offset = _mm_cvtsi128_si32(voffset); voffset = _mm_srli_si128(voffset, 4); | - |
2956 | sbuf1[i * 2 + 0] = ((const uint*)s1)[offset]; | - |
2957 | sbuf1[i * 2 + 1] = ((const uint*)s1)[offset + 1]; | - |
2958 | sbuf2[i * 2 + 0] = ((const uint*)s2)[offset]; | - |
2959 | sbuf2[i * 2 + 1] = ((const uint*)s2)[offset + 1]; | - |
2960 | offset = _mm_cvtsi128_si32(voffset); voffset = _mm_srli_si128(voffset, 4); | - |
2961 | sbuf1[i * 2 + 2] = ((const uint*)s1)[offset]; | - |
2962 | sbuf1[i * 2 + 3] = ((const uint*)s1)[offset + 1]; | - |
2963 | sbuf2[i * 2 + 2] = ((const uint*)s2)[offset]; | - |
2964 | sbuf2[i * 2 + 3] = ((const uint*)s2)[offset + 1]; | - |
2965 | offset = _mm_cvtsi128_si32(voffset); voffset = _mm_srli_si128(voffset, 4); | - |
2966 | sbuf1[i * 2 + 4] = ((const uint*)s1)[offset]; | - |
2967 | sbuf1[i * 2 + 5] = ((const uint*)s1)[offset + 1]; | - |
2968 | sbuf2[i * 2 + 4] = ((const uint*)s2)[offset]; | - |
2969 | sbuf2[i * 2 + 5] = ((const uint*)s2)[offset + 1]; | - |
2970 | offset = _mm_cvtsi128_si32(voffset); | - |
2971 | sbuf1[i * 2 + 6] = ((const uint*)s1)[offset]; | - |
2972 | sbuf1[i * 2 + 7] = ((const uint*)s1)[offset + 1]; | - |
2973 | sbuf2[i * 2 + 6] = ((const uint*)s2)[offset]; | - |
2974 | sbuf2[i * 2 + 7] = ((const uint*)s2)[offset + 1]; | - |
2975 | | - |
2976 | v_fx = _mm_add_epi32(v_fx, v_fdx); | - |
2977 | v_fy = _mm_add_epi32(v_fy, v_fdy); | - |
2978 | } | - |
2979 | fx = _mm_cvtsi128_si32(v_fx); | - |
2980 | fy = _mm_cvtsi128_si32(v_fy); | - |
2981 | } | - |
2982 | #endif | - |
2983 | for (; i < len; ++i) { | - |
2984 | int x1 = (fx >> 16); | - |
2985 | int x2; | - |
2986 | int y1 = (fy >> 16); | - |
2987 | int y2; | - |
2988 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
2989 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
2990 | | - |
2991 | const uchar *s1 = data->texture.scanLine(y1); | - |
2992 | const uchar *s2 = data->texture.scanLine(y2); | - |
2993 | | - |
2994 | if (layout->bpp == QPixelLayout::BPP32) { | - |
2995 | sbuf1[i * 2 + 0] = ((const uint*)s1)[x1]; | - |
2996 | sbuf1[i * 2 + 1] = ((const uint*)s1)[x2]; | - |
2997 | sbuf2[i * 2 + 0] = ((const uint*)s2)[x1]; | - |
2998 | sbuf2[i * 2 + 1] = ((const uint*)s2)[x2]; | - |
2999 | | - |
3000 | } else { | - |
3001 | sbuf1[i * 2 + 0] = fetch(s1, x1); | - |
3002 | sbuf1[i * 2 + 1] = fetch(s1, x2); | - |
3003 | sbuf2[i * 2 + 0] = fetch(s2, x1); | - |
3004 | sbuf2[i * 2 + 1] = fetch(s2, x2); | - |
3005 | } | - |
3006 | | - |
3007 | fx += fdx; | - |
3008 | fy += fdy; | - |
3009 | } | - |
3010 | layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut); | - |
3011 | layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut); | - |
3012 | | - |
3013 | for (int i = 0; i < len; ++i) { | - |
3014 | int distx = (fracX & 0x0000ffff); | - |
3015 | int disty = (fracY & 0x0000ffff); | - |
3016 | b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); | - |
3017 | fracX += fdx; | - |
3018 | fracY += fdy; | - |
3019 | } | - |
3020 | | - |
3021 | length -= len; | - |
3022 | b += len; | - |
3023 | } | - |
3024 | } | - |
3025 | } else { | - |
3026 | qreal fx = data->m21 * cy + data->m11 * cx + data->dx; | - |
3027 | qreal fy = data->m22 * cy + data->m12 * cx + data->dy; | - |
3028 | qreal fw = data->m23 * cy + data->m13 * cx + data->m33; | - |
3029 | | - |
3030 | FetchPixelFunc fetch = qFetchPixel[layout->bpp]; | - |
3031 | uint sbuf1[buffer_size]; | - |
3032 | uint sbuf2[buffer_size]; | - |
3033 | QRgba64 buf1[buffer_size]; | - |
3034 | QRgba64 buf2[buffer_size]; | - |
3035 | QRgba64 *b = buffer; | - |
3036 | | - |
3037 | int distxs[buffer_size / 2]; | - |
3038 | int distys[buffer_size / 2]; | - |
3039 | | - |
3040 | while (length) { | - |
3041 | int len = qMin(length, buffer_size / 2); | - |
3042 | for (int i = 0; i < len; ++i) { | - |
3043 | const qreal iw = fw == 0 ? 1 : 1 / fw; | - |
3044 | const qreal px = fx * iw - qreal(0.5); | - |
3045 | const qreal py = fy * iw - qreal(0.5); | - |
3046 | | - |
3047 | int x1 = int(px) - (px < 0); | - |
3048 | int x2; | - |
3049 | int y1 = int(py) - (py < 0); | - |
3050 | int y2; | - |
3051 | | - |
3052 | distxs[i] = int((px - x1) * (1<<16)); | - |
3053 | distys[i] = int((py - y1) * (1<<16)); | - |
3054 | | - |
3055 | fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); | - |
3056 | fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); | - |
3057 | | - |
3058 | const uchar *s1 = data->texture.scanLine(y1); | - |
3059 | const uchar *s2 = data->texture.scanLine(y2); | - |
3060 | | - |
3061 | if (layout->bpp == QPixelLayout::BPP32) { | - |
3062 | sbuf1[i * 2 + 0] = ((const uint*)s1)[x1]; | - |
3063 | sbuf1[i * 2 + 1] = ((const uint*)s1)[x2]; | - |
3064 | sbuf2[i * 2 + 0] = ((const uint*)s2)[x1]; | - |
3065 | sbuf2[i * 2 + 1] = ((const uint*)s2)[x2]; | - |
3066 | | - |
3067 | } else { | - |
3068 | sbuf1[i * 2 + 0] = fetch(s1, x1); | - |
3069 | sbuf1[i * 2 + 1] = fetch(s1, x2); | - |
3070 | sbuf2[i * 2 + 0] = fetch(s2, x1); | - |
3071 | sbuf2[i * 2 + 1] = fetch(s2, x2); | - |
3072 | } | - |
3073 | | - |
3074 | fx += fdx; | - |
3075 | fy += fdy; | - |
3076 | fw += fdw; | - |
3077 | | - |
3078 | if (!fw) | - |
3079 | fw += fdw; | - |
3080 | } | - |
3081 | | - |
3082 | layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut); | - |
3083 | layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut); | - |
3084 | | - |
3085 | for (int i = 0; i < len; ++i) { | - |
3086 | int distx = distxs[i]; | - |
3087 | int disty = distys[i]; | - |
3088 | b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); | - |
3089 | } | - |
3090 | | - |
3091 | length -= len; | - |
3092 | b += len; | - |
3093 | } | - |
3094 | } | - |
3095 | | - |
3096 | return buffer; | - |
3097 | } | - |
3098 | | - |
3099 | static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { | - |
3100 | | - |
3101 | { | - |
3102 | 0, | - |
3103 | fetchUntransformed, | - |
3104 | fetchUntransformed, | - |
3105 | fetchUntransformed, | - |
3106 | fetchUntransformedARGB32PM, | - |
3107 | fetchUntransformed, | - |
3108 | fetchUntransformedARGB32PM, | - |
3109 | fetchUntransformedRGB16, | - |
3110 | fetchUntransformed, | - |
3111 | fetchUntransformed, | - |
3112 | fetchUntransformed, | - |
3113 | fetchUntransformed, | - |
3114 | fetchUntransformed, | - |
3115 | fetchUntransformed, | - |
3116 | fetchUntransformed, | - |
3117 | fetchUntransformed, | - |
3118 | fetchUntransformed, | - |
3119 | fetchUntransformed, | - |
3120 | fetchUntransformed, | - |
3121 | fetchUntransformed, | - |
3122 | fetchUntransformed, | - |
3123 | fetchUntransformed, | - |
3124 | fetchUntransformed, | - |
3125 | fetchUntransformed, | - |
3126 | fetchUntransformed, | - |
3127 | }, | - |
3128 | | - |
3129 | { | - |
3130 | 0, | - |
3131 | fetchUntransformed, | - |
3132 | fetchUntransformed, | - |
3133 | fetchUntransformed, | - |
3134 | fetchUntransformedARGB32PM, | - |
3135 | fetchUntransformed, | - |
3136 | fetchUntransformedARGB32PM, | - |
3137 | fetchUntransformedRGB16, | - |
3138 | fetchUntransformed, | - |
3139 | fetchUntransformed, | - |
3140 | fetchUntransformed, | - |
3141 | fetchUntransformed, | - |
3142 | fetchUntransformed, | - |
3143 | fetchUntransformed, | - |
3144 | fetchUntransformed, | - |
3145 | fetchUntransformed, | - |
3146 | fetchUntransformed, | - |
3147 | fetchUntransformed, | - |
3148 | fetchUntransformed, | - |
3149 | fetchUntransformed, | - |
3150 | fetchUntransformed, | - |
3151 | fetchUntransformed, | - |
3152 | fetchUntransformed, | - |
3153 | fetchUntransformed, | - |
3154 | fetchUntransformed, | - |
3155 | }, | - |
3156 | | - |
3157 | { | - |
3158 | 0, | - |
3159 | fetchTransformed<BlendTransformed>, | - |
3160 | fetchTransformed<BlendTransformed>, | - |
3161 | fetchTransformed<BlendTransformed>, | - |
3162 | fetchTransformedARGB32PM<BlendTransformed>, | - |
3163 | fetchTransformed<BlendTransformed>, | - |
3164 | fetchTransformedARGB32PM<BlendTransformed>, | - |
3165 | fetchTransformed<BlendTransformed>, | - |
3166 | fetchTransformed<BlendTransformed>, | - |
3167 | fetchTransformed<BlendTransformed>, | - |
3168 | fetchTransformed<BlendTransformed>, | - |
3169 | fetchTransformed<BlendTransformed>, | - |
3170 | fetchTransformed<BlendTransformed>, | - |
3171 | fetchTransformed<BlendTransformed>, | - |
3172 | fetchTransformed<BlendTransformed>, | - |
3173 | fetchTransformed<BlendTransformed>, | - |
3174 | fetchTransformed<BlendTransformed>, | - |
3175 | fetchTransformed<BlendTransformed>, | - |
3176 | fetchTransformed<BlendTransformed>, | - |
3177 | fetchTransformed<BlendTransformed>, | - |
3178 | fetchTransformed<BlendTransformed>, | - |
3179 | fetchTransformed<BlendTransformed>, | - |
3180 | fetchTransformed<BlendTransformed>, | - |
3181 | fetchTransformed<BlendTransformed>, | - |
3182 | fetchTransformed<BlendTransformed>, | - |
3183 | }, | - |
3184 | { | - |
3185 | 0, | - |
3186 | fetchTransformed<BlendTransformedTiled>, | - |
3187 | fetchTransformed<BlendTransformedTiled>, | - |
3188 | fetchTransformed<BlendTransformedTiled>, | - |
3189 | fetchTransformedARGB32PM<BlendTransformedTiled>, | - |
3190 | fetchTransformed<BlendTransformedTiled>, | - |
3191 | fetchTransformedARGB32PM<BlendTransformedTiled>, | - |
3192 | fetchTransformed<BlendTransformedTiled>, | - |
3193 | fetchTransformed<BlendTransformedTiled>, | - |
3194 | fetchTransformed<BlendTransformedTiled>, | - |
3195 | fetchTransformed<BlendTransformedTiled>, | - |
3196 | fetchTransformed<BlendTransformedTiled>, | - |
3197 | fetchTransformed<BlendTransformedTiled>, | - |
3198 | fetchTransformed<BlendTransformedTiled>, | - |
3199 | fetchTransformed<BlendTransformedTiled>, | - |
3200 | fetchTransformed<BlendTransformedTiled>, | - |
3201 | fetchTransformed<BlendTransformedTiled>, | - |
3202 | fetchTransformed<BlendTransformedTiled>, | - |
3203 | fetchTransformed<BlendTransformedTiled>, | - |
3204 | fetchTransformed<BlendTransformedTiled>, | - |
3205 | fetchTransformed<BlendTransformedTiled>, | - |
3206 | fetchTransformed<BlendTransformedTiled>, | - |
3207 | fetchTransformed<BlendTransformedTiled>, | - |
3208 | fetchTransformed<BlendTransformedTiled>, | - |
3209 | fetchTransformed<BlendTransformedTiled>, | - |
3210 | }, | - |
3211 | { | - |
3212 | 0, | - |
3213 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3214 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3215 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3216 | fetchTransformedBilinearARGB32PM<BlendTransformedBilinear>, | - |
3217 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3218 | fetchTransformedBilinearARGB32PM<BlendTransformedBilinear>, | - |
3219 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3220 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3221 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3222 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3223 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3224 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3225 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3226 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3227 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3228 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3229 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3230 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3231 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3232 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3233 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3234 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3235 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3236 | fetchTransformedBilinear<BlendTransformedBilinear>, | - |
3237 | }, | - |
3238 | { | - |
3239 | 0, | - |
3240 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3241 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3242 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3243 | fetchTransformedBilinearARGB32PM<BlendTransformedBilinearTiled>, | - |
3244 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3245 | fetchTransformedBilinearARGB32PM<BlendTransformedBilinearTiled>, | - |
3246 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3247 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3248 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3249 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3250 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3251 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3252 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3253 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3254 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3255 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3256 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3257 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3258 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3259 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3260 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3261 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3262 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3263 | fetchTransformedBilinear<BlendTransformedBilinearTiled>, | - |
3264 | }, | - |
3265 | }; | - |
3266 | | - |
3267 | static SourceFetchProc64 sourceFetch64[NBlendTypes][QImage::NImageFormats] = { | - |
3268 | | - |
3269 | { | - |
3270 | 0, | - |
3271 | fetchUntransformed64, | - |
3272 | fetchUntransformed64, | - |
3273 | fetchUntransformed64, | - |
3274 | fetchUntransformed64, | - |
3275 | fetchUntransformed64, | - |
3276 | fetchUntransformed64, | - |
3277 | fetchUntransformed64, | - |
3278 | fetchUntransformed64, | - |
3279 | fetchUntransformed64, | - |
3280 | fetchUntransformed64, | - |
3281 | fetchUntransformed64, | - |
3282 | fetchUntransformed64, | - |
3283 | fetchUntransformed64, | - |
3284 | fetchUntransformed64, | - |
3285 | fetchUntransformed64, | - |
3286 | fetchUntransformed64, | - |
3287 | fetchUntransformed64, | - |
3288 | fetchUntransformed64, | - |
3289 | fetchUntransformed64, | - |
3290 | fetchUntransformed64, | - |
3291 | fetchUntransformed64, | - |
3292 | fetchUntransformed64, | - |
3293 | fetchUntransformed64, | - |
3294 | fetchUntransformed64, | - |
3295 | }, | - |
3296 | | - |
3297 | { | - |
3298 | 0, | - |
3299 | fetchUntransformed64, | - |
3300 | fetchUntransformed64, | - |
3301 | fetchUntransformed64, | - |
3302 | fetchUntransformed64, | - |
3303 | fetchUntransformed64, | - |
3304 | fetchUntransformed64, | - |
3305 | fetchUntransformed64, | - |
3306 | fetchUntransformed64, | - |
3307 | fetchUntransformed64, | - |
3308 | fetchUntransformed64, | - |
3309 | fetchUntransformed64, | - |
3310 | fetchUntransformed64, | - |
3311 | fetchUntransformed64, | - |
3312 | fetchUntransformed64, | - |
3313 | fetchUntransformed64, | - |
3314 | fetchUntransformed64, | - |
3315 | fetchUntransformed64, | - |
3316 | fetchUntransformed64, | - |
3317 | fetchUntransformed64, | - |
3318 | fetchUntransformed64, | - |
3319 | fetchUntransformed64, | - |
3320 | fetchUntransformed64, | - |
3321 | fetchUntransformed64, | - |
3322 | fetchUntransformed64, | - |
3323 | }, | - |
3324 | | - |
3325 | { | - |
3326 | 0, | - |
3327 | fetchTransformed64<BlendTransformed>, | - |
3328 | fetchTransformed64<BlendTransformed>, | - |
3329 | fetchTransformed64<BlendTransformed>, | - |
3330 | fetchTransformed64<BlendTransformed>, | - |
3331 | fetchTransformed64<BlendTransformed>, | - |
3332 | fetchTransformed64<BlendTransformed>, | - |
3333 | fetchTransformed64<BlendTransformed>, | - |
3334 | fetchTransformed64<BlendTransformed>, | - |
3335 | fetchTransformed64<BlendTransformed>, | - |
3336 | fetchTransformed64<BlendTransformed>, | - |
3337 | fetchTransformed64<BlendTransformed>, | - |
3338 | fetchTransformed64<BlendTransformed>, | - |
3339 | fetchTransformed64<BlendTransformed>, | - |
3340 | fetchTransformed64<BlendTransformed>, | - |
3341 | fetchTransformed64<BlendTransformed>, | - |
3342 | fetchTransformed64<BlendTransformed>, | - |
3343 | fetchTransformed64<BlendTransformed>, | - |
3344 | fetchTransformed64<BlendTransformed>, | - |
3345 | fetchTransformed64<BlendTransformed>, | - |
3346 | fetchTransformed64<BlendTransformed>, | - |
3347 | fetchTransformed64<BlendTransformed>, | - |
3348 | fetchTransformed64<BlendTransformed>, | - |
3349 | fetchTransformed64<BlendTransformed>, | - |
3350 | fetchTransformed64<BlendTransformed>, | - |
3351 | }, | - |
3352 | { | - |
3353 | 0, | - |
3354 | fetchTransformed64<BlendTransformedTiled>, | - |
3355 | fetchTransformed64<BlendTransformedTiled>, | - |
3356 | fetchTransformed64<BlendTransformedTiled>, | - |
3357 | fetchTransformed64<BlendTransformedTiled>, | - |
3358 | fetchTransformed64<BlendTransformedTiled>, | - |
3359 | fetchTransformed64<BlendTransformedTiled>, | - |
3360 | fetchTransformed64<BlendTransformedTiled>, | - |
3361 | fetchTransformed64<BlendTransformedTiled>, | - |
3362 | fetchTransformed64<BlendTransformedTiled>, | - |
3363 | fetchTransformed64<BlendTransformedTiled>, | - |
3364 | fetchTransformed64<BlendTransformedTiled>, | - |
3365 | fetchTransformed64<BlendTransformedTiled>, | - |
3366 | fetchTransformed64<BlendTransformedTiled>, | - |
3367 | fetchTransformed64<BlendTransformedTiled>, | - |
3368 | fetchTransformed64<BlendTransformedTiled>, | - |
3369 | fetchTransformed64<BlendTransformedTiled>, | - |
3370 | fetchTransformed64<BlendTransformedTiled>, | - |
3371 | fetchTransformed64<BlendTransformedTiled>, | - |
3372 | fetchTransformed64<BlendTransformedTiled>, | - |
3373 | fetchTransformed64<BlendTransformedTiled>, | - |
3374 | fetchTransformed64<BlendTransformedTiled>, | - |
3375 | fetchTransformed64<BlendTransformedTiled>, | - |
3376 | fetchTransformed64<BlendTransformedTiled>, | - |
3377 | fetchTransformed64<BlendTransformedTiled>, | - |
3378 | }, | - |
3379 | { | - |
3380 | 0, | - |
3381 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3382 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3383 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3384 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3385 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3386 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3387 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3388 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3389 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3390 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3391 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3392 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3393 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3394 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3395 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3396 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3397 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3398 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3399 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3400 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3401 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3402 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3403 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3404 | fetchTransformedBilinear64<BlendTransformedBilinear>, | - |
3405 | }, | - |
3406 | { | - |
3407 | 0, | - |
3408 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3409 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3410 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3411 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3412 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3413 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3414 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3415 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3416 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3417 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3418 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3419 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3420 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3421 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3422 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3423 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3424 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3425 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3426 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3427 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3428 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3429 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3430 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3431 | fetchTransformedBilinear64<BlendTransformedBilinearTiled>, | - |
3432 | }, | - |
3433 | }; | - |
3434 | | - |
3435 | #define FIXPT_BITS 8 | - |
3436 | #define FIXPT_SIZE (1<<FIXPT_BITS) | - |
3437 | | - |
3438 | static uint qt_gradient_pixel_fixed(const QGradientData *data, int fixed_pos) | - |
3439 | { | - |
3440 | int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS; | - |
3441 | return data->colorTable32[qt_gradient_clamp(data, ipos)]; | - |
3442 | } | - |
3443 | | - |
3444 | static const QRgba64& qt_gradient_pixel64_fixed(const QGradientData *data, int fixed_pos) | - |
3445 | { | - |
3446 | int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS; | - |
3447 | return data->colorTable64[qt_gradient_clamp(data, ipos)]; | - |
3448 | } | - |
3449 | | - |
3450 | static void QT_FASTCALL getLinearGradientValues(LinearGradientValues *v, const QSpanData *data) | - |
3451 | { | - |
3452 | v->dx = data->gradient.linear.end.x - data->gradient.linear.origin.x; | - |
3453 | v->dy = data->gradient.linear.end.y - data->gradient.linear.origin.y; | - |
3454 | v->l = v->dx * v->dx + v->dy * v->dy; | - |
3455 | v->off = 0; | - |
3456 | if (v->l != 0) { | - |
3457 | v->dx /= v->l; | - |
3458 | v->dy /= v->l; | - |
3459 | v->off = -v->dx * data->gradient.linear.origin.x - v->dy * data->gradient.linear.origin.y; | - |
3460 | } | - |
3461 | } | - |
3462 | | - |
3463 | class GradientBase32 | - |
3464 | { | - |
3465 | public: | - |
3466 | typedef uint Type; | - |
3467 | static Type null() { return 0; } | - |
3468 | static Type fetchSingle(const QGradientData& gradient, qreal v) | - |
3469 | { | - |
3470 | return qt_gradient_pixel(&gradient, v); | - |
3471 | } | - |
3472 | static Type fetchSingle(const QGradientData& gradient, int v) | - |
3473 | { | - |
3474 | return qt_gradient_pixel_fixed(&gradient, v); | - |
3475 | } | - |
3476 | static void memfill(Type *buffer, Type fill, int length) | - |
3477 | { | - |
3478 | qt_memfill32(buffer, fill, length); | - |
3479 | } | - |
3480 | }; | - |
3481 | | - |
3482 | class GradientBase64 | - |
3483 | { | - |
3484 | public: | - |
3485 | typedef QRgba64 Type; | - |
3486 | static Type null() { return QRgba64::fromRgba64(0); } | - |
3487 | static Type fetchSingle(const QGradientData& gradient, qreal v) | - |
3488 | { | - |
3489 | return qt_gradient_pixel64(&gradient, v); | - |
3490 | } | - |
3491 | static Type fetchSingle(const QGradientData& gradient, int v) | - |
3492 | { | - |
3493 | return qt_gradient_pixel64_fixed(&gradient, v); | - |
3494 | } | - |
3495 | static void memfill(Type *buffer, Type fill, int length) | - |
3496 | { | - |
3497 | qt_memfill64((quint64*)buffer, fill, length); | - |
3498 | } | - |
3499 | }; | - |
3500 | | - |
3501 | template<class GradientBase, typename BlendType> | - |
3502 | static inline const BlendType * QT_FASTCALL qt_fetch_linear_gradient_template( | - |
3503 | BlendType *buffer, const Operator *op, const QSpanData *data, | - |
3504 | int y, int x, int length) | - |
3505 | { | - |
3506 | const BlendType *b = buffer; | - |
3507 | qreal t, inc; | - |
3508 | | - |
3509 | bool affine = true; | - |
3510 | qreal rx=0, ry=0; | - |
3511 | if (op->linear.l == 0) { | - |
3512 | t = inc = 0; | - |
3513 | } else { | - |
3514 | rx = data->m21 * (y + qreal(0.5)) + data->m11 * (x + qreal(0.5)) + data->dx; | - |
3515 | ry = data->m22 * (y + qreal(0.5)) + data->m12 * (x + qreal(0.5)) + data->dy; | - |
3516 | t = op->linear.dx*rx + op->linear.dy*ry + op->linear.off; | - |
3517 | inc = op->linear.dx * data->m11 + op->linear.dy * data->m12; | - |
3518 | affine = !data->m13 && !data->m23; | - |
3519 | | - |
3520 | if (affine) { | - |
3521 | t *= (GRADIENT_STOPTABLE_SIZE - 1); | - |
3522 | inc *= (GRADIENT_STOPTABLE_SIZE - 1); | - |
3523 | } | - |
3524 | } | - |
3525 | | - |
3526 | const BlendType *end = buffer + length; | - |
3527 | if (affine) { | - |
3528 | if (inc > qreal(-1e-5) && inc < qreal(1e-5)) { | - |
3529 | GradientBase::memfill(buffer, GradientBase::fetchSingle(data->gradient, int(t * FIXPT_SIZE)), length); | - |
3530 | } else { | - |
3531 | if (t+inc*length < qreal(INT_MAX >> (FIXPT_BITS + 1)) && | - |
3532 | t+inc*length > qreal(INT_MIN >> (FIXPT_BITS + 1))) { | - |
3533 | | - |
3534 | int t_fixed = int(t * FIXPT_SIZE); | - |
3535 | int inc_fixed = int(inc * FIXPT_SIZE); | - |
3536 | while (buffer < end) { | - |
3537 | *buffer = GradientBase::fetchSingle(data->gradient, t_fixed); | - |
3538 | t_fixed += inc_fixed; | - |
3539 | ++buffer; | - |
3540 | } | - |
3541 | } else { | - |
3542 | | - |
3543 | while (buffer < end) { | - |
3544 | *buffer = GradientBase::fetchSingle(data->gradient, t/GRADIENT_STOPTABLE_SIZE); | - |
3545 | t += inc; | - |
3546 | ++buffer; | - |
3547 | } | - |
3548 | } | - |
3549 | } | - |
3550 | } else { | - |
3551 | qreal rw = data->m23 * (y + qreal(0.5)) + data->m13 * (x + qreal(0.5)) + data->m33; | - |
3552 | while (buffer < end) { | - |
3553 | qreal x = rx/rw; | - |
3554 | qreal y = ry/rw; | - |
3555 | t = (op->linear.dx*x + op->linear.dy *y) + op->linear.off; | - |
3556 | | - |
3557 | *buffer = GradientBase::fetchSingle(data->gradient, t); | - |
3558 | rx += data->m11; | - |
3559 | ry += data->m12; | - |
3560 | rw += data->m13; | - |
3561 | if (!rw) { | - |
3562 | rw += data->m13; | - |
3563 | } | - |
3564 | ++buffer; | - |
3565 | } | - |
3566 | } | - |
3567 | | - |
3568 | return b; | - |
3569 | } | - |
3570 | | - |
3571 | static const uint * QT_FASTCALL qt_fetch_linear_gradient(uint *buffer, const Operator *op, const QSpanData *data, | - |
3572 | int y, int x, int length) | - |
3573 | { | - |
3574 | return qt_fetch_linear_gradient_template<GradientBase32, uint>(buffer, op, data, y, x, length); | - |
3575 | } | - |
3576 | | - |
3577 | static const QRgba64 * QT_FASTCALL qt_fetch_linear_gradient_rgb64(QRgba64 *buffer, const Operator *op, const QSpanData *data, | - |
3578 | int y, int x, int length) | - |
3579 | { | - |
3580 | return qt_fetch_linear_gradient_template<GradientBase64, QRgba64>(buffer, op, data, y, x, length); | - |
3581 | } | - |
3582 | | - |
3583 | static void QT_FASTCALL getRadialGradientValues(RadialGradientValues *v, const QSpanData *data) | - |
3584 | { | - |
3585 | v->dx = data->gradient.radial.center.x - data->gradient.radial.focal.x; | - |
3586 | v->dy = data->gradient.radial.center.y - data->gradient.radial.focal.y; | - |
3587 | | - |
3588 | v->dr = data->gradient.radial.center.radius - data->gradient.radial.focal.radius; | - |
3589 | v->sqrfr = data->gradient.radial.focal.radius * data->gradient.radial.focal.radius; | - |
3590 | | - |
3591 | v->a = v->dr * v->dr - v->dx*v->dx - v->dy*v->dy; | - |
3592 | v->inv2a = 1 / (2 * v->a); | - |
3593 | | - |
3594 | v->extended = !qFuzzyIsNull(data->gradient.radial.focal.radius) || v->a <= 0; | - |
3595 | } | - |
3596 | | - |
3597 | template <class GradientBase> | - |
3598 | class RadialFetchPlain : public GradientBase | - |
3599 | { | - |
3600 | public: | - |
3601 | typedef typename GradientBase::Type BlendType; | - |
3602 | static void fetch(BlendType *buffer, BlendType *end, | - |
3603 | const Operator *op, const QSpanData *data, qreal det, | - |
3604 | qreal delta_det, qreal delta_delta_det, qreal b, qreal delta_b) | - |
3605 | { | - |
3606 | if (op->radial.extended) { | - |
3607 | while (buffer < end) { | - |
3608 | BlendType result = GradientBase::null(); | - |
3609 | if (det >= 0) { | - |
3610 | qreal w = qSqrt(det) - b; | - |
3611 | if (data->gradient.radial.focal.radius + op->radial.dr * w >= 0) | - |
3612 | result = GradientBase::fetchSingle(data->gradient, w); | - |
3613 | } | - |
3614 | | - |
3615 | *buffer = result; | - |
3616 | | - |
3617 | det += delta_det; | - |
3618 | delta_det += delta_delta_det; | - |
3619 | b += delta_b; | - |
3620 | | - |
3621 | ++buffer; | - |
3622 | } | - |
3623 | } else { | - |
3624 | while (buffer < end) { | - |
3625 | *buffer++ = GradientBase::fetchSingle(data->gradient, qSqrt(det) - b); | - |
3626 | | - |
3627 | det += delta_det; | - |
3628 | delta_det += delta_delta_det; | - |
3629 | b += delta_b; | - |
3630 | } | - |
3631 | } | - |
3632 | } | - |
3633 | }; | - |
3634 | | - |
3635 | const uint * QT_FASTCALL qt_fetch_radial_gradient_plain(uint *buffer, const Operator *op, const QSpanData *data, | - |
3636 | int y, int x, int length) | - |
3637 | { | - |
3638 | return qt_fetch_radial_gradient_template<RadialFetchPlain<GradientBase32>, uint>(buffer, op, data, y, x, length); | - |
3639 | } | - |
3640 | | - |
3641 | static SourceFetchProc qt_fetch_radial_gradient = qt_fetch_radial_gradient_plain; | - |
3642 | | - |
3643 | const QRgba64 * QT_FASTCALL qt_fetch_radial_gradient_rgb64(QRgba64 *buffer, const Operator *op, const QSpanData *data, | - |
3644 | int y, int x, int length) | - |
3645 | { | - |
3646 | return qt_fetch_radial_gradient_template<RadialFetchPlain<GradientBase64>, QRgba64>(buffer, op, data, y, x, length); | - |
3647 | } | - |
3648 | | - |
3649 | template <class GradientBase, typename BlendType> | - |
3650 | static inline const BlendType * QT_FASTCALL qt_fetch_conical_gradient_template( | - |
3651 | BlendType *buffer, const QSpanData *data, | - |
3652 | int y, int x, int length) | - |
3653 | { | - |
3654 | const BlendType *b = buffer; | - |
3655 | qreal rx = data->m21 * (y + qreal(0.5)) | - |
3656 | + data->dx + data->m11 * (x + qreal(0.5)); | - |
3657 | qreal ry = data->m22 * (y + qreal(0.5)) | - |
3658 | + data->dy + data->m12 * (x + qreal(0.5)); | - |
3659 | bool affine = !data->m13 && !data->m23; | - |
3660 | | - |
3661 | const qreal inv2pi = M_1_PI / 2.0; | - |
3662 | | - |
3663 | const BlendType *end = buffer + length; | - |
3664 | if (affine) { | - |
3665 | rx -= data->gradient.conical.center.x; | - |
3666 | ry -= data->gradient.conical.center.y; | - |
3667 | while (buffer < end) { | - |
3668 | qreal angle = qAtan2(ry, rx) + data->gradient.conical.angle; | - |
3669 | | - |
3670 | *buffer = GradientBase::fetchSingle(data->gradient, 1 - angle * inv2pi); | - |
3671 | | - |
3672 | rx += data->m11; | - |
3673 | ry += data->m12; | - |
3674 | ++buffer; | - |
3675 | } | - |
3676 | } else { | - |
3677 | qreal rw = data->m23 * (y + qreal(0.5)) | - |
3678 | + data->m33 + data->m13 * (x + qreal(0.5)); | - |
3679 | if (!rw) | - |
3680 | rw = 1; | - |
3681 | while (buffer < end) { | - |
3682 | qreal angle = qAtan2(ry/rw - data->gradient.conical.center.x, | - |
3683 | rx/rw - data->gradient.conical.center.y) | - |
3684 | + data->gradient.conical.angle; | - |
3685 | | - |
3686 | *buffer = GradientBase::fetchSingle(data->gradient, 1 - angle * inv2pi); | - |
3687 | | - |
3688 | rx += data->m11; | - |
3689 | ry += data->m12; | - |
3690 | rw += data->m13; | - |
3691 | if (!rw) { | - |
3692 | rw += data->m13; | - |
3693 | } | - |
3694 | ++buffer; | - |
3695 | } | - |
3696 | } | - |
3697 | return b; | - |
3698 | } | - |
3699 | | - |
3700 | static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Operator *, const QSpanData *data, | - |
3701 | int y, int x, int length) | - |
3702 | { | - |
3703 | return qt_fetch_conical_gradient_template<GradientBase32, uint>(buffer, data, y, x, length); | - |
3704 | } | - |
3705 | | - |
3706 | static const QRgba64 * QT_FASTCALL qt_fetch_conical_gradient_rgb64(QRgba64 *buffer, const Operator *, const QSpanData *data, | - |
3707 | int y, int x, int length) | - |
3708 | { | - |
3709 | return qt_fetch_conical_gradient_template<GradientBase64, QRgba64>(buffer, data, y, x, length); | - |
3710 | } | - |
3711 | | - |
3712 | extern CompositionFunctionSolid qt_functionForModeSolid_C[]; | - |
3713 | extern CompositionFunctionSolid64 qt_functionForModeSolid64_C[]; | - |
3714 | | - |
3715 | static const CompositionFunctionSolid *functionForModeSolid = qt_functionForModeSolid_C; | - |
3716 | static const CompositionFunctionSolid64 *functionForModeSolid64 = qt_functionForModeSolid64_C; | - |
3717 | | - |
3718 | extern CompositionFunction qt_functionForMode_C[]; | - |
3719 | extern CompositionFunction64 qt_functionForMode64_C[]; | - |
3720 | | - |
3721 | static const CompositionFunction *functionForMode = qt_functionForMode_C; | - |
3722 | static const CompositionFunction64 *functionForMode64 = qt_functionForMode64_C; | - |
3723 | | - |
3724 | static TextureBlendType getBlendType(const QSpanData *data) | - |
3725 | { | - |
3726 | TextureBlendType ft; | - |
3727 | if (data->txop <= QTransform::TxTranslate) | - |
3728 | if (data->texture.type == QTextureData::Tiled) | - |
3729 | ft = BlendTiled; | - |
3730 | else | - |
3731 | ft = BlendUntransformed; | - |
3732 | else if (data->bilinear) | - |
3733 | if (data->texture.type == QTextureData::Tiled) | - |
3734 | ft = BlendTransformedBilinearTiled; | - |
3735 | else | - |
3736 | ft = BlendTransformedBilinear; | - |
3737 | else | - |
3738 | if (data->texture.type == QTextureData::Tiled) | - |
3739 | ft = BlendTransformedTiled; | - |
3740 | else | - |
3741 | ft = BlendTransformed; | - |
3742 | return ft; | - |
3743 | } | - |
3744 | | - |
3745 | static inline Operator getOperator(const QSpanData *data, const QSpan *spans, int spanCount) | - |
3746 | { | - |
3747 | Operator op; | - |
3748 | bool solidSource = false; | - |
3749 | | - |
3750 | switch(data->type) { | - |
3751 | case QSpanData::Solid: | - |
3752 | solidSource = data->solid.color.isOpaque(); | - |
3753 | op.srcFetch = 0; | - |
3754 | op.srcFetch64 = 0; | - |
3755 | break; | - |
3756 | case QSpanData::LinearGradient: | - |
3757 | solidSource = !data->gradient.alphaColor; | - |
3758 | getLinearGradientValues(&op.linear, data); | - |
3759 | op.srcFetch = qt_fetch_linear_gradient; | - |
3760 | op.srcFetch64 = qt_fetch_linear_gradient_rgb64; | - |
3761 | break; | - |
3762 | case QSpanData::RadialGradient: | - |
3763 | solidSource = !data->gradient.alphaColor; | - |
3764 | getRadialGradientValues(&op.radial, data); | - |
3765 | op.srcFetch = qt_fetch_radial_gradient; | - |
3766 | op.srcFetch64 = qt_fetch_radial_gradient_rgb64; | - |
3767 | break; | - |
3768 | case QSpanData::ConicalGradient: | - |
3769 | solidSource = !data->gradient.alphaColor; | - |
3770 | op.srcFetch = qt_fetch_conical_gradient; | - |
3771 | op.srcFetch64 = qt_fetch_conical_gradient_rgb64; | - |
3772 | break; | - |
3773 | case QSpanData::Texture: | - |
3774 | solidSource = !data->texture.hasAlpha; | - |
3775 | op.srcFetch = sourceFetch[getBlendType(data)][data->texture.format]; | - |
3776 | op.srcFetch64 = sourceFetch64[getBlendType(data)][data->texture.format]; | - |
3777 | break; | - |
3778 | default: | - |
3779 | Q_UNREACHABLE(); | - |
3780 | break; | - |
3781 | } | - |
3782 | | - |
3783 | op.mode = data->rasterBuffer->compositionMode; | - |
3784 | if (op.mode == QPainter::CompositionMode_SourceOver && solidSource) | - |
3785 | op.mode = QPainter::CompositionMode_Source; | - |
3786 | | - |
3787 | op.destFetch = destFetchProc[data->rasterBuffer->format]; | - |
3788 | op.destFetch64 = destFetchProc64[data->rasterBuffer->format]; | - |
3789 | if (op.mode == QPainter::CompositionMode_Source) { | - |
3790 | switch (data->rasterBuffer->format) { | - |
3791 | case QImage::Format_RGB32: | - |
3792 | case QImage::Format_ARGB32_Premultiplied: | - |
3793 | | - |
3794 | break; | - |
3795 | default: { | - |
3796 | if (data->type == QSpanData::Texture && data->texture.const_alpha != 256) | - |
3797 | break; | - |
3798 | const QSpan *lastSpan = spans + spanCount; | - |
3799 | bool alphaSpans = false; | - |
3800 | while (spans < lastSpan) { | - |
3801 | if (spans->coverage != 255) { | - |
3802 | alphaSpans = true; | - |
3803 | break; | - |
3804 | } | - |
3805 | ++spans; | - |
3806 | } | - |
3807 | if (!alphaSpans) | - |
3808 | op.destFetch = 0; | - |
3809 | } | - |
3810 | } | - |
3811 | } | - |
3812 | | - |
3813 | op.destStore = destStoreProc[data->rasterBuffer->format]; | - |
3814 | op.destStore64 = destStoreProc64[data->rasterBuffer->format]; | - |
3815 | | - |
3816 | op.funcSolid = functionForModeSolid[op.mode]; | - |
3817 | op.funcSolid64 = functionForModeSolid64[op.mode]; | - |
3818 | op.func = functionForMode[op.mode]; | - |
3819 | op.func64 = functionForMode64[op.mode]; | - |
3820 | | - |
3821 | return op; | - |
3822 | } | - |
3823 | | - |
3824 | | - |
3825 | | - |
3826 | | - |
3827 | | - |
3828 | #if !defined(Q_CC_SUN) | - |
3829 | static | - |
3830 | #endif | - |
3831 | void blend_color_generic(int count, const QSpan *spans, void *userData) | - |
3832 | { | - |
3833 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
3834 | uint buffer[buffer_size]; | - |
3835 | Operator op = getOperator(data, spans, count); | - |
3836 | const uint color = data->solid.color.toArgb32(); | - |
3837 | | - |
3838 | while (count--) { | - |
3839 | int x = spans->x; | - |
3840 | int length = spans->len; | - |
3841 | while (length) { | - |
3842 | int l = qMin(buffer_size, length); | - |
3843 | uint *dest = op.destFetch ? op.destFetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer; | - |
3844 | op.funcSolid(dest, l, color, spans->coverage); | - |
3845 | if (op.destStore) | - |
3846 | op.destStore(data->rasterBuffer, x, spans->y, dest, l); | - |
3847 | length -= l; | - |
3848 | x += l; | - |
3849 | } | - |
3850 | ++spans; | - |
3851 | } | - |
3852 | } | - |
3853 | | - |
3854 | static void blend_color_argb(int count, const QSpan *spans, void *userData) | - |
3855 | { | - |
3856 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
3857 | | - |
3858 | Operator op = getOperator(data, spans, count); | - |
3859 | const uint color = data->solid.color.toArgb32(); | - |
3860 | | - |
3861 | if (op.mode == QPainter::CompositionMode_Source) { | - |
3862 | | - |
3863 | while (count--) { | - |
3864 | uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; | - |
3865 | if (spans->coverage == 255) { | - |
3866 | QT_MEMFILL_UINT(target, spans->len, color); | - |
3867 | } else { | - |
3868 | uint c = BYTE_MUL(color, spans->coverage); | - |
3869 | int ialpha = 255 - spans->coverage; | - |
3870 | for (int i = 0; i < spans->len; ++i) | - |
3871 | target[i] = c + BYTE_MUL(target[i], ialpha); | - |
3872 | } | - |
3873 | ++spans; | - |
3874 | } | - |
3875 | return; | - |
3876 | } | - |
3877 | | - |
3878 | while (count--) { | - |
3879 | uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; | - |
3880 | op.funcSolid(target, spans->len, color, spans->coverage); | - |
3881 | ++spans; | - |
3882 | } | - |
3883 | } | - |
3884 | | - |
3885 | void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData) | - |
3886 | { | - |
3887 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
3888 | Operator op = getOperator(data, spans, count); | - |
3889 | if (!op.funcSolid64) { | - |
3890 | qDebug("unsupported 64bit blend attempted"); | - |
3891 | return blend_color_generic(count, spans, userData); | - |
3892 | } | - |
3893 | | - |
3894 | QRgba64 buffer[buffer_size]; | - |
3895 | const QRgba64 color = data->solid.color; | - |
3896 | | - |
3897 | while (count--) { | - |
3898 | int x = spans->x; | - |
3899 | int length = spans->len; | - |
3900 | while (length) { | - |
3901 | int l = qMin(buffer_size, length); | - |
3902 | QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); | - |
3903 | op.funcSolid64(dest, l, color, spans->coverage); | - |
3904 | op.destStore64(data->rasterBuffer, x, spans->y, dest, l); | - |
3905 | length -= l; | - |
3906 | x += l; | - |
3907 | } | - |
3908 | ++spans; | - |
3909 | } | - |
3910 | } | - |
3911 | | - |
3912 | static void blend_color_rgb16(int count, const QSpan *spans, void *userData) | - |
3913 | { | - |
3914 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
3915 | | - |
3916 | | - |
3917 | | - |
3918 | | - |
3919 | | - |
3920 | | - |
3921 | QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; | - |
3922 | if (mode == QPainter::CompositionMode_SourceOver && data->solid.color.isOpaque()) | - |
3923 | mode = QPainter::CompositionMode_Source; | - |
3924 | | - |
3925 | if (mode == QPainter::CompositionMode_Source) { | - |
3926 | | - |
3927 | ushort c = data->solid.color.toRgb16(); | - |
3928 | while (count--) { | - |
3929 | ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x; | - |
3930 | if (spans->coverage == 255) { | - |
3931 | QT_MEMFILL_USHORT(target, spans->len, c); | - |
3932 | } else { | - |
3933 | ushort color = BYTE_MUL_RGB16(c, spans->coverage); | - |
3934 | int ialpha = 255 - spans->coverage; | - |
3935 | const ushort *end = target + spans->len; | - |
3936 | while (target < end) { | - |
3937 | *target = color + BYTE_MUL_RGB16(*target, ialpha); | - |
3938 | ++target; | - |
3939 | } | - |
3940 | } | - |
3941 | ++spans; | - |
3942 | } | - |
3943 | return; | - |
3944 | } | - |
3945 | | - |
3946 | if (mode == QPainter::CompositionMode_SourceOver) { | - |
3947 | while (count--) { | - |
3948 | uint color = BYTE_MUL(data->solid.color.toArgb32(), spans->coverage); | - |
3949 | int ialpha = qAlpha(~color); | - |
3950 | ushort c = qConvertRgb32To16(color); | - |
3951 | ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x; | - |
3952 | int len = spans->len; | - |
3953 | bool pre = (((quintptr)target) & 0x3) != 0; | - |
3954 | bool post = false; | - |
3955 | if (pre) { | - |
3956 | | - |
3957 | *target = c + BYTE_MUL_RGB16(*target, ialpha); | - |
3958 | ++target; | - |
3959 | --len; | - |
3960 | } | - |
3961 | if (len & 0x1) { | - |
3962 | post = true; | - |
3963 | --len; | - |
3964 | } | - |
3965 | uint *target32 = (uint*)target; | - |
3966 | uint c32 = c | (c<<16); | - |
3967 | len >>= 1; | - |
3968 | uint salpha = (ialpha+1) >> 3; | - |
3969 | while (len--) { | - |
3970 | | - |
3971 | *target32 = c32 + BYTE_MUL_RGB16_32(*target32, salpha); | - |
3972 | ++target32; | - |
3973 | target += 2; | - |
3974 | } | - |
3975 | if (post) { | - |
3976 | | - |
3977 | *target = c + BYTE_MUL_RGB16(*target, ialpha); | - |
3978 | } | - |
3979 | ++spans; | - |
3980 | } | - |
3981 | return; | - |
3982 | } | - |
3983 | | - |
3984 | blend_color_generic(count, spans, userData); | - |
3985 | } | - |
3986 | | - |
3987 | template <typename T> | - |
3988 | void handleSpans(int count, const QSpan *spans, const QSpanData *data, T &handler) | - |
3989 | { | - |
3990 | uint const_alpha = 256; | - |
3991 | if (data->type == QSpanData::Texture) | - |
3992 | const_alpha = data->texture.const_alpha; | - |
3993 | | - |
3994 | int coverage = 0; | - |
3995 | while (count) { | - |
3996 | int x = spans->x; | - |
3997 | const int y = spans->y; | - |
3998 | int right = x + spans->len; | - |
3999 | | - |
4000 | | - |
4001 | for (int i = 1; i < count && spans[i].y == y && spans[i].x == right; ++i) | - |
4002 | right += spans[i].len; | - |
4003 | int length = right - x; | - |
4004 | | - |
4005 | while (length) { | - |
4006 | int l = qMin(buffer_size, length); | - |
4007 | length -= l; | - |
4008 | | - |
4009 | int process_length = l; | - |
4010 | int process_x = x; | - |
4011 | | - |
4012 | const typename T::BlendType *src = handler.fetch(process_x, y, process_length); | - |
4013 | int offset = 0; | - |
4014 | while (l > 0) { | - |
4015 | if (x == spans->x) | - |
4016 | coverage = (spans->coverage * const_alpha) >> 8; | - |
4017 | | - |
4018 | int right = spans->x + spans->len; | - |
4019 | int len = qMin(l, right - x); | - |
4020 | | - |
4021 | handler.process(x, y, len, coverage, src, offset); | - |
4022 | | - |
4023 | l -= len; | - |
4024 | x += len; | - |
4025 | offset += len; | - |
4026 | | - |
4027 | if (x == right) { | - |
4028 | ++spans; | - |
4029 | --count; | - |
4030 | } | - |
4031 | } | - |
4032 | handler.store(process_x, y, process_length); | - |
4033 | } | - |
4034 | } | - |
4035 | } | - |
4036 | | - |
4037 | template<typename T> | - |
4038 | struct QBlendBase | - |
4039 | { | - |
4040 | typedef T BlendType; | - |
4041 | QBlendBase(QSpanData *d, Operator o) | - |
4042 | : data(d) | - |
4043 | , op(o) | - |
4044 | , dest(0) | - |
4045 | { | - |
4046 | } | - |
4047 | | - |
4048 | QSpanData *data; | - |
4049 | Operator op; | - |
4050 | | - |
4051 | BlendType *dest; | - |
4052 | | - |
4053 | BlendType buffer[buffer_size]; | - |
4054 | BlendType src_buffer[buffer_size]; | - |
4055 | }; | - |
4056 | | - |
4057 | class BlendSrcGeneric : public QBlendBase<uint> | - |
4058 | { | - |
4059 | public: | - |
4060 | BlendSrcGeneric(QSpanData *d, Operator o) | - |
4061 | : QBlendBase<uint>(d, o) | - |
4062 | { | - |
4063 | } | - |
4064 | | - |
4065 | const uint *fetch(int x, int y, int len) | - |
4066 | { | - |
4067 | dest = op.destFetch ? op.destFetch(buffer, data->rasterBuffer, x, y, len) : buffer; | - |
4068 | return op.srcFetch(src_buffer, &op, data, y, x, len); | - |
4069 | } | - |
4070 | | - |
4071 | void process(int, int, int len, int coverage, const uint *src, int offset) | - |
4072 | { | - |
4073 | op.func(dest + offset, src + offset, len, coverage); | - |
4074 | } | - |
4075 | | - |
4076 | void store(int x, int y, int len) | - |
4077 | { | - |
4078 | if (op.destStore) | - |
4079 | op.destStore(data->rasterBuffer, x, y, dest, len); | - |
4080 | } | - |
4081 | }; | - |
4082 | | - |
4083 | class BlendSrcGenericRGB64 : public QBlendBase<QRgba64> | - |
4084 | { | - |
4085 | public: | - |
4086 | BlendSrcGenericRGB64(QSpanData *d, Operator o) | - |
4087 | : QBlendBase<QRgba64>(d, o) | - |
4088 | { | - |
4089 | } | - |
4090 | | - |
4091 | bool isSupported() const | - |
4092 | { | - |
4093 | return op.func64 && op.destFetch64 && op.destStore64; | - |
4094 | } | - |
4095 | | - |
4096 | const QRgba64 *fetch(int x, int y, int len) | - |
4097 | { | - |
4098 | dest = op.destFetch64(buffer, data->rasterBuffer, x, y, len); | - |
4099 | return op.srcFetch64(src_buffer, &op, data, y, x, len); | - |
4100 | } | - |
4101 | | - |
4102 | void process(int, int, int len, int coverage, const QRgba64 *src, int offset) | - |
4103 | { | - |
4104 | op.func64(dest + offset, src + offset, len, coverage); | - |
4105 | } | - |
4106 | | - |
4107 | void store(int x, int y, int len) | - |
4108 | { | - |
4109 | op.destStore64(data->rasterBuffer, x, y, dest, len); | - |
4110 | } | - |
4111 | }; | - |
4112 | | - |
4113 | static void blend_src_generic(int count, const QSpan *spans, void *userData) | - |
4114 | { | - |
4115 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
4116 | BlendSrcGeneric blend(data, getOperator(data, spans, count)); | - |
4117 | handleSpans(count, spans, data, blend); | - |
4118 | } | - |
4119 | | - |
4120 | static void blend_src_generic_rgb64(int count, const QSpan *spans, void *userData) | - |
4121 | { | - |
4122 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
4123 | Operator op = getOperator(data, spans, count); | - |
4124 | BlendSrcGenericRGB64 blend64(data, op); | - |
4125 | if (blend64.isSupported()) | - |
4126 | handleSpans(count, spans, data, blend64); | - |
4127 | else { | - |
4128 | qDebug("blend_src_generic_rgb64: unsupported 64-bit blend attempted"); | - |
4129 | BlendSrcGeneric blend32(data, op); | - |
4130 | handleSpans(count, spans, data, blend32); | - |
4131 | } | - |
4132 | } | - |
4133 | | - |
4134 | static void blend_untransformed_generic(int count, const QSpan *spans, void *userData) | - |
4135 | { | - |
4136 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
4137 | | - |
4138 | uint buffer[buffer_size]; | - |
4139 | uint src_buffer[buffer_size]; | - |
4140 | Operator op = getOperator(data, spans, count); | - |
4141 | | - |
4142 | const int image_width = data->texture.width; | - |
4143 | const int image_height = data->texture.height; | - |
4144 | int xoff = -qRound(-data->dx); | - |
4145 | int yoff = -qRound(-data->dy); | - |
4146 | | - |
4147 | while (count--) { | - |
4148 | int x = spans->x; | - |
4149 | int length = spans->len; | - |
4150 | int sx = xoff + x; | - |
4151 | int sy = yoff + spans->y; | - |
4152 | if (sy >= 0 && sy < image_height && sx < image_width) { | - |
4153 | if (sx < 0) { | - |
4154 | x -= sx; | - |
4155 | length += sx; | - |
4156 | sx = 0; | - |
4157 | } | - |
4158 | if (sx + length > image_width) | - |
4159 | length = image_width - sx; | - |
4160 | if (length > 0) { | - |
4161 | const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; | - |
4162 | while (length) { | - |
4163 | int l = qMin(buffer_size, length); | - |
4164 | const uint *src = op.srcFetch(src_buffer, &op, data, sy, sx, l); | - |
4165 | uint *dest = op.destFetch ? op.destFetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer; | - |
4166 | op.func(dest, src, l, coverage); | - |
4167 | if (op.destStore) | - |
4168 | op.destStore(data->rasterBuffer, x, spans->y, dest, l); | - |
4169 | x += l; | - |
4170 | sx += l; | - |
4171 | length -= l; | - |
4172 | } | - |
4173 | } | - |
4174 | } | - |
4175 | ++spans; | - |
4176 | } | - |
4177 | } | - |
4178 | | - |
4179 | static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, void *userData) | - |
4180 | { | - |
4181 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
4182 | | - |
4183 | Operator op = getOperator(data, spans, count); | - |
4184 | if (!op.func64) { | - |
4185 | qWarning("Unsupported blend"); | - |
4186 | return blend_untransformed_generic(count, spans, userData); | - |
4187 | } | - |
4188 | QRgba64 buffer[buffer_size]; | - |
4189 | QRgba64 src_buffer[buffer_size]; | - |
4190 | | - |
4191 | const int image_width = data->texture.width; | - |
4192 | const int image_height = data->texture.height; | - |
4193 | int xoff = -qRound(-data->dx); | - |
4194 | int yoff = -qRound(-data->dy); | - |
4195 | | - |
4196 | while (count--) { | - |
4197 | int x = spans->x; | - |
4198 | int length = spans->len; | - |
4199 | int sx = xoff + x; | - |
4200 | int sy = yoff + spans->y; | - |
4201 | if (sy >= 0 && sy < image_height && sx < image_width) { | - |
4202 | if (sx < 0) { | - |
4203 | x -= sx; | - |
4204 | length += sx; | - |
4205 | sx = 0; | - |
4206 | } | - |
4207 | if (sx + length > image_width) | - |
4208 | length = image_width - sx; | - |
4209 | if (length > 0) { | - |
4210 | const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; | - |
4211 | while (length) { | - |
4212 | int l = qMin(buffer_size, length); | - |
4213 | const QRgba64 *src = op.srcFetch64(src_buffer, &op, data, sy, sx, l); | - |
4214 | QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); | - |
4215 | op.func64(dest, src, l, coverage); | - |
4216 | op.destStore64(data->rasterBuffer, x, spans->y, dest, l); | - |
4217 | x += l; | - |
4218 | sx += l; | - |
4219 | length -= l; | - |
4220 | } | - |
4221 | } | - |
4222 | } | - |
4223 | ++spans; | - |
4224 | } | - |
4225 | } | - |
4226 | | - |
4227 | static void blend_untransformed_argb(int count, const QSpan *spans, void *userData) | - |
4228 | { | - |
4229 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
4230 | if (data->texture.format != QImage::Format_ARGB32_Premultiplied | - |
4231 | && data->texture.format != QImage::Format_RGB32) { | - |
4232 | blend_untransformed_generic(count, spans, userData); | - |
4233 | return; | - |
4234 | } | - |
4235 | | - |
4236 | Operator op = getOperator(data, spans, count); | - |
4237 | | - |
4238 | const int image_width = data->texture.width; | - |
4239 | const int image_height = data->texture.height; | - |
4240 | int xoff = -qRound(-data->dx); | - |
4241 | int yoff = -qRound(-data->dy); | - |
4242 | | - |
4243 | while (count--) { | - |
4244 | int x = spans->x; | - |
4245 | int length = spans->len; | - |
4246 | int sx = xoff + x; | - |
4247 | int sy = yoff + spans->y; | - |
4248 | if (sy >= 0 && sy < image_height && sx < image_width) { | - |
4249 | if (sx < 0) { | - |
4250 | x -= sx; | - |
4251 | length += sx; | - |
4252 | sx = 0; | - |
4253 | } | - |
4254 | if (sx + length > image_width) | - |
4255 | length = image_width - sx; | - |
4256 | if (length > 0) { | - |
4257 | const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; | - |
4258 | const uint *src = (const uint *)data->texture.scanLine(sy) + sx; | - |
4259 | uint *dest = ((uint *)data->rasterBuffer->scanLine(spans->y)) + x; | - |
4260 | op.func(dest, src, length, coverage); | - |
4261 | } | - |
4262 | } | - |
4263 | ++spans; | - |
4264 | } | - |
4265 | } | - |
4266 | | - |
4267 | static inline quint16 interpolate_pixel_rgb16_255(quint16 x, quint8 a, | - |
4268 | quint16 y, quint8 b) | - |
4269 | { | - |
4270 | quint16 t = ((((x & 0x07e0) * a) + ((y & 0x07e0) * b)) >> 5) & 0x07e0; | - |
4271 | t |= ((((x & 0xf81f) * a) + ((y & 0xf81f) * b)) >> 5) & 0xf81f; | - |
4272 | | - |
4273 | return t; | - |
4274 | } | - |
4275 | | - |
4276 | static inline quint32 interpolate_pixel_rgb16x2_255(quint32 x, quint8 a, | - |
4277 | quint32 y, quint8 b) | - |
4278 | { | - |
4279 | uint t; | - |
4280 | t = ((((x & 0xf81f07e0) >> 5) * a) + (((y & 0xf81f07e0) >> 5) * b)) & 0xf81f07e0; | - |
4281 | t |= ((((x & 0x07e0f81f) * a) + ((y & 0x07e0f81f) * b)) >> 5) & 0x07e0f81f; | - |
4282 | return t; | - |
4283 | } | - |
4284 | | - |
4285 | static inline void blend_sourceOver_rgb16_rgb16(quint16 *Q_DECL_RESTRICT dest, | - |
4286 | const quint16 *Q_DECL_RESTRICT src, | - |
4287 | int length, | - |
4288 | const quint8 alpha, | - |
4289 | const quint8 ialpha) | - |
4290 | { | - |
4291 | const int dstAlign = ((quintptr)dest) & 0x3; | - |
4292 | if (dstAlign) { | - |
4293 | *dest = interpolate_pixel_rgb16_255(*src, alpha, *dest, ialpha); | - |
4294 | ++dest; | - |
4295 | ++src; | - |
4296 | --length; | - |
4297 | } | - |
4298 | const int srcAlign = ((quintptr)src) & 0x3; | - |
4299 | int length32 = length >> 1; | - |
4300 | if (length32 && srcAlign == 0) { | - |
4301 | while (length32--) { | - |
4302 | const quint32 *src32 = reinterpret_cast<const quint32*>(src); | - |
4303 | quint32 *dest32 = reinterpret_cast<quint32*>(dest); | - |
4304 | *dest32 = interpolate_pixel_rgb16x2_255(*src32, alpha, | - |
4305 | *dest32, ialpha); | - |
4306 | dest += 2; | - |
4307 | src += 2; | - |
4308 | } | - |
4309 | length &= 0x1; | - |
4310 | } | - |
4311 | while (length--) { | - |
4312 | *dest = interpolate_pixel_rgb16_255(*src, alpha, *dest, ialpha); | - |
4313 | ++dest; | - |
4314 | ++src; | - |
4315 | } | - |
4316 | } | - |
4317 | | - |
4318 | static void blend_untransformed_rgb565(int count, const QSpan *spans, void *userData) | - |
4319 | { | - |
4320 | QSpanData *data = reinterpret_cast<QSpanData*>(userData); | - |
4321 | QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; | - |
4322 | | - |
4323 | if (data->texture.format != QImage::Format_RGB16 | - |
4324 | || (mode != QPainter::CompositionMode_SourceOver | - |
4325 | && mode != QPainter::CompositionMode_Source)) | - |
4326 | { | - |
4327 | blend_untransformed_generic(count, spans, userData); | - |
4328 | return; | - |
4329 | } | - |
4330 | | - |
4331 | const int image_width = data->texture.width; | - |
4332 | const int image_height = data->texture.height; | - |
4333 | int xoff = -qRound(-data->dx); | - |
4334 | int yoff = -qRound(-data->dy); | - |
4335 | | - |
4336 | while (count--) { | - |
4337 | const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; | - |
4338 | if (coverage == 0) { | - |
4339 | ++spans; | - |
4340 | continue; | - |
4341 | } | - |
4342 | | - |
4343 | int x = spans->x; | - |
4344 | int length = spans->len; | - |
4345 | int sx = xoff + x; | - |
4346 | int sy = yoff + spans->y; | - |
4347 | if (sy >= 0 && sy < image_height && sx < image_width) { | - |
4348 | if (sx < 0) { | - |
4349 | x -= sx; | - |
4350 | length += sx; | - |
4351 | sx = 0; | - |
4352 | } | - |
4353 | if (sx + length > image_width) | - |
4354 | length = image_width - sx; | - |
4355 | if (length > 0) { | - |
4356 | quint16 *dest = (quint16 *)data->rasterBuffer->scanLine(spans->y) + x; | - |
4357 | const quint16 *src = (const quint16 *)data->texture.scanLine(sy) + sx; | - |
4358 | if (coverage == 255) { | - |
4359 | memcpy(dest, src, length * sizeof(quint16)); | - |
4360 | } else { | - |
4361 | const quint8 alpha = (coverage + 1) >> 3; | - |
4362 | const quint8 ialpha = 0x20 - alpha; | - |
4363 | if (alpha > 0) | - |
4364 | blend_sourceOver_rgb16_rgb16(dest, src, length, alpha, ialpha); | - |
4365 | } | - |
4366 | } | - |
4367 | } | - |
4368 | ++spans; | - |
4369 | } | - |
4370 | } | - |
4371 | | - |
4372 | static void blend_tiled_generic(int count, const QSpan *spans, void *userData) | - |
4373 | { | - |
4374 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
4375 | | - |
4376 | uint buffer[buffer_size]; | - |
4377 | uint src_buffer[buffer_size]; | - |
4378 | Operator op = getOperator(data, spans, count); | - |
4379 | | - |
4380 | const int image_width = data->texture.width; | - |
4381 | const int image_height = data->texture.height; | - |
4382 | int xoff = -qRound(-data->dx) % image_width; | - |
4383 | int yoff = -qRound(-data->dy) % image_height; | - |
4384 | | - |
4385 | if (xoff < 0) | - |
4386 | xoff += image_width; | - |
4387 | if (yoff < 0) | - |
4388 | yoff += image_height; | - |
4389 | | - |
4390 | while (count--) { | - |
4391 | int x = spans->x; | - |
4392 | int length = spans->len; | - |
4393 | int sx = (xoff + spans->x) % image_width; | - |
4394 | int sy = (spans->y + yoff) % image_height; | - |
4395 | if (sx < 0) | - |
4396 | sx += image_width; | - |
4397 | if (sy < 0) | - |
4398 | sy += image_height; | - |
4399 | | - |
4400 | const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; | - |
4401 | while (length) { | - |
4402 | int l = qMin(image_width - sx, length); | - |
4403 | if (buffer_size < l) | - |
4404 | l = buffer_size; | - |
4405 | const uint *src = op.srcFetch(src_buffer, &op, data, sy, sx, l); | - |
4406 | uint *dest = op.destFetch ? op.destFetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer; | - |
4407 | op.func(dest, src, l, coverage); | - |
4408 | if (op.destStore) | - |
4409 | op.destStore(data->rasterBuffer, x, spans->y, dest, l); | - |
4410 | x += l; | - |
4411 | sx += l; | - |
4412 | length -= l; | - |
4413 | if (sx >= image_width) | - |
4414 | sx = 0; | - |
4415 | } | - |
4416 | ++spans; | - |
4417 | } | - |
4418 | } | - |
4419 | | - |
4420 | static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userData) | - |
4421 | { | - |
4422 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
4423 | | - |
4424 | Operator op = getOperator(data, spans, count); | - |
4425 | if (!op.func64) { | - |
4426 | qDebug("unsupported rgb64 blend"); | - |
4427 | return blend_tiled_generic(count, spans, userData); | - |
4428 | } | - |
4429 | QRgba64 buffer[buffer_size]; | - |
4430 | QRgba64 src_buffer[buffer_size]; | - |
4431 | | - |
4432 | const int image_width = data->texture.width; | - |
4433 | const int image_height = data->texture.height; | - |
4434 | int xoff = -qRound(-data->dx) % image_width; | - |
4435 | int yoff = -qRound(-data->dy) % image_height; | - |
4436 | | - |
4437 | if (xoff < 0) | - |
4438 | xoff += image_width; | - |
4439 | if (yoff < 0) | - |
4440 | yoff += image_height; | - |
4441 | | - |
4442 | while (count--) { | - |
4443 | int x = spans->x; | - |
4444 | int length = spans->len; | - |
4445 | int sx = (xoff + spans->x) % image_width; | - |
4446 | int sy = (spans->y + yoff) % image_height; | - |
4447 | if (sx < 0) | - |
4448 | sx += image_width; | - |
4449 | if (sy < 0) | - |
4450 | sy += image_height; | - |
4451 | | - |
4452 | const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; | - |
4453 | while (length) { | - |
4454 | int l = qMin(image_width - sx, length); | - |
4455 | if (buffer_size < l) | - |
4456 | l = buffer_size; | - |
4457 | const QRgba64 *src = op.srcFetch64(src_buffer, &op, data, sy, sx, l); | - |
4458 | QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); | - |
4459 | op.func64(dest, src, l, coverage); | - |
4460 | op.destStore64(data->rasterBuffer, x, spans->y, dest, l); | - |
4461 | x += l; | - |
4462 | sx += l; | - |
4463 | length -= l; | - |
4464 | if (sx >= image_width) | - |
4465 | sx = 0; | - |
4466 | } | - |
4467 | ++spans; | - |
4468 | } | - |
4469 | } | - |
4470 | | - |
4471 | static void blend_tiled_argb(int count, const QSpan *spans, void *userData) | - |
4472 | { | - |
4473 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
4474 | if (data->texture.format != QImage::Format_ARGB32_Premultiplied | - |
4475 | && data->texture.format != QImage::Format_RGB32) { | - |
4476 | blend_tiled_generic(count, spans, userData); | - |
4477 | return; | - |
4478 | } | - |
4479 | | - |
4480 | Operator op = getOperator(data, spans, count); | - |
4481 | | - |
4482 | int image_width = data->texture.width; | - |
4483 | int image_height = data->texture.height; | - |
4484 | int xoff = -qRound(-data->dx) % image_width; | - |
4485 | int yoff = -qRound(-data->dy) % image_height; | - |
4486 | | - |
4487 | if (xoff < 0) | - |
4488 | xoff += image_width; | - |
4489 | if (yoff < 0) | - |
4490 | yoff += image_height; | - |
4491 | | - |
4492 | while (count--) { | - |
4493 | int x = spans->x; | - |
4494 | int length = spans->len; | - |
4495 | int sx = (xoff + spans->x) % image_width; | - |
4496 | int sy = (spans->y + yoff) % image_height; | - |
4497 | if (sx < 0) | - |
4498 | sx += image_width; | - |
4499 | if (sy < 0) | - |
4500 | sy += image_height; | - |
4501 | | - |
4502 | const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; | - |
4503 | while (length) { | - |
4504 | int l = qMin(image_width - sx, length); | - |
4505 | if (buffer_size < l) | - |
4506 | l = buffer_size; | - |
4507 | const uint *src = (const uint *)data->texture.scanLine(sy) + sx; | - |
4508 | uint *dest = ((uint *)data->rasterBuffer->scanLine(spans->y)) + x; | - |
4509 | op.func(dest, src, l, coverage); | - |
4510 | x += l; | - |
4511 | sx += l; | - |
4512 | length -= l; | - |
4513 | if (sx >= image_width) | - |
4514 | sx = 0; | - |
4515 | } | - |
4516 | ++spans; | - |
4517 | } | - |
4518 | } | - |
4519 | | - |
4520 | static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) | - |
4521 | { | - |
4522 | QSpanData *data = reinterpret_cast<QSpanData*>(userData); | - |
4523 | QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; | - |
4524 | | - |
4525 | if (data->texture.format != QImage::Format_RGB16 | - |
4526 | || (mode != QPainter::CompositionMode_SourceOver | - |
4527 | && mode != QPainter::CompositionMode_Source)) | - |
4528 | { | - |
4529 | blend_tiled_generic(count, spans, userData); | - |
4530 | return; | - |
4531 | } | - |
4532 | | - |
4533 | const int image_width = data->texture.width; | - |
4534 | const int image_height = data->texture.height; | - |
4535 | int xoff = -qRound(-data->dx) % image_width; | - |
4536 | int yoff = -qRound(-data->dy) % image_height; | - |
4537 | | - |
4538 | if (xoff < 0) | - |
4539 | xoff += image_width; | - |
4540 | if (yoff < 0) | - |
4541 | yoff += image_height; | - |
4542 | | - |
4543 | while (count--) { | - |
4544 | const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; | - |
4545 | if (coverage == 0) { | - |
4546 | ++spans; | - |
4547 | continue; | - |
4548 | } | - |
4549 | | - |
4550 | int x = spans->x; | - |
4551 | int length = spans->len; | - |
4552 | int sx = (xoff + spans->x) % image_width; | - |
4553 | int sy = (spans->y + yoff) % image_height; | - |
4554 | if (sx < 0) | - |
4555 | sx += image_width; | - |
4556 | if (sy < 0) | - |
4557 | sy += image_height; | - |
4558 | | - |
4559 | if (coverage == 255) { | - |
4560 | | - |
4561 | length = qMin(image_width,length); | - |
4562 | int tx = x; | - |
4563 | while (length) { | - |
4564 | int l = qMin(image_width - sx, length); | - |
4565 | if (buffer_size < l) | - |
4566 | l = buffer_size; | - |
4567 | quint16 *dest = ((quint16 *)data->rasterBuffer->scanLine(spans->y)) + tx; | - |
4568 | const quint16 *src = (const quint16 *)data->texture.scanLine(sy) + sx; | - |
4569 | memcpy(dest, src, l * sizeof(quint16)); | - |
4570 | length -= l; | - |
4571 | tx += l; | - |
4572 | sx += l; | - |
4573 | if (sx >= image_width) | - |
4574 | sx = 0; | - |
4575 | } | - |
4576 | | - |
4577 | | - |
4578 | | - |
4579 | | - |
4580 | | - |
4581 | | - |
4582 | | - |
4583 | int copy_image_width = qMin(image_width, int(spans->len)); | - |
4584 | length = spans->len - copy_image_width; | - |
4585 | quint16 *src = ((quint16 *)data->rasterBuffer->scanLine(spans->y)) + x; | - |
4586 | quint16 *dest = src + copy_image_width; | - |
4587 | while (copy_image_width < length) { | - |
4588 | memcpy(dest, src, copy_image_width * sizeof(quint16)); | - |
4589 | dest += copy_image_width; | - |
4590 | length -= copy_image_width; | - |
4591 | copy_image_width *= 2; | - |
4592 | } | - |
4593 | if (length > 0) | - |
4594 | memcpy(dest, src, length * sizeof(quint16)); | - |
4595 | } else { | - |
4596 | const quint8 alpha = (coverage + 1) >> 3; | - |
4597 | const quint8 ialpha = 0x20 - alpha; | - |
4598 | if (alpha > 0) { | - |
4599 | while (length) { | - |
4600 | int l = qMin(image_width - sx, length); | - |
4601 | if (buffer_size < l) | - |
4602 | l = buffer_size; | - |
4603 | quint16 *dest = ((quint16 *)data->rasterBuffer->scanLine(spans->y)) + x; | - |
4604 | const quint16 *src = (const quint16 *)data->texture.scanLine(sy) + sx; | - |
4605 | blend_sourceOver_rgb16_rgb16(dest, src, l, alpha, ialpha); | - |
4606 | x += l; | - |
4607 | sx += l; | - |
4608 | length -= l; | - |
4609 | if (sx >= image_width) | - |
4610 | sx = 0; | - |
4611 | } | - |
4612 | } | - |
4613 | } | - |
4614 | ++spans; | - |
4615 | } | - |
4616 | } | - |
4617 | | - |
4618 | static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans, void *userData) | - |
4619 | { | - |
4620 | QSpanData *data = reinterpret_cast<QSpanData*>(userData); | - |
4621 | QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; | - |
4622 | | - |
4623 | if (data->texture.format != QImage::Format_RGB16 | - |
4624 | || (mode != QPainter::CompositionMode_SourceOver | - |
4625 | && mode != QPainter::CompositionMode_Source)) | - |
4626 | { | - |
4627 | blend_src_generic(count, spans, userData); | - |
4628 | return; | - |
4629 | } | - |
4630 | | - |
4631 | quint16 buffer[buffer_size]; | - |
4632 | | - |
4633 | const int src_minx = data->texture.x1; | - |
4634 | const int src_miny = data->texture.y1; | - |
4635 | const int src_maxx = data->texture.x2 - 1; | - |
4636 | const int src_maxy = data->texture.y2 - 1; | - |
4637 | | - |
4638 | if (data->fast_matrix) { | - |
4639 | | - |
4640 | const int fdx = (int)(data->m11 * fixed_scale); | - |
4641 | const int fdy = (int)(data->m12 * fixed_scale); | - |
4642 | | - |
4643 | while (count--) { | - |
4644 | const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; | - |
4645 | const quint8 alpha = (coverage + 1) >> 3; | - |
4646 | const quint8 ialpha = 0x20 - alpha; | - |
4647 | if (alpha == 0) { | - |
4648 | ++spans; | - |
4649 | continue; | - |
4650 | } | - |
4651 | | - |
4652 | quint16 *dest = (quint16 *)data->rasterBuffer->scanLine(spans->y) + spans->x; | - |
4653 | const qreal cx = spans->x + qreal(0.5); | - |
4654 | const qreal cy = spans->y + qreal(0.5); | - |
4655 | int x = int((data->m21 * cy | - |
4656 | + data->m11 * cx + data->dx) * fixed_scale) - half_point; | - |
4657 | int y = int((data->m22 * cy | - |
4658 | + data->m12 * cx + data->dy) * fixed_scale) - half_point; | - |
4659 | int length = spans->len; | - |
4660 | | - |
4661 | while (length) { | - |
4662 | int l; | - |
4663 | quint16 *b; | - |
4664 | if (ialpha == 0) { | - |
4665 | l = length; | - |
4666 | b = dest; | - |
4667 | } else { | - |
4668 | l = qMin(length, buffer_size); | - |
4669 | b = buffer; | - |
4670 | } | - |
4671 | const quint16 *end = b + l; | - |
4672 | | - |
4673 | while (b < end) { | - |
4674 | int x1 = (x >> 16); | - |
4675 | int x2; | - |
4676 | int y1 = (y >> 16); | - |
4677 | int y2; | - |
4678 | | - |
4679 | fetchTransformedBilinear_pixelBounds<BlendTransformedBilinear>(0, src_minx, src_maxx, x1, x2); | - |
4680 | fetchTransformedBilinear_pixelBounds<BlendTransformedBilinear>(0, src_miny, src_maxy, y1, y2); | - |
4681 | | - |
4682 | const quint16 *src1 = (const quint16*)data->texture.scanLine(y1); | - |
4683 | const quint16 *src2 = (const quint16*)data->texture.scanLine(y2); | - |
4684 | quint16 tl = src1[x1]; | - |
4685 | const quint16 tr = src1[x2]; | - |
4686 | quint16 bl = src2[x1]; | - |
4687 | const quint16 br = src2[x2]; | - |
4688 | | - |
4689 | const uint distxsl8 = x & 0xff00; | - |
4690 | const uint distysl8 = y & 0xff00; | - |
4691 | const uint distx = distxsl8 >> 8; | - |
4692 | const uint disty = distysl8 >> 8; | - |
4693 | const uint distxy = distx * disty; | - |
4694 | | - |
4695 | const uint tlw = 0x10000 - distxsl8 - distysl8 + distxy; | - |
4696 | const uint trw = distxsl8 - distxy; | - |
4697 | const uint blw = distysl8 - distxy; | - |
4698 | const uint brw = distxy; | - |
4699 | uint red = ((tl & 0xf800) * tlw + (tr & 0xf800) * trw | - |
4700 | + (bl & 0xf800) * blw + (br & 0xf800) * brw) & 0xf8000000; | - |
4701 | uint green = ((tl & 0x07e0) * tlw + (tr & 0x07e0) * trw | - |
4702 | + (bl & 0x07e0) * blw + (br & 0x07e0) * brw) & 0x07e00000; | - |
4703 | uint blue = ((tl & 0x001f) * tlw + (tr & 0x001f) * trw | - |
4704 | + (bl & 0x001f) * blw + (br & 0x001f) * brw); | - |
4705 | *b = quint16((red | green | blue) >> 16); | - |
4706 | | - |
4707 | ++b; | - |
4708 | x += fdx; | - |
4709 | y += fdy; | - |
4710 | } | - |
4711 | | - |
4712 | if (ialpha != 0) | - |
4713 | blend_sourceOver_rgb16_rgb16(dest, buffer, l, alpha, ialpha); | - |
4714 | | - |
4715 | dest += l; | - |
4716 | length -= l; | - |
4717 | } | - |
4718 | ++spans; | - |
4719 | } | - |
4720 | } else { | - |
4721 | const qreal fdx = data->m11; | - |
4722 | const qreal fdy = data->m12; | - |
4723 | const qreal fdw = data->m13; | - |
4724 | | - |
4725 | while (count--) { | - |
4726 | const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; | - |
4727 | const quint8 alpha = (coverage + 1) >> 3; | - |
4728 | const quint8 ialpha = 0x20 - alpha; | - |
4729 | if (alpha == 0) { | - |
4730 | ++spans; | - |
4731 | continue; | - |
4732 | } | - |
4733 | | - |
4734 | quint16 *dest = (quint16 *)data->rasterBuffer->scanLine(spans->y) + spans->x; | - |
4735 | | - |
4736 | const qreal cx = spans->x + qreal(0.5); | - |
4737 | const qreal cy = spans->y + qreal(0.5); | - |
4738 | | - |
4739 | qreal x = data->m21 * cy + data->m11 * cx + data->dx; | - |
4740 | qreal y = data->m22 * cy + data->m12 * cx + data->dy; | - |
4741 | qreal w = data->m23 * cy + data->m13 * cx + data->m33; | - |
4742 | | - |
4743 | int length = spans->len; | - |
4744 | while (length) { | - |
4745 | int l; | - |
4746 | quint16 *b; | - |
4747 | if (ialpha == 0) { | - |
4748 | l = length; | - |
4749 | b = dest; | - |
4750 | } else { | - |
4751 | l = qMin(length, buffer_size); | - |
4752 | b = buffer; | - |
4753 | } | - |
4754 | const quint16 *end = b + l; | - |
4755 | | - |
4756 | while (b < end) { | - |
4757 | const qreal iw = w == 0 ? 1 : 1 / w; | - |
4758 | const qreal px = x * iw - qreal(0.5); | - |
4759 | const qreal py = y * iw - qreal(0.5); | - |
4760 | | - |
4761 | int x1 = int(px) - (px < 0); | - |
4762 | int x2; | - |
4763 | int y1 = int(py) - (py < 0); | - |
4764 | int y2; | - |
4765 | | - |
4766 | fetchTransformedBilinear_pixelBounds<BlendTransformedBilinear>(0, src_minx, src_maxx, x1, x2); | - |
4767 | fetchTransformedBilinear_pixelBounds<BlendTransformedBilinear>(0, src_miny, src_maxy, y1, y2); | - |
4768 | | - |
4769 | const quint16 *src1 = (const quint16 *)data->texture.scanLine(y1); | - |
4770 | const quint16 *src2 = (const quint16 *)data->texture.scanLine(y2); | - |
4771 | quint16 tl = src1[x1]; | - |
4772 | const quint16 tr = src1[x2]; | - |
4773 | quint16 bl = src2[x1]; | - |
4774 | const quint16 br = src2[x2]; | - |
4775 | | - |
4776 | const uint distx = uint((px - x1) * 256); | - |
4777 | const uint disty = uint((py - y1) * 256); | - |
4778 | const uint distxsl8 = distx << 8; | - |
4779 | const uint distysl8 = disty << 8; | - |
4780 | const uint distxy = distx * disty; | - |
4781 | | - |
4782 | const uint tlw = 0x10000 - distxsl8 - distysl8 + distxy; | - |
4783 | const uint trw = distxsl8 - distxy; | - |
4784 | const uint blw = distysl8 - distxy; | - |
4785 | const uint brw = distxy; | - |
4786 | uint red = ((tl & 0xf800) * tlw + (tr & 0xf800) * trw | - |
4787 | + (bl & 0xf800) * blw + (br & 0xf800) * brw) & 0xf8000000; | - |
4788 | uint green = ((tl & 0x07e0) * tlw + (tr & 0x07e0) * trw | - |
4789 | + (bl & 0x07e0) * blw + (br & 0x07e0) * brw) & 0x07e00000; | - |
4790 | uint blue = ((tl & 0x001f) * tlw + (tr & 0x001f) * trw | - |
4791 | + (bl & 0x001f) * blw + (br & 0x001f) * brw); | - |
4792 | *b = quint16((red | green | blue) >> 16); | - |
4793 | | - |
4794 | ++b; | - |
4795 | x += fdx; | - |
4796 | y += fdy; | - |
4797 | w += fdw; | - |
4798 | } | - |
4799 | | - |
4800 | if (ialpha != 0) | - |
4801 | blend_sourceOver_rgb16_rgb16(dest, buffer, l, alpha, ialpha); | - |
4802 | | - |
4803 | dest += l; | - |
4804 | length -= l; | - |
4805 | } | - |
4806 | ++spans; | - |
4807 | } | - |
4808 | } | - |
4809 | } | - |
4810 | | - |
4811 | static void blend_transformed_argb(int count, const QSpan *spans, void *userData) | - |
4812 | { | - |
4813 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
4814 | if (data->texture.format != QImage::Format_ARGB32_Premultiplied | - |
4815 | && data->texture.format != QImage::Format_RGB32) { | - |
4816 | blend_src_generic(count, spans, userData); | - |
4817 | return; | - |
4818 | } | - |
4819 | | - |
4820 | CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; | - |
4821 | uint buffer[buffer_size]; | - |
4822 | | - |
4823 | int image_width = data->texture.width; | - |
4824 | int image_height = data->texture.height; | - |
4825 | | - |
4826 | if (data->fast_matrix) { | - |
4827 | | - |
4828 | int fdx = (int)(data->m11 * fixed_scale); | - |
4829 | int fdy = (int)(data->m12 * fixed_scale); | - |
4830 | | - |
4831 | while (count--) { | - |
4832 | void *t = data->rasterBuffer->scanLine(spans->y); | - |
4833 | | - |
4834 | uint *target = ((uint *)t) + spans->x; | - |
4835 | | - |
4836 | const qreal cx = spans->x + qreal(0.5); | - |
4837 | const qreal cy = spans->y + qreal(0.5); | - |
4838 | | - |
4839 | int x = int((data->m21 * cy | - |
4840 | + data->m11 * cx + data->dx) * fixed_scale); | - |
4841 | int y = int((data->m22 * cy | - |
4842 | + data->m12 * cx + data->dy) * fixed_scale); | - |
4843 | | - |
4844 | int length = spans->len; | - |
4845 | const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; | - |
4846 | while (length) { | - |
4847 | int l = qMin(length, buffer_size); | - |
4848 | const uint *end = buffer + l; | - |
4849 | uint *b = buffer; | - |
4850 | while (b < end) { | - |
4851 | int px = qBound(0, x >> 16, image_width - 1); | - |
4852 | int py = qBound(0, y >> 16, image_height - 1); | - |
4853 | *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px]; | - |
4854 | | - |
4855 | x += fdx; | - |
4856 | y += fdy; | - |
4857 | ++b; | - |
4858 | } | - |
4859 | func(target, buffer, l, coverage); | - |
4860 | target += l; | - |
4861 | length -= l; | - |
4862 | } | - |
4863 | ++spans; | - |
4864 | } | - |
4865 | } else { | - |
4866 | const qreal fdx = data->m11; | - |
4867 | const qreal fdy = data->m12; | - |
4868 | const qreal fdw = data->m13; | - |
4869 | while (count--) { | - |
4870 | void *t = data->rasterBuffer->scanLine(spans->y); | - |
4871 | | - |
4872 | uint *target = ((uint *)t) + spans->x; | - |
4873 | | - |
4874 | const qreal cx = spans->x + qreal(0.5); | - |
4875 | const qreal cy = spans->y + qreal(0.5); | - |
4876 | | - |
4877 | qreal x = data->m21 * cy + data->m11 * cx + data->dx; | - |
4878 | qreal y = data->m22 * cy + data->m12 * cx + data->dy; | - |
4879 | qreal w = data->m23 * cy + data->m13 * cx + data->m33; | - |
4880 | | - |
4881 | int length = spans->len; | - |
4882 | const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; | - |
4883 | while (length) { | - |
4884 | int l = qMin(length, buffer_size); | - |
4885 | const uint *end = buffer + l; | - |
4886 | uint *b = buffer; | - |
4887 | while (b < end) { | - |
4888 | const qreal iw = w == 0 ? 1 : 1 / w; | - |
4889 | const qreal tx = x * iw; | - |
4890 | const qreal ty = y * iw; | - |
4891 | const int px = qBound(0, int(tx) - (tx < 0), image_width - 1); | - |
4892 | const int py = qBound(0, int(ty) - (ty < 0), image_height - 1); | - |
4893 | | - |
4894 | *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px]; | - |
4895 | x += fdx; | - |
4896 | y += fdy; | - |
4897 | w += fdw; | - |
4898 | | - |
4899 | ++b; | - |
4900 | } | - |
4901 | func(target, buffer, l, coverage); | - |
4902 | target += l; | - |
4903 | length -= l; | - |
4904 | } | - |
4905 | ++spans; | - |
4906 | } | - |
4907 | } | - |
4908 | } | - |
4909 | | - |
4910 | static void blend_transformed_rgb565(int count, const QSpan *spans, void *userData) | - |
4911 | { | - |
4912 | QSpanData *data = reinterpret_cast<QSpanData*>(userData); | - |
4913 | QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; | - |
4914 | | - |
4915 | if (data->texture.format != QImage::Format_RGB16 | - |
4916 | || (mode != QPainter::CompositionMode_SourceOver | - |
4917 | && mode != QPainter::CompositionMode_Source)) | - |
4918 | { | - |
4919 | blend_src_generic(count, spans, userData); | - |
4920 | return; | - |
4921 | } | - |
4922 | | - |
4923 | quint16 buffer[buffer_size]; | - |
4924 | const int image_width = data->texture.width; | - |
4925 | const int image_height = data->texture.height; | - |
4926 | | - |
4927 | if (data->fast_matrix) { | - |
4928 | | - |
4929 | const int fdx = (int)(data->m11 * fixed_scale); | - |
4930 | const int fdy = (int)(data->m12 * fixed_scale); | - |
4931 | | - |
4932 | while (count--) { | - |
4933 | const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; | - |
4934 | const quint8 alpha = (coverage + 1) >> 3; | - |
4935 | const quint8 ialpha = 0x20 - alpha; | - |
4936 | if (alpha == 0) { | - |
4937 | ++spans; | - |
4938 | continue; | - |
4939 | } | - |
4940 | | - |
4941 | quint16 *dest = (quint16 *)data->rasterBuffer->scanLine(spans->y) + spans->x; | - |
4942 | const qreal cx = spans->x + qreal(0.5); | - |
4943 | const qreal cy = spans->y + qreal(0.5); | - |
4944 | int x = int((data->m21 * cy | - |
4945 | + data->m11 * cx + data->dx) * fixed_scale); | - |
4946 | int y = int((data->m22 * cy | - |
4947 | + data->m12 * cx + data->dy) * fixed_scale); | - |
4948 | int length = spans->len; | - |
4949 | | - |
4950 | while (length) { | - |
4951 | int l; | - |
4952 | quint16 *b; | - |
4953 | if (ialpha == 0) { | - |
4954 | l = length; | - |
4955 | b = dest; | - |
4956 | } else { | - |
4957 | l = qMin(length, buffer_size); | - |
4958 | b = buffer; | - |
4959 | } | - |
4960 | const quint16 *end = b + l; | - |
4961 | | - |
4962 | while (b < end) { | - |
4963 | const int px = qBound(0, x >> 16, image_width - 1); | - |
4964 | const int py = qBound(0, y >> 16, image_height - 1); | - |
4965 | | - |
4966 | *b = ((const quint16 *)data->texture.scanLine(py))[px]; | - |
4967 | ++b; | - |
4968 | | - |
4969 | x += fdx; | - |
4970 | y += fdy; | - |
4971 | } | - |
4972 | | - |
4973 | if (ialpha != 0) | - |
4974 | blend_sourceOver_rgb16_rgb16(dest, buffer, l, alpha, ialpha); | - |
4975 | | - |
4976 | dest += l; | - |
4977 | length -= l; | - |
4978 | } | - |
4979 | ++spans; | - |
4980 | } | - |
4981 | } else { | - |
4982 | const qreal fdx = data->m11; | - |
4983 | const qreal fdy = data->m12; | - |
4984 | const qreal fdw = data->m13; | - |
4985 | | - |
4986 | while (count--) { | - |
4987 | const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; | - |
4988 | const quint8 alpha = (coverage + 1) >> 3; | - |
4989 | const quint8 ialpha = 0x20 - alpha; | - |
4990 | if (alpha == 0) { | - |
4991 | ++spans; | - |
4992 | continue; | - |
4993 | } | - |
4994 | | - |
4995 | quint16 *dest = (quint16 *)data->rasterBuffer->scanLine(spans->y) + spans->x; | - |
4996 | | - |
4997 | const qreal cx = spans->x + qreal(0.5); | - |
4998 | const qreal cy = spans->y + qreal(0.5); | - |
4999 | | - |
5000 | qreal x = data->m21 * cy + data->m11 * cx + data->dx; | - |
5001 | qreal y = data->m22 * cy + data->m12 * cx + data->dy; | - |
5002 | qreal w = data->m23 * cy + data->m13 * cx + data->m33; | - |
5003 | | - |
5004 | int length = spans->len; | - |
5005 | while (length) { | - |
5006 | int l; | - |
5007 | quint16 *b; | - |
5008 | if (ialpha == 0) { | - |
5009 | l = length; | - |
5010 | b = dest; | - |
5011 | } else { | - |
5012 | l = qMin(length, buffer_size); | - |
5013 | b = buffer; | - |
5014 | } | - |
5015 | const quint16 *end = b + l; | - |
5016 | | - |
5017 | while (b < end) { | - |
5018 | const qreal iw = w == 0 ? 1 : 1 / w; | - |
5019 | const qreal tx = x * iw; | - |
5020 | const qreal ty = y * iw; | - |
5021 | | - |
5022 | const int px = qBound(0, int(tx) - (tx < 0), image_width - 1); | - |
5023 | const int py = qBound(0, int(ty) - (ty < 0), image_height - 1); | - |
5024 | | - |
5025 | *b = ((const quint16 *)data->texture.scanLine(py))[px]; | - |
5026 | ++b; | - |
5027 | | - |
5028 | x += fdx; | - |
5029 | y += fdy; | - |
5030 | w += fdw; | - |
5031 | } | - |
5032 | | - |
5033 | if (ialpha != 0) | - |
5034 | blend_sourceOver_rgb16_rgb16(dest, buffer, l, alpha, ialpha); | - |
5035 | | - |
5036 | dest += l; | - |
5037 | length -= l; | - |
5038 | } | - |
5039 | ++spans; | - |
5040 | } | - |
5041 | } | - |
5042 | } | - |
5043 | | - |
5044 | static void blend_transformed_tiled_argb(int count, const QSpan *spans, void *userData) | - |
5045 | { | - |
5046 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
5047 | if (data->texture.format != QImage::Format_ARGB32_Premultiplied | - |
5048 | && data->texture.format != QImage::Format_RGB32) { | - |
5049 | blend_src_generic(count, spans, userData); | - |
5050 | return; | - |
5051 | } | - |
5052 | | - |
5053 | CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; | - |
5054 | uint buffer[buffer_size]; | - |
5055 | | - |
5056 | int image_width = data->texture.width; | - |
5057 | int image_height = data->texture.height; | - |
5058 | const int scanline_offset = data->texture.bytesPerLine / 4; | - |
5059 | | - |
5060 | if (data->fast_matrix) { | - |
5061 | | - |
5062 | int fdx = (int)(data->m11 * fixed_scale); | - |
5063 | int fdy = (int)(data->m12 * fixed_scale); | - |
5064 | | - |
5065 | while (count--) { | - |
5066 | void *t = data->rasterBuffer->scanLine(spans->y); | - |
5067 | | - |
5068 | uint *target = ((uint *)t) + spans->x; | - |
5069 | const uint *image_bits = (const uint *)data->texture.imageData; | - |
5070 | | - |
5071 | const qreal cx = spans->x + qreal(0.5); | - |
5072 | const qreal cy = spans->y + qreal(0.5); | - |
5073 | | - |
5074 | int x = int((data->m21 * cy | - |
5075 | + data->m11 * cx + data->dx) * fixed_scale); | - |
5076 | int y = int((data->m22 * cy | - |
5077 | + data->m12 * cx + data->dy) * fixed_scale); | - |
5078 | | - |
5079 | const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; | - |
5080 | int length = spans->len; | - |
5081 | while (length) { | - |
5082 | int l = qMin(length, buffer_size); | - |
5083 | const uint *end = buffer + l; | - |
5084 | uint *b = buffer; | - |
5085 | int px16 = x % (image_width << 16); | - |
5086 | int py16 = y % (image_height << 16); | - |
5087 | int px_delta = fdx % (image_width << 16); | - |
5088 | int py_delta = fdy % (image_height << 16); | - |
5089 | while (b < end) { | - |
5090 | if (px16 < 0) px16 += image_width << 16; | - |
5091 | if (py16 < 0) py16 += image_height << 16; | - |
5092 | int px = px16 >> 16; | - |
5093 | int py = py16 >> 16; | - |
5094 | int y_offset = py * scanline_offset; | - |
5095 | | - |
5096 | Q_ASSERT(px >= 0 && px < image_width); | - |
5097 | Q_ASSERT(py >= 0 && py < image_height); | - |
5098 | | - |
5099 | *b = image_bits[y_offset + px]; | - |
5100 | x += fdx; | - |
5101 | y += fdy; | - |
5102 | px16 += px_delta; | - |
5103 | if (px16 >= image_width << 16) | - |
5104 | px16 -= image_width << 16; | - |
5105 | py16 += py_delta; | - |
5106 | if (py16 >= image_height << 16) | - |
5107 | py16 -= image_height << 16; | - |
5108 | ++b; | - |
5109 | } | - |
5110 | func(target, buffer, l, coverage); | - |
5111 | target += l; | - |
5112 | length -= l; | - |
5113 | } | - |
5114 | ++spans; | - |
5115 | } | - |
5116 | } else { | - |
5117 | const qreal fdx = data->m11; | - |
5118 | const qreal fdy = data->m12; | - |
5119 | const qreal fdw = data->m13; | - |
5120 | while (count--) { | - |
5121 | void *t = data->rasterBuffer->scanLine(spans->y); | - |
5122 | | - |
5123 | uint *target = ((uint *)t) + spans->x; | - |
5124 | const uint *image_bits = (const uint *)data->texture.imageData; | - |
5125 | | - |
5126 | const qreal cx = spans->x + qreal(0.5); | - |
5127 | const qreal cy = spans->y + qreal(0.5); | - |
5128 | | - |
5129 | qreal x = data->m21 * cy + data->m11 * cx + data->dx; | - |
5130 | qreal y = data->m22 * cy + data->m12 * cx + data->dy; | - |
5131 | qreal w = data->m23 * cy + data->m13 * cx + data->m33; | - |
5132 | | - |
5133 | const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; | - |
5134 | int length = spans->len; | - |
5135 | while (length) { | - |
5136 | int l = qMin(length, buffer_size); | - |
5137 | const uint *end = buffer + l; | - |
5138 | uint *b = buffer; | - |
5139 | while (b < end) { | - |
5140 | const qreal iw = w == 0 ? 1 : 1 / w; | - |
5141 | const qreal tx = x * iw; | - |
5142 | const qreal ty = y * iw; | - |
5143 | int px = int(tx) - (tx < 0); | - |
5144 | int py = int(ty) - (ty < 0); | - |
5145 | | - |
5146 | px %= image_width; | - |
5147 | py %= image_height; | - |
5148 | if (px < 0) px += image_width; | - |
5149 | if (py < 0) py += image_height; | - |
5150 | int y_offset = py * scanline_offset; | - |
5151 | | - |
5152 | Q_ASSERT(px >= 0 && px < image_width); | - |
5153 | Q_ASSERT(py >= 0 && py < image_height); | - |
5154 | | - |
5155 | *b = image_bits[y_offset + px]; | - |
5156 | x += fdx; | - |
5157 | y += fdy; | - |
5158 | w += fdw; | - |
5159 | | - |
5160 | if (!w) { | - |
5161 | w += fdw; | - |
5162 | } | - |
5163 | ++b; | - |
5164 | } | - |
5165 | func(target, buffer, l, coverage); | - |
5166 | target += l; | - |
5167 | length -= l; | - |
5168 | } | - |
5169 | ++spans; | - |
5170 | } | - |
5171 | } | - |
5172 | } | - |
5173 | | - |
5174 | static void blend_transformed_tiled_rgb565(int count, const QSpan *spans, void *userData) | - |
5175 | { | - |
5176 | QSpanData *data = reinterpret_cast<QSpanData*>(userData); | - |
5177 | QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; | - |
5178 | | - |
5179 | if (data->texture.format != QImage::Format_RGB16 | - |
5180 | || (mode != QPainter::CompositionMode_SourceOver | - |
5181 | && mode != QPainter::CompositionMode_Source)) | - |
5182 | { | - |
5183 | blend_src_generic(count, spans, userData); | - |
5184 | return; | - |
5185 | } | - |
5186 | | - |
5187 | quint16 buffer[buffer_size]; | - |
5188 | const int image_width = data->texture.width; | - |
5189 | const int image_height = data->texture.height; | - |
5190 | | - |
5191 | if (data->fast_matrix) { | - |
5192 | | - |
5193 | const int fdx = (int)(data->m11 * fixed_scale); | - |
5194 | const int fdy = (int)(data->m12 * fixed_scale); | - |
5195 | | - |
5196 | while (count--) { | - |
5197 | const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; | - |
5198 | const quint8 alpha = (coverage + 1) >> 3; | - |
5199 | const quint8 ialpha = 0x20 - alpha; | - |
5200 | if (alpha == 0) { | - |
5201 | ++spans; | - |
5202 | continue; | - |
5203 | } | - |
5204 | | - |
5205 | quint16 *dest = (quint16 *)data->rasterBuffer->scanLine(spans->y) + spans->x; | - |
5206 | const qreal cx = spans->x + qreal(0.5); | - |
5207 | const qreal cy = spans->y + qreal(0.5); | - |
5208 | int x = int((data->m21 * cy | - |
5209 | + data->m11 * cx + data->dx) * fixed_scale); | - |
5210 | int y = int((data->m22 * cy | - |
5211 | + data->m12 * cx + data->dy) * fixed_scale); | - |
5212 | int length = spans->len; | - |
5213 | | - |
5214 | while (length) { | - |
5215 | int l; | - |
5216 | quint16 *b; | - |
5217 | if (ialpha == 0) { | - |
5218 | l = length; | - |
5219 | b = dest; | - |
5220 | } else { | - |
5221 | l = qMin(length, buffer_size); | - |
5222 | b = buffer; | - |
5223 | } | - |
5224 | const quint16 *end = b + l; | - |
5225 | | - |
5226 | while (b < end) { | - |
5227 | int px = (x >> 16) % image_width; | - |
5228 | int py = (y >> 16) % image_height; | - |
5229 | | - |
5230 | if (px < 0) | - |
5231 | px += image_width; | - |
5232 | if (py < 0) | - |
5233 | py += image_height; | - |
5234 | | - |
5235 | *b = ((const quint16 *)data->texture.scanLine(py))[px]; | - |
5236 | ++b; | - |
5237 | | - |
5238 | x += fdx; | - |
5239 | y += fdy; | - |
5240 | } | - |
5241 | | - |
5242 | if (ialpha != 0) | - |
5243 | blend_sourceOver_rgb16_rgb16(dest, buffer, l, alpha, ialpha); | - |
5244 | | - |
5245 | dest += l; | - |
5246 | length -= l; | - |
5247 | } | - |
5248 | ++spans; | - |
5249 | } | - |
5250 | } else { | - |
5251 | const qreal fdx = data->m11; | - |
5252 | const qreal fdy = data->m12; | - |
5253 | const qreal fdw = data->m13; | - |
5254 | | - |
5255 | while (count--) { | - |
5256 | const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; | - |
5257 | const quint8 alpha = (coverage + 1) >> 3; | - |
5258 | const quint8 ialpha = 0x20 - alpha; | - |
5259 | if (alpha == 0) { | - |
5260 | ++spans; | - |
5261 | continue; | - |
5262 | } | - |
5263 | | - |
5264 | quint16 *dest = (quint16 *)data->rasterBuffer->scanLine(spans->y) + spans->x; | - |
5265 | | - |
5266 | const qreal cx = spans->x + qreal(0.5); | - |
5267 | const qreal cy = spans->y + qreal(0.5); | - |
5268 | | - |
5269 | qreal x = data->m21 * cy + data->m11 * cx + data->dx; | - |
5270 | qreal y = data->m22 * cy + data->m12 * cx + data->dy; | - |
5271 | qreal w = data->m23 * cy + data->m13 * cx + data->m33; | - |
5272 | | - |
5273 | int length = spans->len; | - |
5274 | while (length) { | - |
5275 | int l; | - |
5276 | quint16 *b; | - |
5277 | if (ialpha == 0) { | - |
5278 | l = length; | - |
5279 | b = dest; | - |
5280 | } else { | - |
5281 | l = qMin(length, buffer_size); | - |
5282 | b = buffer; | - |
5283 | } | - |
5284 | const quint16 *end = b + l; | - |
5285 | | - |
5286 | while (b < end) { | - |
5287 | const qreal iw = w == 0 ? 1 : 1 / w; | - |
5288 | const qreal tx = x * iw; | - |
5289 | const qreal ty = y * iw; | - |
5290 | | - |
5291 | int px = int(tx) - (tx < 0); | - |
5292 | int py = int(ty) - (ty < 0); | - |
5293 | | - |
5294 | px %= image_width; | - |
5295 | py %= image_height; | - |
5296 | if (px < 0) | - |
5297 | px += image_width; | - |
5298 | if (py < 0) | - |
5299 | py += image_height; | - |
5300 | | - |
5301 | *b = ((const quint16 *)data->texture.scanLine(py))[px]; | - |
5302 | ++b; | - |
5303 | | - |
5304 | x += fdx; | - |
5305 | y += fdy; | - |
5306 | w += fdw; | - |
5307 | | - |
5308 | if (!w) | - |
5309 | w += fdw; | - |
5310 | } | - |
5311 | | - |
5312 | if (ialpha != 0) | - |
5313 | blend_sourceOver_rgb16_rgb16(dest, buffer, l, alpha, ialpha); | - |
5314 | | - |
5315 | dest += l; | - |
5316 | length -= l; | - |
5317 | } | - |
5318 | ++spans; | - |
5319 | } | - |
5320 | } | - |
5321 | } | - |
5322 | | - |
5323 | | - |
5324 | | - |
5325 | static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats] = { | - |
5326 | | - |
5327 | { | - |
5328 | 0, | - |
5329 | blend_untransformed_generic, | - |
5330 | blend_untransformed_generic, | - |
5331 | blend_untransformed_generic, | - |
5332 | blend_untransformed_generic, | - |
5333 | blend_untransformed_generic, | - |
5334 | blend_untransformed_argb, | - |
5335 | blend_untransformed_rgb565, | - |
5336 | blend_untransformed_generic, | - |
5337 | blend_untransformed_generic, | - |
5338 | blend_untransformed_generic, | - |
5339 | blend_untransformed_generic, | - |
5340 | blend_untransformed_generic, | - |
5341 | blend_untransformed_generic, | - |
5342 | blend_untransformed_generic, | - |
5343 | blend_untransformed_generic, | - |
5344 | blend_untransformed_generic, | - |
5345 | blend_untransformed_generic, | - |
5346 | blend_untransformed_generic, | - |
5347 | blend_untransformed_generic_rgb64, | - |
5348 | blend_untransformed_generic_rgb64, | - |
5349 | blend_untransformed_generic_rgb64, | - |
5350 | blend_untransformed_generic_rgb64, | - |
5351 | blend_untransformed_generic, | - |
5352 | blend_untransformed_generic, | - |
5353 | }, | - |
5354 | | - |
5355 | { | - |
5356 | 0, | - |
5357 | blend_tiled_generic, | - |
5358 | blend_tiled_generic, | - |
5359 | blend_tiled_generic, | - |
5360 | blend_tiled_generic, | - |
5361 | blend_tiled_generic, | - |
5362 | blend_tiled_argb, | - |
5363 | blend_tiled_rgb565, | - |
5364 | blend_tiled_generic, | - |
5365 | blend_tiled_generic, | - |
5366 | blend_tiled_generic, | - |
5367 | blend_tiled_generic, | - |
5368 | blend_tiled_generic, | - |
5369 | blend_tiled_generic, | - |
5370 | blend_tiled_generic, | - |
5371 | blend_tiled_generic, | - |
5372 | blend_tiled_generic, | - |
5373 | blend_tiled_generic, | - |
5374 | blend_tiled_generic, | - |
5375 | blend_tiled_generic_rgb64, | - |
5376 | blend_tiled_generic_rgb64, | - |
5377 | blend_tiled_generic_rgb64, | - |
5378 | blend_tiled_generic_rgb64, | - |
5379 | blend_tiled_generic, | - |
5380 | blend_tiled_generic, | - |
5381 | }, | - |
5382 | | - |
5383 | { | - |
5384 | 0, | - |
5385 | blend_src_generic, | - |
5386 | blend_src_generic, | - |
5387 | blend_src_generic, | - |
5388 | blend_src_generic, | - |
5389 | blend_src_generic, | - |
5390 | blend_transformed_argb, | - |
5391 | blend_transformed_rgb565, | - |
5392 | blend_src_generic, | - |
5393 | blend_src_generic, | - |
5394 | blend_src_generic, | - |
5395 | blend_src_generic, | - |
5396 | blend_src_generic, | - |
5397 | blend_src_generic, | - |
5398 | blend_src_generic, | - |
5399 | blend_src_generic, | - |
5400 | blend_src_generic, | - |
5401 | blend_src_generic, | - |
5402 | blend_src_generic, | - |
5403 | blend_src_generic_rgb64, | - |
5404 | blend_src_generic_rgb64, | - |
5405 | blend_src_generic_rgb64, | - |
5406 | blend_src_generic_rgb64, | - |
5407 | blend_src_generic, | - |
5408 | blend_src_generic, | - |
5409 | }, | - |
5410 | | - |
5411 | { | - |
5412 | 0, | - |
5413 | blend_src_generic, | - |
5414 | blend_src_generic, | - |
5415 | blend_src_generic, | - |
5416 | blend_src_generic, | - |
5417 | blend_src_generic, | - |
5418 | blend_transformed_tiled_argb, | - |
5419 | blend_transformed_tiled_rgb565, | - |
5420 | blend_src_generic, | - |
5421 | blend_src_generic, | - |
5422 | blend_src_generic, | - |
5423 | blend_src_generic, | - |
5424 | blend_src_generic, | - |
5425 | blend_src_generic, | - |
5426 | blend_src_generic, | - |
5427 | blend_src_generic, | - |
5428 | blend_src_generic, | - |
5429 | blend_src_generic, | - |
5430 | blend_src_generic, | - |
5431 | blend_src_generic_rgb64, | - |
5432 | blend_src_generic_rgb64, | - |
5433 | blend_src_generic_rgb64, | - |
5434 | blend_src_generic_rgb64, | - |
5435 | blend_src_generic, | - |
5436 | blend_src_generic, | - |
5437 | }, | - |
5438 | | - |
5439 | { | - |
5440 | 0, | - |
5441 | blend_src_generic, | - |
5442 | blend_src_generic, | - |
5443 | blend_src_generic, | - |
5444 | blend_src_generic, | - |
5445 | blend_src_generic, | - |
5446 | blend_src_generic, | - |
5447 | blend_transformed_bilinear_rgb565, | - |
5448 | blend_src_generic, | - |
5449 | blend_src_generic, | - |
5450 | blend_src_generic, | - |
5451 | blend_src_generic, | - |
5452 | blend_src_generic, | - |
5453 | blend_src_generic, | - |
5454 | blend_src_generic, | - |
5455 | blend_src_generic, | - |
5456 | blend_src_generic, | - |
5457 | blend_src_generic, | - |
5458 | blend_src_generic, | - |
5459 | blend_src_generic_rgb64, | - |
5460 | blend_src_generic_rgb64, | - |
5461 | blend_src_generic_rgb64, | - |
5462 | blend_src_generic_rgb64, | - |
5463 | blend_src_generic, | - |
5464 | blend_src_generic, | - |
5465 | }, | - |
5466 | | - |
5467 | { | - |
5468 | 0, | - |
5469 | blend_src_generic, | - |
5470 | blend_src_generic, | - |
5471 | blend_src_generic, | - |
5472 | blend_src_generic, | - |
5473 | blend_src_generic, | - |
5474 | blend_src_generic, | - |
5475 | blend_src_generic, | - |
5476 | blend_src_generic, | - |
5477 | blend_src_generic, | - |
5478 | blend_src_generic, | - |
5479 | blend_src_generic, | - |
5480 | blend_src_generic, | - |
5481 | blend_src_generic, | - |
5482 | blend_src_generic, | - |
5483 | blend_src_generic, | - |
5484 | blend_src_generic, | - |
5485 | blend_src_generic, | - |
5486 | blend_src_generic, | - |
5487 | blend_src_generic_rgb64, | - |
5488 | blend_src_generic_rgb64, | - |
5489 | blend_src_generic_rgb64, | - |
5490 | blend_src_generic_rgb64, | - |
5491 | blend_src_generic, | - |
5492 | blend_src_generic, | - |
5493 | } | - |
5494 | }; | - |
5495 | | - |
5496 | void qBlendTexture(int count, const QSpan *spans, void *userData) | - |
5497 | { | - |
5498 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
5499 | ProcessSpans proc = processTextureSpans[getBlendType(data)][data->rasterBuffer->format]; | - |
5500 | proc(count, spans, userData); | - |
5501 | } | - |
5502 | | - |
5503 | template <class DST> Q_STATIC_TEMPLATE_FUNCTION | - |
5504 | inline void qt_bitmapblit_template(QRasterBuffer *rasterBuffer, | - |
5505 | int x, int y, DST color, | - |
5506 | const uchar *map, | - |
5507 | int mapWidth, int mapHeight, int mapStride) | - |
5508 | { | - |
5509 | DST *dest = reinterpret_cast<DST *>(rasterBuffer->scanLine(y)) + x; | - |
5510 | const int destStride = rasterBuffer->bytesPerLine() / sizeof(DST); | - |
5511 | | - |
5512 | if (mapWidth > 8) { | - |
5513 | while (mapHeight--) { | - |
5514 | int x0 = 0; | - |
5515 | int n = 0; | - |
5516 | for (int x = 0; x < mapWidth; x += 8) { | - |
5517 | uchar s = map[x >> 3]; | - |
5518 | for (int i = 0; i < 8; ++i) { | - |
5519 | if (s & 0x80) { | - |
5520 | ++n; | - |
5521 | } else { | - |
5522 | if (n) { | - |
5523 | qt_memfill(dest + x0, color, n); | - |
5524 | x0 += n + 1; | - |
5525 | n = 0; | - |
5526 | } else { | - |
5527 | ++x0; | - |
5528 | } | - |
5529 | if (!s) { | - |
5530 | x0 += 8 - 1 - i; | - |
5531 | break; | - |
5532 | } | - |
5533 | } | - |
5534 | s <<= 1; | - |
5535 | } | - |
5536 | } | - |
5537 | if (n) | - |
5538 | qt_memfill(dest + x0, color, n); | - |
5539 | dest += destStride; | - |
5540 | map += mapStride; | - |
5541 | } | - |
5542 | } else { | - |
5543 | while (mapHeight--) { | - |
5544 | int x0 = 0; | - |
5545 | int n = 0; | - |
5546 | for (uchar s = *map; s; s <<= 1) { | - |
5547 | if (s & 0x80) { | - |
5548 | ++n; | - |
5549 | } else if (n) { | - |
5550 | qt_memfill(dest + x0, color, n); | - |
5551 | x0 += n + 1; | - |
5552 | n = 0; | - |
5553 | } else { | - |
5554 | ++x0; | - |
5555 | } | - |
5556 | } | - |
5557 | if (n) | - |
5558 | qt_memfill(dest + x0, color, n); | - |
5559 | dest += destStride; | - |
5560 | map += mapStride; | - |
5561 | } | - |
5562 | } | - |
5563 | } | - |
5564 | | - |
5565 | static void qt_gradient_argb32(int count, const QSpan *spans, void *userData) | - |
5566 | { | - |
5567 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
5568 | | - |
5569 | bool isVerticalGradient = | - |
5570 | data->txop <= QTransform::TxScale && | - |
5571 | data->type == QSpanData::LinearGradient && | - |
5572 | data->gradient.linear.end.x == data->gradient.linear.origin.x; | - |
5573 | | - |
5574 | if (isVerticalGradient) { | - |
5575 | LinearGradientValues linear; | - |
5576 | getLinearGradientValues(&linear, data); | - |
5577 | | - |
5578 | CompositionFunctionSolid funcSolid = | - |
5579 | functionForModeSolid[data->rasterBuffer->compositionMode]; | - |
5580 | | - |
5581 | | - |
5582 | | - |
5583 | | - |
5584 | | - |
5585 | | - |
5586 | | - |
5587 | | - |
5588 | | - |
5589 | | - |
5590 | | - |
5591 | | - |
5592 | | - |
5593 | | - |
5594 | const int gss = GRADIENT_STOPTABLE_SIZE - 1; | - |
5595 | int yinc = int((linear.dy * data->m22 * gss) * FIXPT_SIZE); | - |
5596 | int off = int((((linear.dy * (data->m22 * qreal(0.5) + data->dy) + linear.off) * gss) * FIXPT_SIZE)); | - |
5597 | | - |
5598 | while (count--) { | - |
5599 | int y = spans->y; | - |
5600 | int x = spans->x; | - |
5601 | | - |
5602 | quint32 *dst = (quint32 *)(data->rasterBuffer->scanLine(y)) + x; | - |
5603 | quint32 color = | - |
5604 | qt_gradient_pixel_fixed(&data->gradient, yinc * y + off); | - |
5605 | | - |
5606 | funcSolid(dst, spans->len, color, spans->coverage); | - |
5607 | ++spans; | - |
5608 | } | - |
5609 | | - |
5610 | } else { | - |
5611 | blend_src_generic(count, spans, userData); | - |
5612 | } | - |
5613 | } | - |
5614 | | - |
5615 | static void qt_gradient_quint16(int count, const QSpan *spans, void *userData) | - |
5616 | { | - |
5617 | QSpanData *data = reinterpret_cast<QSpanData *>(userData); | - |
5618 | | - |
5619 | bool isVerticalGradient = | - |
5620 | data->txop <= QTransform::TxScale && | - |
5621 | data->type == QSpanData::LinearGradient && | - |
5622 | data->gradient.linear.end.x == data->gradient.linear.origin.x; | - |
5623 | | - |
5624 | if (isVerticalGradient) { | - |
5625 | | - |
5626 | LinearGradientValues linear; | - |
5627 | getLinearGradientValues(&linear, data); | - |
5628 | | - |
5629 | | - |
5630 | | - |
5631 | | - |
5632 | | - |
5633 | | - |
5634 | | - |
5635 | | - |
5636 | | - |
5637 | | - |
5638 | | - |
5639 | | - |
5640 | | - |
5641 | | - |
5642 | const int gss = GRADIENT_STOPTABLE_SIZE - 1; | - |
5643 | int yinc = int((linear.dy * data->m22 * gss) * FIXPT_SIZE); | - |
5644 | int off = int((((linear.dy * (data->m22 * qreal(0.5) + data->dy) + linear.off) * gss) * FIXPT_SIZE)); | - |
5645 | | - |
5646 | | - |
5647 | QGradientData gradient = data->gradient; | - |
5648 | while (count--) { | - |
5649 | int y = spans->y; | - |
5650 | | - |
5651 | data->solid.color = QRgba64::fromArgb32(qt_gradient_pixel_fixed(&gradient, yinc * y + off)); | - |
5652 | blend_color_rgb16(1, spans, userData); | - |
5653 | ++spans; | - |
5654 | } | - |
5655 | data->gradient = gradient; | - |
5656 | | - |
5657 | } else { | - |
5658 | blend_src_generic(count, spans, userData); | - |
5659 | } | - |
5660 | } | - |
5661 | | - |
5662 | inline static void qt_bitmapblit_argb32(QRasterBuffer *rasterBuffer, | - |
5663 | int x, int y, const QRgba64 &color, | - |
5664 | const uchar *map, | - |
5665 | int mapWidth, int mapHeight, int mapStride) | - |
5666 | { | - |
5667 | qt_bitmapblit_template<quint32>(rasterBuffer, x, y, color.toArgb32(), | - |
5668 | map, mapWidth, mapHeight, mapStride); | - |
5669 | } | - |
5670 | | - |
5671 | inline static void qt_bitmapblit_rgba8888(QRasterBuffer *rasterBuffer, | - |
5672 | int x, int y, const QRgba64 &color, | - |
5673 | const uchar *map, | - |
5674 | int mapWidth, int mapHeight, int mapStride) | - |
5675 | { | - |
5676 | qt_bitmapblit_template<quint32>(rasterBuffer, x, y, ARGB2RGBA(color.toArgb32()), | - |
5677 | map, mapWidth, mapHeight, mapStride); | - |
5678 | } | - |
5679 | | - |
5680 | template<QtPixelOrder PixelOrder> | - |
5681 | inline static void qt_bitmapblit_rgb30(QRasterBuffer *rasterBuffer, | - |
5682 | int x, int y, const QRgba64 &color, | - |
5683 | const uchar *map, | - |
5684 | int mapWidth, int mapHeight, int mapStride) | - |
5685 | { | - |
5686 | qt_bitmapblit_template<quint32>(rasterBuffer, x, y, qConvertRgb64ToRgb30<PixelOrder>(color), | - |
5687 | map, mapWidth, mapHeight, mapStride); | - |
5688 | } | - |
5689 | | - |
5690 | inline static void qt_bitmapblit_quint16(QRasterBuffer *rasterBuffer, | - |
5691 | int x, int y, const QRgba64 &color, | - |
5692 | const uchar *map, | - |
5693 | int mapWidth, int mapHeight, int mapStride) | - |
5694 | { | - |
5695 | qt_bitmapblit_template<quint16>(rasterBuffer, x, y, color.toRgb16(), | - |
5696 | map, mapWidth, mapHeight, mapStride); | - |
5697 | } | - |
5698 | | - |
5699 | static void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer, | - |
5700 | int x, int y, const QRgba64 &color, | - |
5701 | const uchar *map, | - |
5702 | int mapWidth, int mapHeight, int mapStride, | - |
5703 | const QClipData *) | - |
5704 | { | - |
5705 | const quint16 c = color.toRgb16(); | - |
5706 | quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x; | - |
5707 | const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16); | - |
5708 | | - |
5709 | while (mapHeight--) { | - |
5710 | for (int i = 0; i < mapWidth; ++i) { | - |
5711 | const int coverage = map[i]; | - |
5712 | | - |
5713 | if (coverage == 0) { | - |
5714 | | - |
5715 | } else if (coverage == 255) { | - |
5716 | dest[i] = c; | - |
5717 | } else { | - |
5718 | int ialpha = 255 - coverage; | - |
5719 | dest[i] = BYTE_MUL_RGB16(c, coverage) | - |
5720 | + BYTE_MUL_RGB16(dest[i], ialpha); | - |
5721 | } | - |
5722 | } | - |
5723 | dest += destStride; | - |
5724 | map += mapStride; | - |
5725 | } | - |
5726 | } | - |
5727 | | - |
5728 | static inline void rgbBlendPixel(quint32 *dst, int coverage, int sr, int sg, int sb, const uchar *gamma, const uchar *invgamma) | - |
5729 | { | - |
5730 | | - |
5731 | int da = qAlpha(*dst); | - |
5732 | int dr = qRed(*dst); | - |
5733 | int dg = qGreen(*dst); | - |
5734 | int db = qBlue(*dst); | - |
5735 | | - |
5736 | if (da != 255 | - |
5737 | ) { | - |
5738 | | - |
5739 | int a = qGray(coverage); | - |
5740 | sr = qt_div_255(invgamma[sr] * a); | - |
5741 | sg = qt_div_255(invgamma[sg] * a); | - |
5742 | sb = qt_div_255(invgamma[sb] * a); | - |
5743 | | - |
5744 | int ia = 255 - a; | - |
5745 | dr = qt_div_255(dr * ia); | - |
5746 | dg = qt_div_255(dg * ia); | - |
5747 | db = qt_div_255(db * ia); | - |
5748 | | - |
5749 | *dst = ((a + qt_div_255((255 - a) * da)) << 24) | - |
5750 | | ((sr + dr) << 16) | - |
5751 | | ((sg + dg) << 8) | - |
5752 | | ((sb + db)); | - |
5753 | return; | - |
5754 | } | - |
5755 | | - |
5756 | int mr = qRed(coverage); | - |
5757 | int mg = qGreen(coverage); | - |
5758 | int mb = qBlue(coverage); | - |
5759 | | - |
5760 | dr = gamma[dr]; | - |
5761 | dg = gamma[dg]; | - |
5762 | db = gamma[db]; | - |
5763 | | - |
5764 | int nr = qt_div_255(sr * mr + dr * (255 - mr)); | - |
5765 | int ng = qt_div_255(sg * mg + dg * (255 - mg)); | - |
5766 | int nb = qt_div_255(sb * mb + db * (255 - mb)); | - |
5767 | | - |
5768 | nr = invgamma[nr]; | - |
5769 | ng = invgamma[ng]; | - |
5770 | nb = invgamma[nb]; | - |
5771 | | - |
5772 | *dst = qRgb(nr, ng, nb); | - |
5773 | } | - |
5774 | | - |
5775 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - |
5776 | Q_GUI_EXPORT bool qt_needs_a8_gamma_correction = false; | - |
5777 | | - |
5778 | static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, int sb, const uint *gamma, const uchar *invgamma) | - |
5779 | { | - |
5780 | | - |
5781 | int dr = qRed(*dst); | - |
5782 | int dg = qGreen(*dst); | - |
5783 | int db = qBlue(*dst); | - |
5784 | | - |
5785 | dr = gamma[dr]; | - |
5786 | dg = gamma[dg]; | - |
5787 | db = gamma[db]; | - |
5788 | | - |
5789 | int alpha = coverage; | - |
5790 | int ialpha = 255 - alpha; | - |
5791 | int nr = qt_div_255(sr * alpha + dr * ialpha); | - |
5792 | int ng = qt_div_255(sg * alpha + dg * ialpha); | - |
5793 | int nb = qt_div_255(sb * alpha + db * ialpha); | - |
5794 | | - |
5795 | nr = invgamma[nr]; | - |
5796 | ng = invgamma[ng]; | - |
5797 | nb = invgamma[nb]; | - |
5798 | | - |
5799 | *dst = qRgb(nr, ng, nb); | - |
5800 | } | - |
5801 | #endif | - |
5802 | | - |
5803 | static void qt_alphamapblit_uint32(QRasterBuffer *rasterBuffer, | - |
5804 | int x, int y, quint32 color, | - |
5805 | const uchar *map, | - |
5806 | int mapWidth, int mapHeight, int mapStride, | - |
5807 | const QClipData *clip) | - |
5808 | { | - |
5809 | const quint32 c = color; | - |
5810 | const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32); | - |
5811 | | - |
5812 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - |
5813 | const QDrawHelperGammaTables *tables = QGuiApplicationPrivate::instance()->gammaTables(); | - |
5814 | if (!tables) | - |
5815 | return; | - |
5816 | | - |
5817 | const uint *gamma = tables->qt_pow_gamma; | - |
5818 | const uchar *invgamma = tables->qt_pow_invgamma; | - |
5819 | | - |
5820 | int sr = gamma[qRed(color)]; | - |
5821 | int sg = gamma[qGreen(color)]; | - |
5822 | int sb = gamma[qBlue(color)]; | - |
5823 | | - |
5824 | bool opaque_src = (qAlpha(color) == 255); | - |
5825 | bool doGrayBlendPixel = opaque_src && qt_needs_a8_gamma_correction; | - |
5826 | #endif | - |
5827 | | - |
5828 | if (!clip) { | - |
5829 | quint32 *dest = reinterpret_cast<quint32*>(rasterBuffer->scanLine(y)) + x; | - |
5830 | while (mapHeight--) { | - |
5831 | for (int i = 0; i < mapWidth; ++i) { | - |
5832 | const int coverage = map[i]; | - |
5833 | | - |
5834 | if (coverage == 0) { | - |
5835 | | - |
5836 | } else if (coverage == 255) { | - |
5837 | dest[i] = c; | - |
5838 | } else { | - |
5839 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - |
5840 | if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && doGrayBlendPixel | - |
5841 | && qAlpha(dest[i]) == 255) { | - |
5842 | grayBlendPixel(dest+i, coverage, sr, sg, sb, gamma, invgamma); | - |
5843 | } else | - |
5844 | #endif | - |
5845 | { | - |
5846 | int ialpha = 255 - coverage; | - |
5847 | dest[i] = INTERPOLATE_PIXEL_255(c, coverage, dest[i], ialpha); | - |
5848 | } | - |
5849 | } | - |
5850 | } | - |
5851 | dest += destStride; | - |
5852 | map += mapStride; | - |
5853 | } | - |
5854 | } else { | - |
5855 | int bottom = qMin(y + mapHeight, rasterBuffer->height()); | - |
5856 | | - |
5857 | int top = qMax(y, 0); | - |
5858 | map += (top - y) * mapStride; | - |
5859 | | - |
5860 | const_cast<QClipData *>(clip)->initialize(); | - |
5861 | for (int yp = top; yp<bottom; ++yp) { | - |
5862 | const QClipData::ClipLine &line = clip->m_clipLines[yp]; | - |
5863 | | - |
5864 | quint32 *dest = reinterpret_cast<quint32 *>(rasterBuffer->scanLine(yp)); | - |
5865 | | - |
5866 | for (int i=0; i<line.count; ++i) { | - |
5867 | const QSpan &clip = line.spans[i]; | - |
5868 | | - |
5869 | int start = qMax<int>(x, clip.x); | - |
5870 | int end = qMin<int>(x + mapWidth, clip.x + clip.len); | - |
5871 | | - |
5872 | for (int xp=start; xp<end; ++xp) { | - |
5873 | const int coverage = map[xp - x]; | - |
5874 | | - |
5875 | if (coverage == 0) { | - |
5876 | | - |
5877 | } else if (coverage == 255) { | - |
5878 | dest[xp] = c; | - |
5879 | } else { | - |
5880 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - |
5881 | if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && doGrayBlendPixel | - |
5882 | && qAlpha(dest[xp]) == 255) { | - |
5883 | grayBlendPixel(dest+xp, coverage, sr, sg, sb, gamma, invgamma); | - |
5884 | } else | - |
5885 | #endif | - |
5886 | { | - |
5887 | int ialpha = 255 - coverage; | - |
5888 | dest[xp] = INTERPOLATE_PIXEL_255(c, coverage, dest[xp], ialpha); | - |
5889 | } | - |
5890 | } | - |
5891 | | - |
5892 | } | - |
5893 | } | - |
5894 | map += mapStride; | - |
5895 | } | - |
5896 | } | - |
5897 | } | - |
5898 | | - |
5899 | | - |
5900 | static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer, | - |
5901 | int x, int y, const QRgba64 &color, | - |
5902 | const uchar *map, | - |
5903 | int mapWidth, int mapHeight, int mapStride, | - |
5904 | const QClipData *clip) | - |
5905 | { | - |
5906 | qt_alphamapblit_uint32(rasterBuffer, x, y, color.toArgb32(), map, mapWidth, mapHeight, mapStride, clip); | - |
5907 | } | - |
5908 | | - |
5909 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - |
5910 | static void qt_alphamapblit_rgba8888(QRasterBuffer *rasterBuffer, | - |
5911 | int x, int y, const QRgba64 &color, | - |
5912 | const uchar *map, | - |
5913 | int mapWidth, int mapHeight, int mapStride, | - |
5914 | const QClipData *clip) | - |
5915 | { | - |
5916 | qt_alphamapblit_uint32(rasterBuffer, x, y, ARGB2RGBA(color.toArgb32()), map, mapWidth, mapHeight, mapStride, clip); | - |
5917 | } | - |
5918 | #endif | - |
5919 | | - |
5920 | static void qt_alphargbblit_argb32(QRasterBuffer *rasterBuffer, | - |
5921 | int x, int y, const QRgba64 &color, | - |
5922 | const uint *src, int mapWidth, int mapHeight, int srcStride, | - |
5923 | const QClipData *clip) | - |
5924 | { | - |
5925 | const quint32 c = color.toArgb32(); | - |
5926 | | - |
5927 | int sr = qRed(c); | - |
5928 | int sg = qGreen(c); | - |
5929 | int sb = qBlue(c); | - |
5930 | int sa = qAlpha(c); | - |
5931 | | - |
5932 | const QDrawHelperGammaTables *tables = QGuiApplicationPrivate::instance()->gammaTables(); | - |
5933 | if (!tables) | - |
5934 | return; | - |
5935 | | - |
5936 | const uchar *gamma = tables->qt_pow_rgb_gamma; | - |
5937 | const uchar *invgamma = tables->qt_pow_rgb_invgamma; | - |
5938 | | - |
5939 | sr = gamma[sr]; | - |
5940 | sg = gamma[sg]; | - |
5941 | sb = gamma[sb]; | - |
5942 | | - |
5943 | if (sa == 0) | - |
5944 | return; | - |
5945 | | - |
5946 | if (!clip) { | - |
5947 | quint32 *dst = reinterpret_cast<quint32*>(rasterBuffer->scanLine(y)) + x; | - |
5948 | const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32); | - |
5949 | while (mapHeight--) { | - |
5950 | for (int i = 0; i < mapWidth; ++i) { | - |
5951 | const uint coverage = src[i]; | - |
5952 | if (coverage == 0xffffffff) { | - |
5953 | dst[i] = c; | - |
5954 | } else if (coverage != 0xff000000) { | - |
5955 | rgbBlendPixel(dst+i, coverage, sr, sg, sb, gamma, invgamma); | - |
5956 | } | - |
5957 | } | - |
5958 | | - |
5959 | dst += destStride; | - |
5960 | src += srcStride; | - |
5961 | } | - |
5962 | } else { | - |
5963 | int bottom = qMin(y + mapHeight, rasterBuffer->height()); | - |
5964 | | - |
5965 | int top = qMax(y, 0); | - |
5966 | src += (top - y) * srcStride; | - |
5967 | | - |
5968 | const_cast<QClipData *>(clip)->initialize(); | - |
5969 | for (int yp = top; yp<bottom; ++yp) { | - |
5970 | const QClipData::ClipLine &line = clip->m_clipLines[yp]; | - |
5971 | | - |
5972 | quint32 *dst = reinterpret_cast<quint32 *>(rasterBuffer->scanLine(yp)); | - |
5973 | | - |
5974 | for (int i=0; i<line.count; ++i) { | - |
5975 | const QSpan &clip = line.spans[i]; | - |
5976 | | - |
5977 | int start = qMax<int>(x, clip.x); | - |
5978 | int end = qMin<int>(x + mapWidth, clip.x + clip.len); | - |
5979 | | - |
5980 | for (int xp=start; xp<end; ++xp) { | - |
5981 | const uint coverage = src[xp - x]; | - |
5982 | if (coverage == 0xffffffff) { | - |
5983 | dst[xp] = c; | - |
5984 | } else if (coverage != 0xff000000) { | - |
5985 | rgbBlendPixel(dst+xp, coverage, sr, sg, sb, gamma, invgamma); | - |
5986 | } | - |
5987 | } | - |
5988 | } | - |
5989 | src += srcStride; | - |
5990 | } | - |
5991 | | - |
5992 | } | - |
5993 | } | - |
5994 | | - |
5995 | static void qt_rectfill_argb32(QRasterBuffer *rasterBuffer, | - |
5996 | int x, int y, int width, int height, | - |
5997 | const QRgba64 &color) | - |
5998 | { | - |
5999 | qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()), | - |
6000 | color.toArgb32(), x, y, width, height, rasterBuffer->bytesPerLine()); | - |
6001 | } | - |
6002 | | - |
6003 | static void qt_rectfill_quint16(QRasterBuffer *rasterBuffer, | - |
6004 | int x, int y, int width, int height, | - |
6005 | const QRgba64 &color) | - |
6006 | { | - |
6007 | qt_rectfill<quint16>(reinterpret_cast<quint16 *>(rasterBuffer->buffer()), | - |
6008 | color.toRgb16(), x, y, width, height, rasterBuffer->bytesPerLine()); | - |
6009 | } | - |
6010 | | - |
6011 | static void qt_rectfill_nonpremul_argb32(QRasterBuffer *rasterBuffer, | - |
6012 | int x, int y, int width, int height, | - |
6013 | const QRgba64 &color) | - |
6014 | { | - |
6015 | qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()), | - |
6016 | color.unpremultiplied().toArgb32(), x, y, width, height, rasterBuffer->bytesPerLine()); | - |
6017 | } | - |
6018 | | - |
6019 | static void qt_rectfill_rgba(QRasterBuffer *rasterBuffer, | - |
6020 | int x, int y, int width, int height, | - |
6021 | const QRgba64 &color) | - |
6022 | { | - |
6023 | qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()), | - |
6024 | ARGB2RGBA(color.toArgb32()), x, y, width, height, rasterBuffer->bytesPerLine()); | - |
6025 | } | - |
6026 | | - |
6027 | static void qt_rectfill_nonpremul_rgba(QRasterBuffer *rasterBuffer, | - |
6028 | int x, int y, int width, int height, | - |
6029 | const QRgba64 &color) | - |
6030 | { | - |
6031 | qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()), | - |
6032 | ARGB2RGBA(color.unpremultiplied().toArgb32()), x, y, width, height, rasterBuffer->bytesPerLine()); | - |
6033 | } | - |
6034 | | - |
6035 | template<QtPixelOrder PixelOrder> | - |
6036 | static void qt_rectfill_rgb30(QRasterBuffer *rasterBuffer, | - |
6037 | int x, int y, int width, int height, | - |
6038 | const QRgba64 &color) | - |
6039 | { | - |
6040 | qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()), | - |
6041 | qConvertRgb64ToRgb30<PixelOrder>(color), x, y, width, height, rasterBuffer->bytesPerLine()); | - |
6042 | } | - |
6043 | | - |
6044 | static void qt_rectfill_alpha(QRasterBuffer *rasterBuffer, | - |
6045 | int x, int y, int width, int height, | - |
6046 | const QRgba64 &color) | - |
6047 | { | - |
6048 | qt_rectfill<quint8>(reinterpret_cast<quint8 *>(rasterBuffer->buffer()), | - |
6049 | color.alpha() >> 8, x, y, width, height, rasterBuffer->bytesPerLine()); | - |
6050 | } | - |
6051 | | - |
6052 | static void qt_rectfill_gray(QRasterBuffer *rasterBuffer, | - |
6053 | int x, int y, int width, int height, | - |
6054 | const QRgba64 &color) | - |
6055 | { | - |
6056 | qt_rectfill<quint8>(reinterpret_cast<quint8 *>(rasterBuffer->buffer()), | - |
6057 | qGray(color.toArgb32()), x, y, width, height, rasterBuffer->bytesPerLine()); | - |
6058 | } | - |
6059 | | - |
6060 | | - |
6061 | | - |
6062 | | - |
6063 | DrawHelper qDrawHelper[QImage::NImageFormats] = | - |
6064 | { | - |
6065 | | - |
6066 | { 0, 0, 0, 0, 0, 0 }, | - |
6067 | | - |
6068 | { | - |
6069 | blend_color_generic, | - |
6070 | blend_src_generic, | - |
6071 | 0, 0, 0, 0 | - |
6072 | }, | - |
6073 | | - |
6074 | { | - |
6075 | blend_color_generic, | - |
6076 | blend_src_generic, | - |
6077 | 0, 0, 0, 0 | - |
6078 | }, | - |
6079 | | - |
6080 | { | - |
6081 | blend_color_generic, | - |
6082 | blend_src_generic, | - |
6083 | 0, 0, 0, 0 | - |
6084 | }, | - |
6085 | | - |
6086 | { | - |
6087 | blend_color_argb, | - |
6088 | qt_gradient_argb32, | - |
6089 | qt_bitmapblit_argb32, | - |
6090 | qt_alphamapblit_argb32, | - |
6091 | qt_alphargbblit_argb32, | - |
6092 | qt_rectfill_argb32 | - |
6093 | }, | - |
6094 | | - |
6095 | { | - |
6096 | blend_color_generic, | - |
6097 | qt_gradient_argb32, | - |
6098 | qt_bitmapblit_argb32, | - |
6099 | qt_alphamapblit_argb32, | - |
6100 | qt_alphargbblit_argb32, | - |
6101 | qt_rectfill_nonpremul_argb32 | - |
6102 | }, | - |
6103 | | - |
6104 | { | - |
6105 | blend_color_argb, | - |
6106 | qt_gradient_argb32, | - |
6107 | qt_bitmapblit_argb32, | - |
6108 | qt_alphamapblit_argb32, | - |
6109 | qt_alphargbblit_argb32, | - |
6110 | qt_rectfill_argb32 | - |
6111 | }, | - |
6112 | | - |
6113 | { | - |
6114 | blend_color_rgb16, | - |
6115 | qt_gradient_quint16, | - |
6116 | qt_bitmapblit_quint16, | - |
6117 | qt_alphamapblit_quint16, | - |
6118 | 0, | - |
6119 | qt_rectfill_quint16 | - |
6120 | }, | - |
6121 | | - |
6122 | { | - |
6123 | blend_color_generic, | - |
6124 | blend_src_generic, | - |
6125 | 0, 0, 0, 0 | - |
6126 | }, | - |
6127 | | - |
6128 | { | - |
6129 | blend_color_generic, | - |
6130 | blend_src_generic, | - |
6131 | 0, 0, 0, 0 | - |
6132 | }, | - |
6133 | | - |
6134 | { | - |
6135 | blend_color_generic, | - |
6136 | blend_src_generic, | - |
6137 | 0, 0, 0, 0 | - |
6138 | }, | - |
6139 | | - |
6140 | { | - |
6141 | blend_color_generic, | - |
6142 | blend_src_generic, | - |
6143 | 0, 0, 0, 0 | - |
6144 | }, | - |
6145 | | - |
6146 | { | - |
6147 | blend_color_generic, | - |
6148 | blend_src_generic, | - |
6149 | 0, 0, 0, 0 | - |
6150 | }, | - |
6151 | | - |
6152 | { | - |
6153 | blend_color_generic, | - |
6154 | blend_src_generic, | - |
6155 | 0, 0, 0, 0 | - |
6156 | }, | - |
6157 | | - |
6158 | { | - |
6159 | blend_color_generic, | - |
6160 | blend_src_generic, | - |
6161 | 0, 0, 0, 0 | - |
6162 | }, | - |
6163 | | - |
6164 | { | - |
6165 | blend_color_generic, | - |
6166 | blend_src_generic, | - |
6167 | 0, 0, 0, 0 | - |
6168 | }, | - |
6169 | | - |
6170 | { | - |
6171 | blend_color_generic, | - |
6172 | blend_src_generic, | - |
6173 | qt_bitmapblit_rgba8888, | - |
6174 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - |
6175 | qt_alphamapblit_rgba8888, | - |
6176 | #else | - |
6177 | 0, | - |
6178 | #endif | - |
6179 | 0, | - |
6180 | qt_rectfill_rgba | - |
6181 | }, | - |
6182 | | - |
6183 | { | - |
6184 | blend_color_generic, | - |
6185 | blend_src_generic, | - |
6186 | qt_bitmapblit_rgba8888, | - |
6187 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - |
6188 | qt_alphamapblit_rgba8888, | - |
6189 | #else | - |
6190 | 0, | - |
6191 | #endif | - |
6192 | 0, | - |
6193 | qt_rectfill_nonpremul_rgba | - |
6194 | }, | - |
6195 | | - |
6196 | { | - |
6197 | blend_color_generic, | - |
6198 | blend_src_generic, | - |
6199 | qt_bitmapblit_rgba8888, | - |
6200 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - |
6201 | qt_alphamapblit_rgba8888, | - |
6202 | #else | - |
6203 | 0, | - |
6204 | #endif | - |
6205 | 0, | - |
6206 | qt_rectfill_rgba | - |
6207 | }, | - |
6208 | | - |
6209 | { | - |
6210 | blend_color_generic_rgb64, | - |
6211 | blend_src_generic_rgb64, | - |
6212 | qt_bitmapblit_rgb30<PixelOrderBGR>, | - |
6213 | 0, | - |
6214 | 0, | - |
6215 | qt_rectfill_rgb30<PixelOrderBGR> | - |
6216 | }, | - |
6217 | | - |
6218 | { | - |
6219 | blend_color_generic_rgb64, | - |
6220 | blend_src_generic_rgb64, | - |
6221 | qt_bitmapblit_rgb30<PixelOrderBGR>, | - |
6222 | 0, | - |
6223 | 0, | - |
6224 | qt_rectfill_rgb30<PixelOrderBGR> | - |
6225 | }, | - |
6226 | | - |
6227 | { | - |
6228 | blend_color_generic_rgb64, | - |
6229 | blend_src_generic_rgb64, | - |
6230 | qt_bitmapblit_rgb30<PixelOrderRGB>, | - |
6231 | 0, | - |
6232 | 0, | - |
6233 | qt_rectfill_rgb30<PixelOrderRGB> | - |
6234 | }, | - |
6235 | | - |
6236 | { | - |
6237 | blend_color_generic_rgb64, | - |
6238 | blend_src_generic_rgb64, | - |
6239 | qt_bitmapblit_rgb30<PixelOrderRGB>, | - |
6240 | 0, | - |
6241 | 0, | - |
6242 | qt_rectfill_rgb30<PixelOrderRGB> | - |
6243 | }, | - |
6244 | | - |
6245 | { | - |
6246 | blend_color_generic, | - |
6247 | blend_src_generic, | - |
6248 | 0, 0, 0, | - |
6249 | qt_rectfill_alpha | - |
6250 | }, | - |
6251 | | - |
6252 | { | - |
6253 | blend_color_generic, | - |
6254 | blend_src_generic, | - |
6255 | 0, 0, 0, | - |
6256 | qt_rectfill_gray | - |
6257 | }, | - |
6258 | }; | - |
6259 | | - |
6260 | #if defined(Q_CC_MSVC) && !defined(_MIPS_) | - |
6261 | template <class T> | - |
6262 | inline void qt_memfill_template(T *dest, T color, int count) | - |
6263 | { | - |
6264 | while (count--) | - |
6265 | *dest++ = color; | - |
6266 | } | - |
6267 | | - |
6268 | #else | - |
6269 | | - |
6270 | template <class T> | - |
6271 | inline void qt_memfill_template(T *dest, T color, int count) | - |
6272 | { | - |
6273 | int n = (count + 7) / 8; | - |
6274 | switch (count & 0x07) | - |
6275 | { | - |
6276 | case 0: do { *dest++ = color; | - |
6277 | case 7: *dest++ = color; | - |
6278 | case 6: *dest++ = color; | - |
6279 | case 5: *dest++ = color; | - |
6280 | case 4: *dest++ = color; | - |
6281 | case 3: *dest++ = color; | - |
6282 | case 2: *dest++ = color; | - |
6283 | case 1: *dest++ = color; | - |
6284 | } while (--n > 0); | - |
6285 | } | - |
6286 | } | - |
6287 | | - |
6288 | template <> | - |
6289 | inline void qt_memfill_template(quint16 *dest, quint16 value, int count) | - |
6290 | { | - |
6291 | if (count < 3) { | - |
6292 | switch (count) { | - |
6293 | case 2: *dest++ = value; | - |
6294 | case 1: *dest = value; | - |
6295 | } | - |
6296 | return; | - |
6297 | } | - |
6298 | | - |
6299 | const int align = (quintptr)(dest) & 0x3; | - |
6300 | switch (align) { | - |
6301 | case 2: *dest++ = value; --count; | - |
6302 | } | - |
6303 | | - |
6304 | const quint32 value32 = (value << 16) | value; | - |
6305 | qt_memfill(reinterpret_cast<quint32*>(dest), value32, count / 2); | - |
6306 | if (count & 0x1) | - |
6307 | dest[count - 1] = value; | - |
6308 | } | - |
6309 | #endif | - |
6310 | | - |
6311 | void qt_memfill64(quint64 *dest, quint64 color, int count) | - |
6312 | { | - |
6313 | qt_memfill_template<quint64>(dest, color, count); | - |
6314 | } | - |
6315 | | - |
6316 | #if !defined(__SSE2__) | - |
6317 | void qt_memfill16(quint16 *dest, quint16 color, int count) | - |
6318 | { | - |
6319 | qt_memfill_template<quint16>(dest, color, count); | - |
6320 | } | - |
6321 | #endif | - |
6322 | #if !defined(__SSE2__) && !defined(__ARM_NEON__) | - |
6323 | # ifdef QT_COMPILER_SUPPORTS_MIPS_DSP | - |
6324 | extern "C" void qt_memfill32_asm_mips_dsp(quint32 *, quint32, int); | - |
6325 | # endif | - |
6326 | | - |
6327 | void qt_memfill32(quint32 *dest, quint32 color, int count) | - |
6328 | { | - |
6329 | # ifdef QT_COMPILER_SUPPORTS_MIPS_DSP | - |
6330 | qt_memfill32_asm_mips_dsp(dest, color, count); | - |
6331 | # else | - |
6332 | qt_memfill_template<quint32>(dest, color, count); | - |
6333 | # endif | - |
6334 | } | - |
6335 | #endif | - |
6336 | | - |
6337 | #ifdef QT_COMPILER_SUPPORTS_SSE4_1 | - |
6338 | template<QtPixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); | - |
6339 | #endif | - |
6340 | | - |
6341 | extern void qInitBlendFunctions(); | - |
6342 | | - |
6343 | static void qInitDrawhelperFunctions() | - |
6344 | { | - |
6345 | | - |
6346 | qInitBlendFunctions(); | - |
6347 | | - |
6348 | #ifdef __SSE2__ | - |
6349 | qDrawHelper[QImage::Format_RGB32].bitmapBlit = qt_bitmapblit32_sse2; | - |
6350 | qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_sse2; | - |
6351 | qDrawHelper[QImage::Format_ARGB32_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2; | - |
6352 | qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse2; | - |
6353 | qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit8888_sse2; | - |
6354 | qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit8888_sse2; | - |
6355 | qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit8888_sse2; | - |
6356 | | - |
6357 | extern void qt_scale_image_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, | - |
6358 | const uchar *srcPixels, int sbpl, int srch, | - |
6359 | const QRectF &targetRect, | - |
6360 | const QRectF &sourceRect, | - |
6361 | const QRect &clip, | - |
6362 | int const_alpha); | - |
6363 | qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2; | - |
6364 | qScaleFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2; | - |
6365 | qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2; | - |
6366 | qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2; | - |
6367 | | - |
6368 | extern void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, | - |
6369 | const uchar *srcPixels, int sbpl, | - |
6370 | int w, int h, | - |
6371 | int const_alpha); | - |
6372 | extern void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, | - |
6373 | const uchar *srcPixels, int sbpl, | - |
6374 | int w, int h, | - |
6375 | int const_alpha); | - |
6376 | | - |
6377 | qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; | - |
6378 | qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; | - |
6379 | qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; | - |
6380 | qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; | - |
6381 | qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_sse2; | - |
6382 | qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_sse2; | - |
6383 | qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_sse2; | - |
6384 | qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_sse2; | - |
6385 | | - |
6386 | extern const uint * QT_FASTCALL qt_fetch_radial_gradient_sse2(uint *buffer, const Operator *op, const QSpanData *data, | - |
6387 | int y, int x, int length); | - |
6388 | | - |
6389 | qt_fetch_radial_gradient = qt_fetch_radial_gradient_sse2; | - |
6390 | | - |
6391 | #ifdef QT_COMPILER_SUPPORTS_SSSE3 | - |
6392 | if (qCpuHasFeature(SSSE3)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6393 | extern void qt_blend_argb32_on_argb32_ssse3(uchar *destPixels, int dbpl, | - |
6394 | const uchar *srcPixels, int sbpl, | - |
6395 | int w, int h, | - |
6396 | int const_alpha); | - |
6397 | | - |
6398 | extern void QT_FASTCALL storePixelsBPP24_ssse3(uchar *dest, const uint *src, int index, int count); | - |
6399 | extern const uint * QT_FASTCALL qt_fetchUntransformed_888_ssse3(uint *buffer, const Operator *, const QSpanData *data, | - |
6400 | int y, int x, int length); | - |
6401 | qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; | - |
6402 | qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; | - |
6403 | qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; | - |
6404 | qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; | - |
6405 | qStorePixels[QPixelLayout::BPP24] = storePixelsBPP24_ssse3; | - |
6406 | sourceFetch[BlendUntransformed][QImage::Format_RGB888] = qt_fetchUntransformed_888_ssse3; | - |
6407 | sourceFetch[BlendTiled][QImage::Format_RGB888] = qt_fetchUntransformed_888_ssse3; | - |
6408 | } never executed: end of block | 0 |
6409 | #endif // SSSE3 | - |
6410 | | - |
6411 | #if defined(QT_COMPILER_SUPPORTS_SSE4_1) | - |
6412 | if (qCpuHasFeature(SSE4_1)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6413 | #if !defined(__SSE4_1__) | - |
6414 | extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); | - |
6415 | extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); | - |
6416 | qPixelLayouts[QImage::Format_ARGB32].convertToARGB32PM = convertARGB32ToARGB32PM_sse4; | - |
6417 | qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_sse4; | - |
6418 | #endif | - |
6419 | extern const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); | - |
6420 | extern const uint *QT_FASTCALL convertRGBA8888FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); | - |
6421 | extern const uint *QT_FASTCALL convertRGBXFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); | - |
6422 | qPixelLayouts[QImage::Format_ARGB32].convertFromARGB32PM = convertARGB32FromARGB32PM_sse4; | - |
6423 | qPixelLayouts[QImage::Format_RGBA8888].convertFromARGB32PM = convertRGBA8888FromARGB32PM_sse4; | - |
6424 | qPixelLayouts[QImage::Format_RGBX8888].convertFromARGB32PM = convertRGBXFromARGB32PM_sse4; | - |
6425 | qPixelLayouts[QImage::Format_A2BGR30_Premultiplied].convertFromARGB32PM = convertA2RGB30PMFromARGB32PM_sse4<PixelOrderBGR>; | - |
6426 | qPixelLayouts[QImage::Format_A2RGB30_Premultiplied].convertFromARGB32PM = convertA2RGB30PMFromARGB32PM_sse4<PixelOrderRGB>; | - |
6427 | } never executed: end of block | 0 |
6428 | #endif | - |
6429 | | - |
6430 | #if defined(QT_COMPILER_SUPPORTS_AVX2) && !defined(__AVX2__) | - |
6431 | if (qCpuHasFeature(AVX2)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6432 | extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_avx2(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); | - |
6433 | extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_avx2(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); | - |
6434 | qPixelLayouts[QImage::Format_ARGB32].convertToARGB32PM = convertARGB32ToARGB32PM_avx2; | - |
6435 | qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_avx2; | - |
6436 | } never executed: end of block | 0 |
6437 | #endif | - |
6438 | extern void QT_FASTCALL comp_func_SourceOver_sse2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha); | - |
6439 | extern void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, uint color, uint const_alpha); | - |
6440 | extern void QT_FASTCALL comp_func_Source_sse2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha); | - |
6441 | extern void QT_FASTCALL comp_func_Plus_sse2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha); | - |
6442 | qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_sse2; | - |
6443 | qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_sse2; | - |
6444 | qt_functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_sse2; | - |
6445 | qt_functionForMode_C[QPainter::CompositionMode_Plus] = comp_func_Plus_sse2; | - |
6446 | | - |
6447 | #endif // SSE2 | - |
6448 | | - |
6449 | #if defined(__ARM_NEON__) | - |
6450 | qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon; | - |
6451 | qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon; | - |
6452 | qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_neon; | - |
6453 | qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_neon; | - |
6454 | #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | - |
6455 | qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_neon; | - |
6456 | qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_neon; | - |
6457 | qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_neon; | - |
6458 | qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_neon; | - |
6459 | #endif | - |
6460 | | - |
6461 | qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = qt_blend_argb32_on_argb32_scanline_neon; | - |
6462 | qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_neon; | - |
6463 | qt_functionForMode_C[QPainter::CompositionMode_Plus] = comp_func_Plus_neon; | - |
6464 | | - |
6465 | extern const uint * QT_FASTCALL qt_fetch_radial_gradient_neon(uint *buffer, const Operator *op, const QSpanData *data, | - |
6466 | int y, int x, int length); | - |
6467 | | - |
6468 | qt_fetch_radial_gradient = qt_fetch_radial_gradient_neon; | - |
6469 | | - |
6470 | sourceFetch[BlendUntransformed][QImage::Format_RGB888] = qt_fetchUntransformed_888_neon; | - |
6471 | sourceFetch[BlendTiled][QImage::Format_RGB888] = qt_fetchUntransformed_888_neon; | - |
6472 | | - |
6473 | #if defined(ENABLE_PIXMAN_DRAWHELPERS) | - |
6474 | | - |
6475 | qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16_neon; | - |
6476 | qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB16] = qt_blend_rgb16_on_argb32_neon; | - |
6477 | qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_neon; | - |
6478 | | - |
6479 | qScaleFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_rgb16_neon; | - |
6480 | qScaleFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_scale_image_rgb16_on_rgb16_neon; | - |
6481 | | - |
6482 | qTransformFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_rgb16_neon; | - |
6483 | qTransformFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_transform_image_rgb16_on_rgb16_neon; | - |
6484 | | - |
6485 | qDrawHelper[QImage::Format_RGB16].alphamapBlit = qt_alphamapblit_quint16_neon; | - |
6486 | | - |
6487 | destFetchProc[QImage::Format_RGB16] = qt_destFetchRGB16_neon; | - |
6488 | destStoreProc[QImage::Format_RGB16] = qt_destStoreRGB16_neon; | - |
6489 | | - |
6490 | qMemRotateFunctions[QImage::Format_RGB16][0] = qt_memrotate90_16_neon; | - |
6491 | qMemRotateFunctions[QImage::Format_RGB16][2] = qt_memrotate270_16_neon; | - |
6492 | #endif | - |
6493 | | - |
6494 | #endif | - |
6495 | | - |
6496 | #if defined(Q_PROCESSOR_MIPS_32) && defined(QT_COMPILER_SUPPORTS_MIPS_DSP) | - |
6497 | qt_memfill32 = qt_memfill32_asm_mips_dsp; | - |
6498 | #endif // Q_PROCESSOR_MIPS_32 | - |
6499 | | - |
6500 | #if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) || defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) | - |
6501 | if (qCpuHasFeature(DSP) && qCpuHasFeature(DSPR2)) { | - |
6502 | | - |
6503 | qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_asm_mips_dsp; | - |
6504 | qt_functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_mips_dsp; | - |
6505 | qt_functionForMode_C[QPainter::CompositionMode_DestinationOver] = comp_func_DestinationOver_mips_dsp; | - |
6506 | qt_functionForMode_C[QPainter::CompositionMode_SourceIn] = comp_func_SourceIn_mips_dsp; | - |
6507 | qt_functionForMode_C[QPainter::CompositionMode_DestinationIn] = comp_func_DestinationIn_mips_dsp; | - |
6508 | qt_functionForMode_C[QPainter::CompositionMode_DestinationOut] = comp_func_DestinationOut_mips_dsp; | - |
6509 | qt_functionForMode_C[QPainter::CompositionMode_SourceAtop] = comp_func_SourceAtop_mips_dsp; | - |
6510 | qt_functionForMode_C[QPainter::CompositionMode_DestinationAtop] = comp_func_DestinationAtop_mips_dsp; | - |
6511 | qt_functionForMode_C[QPainter::CompositionMode_Xor] = comp_func_XOR_mips_dsp; | - |
6512 | qt_functionForMode_C[QPainter::CompositionMode_SourceOut] = comp_func_SourceOut_mips_dsp; | - |
6513 | | - |
6514 | qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_mips_dsp; | - |
6515 | qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationOver] = comp_func_solid_DestinationOver_mips_dsp; | - |
6516 | qt_functionForModeSolid_C[QPainter::CompositionMode_SourceIn] = comp_func_solid_SourceIn_mips_dsp; | - |
6517 | qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationIn] = comp_func_solid_DestinationIn_mips_dsp; | - |
6518 | qt_functionForModeSolid_C[QPainter::CompositionMode_SourceAtop] = comp_func_solid_SourceAtop_mips_dsp; | - |
6519 | qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationAtop] = comp_func_solid_DestinationAtop_mips_dsp; | - |
6520 | qt_functionForModeSolid_C[QPainter::CompositionMode_Xor] = comp_func_solid_XOR_mips_dsp; | - |
6521 | qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOut] = comp_func_solid_SourceOut_mips_dsp; | - |
6522 | | - |
6523 | qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mips_dsp; | - |
6524 | qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mips_dsp; | - |
6525 | qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_mips_dsp; | - |
6526 | qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_mips_dsp; | - |
6527 | | - |
6528 | destFetchProc[QImage::Format_ARGB32] = qt_destFetchARGB32_mips_dsp; | - |
6529 | | - |
6530 | destStoreProc[QImage::Format_ARGB32] = qt_destStoreARGB32_mips_dsp; | - |
6531 | | - |
6532 | sourceFetch[BlendUntransformed][QImage::Format_RGB888] = qt_fetchUntransformed_888_mips_dsp; | - |
6533 | sourceFetch[BlendTiled][QImage::Format_RGB888] = qt_fetchUntransformed_888_mips_dsp; | - |
6534 | | - |
6535 | sourceFetch[BlendUntransformed][QImage::Format_RGB444] = qt_fetchUntransformed_444_mips_dsp; | - |
6536 | sourceFetch[BlendTiled][QImage::Format_RGB444] = qt_fetchUntransformed_444_mips_dsp; | - |
6537 | | - |
6538 | sourceFetch[BlendUntransformed][QImage::Format_ARGB8565_Premultiplied] = qt_fetchUntransformed_argb8565_premultiplied_mips_dsp; | - |
6539 | sourceFetch[BlendTiled][QImage::Format_ARGB8565_Premultiplied] = qt_fetchUntransformed_argb8565_premultiplied_mips_dsp; | - |
6540 | | - |
6541 | #if defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) | - |
6542 | qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_mips_dspr2; | - |
6543 | #else | - |
6544 | qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_mips_dsp; | - |
6545 | #endif // QT_COMPILER_SUPPORTS_MIPS_DSPR2 | - |
6546 | } | - |
6547 | #endif // QT_COMPILER_SUPPORTS_MIPS_DSP || QT_COMPILER_SUPPORTS_MIPS_DSPR2 | - |
6548 | } never executed: end of block | 0 |
6549 | | - |
6550 | | - |
6551 | Q_CONSTRUCTOR_FUNCTION(qInitDrawhelperFunctions); | - |
6552 | | - |
6553 | QT_END_NAMESPACE | - |
| | |