Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qdrawhelper.cpp |
Switch to Source code | Preprocessed file |
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
| 0 | ||||||||||||||||||
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 | } never executed: end of block | 0 | ||||||||||||||||||
142 | - | |||||||||||||||||||
143 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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 < count
| 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: buffer;return 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 (mustMin
| 0 | ||||||||||||||||||
200 | for (int i = 0; i < count
| 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: else {end of block | 0 | ||||||||||||||||||
213 | for (int i = 0; i < count
| 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: buffer;return 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 (mustMin
| 0 | ||||||||||||||||||
254 | for (int i = 0; i < count
| 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 | } never executed: else {end of block | 0 | ||||||||||||||||||
267 | for (int i = 0; i < count
| 0 | ||||||||||||||||||
268 | uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask; | - | ||||||||||||||||||
269 | uint red = (src[i] >> redShift<Format>()) & redMask; | - | ||||||||||||||||||
270 | uint green = (src[i] >> greenShift<Format>()) & greenMask; | - | ||||||||||||||||||
271 | uint blue = (src[i] >> blueShift<Format>()) & blueMask; | - | ||||||||||||||||||
272 | - | |||||||||||||||||||
273 | alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); | - | ||||||||||||||||||
274 | red = (red << redLeftShift) | (red >> redRightShift); | - | ||||||||||||||||||
275 | green = (green << greenLeftShift) | (green >> greenRightShift); | - | ||||||||||||||||||
276 | blue = (blue << blueLeftShift) | (blue >> blueRightShift); | - | ||||||||||||||||||
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: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
282 | } | - | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | template<QImage::Format Format, bool fromRGB> | - | ||||||||||||||||||
285 | static const uint * convertRGBFromARGB32PM(uint *buffer, const uint *src, int count, | - | ||||||||||||||||||
286 | const QPixelLayout *, const QRgb *) | - | ||||||||||||||||||
287 | { | - | ||||||||||||||||||
288 | constexpr uint rMask = ((1 << redWidth<Format>()) - 1); | - | ||||||||||||||||||
289 | constexpr uint gMask = ((1 << greenWidth<Format>()) - 1); | - | ||||||||||||||||||
290 | constexpr uint bMask = ((1 << blueWidth<Format>()) - 1); | - | ||||||||||||||||||
291 | - | |||||||||||||||||||
292 | constexpr uchar rRightShift = 24 - redWidth<Format>(); | - | ||||||||||||||||||
293 | constexpr uchar gRightShift = 16 - greenWidth<Format>(); | - | ||||||||||||||||||
294 | constexpr uchar bRightShift = 8 - blueWidth<Format>(); | - | ||||||||||||||||||
295 | - | |||||||||||||||||||
296 | for (int i = 0; i < count
| 0 | ||||||||||||||||||
297 | const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]); | - | ||||||||||||||||||
298 | const uint r = ((c >> rRightShift) & rMask) << redShift<Format>(); | - | ||||||||||||||||||
299 | const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>(); | - | ||||||||||||||||||
300 | const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>(); | - | ||||||||||||||||||
301 | buffer[i] = r | g | b; | - | ||||||||||||||||||
302 | } never executed: end of block | 0 | ||||||||||||||||||
303 | return never executed: buffer;return 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 aMask = ((1 << alphaWidth<Format>()) - 1); | - | ||||||||||||||||||
311 | constexpr uint rMask = ((1 << redWidth<Format>()) - 1); | - | ||||||||||||||||||
312 | constexpr uint gMask = ((1 << greenWidth<Format>()) - 1); | - | ||||||||||||||||||
313 | constexpr uint bMask = ((1 << blueWidth<Format>()) - 1); | - | ||||||||||||||||||
314 | - | |||||||||||||||||||
315 | constexpr uchar aRightShift = 32 - alphaWidth<Format>(); | - | ||||||||||||||||||
316 | constexpr uchar rRightShift = 24 - redWidth<Format>(); | - | ||||||||||||||||||
317 | constexpr uchar gRightShift = 16 - greenWidth<Format>(); | - | ||||||||||||||||||
318 | constexpr uchar bRightShift = 8 - blueWidth<Format>(); | - | ||||||||||||||||||
319 | - | |||||||||||||||||||
320 | constexpr uint aOpaque = (0xff & aMask) << alphaShift<Format>(); | - | ||||||||||||||||||
321 | for (int i = 0; i < count
| 0 | ||||||||||||||||||
322 | const uint c = src[i]; | - | ||||||||||||||||||
323 | const uint a = fromRGB ? aOpaque : (((c >> aRightShift) & aMask) << alphaShift<Format>()); | - | ||||||||||||||||||
324 | const uint r = ((c >> rRightShift) & rMask) << redShift<Format>(); | - | ||||||||||||||||||
325 | const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>(); | - | ||||||||||||||||||
326 | const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>(); | - | ||||||||||||||||||
327 | buffer[i] = a | r | g | b; | - | ||||||||||||||||||
328 | } never executed: end of block | 0 | ||||||||||||||||||
329 | return never executed: buffer;return 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 | convertRGBFromARGB32PM<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 | convertARGBPMFromARGB32PM<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
| 0 | ||||||||||||||||||
371 | buffer[i] = qPremultiply(clut[src[i]]); never executed: buffer[i] = qPremultiply(clut[src[i]]); | 0 | ||||||||||||||||||
372 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
379 | buffer[i] = QRgba64::fromArgb32(clut[src[i]]).premultiplied(); never executed: buffer[i] = QRgba64::fromArgb32(clut[src[i]]).premultiplied(); | 0 | ||||||||||||||||||
380 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
381 | } | - | ||||||||||||||||||
382 | - | |||||||||||||||||||
383 | static const uint * convertPassThrough(uint *, const uint *src, int, | - | ||||||||||||||||||
384 | const QPixelLayout *, const QRgb *) | - | ||||||||||||||||||
385 | { | - | ||||||||||||||||||
386 | return never executed: src;return src; never executed: return src; | 0 | ||||||||||||||||||
387 | } | - | ||||||||||||||||||
388 | - | |||||||||||||||||||
389 | static const uint * convertARGB32ToARGB32PM(uint *buffer, const uint *src, int count, | - | ||||||||||||||||||
390 | const QPixelLayout *, const QRgb *) | - | ||||||||||||||||||
391 | { | - | ||||||||||||||||||
392 | return never executed: qt_convertARGB32ToARGB32PM(buffer, src, count);return qt_convertARGB32ToARGB32PM(buffer, src, count); never executed: return qt_convertARGB32ToARGB32PM(buffer, src, count); | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
399 | buffer[i] = RGBA2ARGB(src[i]); never executed: buffer[i] = RGBA2ARGB(src[i]); | 0 | ||||||||||||||||||
400 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
401 | } | - | ||||||||||||||||||
402 | - | |||||||||||||||||||
403 | static const uint * convertRGBA8888ToARGB32PM(uint *buffer, const uint *src, int count, | - | ||||||||||||||||||
404 | const QPixelLayout *, const QRgb *) | - | ||||||||||||||||||
405 | { | - | ||||||||||||||||||
406 | return never executed: qt_convertRGBA8888ToARGB32PM(buffer, src, count);return qt_convertRGBA8888ToARGB32PM(buffer, src, count); never executed: return qt_convertRGBA8888ToARGB32PM(buffer, src, count); | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
413 | buffer[i] = qRgba(0, 0, 0, src[i]); never executed: buffer[i] = qRgba(0, 0, 0, src[i]); | 0 | ||||||||||||||||||
414 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
421 | buffer[i] = qRgb(src[i], src[i], src[i]); never executed: buffer[i] = qRgb(src[i], src[i], src[i]); | 0 | ||||||||||||||||||
422 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
429 | buffer[i] = QRgba64::fromRgba(0, 0, 0, src[i]); never executed: buffer[i] = QRgba64::fromRgba(0, 0, 0, src[i]); | 0 | ||||||||||||||||||
430 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
437 | buffer[i] = QRgba64::fromRgba(src[i], src[i], src[i], 255); never executed: buffer[i] = QRgba64::fromRgba(src[i], src[i], src[i], 255); | 0 | ||||||||||||||||||
438 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
445 | buffer[i] = qUnpremultiply(src[i]); never executed: buffer[i] = qUnpremultiply(src[i]); | 0 | ||||||||||||||||||
446 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
453 | buffer[i] = ARGB2RGBA(src[i]); never executed: buffer[i] = ARGB2RGBA(src[i]); | 0 | ||||||||||||||||||
454 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
462 | return; never executed: return; | 0 | ||||||||||||||||||
463 | - | |||||||||||||||||||
464 | const __m128i amask = _mm_set1_epi32(0xff000000); | - | ||||||||||||||||||
465 | int i = 0; | - | ||||||||||||||||||
466 | for (; ((
| 0 | ||||||||||||||||||
467 | uint s = *src++; | - | ||||||||||||||||||
468 | if (RGBA
| 0 | ||||||||||||||||||
469 | s = RGBA2ARGB(s); never executed: s = RGBA2ARGB(s); | 0 | ||||||||||||||||||
470 | *buffer++ = QRgba64::fromArgb32(s); | - | ||||||||||||||||||
471 | } never executed: end of block | 0 | ||||||||||||||||||
472 | for (; i < count-3
| 0 | ||||||||||||||||||
473 | __m128i vs = _mm_loadu_si128((const __m128i*)src); | - | ||||||||||||||||||
474 | if (maskAlpha
| 0 | ||||||||||||||||||
475 | vs = _mm_or_si128(vs, amask); never executed: vs = _mm_or_si128(vs, amask); | 0 | ||||||||||||||||||
476 | src += 4; | - | ||||||||||||||||||
477 | __m128i v1 = _mm_unpacklo_epi8(vs, vs); | - | ||||||||||||||||||
478 | __m128i v2 = _mm_unpackhi_epi8(vs, vs); | - | ||||||||||||||||||
479 | if (!RGBA
| 0 | ||||||||||||||||||
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 | } never executed: end of block | 0 | ||||||||||||||||||
485 | _mm_store_si128((__m128i*)(buffer), v1); | - | ||||||||||||||||||
486 | buffer += 2; | - | ||||||||||||||||||
487 | _mm_store_si128((__m128i*)(buffer), v2); | - | ||||||||||||||||||
488 | buffer += 2; | - | ||||||||||||||||||
489 | } never executed: end of block | 0 | ||||||||||||||||||
490 | - | |||||||||||||||||||
491 | for (; i < count
| 0 | ||||||||||||||||||
492 | uint s = *src++; | - | ||||||||||||||||||
493 | if (RGBA
| 0 | ||||||||||||||||||
494 | s = RGBA2ARGB(s); never executed: s = RGBA2ARGB(s); | 0 | ||||||||||||||||||
495 | *buffer++ = QRgba64::fromArgb32(s); | - | ||||||||||||||||||
496 | } never executed: end of block | 0 | ||||||||||||||||||
497 | } never executed: end of block | 0 | ||||||||||||||||||
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 never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
518 | buffer[i] = buffer[i].premultiplied(); never executed: buffer[i] = buffer[i].premultiplied(); | 0 | ||||||||||||||||||
519 | - | |||||||||||||||||||
520 | - | |||||||||||||||||||
521 | - | |||||||||||||||||||
522 | - | |||||||||||||||||||
523 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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 never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
544 | buffer[i] = buffer[i].premultiplied(); never executed: buffer[i] = buffer[i].premultiplied(); | 0 | ||||||||||||||||||
545 | - | |||||||||||||||||||
546 | - | |||||||||||||||||||
547 | - | |||||||||||||||||||
548 | - | |||||||||||||||||||
549 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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 never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
568 | buffer[i] = ARGB2RGBA(qUnpremultiply(src[i])); never executed: buffer[i] = ARGB2RGBA(qUnpremultiply(src[i])); | 0 | ||||||||||||||||||
569 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
576 | buffer[i] = ARGB2RGBA(0xff000000 | src[i]); never executed: buffer[i] = ARGB2RGBA(0xff000000 | src[i]); | 0 | ||||||||||||||||||
577 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
584 | buffer[i] = ARGB2RGBA(0xff000000 | qUnpremultiply(src[i])); never executed: buffer[i] = ARGB2RGBA(0xff000000 | qUnpremultiply(src[i])); | 0 | ||||||||||||||||||
585 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
593 | buffer[i] = qConvertA2rgb30ToArgb32<PixelOrder>(src[i]); never executed: buffer[i] = qConvertA2rgb30ToArgb32<PixelOrder>(src[i]); | 0 | ||||||||||||||||||
594 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
602 | return; never executed: return; | 0 | ||||||||||||||||||
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 (; ((
| 0 | ||||||||||||||||||
611 | * never executed: buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++);*buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++); never executed: *buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++); | 0 | ||||||||||||||||||
612 | - | |||||||||||||||||||
613 | for (; i < count-3
| 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
626 | vrb = _mm_or_si128(vr, ((__m128i)__builtin_ia32_pslldqi128 ((__m128i)(vb), (int)(2) * 8))); never executed: vrb = _mm_or_si128(vr, ((__m128i)__builtin_ia32_pslldqi128 ((__m128i)(vb), (int)(2) * 8))); | 0 | ||||||||||||||||||
627 | else | - | ||||||||||||||||||
628 | vrb = _mm_or_si128(vb, ((__m128i)__builtin_ia32_pslldqi128 ((__m128i)(vr), (int)(2) * 8))); never executed: vrb = _mm_or_si128(vb, ((__m128i)__builtin_ia32_pslldqi128 ((__m128i)(vr), (int)(2) * 8))); | 0 | ||||||||||||||||||
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 | } never executed: end of block | 0 | ||||||||||||||||||
635 | - | |||||||||||||||||||
636 | for (; i < count
| 0 | ||||||||||||||||||
637 | * never executed: buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++);*buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++); never executed: *buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++); | 0 | ||||||||||||||||||
638 | } never executed: end of block | 0 | ||||||||||||||||||
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 never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
659 | buffer[i] = qConvertArgb32ToA2rgb30<PixelOrder>(src[i]); never executed: buffer[i] = qConvertArgb32ToA2rgb30<PixelOrder>(src[i]); | 0 | ||||||||||||||||||
660 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
668 | buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(src[i]); never executed: buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(src[i]); | 0 | ||||||||||||||||||
669 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
677 | buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(qUnpremultiply(src[i])); never executed: buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(qUnpremultiply(src[i])); | 0 | ||||||||||||||||||
678 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
685 | buffer[i] = qAlpha(src[i]); never executed: buffer[i] = qAlpha(src[i]); | 0 | ||||||||||||||||||
686 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
693 | buffer[i] = qGray(src[i]); never executed: buffer[i] = qGray(src[i]); | 0 | ||||||||||||||||||
694 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
701 | buffer[i] = qGray(qUnpremultiply(src[i])); never executed: buffer[i] = qGray(qUnpremultiply(src[i])); | 0 | ||||||||||||||||||
702 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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 never executed: (src[index >> 3] >> (index & 7)) & 1;return (src[index >> 3] >> (index & 7)) & 1; never executed: return (src[index >> 3] >> (index & 7)) & 1; | 0 | ||||||||||||||||||
712 | } | - | ||||||||||||||||||
713 | - | |||||||||||||||||||
714 | template <> | - | ||||||||||||||||||
715 | inline uint fetchPixel<QPixelLayout::BPP1MSB>(const uchar *src, int index) | - | ||||||||||||||||||
716 | { | - | ||||||||||||||||||
717 | return never executed: (src[index >> 3] >> (~index & 7)) & 1;return (src[index >> 3] >> (~index & 7)) & 1; never executed: return (src[index >> 3] >> (~index & 7)) & 1; | 0 | ||||||||||||||||||
718 | } | - | ||||||||||||||||||
719 | - | |||||||||||||||||||
720 | template <> | - | ||||||||||||||||||
721 | inline uint fetchPixel<QPixelLayout::BPP8>(const uchar *src, int index) | - | ||||||||||||||||||
722 | { | - | ||||||||||||||||||
723 | return never executed: src[index];return src[index]; never executed: return src[index]; | 0 | ||||||||||||||||||
724 | } | - | ||||||||||||||||||
725 | - | |||||||||||||||||||
726 | template <> | - | ||||||||||||||||||
727 | inline uint fetchPixel<QPixelLayout::BPP16>(const uchar *src, int index) | - | ||||||||||||||||||
728 | { | - | ||||||||||||||||||
729 | return never executed: reinterpret_cast<const quint16 *>(src)[index];return reinterpret_cast<const quint16 *>(src)[index]; never executed: return reinterpret_cast<const quint16 *>(src)[index]; | 0 | ||||||||||||||||||
730 | } | - | ||||||||||||||||||
731 | - | |||||||||||||||||||
732 | template <> | - | ||||||||||||||||||
733 | inline uint fetchPixel<QPixelLayout::BPP24>(const uchar *src, int index) | - | ||||||||||||||||||
734 | { | - | ||||||||||||||||||
735 | return never executed: reinterpret_cast<const quint24 *>(src)[index];return reinterpret_cast<const quint24 *>(src)[index]; never executed: return reinterpret_cast<const quint24 *>(src)[index]; | 0 | ||||||||||||||||||
736 | } | - | ||||||||||||||||||
737 | - | |||||||||||||||||||
738 | template <> | - | ||||||||||||||||||
739 | inline uint fetchPixel<QPixelLayout::BPP32>(const uchar *src, int index) | - | ||||||||||||||||||
740 | { | - | ||||||||||||||||||
741 | return never executed: reinterpret_cast<const uint *>(src)[index];return reinterpret_cast<const uint *>(src)[index]; never executed: return reinterpret_cast<const uint *>(src)[index]; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
748 | buffer[i] = fetchPixel<bpp>(src, index + i); never executed: buffer[i] = fetchPixel<bpp>(src, index + i); | 0 | ||||||||||||||||||
749 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
750 | } | - | ||||||||||||||||||
751 | - | |||||||||||||||||||
752 | template <> | - | ||||||||||||||||||
753 | inline const uint * fetchPixels<QPixelLayout::BPP32>(uint *, const uchar *src, int index, int) | - | ||||||||||||||||||
754 | { | - | ||||||||||||||||||
755 | return never executed: reinterpret_cast<const uint *>(src) + index;return reinterpret_cast<const uint *>(src) + index; never executed: return reinterpret_cast<const uint *>(src) + index; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
765 | dest[index >> 3] |= 1 << (index & 7); never executed: dest[index >> 3] |= 1 << (index & 7); | 0 | ||||||||||||||||||
766 | else | - | ||||||||||||||||||
767 | dest[index >> 3] &= ~(1 << (index & 7)); never executed: dest[index >> 3] &= ~(1 << (index & 7)); | 0 | ||||||||||||||||||
768 | } | - | ||||||||||||||||||
769 | - | |||||||||||||||||||
770 | template <> | - | ||||||||||||||||||
771 | inline void storePixel<QPixelLayout::BPP1MSB>(uchar *dest, int index, uint pixel) | - | ||||||||||||||||||
772 | { | - | ||||||||||||||||||
773 | if (pixel
| 0 | ||||||||||||||||||
774 | dest[index >> 3] |= 1 << (~index & 7); never executed: dest[index >> 3] |= 1 << (~index & 7); | 0 | ||||||||||||||||||
775 | else | - | ||||||||||||||||||
776 | dest[index >> 3] &= ~(1 << (~index & 7)); never executed: dest[index >> 3] &= ~(1 << (~index & 7)); | 0 | ||||||||||||||||||
777 | } | - | ||||||||||||||||||
778 | - | |||||||||||||||||||
779 | template <> | - | ||||||||||||||||||
780 | inline void storePixel<QPixelLayout::BPP8>(uchar *dest, int index, uint pixel) | - | ||||||||||||||||||
781 | { | - | ||||||||||||||||||
782 | dest[index] = uchar(pixel); | - | ||||||||||||||||||
783 | } never executed: end of block | 0 | ||||||||||||||||||
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 | } never executed: end of block | 0 | ||||||||||||||||||
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 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
801 | storePixel<width>(dest, index + i, src[i]); never executed: storePixel<width>(dest, index + i, src[i]); | 0 | ||||||||||||||||||
802 | } never executed: end of block | 0 | ||||||||||||||||||
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 | } never executed: end of block | 0 | ||||||||||||||||||
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 | - | |||||||||||||||||||
856 | StorePixelsFunc 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
| 0 | ||||||||||||||||||
889 | *buffer = data[x>>3] & (0x80 >> (x & 7))
| 0 | ||||||||||||||||||
890 | ++buffer; | - | ||||||||||||||||||
891 | ++x; | - | ||||||||||||||||||
892 | } never executed: end of block | 0 | ||||||||||||||||||
893 | return never executed: start;return start; never executed: return start; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
902 | *buffer = data[x>>3] & (0x1 << (x & 7))
| 0 | ||||||||||||||||||
903 | ++buffer; | - | ||||||||||||||||||
904 | ++x; | - | ||||||||||||||||||
905 | } never executed: end of block | 0 | ||||||||||||||||||
906 | return never executed: start;return start; never executed: return start; | 0 | ||||||||||||||||||
907 | } | - | ||||||||||||||||||
908 | - | |||||||||||||||||||
909 | static uint * destFetchARGB32P(uint *, QRasterBuffer *rasterBuffer, int x, int y, int) | - | ||||||||||||||||||
910 | { | - | ||||||||||||||||||
911 | return never executed: (uint *)rasterBuffer->scanLine(y) + x;return (uint *)rasterBuffer->scanLine(y) + x; never executed: return (uint *)rasterBuffer->scanLine(y) + x; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
918 | buffer[i] = qConvertRgb16To32(data[i]); never executed: buffer[i] = qConvertRgb16To32(data[i]); | 0 | ||||||||||||||||||
919 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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 never executed: const_cast<uint *>(layout->convertToARGB32PM(buffer, ptr, length, layout, 0));return const_cast<uint *>(layout->convertToARGB32PM(buffer, ptr, length, layout, 0)); never executed: return const_cast<uint *>(layout->convertToARGB32PM(buffer, ptr, length, layout, 0)); | 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 never executed: const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, ptr, length, layout, 0));return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, ptr, length, layout, 0)); never executed: return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, ptr, length, layout, 0)); | 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 never executed: const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, src, length, layout, 0));return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, src, length, layout, 0)); never executed: return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, src, length, layout, 0)); | 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
| 0 | ||||||||||||||||||
1029 | return never executed: color_0;return color_0; never executed: return color_0; | 0 | ||||||||||||||||||
1030 | return never executed: color_1;return color_1; never executed: return color_1; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1041 | for (int i = 0; i < length
| 0 | ||||||||||||||||||
1042 | if (buffer[i] == rasterBuffer->destColor0
| 0 | ||||||||||||||||||
1043 | data[x >> 3] &= ~(0x80 >> (x & 7)); | - | ||||||||||||||||||
1044 | } never executed: else if (buffer[i] == rasterBuffer->destColor1end of block
| 0 | ||||||||||||||||||
1045 | data[x >> 3] |= 0x80 >> (x & 7); | - | ||||||||||||||||||
1046 | } never executed: else if (findNearestColor(buffer[i], rasterBuffer) == rasterBuffer->destColor0end of block
| 0 | ||||||||||||||||||
1047 | data[x >> 3] &= ~(0x80 >> (x & 7)); | - | ||||||||||||||||||
1048 | } never executed: else {end of block | 0 | ||||||||||||||||||
1049 | data[x >> 3] |= 0x80 >> (x & 7); | - | ||||||||||||||||||
1050 | } never executed: end of block | 0 | ||||||||||||||||||
1051 | ++x; | - | ||||||||||||||||||
1052 | } never executed: end of block | 0 | ||||||||||||||||||
1053 | } never executed: else {end of block | 0 | ||||||||||||||||||
1054 | for (int i = 0; i < length
| 0 | ||||||||||||||||||
1055 | if (qGray(buffer[i]) < int(qt_bayer_matrix[y & 15][x & 15])
| 0 | ||||||||||||||||||
1056 | data[x >> 3] |= 0x80 >> (x & 7); never executed: data[x >> 3] |= 0x80 >> (x & 7); | 0 | ||||||||||||||||||
1057 | else | - | ||||||||||||||||||
1058 | data[x >> 3] &= ~(0x80 >> (x & 7)); never executed: data[x >> 3] &= ~(0x80 >> (x & 7)); | 0 | ||||||||||||||||||
1059 | ++x; | - | ||||||||||||||||||
1060 | } never executed: end of block | 0 | ||||||||||||||||||
1061 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1068 | for (int i = 0; i < length
| 0 | ||||||||||||||||||
1069 | if (buffer[i] == rasterBuffer->destColor0
| 0 | ||||||||||||||||||
1070 | data[x >> 3] &= ~(1 << (x & 7)); | - | ||||||||||||||||||
1071 | } never executed: else if (buffer[i] == rasterBuffer->destColor1end of block
| 0 | ||||||||||||||||||
1072 | data[x >> 3] |= 1 << (x & 7); | - | ||||||||||||||||||
1073 | } never executed: else if (findNearestColor(buffer[i], rasterBuffer) == rasterBuffer->destColor0end of block
| 0 | ||||||||||||||||||
1074 | data[x >> 3] &= ~(1 << (x & 7)); | - | ||||||||||||||||||
1075 | } never executed: else {end of block | 0 | ||||||||||||||||||
1076 | data[x >> 3] |= 1 << (x & 7); | - | ||||||||||||||||||
1077 | } never executed: end of block | 0 | ||||||||||||||||||
1078 | ++x; | - | ||||||||||||||||||
1079 | } never executed: end of block | 0 | ||||||||||||||||||
1080 | } never executed: else {end of block | 0 | ||||||||||||||||||
1081 | for (int i = 0; i < length
| 0 | ||||||||||||||||||
1082 | if (qGray(buffer[i]) < int(qt_bayer_matrix[y & 15][x & 15])
| 0 | ||||||||||||||||||
1083 | data[x >> 3] |= 1 << (x & 7); never executed: data[x >> 3] |= 1 << (x & 7); | 0 | ||||||||||||||||||
1084 | else | - | ||||||||||||||||||
1085 | data[x >> 3] &= ~(1 << (x & 7)); never executed: data[x >> 3] &= ~(1 << (x & 7)); | 0 | ||||||||||||||||||
1086 | ++x; | - | ||||||||||||||||||
1087 | } never executed: end of block | 0 | ||||||||||||||||||
1088 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1095 | data[i] = qConvertRgb32To16(buffer[i]); never executed: data[i] = qConvertRgb32To16(buffer[i]); | 0 | ||||||||||||||||||
1096 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1105 | int l = qMin(length, buffer_size); | - | ||||||||||||||||||
1106 | const uint *ptr = 0; | - | ||||||||||||||||||
1107 | if (!layout->premultiplied
| 0 | ||||||||||||||||||
1108 | ptr = layout->convertFromRGB32(buf, buffer, l, layout, 0); never executed: ptr = layout->convertFromRGB32(buf, buffer, l, layout, 0); | 0 | ||||||||||||||||||
1109 | else | - | ||||||||||||||||||
1110 | ptr = layout->convertFromARGB32PM(buf, buffer, l, layout, 0); never executed: ptr = layout->convertFromARGB32PM(buf, buffer, l, layout, 0); | 0 | ||||||||||||||||||
1111 | store(dest, ptr, x, l); | - | ||||||||||||||||||
1112 | length -= l; | - | ||||||||||||||||||
1113 | buffer += l; | - | ||||||||||||||||||
1114 | x += l; | - | ||||||||||||||||||
1115 | } never executed: end of block | 0 | ||||||||||||||||||
1116 | } never executed: end of block | 0 | ||||||||||||||||||
1117 | - | |||||||||||||||||||
1118 | static void convertFromRgb64(uint *dest, const QRgba64 *src, int length) | - | ||||||||||||||||||
1119 | { | - | ||||||||||||||||||
1120 | for (int i = 0; i < length
| 0 | ||||||||||||||||||
1121 | dest[i] = src[i].toArgb32(); | - | ||||||||||||||||||
1122 | } never executed: end of block | 0 | ||||||||||||||||||
1123 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1132 | int l = qMin(length, buffer_size); | - | ||||||||||||||||||
1133 | const uint *ptr = 0; | - | ||||||||||||||||||
1134 | convertFromRgb64(buf, buffer, l); | - | ||||||||||||||||||
1135 | if (!layout->premultiplied
| 0 | ||||||||||||||||||
1136 | ptr = layout->convertFromRGB32(buf, buf, l, layout, 0); never executed: ptr = layout->convertFromRGB32(buf, buf, l, layout, 0); | 0 | ||||||||||||||||||
1137 | else | - | ||||||||||||||||||
1138 | ptr = layout->convertFromARGB32PM(buf, buf, l, layout, 0); never executed: ptr = layout->convertFromARGB32PM(buf, buf, l, layout, 0); | 0 | ||||||||||||||||||
1139 | store(dest, ptr, x, l); | - | ||||||||||||||||||
1140 | length -= l; | - | ||||||||||||||||||
1141 | buffer += l; | - | ||||||||||||||||||
1142 | x += l; | - | ||||||||||||||||||
1143 | } never executed: end of block | 0 | ||||||||||||||||||
1144 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1155 | *dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++); | - | ||||||||||||||||||
1156 | } never executed: end of block | 0 | ||||||||||||||||||
1157 | - | |||||||||||||||||||
1158 | for (; i < count-15
| 0 | ||||||||||||||||||
1159 | - | |||||||||||||||||||
1160 | - | |||||||||||||||||||
1161 | __m128i vOr = _mm_set1_epi32(0); | - | ||||||||||||||||||
1162 | __m128i vAnd = _mm_set1_epi32(0xffffffff); | - | ||||||||||||||||||
1163 | for (int j = 0; j < 16
| 0 | ||||||||||||||||||
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 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1172 | for (int j = 0; j < 16
| 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1183 | vr = _mm_slli_epi32(vr, 20); never executed: vr = _mm_slli_epi32(vr, 20); | 0 | ||||||||||||||||||
1184 | else | - | ||||||||||||||||||
1185 | vb = _mm_slli_epi32(vb, 20); never executed: vb = _mm_slli_epi32(vb, 20); | 0 | ||||||||||||||||||
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 | } never executed: end of block | 0 | ||||||||||||||||||
1192 | } never executed: else if (orAlpha == 0end of block
| 0 | ||||||||||||||||||
1193 | for (int j = 0; j < 16
| 0 | ||||||||||||||||||
1194 | *dest++ = 0; | - | ||||||||||||||||||
1195 | buffer++; | - | ||||||||||||||||||
1196 | } never executed: end of block | 0 | ||||||||||||||||||
1197 | } never executed: else {end of block | 0 | ||||||||||||||||||
1198 | for (int j = 0; j < 16
| 0 | ||||||||||||||||||
1199 | * never executed: dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++);*dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++); never executed: *dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++); | 0 | ||||||||||||||||||
1200 | } never executed: end of block | 0 | ||||||||||||||||||
1201 | } | - | ||||||||||||||||||
1202 | - | |||||||||||||||||||
1203 | for (; i < count
| 0 | ||||||||||||||||||
1204 | * never executed: dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++);*dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++); never executed: *dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++); | 0 | ||||||||||||||||||
1205 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1212 | dest[i] = buffer[i].unpremultiplied().toArgb32(); | - | ||||||||||||||||||
1213 | } never executed: end of block | 0 | ||||||||||||||||||
1214 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1220 | dest[i] = ARGB2RGBA(buffer[i].unpremultiplied().toArgb32()); | - | ||||||||||||||||||
1221 | } never executed: end of block | 0 | ||||||||||||||||||
1222 | } never executed: end of block | 0 | ||||||||||||||||||
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 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1310 | return never executed: layout->convertToARGB32PM(buffer, ptr, length, layout, clut);return layout->convertToARGB32PM(buffer, ptr, length, layout, clut); never executed: return layout->convertToARGB32PM(buffer, ptr, length, layout, clut); | 0 | ||||||||||||||||||
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 never executed: ((const uint *)scanLine) + x;return ((const uint *)scanLine) + x; never executed: return ((const uint *)scanLine) + x; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1329 | buffer[i] = qConvertRgb16To32(scanLine[i]); never executed: buffer[i] = qConvertRgb16To32(scanLine[i]); | 0 | ||||||||||||||||||
1330 | - | |||||||||||||||||||
1331 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1339 | if (layout->bpp != QPixelLayout::BPP32
| 0 | ||||||||||||||||||
1340 | uint buffer32[buffer_size]; | - | ||||||||||||||||||
1341 | const uint *ptr = qFetchPixels[layout->bpp](buffer32, data->texture.scanLine(y), x, length); | - | ||||||||||||||||||
1342 | return never executed: layout->convertToARGB64PM(buffer, ptr, length, layout, clut);return layout->convertToARGB64PM(buffer, ptr, length, layout, clut); never executed: return layout->convertToARGB64PM(buffer, ptr, length, layout, clut); | 0 | ||||||||||||||||||
1343 | } else { | - | ||||||||||||||||||
1344 | const uint *src = (const uint *)data->texture.scanLine(y) + x; | - | ||||||||||||||||||
1345 | return never executed: layout->convertToARGB64PM(buffer, src, length, layout, clut);return layout->convertToARGB64PM(buffer, src, length, layout, clut); never executed: return layout->convertToARGB64PM(buffer, src, length, layout, clut); | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1373 | int px = fx >> 16; | - | ||||||||||||||||||
1374 | int py = fy >> 16; | - | ||||||||||||||||||
1375 | - | |||||||||||||||||||
1376 | if (blendType == BlendTransformedTiled
| 0 | ||||||||||||||||||
1377 | px %= image_width; | - | ||||||||||||||||||
1378 | py %= image_height; | - | ||||||||||||||||||
1379 | if (px < 0
never executed: px += image_width; | 0 | ||||||||||||||||||
1380 | if (py < 0
never executed: py += image_height; | 0 | ||||||||||||||||||
1381 | } never executed: else {end of block | 0 | ||||||||||||||||||
1382 | px = qBound(0, px, image_width - 1); | - | ||||||||||||||||||
1383 | py = qBound(0, py, image_height - 1); | - | ||||||||||||||||||
1384 | } never executed: end of block | 0 | ||||||||||||||||||
1385 | *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px]; | - | ||||||||||||||||||
1386 | - | |||||||||||||||||||
1387 | fx += fdx; | - | ||||||||||||||||||
1388 | fy += fdy; | - | ||||||||||||||||||
1389 | ++b; | - | ||||||||||||||||||
1390 | } never executed: end of block | 0 | ||||||||||||||||||
1391 | } never executed: else {end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1408 | px %= image_width; | - | ||||||||||||||||||
1409 | py %= image_height; | - | ||||||||||||||||||
1410 | if (px < 0
never executed: px += image_width; | 0 | ||||||||||||||||||
1411 | if (py < 0
never executed: py += image_height; | 0 | ||||||||||||||||||
1412 | } never executed: else {end of block | 0 | ||||||||||||||||||
1413 | px = qBound(0, px, image_width - 1); | - | ||||||||||||||||||
1414 | py = qBound(0, py, image_height - 1); | - | ||||||||||||||||||
1415 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1423 | fw += fdw; | - | ||||||||||||||||||
1424 | } never executed: end of block | 0 | ||||||||||||||||||
1425 | ++b; | - | ||||||||||||||||||
1426 | } never executed: end of block | 0 | ||||||||||||||||||
1427 | } never executed: end of block | 0 | ||||||||||||||||||
1428 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1457 | int px = fx >> 16; | - | ||||||||||||||||||
1458 | int py = fy >> 16; | - | ||||||||||||||||||
1459 | - | |||||||||||||||||||
1460 | if (blendType == BlendTransformedTiled
| 0 | ||||||||||||||||||
1461 | px %= image_width; | - | ||||||||||||||||||
1462 | py %= image_height; | - | ||||||||||||||||||
1463 | if (px < 0
never executed: px += image_width; | 0 | ||||||||||||||||||
1464 | if (py < 0
never executed: py += image_height; | 0 | ||||||||||||||||||
1465 | } never executed: else {end of block | 0 | ||||||||||||||||||
1466 | px = qBound(0, px, image_width - 1); | - | ||||||||||||||||||
1467 | py = qBound(0, py, image_height - 1); | - | ||||||||||||||||||
1468 | } never executed: end of block | 0 | ||||||||||||||||||
1469 | *b = fetch(data->texture.scanLine(py), px); | - | ||||||||||||||||||
1470 | - | |||||||||||||||||||
1471 | fx += fdx; | - | ||||||||||||||||||
1472 | fy += fdy; | - | ||||||||||||||||||
1473 | ++b; | - | ||||||||||||||||||
1474 | } never executed: end of block | 0 | ||||||||||||||||||
1475 | } never executed: else {end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1492 | px %= image_width; | - | ||||||||||||||||||
1493 | py %= image_height; | - | ||||||||||||||||||
1494 | if (px < 0
never executed: px += image_width; | 0 | ||||||||||||||||||
1495 | if (py < 0
never executed: py += image_height; | 0 | ||||||||||||||||||
1496 | } never executed: else {end of block | 0 | ||||||||||||||||||
1497 | px = qBound(0, px, image_width - 1); | - | ||||||||||||||||||
1498 | py = qBound(0, py, image_height - 1); | - | ||||||||||||||||||
1499 | } never executed: end of block | 0 | ||||||||||||||||||
1500 | *b = fetch(data->texture.scanLine(py), px); | - | ||||||||||||||||||
1501 | - | |||||||||||||||||||
1502 | fx += fdx; | - | ||||||||||||||||||
1503 | fy += fdy; | - | ||||||||||||||||||
1504 | fw += fdw; | - | ||||||||||||||||||
1505 | - | |||||||||||||||||||
1506 | if (!fw
| 0 | ||||||||||||||||||
1507 | fw += fdw; | - | ||||||||||||||||||
1508 | } never executed: end of block | 0 | ||||||||||||||||||
1509 | ++b; | - | ||||||||||||||||||
1510 | } never executed: end of block | 0 | ||||||||||||||||||
1511 | } never executed: end of block | 0 | ||||||||||||||||||
1512 | const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; | - | ||||||||||||||||||
1513 | return never executed: layout->convertToARGB32PM(buffer, buffer, length, layout, clut);return layout->convertToARGB32PM(buffer, buffer, length, layout, clut); never executed: return layout->convertToARGB32PM(buffer, buffer, length, layout, clut); | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1544 | if (j == buffer_size
| 0 | ||||||||||||||||||
1545 | layout->convertToARGB64PM(b, buffer32, buffer_size, layout, clut); | - | ||||||||||||||||||
1546 | b += buffer_size; | - | ||||||||||||||||||
1547 | j = 0; | - | ||||||||||||||||||
1548 | } never executed: end of block | 0 | ||||||||||||||||||
1549 | int px = fx >> 16; | - | ||||||||||||||||||
1550 | int py = fy >> 16; | - | ||||||||||||||||||
1551 | - | |||||||||||||||||||
1552 | if (blendType == BlendTransformedTiled
| 0 | ||||||||||||||||||
1553 | px %= image_width; | - | ||||||||||||||||||
1554 | py %= image_height; | - | ||||||||||||||||||
1555 | if (px < 0
never executed: px += image_width; | 0 | ||||||||||||||||||
1556 | if (py < 0
never executed: py += image_height; | 0 | ||||||||||||||||||
1557 | } never executed: else {end of block | 0 | ||||||||||||||||||
1558 | px = qBound(0, px, image_width - 1); | - | ||||||||||||||||||
1559 | py = qBound(0, py, image_height - 1); | - | ||||||||||||||||||
1560 | } never executed: end of block | 0 | ||||||||||||||||||
1561 | buffer32[j] = fetch(data->texture.scanLine(py), px); | - | ||||||||||||||||||
1562 | - | |||||||||||||||||||
1563 | fx += fdx; | - | ||||||||||||||||||
1564 | fy += fdy; | - | ||||||||||||||||||
1565 | ++i; ++j; | - | ||||||||||||||||||
1566 | } never executed: end of block | 0 | ||||||||||||||||||
1567 | if (j > 0
| 0 | ||||||||||||||||||
1568 | layout->convertToARGB64PM(b, buffer32, j, layout, clut); | - | ||||||||||||||||||
1569 | b += j; | - | ||||||||||||||||||
1570 | } never executed: end of block | 0 | ||||||||||||||||||
1571 | } never executed: else {end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1582 | if (j == buffer_size
| 0 | ||||||||||||||||||
1583 | layout->convertToARGB64PM(b, buffer32, buffer_size, layout, clut); | - | ||||||||||||||||||
1584 | b += buffer_size; | - | ||||||||||||||||||
1585 | j = 0; | - | ||||||||||||||||||
1586 | } never executed: end of block | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1594 | px %= image_width; | - | ||||||||||||||||||
1595 | py %= image_height; | - | ||||||||||||||||||
1596 | if (px < 0
never executed: px += image_width; | 0 | ||||||||||||||||||
1597 | if (py < 0
never executed: py += image_height; | 0 | ||||||||||||||||||
1598 | } never executed: else {end of block | 0 | ||||||||||||||||||
1599 | px = qBound(0, px, image_width - 1); | - | ||||||||||||||||||
1600 | py = qBound(0, py, image_height - 1); | - | ||||||||||||||||||
1601 | } never executed: end of block | 0 | ||||||||||||||||||
1602 | buffer32[j] = fetch(data->texture.scanLine(py), px); | - | ||||||||||||||||||
1603 | - | |||||||||||||||||||
1604 | fx += fdx; | - | ||||||||||||||||||
1605 | fy += fdy; | - | ||||||||||||||||||
1606 | fw += fdw; | - | ||||||||||||||||||
1607 | - | |||||||||||||||||||
1608 | if (!fw
| 0 | ||||||||||||||||||
1609 | fw += fdw; | - | ||||||||||||||||||
1610 | } never executed: end of block | 0 | ||||||||||||||||||
1611 | ++i; ++j; | - | ||||||||||||||||||
1612 | } never executed: end of block | 0 | ||||||||||||||||||
1613 | if (j > 0
| 0 | ||||||||||||||||||
1614 | layout->convertToARGB64PM(b, buffer32, j, layout, clut); | - | ||||||||||||||||||
1615 | b += j; | - | ||||||||||||||||||
1616 | } never executed: end of block | 0 | ||||||||||||||||||
1617 | } never executed: end of block | 0 | ||||||||||||||||||
1618 | return never executed: buffer;return buffer; never executed: return buffer; | 0 | ||||||||||||||||||
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 never executed: (((tlrb + trrb + blrb + brrb) >> 8) & 0x00ff00ff) | ((tlag + trag + blag + brag) & 0xff00ff00);return (((tlrb + trrb + blrb + brrb) >> 8) & 0x00ff00ff) | ((tlag + trag + blag + brag) & 0xff00ff00); never executed: return (((tlrb + trrb + blrb + brrb) >> 8) & 0x00ff00ff) | ((tlag + trag + blag + brag) & 0xff00ff00); | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
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 | } never executed: end of block | 0 | ||||||||||||||||||
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 never executed: QRgba64::fromRgba64(_mm_cvtsi128_si64(vt));return QRgba64::fromRgba64(_mm_cvtsi128_si64(vt)); never executed: return QRgba64::fromRgba64(_mm_cvtsi128_si64(vt)); | 0 | ||||||||||||||||||
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
| 0 | ||||||||||||||||||
1670 | v1 += max; never executed: v1 += max; | 0 | ||||||||||||||||||
1671 | v2 = v1 + 1; | - | ||||||||||||||||||
1672 | if (v2 == max
| 0 | ||||||||||||||||||
1673 | v2 = 0; never executed: v2 = 0; | 0 | ||||||||||||||||||
1674 | ((!(v1 >= 0 && v1 < max)) ? qt_assert("v1 >= 0 && v1 < max",__FILE__,1889) : qt_noop()); | - | ||||||||||||||||||
1675 | ((!(v2 >= 0 && v2 < max)) ? qt_assert("v2 >= 0 && v2 < max",__FILE__,1890) : qt_noop()); | - | ||||||||||||||||||
1676 | } never executed: end of block | 0 | ||||||||||||||||||
1677 | - | |||||||||||||||||||
1678 | template<> | - | ||||||||||||||||||
1679 | inline void fetchTransformedBilinear_pixelBounds<BlendTransformedBilinear>(int, int l1, int l2, int &v1, int &v2) | - | ||||||||||||||||||
1680 | { | - | ||||||||||||||||||
1681 | if (v1 < l1
| 0 | ||||||||||||||||||
1682 | v2 = v1 = l1; never executed: v2 = v1 = l1; | 0 | ||||||||||||||||||
1683 | else if (v1 >= l2
| 0 | ||||||||||||||||||
1684 | v2 = v1 = l2; never executed: v2 = v1 = l2; | 0 | ||||||||||||||||||
1685 | else | - | ||||||||||||||||||
1686 | v2 = v1 + 1; never executed: v2 = v1 + 1; | 0 | ||||||||||||||||||
1687 | ((!(v1 >= l1 && v1 <= l2)) ? qt_assert("v1 >= l1 && v1 <= l2",__FILE__,1902) : qt_noop()); | - | ||||||||||||||||||
1688 | ((!(v2 >= l1 && v2 <= l2)) ? qt_assert("v2 >= l1 && v2 <= l2",__FILE__,1903) : qt_noop()); | - | ||||||||||||||||||
1689 | } never executed: end of block | 0 | ||||||||||||||||||
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_matrix
| 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 == 0
| 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_scale
| 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__,1958) : qt_noop()); | - | ||||||||||||||||||
1744 | int f = 0; | - | ||||||||||||||||||
1745 | int lim = count; | - | ||||||||||||||||||
1746 | if (blendType == BlendTransformedBilinearTiled
| 0 | ||||||||||||||||||
1747 | x %= image_width; | - | ||||||||||||||||||
1748 | if (x < 0
never executed: x += image_width; | 0 | ||||||||||||||||||
1749 | } never executed: else {end of block | 0 | ||||||||||||||||||
1750 | lim = qMin(count, image_x2-x+1); | - | ||||||||||||||||||
1751 | if (x < image_x1
| 0 | ||||||||||||||||||
1752 | ((!(x <= image_x2)) ? qt_assert("x <= image_x2",__FILE__,1967) : 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: while (x < image_x1end of block
| 0 | ||||||||||||||||||
1763 | } never executed: end of block | 0 | ||||||||||||||||||
1764 | } never executed: end of block | 0 | ||||||||||||||||||
1765 | - | |||||||||||||||||||
1766 | if (blendType != BlendTransformedBilinearTiled
| 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 < lim
| 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 < count
| 0 | ||||||||||||||||||
1799 | if (blendType == BlendTransformedBilinearTiled
| 0 | ||||||||||||||||||
1800 | if (x >= image_width
never executed: x -= image_width; | 0 | ||||||||||||||||||
1801 | } never executed: else {end of block | 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__,2060) : qt_noop()); | - | ||||||||||||||||||
1815 | while (b < end
| 0 | ||||||||||||||||||
1816 | int x1 = (fx >> 16); | - | ||||||||||||||||||
1817 | int x2 = x1 + 1; | - | ||||||||||||||||||
1818 | ((!(x1 >= 0)) ? qt_assert("x1 >= 0",__FILE__,2064) : qt_noop()); | - | ||||||||||||||||||
1819 | ((!(x2 < count)) ? qt_assert("x2 < count",__FILE__,2065) : 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: else if ((fdx < 0end of block
| 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 < end
| 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: else {end of block | 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 != BlendTransformedBilinearTiled
| 0 | ||||||||||||||||||
1859 | while (b < end
never executed: 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; }break; never executed: uint *boundedEnd; if (fdx > 0end of block
never executed: else boundedEnd = qMin(end, buffer + uint((image_x1 - (fx >> 16)) / data->m11));boundedEnd = qMin(end, buffer + uint((image_x2 - (fx >> 16)) / data->m11)); never executed: boundedEnd -= 3;boundedEnd = qMin(end, buffer + uint((image_x1 - (fx >> 16)) / data->m11)); | 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 < boundedEnd
| 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) |