Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | class QPixmapFilterPrivate : public QObjectPrivate | - |
9 | { | - |
10 | inline QPixmapFilter* q_func() { return static_cast<QPixmapFilter *>(q_ptr); } inline const QPixmapFilter* q_func() const { return static_cast<const QPixmapFilter *>(q_ptr); } friend class QPixmapFilter; | - |
11 | public: | - |
12 | QPixmapFilter::FilterType type; | - |
13 | }; | - |
14 | QPixmapFilter::QPixmapFilter(FilterType type, QObject *parent) | - |
15 | : QObject(*new QPixmapFilterPrivate, parent) | - |
16 | { | - |
17 | d_func()->type = type; | - |
18 | } executed: } Execution Count:1 | 1 |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | QPixmapFilter::QPixmapFilter(QPixmapFilterPrivate&d, QPixmapFilter::FilterType type, QObject *parent) | - |
26 | : QObject(d, parent) | - |
27 | { | - |
28 | d_func()->type = type; | - |
29 | } executed: } Execution Count:18 | 18 |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | QPixmapFilter::~QPixmapFilter() | - |
38 | { | - |
39 | } | - |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | QPixmapFilter::FilterType QPixmapFilter::type() const | - |
48 | { | - |
49 | const QPixmapFilterPrivate * const d = d_func(); | - |
50 | return d->type; executed: return d->type; Execution Count:15 | 15 |
51 | } | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | | - |
59 | QRectF QPixmapFilter::boundingRectFor(const QRectF &rect) const | - |
60 | { | - |
61 | return rect; executed: return rect; Execution Count:4 | 4 |
62 | } | - |
63 | class QPixmapConvolutionFilterPrivate : public QPixmapFilterPrivate | - |
64 | { | - |
65 | public: | - |
66 | QPixmapConvolutionFilterPrivate(): convolutionKernel(0), kernelWidth(0), kernelHeight(0), convoluteAlpha(false) {} executed: } Execution Count:2 | 2 |
67 | ~QPixmapConvolutionFilterPrivate() { | - |
68 | delete[] convolutionKernel; | - |
69 | } executed: } Execution Count:2 | 2 |
70 | | - |
71 | qreal *convolutionKernel; | - |
72 | int kernelWidth; | - |
73 | int kernelHeight; | - |
74 | bool convoluteAlpha; | - |
75 | }; | - |
76 | QPixmapConvolutionFilter::QPixmapConvolutionFilter(QObject *parent) | - |
77 | : QPixmapFilter(*new QPixmapConvolutionFilterPrivate, ConvolutionFilter, parent) | - |
78 | { | - |
79 | QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
80 | d->convoluteAlpha = true; | - |
81 | } executed: } Execution Count:2 | 2 |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | QPixmapConvolutionFilter::~QPixmapConvolutionFilter() | - |
89 | { | - |
90 | } | - |
91 | void QPixmapConvolutionFilter::setConvolutionKernel(const qreal *kernel, int rows, int columns) | - |
92 | { | - |
93 | QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
94 | delete [] d->convolutionKernel; | - |
95 | d->convolutionKernel = new qreal[rows * columns]; | - |
96 | memcpy(d->convolutionKernel, kernel, sizeof(qreal) * rows * columns); | - |
97 | d->kernelWidth = columns; | - |
98 | d->kernelHeight = rows; | - |
99 | } executed: } Execution Count:5 | 5 |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | const qreal *QPixmapConvolutionFilter::convolutionKernel() const | - |
107 | { | - |
108 | const QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
109 | return d->convolutionKernel; never executed: return d->convolutionKernel; | 0 |
110 | } | - |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | int QPixmapConvolutionFilter::rows() const | - |
118 | { | - |
119 | const QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
120 | return d->kernelHeight; never executed: return d->kernelHeight; | 0 |
121 | } | - |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | int QPixmapConvolutionFilter::columns() const | - |
129 | { | - |
130 | const QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
131 | return d->kernelWidth; never executed: return d->kernelWidth; | 0 |
132 | } | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | QRectF QPixmapConvolutionFilter::boundingRectFor(const QRectF &rect) const | - |
139 | { | - |
140 | const QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
141 | return rect.adjusted(-d->kernelWidth / 2, -d->kernelHeight / 2, (d->kernelWidth - 1) / 2, (d->kernelHeight - 1) / 2); executed: return rect.adjusted(-d->kernelWidth / 2, -d->kernelHeight / 2, (d->kernelWidth - 1) / 2, (d->kernelHeight - 1) / 2); Execution Count:14 | 14 |
142 | } | - |
143 | | - |
144 | | - |
145 | static void convolute( | - |
146 | QImage *destImage, | - |
147 | const QPointF &pos, | - |
148 | const QImage &srcImage, | - |
149 | const QRectF &srcRect, | - |
150 | QPainter::CompositionMode mode, | - |
151 | qreal *kernel, | - |
152 | int kernelWidth, | - |
153 | int kernelHeight ) | - |
154 | { | - |
155 | const QImage processImage = (srcImage.format() != QImage::Format_ARGB32_Premultiplied ) ? srcImage.convertToFormat(QImage::Format_ARGB32_Premultiplied) : srcImage; partially evaluated: (srcImage.format() != QImage::Format_ARGB32_Premultiplied ) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
156 | | - |
157 | | - |
158 | int *fixedKernel = new int[kernelWidth*kernelHeight]; | - |
159 | for(int i = 0; i < kernelWidth*kernelHeight; i++) evaluated: i < kernelWidth*kernelHeight yes Evaluation Count:18 | yes Evaluation Count:2 |
| 2-18 |
160 | { | - |
161 | fixedKernel[i] = (int)(65536 * kernel[i]); | - |
162 | } executed: } Execution Count:18 | 18 |
163 | QRectF trect = srcRect.isNull() ? processImage.rect() : srcRect; partially evaluated: srcRect.isNull() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
164 | trect.moveTo(pos); | - |
165 | QRectF bounded = trect.adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2); | - |
166 | QRect rect = bounded.toAlignedRect(); | - |
167 | QRect targetRect = rect.intersected(destImage->rect()); | - |
168 | | - |
169 | QRectF srect = srcRect.isNull() ? processImage.rect() : srcRect; partially evaluated: srcRect.isNull() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
170 | QRectF sbounded = srect.adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2); | - |
171 | QPoint srcStartPoint = sbounded.toAlignedRect().topLeft()+(targetRect.topLeft()-rect.topLeft()); | - |
172 | | - |
173 | const uint *sourceStart = (uint*)processImage.scanLine(0); | - |
174 | uint *outputStart = (uint*)destImage->scanLine(0); | - |
175 | | - |
176 | int yk = srcStartPoint.y(); | - |
177 | for (int y = targetRect.top(); y <= targetRect.bottom(); y++) { evaluated: y <= targetRect.bottom() yes Evaluation Count:36 | yes Evaluation Count:2 |
| 2-36 |
178 | uint* output = outputStart + (destImage->bytesPerLine()/sizeof(uint))*y+targetRect.left(); | - |
179 | int xk = srcStartPoint.x(); | - |
180 | for(int x = targetRect.left(); x <= targetRect.right(); x++) { evaluated: x <= targetRect.right() yes Evaluation Count:648 | yes Evaluation Count:36 |
| 36-648 |
181 | int r = 0; | - |
182 | int g = 0; | - |
183 | int b = 0; | - |
184 | int a = 0; | - |
185 | | - |
186 | | - |
187 | int kernely = -kernelHeight/2; | - |
188 | int starty = 0; | - |
189 | int endy = kernelHeight; | - |
190 | if(yk+kernely+endy >= srcImage.height()) partially evaluated: yk+kernely+endy >= srcImage.height() no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
191 | endy = kernelHeight-((yk+kernely+endy)-srcImage.height())-1; never executed: endy = kernelHeight-((yk+kernely+endy)-srcImage.height())-1; | 0 |
192 | if(yk+kernely < 0) partially evaluated: yk+kernely < 0 no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
193 | starty = -(yk+kernely); never executed: starty = -(yk+kernely); | 0 |
194 | | - |
195 | int kernelx = -kernelWidth/2; | - |
196 | int startx = 0; | - |
197 | int endx = kernelWidth; | - |
198 | if(xk+kernelx+endx >= srcImage.width()) partially evaluated: xk+kernelx+endx >= srcImage.width() no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
199 | endx = kernelWidth-((xk+kernelx+endx)-srcImage.width())-1; never executed: endx = kernelWidth-((xk+kernelx+endx)-srcImage.width())-1; | 0 |
200 | if(xk+kernelx < 0) partially evaluated: xk+kernelx < 0 no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
201 | startx = -(xk+kernelx); never executed: startx = -(xk+kernelx); | 0 |
202 | | - |
203 | for (int ys = starty; ys < endy; ys ++) { evaluated: ys < endy yes Evaluation Count:1944 | yes Evaluation Count:648 |
| 648-1944 |
204 | const uint *pix = sourceStart + (processImage.bytesPerLine()/sizeof(uint))*(yk+kernely+ys) + ((xk+kernelx+startx)); | - |
205 | const uint *endPix = pix+endx-startx; | - |
206 | int kernelPos = ys*kernelWidth+startx; | - |
207 | while (pix < endPix) { evaluated: pix < endPix yes Evaluation Count:5832 | yes Evaluation Count:1944 |
| 1944-5832 |
208 | int factor = fixedKernel[kernelPos++]; | - |
209 | a += (((*pix) & 0xff000000)>>24) * factor; | - |
210 | r += (((*pix) & 0x00ff0000)>>16) * factor; | - |
211 | g += (((*pix) & 0x0000ff00)>>8 ) * factor; | - |
212 | b += (((*pix) & 0x000000ff) ) * factor; | - |
213 | pix++; | - |
214 | } executed: } Execution Count:5832 | 5832 |
215 | } executed: } Execution Count:1944 | 1944 |
216 | | - |
217 | r = qBound((int)0, r >> 16, (int)255); | - |
218 | g = qBound((int)0, g >> 16, (int)255); | - |
219 | b = qBound((int)0, b >> 16, (int)255); | - |
220 | a = qBound((int)0, a >> 16, (int)255); | - |
221 | | - |
222 | if(mode == QPainter::CompositionMode_Source) { partially evaluated: mode == QPainter::CompositionMode_Source no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
223 | uint color = (a<<24)+(r<<16)+(g<<8)+b; | - |
224 | *output++ = color; | - |
225 | } else { | 0 |
226 | uint current = *output; | - |
227 | uchar ca = (current&0xff000000)>>24; | - |
228 | uchar cr = (current&0x00ff0000)>>16; | - |
229 | uchar cg = (current&0x0000ff00)>>8; | - |
230 | uchar cb = (current&0x000000ff); | - |
231 | uint color = | - |
232 | (((ca*(255-a) >> 8)+a) << 24)+ | - |
233 | (((cr*(255-a) >> 8)+r) << 16)+ | - |
234 | (((cg*(255-a) >> 8)+g) << 8)+ | - |
235 | (((cb*(255-a) >> 8)+b)); | - |
236 | *output++ = color;; | - |
237 | } executed: } Execution Count:648 | 648 |
238 | xk++; | - |
239 | } executed: } Execution Count:648 | 648 |
240 | yk++; | - |
241 | } executed: } Execution Count:36 | 36 |
242 | delete[] fixedKernel; | - |
243 | } executed: } Execution Count:2 | 2 |
244 | | - |
245 | | - |
246 | | - |
247 | | - |
248 | void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF& srcRect) const | - |
249 | { | - |
250 | const QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
251 | if (!painter->isActive()) partially evaluated: !painter->isActive() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
252 | return; | 0 |
253 | | - |
254 | if(d->kernelWidth<=0 || d->kernelHeight <= 0) partially evaluated: d->kernelWidth<=0 no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: d->kernelHeight <= 0 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
255 | return; | 0 |
256 | | - |
257 | if (src.isNull()) partially evaluated: src.isNull() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
258 | return; | 0 |
259 | | - |
260 | QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? partially evaluated: painter->paintEngine() yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: painter->paintEngine()->isExtended() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
261 | static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; | - |
262 | QPixmapConvolutionFilter *convolutionFilter = static_cast<QPixmapConvolutionFilter*>(filter); | - |
263 | if (convolutionFilter) { partially evaluated: convolutionFilter no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
264 | convolutionFilter->setConvolutionKernel(d->convolutionKernel, d->kernelWidth, d->kernelHeight); | - |
265 | convolutionFilter->d_func()->convoluteAlpha = d->convoluteAlpha; | - |
266 | convolutionFilter->draw(painter, p, src, srcRect); | - |
267 | return; | 0 |
268 | } | - |
269 | | - |
270 | | - |
271 | | - |
272 | QImage *target = 0; | - |
273 | if (painter->paintEngine()->paintDevice()->devType() == QInternal::Image) { partially evaluated: painter->paintEngine()->paintDevice()->devType() == QInternal::Image yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
274 | target = static_cast<QImage *>(painter->paintEngine()->paintDevice()); | - |
275 | | - |
276 | QTransform mat = painter->combinedTransform(); | - |
277 | | - |
278 | if (mat.type() > QTransform::TxTranslate) { partially evaluated: mat.type() > QTransform::TxTranslate no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
279 | | - |
280 | target = 0; | - |
281 | } else { | 0 |
282 | QRasterPaintEngine *pe = static_cast<QRasterPaintEngine *>(painter->paintEngine()); | - |
283 | if (pe->clipType() == QRasterPaintEngine::ComplexClip) partially evaluated: pe->clipType() == QRasterPaintEngine::ComplexClip no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
284 | | - |
285 | target = 0; never executed: target = 0; | 0 |
286 | else { | - |
287 | QRectF clip = pe->clipBoundingRect(); | - |
288 | QRectF rect = boundingRectFor(srcRect.isEmpty() ? src.rect() : srcRect); | - |
289 | QTransform x = painter->deviceTransform(); | - |
290 | if (!clip.contains(rect.translated(x.dx() + p.x(), x.dy() + p.y()))) { partially evaluated: !clip.contains(rect.translated(x.dx() + p.x(), x.dy() + p.y())) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
291 | target = 0; | - |
292 | } | 0 |
293 | | - |
294 | } executed: } Execution Count:2 | 2 |
295 | } | - |
296 | } | - |
297 | | - |
298 | if (target) { partially evaluated: target yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
299 | QTransform x = painter->deviceTransform(); | - |
300 | QPointF offset(x.dx(), x.dy()); | - |
301 | | - |
302 | convolute(target, p+offset, src.toImage(), srcRect, QPainter::CompositionMode_SourceOver, d->convolutionKernel, d->kernelWidth, d->kernelHeight); | - |
303 | } else { executed: } Execution Count:2 | 2 |
304 | QRect srect = srcRect.isNull() ? src.rect() : srcRect.toRect(); never evaluated: srcRect.isNull() | 0 |
305 | QRect rect = boundingRectFor(srect).toRect(); | - |
306 | QImage result = QImage(rect.size(), QImage::Format_ARGB32_Premultiplied); | - |
307 | QPoint offset = srect.topLeft() - rect.topLeft(); | - |
308 | convolute(&result, | - |
309 | offset, | - |
310 | src.toImage(), | - |
311 | srect, | - |
312 | QPainter::CompositionMode_Source, | - |
313 | d->convolutionKernel, | - |
314 | d->kernelWidth, | - |
315 | d->kernelHeight); | - |
316 | painter->drawImage(p - offset, result); | - |
317 | } | 0 |
318 | } | - |
319 | class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate | - |
320 | { | - |
321 | public: | - |
322 | QPixmapBlurFilterPrivate() : radius(5), hints(QGraphicsBlurEffect::PerformanceHint) {} executed: } Execution Count:4 | 4 |
323 | | - |
324 | qreal radius; | - |
325 | QGraphicsBlurEffect::BlurHints hints; | - |
326 | }; | - |
327 | | - |
328 | | - |
329 | | - |
330 | | - |
331 | | - |
332 | | - |
333 | | - |
334 | QPixmapBlurFilter::QPixmapBlurFilter(QObject *parent) | - |
335 | : QPixmapFilter(*new QPixmapBlurFilterPrivate, BlurFilter, parent) | - |
336 | { | - |
337 | } executed: } Execution Count:4 | 4 |
338 | | - |
339 | | - |
340 | | - |
341 | | - |
342 | | - |
343 | | - |
344 | QPixmapBlurFilter::~QPixmapBlurFilter() | - |
345 | { | - |
346 | } | - |
347 | | - |
348 | | - |
349 | | - |
350 | | - |
351 | | - |
352 | | - |
353 | void QPixmapBlurFilter::setRadius(qreal radius) | - |
354 | { | - |
355 | QPixmapBlurFilterPrivate * const d = d_func(); | - |
356 | d->radius = radius; | - |
357 | } | 0 |
358 | | - |
359 | | - |
360 | | - |
361 | | - |
362 | | - |
363 | | - |
364 | qreal QPixmapBlurFilter::radius() const | - |
365 | { | - |
366 | const QPixmapBlurFilterPrivate * const d = d_func(); | - |
367 | return d->radius; never executed: return d->radius; | 0 |
368 | } | - |
369 | void QPixmapBlurFilter::setBlurHints(QGraphicsBlurEffect::BlurHints hints) | - |
370 | { | - |
371 | QPixmapBlurFilterPrivate * const d = d_func(); | - |
372 | d->hints = hints; | - |
373 | } executed: } Execution Count:4 | 4 |
374 | | - |
375 | | - |
376 | | - |
377 | | - |
378 | | - |
379 | | - |
380 | QGraphicsBlurEffect::BlurHints QPixmapBlurFilter::blurHints() const | - |
381 | { | - |
382 | const QPixmapBlurFilterPrivate * const d = d_func(); | - |
383 | return d->hints; never executed: return d->hints; | 0 |
384 | } | - |
385 | | - |
386 | const qreal radiusScale = qreal(2.5); | - |
387 | | - |
388 | | - |
389 | | - |
390 | | - |
391 | QRectF QPixmapBlurFilter::boundingRectFor(const QRectF &rect) const | - |
392 | { | - |
393 | const QPixmapBlurFilterPrivate * const d = d_func(); | - |
394 | const qreal delta = radiusScale * d->radius + 1; | - |
395 | return rect.adjusted(-delta, -delta, delta, delta); never executed: return rect.adjusted(-delta, -delta, delta, delta); | 0 |
396 | } | - |
397 | | - |
398 | template <int shift> | - |
399 | inline int qt_static_shift(int value) | - |
400 | { | - |
401 | if (shift == 0) never evaluated: shift == 0 | 0 |
402 | return value; never executed: return value; | 0 |
403 | else if (shift > 0) never evaluated: shift > 0 | 0 |
404 | return value << (uint(shift) & 0x1f); never executed: return value << (uint(shift) & 0x1f); | 0 |
405 | else | - |
406 | return value >> (uint(-shift) & 0x1f); never executed: return value >> (uint(-shift) & 0x1f); | 0 |
407 | } | - |
408 | | - |
409 | template<int aprec, int zprec> | - |
410 | inline void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, int alpha) | - |
411 | { | - |
412 | QRgb *pixel = (QRgb *)bptr; | - |
413 | | - |
414 | | - |
415 | const int A_zprec = qt_static_shift<zprec - 24>(*pixel) & (0xff << zprec); | - |
416 | const int R_zprec = qt_static_shift<zprec - 16>(*pixel) & (0xff << zprec); | - |
417 | const int G_zprec = qt_static_shift<zprec - 8>(*pixel) & (0xff << zprec); | - |
418 | const int B_zprec = qt_static_shift<zprec>(*pixel) & (0xff << zprec); | - |
419 | | - |
420 | | - |
421 | const int zR_zprec = zR >> aprec; | - |
422 | const int zG_zprec = zG >> aprec; | - |
423 | const int zB_zprec = zB >> aprec; | - |
424 | const int zA_zprec = zA >> aprec; | - |
425 | | - |
426 | zR += alpha * (R_zprec - zR_zprec); | - |
427 | zG += alpha * (G_zprec - zG_zprec); | - |
428 | zB += alpha * (B_zprec - zB_zprec); | - |
429 | zA += alpha * (A_zprec - zA_zprec); | - |
430 | | - |
431 | | - |
432 | *pixel = | - |
433 | qt_static_shift<24 - zprec - aprec>(zA & (0xff << (zprec + aprec))) | - |
434 | | qt_static_shift<16 - zprec - aprec>(zR & (0xff << (zprec + aprec))) | - |
435 | | qt_static_shift<8 - zprec - aprec>(zG & (0xff << (zprec + aprec))) | - |
436 | | qt_static_shift<-zprec - aprec>(zB & (0xff << (zprec + aprec))); | - |
437 | | - |
438 | } | 0 |
439 | | - |
440 | const int alphaIndex = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3); | - |
441 | | - |
442 | template<int aprec, int zprec> | - |
443 | inline void qt_blurinner_alphaOnly(uchar *bptr, int &z, int alpha) | - |
444 | { | - |
445 | const int A_zprec = int(*(bptr)) << zprec; | - |
446 | const int z_zprec = z >> aprec; | - |
447 | z += alpha * (A_zprec - z_zprec); | - |
448 | *(bptr) = z >> (zprec + aprec); | - |
449 | } executed: } Execution Count:1750492 | 1750492 |
450 | | - |
451 | template<int aprec, int zprec, bool alphaOnly> | - |
452 | inline void qt_blurrow(QImage & im, int line, int alpha) | - |
453 | { | - |
454 | uchar *bptr = im.scanLine(line); | - |
455 | | - |
456 | int zR = 0, zG = 0, zB = 0, zA = 0; | - |
457 | | - |
458 | if (alphaOnly && im.format() != QImage::Format_Indexed8) partially evaluated: alphaOnly yes Evaluation Count:4328 | no Evaluation Count:0 |
evaluated: im.format() != QImage::Format_Indexed8 yes Evaluation Count:4136 | yes Evaluation Count:192 |
| 0-4328 |
459 | bptr += alphaIndex; executed: bptr += alphaIndex; Execution Count:4136 | 4136 |
460 | | - |
461 | const int stride = im.depth() >> 3; | - |
462 | const int im_width = im.width(); | - |
463 | for (int index = 0; index < im_width; ++index) { evaluated: index < im_width yes Evaluation Count:877410 | yes Evaluation Count:4328 |
| 4328-877410 |
464 | if (alphaOnly) partially evaluated: alphaOnly yes Evaluation Count:877410 | no Evaluation Count:0 |
| 0-877410 |
465 | qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha); executed: qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha); Execution Count:877410 | 877410 |
466 | else | - |
467 | qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); never executed: qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); | 0 |
468 | bptr += stride; | - |
469 | } executed: } Execution Count:877410 | 877410 |
470 | | - |
471 | bptr -= stride; | - |
472 | | - |
473 | for (int index = im_width - 2; index >= 0; --index) { evaluated: index >= 0 yes Evaluation Count:873082 | yes Evaluation Count:4328 |
| 4328-873082 |
474 | bptr -= stride; | - |
475 | if (alphaOnly) partially evaluated: alphaOnly yes Evaluation Count:873082 | no Evaluation Count:0 |
| 0-873082 |
476 | qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha); executed: qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha); Execution Count:873082 | 873082 |
477 | else | - |
478 | qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); never executed: qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); | 0 |
479 | } | - |
480 | } executed: } Execution Count:4328 | 4328 |
481 | template <int aprec, int zprec, bool alphaOnly> | - |
482 | void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transposed = 0) | - |
483 | { | - |
484 | | - |
485 | if (improvedQuality) evaluated: improvedQuality yes Evaluation Count:2 | yes Evaluation Count:7 |
| 2-7 |
486 | radius *= qreal(0.5); executed: radius *= qreal(0.5); Execution Count:2 | 2 |
487 | | - |
488 | qt_noop(); | - |
489 | | - |
490 | | - |
491 | | - |
492 | | - |
493 | | - |
494 | | - |
495 | const qreal cutOffIntensity = 2; | - |
496 | int alpha = radius <= qreal(1e-5) partially evaluated: radius <= qreal(1e-5) no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
497 | ? ((1 << aprec)-1) | - |
498 | : qRound((1<<aprec)*(1 - qPow(cutOffIntensity * (1 / qreal(255)), 1 / radius))); | - |
499 | | - |
500 | int img_height = img.height(); | - |
501 | for (int row = 0; row < img_height; ++row) { evaluated: row < img_height yes Evaluation Count:2627 | yes Evaluation Count:9 |
| 9-2627 |
502 | for (int i = 0; i <= int(improvedQuality); ++i) evaluated: i <= int(improvedQuality) yes Evaluation Count:2691 | yes Evaluation Count:2627 |
| 2627-2691 |
503 | qt_blurrow<aprec, zprec, alphaOnly>(img, row, alpha); executed: qt_blurrow<aprec, zprec, alphaOnly>(img, row, alpha); Execution Count:2691 | 2691 |
504 | } executed: } Execution Count:2627 | 2627 |
505 | | - |
506 | QImage temp(img.height(), img.width(), img.format()); | - |
507 | if (transposed >= 0) { partially evaluated: transposed >= 0 yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
508 | if (img.depth() == 8) { evaluated: img.depth() == 8 yes Evaluation Count:2 | yes Evaluation Count:7 |
| 2-7 |
509 | qt_memrotate270(reinterpret_cast<const quint8*>(img.bits()), | - |
510 | img.width(), img.height(), img.bytesPerLine(), | - |
511 | reinterpret_cast<quint8*>(temp.bits()), | - |
512 | temp.bytesPerLine()); | - |
513 | } else { executed: } Execution Count:2 | 2 |
514 | qt_memrotate270(reinterpret_cast<const quint32*>(img.bits()), | - |
515 | img.width(), img.height(), img.bytesPerLine(), | - |
516 | reinterpret_cast<quint32*>(temp.bits()), | - |
517 | temp.bytesPerLine()); | - |
518 | } executed: } Execution Count:7 | 7 |
519 | } else { | - |
520 | if (img.depth() == 8) { never evaluated: img.depth() == 8 | 0 |
521 | qt_memrotate90(reinterpret_cast<const quint8*>(img.bits()), | - |
522 | img.width(), img.height(), img.bytesPerLine(), | - |
523 | reinterpret_cast<quint8*>(temp.bits()), | - |
524 | temp.bytesPerLine()); | - |
525 | } else { | 0 |
526 | qt_memrotate90(reinterpret_cast<const quint32*>(img.bits()), | - |
527 | img.width(), img.height(), img.bytesPerLine(), | - |
528 | reinterpret_cast<quint32*>(temp.bits()), | - |
529 | temp.bytesPerLine()); | - |
530 | } | 0 |
531 | } | - |
532 | | - |
533 | img_height = temp.height(); | - |
534 | for (int row = 0; row < img_height; ++row) { evaluated: row < img_height yes Evaluation Count:1605 | yes Evaluation Count:9 |
| 9-1605 |
535 | for (int i = 0; i <= int(improvedQuality); ++i) evaluated: i <= int(improvedQuality) yes Evaluation Count:1637 | yes Evaluation Count:1605 |
| 1605-1637 |
536 | qt_blurrow<aprec, zprec, alphaOnly>(temp, row, alpha); executed: qt_blurrow<aprec, zprec, alphaOnly>(temp, row, alpha); Execution Count:1637 | 1637 |
537 | } executed: } Execution Count:1605 | 1605 |
538 | | - |
539 | if (transposed == 0) { evaluated: transposed == 0 yes Evaluation Count:8 | yes Evaluation Count:1 |
| 1-8 |
540 | if (img.depth() == 8) { evaluated: img.depth() == 8 yes Evaluation Count:1 | yes Evaluation Count:7 |
| 1-7 |
541 | qt_memrotate90(reinterpret_cast<const quint8*>(temp.bits()), | - |
542 | temp.width(), temp.height(), temp.bytesPerLine(), | - |
543 | reinterpret_cast<quint8*>(img.bits()), | - |
544 | img.bytesPerLine()); | - |
545 | } else { executed: } Execution Count:1 | 1 |
546 | qt_memrotate90(reinterpret_cast<const quint32*>(temp.bits()), | - |
547 | temp.width(), temp.height(), temp.bytesPerLine(), | - |
548 | reinterpret_cast<quint32*>(img.bits()), | - |
549 | img.bytesPerLine()); | - |
550 | } executed: } Execution Count:7 | 7 |
551 | } else { | - |
552 | img = temp; | - |
553 | } executed: } Execution Count:1 | 1 |
554 | } | - |
555 | | - |
556 | | - |
557 | | - |
558 | __attribute__((visibility("default"))) QImage qt_halfScaled(const QImage &source) | - |
559 | { | - |
560 | if (source.width() < 2 || source.height() < 2) never evaluated: source.width() < 2 never evaluated: source.height() < 2 | 0 |
561 | return QImage(); never executed: return QImage(); | 0 |
562 | | - |
563 | QImage srcImage = source; | - |
564 | | - |
565 | if (source.format() == QImage::Format_Indexed8) { never evaluated: source.format() == QImage::Format_Indexed8 | 0 |
566 | | - |
567 | QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); | - |
568 | | - |
569 | const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits()); | - |
570 | int sx = srcImage.bytesPerLine(); | - |
571 | int sx2 = sx << 1; | - |
572 | | - |
573 | uchar *dst = reinterpret_cast<uchar*>(dest.bits()); | - |
574 | int dx = dest.bytesPerLine(); | - |
575 | int ww = dest.width(); | - |
576 | int hh = dest.height(); | - |
577 | | - |
578 | for (int y = hh; y; --y, dst += dx, src += sx2) { | 0 |
579 | const uchar *p1 = src; | - |
580 | const uchar *p2 = src + sx; | - |
581 | uchar *q = dst; | - |
582 | for (int x = ww; x; --x, ++q, p1 += 2, p2 += 2) | 0 |
583 | *q = ((int(p1[0]) + int(p1[1]) + int(p2[0]) + int(p2[1])) + 2) >> 2; never executed: *q = ((int(p1[0]) + int(p1[1]) + int(p2[0]) + int(p2[1])) + 2) >> 2; | 0 |
584 | } | 0 |
585 | | - |
586 | return dest; never executed: return dest; | 0 |
587 | } else if (source.format() == QImage::Format_ARGB8565_Premultiplied) { never evaluated: source.format() == QImage::Format_ARGB8565_Premultiplied | 0 |
588 | QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); | - |
589 | | - |
590 | const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits()); | - |
591 | int sx = srcImage.bytesPerLine(); | - |
592 | int sx2 = sx << 1; | - |
593 | | - |
594 | uchar *dst = reinterpret_cast<uchar*>(dest.bits()); | - |
595 | int dx = dest.bytesPerLine(); | - |
596 | int ww = dest.width(); | - |
597 | int hh = dest.height(); | - |
598 | | - |
599 | for (int y = hh; y; --y, dst += dx, src += sx2) { | 0 |
600 | const uchar *p1 = src; | - |
601 | const uchar *p2 = src + sx; | - |
602 | uchar *q = dst; | - |
603 | for (int x = ww; x; --x, q += 3, p1 += 6, p2 += 6) { | 0 |
604 | | - |
605 | q[0] = ( ((((( ((((p1[0])^(p1[3])) & 0xfefefefeUL) >> 1) + ((p1[0])&(p1[3])) ))^(( ((((p2[0])^(p2[3])) & 0xfefefefeUL) >> 1) + ((p2[0])&(p2[3])) ))) & 0xfefefefeUL) >> 1) + ((( ((((p1[0])^(p1[3])) & 0xfefefefeUL) >> 1) + ((p1[0])&(p1[3])) ))&(( ((((p2[0])^(p2[3])) & 0xfefefefeUL) >> 1) + ((p2[0])&(p2[3])) ))) ); | - |
606 | | - |
607 | const quint16 p16_1 = (p1[2] << 8) | p1[1]; | - |
608 | const quint16 p16_2 = (p1[5] << 8) | p1[4]; | - |
609 | const quint16 p16_3 = (p2[2] << 8) | p2[1]; | - |
610 | const quint16 p16_4 = (p2[5] << 8) | p2[4]; | - |
611 | const quint16 result = ( ((((( ((((p16_1)^(p16_2)) & 0xf7deUL) >> 1) + ((p16_1)&(p16_2)) ))^(( ((((p16_3)^(p16_4)) & 0xf7deUL) >> 1) + ((p16_3)&(p16_4)) ))) & 0xf7deUL) >> 1) + ((( ((((p16_1)^(p16_2)) & 0xf7deUL) >> 1) + ((p16_1)&(p16_2)) ))&(( ((((p16_3)^(p16_4)) & 0xf7deUL) >> 1) + ((p16_3)&(p16_4)) ))) ); | - |
612 | q[1] = result & 0xff; | - |
613 | q[2] = result >> 8; | - |
614 | } | 0 |
615 | } | 0 |
616 | | - |
617 | return dest; never executed: return dest; | 0 |
618 | } else if (source.format() != QImage::Format_ARGB32_Premultiplied never evaluated: source.format() != QImage::Format_ARGB32_Premultiplied | 0 |
619 | && source.format() != QImage::Format_RGB32) never evaluated: source.format() != QImage::Format_RGB32 | 0 |
620 | { | - |
621 | srcImage = source.convertToFormat(QImage::Format_ARGB32_Premultiplied); | - |
622 | } | 0 |
623 | | - |
624 | QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); | - |
625 | | - |
626 | const quint32 *src = reinterpret_cast<const quint32*>(const_cast<const QImage &>(srcImage).bits()); | - |
627 | int sx = srcImage.bytesPerLine() >> 2; | - |
628 | int sx2 = sx << 1; | - |
629 | | - |
630 | quint32 *dst = reinterpret_cast<quint32*>(dest.bits()); | - |
631 | int dx = dest.bytesPerLine() >> 2; | - |
632 | int ww = dest.width(); | - |
633 | int hh = dest.height(); | - |
634 | | - |
635 | for (int y = hh; y; --y, dst += dx, src += sx2) { | 0 |
636 | const quint32 *p1 = src; | - |
637 | const quint32 *p2 = src + sx; | - |
638 | quint32 *q = dst; | - |
639 | for (int x = ww; x; --x, q++, p1 += 2, p2 += 2) | 0 |
640 | *q = ( ((((( ((((p1[0])^(p1[1])) & 0xfefefefeUL) >> 1) + ((p1[0])&(p1[1])) ))^(( ((((p2[0])^(p2[1])) & 0xfefefefeUL) >> 1) + ((p2[0])&(p2[1])) ))) & 0xfefefefeUL) >> 1) + ((( ((((p1[0])^(p1[1])) & 0xfefefefeUL) >> 1) + ((p1[0])&(p1[1])) ))&(( ((((p2[0])^(p2[1])) & 0xfefefefeUL) >> 1) + ((p2[0])&(p2[1])) ))) ); never executed: *q = ( ((((( ((((p1[0])^(p1[1])) & 0xfefefefeUL) >> 1) + ((p1[0])&(p1[1])) ))^(( ((((p2[0])^(p2[1])) & 0xfefefefeUL) >> 1) + ((p2[0])&(p2[1])) ))) & 0xfefefefeUL) >> 1) + ((( ((((p1[0])^(p1[1])) & 0xfefefefeUL) >> 1) + ((p1[0])&(p1[1])) ))&(( ((((p2[0])^(p2[1])) & 0xfefefefeUL) >> 1) + ((p2[0])&(p2[1])) ))) ); | 0 |
641 | } | 0 |
642 | | - |
643 | return dest; never executed: return dest; | 0 |
644 | } | - |
645 | | - |
646 | __attribute__((visibility("default"))) void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0) | - |
647 | { | - |
648 | if (blurImage.format() != QImage::Format_ARGB32_Premultiplied partially evaluated: blurImage.format() != QImage::Format_ARGB32_Premultiplied no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
649 | && blurImage.format() != QImage::Format_RGB32) never evaluated: blurImage.format() != QImage::Format_RGB32 | 0 |
650 | { | - |
651 | blurImage = blurImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); | - |
652 | } | 0 |
653 | | - |
654 | qreal scale = 1; | - |
655 | if (radius >= 4 && blurImage.width() >= 2 && blurImage.height() >= 2) { partially evaluated: radius >= 4 no Evaluation Count:0 | yes Evaluation Count:7 |
never evaluated: blurImage.width() >= 2 never evaluated: blurImage.height() >= 2 | 0-7 |
656 | blurImage = qt_halfScaled(blurImage); | - |
657 | scale = 2; | - |
658 | radius *= qreal(0.5); | - |
659 | } | 0 |
660 | | - |
661 | if (alphaOnly) partially evaluated: alphaOnly yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
662 | expblur<12, 10, true>(blurImage, radius, quality, transposed); executed: expblur<12, 10, true>(blurImage, radius, quality, transposed); Execution Count:7 | 7 |
663 | else | - |
664 | expblur<12, 10, false>(blurImage, radius, quality, transposed); never executed: expblur<12, 10, false>(blurImage, radius, quality, transposed); | 0 |
665 | | - |
666 | if (p) { partially evaluated: p yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
667 | p->scale(scale, scale); | - |
668 | p->setRenderHint(QPainter::SmoothPixmapTransform); | - |
669 | p->drawImage(QRect(0, 0, blurImage.width(), blurImage.height()), blurImage); | - |
670 | } executed: } Execution Count:7 | 7 |
671 | } executed: } Execution Count:7 | 7 |
672 | | - |
673 | __attribute__((visibility("default"))) void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0) | - |
674 | { | - |
675 | if (blurImage.format() == QImage::Format_Indexed8) partially evaluated: blurImage.format() == QImage::Format_Indexed8 yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
676 | expblur<12, 10, true>(blurImage, radius, quality, transposed); executed: expblur<12, 10, true>(blurImage, radius, quality, transposed); Execution Count:2 | 2 |
677 | else | - |
678 | expblur<12, 10, false>(blurImage, radius, quality, transposed); never executed: expblur<12, 10, false>(blurImage, radius, quality, transposed); | 0 |
679 | } | - |
680 | | - |
681 | __attribute__((visibility("default"))) extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); | - |
682 | | - |
683 | | - |
684 | | - |
685 | | - |
686 | void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &rect) const | - |
687 | { | - |
688 | const QPixmapBlurFilterPrivate * const d = d_func(); | - |
689 | if (!painter->isActive()) never evaluated: !painter->isActive() | 0 |
690 | return; | 0 |
691 | | - |
692 | if (src.isNull()) never evaluated: src.isNull() | 0 |
693 | return; | 0 |
694 | | - |
695 | QRectF srcRect = rect; | - |
696 | if (srcRect.isNull()) never evaluated: srcRect.isNull() | 0 |
697 | srcRect = src.rect(); never executed: srcRect = src.rect(); | 0 |
698 | | - |
699 | if (d->radius <= 1) { never evaluated: d->radius <= 1 | 0 |
700 | painter->drawPixmap(srcRect.translated(p), src, srcRect); | - |
701 | return; | 0 |
702 | } | - |
703 | | - |
704 | qreal scaledRadius = radiusScale * d->radius; | - |
705 | qreal scale; | - |
706 | if (qt_scaleForTransform(painter->transform(), &scale)) never evaluated: qt_scaleForTransform(painter->transform(), &scale) | 0 |
707 | scaledRadius /= scale; never executed: scaledRadius /= scale; | 0 |
708 | | - |
709 | QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? never evaluated: painter->paintEngine() never evaluated: painter->paintEngine()->isExtended() | 0 |
710 | static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; | - |
711 | QPixmapBlurFilter *blurFilter = static_cast<QPixmapBlurFilter*>(filter); | - |
712 | if (blurFilter) { never evaluated: blurFilter | 0 |
713 | blurFilter->setRadius(scaledRadius); | - |
714 | blurFilter->setBlurHints(d->hints); | - |
715 | blurFilter->draw(painter, p, src, srcRect); | - |
716 | return; | 0 |
717 | } | - |
718 | | - |
719 | QImage srcImage; | - |
720 | QImage destImage; | - |
721 | | - |
722 | if (srcRect == src.rect()) { never evaluated: srcRect == src.rect() | 0 |
723 | srcImage = src.toImage(); | - |
724 | } else { | 0 |
725 | QRect rect = srcRect.toAlignedRect().intersected(src.rect()); | - |
726 | srcImage = src.copy(rect).toImage(); | - |
727 | } | 0 |
728 | | - |
729 | QTransform transform = painter->worldTransform(); | - |
730 | painter->translate(p); | - |
731 | qt_blurImage(painter, srcImage, scaledRadius, (d->hints & QGraphicsBlurEffect::QualityHint), false); | - |
732 | painter->setWorldTransform(transform); | - |
733 | } | 0 |
734 | | - |
735 | | - |
736 | | - |
737 | | - |
738 | static void grayscale(const QImage &image, QImage &dest, const QRect& rect = QRect()) | - |
739 | { | - |
740 | QRect destRect = rect; | - |
741 | QRect srcRect = rect; | - |
742 | if (rect.isNull()) { partially evaluated: rect.isNull() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
743 | srcRect = dest.rect(); | - |
744 | destRect = dest.rect(); | - |
745 | } | 0 |
746 | if (&image != &dest) { partially evaluated: &image != &dest yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
747 | destRect.moveTo(QPoint(0, 0)); | - |
748 | } executed: } Execution Count:5 | 5 |
749 | | - |
750 | unsigned int *data = (unsigned int *)image.bits(); | - |
751 | unsigned int *outData = (unsigned int *)dest.bits(); | - |
752 | | - |
753 | if (dest.size() == image.size() && image.rect() == srcRect) { partially evaluated: dest.size() == image.size() yes Evaluation Count:5 | no Evaluation Count:0 |
partially evaluated: image.rect() == srcRect yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
754 | | - |
755 | int pixels = dest.width() * dest.height(); | - |
756 | for (int i = 0; i < pixels; ++i) { evaluated: i < pixels yes Evaluation Count:41472 | yes Evaluation Count:5 |
| 5-41472 |
757 | int val = qGray(data[i]); | - |
758 | outData[i] = qRgba(val, val, val, qAlpha(data[i])); | - |
759 | } executed: } Execution Count:41472 | 41472 |
760 | } else { executed: } Execution Count:5 | 5 |
761 | int yd = destRect.top(); | - |
762 | for (int y = srcRect.top(); y <= srcRect.bottom() && y < image.height(); y++) { never evaluated: y <= srcRect.bottom() never evaluated: y < image.height() | 0 |
763 | data = (unsigned int*)image.scanLine(y); | - |
764 | outData = (unsigned int*)dest.scanLine(yd++); | - |
765 | int xd = destRect.left(); | - |
766 | for (int x = srcRect.left(); x <= srcRect.right() && x < image.width(); x++) { never evaluated: x <= srcRect.right() never evaluated: x < image.width() | 0 |
767 | int val = qGray(data[x]); | - |
768 | outData[xd++] = qRgba(val, val, val, qAlpha(data[x])); | - |
769 | } | 0 |
770 | } | 0 |
771 | } | 0 |
772 | } | - |
773 | class QPixmapColorizeFilterPrivate : public QPixmapFilterPrivate | - |
774 | { | - |
775 | inline QPixmapColorizeFilter* q_func() { return static_cast<QPixmapColorizeFilter *>(q_ptr); } inline const QPixmapColorizeFilter* q_func() const { return static_cast<const QPixmapColorizeFilter *>(q_ptr); } friend class QPixmapColorizeFilter; | - |
776 | public: | - |
777 | QColor color; | - |
778 | qreal strength; | - |
779 | quint32 opaque : 1; | - |
780 | quint32 alphaBlend : 1; | - |
781 | quint32 padding : 30; | - |
782 | }; | - |
783 | QPixmapColorizeFilter::QPixmapColorizeFilter(QObject *parent) | - |
784 | : QPixmapFilter(*new QPixmapColorizeFilterPrivate, ColorizeFilter, parent) | - |
785 | { | - |
786 | QPixmapColorizeFilterPrivate * const d = d_func(); | - |
787 | d->color = QColor(0, 0, 192); | - |
788 | d->strength = qreal(1); | - |
789 | d->opaque = true; | - |
790 | d->alphaBlend = false; | - |
791 | } executed: } Execution Count:7 | 7 |
792 | | - |
793 | | - |
794 | | - |
795 | | - |
796 | | - |
797 | | - |
798 | QColor QPixmapColorizeFilter::color() const | - |
799 | { | - |
800 | const QPixmapColorizeFilterPrivate * const d = d_func(); | - |
801 | return d->color; executed: return d->color; Execution Count:1 | 1 |
802 | } | - |
803 | | - |
804 | | - |
805 | | - |
806 | | - |
807 | | - |
808 | | - |
809 | void QPixmapColorizeFilter::setColor(const QColor &color) | - |
810 | { | - |
811 | QPixmapColorizeFilterPrivate * const d = d_func(); | - |
812 | d->color = color; | - |
813 | } executed: } Execution Count:6 | 6 |
814 | | - |
815 | | - |
816 | | - |
817 | | - |
818 | | - |
819 | | - |
820 | | - |
821 | qreal QPixmapColorizeFilter::strength() const | - |
822 | { | - |
823 | const QPixmapColorizeFilterPrivate * const d = d_func(); | - |
824 | return d->strength; executed: return d->strength; Execution Count:3 | 3 |
825 | } | - |
826 | | - |
827 | | - |
828 | | - |
829 | | - |
830 | | - |
831 | | - |
832 | void QPixmapColorizeFilter::setStrength(qreal strength) | - |
833 | { | - |
834 | QPixmapColorizeFilterPrivate * const d = d_func(); | - |
835 | d->strength = qBound(qreal(0), strength, qreal(1)); | - |
836 | d->opaque = !qFuzzyIsNull(d->strength); | - |
837 | d->alphaBlend = !qFuzzyIsNull(d->strength - 1); | - |
838 | } executed: } Execution Count:3 | 3 |
839 | | - |
840 | | - |
841 | | - |
842 | | - |
843 | void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const | - |
844 | { | - |
845 | const QPixmapColorizeFilterPrivate * const d = d_func(); | - |
846 | | - |
847 | if (src.isNull()) partially evaluated: src.isNull() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
848 | return; | 0 |
849 | | - |
850 | QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? partially evaluated: painter->paintEngine() yes Evaluation Count:5 | no Evaluation Count:0 |
partially evaluated: painter->paintEngine()->isExtended() yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
851 | static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; | - |
852 | QPixmapColorizeFilter *colorizeFilter = static_cast<QPixmapColorizeFilter*>(filter); | - |
853 | if (colorizeFilter) { partially evaluated: colorizeFilter no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
854 | colorizeFilter->setColor(d->color); | - |
855 | colorizeFilter->setStrength(d->strength); | - |
856 | colorizeFilter->draw(painter, dest, src, srcRect); | - |
857 | return; | 0 |
858 | } | - |
859 | | - |
860 | | - |
861 | | - |
862 | if (!d->opaque) { partially evaluated: !d->opaque no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
863 | painter->drawPixmap(dest, src, srcRect); | - |
864 | return; | 0 |
865 | } | - |
866 | | - |
867 | QImage srcImage; | - |
868 | QImage destImage; | - |
869 | | - |
870 | if (srcRect.isNull()) { evaluated: srcRect.isNull() yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
871 | srcImage = src.toImage(); | - |
872 | srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); | - |
873 | destImage = QImage(srcImage.size(), srcImage.format()); | - |
874 | } else { executed: } Execution Count:3 | 3 |
875 | QRect rect = srcRect.toAlignedRect().intersected(src.rect()); | - |
876 | | - |
877 | srcImage = src.copy(rect).toImage(); | - |
878 | srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); | - |
879 | destImage = QImage(rect.size(), srcImage.format()); | - |
880 | } executed: } Execution Count:2 | 2 |
881 | | - |
882 | | - |
883 | QPainter destPainter(&destImage); | - |
884 | grayscale(srcImage, destImage, srcImage.rect()); | - |
885 | destPainter.setCompositionMode(QPainter::CompositionMode_Screen); | - |
886 | destPainter.fillRect(srcImage.rect(), d->color); | - |
887 | destPainter.end(); | - |
888 | | - |
889 | if (d->alphaBlend) { evaluated: d->alphaBlend yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
890 | | - |
891 | QImage buffer = srcImage; | - |
892 | QPainter bufPainter(&buffer); | - |
893 | bufPainter.setOpacity(d->strength); | - |
894 | bufPainter.drawImage(0, 0, destImage); | - |
895 | bufPainter.end(); | - |
896 | destImage = buffer; | - |
897 | } executed: } Execution Count:1 | 1 |
898 | | - |
899 | if (srcImage.hasAlphaChannel()) partially evaluated: srcImage.hasAlphaChannel() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
900 | destImage.setAlphaChannel(srcImage.alphaChannel()); never executed: destImage.setAlphaChannel(srcImage.alphaChannel()); | 0 |
901 | | - |
902 | painter->drawImage(dest, destImage); | - |
903 | } executed: } Execution Count:5 | 5 |
904 | | - |
905 | class QPixmapDropShadowFilterPrivate : public QPixmapFilterPrivate | - |
906 | { | - |
907 | public: | - |
908 | QPixmapDropShadowFilterPrivate() | - |
909 | : offset(8, 8), color(63, 63, 63, 180), radius(1) {} executed: } Execution Count:5 | 5 |
910 | | - |
911 | QPointF offset; | - |
912 | QColor color; | - |
913 | qreal radius; | - |
914 | }; | - |
915 | QPixmapDropShadowFilter::QPixmapDropShadowFilter(QObject *parent) | - |
916 | : QPixmapFilter(*new QPixmapDropShadowFilterPrivate, DropShadowFilter, parent) | - |
917 | { | - |
918 | } executed: } Execution Count:5 | 5 |
919 | | - |
920 | | - |
921 | | - |
922 | | - |
923 | | - |
924 | | - |
925 | QPixmapDropShadowFilter::~QPixmapDropShadowFilter() | - |
926 | { | - |
927 | } | - |
928 | qreal QPixmapDropShadowFilter::blurRadius() const | - |
929 | { | - |
930 | const QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
931 | return d->radius; executed: return d->radius; Execution Count:8 | 8 |
932 | } | - |
933 | void QPixmapDropShadowFilter::setBlurRadius(qreal radius) | - |
934 | { | - |
935 | QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
936 | d->radius = radius; | - |
937 | } executed: } Execution Count:2 | 2 |
938 | QColor QPixmapDropShadowFilter::color() const | - |
939 | { | - |
940 | const QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
941 | return d->color; never executed: return d->color; | 0 |
942 | } | - |
943 | void QPixmapDropShadowFilter::setColor(const QColor &color) | - |
944 | { | - |
945 | QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
946 | d->color = color; | - |
947 | } | 0 |
948 | QPointF QPixmapDropShadowFilter::offset() const | - |
949 | { | - |
950 | const QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
951 | return d->offset; executed: return d->offset; Execution Count:1 | 1 |
952 | } | - |
953 | void QPixmapDropShadowFilter::setOffset(const QPointF &offset) | - |
954 | { | - |
955 | QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
956 | d->offset = offset; | - |
957 | } executed: } Execution Count:6 | 6 |
958 | QRectF QPixmapDropShadowFilter::boundingRectFor(const QRectF &rect) const | - |
959 | { | - |
960 | const QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
961 | return rect.united(rect.translated(d->offset).adjusted(-d->radius, -d->radius, d->radius, d->radius)); executed: return rect.united(rect.translated(d->offset).adjusted(-d->radius, -d->radius, d->radius, d->radius)); Execution Count:50 | 50 |
962 | } | - |
963 | | - |
964 | | - |
965 | | - |
966 | | - |
967 | void QPixmapDropShadowFilter::draw(QPainter *p, | - |
968 | const QPointF &pos, | - |
969 | const QPixmap &px, | - |
970 | const QRectF &src) const | - |
971 | { | - |
972 | const QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
973 | | - |
974 | if (px.isNull()) partially evaluated: px.isNull() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
975 | return; | 0 |
976 | | - |
977 | QPixmapFilter *filter = p->paintEngine() && p->paintEngine()->isExtended() ? partially evaluated: p->paintEngine() yes Evaluation Count:7 | no Evaluation Count:0 |
partially evaluated: p->paintEngine()->isExtended() yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
978 | static_cast<QPaintEngineEx *>(p->paintEngine())->pixmapFilter(type(), this) : 0; | - |
979 | QPixmapDropShadowFilter *dropShadowFilter = static_cast<QPixmapDropShadowFilter*>(filter); | - |
980 | if (dropShadowFilter) { partially evaluated: dropShadowFilter no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
981 | dropShadowFilter->setColor(d->color); | - |
982 | dropShadowFilter->setBlurRadius(d->radius); | - |
983 | dropShadowFilter->setOffset(d->offset); | - |
984 | dropShadowFilter->draw(p, pos, px, src); | - |
985 | return; | 0 |
986 | } | - |
987 | | - |
988 | QImage tmp(px.size(), QImage::Format_ARGB32_Premultiplied); | - |
989 | tmp.fill(0); | - |
990 | QPainter tmpPainter(&tmp); | - |
991 | tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); | - |
992 | tmpPainter.drawPixmap(d->offset, px); | - |
993 | tmpPainter.end(); | - |
994 | | - |
995 | | - |
996 | QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied); | - |
997 | blurred.fill(0); | - |
998 | QPainter blurPainter(&blurred); | - |
999 | qt_blurImage(&blurPainter, tmp, d->radius, false, true); | - |
1000 | blurPainter.end(); | - |
1001 | | - |
1002 | tmp = blurred; | - |
1003 | | - |
1004 | | - |
1005 | tmpPainter.begin(&tmp); | - |
1006 | tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); | - |
1007 | tmpPainter.fillRect(tmp.rect(), d->color); | - |
1008 | tmpPainter.end(); | - |
1009 | | - |
1010 | | - |
1011 | p->drawImage(pos, tmp); | - |
1012 | | - |
1013 | | - |
1014 | p->drawPixmap(pos, px, src); | - |
1015 | } executed: } Execution Count:7 | 7 |
1016 | | - |
1017 | | - |
1018 | | - |
| | |