| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include <qglobal.h> | - |
| 43 | | - |
| 44 | #include <QDebug> | - |
| 45 | | - |
| 46 | #include "qpainter.h" | - |
| 47 | #include "qpixmap.h" | - |
| 48 | #include "qpixmapfilter_p.h" | - |
| 49 | #include "qvarlengtharray.h" | - |
| 50 | | - |
| 51 | #include "private/qguiapplication_p.h" | - |
| 52 | #include "private/qpaintengineex_p.h" | - |
| 53 | #include "private/qpaintengine_raster_p.h" | - |
| 54 | #include "qmath.h" | - |
| 55 | #include "private/qmath_p.h" | - |
| 56 | #include "private/qmemrotate_p.h" | - |
| 57 | #include "private/qdrawhelper_p.h" | - |
| 58 | | - |
| 59 | #ifndef QT_NO_GRAPHICSEFFECT | - |
| 60 | QT_BEGIN_NAMESPACE | - |
| 61 | | - |
| 62 | class QPixmapFilterPrivate : public QObjectPrivate | - |
| 63 | { | - |
| 64 | Q_DECLARE_PUBLIC(QPixmapFilter) | - |
| 65 | public: | - |
| 66 | QPixmapFilter::FilterType type; | - |
| 67 | }; | - |
| 68 | | - |
| 69 | /*! | - |
| 70 | \class QPixmapFilter | - |
| 71 | \since 4.5 | - |
| 72 | \ingroup painting | - |
| 73 | | - |
| 74 | \brief The QPixmapFilter class provides the basic functionality for | - |
| 75 | pixmap filter classes. Pixmap filter can be for example colorize or blur. | - |
| 76 | | - |
| 77 | QPixmapFilter is the base class for every pixmap filter. QPixmapFilter is | - |
| 78 | an abstract class and cannot itself be instantiated. It provides a standard | - |
| 79 | interface for filter processing. | - |
| 80 | | - |
| 81 | \internal | - |
| 82 | */ | - |
| 83 | | - |
| 84 | /*! | - |
| 85 | \enum QPixmapFilter::FilterType | - |
| 86 | | - |
| 87 | \internal | - |
| 88 | | - |
| 89 | This enum describes the types of filter that can be applied to pixmaps. | - |
| 90 | | - |
| 91 | \value ConvolutionFilter A filter that is used to calculate the convolution | - |
| 92 | of the image with a kernel. See | - |
| 93 | QPixmapConvolutionFilter for more information. | - |
| 94 | \value ColorizeFilter A filter that is used to change the overall color | - |
| 95 | of an image. See QPixmapColorizeFilter for more | - |
| 96 | information. | - |
| 97 | \value DropShadowFilter A filter that is used to add a drop shadow to an | - |
| 98 | image. See QPixmapDropShadowFilter for more | - |
| 99 | information. | - |
| 100 | \value BlurFilter A filter that is used to blur an image using | - |
| 101 | a simple blur radius. See QPixmapBlurFilter | - |
| 102 | for more information. | - |
| 103 | | - |
| 104 | \value UserFilter The first filter type that can be used for | - |
| 105 | application-specific purposes. | - |
| 106 | */ | - |
| 107 | | - |
| 108 | | - |
| 109 | /*! | - |
| 110 | Constructs a default QPixmapFilter with the given \a type. | - |
| 111 | | - |
| 112 | This constructor should be used when subclassing QPixmapFilter to | - |
| 113 | create custom user filters. | - |
| 114 | | - |
| 115 | \internal | - |
| 116 | */ | - |
| 117 | QPixmapFilter::QPixmapFilter(FilterType type, QObject *parent) | - |
| 118 | : QObject(*new QPixmapFilterPrivate, parent) | - |
| 119 | { | - |
| 120 | d_func()->type = type; executed (the execution status of this line is deduced): d_func()->type = type; | - |
| 121 | } executed: }Execution Count:1 | 1 |
| 122 | | - |
| 123 | | - |
| 124 | | - |
| 125 | /*! | - |
| 126 | \internal | - |
| 127 | */ | - |
| 128 | QPixmapFilter::QPixmapFilter(QPixmapFilterPrivate&d, QPixmapFilter::FilterType type, QObject *parent) | - |
| 129 | : QObject(d, parent) | - |
| 130 | { | - |
| 131 | d_func()->type = type; executed (the execution status of this line is deduced): d_func()->type = type; | - |
| 132 | } executed: }Execution Count:18 | 18 |
| 133 | | - |
| 134 | | - |
| 135 | /*! | - |
| 136 | Destroys the pixmap filter. | - |
| 137 | | - |
| 138 | \internal | - |
| 139 | */ | - |
| 140 | QPixmapFilter::~QPixmapFilter() | - |
| 141 | { | - |
| 142 | } | - |
| 143 | | - |
| 144 | /*! | - |
| 145 | Returns the type of the filter. All standard pixmap filter classes | - |
| 146 | are associated with a unique value. | - |
| 147 | | - |
| 148 | \internal | - |
| 149 | */ | - |
| 150 | QPixmapFilter::FilterType QPixmapFilter::type() const | - |
| 151 | { | - |
| 152 | Q_D(const QPixmapFilter); executed (the execution status of this line is deduced): const QPixmapFilterPrivate * const d = d_func(); | - |
| 153 | return d->type; executed: return d->type;Execution Count:15 | 15 |
| 154 | } | - |
| 155 | | - |
| 156 | /*! | - |
| 157 | Returns the bounding rectangle that is affected by the pixmap | - |
| 158 | filter if the filter is applied to the specified \a rect. | - |
| 159 | | - |
| 160 | \internal | - |
| 161 | */ | - |
| 162 | QRectF QPixmapFilter::boundingRectFor(const QRectF &rect) const | - |
| 163 | { | - |
| 164 | return rect; executed: return rect;Execution Count:4 | 4 |
| 165 | } | - |
| 166 | | - |
| 167 | /*! | - |
| 168 | \fn void QPixmapFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF& srcRect) const | - |
| 169 | | - |
| 170 | Uses \a painter to draw filtered result of \a src at the point | - |
| 171 | specified by \a p. If \a srcRect is specified the it will | - |
| 172 | be used as a source rectangle to only draw a part of the source. | - |
| 173 | | - |
| 174 | draw() will affect the area which boundingRectFor() returns. | - |
| 175 | | - |
| 176 | \internal | - |
| 177 | */ | - |
| 178 | | - |
| 179 | /*! | - |
| 180 | \class QPixmapConvolutionFilter | - |
| 181 | \since 4.5 | - |
| 182 | \ingroup painting | - |
| 183 | | - |
| 184 | \brief The QPixmapConvolutionFilter class provides convolution | - |
| 185 | filtering for pixmaps. | - |
| 186 | | - |
| 187 | QPixmapConvolutionFilter implements a convolution pixmap filter, | - |
| 188 | which is applied when \l{QPixmapFilter::}{draw()} is called. A | - |
| 189 | convolution filter lets you distort an image by setting the values | - |
| 190 | of a matrix of qreal values called its | - |
| 191 | \l{setConvolutionKernel()}{kernel}. The matrix's values are | - |
| 192 | usually between -1.0 and 1.0. | - |
| 193 | | - |
| 194 | \omit | - |
| 195 | In convolution filtering, the pixel value is calculated from the | - |
| 196 | neighboring pixels based on the weighting convolution kernel. | - |
| 197 | This needs explaining to be useful. | - |
| 198 | \endomit | - |
| 199 | | - |
| 200 | Example: | - |
| 201 | \snippet code/src_gui_image_qpixmapfilter.cpp 1 | - |
| 202 | | - |
| 203 | \sa {Pixmap Filters Example}, QPixmapColorizeFilter, QPixmapDropShadowFilter | - |
| 204 | | - |
| 205 | | - |
| 206 | \internal | - |
| 207 | */ | - |
| 208 | | - |
| 209 | class QPixmapConvolutionFilterPrivate : public QPixmapFilterPrivate | - |
| 210 | { | - |
| 211 | public: | - |
| 212 | QPixmapConvolutionFilterPrivate(): convolutionKernel(0), kernelWidth(0), kernelHeight(0), convoluteAlpha(false) {} executed: }Execution Count:2 | 2 |
| 213 | ~QPixmapConvolutionFilterPrivate() { | - |
| 214 | delete[] convolutionKernel; executed (the execution status of this line is deduced): delete[] convolutionKernel; | - |
| 215 | } executed: }Execution Count:2 | 2 |
| 216 | | - |
| 217 | qreal *convolutionKernel; | - |
| 218 | int kernelWidth; | - |
| 219 | int kernelHeight; | - |
| 220 | bool convoluteAlpha; | - |
| 221 | }; | - |
| 222 | | - |
| 223 | | - |
| 224 | /*! | - |
| 225 | Constructs a pixmap convolution filter. | - |
| 226 | | - |
| 227 | By default there is no convolution kernel. | - |
| 228 | | - |
| 229 | \internal | - |
| 230 | */ | - |
| 231 | QPixmapConvolutionFilter::QPixmapConvolutionFilter(QObject *parent) | - |
| 232 | : QPixmapFilter(*new QPixmapConvolutionFilterPrivate, ConvolutionFilter, parent) | - |
| 233 | { | - |
| 234 | Q_D(QPixmapConvolutionFilter); executed (the execution status of this line is deduced): QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
| 235 | d->convoluteAlpha = true; executed (the execution status of this line is deduced): d->convoluteAlpha = true; | - |
| 236 | } executed: }Execution Count:2 | 2 |
| 237 | | - |
| 238 | /*! | - |
| 239 | Destructor of pixmap convolution filter. | - |
| 240 | | - |
| 241 | \internal | - |
| 242 | */ | - |
| 243 | QPixmapConvolutionFilter::~QPixmapConvolutionFilter() | - |
| 244 | { | - |
| 245 | } | - |
| 246 | | - |
| 247 | /*! | - |
| 248 | Sets convolution kernel with the given number of \a rows and \a columns. | - |
| 249 | Values from \a kernel are copied to internal data structure. | - |
| 250 | | - |
| 251 | To preserve the intensity of the pixmap, the sum of all the | - |
| 252 | values in the convolution kernel should add up to 1.0. A sum | - |
| 253 | greater than 1.0 produces a lighter result and a sum less than 1.0 | - |
| 254 | produces a darker and transparent result. | - |
| 255 | | - |
| 256 | \internal | - |
| 257 | */ | - |
| 258 | void QPixmapConvolutionFilter::setConvolutionKernel(const qreal *kernel, int rows, int columns) | - |
| 259 | { | - |
| 260 | Q_D(QPixmapConvolutionFilter); executed (the execution status of this line is deduced): QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
| 261 | delete [] d->convolutionKernel; executed (the execution status of this line is deduced): delete [] d->convolutionKernel; | - |
| 262 | d->convolutionKernel = new qreal[rows * columns]; executed (the execution status of this line is deduced): d->convolutionKernel = new qreal[rows * columns]; | - |
| 263 | memcpy(d->convolutionKernel, kernel, sizeof(qreal) * rows * columns); executed (the execution status of this line is deduced): memcpy(d->convolutionKernel, kernel, sizeof(qreal) * rows * columns); | - |
| 264 | d->kernelWidth = columns; executed (the execution status of this line is deduced): d->kernelWidth = columns; | - |
| 265 | d->kernelHeight = rows; executed (the execution status of this line is deduced): d->kernelHeight = rows; | - |
| 266 | } executed: }Execution Count:5 | 5 |
| 267 | | - |
| 268 | /*! | - |
| 269 | Gets the convolution kernel data. | - |
| 270 | | - |
| 271 | \internal | - |
| 272 | */ | - |
| 273 | const qreal *QPixmapConvolutionFilter::convolutionKernel() const | - |
| 274 | { | - |
| 275 | Q_D(const QPixmapConvolutionFilter); never executed (the execution status of this line is deduced): const QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
| 276 | return d->convolutionKernel; never executed: return d->convolutionKernel; | 0 |
| 277 | } | - |
| 278 | | - |
| 279 | /*! | - |
| 280 | Gets the number of rows in the convolution kernel. | - |
| 281 | | - |
| 282 | \internal | - |
| 283 | */ | - |
| 284 | int QPixmapConvolutionFilter::rows() const | - |
| 285 | { | - |
| 286 | Q_D(const QPixmapConvolutionFilter); never executed (the execution status of this line is deduced): const QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
| 287 | return d->kernelHeight; never executed: return d->kernelHeight; | 0 |
| 288 | } | - |
| 289 | | - |
| 290 | /*! | - |
| 291 | Gets the number of columns in the convolution kernel. | - |
| 292 | | - |
| 293 | \internal | - |
| 294 | */ | - |
| 295 | int QPixmapConvolutionFilter::columns() const | - |
| 296 | { | - |
| 297 | Q_D(const QPixmapConvolutionFilter); never executed (the execution status of this line is deduced): const QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
| 298 | return d->kernelWidth; never executed: return d->kernelWidth; | 0 |
| 299 | } | - |
| 300 | | - |
| 301 | | - |
| 302 | /*! | - |
| 303 | \internal | - |
| 304 | */ | - |
| 305 | QRectF QPixmapConvolutionFilter::boundingRectFor(const QRectF &rect) const | - |
| 306 | { | - |
| 307 | Q_D(const QPixmapConvolutionFilter); executed (the execution status of this line is deduced): const QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
| 308 | 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 |
| 309 | } | - |
| 310 | | - |
| 311 | // Convolutes the image | - |
| 312 | static void convolute( | - |
| 313 | QImage *destImage, | - |
| 314 | const QPointF &pos, | - |
| 315 | const QImage &srcImage, | - |
| 316 | const QRectF &srcRect, | - |
| 317 | QPainter::CompositionMode mode, | - |
| 318 | qreal *kernel, | - |
| 319 | int kernelWidth, | - |
| 320 | int kernelHeight ) | - |
| 321 | { | - |
| 322 | 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 |
| 323 | // TODO: support also other formats directly without copying | - |
| 324 | | - |
| 325 | int *fixedKernel = new int[kernelWidth*kernelHeight]; executed (the execution status of this line is deduced): int *fixedKernel = new int[kernelWidth*kernelHeight]; | - |
| 326 | for(int i = 0; i < kernelWidth*kernelHeight; i++) evaluated: i < kernelWidth*kernelHeight| yes Evaluation Count:18 | yes Evaluation Count:2 |
| 2-18 |
| 327 | { | - |
| 328 | fixedKernel[i] = (int)(65536 * kernel[i]); executed (the execution status of this line is deduced): fixedKernel[i] = (int)(65536 * kernel[i]); | - |
| 329 | } executed: }Execution Count:18 | 18 |
| 330 | QRectF trect = srcRect.isNull() ? processImage.rect() : srcRect; partially evaluated: srcRect.isNull()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 331 | trect.moveTo(pos); executed (the execution status of this line is deduced): trect.moveTo(pos); | - |
| 332 | QRectF bounded = trect.adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2); executed (the execution status of this line is deduced): QRectF bounded = trect.adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2); | - |
| 333 | QRect rect = bounded.toAlignedRect(); executed (the execution status of this line is deduced): QRect rect = bounded.toAlignedRect(); | - |
| 334 | QRect targetRect = rect.intersected(destImage->rect()); executed (the execution status of this line is deduced): QRect targetRect = rect.intersected(destImage->rect()); | - |
| 335 | | - |
| 336 | QRectF srect = srcRect.isNull() ? processImage.rect() : srcRect; partially evaluated: srcRect.isNull()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 337 | QRectF sbounded = srect.adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2); executed (the execution status of this line is deduced): QRectF sbounded = srect.adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2); | - |
| 338 | QPoint srcStartPoint = sbounded.toAlignedRect().topLeft()+(targetRect.topLeft()-rect.topLeft()); executed (the execution status of this line is deduced): QPoint srcStartPoint = sbounded.toAlignedRect().topLeft()+(targetRect.topLeft()-rect.topLeft()); | - |
| 339 | | - |
| 340 | const uint *sourceStart = (uint*)processImage.scanLine(0); executed (the execution status of this line is deduced): const uint *sourceStart = (uint*)processImage.scanLine(0); | - |
| 341 | uint *outputStart = (uint*)destImage->scanLine(0); executed (the execution status of this line is deduced): uint *outputStart = (uint*)destImage->scanLine(0); | - |
| 342 | | - |
| 343 | int yk = srcStartPoint.y(); executed (the execution status of this line is deduced): int yk = srcStartPoint.y(); | - |
| 344 | for (int y = targetRect.top(); y <= targetRect.bottom(); y++) { evaluated: y <= targetRect.bottom()| yes Evaluation Count:36 | yes Evaluation Count:2 |
| 2-36 |
| 345 | uint* output = outputStart + (destImage->bytesPerLine()/sizeof(uint))*y+targetRect.left(); executed (the execution status of this line is deduced): uint* output = outputStart + (destImage->bytesPerLine()/sizeof(uint))*y+targetRect.left(); | - |
| 346 | int xk = srcStartPoint.x(); executed (the execution status of this line is deduced): int xk = srcStartPoint.x(); | - |
| 347 | for(int x = targetRect.left(); x <= targetRect.right(); x++) { evaluated: x <= targetRect.right()| yes Evaluation Count:648 | yes Evaluation Count:36 |
| 36-648 |
| 348 | int r = 0; executed (the execution status of this line is deduced): int r = 0; | - |
| 349 | int g = 0; executed (the execution status of this line is deduced): int g = 0; | - |
| 350 | int b = 0; executed (the execution status of this line is deduced): int b = 0; | - |
| 351 | int a = 0; executed (the execution status of this line is deduced): int a = 0; | - |
| 352 | | - |
| 353 | // some out of bounds pre-checking to avoid inner-loop ifs | - |
| 354 | int kernely = -kernelHeight/2; executed (the execution status of this line is deduced): int kernely = -kernelHeight/2; | - |
| 355 | int starty = 0; executed (the execution status of this line is deduced): int starty = 0; | - |
| 356 | int endy = kernelHeight; executed (the execution status of this line is deduced): int endy = kernelHeight; | - |
| 357 | if(yk+kernely+endy >= srcImage.height()) partially evaluated: yk+kernely+endy >= srcImage.height()| no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
| 358 | endy = kernelHeight-((yk+kernely+endy)-srcImage.height())-1; never executed: endy = kernelHeight-((yk+kernely+endy)-srcImage.height())-1; | 0 |
| 359 | if(yk+kernely < 0) partially evaluated: yk+kernely < 0| no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
| 360 | starty = -(yk+kernely); never executed: starty = -(yk+kernely); | 0 |
| 361 | | - |
| 362 | int kernelx = -kernelWidth/2; executed (the execution status of this line is deduced): int kernelx = -kernelWidth/2; | - |
| 363 | int startx = 0; executed (the execution status of this line is deduced): int startx = 0; | - |
| 364 | int endx = kernelWidth; executed (the execution status of this line is deduced): int endx = kernelWidth; | - |
| 365 | if(xk+kernelx+endx >= srcImage.width()) partially evaluated: xk+kernelx+endx >= srcImage.width()| no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
| 366 | endx = kernelWidth-((xk+kernelx+endx)-srcImage.width())-1; never executed: endx = kernelWidth-((xk+kernelx+endx)-srcImage.width())-1; | 0 |
| 367 | if(xk+kernelx < 0) partially evaluated: xk+kernelx < 0| no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
| 368 | startx = -(xk+kernelx); never executed: startx = -(xk+kernelx); | 0 |
| 369 | | - |
| 370 | for (int ys = starty; ys < endy; ys ++) { evaluated: ys < endy| yes Evaluation Count:1944 | yes Evaluation Count:648 |
| 648-1944 |
| 371 | const uint *pix = sourceStart + (processImage.bytesPerLine()/sizeof(uint))*(yk+kernely+ys) + ((xk+kernelx+startx)); executed (the execution status of this line is deduced): const uint *pix = sourceStart + (processImage.bytesPerLine()/sizeof(uint))*(yk+kernely+ys) + ((xk+kernelx+startx)); | - |
| 372 | const uint *endPix = pix+endx-startx; executed (the execution status of this line is deduced): const uint *endPix = pix+endx-startx; | - |
| 373 | int kernelPos = ys*kernelWidth+startx; executed (the execution status of this line is deduced): int kernelPos = ys*kernelWidth+startx; | - |
| 374 | while (pix < endPix) { evaluated: pix < endPix| yes Evaluation Count:5832 | yes Evaluation Count:1944 |
| 1944-5832 |
| 375 | int factor = fixedKernel[kernelPos++]; executed (the execution status of this line is deduced): int factor = fixedKernel[kernelPos++]; | - |
| 376 | a += (((*pix) & 0xff000000)>>24) * factor; executed (the execution status of this line is deduced): a += (((*pix) & 0xff000000)>>24) * factor; | - |
| 377 | r += (((*pix) & 0x00ff0000)>>16) * factor; executed (the execution status of this line is deduced): r += (((*pix) & 0x00ff0000)>>16) * factor; | - |
| 378 | g += (((*pix) & 0x0000ff00)>>8 ) * factor; executed (the execution status of this line is deduced): g += (((*pix) & 0x0000ff00)>>8 ) * factor; | - |
| 379 | b += (((*pix) & 0x000000ff) ) * factor; executed (the execution status of this line is deduced): b += (((*pix) & 0x000000ff) ) * factor; | - |
| 380 | pix++; executed (the execution status of this line is deduced): pix++; | - |
| 381 | } executed: }Execution Count:5832 | 5832 |
| 382 | } executed: }Execution Count:1944 | 1944 |
| 383 | | - |
| 384 | r = qBound((int)0, r >> 16, (int)255); executed (the execution status of this line is deduced): r = qBound((int)0, r >> 16, (int)255); | - |
| 385 | g = qBound((int)0, g >> 16, (int)255); executed (the execution status of this line is deduced): g = qBound((int)0, g >> 16, (int)255); | - |
| 386 | b = qBound((int)0, b >> 16, (int)255); executed (the execution status of this line is deduced): b = qBound((int)0, b >> 16, (int)255); | - |
| 387 | a = qBound((int)0, a >> 16, (int)255); executed (the execution status of this line is deduced): a = qBound((int)0, a >> 16, (int)255); | - |
| 388 | // composition mode checking could be moved outside of loop | - |
| 389 | if(mode == QPainter::CompositionMode_Source) { partially evaluated: mode == QPainter::CompositionMode_Source| no Evaluation Count:0 | yes Evaluation Count:648 |
| 0-648 |
| 390 | uint color = (a<<24)+(r<<16)+(g<<8)+b; never executed (the execution status of this line is deduced): uint color = (a<<24)+(r<<16)+(g<<8)+b; | - |
| 391 | *output++ = color; never executed (the execution status of this line is deduced): *output++ = color; | - |
| 392 | } else { | 0 |
| 393 | uint current = *output; executed (the execution status of this line is deduced): uint current = *output; | - |
| 394 | uchar ca = (current&0xff000000)>>24; executed (the execution status of this line is deduced): uchar ca = (current&0xff000000)>>24; | - |
| 395 | uchar cr = (current&0x00ff0000)>>16; executed (the execution status of this line is deduced): uchar cr = (current&0x00ff0000)>>16; | - |
| 396 | uchar cg = (current&0x0000ff00)>>8; executed (the execution status of this line is deduced): uchar cg = (current&0x0000ff00)>>8; | - |
| 397 | uchar cb = (current&0x000000ff); executed (the execution status of this line is deduced): uchar cb = (current&0x000000ff); | - |
| 398 | uint color = executed (the execution status of this line is deduced): uint color = | - |
| 399 | (((ca*(255-a) >> 8)+a) << 24)+ executed (the execution status of this line is deduced): (((ca*(255-a) >> 8)+a) << 24)+ | - |
| 400 | (((cr*(255-a) >> 8)+r) << 16)+ executed (the execution status of this line is deduced): (((cr*(255-a) >> 8)+r) << 16)+ | - |
| 401 | (((cg*(255-a) >> 8)+g) << 8)+ executed (the execution status of this line is deduced): (((cg*(255-a) >> 8)+g) << 8)+ | - |
| 402 | (((cb*(255-a) >> 8)+b)); executed (the execution status of this line is deduced): (((cb*(255-a) >> 8)+b)); | - |
| 403 | *output++ = color;; executed (the execution status of this line is deduced): *output++ = color;; | - |
| 404 | } executed: }Execution Count:648 | 648 |
| 405 | xk++; executed (the execution status of this line is deduced): xk++; | - |
| 406 | } executed: }Execution Count:648 | 648 |
| 407 | yk++; executed (the execution status of this line is deduced): yk++; | - |
| 408 | } executed: }Execution Count:36 | 36 |
| 409 | delete[] fixedKernel; executed (the execution status of this line is deduced): delete[] fixedKernel; | - |
| 410 | } executed: }Execution Count:2 | 2 |
| 411 | | - |
| 412 | /*! | - |
| 413 | \internal | - |
| 414 | */ | - |
| 415 | void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF& srcRect) const | - |
| 416 | { | - |
| 417 | Q_D(const QPixmapConvolutionFilter); executed (the execution status of this line is deduced): const QPixmapConvolutionFilterPrivate * const d = d_func(); | - |
| 418 | if (!painter->isActive()) partially evaluated: !painter->isActive()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 419 | return; | 0 |
| 420 | | - |
| 421 | 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 |
| 422 | return; | 0 |
| 423 | | - |
| 424 | if (src.isNull()) partially evaluated: src.isNull()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 425 | return; | 0 |
| 426 | | - |
| 427 | 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 |
| 428 | static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; executed (the execution status of this line is deduced): static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; | - |
| 429 | QPixmapConvolutionFilter *convolutionFilter = static_cast<QPixmapConvolutionFilter*>(filter); executed (the execution status of this line is deduced): QPixmapConvolutionFilter *convolutionFilter = static_cast<QPixmapConvolutionFilter*>(filter); | - |
| 430 | if (convolutionFilter) { partially evaluated: convolutionFilter| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 431 | convolutionFilter->setConvolutionKernel(d->convolutionKernel, d->kernelWidth, d->kernelHeight); never executed (the execution status of this line is deduced): convolutionFilter->setConvolutionKernel(d->convolutionKernel, d->kernelWidth, d->kernelHeight); | - |
| 432 | convolutionFilter->d_func()->convoluteAlpha = d->convoluteAlpha; never executed (the execution status of this line is deduced): convolutionFilter->d_func()->convoluteAlpha = d->convoluteAlpha; | - |
| 433 | convolutionFilter->draw(painter, p, src, srcRect); never executed (the execution status of this line is deduced): convolutionFilter->draw(painter, p, src, srcRect); | - |
| 434 | return; | 0 |
| 435 | } | - |
| 436 | | - |
| 437 | // falling back to raster implementation | - |
| 438 | | - |
| 439 | QImage *target = 0; executed (the execution status of this line is deduced): QImage *target = 0; | - |
| 440 | 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 |
| 441 | target = static_cast<QImage *>(painter->paintEngine()->paintDevice()); executed (the execution status of this line is deduced): target = static_cast<QImage *>(painter->paintEngine()->paintDevice()); | - |
| 442 | | - |
| 443 | QTransform mat = painter->combinedTransform(); executed (the execution status of this line is deduced): QTransform mat = painter->combinedTransform(); | - |
| 444 | | - |
| 445 | if (mat.type() > QTransform::TxTranslate) { partially evaluated: mat.type() > QTransform::TxTranslate| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 446 | // Disabled because of transformation... | - |
| 447 | target = 0; never executed (the execution status of this line is deduced): target = 0; | - |
| 448 | } else { | 0 |
| 449 | QRasterPaintEngine *pe = static_cast<QRasterPaintEngine *>(painter->paintEngine()); executed (the execution status of this line is deduced): QRasterPaintEngine *pe = static_cast<QRasterPaintEngine *>(painter->paintEngine()); | - |
| 450 | if (pe->clipType() == QRasterPaintEngine::ComplexClip) partially evaluated: pe->clipType() == QRasterPaintEngine::ComplexClip| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 451 | // disabled because of complex clipping... | - |
| 452 | target = 0; never executed: target = 0; | 0 |
| 453 | else { | - |
| 454 | QRectF clip = pe->clipBoundingRect(); executed (the execution status of this line is deduced): QRectF clip = pe->clipBoundingRect(); | - |
| 455 | QRectF rect = boundingRectFor(srcRect.isEmpty() ? src.rect() : srcRect); executed (the execution status of this line is deduced): QRectF rect = boundingRectFor(srcRect.isEmpty() ? src.rect() : srcRect); | - |
| 456 | QTransform x = painter->deviceTransform(); executed (the execution status of this line is deduced): QTransform x = painter->deviceTransform(); | - |
| 457 | 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 |
| 458 | target = 0; never executed (the execution status of this line is deduced): target = 0; | - |
| 459 | } | 0 |
| 460 | | - |
| 461 | } executed: }Execution Count:2 | 2 |
| 462 | } | - |
| 463 | } | - |
| 464 | | - |
| 465 | if (target) { partially evaluated: target| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 466 | QTransform x = painter->deviceTransform(); executed (the execution status of this line is deduced): QTransform x = painter->deviceTransform(); | - |
| 467 | QPointF offset(x.dx(), x.dy()); executed (the execution status of this line is deduced): QPointF offset(x.dx(), x.dy()); | - |
| 468 | | - |
| 469 | convolute(target, p+offset, src.toImage(), srcRect, QPainter::CompositionMode_SourceOver, d->convolutionKernel, d->kernelWidth, d->kernelHeight); executed (the execution status of this line is deduced): convolute(target, p+offset, src.toImage(), srcRect, QPainter::CompositionMode_SourceOver, d->convolutionKernel, d->kernelWidth, d->kernelHeight); | - |
| 470 | } else { executed: }Execution Count:2 | 2 |
| 471 | QRect srect = srcRect.isNull() ? src.rect() : srcRect.toRect(); never evaluated: srcRect.isNull() | 0 |
| 472 | QRect rect = boundingRectFor(srect).toRect(); never executed (the execution status of this line is deduced): QRect rect = boundingRectFor(srect).toRect(); | - |
| 473 | QImage result = QImage(rect.size(), QImage::Format_ARGB32_Premultiplied); never executed (the execution status of this line is deduced): QImage result = QImage(rect.size(), QImage::Format_ARGB32_Premultiplied); | - |
| 474 | QPoint offset = srect.topLeft() - rect.topLeft(); never executed (the execution status of this line is deduced): QPoint offset = srect.topLeft() - rect.topLeft(); | - |
| 475 | convolute(&result, never executed (the execution status of this line is deduced): convolute(&result, | - |
| 476 | offset, never executed (the execution status of this line is deduced): offset, | - |
| 477 | src.toImage(), never executed (the execution status of this line is deduced): src.toImage(), | - |
| 478 | srect, never executed (the execution status of this line is deduced): srect, | - |
| 479 | QPainter::CompositionMode_Source, never executed (the execution status of this line is deduced): QPainter::CompositionMode_Source, | - |
| 480 | d->convolutionKernel, never executed (the execution status of this line is deduced): d->convolutionKernel, | - |
| 481 | d->kernelWidth, never executed (the execution status of this line is deduced): d->kernelWidth, | - |
| 482 | d->kernelHeight); never executed (the execution status of this line is deduced): d->kernelHeight); | - |
| 483 | painter->drawImage(p - offset, result); never executed (the execution status of this line is deduced): painter->drawImage(p - offset, result); | - |
| 484 | } | 0 |
| 485 | } | - |
| 486 | | - |
| 487 | /*! | - |
| 488 | \class QPixmapBlurFilter | - |
| 489 | \since 4.6 | - |
| 490 | \ingroup multimedia | - |
| 491 | | - |
| 492 | \brief The QPixmapBlurFilter class provides blur filtering | - |
| 493 | for pixmaps. | - |
| 494 | | - |
| 495 | QPixmapBlurFilter implements a blur pixmap filter, | - |
| 496 | which is applied when \l{QPixmapFilter::}{draw()} is called. | - |
| 497 | | - |
| 498 | The filter lets you specialize the radius of the blur as well | - |
| 499 | as hints as to whether to prefer performance or quality. | - |
| 500 | | - |
| 501 | By default, the blur effect is produced by applying an exponential | - |
| 502 | filter generated from the specified blurRadius(). Paint engines | - |
| 503 | may override this with a custom blur that is faster on the | - |
| 504 | underlying hardware. | - |
| 505 | | - |
| 506 | \sa {Pixmap Filters Example}, QPixmapConvolutionFilter, QPixmapDropShadowFilter | - |
| 507 | | - |
| 508 | \internal | - |
| 509 | */ | - |
| 510 | | - |
| 511 | class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate | - |
| 512 | { | - |
| 513 | public: | - |
| 514 | QPixmapBlurFilterPrivate() : radius(5), hints(QGraphicsBlurEffect::PerformanceHint) {} executed: }Execution Count:4 | 4 |
| 515 | | - |
| 516 | qreal radius; | - |
| 517 | QGraphicsBlurEffect::BlurHints hints; | - |
| 518 | }; | - |
| 519 | | - |
| 520 | | - |
| 521 | /*! | - |
| 522 | Constructs a pixmap blur filter. | - |
| 523 | | - |
| 524 | \internal | - |
| 525 | */ | - |
| 526 | QPixmapBlurFilter::QPixmapBlurFilter(QObject *parent) | - |
| 527 | : QPixmapFilter(*new QPixmapBlurFilterPrivate, BlurFilter, parent) | - |
| 528 | { | - |
| 529 | } executed: }Execution Count:4 | 4 |
| 530 | | - |
| 531 | /*! | - |
| 532 | Destructor of pixmap blur filter. | - |
| 533 | | - |
| 534 | \internal | - |
| 535 | */ | - |
| 536 | QPixmapBlurFilter::~QPixmapBlurFilter() | - |
| 537 | { | - |
| 538 | } | - |
| 539 | | - |
| 540 | /*! | - |
| 541 | Sets the radius of the blur filter. Higher radius produces increased blurriness. | - |
| 542 | | - |
| 543 | \internal | - |
| 544 | */ | - |
| 545 | void QPixmapBlurFilter::setRadius(qreal radius) | - |
| 546 | { | - |
| 547 | Q_D(QPixmapBlurFilter); never executed (the execution status of this line is deduced): QPixmapBlurFilterPrivate * const d = d_func(); | - |
| 548 | d->radius = radius; never executed (the execution status of this line is deduced): d->radius = radius; | - |
| 549 | } | 0 |
| 550 | | - |
| 551 | /*! | - |
| 552 | Gets the radius of the blur filter. | - |
| 553 | | - |
| 554 | \internal | - |
| 555 | */ | - |
| 556 | qreal QPixmapBlurFilter::radius() const | - |
| 557 | { | - |
| 558 | Q_D(const QPixmapBlurFilter); never executed (the execution status of this line is deduced): const QPixmapBlurFilterPrivate * const d = d_func(); | - |
| 559 | return d->radius; never executed: return d->radius; | 0 |
| 560 | } | - |
| 561 | | - |
| 562 | /*! | - |
| 563 | Setting the blur hints to PerformanceHint causes the implementation | - |
| 564 | to trade off visual quality to blur the image faster. Setting the | - |
| 565 | blur hints to QualityHint causes the implementation to improve | - |
| 566 | visual quality at the expense of speed. | - |
| 567 | | - |
| 568 | AnimationHint causes the implementation to optimize for animating | - |
| 569 | the blur radius, possibly by caching blurred versions of the source | - |
| 570 | pixmap. | - |
| 571 | | - |
| 572 | The implementation is free to ignore this value if it only has a single | - |
| 573 | blur algorithm. | - |
| 574 | | - |
| 575 | \internal | - |
| 576 | */ | - |
| 577 | void QPixmapBlurFilter::setBlurHints(QGraphicsBlurEffect::BlurHints hints) | - |
| 578 | { | - |
| 579 | Q_D(QPixmapBlurFilter); executed (the execution status of this line is deduced): QPixmapBlurFilterPrivate * const d = d_func(); | - |
| 580 | d->hints = hints; executed (the execution status of this line is deduced): d->hints = hints; | - |
| 581 | } executed: }Execution Count:4 | 4 |
| 582 | | - |
| 583 | /*! | - |
| 584 | Gets the blur hints of the blur filter. | - |
| 585 | | - |
| 586 | \internal | - |
| 587 | */ | - |
| 588 | QGraphicsBlurEffect::BlurHints QPixmapBlurFilter::blurHints() const | - |
| 589 | { | - |
| 590 | Q_D(const QPixmapBlurFilter); never executed (the execution status of this line is deduced): const QPixmapBlurFilterPrivate * const d = d_func(); | - |
| 591 | return d->hints; never executed: return d->hints; | 0 |
| 592 | } | - |
| 593 | | - |
| 594 | const qreal radiusScale = qreal(2.5); | - |
| 595 | | - |
| 596 | /*! | - |
| 597 | \internal | - |
| 598 | */ | - |
| 599 | QRectF QPixmapBlurFilter::boundingRectFor(const QRectF &rect) const | - |
| 600 | { | - |
| 601 | Q_D(const QPixmapBlurFilter); never executed (the execution status of this line is deduced): const QPixmapBlurFilterPrivate * const d = d_func(); | - |
| 602 | const qreal delta = radiusScale * d->radius + 1; never executed (the execution status of this line is deduced): const qreal delta = radiusScale * d->radius + 1; | - |
| 603 | return rect.adjusted(-delta, -delta, delta, delta); never executed: return rect.adjusted(-delta, -delta, delta, delta); | 0 |
| 604 | } | - |
| 605 | | - |
| 606 | template <int shift> | - |
| 607 | inline int qt_static_shift(int value) | - |
| 608 | { | - |
| 609 | if (shift == 0) never evaluated: shift == 0 | 0 |
| 610 | return value; never executed: return value; | 0 |
| 611 | else if (shift > 0) never evaluated: shift > 0 | 0 |
| 612 | return value << (uint(shift) & 0x1f); never executed: return value << (uint(shift) & 0x1f); | 0 |
| 613 | else | - |
| 614 | return value >> (uint(-shift) & 0x1f); never executed: return value >> (uint(-shift) & 0x1f); | 0 |
| 615 | } | - |
| 616 | | - |
| 617 | template<int aprec, int zprec> | - |
| 618 | inline void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, int alpha) | - |
| 619 | { | - |
| 620 | QRgb *pixel = (QRgb *)bptr; never executed (the execution status of this line is deduced): QRgb *pixel = (QRgb *)bptr; | - |
| 621 | | - |
| 622 | #define Z_MASK (0xff << zprec) | - |
| 623 | const int A_zprec = qt_static_shift<zprec - 24>(*pixel) & Z_MASK; never executed (the execution status of this line is deduced): const int A_zprec = qt_static_shift<zprec - 24>(*pixel) & (0xff << zprec); | - |
| 624 | const int R_zprec = qt_static_shift<zprec - 16>(*pixel) & Z_MASK; never executed (the execution status of this line is deduced): const int R_zprec = qt_static_shift<zprec - 16>(*pixel) & (0xff << zprec); | - |
| 625 | const int G_zprec = qt_static_shift<zprec - 8>(*pixel) & Z_MASK; never executed (the execution status of this line is deduced): const int G_zprec = qt_static_shift<zprec - 8>(*pixel) & (0xff << zprec); | - |
| 626 | const int B_zprec = qt_static_shift<zprec>(*pixel) & Z_MASK; never executed (the execution status of this line is deduced): const int B_zprec = qt_static_shift<zprec>(*pixel) & (0xff << zprec); | - |
| 627 | #undef Z_MASK | - |
| 628 | | - |
| 629 | const int zR_zprec = zR >> aprec; never executed (the execution status of this line is deduced): const int zR_zprec = zR >> aprec; | - |
| 630 | const int zG_zprec = zG >> aprec; never executed (the execution status of this line is deduced): const int zG_zprec = zG >> aprec; | - |
| 631 | const int zB_zprec = zB >> aprec; never executed (the execution status of this line is deduced): const int zB_zprec = zB >> aprec; | - |
| 632 | const int zA_zprec = zA >> aprec; never executed (the execution status of this line is deduced): const int zA_zprec = zA >> aprec; | - |
| 633 | | - |
| 634 | zR += alpha * (R_zprec - zR_zprec); never executed (the execution status of this line is deduced): zR += alpha * (R_zprec - zR_zprec); | - |
| 635 | zG += alpha * (G_zprec - zG_zprec); never executed (the execution status of this line is deduced): zG += alpha * (G_zprec - zG_zprec); | - |
| 636 | zB += alpha * (B_zprec - zB_zprec); never executed (the execution status of this line is deduced): zB += alpha * (B_zprec - zB_zprec); | - |
| 637 | zA += alpha * (A_zprec - zA_zprec); never executed (the execution status of this line is deduced): zA += alpha * (A_zprec - zA_zprec); | - |
| 638 | | - |
| 639 | #define ZA_MASK (0xff << (zprec + aprec)) | - |
| 640 | *pixel = never executed (the execution status of this line is deduced): *pixel = | - |
| 641 | qt_static_shift<24 - zprec - aprec>(zA & ZA_MASK) never executed (the execution status of this line is deduced): qt_static_shift<24 - zprec - aprec>(zA & (0xff << (zprec + aprec))) | - |
| 642 | | qt_static_shift<16 - zprec - aprec>(zR & ZA_MASK) never executed (the execution status of this line is deduced): | qt_static_shift<16 - zprec - aprec>(zR & (0xff << (zprec + aprec))) | - |
| 643 | | qt_static_shift<8 - zprec - aprec>(zG & ZA_MASK) never executed (the execution status of this line is deduced): | qt_static_shift<8 - zprec - aprec>(zG & (0xff << (zprec + aprec))) | - |
| 644 | | qt_static_shift<-zprec - aprec>(zB & ZA_MASK); never executed (the execution status of this line is deduced): | qt_static_shift<-zprec - aprec>(zB & (0xff << (zprec + aprec))); | - |
| 645 | #undef ZA_MASK | - |
| 646 | } | 0 |
| 647 | | - |
| 648 | const int alphaIndex = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3); | - |
| 649 | | - |
| 650 | template<int aprec, int zprec> | - |
| 651 | inline void qt_blurinner_alphaOnly(uchar *bptr, int &z, int alpha) | - |
| 652 | { | - |
| 653 | const int A_zprec = int(*(bptr)) << zprec; executed (the execution status of this line is deduced): const int A_zprec = int(*(bptr)) << zprec; | - |
| 654 | const int z_zprec = z >> aprec; executed (the execution status of this line is deduced): const int z_zprec = z >> aprec; | - |
| 655 | z += alpha * (A_zprec - z_zprec); executed (the execution status of this line is deduced): z += alpha * (A_zprec - z_zprec); | - |
| 656 | *(bptr) = z >> (zprec + aprec); executed (the execution status of this line is deduced): *(bptr) = z >> (zprec + aprec); | - |
| 657 | } executed: }Execution Count:1750492 | 1750492 |
| 658 | | - |
| 659 | template<int aprec, int zprec, bool alphaOnly> | - |
| 660 | inline void qt_blurrow(QImage & im, int line, int alpha) | - |
| 661 | { | - |
| 662 | uchar *bptr = im.scanLine(line); executed (the execution status of this line is deduced): uchar *bptr = im.scanLine(line); | - |
| 663 | | - |
| 664 | int zR = 0, zG = 0, zB = 0, zA = 0; executed (the execution status of this line is deduced): int zR = 0, zG = 0, zB = 0, zA = 0; | - |
| 665 | | - |
| 666 | 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 |
| 667 | bptr += alphaIndex; executed: bptr += alphaIndex;Execution Count:4136 | 4136 |
| 668 | | - |
| 669 | const int stride = im.depth() >> 3; executed (the execution status of this line is deduced): const int stride = im.depth() >> 3; | - |
| 670 | const int im_width = im.width(); executed (the execution status of this line is deduced): const int im_width = im.width(); | - |
| 671 | for (int index = 0; index < im_width; ++index) { evaluated: index < im_width| yes Evaluation Count:877410 | yes Evaluation Count:4328 |
| 4328-877410 |
| 672 | if (alphaOnly) partially evaluated: alphaOnly| yes Evaluation Count:877410 | no Evaluation Count:0 |
| 0-877410 |
| 673 | qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha); executed: qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha);Execution Count:877410 | 877410 |
| 674 | else | - |
| 675 | qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); never executed: qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); | 0 |
| 676 | bptr += stride; executed (the execution status of this line is deduced): bptr += stride; | - |
| 677 | } executed: }Execution Count:877410 | 877410 |
| 678 | | - |
| 679 | bptr -= stride; executed (the execution status of this line is deduced): bptr -= stride; | - |
| 680 | | - |
| 681 | for (int index = im_width - 2; index >= 0; --index) { evaluated: index >= 0| yes Evaluation Count:873082 | yes Evaluation Count:4328 |
| 4328-873082 |
| 682 | bptr -= stride; executed (the execution status of this line is deduced): bptr -= stride; | - |
| 683 | if (alphaOnly) partially evaluated: alphaOnly| yes Evaluation Count:873082 | no Evaluation Count:0 |
| 0-873082 |
| 684 | qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha); executed: qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha);Execution Count:873082 | 873082 |
| 685 | else | - |
| 686 | qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); never executed: qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha); | 0 |
| 687 | } | - |
| 688 | } executed: }Execution Count:4328 | 4328 |
| 689 | | - |
| 690 | /* | - |
| 691 | * expblur(QImage &img, int radius) | - |
| 692 | * | - |
| 693 | * Based on exponential blur algorithm by Jani Huhtanen | - |
| 694 | * | - |
| 695 | * In-place blur of image 'img' with kernel | - |
| 696 | * of approximate radius 'radius'. | - |
| 697 | * | - |
| 698 | * Blurs with two sided exponential impulse | - |
| 699 | * response. | - |
| 700 | * | - |
| 701 | * aprec = precision of alpha parameter | - |
| 702 | * in fixed-point format 0.aprec | - |
| 703 | * | - |
| 704 | * zprec = precision of state parameters | - |
| 705 | * zR,zG,zB and zA in fp format 8.zprec | - |
| 706 | */ | - |
| 707 | template <int aprec, int zprec, bool alphaOnly> | - |
| 708 | void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transposed = 0) | - |
| 709 | { | - |
| 710 | // halve the radius if we're using two passes | - |
| 711 | if (improvedQuality) evaluated: improvedQuality| yes Evaluation Count:2 | yes Evaluation Count:7 |
| 2-7 |
| 712 | radius *= qreal(0.5); executed: radius *= qreal(0.5);Execution Count:2 | 2 |
| 713 | | - |
| 714 | Q_ASSERT(img.format() == QImage::Format_ARGB32_Premultiplied executed (the execution status of this line is deduced): qt_noop(); | - |
| 715 | || img.format() == QImage::Format_RGB32 | - |
| 716 | || img.format() == QImage::Format_Indexed8); | - |
| 717 | | - |
| 718 | // choose the alpha such that pixels at radius distance from a fully | - |
| 719 | // saturated pixel will have an alpha component of no greater than | - |
| 720 | // the cutOffIntensity | - |
| 721 | const qreal cutOffIntensity = 2; executed (the execution status of this line is deduced): const qreal cutOffIntensity = 2; | - |
| 722 | int alpha = radius <= qreal(1e-5) partially evaluated: radius <= qreal(1e-5)| no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
| 723 | ? ((1 << aprec)-1) executed (the execution status of this line is deduced): ? ((1 << aprec)-1) | - |
| 724 | : qRound((1<<aprec)*(1 - qPow(cutOffIntensity * (1 / qreal(255)), 1 / radius))); executed (the execution status of this line is deduced): : qRound((1<<aprec)*(1 - qPow(cutOffIntensity * (1 / qreal(255)), 1 / radius))); | - |
| 725 | | - |
| 726 | int img_height = img.height(); executed (the execution status of this line is deduced): int img_height = img.height(); | - |
| 727 | for (int row = 0; row < img_height; ++row) { evaluated: row < img_height| yes Evaluation Count:2627 | yes Evaluation Count:9 |
| 9-2627 |
| 728 | for (int i = 0; i <= int(improvedQuality); ++i) evaluated: i <= int(improvedQuality)| yes Evaluation Count:2691 | yes Evaluation Count:2627 |
| 2627-2691 |
| 729 | qt_blurrow<aprec, zprec, alphaOnly>(img, row, alpha); executed: qt_blurrow<aprec, zprec, alphaOnly>(img, row, alpha);Execution Count:2691 | 2691 |
| 730 | } executed: }Execution Count:2627 | 2627 |
| 731 | | - |
| 732 | QImage temp(img.height(), img.width(), img.format()); executed (the execution status of this line is deduced): QImage temp(img.height(), img.width(), img.format()); | - |
| 733 | if (transposed >= 0) { partially evaluated: transposed >= 0| yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
| 734 | if (img.depth() == 8) { evaluated: img.depth() == 8| yes Evaluation Count:2 | yes Evaluation Count:7 |
| 2-7 |
| 735 | qt_memrotate270(reinterpret_cast<const quint8*>(img.bits()), executed (the execution status of this line is deduced): qt_memrotate270(reinterpret_cast<const quint8*>(img.bits()), | - |
| 736 | img.width(), img.height(), img.bytesPerLine(), executed (the execution status of this line is deduced): img.width(), img.height(), img.bytesPerLine(), | - |
| 737 | reinterpret_cast<quint8*>(temp.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint8*>(temp.bits()), | - |
| 738 | temp.bytesPerLine()); executed (the execution status of this line is deduced): temp.bytesPerLine()); | - |
| 739 | } else { executed: }Execution Count:2 | 2 |
| 740 | qt_memrotate270(reinterpret_cast<const quint32*>(img.bits()), executed (the execution status of this line is deduced): qt_memrotate270(reinterpret_cast<const quint32*>(img.bits()), | - |
| 741 | img.width(), img.height(), img.bytesPerLine(), executed (the execution status of this line is deduced): img.width(), img.height(), img.bytesPerLine(), | - |
| 742 | reinterpret_cast<quint32*>(temp.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint32*>(temp.bits()), | - |
| 743 | temp.bytesPerLine()); executed (the execution status of this line is deduced): temp.bytesPerLine()); | - |
| 744 | } executed: }Execution Count:7 | 7 |
| 745 | } else { | - |
| 746 | if (img.depth() == 8) { never evaluated: img.depth() == 8 | 0 |
| 747 | qt_memrotate90(reinterpret_cast<const quint8*>(img.bits()), never executed (the execution status of this line is deduced): qt_memrotate90(reinterpret_cast<const quint8*>(img.bits()), | - |
| 748 | img.width(), img.height(), img.bytesPerLine(), never executed (the execution status of this line is deduced): img.width(), img.height(), img.bytesPerLine(), | - |
| 749 | reinterpret_cast<quint8*>(temp.bits()), never executed (the execution status of this line is deduced): reinterpret_cast<quint8*>(temp.bits()), | - |
| 750 | temp.bytesPerLine()); never executed (the execution status of this line is deduced): temp.bytesPerLine()); | - |
| 751 | } else { | 0 |
| 752 | qt_memrotate90(reinterpret_cast<const quint32*>(img.bits()), never executed (the execution status of this line is deduced): qt_memrotate90(reinterpret_cast<const quint32*>(img.bits()), | - |
| 753 | img.width(), img.height(), img.bytesPerLine(), never executed (the execution status of this line is deduced): img.width(), img.height(), img.bytesPerLine(), | - |
| 754 | reinterpret_cast<quint32*>(temp.bits()), never executed (the execution status of this line is deduced): reinterpret_cast<quint32*>(temp.bits()), | - |
| 755 | temp.bytesPerLine()); never executed (the execution status of this line is deduced): temp.bytesPerLine()); | - |
| 756 | } | 0 |
| 757 | } | - |
| 758 | | - |
| 759 | img_height = temp.height(); executed (the execution status of this line is deduced): img_height = temp.height(); | - |
| 760 | for (int row = 0; row < img_height; ++row) { evaluated: row < img_height| yes Evaluation Count:1605 | yes Evaluation Count:9 |
| 9-1605 |
| 761 | for (int i = 0; i <= int(improvedQuality); ++i) evaluated: i <= int(improvedQuality)| yes Evaluation Count:1637 | yes Evaluation Count:1605 |
| 1605-1637 |
| 762 | qt_blurrow<aprec, zprec, alphaOnly>(temp, row, alpha); executed: qt_blurrow<aprec, zprec, alphaOnly>(temp, row, alpha);Execution Count:1637 | 1637 |
| 763 | } executed: }Execution Count:1605 | 1605 |
| 764 | | - |
| 765 | if (transposed == 0) { evaluated: transposed == 0| yes Evaluation Count:8 | yes Evaluation Count:1 |
| 1-8 |
| 766 | if (img.depth() == 8) { evaluated: img.depth() == 8| yes Evaluation Count:1 | yes Evaluation Count:7 |
| 1-7 |
| 767 | qt_memrotate90(reinterpret_cast<const quint8*>(temp.bits()), executed (the execution status of this line is deduced): qt_memrotate90(reinterpret_cast<const quint8*>(temp.bits()), | - |
| 768 | temp.width(), temp.height(), temp.bytesPerLine(), executed (the execution status of this line is deduced): temp.width(), temp.height(), temp.bytesPerLine(), | - |
| 769 | reinterpret_cast<quint8*>(img.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint8*>(img.bits()), | - |
| 770 | img.bytesPerLine()); executed (the execution status of this line is deduced): img.bytesPerLine()); | - |
| 771 | } else { executed: }Execution Count:1 | 1 |
| 772 | qt_memrotate90(reinterpret_cast<const quint32*>(temp.bits()), executed (the execution status of this line is deduced): qt_memrotate90(reinterpret_cast<const quint32*>(temp.bits()), | - |
| 773 | temp.width(), temp.height(), temp.bytesPerLine(), executed (the execution status of this line is deduced): temp.width(), temp.height(), temp.bytesPerLine(), | - |
| 774 | reinterpret_cast<quint32*>(img.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint32*>(img.bits()), | - |
| 775 | img.bytesPerLine()); executed (the execution status of this line is deduced): img.bytesPerLine()); | - |
| 776 | } executed: }Execution Count:7 | 7 |
| 777 | } else { | - |
| 778 | img = temp; executed (the execution status of this line is deduced): img = temp; | - |
| 779 | } executed: }Execution Count:1 | 1 |
| 780 | } | - |
| 781 | #define AVG(a,b) ( ((((a)^(b)) & 0xfefefefeUL) >> 1) + ((a)&(b)) ) | - |
| 782 | #define AVG16(a,b) ( ((((a)^(b)) & 0xf7deUL) >> 1) + ((a)&(b)) ) | - |
| 783 | | - |
| 784 | Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source) | - |
| 785 | { | - |
| 786 | if (source.width() < 2 || source.height() < 2) never evaluated: source.width() < 2 never evaluated: source.height() < 2 | 0 |
| 787 | return QImage(); never executed: return QImage(); | 0 |
| 788 | | - |
| 789 | QImage srcImage = source; never executed (the execution status of this line is deduced): QImage srcImage = source; | - |
| 790 | | - |
| 791 | if (source.format() == QImage::Format_Indexed8) { never evaluated: source.format() == QImage::Format_Indexed8 | 0 |
| 792 | // assumes grayscale | - |
| 793 | QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); never executed (the execution status of this line is deduced): QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); | - |
| 794 | | - |
| 795 | const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits()); never executed (the execution status of this line is deduced): const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits()); | - |
| 796 | int sx = srcImage.bytesPerLine(); never executed (the execution status of this line is deduced): int sx = srcImage.bytesPerLine(); | - |
| 797 | int sx2 = sx << 1; never executed (the execution status of this line is deduced): int sx2 = sx << 1; | - |
| 798 | | - |
| 799 | uchar *dst = reinterpret_cast<uchar*>(dest.bits()); never executed (the execution status of this line is deduced): uchar *dst = reinterpret_cast<uchar*>(dest.bits()); | - |
| 800 | int dx = dest.bytesPerLine(); never executed (the execution status of this line is deduced): int dx = dest.bytesPerLine(); | - |
| 801 | int ww = dest.width(); never executed (the execution status of this line is deduced): int ww = dest.width(); | - |
| 802 | int hh = dest.height(); never executed (the execution status of this line is deduced): int hh = dest.height(); | - |
| 803 | | - |
| 804 | for (int y = hh; y; --y, dst += dx, src += sx2) { | 0 |
| 805 | const uchar *p1 = src; never executed (the execution status of this line is deduced): const uchar *p1 = src; | - |
| 806 | const uchar *p2 = src + sx; never executed (the execution status of this line is deduced): const uchar *p2 = src + sx; | - |
| 807 | uchar *q = dst; never executed (the execution status of this line is deduced): uchar *q = dst; | - |
| 808 | for (int x = ww; x; --x, ++q, p1 += 2, p2 += 2) | 0 |
| 809 | *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 |
| 810 | } | 0 |
| 811 | | - |
| 812 | return dest; never executed: return dest; | 0 |
| 813 | } else if (source.format() == QImage::Format_ARGB8565_Premultiplied) { never evaluated: source.format() == QImage::Format_ARGB8565_Premultiplied | 0 |
| 814 | QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); never executed (the execution status of this line is deduced): QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); | - |
| 815 | | - |
| 816 | const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits()); never executed (the execution status of this line is deduced): const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits()); | - |
| 817 | int sx = srcImage.bytesPerLine(); never executed (the execution status of this line is deduced): int sx = srcImage.bytesPerLine(); | - |
| 818 | int sx2 = sx << 1; never executed (the execution status of this line is deduced): int sx2 = sx << 1; | - |
| 819 | | - |
| 820 | uchar *dst = reinterpret_cast<uchar*>(dest.bits()); never executed (the execution status of this line is deduced): uchar *dst = reinterpret_cast<uchar*>(dest.bits()); | - |
| 821 | int dx = dest.bytesPerLine(); never executed (the execution status of this line is deduced): int dx = dest.bytesPerLine(); | - |
| 822 | int ww = dest.width(); never executed (the execution status of this line is deduced): int ww = dest.width(); | - |
| 823 | int hh = dest.height(); never executed (the execution status of this line is deduced): int hh = dest.height(); | - |
| 824 | | - |
| 825 | for (int y = hh; y; --y, dst += dx, src += sx2) { | 0 |
| 826 | const uchar *p1 = src; never executed (the execution status of this line is deduced): const uchar *p1 = src; | - |
| 827 | const uchar *p2 = src + sx; never executed (the execution status of this line is deduced): const uchar *p2 = src + sx; | - |
| 828 | uchar *q = dst; never executed (the execution status of this line is deduced): uchar *q = dst; | - |
| 829 | for (int x = ww; x; --x, q += 3, p1 += 6, p2 += 6) { | 0 |
| 830 | // alpha | - |
| 831 | q[0] = AVG(AVG(p1[0], p1[3]), AVG(p2[0], p2[3])); never executed (the execution status of this line is deduced): 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])) ))) ); | - |
| 832 | // rgb | - |
| 833 | const quint16 p16_1 = (p1[2] << 8) | p1[1]; never executed (the execution status of this line is deduced): const quint16 p16_1 = (p1[2] << 8) | p1[1]; | - |
| 834 | const quint16 p16_2 = (p1[5] << 8) | p1[4]; never executed (the execution status of this line is deduced): const quint16 p16_2 = (p1[5] << 8) | p1[4]; | - |
| 835 | const quint16 p16_3 = (p2[2] << 8) | p2[1]; never executed (the execution status of this line is deduced): const quint16 p16_3 = (p2[2] << 8) | p2[1]; | - |
| 836 | const quint16 p16_4 = (p2[5] << 8) | p2[4]; never executed (the execution status of this line is deduced): const quint16 p16_4 = (p2[5] << 8) | p2[4]; | - |
| 837 | const quint16 result = AVG16(AVG16(p16_1, p16_2), AVG16(p16_3, p16_4)); never executed (the execution status of this line is deduced): 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)) ))) ); | - |
| 838 | q[1] = result & 0xff; never executed (the execution status of this line is deduced): q[1] = result & 0xff; | - |
| 839 | q[2] = result >> 8; never executed (the execution status of this line is deduced): q[2] = result >> 8; | - |
| 840 | } | 0 |
| 841 | } | 0 |
| 842 | | - |
| 843 | return dest; never executed: return dest; | 0 |
| 844 | } else if (source.format() != QImage::Format_ARGB32_Premultiplied never evaluated: source.format() != QImage::Format_ARGB32_Premultiplied | 0 |
| 845 | && source.format() != QImage::Format_RGB32) never evaluated: source.format() != QImage::Format_RGB32 | 0 |
| 846 | { | - |
| 847 | srcImage = source.convertToFormat(QImage::Format_ARGB32_Premultiplied); never executed (the execution status of this line is deduced): srcImage = source.convertToFormat(QImage::Format_ARGB32_Premultiplied); | - |
| 848 | } | 0 |
| 849 | | - |
| 850 | QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); never executed (the execution status of this line is deduced): QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); | - |
| 851 | | - |
| 852 | const quint32 *src = reinterpret_cast<const quint32*>(const_cast<const QImage &>(srcImage).bits()); never executed (the execution status of this line is deduced): const quint32 *src = reinterpret_cast<const quint32*>(const_cast<const QImage &>(srcImage).bits()); | - |
| 853 | int sx = srcImage.bytesPerLine() >> 2; never executed (the execution status of this line is deduced): int sx = srcImage.bytesPerLine() >> 2; | - |
| 854 | int sx2 = sx << 1; never executed (the execution status of this line is deduced): int sx2 = sx << 1; | - |
| 855 | | - |
| 856 | quint32 *dst = reinterpret_cast<quint32*>(dest.bits()); never executed (the execution status of this line is deduced): quint32 *dst = reinterpret_cast<quint32*>(dest.bits()); | - |
| 857 | int dx = dest.bytesPerLine() >> 2; never executed (the execution status of this line is deduced): int dx = dest.bytesPerLine() >> 2; | - |
| 858 | int ww = dest.width(); never executed (the execution status of this line is deduced): int ww = dest.width(); | - |
| 859 | int hh = dest.height(); never executed (the execution status of this line is deduced): int hh = dest.height(); | - |
| 860 | | - |
| 861 | for (int y = hh; y; --y, dst += dx, src += sx2) { | 0 |
| 862 | const quint32 *p1 = src; never executed (the execution status of this line is deduced): const quint32 *p1 = src; | - |
| 863 | const quint32 *p2 = src + sx; never executed (the execution status of this line is deduced): const quint32 *p2 = src + sx; | - |
| 864 | quint32 *q = dst; never executed (the execution status of this line is deduced): quint32 *q = dst; | - |
| 865 | for (int x = ww; x; --x, q++, p1 += 2, p2 += 2) | 0 |
| 866 | *q = AVG(AVG(p1[0], p1[1]), AVG(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 |
| 867 | } | 0 |
| 868 | | - |
| 869 | return dest; never executed: return dest; | 0 |
| 870 | } | - |
| 871 | | - |
| 872 | Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0) | - |
| 873 | { | - |
| 874 | 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 |
| 875 | && blurImage.format() != QImage::Format_RGB32) never evaluated: blurImage.format() != QImage::Format_RGB32 | 0 |
| 876 | { | - |
| 877 | blurImage = blurImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); never executed (the execution status of this line is deduced): blurImage = blurImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); | - |
| 878 | } | 0 |
| 879 | | - |
| 880 | qreal scale = 1; executed (the execution status of this line is deduced): qreal scale = 1; | - |
| 881 | 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 |
| 882 | blurImage = qt_halfScaled(blurImage); never executed (the execution status of this line is deduced): blurImage = qt_halfScaled(blurImage); | - |
| 883 | scale = 2; never executed (the execution status of this line is deduced): scale = 2; | - |
| 884 | radius *= qreal(0.5); never executed (the execution status of this line is deduced): radius *= qreal(0.5); | - |
| 885 | } | 0 |
| 886 | | - |
| 887 | if (alphaOnly) partially evaluated: alphaOnly| yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
| 888 | expblur<12, 10, true>(blurImage, radius, quality, transposed); executed: expblur<12, 10, true>(blurImage, radius, quality, transposed);Execution Count:7 | 7 |
| 889 | else | - |
| 890 | expblur<12, 10, false>(blurImage, radius, quality, transposed); never executed: expblur<12, 10, false>(blurImage, radius, quality, transposed); | 0 |
| 891 | | - |
| 892 | if (p) { partially evaluated: p| yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
| 893 | p->scale(scale, scale); executed (the execution status of this line is deduced): p->scale(scale, scale); | - |
| 894 | p->setRenderHint(QPainter::SmoothPixmapTransform); executed (the execution status of this line is deduced): p->setRenderHint(QPainter::SmoothPixmapTransform); | - |
| 895 | p->drawImage(QRect(0, 0, blurImage.width(), blurImage.height()), blurImage); executed (the execution status of this line is deduced): p->drawImage(QRect(0, 0, blurImage.width(), blurImage.height()), blurImage); | - |
| 896 | } executed: }Execution Count:7 | 7 |
| 897 | } executed: }Execution Count:7 | 7 |
| 898 | | - |
| 899 | Q_WIDGETS_EXPORT void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0) | - |
| 900 | { | - |
| 901 | if (blurImage.format() == QImage::Format_Indexed8) partially evaluated: blurImage.format() == QImage::Format_Indexed8| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 902 | expblur<12, 10, true>(blurImage, radius, quality, transposed); executed: expblur<12, 10, true>(blurImage, radius, quality, transposed);Execution Count:2 | 2 |
| 903 | else | - |
| 904 | expblur<12, 10, false>(blurImage, radius, quality, transposed); never executed: expblur<12, 10, false>(blurImage, radius, quality, transposed); | 0 |
| 905 | } | - |
| 906 | | - |
| 907 | Q_GUI_EXPORT extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); | - |
| 908 | | - |
| 909 | /*! | - |
| 910 | \internal | - |
| 911 | */ | - |
| 912 | void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &rect) const | - |
| 913 | { | - |
| 914 | Q_D(const QPixmapBlurFilter); never executed (the execution status of this line is deduced): const QPixmapBlurFilterPrivate * const d = d_func(); | - |
| 915 | if (!painter->isActive()) never evaluated: !painter->isActive() | 0 |
| 916 | return; | 0 |
| 917 | | - |
| 918 | if (src.isNull()) never evaluated: src.isNull() | 0 |
| 919 | return; | 0 |
| 920 | | - |
| 921 | QRectF srcRect = rect; never executed (the execution status of this line is deduced): QRectF srcRect = rect; | - |
| 922 | if (srcRect.isNull()) never evaluated: srcRect.isNull() | 0 |
| 923 | srcRect = src.rect(); never executed: srcRect = src.rect(); | 0 |
| 924 | | - |
| 925 | if (d->radius <= 1) { never evaluated: d->radius <= 1 | 0 |
| 926 | painter->drawPixmap(srcRect.translated(p), src, srcRect); never executed (the execution status of this line is deduced): painter->drawPixmap(srcRect.translated(p), src, srcRect); | - |
| 927 | return; | 0 |
| 928 | } | - |
| 929 | | - |
| 930 | qreal scaledRadius = radiusScale * d->radius; never executed (the execution status of this line is deduced): qreal scaledRadius = radiusScale * d->radius; | - |
| 931 | qreal scale; never executed (the execution status of this line is deduced): qreal scale; | - |
| 932 | if (qt_scaleForTransform(painter->transform(), &scale)) never evaluated: qt_scaleForTransform(painter->transform(), &scale) | 0 |
| 933 | scaledRadius /= scale; never executed: scaledRadius /= scale; | 0 |
| 934 | | - |
| 935 | QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? never evaluated: painter->paintEngine() never evaluated: painter->paintEngine()->isExtended() | 0 |
| 936 | static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; never executed (the execution status of this line is deduced): static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; | - |
| 937 | QPixmapBlurFilter *blurFilter = static_cast<QPixmapBlurFilter*>(filter); never executed (the execution status of this line is deduced): QPixmapBlurFilter *blurFilter = static_cast<QPixmapBlurFilter*>(filter); | - |
| 938 | if (blurFilter) { never evaluated: blurFilter | 0 |
| 939 | blurFilter->setRadius(scaledRadius); never executed (the execution status of this line is deduced): blurFilter->setRadius(scaledRadius); | - |
| 940 | blurFilter->setBlurHints(d->hints); never executed (the execution status of this line is deduced): blurFilter->setBlurHints(d->hints); | - |
| 941 | blurFilter->draw(painter, p, src, srcRect); never executed (the execution status of this line is deduced): blurFilter->draw(painter, p, src, srcRect); | - |
| 942 | return; | 0 |
| 943 | } | - |
| 944 | | - |
| 945 | QImage srcImage; never executed (the execution status of this line is deduced): QImage srcImage; | - |
| 946 | QImage destImage; never executed (the execution status of this line is deduced): QImage destImage; | - |
| 947 | | - |
| 948 | if (srcRect == src.rect()) { never evaluated: srcRect == src.rect() | 0 |
| 949 | srcImage = src.toImage(); never executed (the execution status of this line is deduced): srcImage = src.toImage(); | - |
| 950 | } else { | 0 |
| 951 | QRect rect = srcRect.toAlignedRect().intersected(src.rect()); never executed (the execution status of this line is deduced): QRect rect = srcRect.toAlignedRect().intersected(src.rect()); | - |
| 952 | srcImage = src.copy(rect).toImage(); never executed (the execution status of this line is deduced): srcImage = src.copy(rect).toImage(); | - |
| 953 | } | 0 |
| 954 | | - |
| 955 | QTransform transform = painter->worldTransform(); never executed (the execution status of this line is deduced): QTransform transform = painter->worldTransform(); | - |
| 956 | painter->translate(p); never executed (the execution status of this line is deduced): painter->translate(p); | - |
| 957 | qt_blurImage(painter, srcImage, scaledRadius, (d->hints & QGraphicsBlurEffect::QualityHint), false); never executed (the execution status of this line is deduced): qt_blurImage(painter, srcImage, scaledRadius, (d->hints & QGraphicsBlurEffect::QualityHint), false); | - |
| 958 | painter->setWorldTransform(transform); never executed (the execution status of this line is deduced): painter->setWorldTransform(transform); | - |
| 959 | } | 0 |
| 960 | | - |
| 961 | // grayscales the image to dest (could be same). If rect isn't defined | - |
| 962 | // destination image size is used to determine the dimension of grayscaling | - |
| 963 | // process. | - |
| 964 | static void grayscale(const QImage &image, QImage &dest, const QRect& rect = QRect()) | - |
| 965 | { | - |
| 966 | QRect destRect = rect; executed (the execution status of this line is deduced): QRect destRect = rect; | - |
| 967 | QRect srcRect = rect; executed (the execution status of this line is deduced): QRect srcRect = rect; | - |
| 968 | if (rect.isNull()) { partially evaluated: rect.isNull()| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 969 | srcRect = dest.rect(); never executed (the execution status of this line is deduced): srcRect = dest.rect(); | - |
| 970 | destRect = dest.rect(); never executed (the execution status of this line is deduced): destRect = dest.rect(); | - |
| 971 | } | 0 |
| 972 | if (&image != &dest) { partially evaluated: &image != &dest| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 973 | destRect.moveTo(QPoint(0, 0)); executed (the execution status of this line is deduced): destRect.moveTo(QPoint(0, 0)); | - |
| 974 | } executed: }Execution Count:5 | 5 |
| 975 | | - |
| 976 | unsigned int *data = (unsigned int *)image.bits(); executed (the execution status of this line is deduced): unsigned int *data = (unsigned int *)image.bits(); | - |
| 977 | unsigned int *outData = (unsigned int *)dest.bits(); executed (the execution status of this line is deduced): unsigned int *outData = (unsigned int *)dest.bits(); | - |
| 978 | | - |
| 979 | 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 |
| 980 | // a bit faster loop for grayscaling everything | - |
| 981 | int pixels = dest.width() * dest.height(); executed (the execution status of this line is deduced): int pixels = dest.width() * dest.height(); | - |
| 982 | for (int i = 0; i < pixels; ++i) { evaluated: i < pixels| yes Evaluation Count:41472 | yes Evaluation Count:5 |
| 5-41472 |
| 983 | int val = qGray(data[i]); executed (the execution status of this line is deduced): int val = qGray(data[i]); | - |
| 984 | outData[i] = qRgba(val, val, val, qAlpha(data[i])); executed (the execution status of this line is deduced): outData[i] = qRgba(val, val, val, qAlpha(data[i])); | - |
| 985 | } executed: }Execution Count:41472 | 41472 |
| 986 | } else { executed: }Execution Count:5 | 5 |
| 987 | int yd = destRect.top(); never executed (the execution status of this line is deduced): int yd = destRect.top(); | - |
| 988 | for (int y = srcRect.top(); y <= srcRect.bottom() && y < image.height(); y++) { never evaluated: y <= srcRect.bottom() never evaluated: y < image.height() | 0 |
| 989 | data = (unsigned int*)image.scanLine(y); never executed (the execution status of this line is deduced): data = (unsigned int*)image.scanLine(y); | - |
| 990 | outData = (unsigned int*)dest.scanLine(yd++); never executed (the execution status of this line is deduced): outData = (unsigned int*)dest.scanLine(yd++); | - |
| 991 | int xd = destRect.left(); never executed (the execution status of this line is deduced): int xd = destRect.left(); | - |
| 992 | for (int x = srcRect.left(); x <= srcRect.right() && x < image.width(); x++) { never evaluated: x <= srcRect.right() never evaluated: x < image.width() | 0 |
| 993 | int val = qGray(data[x]); never executed (the execution status of this line is deduced): int val = qGray(data[x]); | - |
| 994 | outData[xd++] = qRgba(val, val, val, qAlpha(data[x])); never executed (the execution status of this line is deduced): outData[xd++] = qRgba(val, val, val, qAlpha(data[x])); | - |
| 995 | } | 0 |
| 996 | } | 0 |
| 997 | } | 0 |
| 998 | } | - |
| 999 | | - |
| 1000 | /*! | - |
| 1001 | \class QPixmapColorizeFilter | - |
| 1002 | \since 4.5 | - |
| 1003 | \ingroup painting | - |
| 1004 | | - |
| 1005 | \brief The QPixmapColorizeFilter class provides colorizing | - |
| 1006 | filtering for pixmaps. | - |
| 1007 | | - |
| 1008 | A colorize filter gives the pixmap a tint of its color(). The | - |
| 1009 | filter first grayscales the pixmap and then converts those to | - |
| 1010 | colorized values using QPainter::CompositionMode_Screen with the | - |
| 1011 | chosen color. The alpha-channel is not changed. | - |
| 1012 | | - |
| 1013 | Example: | - |
| 1014 | \snippet code/src_gui_image_qpixmapfilter.cpp 0 | - |
| 1015 | | - |
| 1016 | \sa QPainter::CompositionMode | - |
| 1017 | | - |
| 1018 | \internal | - |
| 1019 | */ | - |
| 1020 | class QPixmapColorizeFilterPrivate : public QPixmapFilterPrivate | - |
| 1021 | { | - |
| 1022 | Q_DECLARE_PUBLIC(QPixmapColorizeFilter) | - |
| 1023 | public: | - |
| 1024 | QColor color; | - |
| 1025 | qreal strength; | - |
| 1026 | quint32 opaque : 1; | - |
| 1027 | quint32 alphaBlend : 1; | - |
| 1028 | quint32 padding : 30; | - |
| 1029 | }; | - |
| 1030 | | - |
| 1031 | /*! | - |
| 1032 | Constructs an pixmap colorize filter. | - |
| 1033 | | - |
| 1034 | Default color value for colorizing is QColor(0, 0, 192). | - |
| 1035 | | - |
| 1036 | \internal | - |
| 1037 | */ | - |
| 1038 | QPixmapColorizeFilter::QPixmapColorizeFilter(QObject *parent) | - |
| 1039 | : QPixmapFilter(*new QPixmapColorizeFilterPrivate, ColorizeFilter, parent) | - |
| 1040 | { | - |
| 1041 | Q_D(QPixmapColorizeFilter); executed (the execution status of this line is deduced): QPixmapColorizeFilterPrivate * const d = d_func(); | - |
| 1042 | d->color = QColor(0, 0, 192); executed (the execution status of this line is deduced): d->color = QColor(0, 0, 192); | - |
| 1043 | d->strength = qreal(1); executed (the execution status of this line is deduced): d->strength = qreal(1); | - |
| 1044 | d->opaque = true; executed (the execution status of this line is deduced): d->opaque = true; | - |
| 1045 | d->alphaBlend = false; executed (the execution status of this line is deduced): d->alphaBlend = false; | - |
| 1046 | } executed: }Execution Count:7 | 7 |
| 1047 | | - |
| 1048 | /*! | - |
| 1049 | Gets the color of the colorize filter. | - |
| 1050 | | - |
| 1051 | \internal | - |
| 1052 | */ | - |
| 1053 | QColor QPixmapColorizeFilter::color() const | - |
| 1054 | { | - |
| 1055 | Q_D(const QPixmapColorizeFilter); executed (the execution status of this line is deduced): const QPixmapColorizeFilterPrivate * const d = d_func(); | - |
| 1056 | return d->color; executed: return d->color;Execution Count:1 | 1 |
| 1057 | } | - |
| 1058 | | - |
| 1059 | /*! | - |
| 1060 | Sets the color of the colorize filter to the \a color specified. | - |
| 1061 | | - |
| 1062 | \internal | - |
| 1063 | */ | - |
| 1064 | void QPixmapColorizeFilter::setColor(const QColor &color) | - |
| 1065 | { | - |
| 1066 | Q_D(QPixmapColorizeFilter); executed (the execution status of this line is deduced): QPixmapColorizeFilterPrivate * const d = d_func(); | - |
| 1067 | d->color = color; executed (the execution status of this line is deduced): d->color = color; | - |
| 1068 | } executed: }Execution Count:6 | 6 |
| 1069 | | - |
| 1070 | /*! | - |
| 1071 | Gets the strength of the colorize filter, 1.0 means full colorized while | - |
| 1072 | 0.0 equals to no filtering at all. | - |
| 1073 | | - |
| 1074 | \internal | - |
| 1075 | */ | - |
| 1076 | qreal QPixmapColorizeFilter::strength() const | - |
| 1077 | { | - |
| 1078 | Q_D(const QPixmapColorizeFilter); executed (the execution status of this line is deduced): const QPixmapColorizeFilterPrivate * const d = d_func(); | - |
| 1079 | return d->strength; executed: return d->strength;Execution Count:3 | 3 |
| 1080 | } | - |
| 1081 | | - |
| 1082 | /*! | - |
| 1083 | Sets the strength of the colorize filter to \a strength. | - |
| 1084 | | - |
| 1085 | \internal | - |
| 1086 | */ | - |
| 1087 | void QPixmapColorizeFilter::setStrength(qreal strength) | - |
| 1088 | { | - |
| 1089 | Q_D(QPixmapColorizeFilter); executed (the execution status of this line is deduced): QPixmapColorizeFilterPrivate * const d = d_func(); | - |
| 1090 | d->strength = qBound(qreal(0), strength, qreal(1)); executed (the execution status of this line is deduced): d->strength = qBound(qreal(0), strength, qreal(1)); | - |
| 1091 | d->opaque = !qFuzzyIsNull(d->strength); executed (the execution status of this line is deduced): d->opaque = !qFuzzyIsNull(d->strength); | - |
| 1092 | d->alphaBlend = !qFuzzyIsNull(d->strength - 1); executed (the execution status of this line is deduced): d->alphaBlend = !qFuzzyIsNull(d->strength - 1); | - |
| 1093 | } executed: }Execution Count:3 | 3 |
| 1094 | | - |
| 1095 | /*! | - |
| 1096 | \internal | - |
| 1097 | */ | - |
| 1098 | void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const | - |
| 1099 | { | - |
| 1100 | Q_D(const QPixmapColorizeFilter); executed (the execution status of this line is deduced): const QPixmapColorizeFilterPrivate * const d = d_func(); | - |
| 1101 | | - |
| 1102 | if (src.isNull()) partially evaluated: src.isNull()| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 1103 | return; | 0 |
| 1104 | | - |
| 1105 | 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 |
| 1106 | static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; executed (the execution status of this line is deduced): static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; | - |
| 1107 | QPixmapColorizeFilter *colorizeFilter = static_cast<QPixmapColorizeFilter*>(filter); executed (the execution status of this line is deduced): QPixmapColorizeFilter *colorizeFilter = static_cast<QPixmapColorizeFilter*>(filter); | - |
| 1108 | if (colorizeFilter) { partially evaluated: colorizeFilter| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 1109 | colorizeFilter->setColor(d->color); never executed (the execution status of this line is deduced): colorizeFilter->setColor(d->color); | - |
| 1110 | colorizeFilter->setStrength(d->strength); never executed (the execution status of this line is deduced): colorizeFilter->setStrength(d->strength); | - |
| 1111 | colorizeFilter->draw(painter, dest, src, srcRect); never executed (the execution status of this line is deduced): colorizeFilter->draw(painter, dest, src, srcRect); | - |
| 1112 | return; | 0 |
| 1113 | } | - |
| 1114 | | - |
| 1115 | // falling back to raster implementation | - |
| 1116 | | - |
| 1117 | if (!d->opaque) { partially evaluated: !d->opaque| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 1118 | painter->drawPixmap(dest, src, srcRect); never executed (the execution status of this line is deduced): painter->drawPixmap(dest, src, srcRect); | - |
| 1119 | return; | 0 |
| 1120 | } | - |
| 1121 | | - |
| 1122 | QImage srcImage; executed (the execution status of this line is deduced): QImage srcImage; | - |
| 1123 | QImage destImage; executed (the execution status of this line is deduced): QImage destImage; | - |
| 1124 | | - |
| 1125 | if (srcRect.isNull()) { evaluated: srcRect.isNull()| yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
| 1126 | srcImage = src.toImage(); executed (the execution status of this line is deduced): srcImage = src.toImage(); | - |
| 1127 | srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); executed (the execution status of this line is deduced): srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); | - |
| 1128 | destImage = QImage(srcImage.size(), srcImage.format()); executed (the execution status of this line is deduced): destImage = QImage(srcImage.size(), srcImage.format()); | - |
| 1129 | } else { executed: }Execution Count:3 | 3 |
| 1130 | QRect rect = srcRect.toAlignedRect().intersected(src.rect()); executed (the execution status of this line is deduced): QRect rect = srcRect.toAlignedRect().intersected(src.rect()); | - |
| 1131 | | - |
| 1132 | srcImage = src.copy(rect).toImage(); executed (the execution status of this line is deduced): srcImage = src.copy(rect).toImage(); | - |
| 1133 | srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); executed (the execution status of this line is deduced): srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); | - |
| 1134 | destImage = QImage(rect.size(), srcImage.format()); executed (the execution status of this line is deduced): destImage = QImage(rect.size(), srcImage.format()); | - |
| 1135 | } executed: }Execution Count:2 | 2 |
| 1136 | | - |
| 1137 | // do colorizing | - |
| 1138 | QPainter destPainter(&destImage); executed (the execution status of this line is deduced): QPainter destPainter(&destImage); | - |
| 1139 | grayscale(srcImage, destImage, srcImage.rect()); executed (the execution status of this line is deduced): grayscale(srcImage, destImage, srcImage.rect()); | - |
| 1140 | destPainter.setCompositionMode(QPainter::CompositionMode_Screen); executed (the execution status of this line is deduced): destPainter.setCompositionMode(QPainter::CompositionMode_Screen); | - |
| 1141 | destPainter.fillRect(srcImage.rect(), d->color); executed (the execution status of this line is deduced): destPainter.fillRect(srcImage.rect(), d->color); | - |
| 1142 | destPainter.end(); executed (the execution status of this line is deduced): destPainter.end(); | - |
| 1143 | | - |
| 1144 | if (d->alphaBlend) { evaluated: d->alphaBlend| yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
| 1145 | // alpha blending srcImage and destImage | - |
| 1146 | QImage buffer = srcImage; executed (the execution status of this line is deduced): QImage buffer = srcImage; | - |
| 1147 | QPainter bufPainter(&buffer); executed (the execution status of this line is deduced): QPainter bufPainter(&buffer); | - |
| 1148 | bufPainter.setOpacity(d->strength); executed (the execution status of this line is deduced): bufPainter.setOpacity(d->strength); | - |
| 1149 | bufPainter.drawImage(0, 0, destImage); executed (the execution status of this line is deduced): bufPainter.drawImage(0, 0, destImage); | - |
| 1150 | bufPainter.end(); executed (the execution status of this line is deduced): bufPainter.end(); | - |
| 1151 | destImage = buffer; executed (the execution status of this line is deduced): destImage = buffer; | - |
| 1152 | } executed: }Execution Count:1 | 1 |
| 1153 | | - |
| 1154 | if (srcImage.hasAlphaChannel()) partially evaluated: srcImage.hasAlphaChannel()| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 1155 | destImage.setAlphaChannel(srcImage.alphaChannel()); never executed: destImage.setAlphaChannel(srcImage.alphaChannel()); | 0 |
| 1156 | | - |
| 1157 | painter->drawImage(dest, destImage); executed (the execution status of this line is deduced): painter->drawImage(dest, destImage); | - |
| 1158 | } executed: }Execution Count:5 | 5 |
| 1159 | | - |
| 1160 | class QPixmapDropShadowFilterPrivate : public QPixmapFilterPrivate | - |
| 1161 | { | - |
| 1162 | public: | - |
| 1163 | QPixmapDropShadowFilterPrivate() | - |
| 1164 | : offset(8, 8), color(63, 63, 63, 180), radius(1) {} executed: }Execution Count:5 | 5 |
| 1165 | | - |
| 1166 | QPointF offset; | - |
| 1167 | QColor color; | - |
| 1168 | qreal radius; | - |
| 1169 | }; | - |
| 1170 | | - |
| 1171 | /*! | - |
| 1172 | \class QPixmapDropShadowFilter | - |
| 1173 | \since 4.5 | - |
| 1174 | \ingroup painting | - |
| 1175 | | - |
| 1176 | \brief The QPixmapDropShadowFilter class is a convenience class | - |
| 1177 | for drawing pixmaps with drop shadows. | - |
| 1178 | | - |
| 1179 | The drop shadow is produced by taking a copy of the source pixmap | - |
| 1180 | and applying a color to the copy using a | - |
| 1181 | QPainter::CompositionMode_DestinationIn operation. This produces a | - |
| 1182 | homogeneously-colored pixmap which is then drawn using a | - |
| 1183 | QPixmapConvolutionFilter at an offset. The original pixmap is | - |
| 1184 | drawn on top. | - |
| 1185 | | - |
| 1186 | The QPixmapDropShadowFilter class provides some customization | - |
| 1187 | options to specify how the drop shadow should appear. The color of | - |
| 1188 | the drop shadow can be modified using the setColor() function, the | - |
| 1189 | drop shadow offset can be modified using the setOffset() function, | - |
| 1190 | and the blur radius of the drop shadow can be changed through the | - |
| 1191 | setBlurRadius() function. | - |
| 1192 | | - |
| 1193 | By default, the drop shadow is a dark gray shadow, blurred with a | - |
| 1194 | radius of 1 at an offset of 8 pixels towards the lower right. | - |
| 1195 | | - |
| 1196 | Example: | - |
| 1197 | \snippet code/src_gui_image_qpixmapfilter.cpp 2 | - |
| 1198 | | - |
| 1199 | \sa QPixmapColorizeFilter, QPixmapConvolutionFilter | - |
| 1200 | | - |
| 1201 | \internal | - |
| 1202 | */ | - |
| 1203 | | - |
| 1204 | /*! | - |
| 1205 | Constructs drop shadow filter. | - |
| 1206 | | - |
| 1207 | \internal | - |
| 1208 | */ | - |
| 1209 | QPixmapDropShadowFilter::QPixmapDropShadowFilter(QObject *parent) | - |
| 1210 | : QPixmapFilter(*new QPixmapDropShadowFilterPrivate, DropShadowFilter, parent) | - |
| 1211 | { | - |
| 1212 | } executed: }Execution Count:5 | 5 |
| 1213 | | - |
| 1214 | /*! | - |
| 1215 | Destroys drop shadow filter. | - |
| 1216 | | - |
| 1217 | \internal | - |
| 1218 | */ | - |
| 1219 | QPixmapDropShadowFilter::~QPixmapDropShadowFilter() | - |
| 1220 | { | - |
| 1221 | } | - |
| 1222 | | - |
| 1223 | /*! | - |
| 1224 | Returns the radius in pixels of the blur on the drop shadow. | - |
| 1225 | | - |
| 1226 | A smaller radius results in a sharper shadow. | - |
| 1227 | | - |
| 1228 | \sa color(), offset() | - |
| 1229 | | - |
| 1230 | \internal | - |
| 1231 | */ | - |
| 1232 | qreal QPixmapDropShadowFilter::blurRadius() const | - |
| 1233 | { | - |
| 1234 | Q_D(const QPixmapDropShadowFilter); executed (the execution status of this line is deduced): const QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
| 1235 | return d->radius; executed: return d->radius;Execution Count:8 | 8 |
| 1236 | } | - |
| 1237 | | - |
| 1238 | /*! | - |
| 1239 | Sets the radius in pixels of the blur on the drop shadow to the \a radius specified. | - |
| 1240 | | - |
| 1241 | Using a smaller radius results in a sharper shadow. | - |
| 1242 | | - |
| 1243 | \sa setColor(), setOffset() | - |
| 1244 | | - |
| 1245 | \internal | - |
| 1246 | */ | - |
| 1247 | void QPixmapDropShadowFilter::setBlurRadius(qreal radius) | - |
| 1248 | { | - |
| 1249 | Q_D(QPixmapDropShadowFilter); executed (the execution status of this line is deduced): QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
| 1250 | d->radius = radius; executed (the execution status of this line is deduced): d->radius = radius; | - |
| 1251 | } executed: }Execution Count:2 | 2 |
| 1252 | | - |
| 1253 | /*! | - |
| 1254 | Returns the color of the drop shadow. | - |
| 1255 | | - |
| 1256 | \sa blurRadius(), offset() | - |
| 1257 | | - |
| 1258 | \internal | - |
| 1259 | */ | - |
| 1260 | QColor QPixmapDropShadowFilter::color() const | - |
| 1261 | { | - |
| 1262 | Q_D(const QPixmapDropShadowFilter); never executed (the execution status of this line is deduced): const QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
| 1263 | return d->color; never executed: return d->color; | 0 |
| 1264 | } | - |
| 1265 | | - |
| 1266 | /*! | - |
| 1267 | Sets the color of the drop shadow to the \a color specified. | - |
| 1268 | | - |
| 1269 | \sa setBlurRadius(), setOffset() | - |
| 1270 | | - |
| 1271 | \internal | - |
| 1272 | */ | - |
| 1273 | void QPixmapDropShadowFilter::setColor(const QColor &color) | - |
| 1274 | { | - |
| 1275 | Q_D(QPixmapDropShadowFilter); never executed (the execution status of this line is deduced): QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
| 1276 | d->color = color; never executed (the execution status of this line is deduced): d->color = color; | - |
| 1277 | } | 0 |
| 1278 | | - |
| 1279 | /*! | - |
| 1280 | Returns the shadow offset in pixels. | - |
| 1281 | | - |
| 1282 | \sa blurRadius(), color() | - |
| 1283 | | - |
| 1284 | \internal | - |
| 1285 | */ | - |
| 1286 | QPointF QPixmapDropShadowFilter::offset() const | - |
| 1287 | { | - |
| 1288 | Q_D(const QPixmapDropShadowFilter); executed (the execution status of this line is deduced): const QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
| 1289 | return d->offset; executed: return d->offset;Execution Count:1 | 1 |
| 1290 | } | - |
| 1291 | | - |
| 1292 | /*! | - |
| 1293 | Sets the shadow offset in pixels to the \a offset specified. | - |
| 1294 | | - |
| 1295 | \sa setBlurRadius(), setColor() | - |
| 1296 | | - |
| 1297 | \internal | - |
| 1298 | */ | - |
| 1299 | void QPixmapDropShadowFilter::setOffset(const QPointF &offset) | - |
| 1300 | { | - |
| 1301 | Q_D(QPixmapDropShadowFilter); executed (the execution status of this line is deduced): QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
| 1302 | d->offset = offset; executed (the execution status of this line is deduced): d->offset = offset; | - |
| 1303 | } executed: }Execution Count:6 | 6 |
| 1304 | | - |
| 1305 | /*! | - |
| 1306 | \fn void QPixmapDropShadowFilter::setOffset(qreal dx, qreal dy) | - |
| 1307 | \overload | - |
| 1308 | | - |
| 1309 | Sets the shadow offset in pixels to be the displacement specified by the | - |
| 1310 | horizontal \a dx and vertical \a dy coordinates. | - |
| 1311 | | - |
| 1312 | \sa setBlurRadius(), setColor() | - |
| 1313 | | - |
| 1314 | \internal | - |
| 1315 | */ | - |
| 1316 | | - |
| 1317 | /*! | - |
| 1318 | \internal | - |
| 1319 | */ | - |
| 1320 | QRectF QPixmapDropShadowFilter::boundingRectFor(const QRectF &rect) const | - |
| 1321 | { | - |
| 1322 | Q_D(const QPixmapDropShadowFilter); executed (the execution status of this line is deduced): const QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
| 1323 | 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 |
| 1324 | } | - |
| 1325 | | - |
| 1326 | /*! | - |
| 1327 | \internal | - |
| 1328 | */ | - |
| 1329 | void QPixmapDropShadowFilter::draw(QPainter *p, | - |
| 1330 | const QPointF &pos, | - |
| 1331 | const QPixmap &px, | - |
| 1332 | const QRectF &src) const | - |
| 1333 | { | - |
| 1334 | Q_D(const QPixmapDropShadowFilter); executed (the execution status of this line is deduced): const QPixmapDropShadowFilterPrivate * const d = d_func(); | - |
| 1335 | | - |
| 1336 | if (px.isNull()) partially evaluated: px.isNull()| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 1337 | return; | 0 |
| 1338 | | - |
| 1339 | 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 |
| 1340 | static_cast<QPaintEngineEx *>(p->paintEngine())->pixmapFilter(type(), this) : 0; executed (the execution status of this line is deduced): static_cast<QPaintEngineEx *>(p->paintEngine())->pixmapFilter(type(), this) : 0; | - |
| 1341 | QPixmapDropShadowFilter *dropShadowFilter = static_cast<QPixmapDropShadowFilter*>(filter); executed (the execution status of this line is deduced): QPixmapDropShadowFilter *dropShadowFilter = static_cast<QPixmapDropShadowFilter*>(filter); | - |
| 1342 | if (dropShadowFilter) { partially evaluated: dropShadowFilter| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 1343 | dropShadowFilter->setColor(d->color); never executed (the execution status of this line is deduced): dropShadowFilter->setColor(d->color); | - |
| 1344 | dropShadowFilter->setBlurRadius(d->radius); never executed (the execution status of this line is deduced): dropShadowFilter->setBlurRadius(d->radius); | - |
| 1345 | dropShadowFilter->setOffset(d->offset); never executed (the execution status of this line is deduced): dropShadowFilter->setOffset(d->offset); | - |
| 1346 | dropShadowFilter->draw(p, pos, px, src); never executed (the execution status of this line is deduced): dropShadowFilter->draw(p, pos, px, src); | - |
| 1347 | return; | 0 |
| 1348 | } | - |
| 1349 | | - |
| 1350 | QImage tmp(px.size(), QImage::Format_ARGB32_Premultiplied); executed (the execution status of this line is deduced): QImage tmp(px.size(), QImage::Format_ARGB32_Premultiplied); | - |
| 1351 | tmp.fill(0); executed (the execution status of this line is deduced): tmp.fill(0); | - |
| 1352 | QPainter tmpPainter(&tmp); executed (the execution status of this line is deduced): QPainter tmpPainter(&tmp); | - |
| 1353 | tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); executed (the execution status of this line is deduced): tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); | - |
| 1354 | tmpPainter.drawPixmap(d->offset, px); executed (the execution status of this line is deduced): tmpPainter.drawPixmap(d->offset, px); | - |
| 1355 | tmpPainter.end(); executed (the execution status of this line is deduced): tmpPainter.end(); | - |
| 1356 | | - |
| 1357 | // blur the alpha channel | - |
| 1358 | QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied); executed (the execution status of this line is deduced): QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied); | - |
| 1359 | blurred.fill(0); executed (the execution status of this line is deduced): blurred.fill(0); | - |
| 1360 | QPainter blurPainter(&blurred); executed (the execution status of this line is deduced): QPainter blurPainter(&blurred); | - |
| 1361 | qt_blurImage(&blurPainter, tmp, d->radius, false, true); executed (the execution status of this line is deduced): qt_blurImage(&blurPainter, tmp, d->radius, false, true); | - |
| 1362 | blurPainter.end(); executed (the execution status of this line is deduced): blurPainter.end(); | - |
| 1363 | | - |
| 1364 | tmp = blurred; executed (the execution status of this line is deduced): tmp = blurred; | - |
| 1365 | | - |
| 1366 | // blacken the image... | - |
| 1367 | tmpPainter.begin(&tmp); executed (the execution status of this line is deduced): tmpPainter.begin(&tmp); | - |
| 1368 | tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); executed (the execution status of this line is deduced): tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); | - |
| 1369 | tmpPainter.fillRect(tmp.rect(), d->color); executed (the execution status of this line is deduced): tmpPainter.fillRect(tmp.rect(), d->color); | - |
| 1370 | tmpPainter.end(); executed (the execution status of this line is deduced): tmpPainter.end(); | - |
| 1371 | | - |
| 1372 | // draw the blurred drop shadow... | - |
| 1373 | p->drawImage(pos, tmp); executed (the execution status of this line is deduced): p->drawImage(pos, tmp); | - |
| 1374 | | - |
| 1375 | // Draw the actual pixmap... | - |
| 1376 | p->drawPixmap(pos, px, src); executed (the execution status of this line is deduced): p->drawPixmap(pos, px, src); | - |
| 1377 | } executed: }Execution Count:7 | 7 |
| 1378 | | - |
| 1379 | QT_END_NAMESPACE | - |
| 1380 | | - |
| 1381 | #endif //QT_NO_GRAPHICSEFFECT | - |
| 1382 | | - |
| | |