| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/effects/qpixmapfilter.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 | } never executed: end of block | 0 | ||||||||||||||||||
| 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 | } never executed: end of block | 0 | ||||||||||||||||||
| 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 never executed: d->type;return d->type;never executed: return d->type; | 0 | ||||||||||||||||||
| 51 | } | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | QRectF QPixmapFilter::boundingRectFor(const QRectF &rect) const | - | ||||||||||||||||||
| 60 | { | - | ||||||||||||||||||
| 61 | return never executed: rect;return rect;never executed: return rect; | 0 | ||||||||||||||||||
| 62 | } | - | ||||||||||||||||||
| 63 | class QPixmapConvolutionFilterPrivate : public QPixmapFilterPrivate | - | ||||||||||||||||||
| 64 | { | - | ||||||||||||||||||
| 65 | public: | - | ||||||||||||||||||
| 66 | QPixmapConvolutionFilterPrivate(): convolutionKernel(0), kernelWidth(0), kernelHeight(0), convoluteAlpha(false) {} never executed: end of block | 0 | ||||||||||||||||||
| 67 | ~QPixmapConvolutionFilterPrivate() { | - | ||||||||||||||||||
| 68 | delete[] convolutionKernel; | - | ||||||||||||||||||
| 69 | } never executed: end of block | 0 | ||||||||||||||||||
| 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 | } never executed: end of block | 0 | ||||||||||||||||||
| 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 | } never executed: end of block | 0 | ||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | - | |||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | const qreal *QPixmapConvolutionFilter::convolutionKernel() const | - | ||||||||||||||||||
| 107 | { | - | ||||||||||||||||||
| 108 | const QPixmapConvolutionFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 109 | return never executed: d->convolutionKernel;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 never executed: d->kernelHeight;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 never executed: d->kernelWidth;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 never executed: rect.adjusted(-d->kernelWidth / 2, -d->kernelHeight / 2, (d->kernelWidth - 1) / 2, (d->kernelHeight - 1) / 2);return rect.adjusted(-d->kernelWidth / 2, -d->kernelHeight / 2, (d->kernelWidth - 1) / 2, (d->kernelHeight - 1) / 2);never executed: return rect.adjusted(-d->kernelWidth / 2, -d->kernelHeight / 2, (d->kernelWidth - 1) / 2, (d->kernelHeight - 1) / 2); | 0 | ||||||||||||||||||
| 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 = (
| 0 | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | int *fixedKernel = new int[kernelWidth*kernelHeight]; | - | ||||||||||||||||||
| 159 | for(int i = 0; i < kernelWidth*kernelHeight
| 0 | ||||||||||||||||||
| 160 | { | - | ||||||||||||||||||
| 161 | fixedKernel[i] = (int)(65536 * kernel[i]); | - | ||||||||||||||||||
| 162 | } never executed: end of block | 0 | ||||||||||||||||||
| 163 | QRectF trect = srcRect.isNull()
| 0 | ||||||||||||||||||
| 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()
| 0 | ||||||||||||||||||
| 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 = (const 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()
| 0 | ||||||||||||||||||
| 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()
| 0 | ||||||||||||||||||
| 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()
| 0 | ||||||||||||||||||
| 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
| 0 | ||||||||||||||||||
| 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()
| 0 | ||||||||||||||||||
| 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
| 0 | ||||||||||||||||||
| 201 | startx = -(xk+kernelx); never executed: startx = -(xk+kernelx); | 0 | ||||||||||||||||||
| 202 | - | |||||||||||||||||||
| 203 | for (int ys = starty; ys < endy
| 0 | ||||||||||||||||||
| 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
| 0 | ||||||||||||||||||
| 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 | } never executed: end of block | 0 | ||||||||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||||||||
| 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
| 0 | ||||||||||||||||||
| 223 | uint color = (a<<24)+(r<<16)+(g<<8)+b; | - | ||||||||||||||||||
| 224 | *output++ = color; | - | ||||||||||||||||||
| 225 | } never executed: else {end of block | 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 | } never executed: end of block | 0 | ||||||||||||||||||
| 238 | xk++; | - | ||||||||||||||||||
| 239 | } never executed: end of block | 0 | ||||||||||||||||||
| 240 | yk++; | - | ||||||||||||||||||
| 241 | } never executed: end of block | 0 | ||||||||||||||||||
| 242 | delete[] fixedKernel; | - | ||||||||||||||||||
| 243 | } never executed: end of block | 0 | ||||||||||||||||||
| 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()
| 0 | ||||||||||||||||||
| 252 | return; never executed: return; | 0 | ||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | if(d->kernelWidth<=0
| 0 | ||||||||||||||||||
| 255 | return; never executed: return; | 0 | ||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | if (src.isNull()
| 0 | ||||||||||||||||||
| 258 | return; never executed: return; | 0 | ||||||||||||||||||
| 259 | - | |||||||||||||||||||
| 260 | - | |||||||||||||||||||
| 261 | - | |||||||||||||||||||
| 262 | QImage *target = 0; | - | ||||||||||||||||||
| 263 | if (painter->paintEngine()->paintDevice()->devType() == QInternal::Image
| 0 | ||||||||||||||||||
| 264 | target = static_cast<QImage *>(painter->paintEngine()->paintDevice()); | - | ||||||||||||||||||
| 265 | - | |||||||||||||||||||
| 266 | QTransform mat = painter->combinedTransform(); | - | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | if (mat.type() > QTransform::TxTranslate
| 0 | ||||||||||||||||||
| 269 | - | |||||||||||||||||||
| 270 | target = 0; | - | ||||||||||||||||||
| 271 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 272 | QRasterPaintEngine *pe = static_cast<QRasterPaintEngine *>(painter->paintEngine()); | - | ||||||||||||||||||
| 273 | if (pe->clipType() == QRasterPaintEngine::ComplexClip
| 0 | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | target = 0; never executed: target = 0; | 0 | ||||||||||||||||||
| 276 | else { | - | ||||||||||||||||||
| 277 | QRectF clip = pe->clipBoundingRect(); | - | ||||||||||||||||||
| 278 | QRectF rect = boundingRectFor(srcRect.isEmpty() ? src.rect() : srcRect); | - | ||||||||||||||||||
| 279 | QTransform x = painter->deviceTransform(); | - | ||||||||||||||||||
| 280 | if (!clip.contains(rect.translated(x.dx() + p.x(), x.dy() + p.y()))
| 0 | ||||||||||||||||||
| 281 | target = 0; | - | ||||||||||||||||||
| 282 | } never executed: end of block | 0 | ||||||||||||||||||
| 283 | - | |||||||||||||||||||
| 284 | } never executed: end of block | 0 | ||||||||||||||||||
| 285 | } | - | ||||||||||||||||||
| 286 | } | - | ||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | if (target
| 0 | ||||||||||||||||||
| 289 | QTransform x = painter->deviceTransform(); | - | ||||||||||||||||||
| 290 | QPointF offset(x.dx(), x.dy()); | - | ||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | convolute(target, p+offset, src.toImage(), srcRect, QPainter::CompositionMode_SourceOver, d->convolutionKernel, d->kernelWidth, d->kernelHeight); | - | ||||||||||||||||||
| 293 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 294 | QRect srect = srcRect.isNull()
| 0 | ||||||||||||||||||
| 295 | QRect rect = boundingRectFor(srect).toRect(); | - | ||||||||||||||||||
| 296 | QImage result = QImage(rect.size(), QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||
| 297 | QPoint offset = srect.topLeft() - rect.topLeft(); | - | ||||||||||||||||||
| 298 | convolute(&result, | - | ||||||||||||||||||
| 299 | offset, | - | ||||||||||||||||||
| 300 | src.toImage(), | - | ||||||||||||||||||
| 301 | srect, | - | ||||||||||||||||||
| 302 | QPainter::CompositionMode_Source, | - | ||||||||||||||||||
| 303 | d->convolutionKernel, | - | ||||||||||||||||||
| 304 | d->kernelWidth, | - | ||||||||||||||||||
| 305 | d->kernelHeight); | - | ||||||||||||||||||
| 306 | painter->drawImage(p - offset, result); | - | ||||||||||||||||||
| 307 | } never executed: end of block | 0 | ||||||||||||||||||
| 308 | } | - | ||||||||||||||||||
| 309 | class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate | - | ||||||||||||||||||
| 310 | { | - | ||||||||||||||||||
| 311 | public: | - | ||||||||||||||||||
| 312 | QPixmapBlurFilterPrivate() : radius(5), hints(QGraphicsBlurEffect::PerformanceHint) {} never executed: end of block | 0 | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | qreal radius; | - | ||||||||||||||||||
| 315 | QGraphicsBlurEffect::BlurHints hints; | - | ||||||||||||||||||
| 316 | }; | - | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | - | |||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | - | |||||||||||||||||||
| 324 | QPixmapBlurFilter::QPixmapBlurFilter(QObject *parent) | - | ||||||||||||||||||
| 325 | : QPixmapFilter(*new QPixmapBlurFilterPrivate, BlurFilter, parent) | - | ||||||||||||||||||
| 326 | { | - | ||||||||||||||||||
| 327 | } never executed: end of block | 0 | ||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | - | |||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | - | |||||||||||||||||||
| 334 | QPixmapBlurFilter::~QPixmapBlurFilter() | - | ||||||||||||||||||
| 335 | { | - | ||||||||||||||||||
| 336 | } | - | ||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | - | |||||||||||||||||||
| 341 | - | |||||||||||||||||||
| 342 | - | |||||||||||||||||||
| 343 | void QPixmapBlurFilter::setRadius(qreal radius) | - | ||||||||||||||||||
| 344 | { | - | ||||||||||||||||||
| 345 | QPixmapBlurFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 346 | d->radius = radius; | - | ||||||||||||||||||
| 347 | } never executed: end of block | 0 | ||||||||||||||||||
| 348 | - | |||||||||||||||||||
| 349 | - | |||||||||||||||||||
| 350 | - | |||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | - | |||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | qreal QPixmapBlurFilter::radius() const | - | ||||||||||||||||||
| 355 | { | - | ||||||||||||||||||
| 356 | const QPixmapBlurFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 357 | return never executed: d->radius;return d->radius;never executed: return d->radius; | 0 | ||||||||||||||||||
| 358 | } | - | ||||||||||||||||||
| 359 | void QPixmapBlurFilter::setBlurHints(QGraphicsBlurEffect::BlurHints hints) | - | ||||||||||||||||||
| 360 | { | - | ||||||||||||||||||
| 361 | QPixmapBlurFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 362 | d->hints = hints; | - | ||||||||||||||||||
| 363 | } never executed: end of block | 0 | ||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | - | |||||||||||||||||||
| 369 | - | |||||||||||||||||||
| 370 | QGraphicsBlurEffect::BlurHints QPixmapBlurFilter::blurHints() const | - | ||||||||||||||||||
| 371 | { | - | ||||||||||||||||||
| 372 | const QPixmapBlurFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 373 | return never executed: d->hints;return d->hints;never executed: return d->hints; | 0 | ||||||||||||||||||
| 374 | } | - | ||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | const qreal radiusScale = qreal(2.5); | - | ||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | QRectF QPixmapBlurFilter::boundingRectFor(const QRectF &rect) const | - | ||||||||||||||||||
| 382 | { | - | ||||||||||||||||||
| 383 | const QPixmapBlurFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 384 | const qreal delta = radiusScale * d->radius + 1; | - | ||||||||||||||||||
| 385 | return never executed: rect.adjusted(-delta, -delta, delta, delta);return rect.adjusted(-delta, -delta, delta, delta);never executed: return rect.adjusted(-delta, -delta, delta, delta); | 0 | ||||||||||||||||||
| 386 | } | - | ||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | template <int shift> | - | ||||||||||||||||||
| 389 | inline int qt_static_shift(int value) | - | ||||||||||||||||||
| 390 | { | - | ||||||||||||||||||
| 391 | if (shift == 0
| 0 | ||||||||||||||||||
| 392 | return never executed: value;return value;never executed: return value; | 0 | ||||||||||||||||||
| 393 | else if (shift > 0
| 0 | ||||||||||||||||||
| 394 | return never executed: value << (uint(shift) & 0x1f);return value << (uint(shift) & 0x1f);never executed: return value << (uint(shift) & 0x1f); | 0 | ||||||||||||||||||
| 395 | else | - | ||||||||||||||||||
| 396 | return never executed: value >> (uint(-shift) & 0x1f);return value >> (uint(-shift) & 0x1f);never executed: return value >> (uint(-shift) & 0x1f); | 0 | ||||||||||||||||||
| 397 | } | - | ||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | template<int aprec, int zprec> | - | ||||||||||||||||||
| 400 | inline void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, int alpha) | - | ||||||||||||||||||
| 401 | { | - | ||||||||||||||||||
| 402 | QRgb *pixel = (QRgb *)bptr; | - | ||||||||||||||||||
| 403 | - | |||||||||||||||||||
| 404 | - | |||||||||||||||||||
| 405 | const int A_zprec = qt_static_shift<zprec - 24>(*pixel) & (0xff << zprec); | - | ||||||||||||||||||
| 406 | const int R_zprec = qt_static_shift<zprec - 16>(*pixel) & (0xff << zprec); | - | ||||||||||||||||||
| 407 | const int G_zprec = qt_static_shift<zprec - 8>(*pixel) & (0xff << zprec); | - | ||||||||||||||||||
| 408 | const int B_zprec = qt_static_shift<zprec>(*pixel) & (0xff << zprec); | - | ||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | const int zR_zprec = zR >> aprec; | - | ||||||||||||||||||
| 412 | const int zG_zprec = zG >> aprec; | - | ||||||||||||||||||
| 413 | const int zB_zprec = zB >> aprec; | - | ||||||||||||||||||
| 414 | const int zA_zprec = zA >> aprec; | - | ||||||||||||||||||
| 415 | - | |||||||||||||||||||
| 416 | zR += alpha * (R_zprec - zR_zprec); | - | ||||||||||||||||||
| 417 | zG += alpha * (G_zprec - zG_zprec); | - | ||||||||||||||||||
| 418 | zB += alpha * (B_zprec - zB_zprec); | - | ||||||||||||||||||
| 419 | zA += alpha * (A_zprec - zA_zprec); | - | ||||||||||||||||||
| 420 | - | |||||||||||||||||||
| 421 | - | |||||||||||||||||||
| 422 | *pixel = | - | ||||||||||||||||||
| 423 | qt_static_shift<24 - zprec - aprec>(zA & (0xff << (zprec + aprec))) | - | ||||||||||||||||||
| 424 | | qt_static_shift<16 - zprec - aprec>(zR & (0xff << (zprec + aprec))) | - | ||||||||||||||||||
| 425 | | qt_static_shift<8 - zprec - aprec>(zG & (0xff << (zprec + aprec))) | - | ||||||||||||||||||
| 426 | | qt_static_shift<-zprec - aprec>(zB & (0xff << (zprec + aprec))); | - | ||||||||||||||||||
| 427 | - | |||||||||||||||||||
| 428 | } never executed: end of block | 0 | ||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | const int alphaIndex = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3); | - | ||||||||||||||||||
| 431 | - | |||||||||||||||||||
| 432 | template<int aprec, int zprec> | - | ||||||||||||||||||
| 433 | inline void qt_blurinner_alphaOnly(uchar *bptr, int &z, int alpha) | - | ||||||||||||||||||
| 434 | { | - | ||||||||||||||||||
| 435 | const int A_zprec = int(*(bptr)) << zprec; | - | ||||||||||||||||||
| 436 | const int z_zprec = z >> aprec; | - | ||||||||||||||||||
| 437 | z += alpha * (A_zprec - z_zprec); | - | ||||||||||||||||||
| 438 | *(bptr) = z >> (zprec + aprec); | - | ||||||||||||||||||
| 439 | } never executed: end of block | 0 | ||||||||||||||||||
| 440 | - | |||||||||||||||||||
| 441 | template<int aprec, int zprec, bool alphaOnly> | - | ||||||||||||||||||
| 442 | inline void qt_blurrow(QImage & im, int line, int alpha) | - | ||||||||||||||||||
| 443 | { | - | ||||||||||||||||||
| 444 | uchar *bptr = im.scanLine(line); | - | ||||||||||||||||||
| 445 | - | |||||||||||||||||||
| 446 | int zR = 0, zG = 0, zB = 0, zA = 0; | - | ||||||||||||||||||
| 447 | - | |||||||||||||||||||
| 448 | if (alphaOnly
| 0 | ||||||||||||||||||
| 449 | bptr += alphaIndex; never executed: bptr += alphaIndex; | 0 | ||||||||||||||||||
| 450 | - | |||||||||||||||||||
| 451 | const int stride = im.depth() >> 3; | - | ||||||||||||||||||
| 452 | const int im_width = im.width(); | - | ||||||||||||||||||
| 453 | for (int index = 0; index < im_width
| 0 | ||||||||||||||||||
| 454 | if (alphaOnly
| 0 | ||||||||||||||||||
| 455 | qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha); never executed: qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha); | 0 | ||||||||||||||||||
| 456 | else | - | ||||||||||||||||||
| 457 | qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); never executed: qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); | 0 | ||||||||||||||||||
| 458 | bptr += stride; | - | ||||||||||||||||||
| 459 | } never executed: end of block | 0 | ||||||||||||||||||
| 460 | - | |||||||||||||||||||
| 461 | bptr -= stride; | - | ||||||||||||||||||
| 462 | - | |||||||||||||||||||
| 463 | for (int index = im_width - 2; index >= 0
| 0 | ||||||||||||||||||
| 464 | bptr -= stride; | - | ||||||||||||||||||
| 465 | if (alphaOnly
| 0 | ||||||||||||||||||
| 466 | qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha); never executed: qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha); | 0 | ||||||||||||||||||
| 467 | else | - | ||||||||||||||||||
| 468 | qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); never executed: qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); | 0 | ||||||||||||||||||
| 469 | } | - | ||||||||||||||||||
| 470 | } never executed: end of block | 0 | ||||||||||||||||||
| 471 | template <int aprec, int zprec, bool alphaOnly> | - | ||||||||||||||||||
| 472 | void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transposed = 0) | - | ||||||||||||||||||
| 473 | { | - | ||||||||||||||||||
| 474 | - | |||||||||||||||||||
| 475 | if (improvedQuality
| 0 | ||||||||||||||||||
| 476 | radius *= qreal(0.5); never executed: radius *= qreal(0.5); | 0 | ||||||||||||||||||
| 477 | - | |||||||||||||||||||
| 478 | ((!(img.format() == QImage::Format_ARGB32_Premultiplied || img.format() == QImage::Format_RGB32 || img.format() == QImage::Format_Indexed8 || img.format() == QImage::Format_Grayscale8)) ? qt_assert("img.format() == QImage::Format_ARGB32_Premultiplied || img.format() == QImage::Format_RGB32 || img.format() == QImage::Format_Indexed8 || img.format() == QImage::Format_Grayscale8", | - | ||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | __FILE__ | - | ||||||||||||||||||
| 482 | , | - | ||||||||||||||||||
| 483 | - | |||||||||||||||||||
| 484 | - | |||||||||||||||||||
| 485 | 705 | - | ||||||||||||||||||
| 486 | ) : qt_noop()) | - | ||||||||||||||||||
| 487 | - | |||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | ; | - | ||||||||||||||||||
| 490 | - | |||||||||||||||||||
| 491 | - | |||||||||||||||||||
| 492 | - | |||||||||||||||||||
| 493 | - | |||||||||||||||||||
| 494 | const qreal cutOffIntensity = 2; | - | ||||||||||||||||||
| 495 | int alpha = radius <= qreal(1e-5)
| 0 | ||||||||||||||||||
| 496 | ? ((1 << aprec)-1) | - | ||||||||||||||||||
| 497 | : qRound((1<<aprec)*(1 - qPow(cutOffIntensity * (1 / qreal(255)), 1 / radius))); | - | ||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | int img_height = img.height(); | - | ||||||||||||||||||
| 500 | for (int row = 0; row < img_height
| 0 | ||||||||||||||||||
| 501 | for (int i = 0; i <= int(improvedQuality)
| 0 | ||||||||||||||||||
| 502 | qt_blurrow<aprec, zprec, alphaOnly>(img, row, alpha); never executed: qt_blurrow<aprec, zprec, alphaOnly>(img, row, alpha); | 0 | ||||||||||||||||||
| 503 | } never executed: end of block | 0 | ||||||||||||||||||
| 504 | - | |||||||||||||||||||
| 505 | QImage temp(img.height(), img.width(), img.format()); | - | ||||||||||||||||||
| 506 | if (transposed >= 0
| 0 | ||||||||||||||||||
| 507 | if (img.depth() == 8
| 0 | ||||||||||||||||||
| 508 | qt_memrotate270(reinterpret_cast<const quint8*>(img.bits()), | - | ||||||||||||||||||
| 509 | img.width(), img.height(), img.bytesPerLine(), | - | ||||||||||||||||||
| 510 | reinterpret_cast<quint8*>(temp.bits()), | - | ||||||||||||||||||
| 511 | temp.bytesPerLine()); | - | ||||||||||||||||||
| 512 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 513 | qt_memrotate270(reinterpret_cast<const quint32*>(img.bits()), | - | ||||||||||||||||||
| 514 | img.width(), img.height(), img.bytesPerLine(), | - | ||||||||||||||||||
| 515 | reinterpret_cast<quint32*>(temp.bits()), | - | ||||||||||||||||||
| 516 | temp.bytesPerLine()); | - | ||||||||||||||||||
| 517 | } never executed: end of block | 0 | ||||||||||||||||||
| 518 | } else { | - | ||||||||||||||||||
| 519 | if (img.depth() == 8
| 0 | ||||||||||||||||||
| 520 | qt_memrotate90(reinterpret_cast<const quint8*>(img.bits()), | - | ||||||||||||||||||
| 521 | img.width(), img.height(), img.bytesPerLine(), | - | ||||||||||||||||||
| 522 | reinterpret_cast<quint8*>(temp.bits()), | - | ||||||||||||||||||
| 523 | temp.bytesPerLine()); | - | ||||||||||||||||||
| 524 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 525 | qt_memrotate90(reinterpret_cast<const quint32*>(img.bits()), | - | ||||||||||||||||||
| 526 | img.width(), img.height(), img.bytesPerLine(), | - | ||||||||||||||||||
| 527 | reinterpret_cast<quint32*>(temp.bits()), | - | ||||||||||||||||||
| 528 | temp.bytesPerLine()); | - | ||||||||||||||||||
| 529 | } never executed: end of block | 0 | ||||||||||||||||||
| 530 | } | - | ||||||||||||||||||
| 531 | - | |||||||||||||||||||
| 532 | img_height = temp.height(); | - | ||||||||||||||||||
| 533 | for (int row = 0; row < img_height
| 0 | ||||||||||||||||||
| 534 | for (int i = 0; i <= int(improvedQuality)
| 0 | ||||||||||||||||||
| 535 | qt_blurrow<aprec, zprec, alphaOnly>(temp, row, alpha); never executed: qt_blurrow<aprec, zprec, alphaOnly>(temp, row, alpha); | 0 | ||||||||||||||||||
| 536 | } never executed: end of block | 0 | ||||||||||||||||||
| 537 | - | |||||||||||||||||||
| 538 | if (transposed == 0
| 0 | ||||||||||||||||||
| 539 | if (img.depth() == 8
| 0 | ||||||||||||||||||
| 540 | qt_memrotate90(reinterpret_cast<const quint8*>(temp.bits()), | - | ||||||||||||||||||
| 541 | temp.width(), temp.height(), temp.bytesPerLine(), | - | ||||||||||||||||||
| 542 | reinterpret_cast<quint8*>(img.bits()), | - | ||||||||||||||||||
| 543 | img.bytesPerLine()); | - | ||||||||||||||||||
| 544 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 545 | qt_memrotate90(reinterpret_cast<const quint32*>(temp.bits()), | - | ||||||||||||||||||
| 546 | temp.width(), temp.height(), temp.bytesPerLine(), | - | ||||||||||||||||||
| 547 | reinterpret_cast<quint32*>(img.bits()), | - | ||||||||||||||||||
| 548 | img.bytesPerLine()); | - | ||||||||||||||||||
| 549 | } never executed: end of block | 0 | ||||||||||||||||||
| 550 | } else { | - | ||||||||||||||||||
| 551 | img = temp; | - | ||||||||||||||||||
| 552 | } never executed: end of block | 0 | ||||||||||||||||||
| 553 | } | - | ||||||||||||||||||
| 554 | - | |||||||||||||||||||
| 555 | - | |||||||||||||||||||
| 556 | - | |||||||||||||||||||
| 557 | __attribute__((visibility("default"))) QImage qt_halfScaled(const QImage &source) | - | ||||||||||||||||||
| 558 | { | - | ||||||||||||||||||
| 559 | if (source.width() < 2
| 0 | ||||||||||||||||||
| 560 | return never executed: QImage();return QImage();never executed: return QImage(); | 0 | ||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | QImage srcImage = source; | - | ||||||||||||||||||
| 563 | - | |||||||||||||||||||
| 564 | if (source.format() == QImage::Format_Indexed8
| 0 | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); | - | ||||||||||||||||||
| 567 | - | |||||||||||||||||||
| 568 | const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits()); | - | ||||||||||||||||||
| 569 | int sx = srcImage.bytesPerLine(); | - | ||||||||||||||||||
| 570 | int sx2 = sx << 1; | - | ||||||||||||||||||
| 571 | - | |||||||||||||||||||
| 572 | uchar *dst = reinterpret_cast<uchar*>(dest.bits()); | - | ||||||||||||||||||
| 573 | int dx = dest.bytesPerLine(); | - | ||||||||||||||||||
| 574 | int ww = dest.width(); | - | ||||||||||||||||||
| 575 | int hh = dest.height(); | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | for (int y = hh; y
| 0 | ||||||||||||||||||
| 578 | const uchar *p1 = src; | - | ||||||||||||||||||
| 579 | const uchar *p2 = src + sx; | - | ||||||||||||||||||
| 580 | uchar *q = dst; | - | ||||||||||||||||||
| 581 | for (int x = ww; x
| 0 | ||||||||||||||||||
| 582 | * never executed: q = ((int(p1[0]) + int(p1[1]) + int(p2[0]) + int(p2[1])) + 2) >> 2;*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 | ||||||||||||||||||
| 583 | } never executed: end of block | 0 | ||||||||||||||||||
| 584 | - | |||||||||||||||||||
| 585 | return never executed: dest;return dest;never executed: return dest; | 0 | ||||||||||||||||||
| 586 | } else if (source.format() == QImage::Format_ARGB8565_Premultiplied
| 0 | ||||||||||||||||||
| 587 | QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); | - | ||||||||||||||||||
| 588 | - | |||||||||||||||||||
| 589 | const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits()); | - | ||||||||||||||||||
| 590 | int sx = srcImage.bytesPerLine(); | - | ||||||||||||||||||
| 591 | int sx2 = sx << 1; | - | ||||||||||||||||||
| 592 | - | |||||||||||||||||||
| 593 | uchar *dst = reinterpret_cast<uchar*>(dest.bits()); | - | ||||||||||||||||||
| 594 | int dx = dest.bytesPerLine(); | - | ||||||||||||||||||
| 595 | int ww = dest.width(); | - | ||||||||||||||||||
| 596 | int hh = dest.height(); | - | ||||||||||||||||||
| 597 | - | |||||||||||||||||||
| 598 | for (int y = hh; y
| 0 | ||||||||||||||||||
| 599 | const uchar *p1 = src; | - | ||||||||||||||||||
| 600 | const uchar *p2 = src + sx; | - | ||||||||||||||||||
| 601 | uchar *q = dst; | - | ||||||||||||||||||
| 602 | for (int x = ww; x
| 0 | ||||||||||||||||||
| 603 | - | |||||||||||||||||||
| 604 | 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])) ))) ); | - | ||||||||||||||||||
| 605 | - | |||||||||||||||||||
| 606 | const quint16 p16_1 = (p1[2] << 8) | p1[1]; | - | ||||||||||||||||||
| 607 | const quint16 p16_2 = (p1[5] << 8) | p1[4]; | - | ||||||||||||||||||
| 608 | const quint16 p16_3 = (p2[2] << 8) | p2[1]; | - | ||||||||||||||||||
| 609 | const quint16 p16_4 = (p2[5] << 8) | p2[4]; | - | ||||||||||||||||||
| 610 | 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)) ))) ); | - | ||||||||||||||||||
| 611 | q[1] = result & 0xff; | - | ||||||||||||||||||
| 612 | q[2] = result >> 8; | - | ||||||||||||||||||
| 613 | } never executed: end of block | 0 | ||||||||||||||||||
| 614 | } never executed: end of block | 0 | ||||||||||||||||||
| 615 | - | |||||||||||||||||||
| 616 | return never executed: dest;return dest;never executed: return dest; | 0 | ||||||||||||||||||
| 617 | } else if (source.format() != QImage::Format_ARGB32_Premultiplied
| 0 | ||||||||||||||||||
| 618 | && source.format() != QImage::Format_RGB32
| 0 | ||||||||||||||||||
| 619 | { | - | ||||||||||||||||||
| 620 | srcImage = source.convertToFormat(QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||
| 621 | } never executed: end of block | 0 | ||||||||||||||||||
| 622 | - | |||||||||||||||||||
| 623 | QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); | - | ||||||||||||||||||
| 624 | - | |||||||||||||||||||
| 625 | const quint32 *src = reinterpret_cast<const quint32*>(const_cast<const QImage &>(srcImage).bits()); | - | ||||||||||||||||||
| 626 | int sx = srcImage.bytesPerLine() >> 2; | - | ||||||||||||||||||
| 627 | int sx2 = sx << 1; | - | ||||||||||||||||||
| 628 | - | |||||||||||||||||||
| 629 | quint32 *dst = reinterpret_cast<quint32*>(dest.bits()); | - | ||||||||||||||||||
| 630 | int dx = dest.bytesPerLine() >> 2; | - | ||||||||||||||||||
| 631 | int ww = dest.width(); | - | ||||||||||||||||||
| 632 | int hh = dest.height(); | - | ||||||||||||||||||
| 633 | - | |||||||||||||||||||
| 634 | for (int y = hh; y
| 0 | ||||||||||||||||||
| 635 | const quint32 *p1 = src; | - | ||||||||||||||||||
| 636 | const quint32 *p2 = src + sx; | - | ||||||||||||||||||
| 637 | quint32 *q = dst; | - | ||||||||||||||||||
| 638 | for (int x = ww; x
| 0 | ||||||||||||||||||
| 639 | * 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])) ))) );*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 | ||||||||||||||||||
| 640 | } never executed: end of block | 0 | ||||||||||||||||||
| 641 | - | |||||||||||||||||||
| 642 | return never executed: dest;return dest;never executed: return dest; | 0 | ||||||||||||||||||
| 643 | } | - | ||||||||||||||||||
| 644 | - | |||||||||||||||||||
| 645 | __attribute__((visibility("default"))) void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0) | - | ||||||||||||||||||
| 646 | { | - | ||||||||||||||||||
| 647 | if (blurImage.format() != QImage::Format_ARGB32_Premultiplied
| 0 | ||||||||||||||||||
| 648 | && blurImage.format() != QImage::Format_RGB32
| 0 | ||||||||||||||||||
| 649 | { | - | ||||||||||||||||||
| 650 | blurImage = blurImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||
| 651 | } never executed: end of block | 0 | ||||||||||||||||||
| 652 | - | |||||||||||||||||||
| 653 | qreal scale = 1; | - | ||||||||||||||||||
| 654 | if (radius >= 4
| 0 | ||||||||||||||||||
| 655 | blurImage = qt_halfScaled(blurImage); | - | ||||||||||||||||||
| 656 | scale = 2; | - | ||||||||||||||||||
| 657 | radius *= qreal(0.5); | - | ||||||||||||||||||
| 658 | } never executed: end of block | 0 | ||||||||||||||||||
| 659 | - | |||||||||||||||||||
| 660 | if (alphaOnly
| 0 | ||||||||||||||||||
| 661 | expblur<12, 10, true>(blurImage, radius, quality, transposed); never executed: expblur<12, 10, true>(blurImage, radius, quality, transposed); | 0 | ||||||||||||||||||
| 662 | else | - | ||||||||||||||||||
| 663 | expblur<12, 10, false>(blurImage, radius, quality, transposed); never executed: expblur<12, 10, false>(blurImage, radius, quality, transposed); | 0 | ||||||||||||||||||
| 664 | - | |||||||||||||||||||
| 665 | if (p
| 0 | ||||||||||||||||||
| 666 | p->scale(scale, scale); | - | ||||||||||||||||||
| 667 | p->setRenderHint(QPainter::SmoothPixmapTransform); | - | ||||||||||||||||||
| 668 | p->drawImage(QRect(0, 0, blurImage.width(), blurImage.height()), blurImage); | - | ||||||||||||||||||
| 669 | } never executed: end of block | 0 | ||||||||||||||||||
| 670 | } never executed: end of block | 0 | ||||||||||||||||||
| 671 | - | |||||||||||||||||||
| 672 | __attribute__((visibility("default"))) void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0) | - | ||||||||||||||||||
| 673 | { | - | ||||||||||||||||||
| 674 | if (blurImage.format() == QImage::Format_Indexed8
| 0 | ||||||||||||||||||
| 675 | expblur<12, 10, true>(blurImage, radius, quality, transposed); never executed: expblur<12, 10, true>(blurImage, radius, quality, transposed); | 0 | ||||||||||||||||||
| 676 | else | - | ||||||||||||||||||
| 677 | expblur<12, 10, false>(blurImage, radius, quality, transposed); never executed: expblur<12, 10, false>(blurImage, radius, quality, transposed); | 0 | ||||||||||||||||||
| 678 | } | - | ||||||||||||||||||
| 679 | - | |||||||||||||||||||
| 680 | __attribute__((visibility("default"))) extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); | - | ||||||||||||||||||
| 681 | - | |||||||||||||||||||
| 682 | - | |||||||||||||||||||
| 683 | - | |||||||||||||||||||
| 684 | - | |||||||||||||||||||
| 685 | void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &rect) const | - | ||||||||||||||||||
| 686 | { | - | ||||||||||||||||||
| 687 | const QPixmapBlurFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 688 | if (!painter->isActive()
| 0 | ||||||||||||||||||
| 689 | return; never executed: return; | 0 | ||||||||||||||||||
| 690 | - | |||||||||||||||||||
| 691 | if (src.isNull()
| 0 | ||||||||||||||||||
| 692 | return; never executed: return; | 0 | ||||||||||||||||||
| 693 | - | |||||||||||||||||||
| 694 | QRectF srcRect = rect; | - | ||||||||||||||||||
| 695 | if (srcRect.isNull()
| 0 | ||||||||||||||||||
| 696 | srcRect = src.rect(); never executed: srcRect = src.rect(); | 0 | ||||||||||||||||||
| 697 | - | |||||||||||||||||||
| 698 | if (d->radius <= 1
| 0 | ||||||||||||||||||
| 699 | painter->drawPixmap(srcRect.translated(p), src, srcRect); | - | ||||||||||||||||||
| 700 | return; never executed: return; | 0 | ||||||||||||||||||
| 701 | } | - | ||||||||||||||||||
| 702 | - | |||||||||||||||||||
| 703 | qreal scaledRadius = radiusScale * d->radius; | - | ||||||||||||||||||
| 704 | qreal scale; | - | ||||||||||||||||||
| 705 | if (qt_scaleForTransform(painter->transform(), &scale)
| 0 | ||||||||||||||||||
| 706 | scaledRadius /= scale; never executed: scaledRadius /= scale; | 0 | ||||||||||||||||||
| 707 | - | |||||||||||||||||||
| 708 | QImage srcImage; | - | ||||||||||||||||||
| 709 | QImage destImage; | - | ||||||||||||||||||
| 710 | - | |||||||||||||||||||
| 711 | if (srcRect == src.rect()
| 0 | ||||||||||||||||||
| 712 | srcImage = src.toImage(); | - | ||||||||||||||||||
| 713 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 714 | QRect rect = srcRect.toAlignedRect().intersected(src.rect()); | - | ||||||||||||||||||
| 715 | srcImage = src.copy(rect).toImage(); | - | ||||||||||||||||||
| 716 | } never executed: end of block | 0 | ||||||||||||||||||
| 717 | - | |||||||||||||||||||
| 718 | QTransform transform = painter->worldTransform(); | - | ||||||||||||||||||
| 719 | painter->translate(p); | - | ||||||||||||||||||
| 720 | qt_blurImage(painter, srcImage, scaledRadius, (d->hints & QGraphicsBlurEffect::QualityHint), false); | - | ||||||||||||||||||
| 721 | painter->setWorldTransform(transform); | - | ||||||||||||||||||
| 722 | } never executed: end of block | 0 | ||||||||||||||||||
| 723 | - | |||||||||||||||||||
| 724 | - | |||||||||||||||||||
| 725 | - | |||||||||||||||||||
| 726 | - | |||||||||||||||||||
| 727 | static void grayscale(const QImage &image, QImage &dest, const QRect& rect = QRect()) | - | ||||||||||||||||||
| 728 | { | - | ||||||||||||||||||
| 729 | QRect destRect = rect; | - | ||||||||||||||||||
| 730 | QRect srcRect = rect; | - | ||||||||||||||||||
| 731 | if (rect.isNull()
| 0 | ||||||||||||||||||
| 732 | srcRect = dest.rect(); | - | ||||||||||||||||||
| 733 | destRect = dest.rect(); | - | ||||||||||||||||||
| 734 | } never executed: end of block | 0 | ||||||||||||||||||
| 735 | if (&image != &dest
| 0 | ||||||||||||||||||
| 736 | destRect.moveTo(QPoint(0, 0)); | - | ||||||||||||||||||
| 737 | } never executed: end of block | 0 | ||||||||||||||||||
| 738 | - | |||||||||||||||||||
| 739 | const unsigned int *data = (const unsigned int *)image.bits(); | - | ||||||||||||||||||
| 740 | unsigned int *outData = (unsigned int *)dest.bits(); | - | ||||||||||||||||||
| 741 | - | |||||||||||||||||||
| 742 | if (dest.size() == image.size()
| 0 | ||||||||||||||||||
| 743 | - | |||||||||||||||||||
| 744 | int pixels = dest.width() * dest.height(); | - | ||||||||||||||||||
| 745 | for (int i = 0; i < pixels
| 0 | ||||||||||||||||||
| 746 | int val = qGray(data[i]); | - | ||||||||||||||||||
| 747 | outData[i] = qRgba(val, val, val, qAlpha(data[i])); | - | ||||||||||||||||||
| 748 | } never executed: end of block | 0 | ||||||||||||||||||
| 749 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 750 | int yd = destRect.top(); | - | ||||||||||||||||||
| 751 | for (int y = srcRect.top(); y <= srcRect.bottom()
| 0 | ||||||||||||||||||
| 752 | data = (const unsigned int*)image.scanLine(y); | - | ||||||||||||||||||
| 753 | outData = (unsigned int*)dest.scanLine(yd++); | - | ||||||||||||||||||
| 754 | int xd = destRect.left(); | - | ||||||||||||||||||
| 755 | for (int x = srcRect.left(); x <= srcRect.right()
| 0 | ||||||||||||||||||
| 756 | int val = qGray(data[x]); | - | ||||||||||||||||||
| 757 | outData[xd++] = qRgba(val, val, val, qAlpha(data[x])); | - | ||||||||||||||||||
| 758 | } never executed: end of block | 0 | ||||||||||||||||||
| 759 | } never executed: end of block | 0 | ||||||||||||||||||
| 760 | } never executed: end of block | 0 | ||||||||||||||||||
| 761 | } | - | ||||||||||||||||||
| 762 | class QPixmapColorizeFilterPrivate : public QPixmapFilterPrivate | - | ||||||||||||||||||
| 763 | { | - | ||||||||||||||||||
| 764 | 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; | - | ||||||||||||||||||
| 765 | public: | - | ||||||||||||||||||
| 766 | QColor color; | - | ||||||||||||||||||
| 767 | qreal strength; | - | ||||||||||||||||||
| 768 | quint32 opaque : 1; | - | ||||||||||||||||||
| 769 | quint32 alphaBlend : 1; | - | ||||||||||||||||||
| 770 | quint32 padding : 30; | - | ||||||||||||||||||
| 771 | }; | - | ||||||||||||||||||
| 772 | QPixmapColorizeFilter::QPixmapColorizeFilter(QObject *parent) | - | ||||||||||||||||||
| 773 | : QPixmapFilter(*new QPixmapColorizeFilterPrivate, ColorizeFilter, parent) | - | ||||||||||||||||||
| 774 | { | - | ||||||||||||||||||
| 775 | QPixmapColorizeFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 776 | d->color = QColor(0, 0, 192); | - | ||||||||||||||||||
| 777 | d->strength = qreal(1); | - | ||||||||||||||||||
| 778 | d->opaque = true; | - | ||||||||||||||||||
| 779 | d->alphaBlend = false; | - | ||||||||||||||||||
| 780 | } never executed: end of block | 0 | ||||||||||||||||||
| 781 | - | |||||||||||||||||||
| 782 | - | |||||||||||||||||||
| 783 | - | |||||||||||||||||||
| 784 | - | |||||||||||||||||||
| 785 | QPixmapColorizeFilter::~QPixmapColorizeFilter() | - | ||||||||||||||||||
| 786 | { | - | ||||||||||||||||||
| 787 | - | |||||||||||||||||||
| 788 | - | |||||||||||||||||||
| 789 | } | - | ||||||||||||||||||
| 790 | - | |||||||||||||||||||
| 791 | - | |||||||||||||||||||
| 792 | - | |||||||||||||||||||
| 793 | - | |||||||||||||||||||
| 794 | - | |||||||||||||||||||
| 795 | - | |||||||||||||||||||
| 796 | QColor QPixmapColorizeFilter::color() const | - | ||||||||||||||||||
| 797 | { | - | ||||||||||||||||||
| 798 | const QPixmapColorizeFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 799 | return never executed: d->color;return d->color;never executed: return d->color; | 0 | ||||||||||||||||||
| 800 | } | - | ||||||||||||||||||
| 801 | - | |||||||||||||||||||
| 802 | - | |||||||||||||||||||
| 803 | - | |||||||||||||||||||
| 804 | - | |||||||||||||||||||
| 805 | - | |||||||||||||||||||
| 806 | - | |||||||||||||||||||
| 807 | void QPixmapColorizeFilter::setColor(const QColor &color) | - | ||||||||||||||||||
| 808 | { | - | ||||||||||||||||||
| 809 | QPixmapColorizeFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 810 | d->color = color; | - | ||||||||||||||||||
| 811 | } never executed: end of block | 0 | ||||||||||||||||||
| 812 | - | |||||||||||||||||||
| 813 | - | |||||||||||||||||||
| 814 | - | |||||||||||||||||||
| 815 | - | |||||||||||||||||||
| 816 | - | |||||||||||||||||||
| 817 | - | |||||||||||||||||||
| 818 | - | |||||||||||||||||||
| 819 | qreal QPixmapColorizeFilter::strength() const | - | ||||||||||||||||||
| 820 | { | - | ||||||||||||||||||
| 821 | const QPixmapColorizeFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 822 | return never executed: d->strength;return d->strength;never executed: return d->strength; | 0 | ||||||||||||||||||
| 823 | } | - | ||||||||||||||||||
| 824 | - | |||||||||||||||||||
| 825 | - | |||||||||||||||||||
| 826 | - | |||||||||||||||||||
| 827 | - | |||||||||||||||||||
| 828 | - | |||||||||||||||||||
| 829 | - | |||||||||||||||||||
| 830 | void QPixmapColorizeFilter::setStrength(qreal strength) | - | ||||||||||||||||||
| 831 | { | - | ||||||||||||||||||
| 832 | QPixmapColorizeFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 833 | d->strength = qBound(qreal(0), strength, qreal(1)); | - | ||||||||||||||||||
| 834 | d->opaque = !qFuzzyIsNull(d->strength); | - | ||||||||||||||||||
| 835 | d->alphaBlend = !qFuzzyIsNull(d->strength - 1); | - | ||||||||||||||||||
| 836 | } never executed: end of block | 0 | ||||||||||||||||||
| 837 | - | |||||||||||||||||||
| 838 | - | |||||||||||||||||||
| 839 | - | |||||||||||||||||||
| 840 | - | |||||||||||||||||||
| 841 | void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const | - | ||||||||||||||||||
| 842 | { | - | ||||||||||||||||||
| 843 | const QPixmapColorizeFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 844 | - | |||||||||||||||||||
| 845 | if (src.isNull()
| 0 | ||||||||||||||||||
| 846 | return; never executed: return; | 0 | ||||||||||||||||||
| 847 | - | |||||||||||||||||||
| 848 | - | |||||||||||||||||||
| 849 | - | |||||||||||||||||||
| 850 | if (!d->opaque
| 0 | ||||||||||||||||||
| 851 | painter->drawPixmap(dest, src, srcRect); | - | ||||||||||||||||||
| 852 | return; never executed: return; | 0 | ||||||||||||||||||
| 853 | } | - | ||||||||||||||||||
| 854 | - | |||||||||||||||||||
| 855 | QImage srcImage; | - | ||||||||||||||||||
| 856 | QImage destImage; | - | ||||||||||||||||||
| 857 | - | |||||||||||||||||||
| 858 | if (srcRect.isNull()
| 0 | ||||||||||||||||||
| 859 | srcImage = src.toImage(); | - | ||||||||||||||||||
| 860 | srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); | - | ||||||||||||||||||
| 861 | destImage = QImage(srcImage.size(), srcImage.format()); | - | ||||||||||||||||||
| 862 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 863 | QRect rect = srcRect.toAlignedRect().intersected(src.rect()); | - | ||||||||||||||||||
| 864 | - | |||||||||||||||||||
| 865 | srcImage = src.copy(rect).toImage(); | - | ||||||||||||||||||
| 866 | srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); | - | ||||||||||||||||||
| 867 | destImage = QImage(rect.size(), srcImage.format()); | - | ||||||||||||||||||
| 868 | } never executed: end of block | 0 | ||||||||||||||||||
| 869 | - | |||||||||||||||||||
| 870 | - | |||||||||||||||||||
| 871 | QPainter destPainter(&destImage); | - | ||||||||||||||||||
| 872 | grayscale(srcImage, destImage, srcImage.rect()); | - | ||||||||||||||||||
| 873 | destPainter.setCompositionMode(QPainter::CompositionMode_Screen); | - | ||||||||||||||||||
| 874 | destPainter.fillRect(srcImage.rect(), d->color); | - | ||||||||||||||||||
| 875 | destPainter.end(); | - | ||||||||||||||||||
| 876 | - | |||||||||||||||||||
| 877 | if (d->alphaBlend
| 0 | ||||||||||||||||||
| 878 | - | |||||||||||||||||||
| 879 | QImage buffer = srcImage; | - | ||||||||||||||||||
| 880 | QPainter bufPainter(&buffer); | - | ||||||||||||||||||
| 881 | bufPainter.setOpacity(d->strength); | - | ||||||||||||||||||
| 882 | bufPainter.drawImage(0, 0, destImage); | - | ||||||||||||||||||
| 883 | bufPainter.end(); | - | ||||||||||||||||||
| 884 | destImage = buffer; | - | ||||||||||||||||||
| 885 | } never executed: end of block | 0 | ||||||||||||||||||
| 886 | - | |||||||||||||||||||
| 887 | if (srcImage.hasAlphaChannel()
| 0 | ||||||||||||||||||
| 888 | destImage.setAlphaChannel(srcImage.alphaChannel()); never executed: destImage.setAlphaChannel(srcImage.alphaChannel()); | 0 | ||||||||||||||||||
| 889 | - | |||||||||||||||||||
| 890 | painter->drawImage(dest, destImage); | - | ||||||||||||||||||
| 891 | } never executed: end of block | 0 | ||||||||||||||||||
| 892 | - | |||||||||||||||||||
| 893 | class QPixmapDropShadowFilterPrivate : public QPixmapFilterPrivate | - | ||||||||||||||||||
| 894 | { | - | ||||||||||||||||||
| 895 | public: | - | ||||||||||||||||||
| 896 | QPixmapDropShadowFilterPrivate() | - | ||||||||||||||||||
| 897 | : offset(8, 8), color(63, 63, 63, 180), radius(1) {} never executed: end of block | 0 | ||||||||||||||||||
| 898 | - | |||||||||||||||||||
| 899 | QPointF offset; | - | ||||||||||||||||||
| 900 | QColor color; | - | ||||||||||||||||||
| 901 | qreal radius; | - | ||||||||||||||||||
| 902 | }; | - | ||||||||||||||||||
| 903 | QPixmapDropShadowFilter::QPixmapDropShadowFilter(QObject *parent) | - | ||||||||||||||||||
| 904 | : QPixmapFilter(*new QPixmapDropShadowFilterPrivate, DropShadowFilter, parent) | - | ||||||||||||||||||
| 905 | { | - | ||||||||||||||||||
| 906 | } never executed: end of block | 0 | ||||||||||||||||||
| 907 | - | |||||||||||||||||||
| 908 | - | |||||||||||||||||||
| 909 | - | |||||||||||||||||||
| 910 | - | |||||||||||||||||||
| 911 | - | |||||||||||||||||||
| 912 | - | |||||||||||||||||||
| 913 | QPixmapDropShadowFilter::~QPixmapDropShadowFilter() | - | ||||||||||||||||||
| 914 | { | - | ||||||||||||||||||
| 915 | } | - | ||||||||||||||||||
| 916 | qreal QPixmapDropShadowFilter::blurRadius() const | - | ||||||||||||||||||
| 917 | { | - | ||||||||||||||||||
| 918 | const QPixmapDropShadowFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 919 | return never executed: d->radius;return d->radius;never executed: return d->radius; | 0 | ||||||||||||||||||
| 920 | } | - | ||||||||||||||||||
| 921 | void QPixmapDropShadowFilter::setBlurRadius(qreal radius) | - | ||||||||||||||||||
| 922 | { | - | ||||||||||||||||||
| 923 | QPixmapDropShadowFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 924 | d->radius = radius; | - | ||||||||||||||||||
| 925 | } never executed: end of block | 0 | ||||||||||||||||||
| 926 | QColor QPixmapDropShadowFilter::color() const | - | ||||||||||||||||||
| 927 | { | - | ||||||||||||||||||
| 928 | const QPixmapDropShadowFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 929 | return never executed: d->color;return d->color;never executed: return d->color; | 0 | ||||||||||||||||||
| 930 | } | - | ||||||||||||||||||
| 931 | void QPixmapDropShadowFilter::setColor(const QColor &color) | - | ||||||||||||||||||
| 932 | { | - | ||||||||||||||||||
| 933 | QPixmapDropShadowFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 934 | d->color = color; | - | ||||||||||||||||||
| 935 | } never executed: end of block | 0 | ||||||||||||||||||
| 936 | QPointF QPixmapDropShadowFilter::offset() const | - | ||||||||||||||||||
| 937 | { | - | ||||||||||||||||||
| 938 | const QPixmapDropShadowFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 939 | return never executed: d->offset;return d->offset;never executed: return d->offset; | 0 | ||||||||||||||||||
| 940 | } | - | ||||||||||||||||||
| 941 | void QPixmapDropShadowFilter::setOffset(const QPointF &offset) | - | ||||||||||||||||||
| 942 | { | - | ||||||||||||||||||
| 943 | QPixmapDropShadowFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 944 | d->offset = offset; | - | ||||||||||||||||||
| 945 | } never executed: end of block | 0 | ||||||||||||||||||
| 946 | QRectF QPixmapDropShadowFilter::boundingRectFor(const QRectF &rect) const | - | ||||||||||||||||||
| 947 | { | - | ||||||||||||||||||
| 948 | const QPixmapDropShadowFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 949 | return never executed: rect.united(rect.translated(d->offset).adjusted(-d->radius, -d->radius, d->radius, d->radius));return rect.united(rect.translated(d->offset).adjusted(-d->radius, -d->radius, d->radius, d->radius));never executed: return rect.united(rect.translated(d->offset).adjusted(-d->radius, -d->radius, d->radius, d->radius)); | 0 | ||||||||||||||||||
| 950 | } | - | ||||||||||||||||||
| 951 | - | |||||||||||||||||||
| 952 | - | |||||||||||||||||||
| 953 | - | |||||||||||||||||||
| 954 | - | |||||||||||||||||||
| 955 | void QPixmapDropShadowFilter::draw(QPainter *p, | - | ||||||||||||||||||
| 956 | const QPointF &pos, | - | ||||||||||||||||||
| 957 | const QPixmap &px, | - | ||||||||||||||||||
| 958 | const QRectF &src) const | - | ||||||||||||||||||
| 959 | { | - | ||||||||||||||||||
| 960 | const QPixmapDropShadowFilterPrivate * const d = d_func(); | - | ||||||||||||||||||
| 961 | - | |||||||||||||||||||
| 962 | if (px.isNull()
| 0 | ||||||||||||||||||
| 963 | return; never executed: return; | 0 | ||||||||||||||||||
| 964 | - | |||||||||||||||||||
| 965 | QImage tmp(px.size(), QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||
| 966 | tmp.fill(0); | - | ||||||||||||||||||
| 967 | QPainter tmpPainter(&tmp); | - | ||||||||||||||||||
| 968 | tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||||||||
| 969 | tmpPainter.drawPixmap(d->offset, px); | - | ||||||||||||||||||
| 970 | tmpPainter.end(); | - | ||||||||||||||||||
| 971 | - | |||||||||||||||||||
| 972 | - | |||||||||||||||||||
| 973 | QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||
| 974 | blurred.fill(0); | - | ||||||||||||||||||
| 975 | QPainter blurPainter(&blurred); | - | ||||||||||||||||||
| 976 | qt_blurImage(&blurPainter, tmp, d->radius, false, true); | - | ||||||||||||||||||
| 977 | blurPainter.end(); | - | ||||||||||||||||||
| 978 | - | |||||||||||||||||||
| 979 | tmp = blurred; | - | ||||||||||||||||||
| 980 | - | |||||||||||||||||||
| 981 | - | |||||||||||||||||||
| 982 | tmpPainter.begin(&tmp); | - | ||||||||||||||||||
| 983 | tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); | - | ||||||||||||||||||
| 984 | tmpPainter.fillRect(tmp.rect(), d->color); | - | ||||||||||||||||||
| 985 | tmpPainter.end(); | - | ||||||||||||||||||
| 986 | - | |||||||||||||||||||
| 987 | - | |||||||||||||||||||
| 988 | p->drawImage(pos, tmp); | - | ||||||||||||||||||
| 989 | - | |||||||||||||||||||
| 990 | - | |||||||||||||||||||
| 991 | p->drawPixmap(pos, px, src); | - | ||||||||||||||||||
| 992 | } never executed: end of block | 0 | ||||||||||||||||||
| 993 | - | |||||||||||||||||||
| 994 | - | |||||||||||||||||||
| 995 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |