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