| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | QSGSoftwareInternalRectangleNode::QSGSoftwareInternalRectangleNode() | - | ||||||||||||
| 6 | : m_penWidth(0) | - | ||||||||||||
| 7 | , m_radius(0) | - | ||||||||||||
| 8 | , m_vertical(true) | - | ||||||||||||
| 9 | , m_cornerPixmapIsDirty(true) | - | ||||||||||||
| 10 | , m_devicePixelRatio(1) | - | ||||||||||||
| 11 | { | - | ||||||||||||
| 12 | m_pen.setJoinStyle(Qt::MiterJoin); | - | ||||||||||||
| 13 | m_pen.setMiterLimit(0); | - | ||||||||||||
| 14 | setMaterial((QSGMaterial*)1); | - | ||||||||||||
| 15 | setGeometry((QSGGeometry*)1); | - | ||||||||||||
| 16 | } never executed: end of block | 0 | ||||||||||||
| 17 | - | |||||||||||||
| 18 | void QSGSoftwareInternalRectangleNode::setRect(const QRectF &rect) | - | ||||||||||||
| 19 | { | - | ||||||||||||
| 20 | QRect alignedRect = rect.toAlignedRect(); | - | ||||||||||||
| 21 | if (m_rect != alignedRect
| 0 | ||||||||||||
| 22 | m_rect = alignedRect; | - | ||||||||||||
| 23 | markDirty(DirtyMaterial); | - | ||||||||||||
| 24 | } never executed: end of block | 0 | ||||||||||||
| 25 | } never executed: end of block | 0 | ||||||||||||
| 26 | - | |||||||||||||
| 27 | void QSGSoftwareInternalRectangleNode::setColor(const QColor &color) | - | ||||||||||||
| 28 | { | - | ||||||||||||
| 29 | if (m_color != color
| 0 | ||||||||||||
| 30 | m_color = color; | - | ||||||||||||
| 31 | m_cornerPixmapIsDirty = true; | - | ||||||||||||
| 32 | markDirty(DirtyMaterial); | - | ||||||||||||
| 33 | } never executed: end of block | 0 | ||||||||||||
| 34 | } never executed: end of block | 0 | ||||||||||||
| 35 | - | |||||||||||||
| 36 | void QSGSoftwareInternalRectangleNode::setPenColor(const QColor &color) | - | ||||||||||||
| 37 | { | - | ||||||||||||
| 38 | if (m_penColor != color
| 0 | ||||||||||||
| 39 | m_penColor = color; | - | ||||||||||||
| 40 | m_cornerPixmapIsDirty = true; | - | ||||||||||||
| 41 | markDirty(DirtyMaterial); | - | ||||||||||||
| 42 | } never executed: end of block | 0 | ||||||||||||
| 43 | } never executed: end of block | 0 | ||||||||||||
| 44 | - | |||||||||||||
| 45 | void QSGSoftwareInternalRectangleNode::setPenWidth(qreal width) | - | ||||||||||||
| 46 | { | - | ||||||||||||
| 47 | if (m_penWidth != width
| 0 | ||||||||||||
| 48 | m_penWidth = width; | - | ||||||||||||
| 49 | m_cornerPixmapIsDirty = true; | - | ||||||||||||
| 50 | markDirty(DirtyMaterial); | - | ||||||||||||
| 51 | } never executed: end of block | 0 | ||||||||||||
| 52 | } never executed: end of block | 0 | ||||||||||||
| 53 | - | |||||||||||||
| 54 | - | |||||||||||||
| 55 | static QGradientStop interpolateStop(const QGradientStop &firstStop, const QGradientStop &secondStop, double newPos) | - | ||||||||||||
| 56 | { | - | ||||||||||||
| 57 | double distance = secondStop.first - firstStop.first; | - | ||||||||||||
| 58 | double distanceDelta = newPos - firstStop.first; | - | ||||||||||||
| 59 | double modifierValue = distanceDelta / distance; | - | ||||||||||||
| 60 | int redDelta = (secondStop.second.red() - firstStop.second.red()) * modifierValue; | - | ||||||||||||
| 61 | int greenDelta = (secondStop.second.green() - firstStop.second.green()) * modifierValue; | - | ||||||||||||
| 62 | int blueDelta = (secondStop.second.blue() - firstStop.second.blue()) * modifierValue; | - | ||||||||||||
| 63 | int alphaDelta = (secondStop.second.alpha() - firstStop.second.alpha()) * modifierValue; | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | QGradientStop newStop; | - | ||||||||||||
| 66 | newStop.first = newPos; | - | ||||||||||||
| 67 | newStop.second = QColor(firstStop.second.red() + redDelta, | - | ||||||||||||
| 68 | firstStop.second.green() + greenDelta, | - | ||||||||||||
| 69 | firstStop.second.blue() + blueDelta, | - | ||||||||||||
| 70 | firstStop.second.alpha() + alphaDelta); | - | ||||||||||||
| 71 | - | |||||||||||||
| 72 | return never executed: newStop;return newStop;never executed: return newStop; | 0 | ||||||||||||
| 73 | } | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | void QSGSoftwareInternalRectangleNode::setGradientStops(const QGradientStops &stops) | - | ||||||||||||
| 76 | { | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | bool needsNormalization = false; | - | ||||||||||||
| 79 | for (const QGradientStop &stop : qAsConst(stops)) { | - | ||||||||||||
| 80 | if (stop.first < 0.0
| 0 | ||||||||||||
| 81 | needsNormalization = true; | - | ||||||||||||
| 82 | continue; never executed: continue; | 0 | ||||||||||||
| 83 | } | - | ||||||||||||
| 84 | } never executed: end of block | 0 | ||||||||||||
| 85 | - | |||||||||||||
| 86 | if (needsNormalization
| 0 | ||||||||||||
| 87 | QGradientStops normalizedStops; | - | ||||||||||||
| 88 | if (stops.count() == 1
| 0 | ||||||||||||
| 89 | - | |||||||||||||
| 90 | - | |||||||||||||
| 91 | QGradientStop stop = stops.at(0); | - | ||||||||||||
| 92 | stop.first = 0.0; | - | ||||||||||||
| 93 | normalizedStops.append(stop); | - | ||||||||||||
| 94 | } never executed: else {end of block | 0 | ||||||||||||
| 95 | - | |||||||||||||
| 96 | int below = -1; | - | ||||||||||||
| 97 | int above = -1; | - | ||||||||||||
| 98 | QVector<int> between; | - | ||||||||||||
| 99 | for (int i = 0; i < stops.count()
| 0 | ||||||||||||
| 100 | if (stops.at(i).first < 0.0
| 0 | ||||||||||||
| 101 | below = i; | - | ||||||||||||
| 102 | } never executed: else if (stops.at(i).first > 1.0end of block
| 0 | ||||||||||||
| 103 | above = i; | - | ||||||||||||
| 104 | break; never executed: break; | 0 | ||||||||||||
| 105 | } else { | - | ||||||||||||
| 106 | between.append(i); | - | ||||||||||||
| 107 | } never executed: end of block | 0 | ||||||||||||
| 108 | } | - | ||||||||||||
| 109 | - | |||||||||||||
| 110 | - | |||||||||||||
| 111 | if (below != -1
| 0 | ||||||||||||
| 112 | - | |||||||||||||
| 113 | if (below + 1 < stops.count()
| 0 | ||||||||||||
| 114 | normalizedStops.append(interpolateStop(stops.at(below), stops.at(below + 1), 0.0)); | - | ||||||||||||
| 115 | } never executed: else {end of block | 0 | ||||||||||||
| 116 | QGradientStop singleStop; | - | ||||||||||||
| 117 | singleStop.first = 0.0; | - | ||||||||||||
| 118 | singleStop.second = stops.at(below).second; | - | ||||||||||||
| 119 | normalizedStops.append(singleStop); | - | ||||||||||||
| 120 | } never executed: end of block | 0 | ||||||||||||
| 121 | } | - | ||||||||||||
| 122 | - | |||||||||||||
| 123 | for (int i = 0; i < between.count()
| 0 | ||||||||||||
| 124 | normalizedStops.append(stops.at(between.at(i))); never executed: normalizedStops.append(stops.at(between.at(i))); | 0 | ||||||||||||
| 125 | - | |||||||||||||
| 126 | if (above != -1
| 0 | ||||||||||||
| 127 | - | |||||||||||||
| 128 | if (above >= 1
| 0 | ||||||||||||
| 129 | normalizedStops.append(interpolateStop(stops.at(above), stops.at(above - 1), 1.0)); | - | ||||||||||||
| 130 | } never executed: else {end of block | 0 | ||||||||||||
| 131 | QGradientStop singleStop; | - | ||||||||||||
| 132 | singleStop.first = 1.0; | - | ||||||||||||
| 133 | singleStop.second = stops.at(above).second; | - | ||||||||||||
| 134 | normalizedStops.append(singleStop); | - | ||||||||||||
| 135 | } never executed: end of block | 0 | ||||||||||||
| 136 | } | - | ||||||||||||
| 137 | } never executed: end of block | 0 | ||||||||||||
| 138 | - | |||||||||||||
| 139 | m_stops = normalizedStops; | - | ||||||||||||
| 140 | - | |||||||||||||
| 141 | } never executed: else {end of block | 0 | ||||||||||||
| 142 | m_stops = stops; | - | ||||||||||||
| 143 | } never executed: end of block | 0 | ||||||||||||
| 144 | m_cornerPixmapIsDirty = true; | - | ||||||||||||
| 145 | markDirty(DirtyMaterial); | - | ||||||||||||
| 146 | } never executed: end of block | 0 | ||||||||||||
| 147 | - | |||||||||||||
| 148 | void QSGSoftwareInternalRectangleNode::setGradientVertical(bool vertical) | - | ||||||||||||
| 149 | { | - | ||||||||||||
| 150 | if (m_vertical != vertical
| 0 | ||||||||||||
| 151 | m_vertical = vertical; | - | ||||||||||||
| 152 | m_cornerPixmapIsDirty = true; | - | ||||||||||||
| 153 | markDirty(DirtyMaterial); | - | ||||||||||||
| 154 | } never executed: end of block | 0 | ||||||||||||
| 155 | } never executed: end of block | 0 | ||||||||||||
| 156 | - | |||||||||||||
| 157 | void QSGSoftwareInternalRectangleNode::setRadius(qreal radius) | - | ||||||||||||
| 158 | { | - | ||||||||||||
| 159 | if (m_radius != radius
| 0 | ||||||||||||
| 160 | m_radius = radius; | - | ||||||||||||
| 161 | m_cornerPixmapIsDirty = true; | - | ||||||||||||
| 162 | markDirty(DirtyMaterial); | - | ||||||||||||
| 163 | } never executed: end of block | 0 | ||||||||||||
| 164 | } never executed: end of block | 0 | ||||||||||||
| 165 | - | |||||||||||||
| 166 | void QSGSoftwareInternalRectangleNode::setAligned(bool ) | - | ||||||||||||
| 167 | { | - | ||||||||||||
| 168 | } | - | ||||||||||||
| 169 | - | |||||||||||||
| 170 | void QSGSoftwareInternalRectangleNode::update() | - | ||||||||||||
| 171 | { | - | ||||||||||||
| 172 | if (!m_penWidth
| 0 | ||||||||||||
| 173 | m_pen = Qt::NoPen; | - | ||||||||||||
| 174 | } never executed: else {end of block | 0 | ||||||||||||
| 175 | m_pen = QPen(m_penColor); | - | ||||||||||||
| 176 | m_pen.setWidthF(m_penWidth); | - | ||||||||||||
| 177 | } never executed: end of block | 0 | ||||||||||||
| 178 | - | |||||||||||||
| 179 | if (!m_stops.isEmpty()
| 0 | ||||||||||||
| 180 | QLinearGradient gradient(QPoint(0,0), QPoint(m_vertical ? 0 : 1, m_vertical ? 1 : 0)); | - | ||||||||||||
| 181 | gradient.setStops(m_stops); | - | ||||||||||||
| 182 | gradient.setCoordinateMode(QGradient::ObjectBoundingMode); | - | ||||||||||||
| 183 | m_brush = QBrush(gradient); | - | ||||||||||||
| 184 | } never executed: else {end of block | 0 | ||||||||||||
| 185 | m_brush = QBrush(m_color); | - | ||||||||||||
| 186 | } never executed: end of block | 0 | ||||||||||||
| 187 | - | |||||||||||||
| 188 | if (m_cornerPixmapIsDirty
| 0 | ||||||||||||
| 189 | generateCornerPixmap(); | - | ||||||||||||
| 190 | m_cornerPixmapIsDirty = false; | - | ||||||||||||
| 191 | } never executed: end of block | 0 | ||||||||||||
| 192 | } never executed: end of block | 0 | ||||||||||||
| 193 | - | |||||||||||||
| 194 | void QSGSoftwareInternalRectangleNode::paint(QPainter *painter) | - | ||||||||||||
| 195 | { | - | ||||||||||||
| 196 | - | |||||||||||||
| 197 | - | |||||||||||||
| 198 | if (!qFuzzyCompare(painter->device()->devicePixelRatioF(), m_devicePixelRatio)
| 0 | ||||||||||||
| 199 | m_devicePixelRatio = painter->device()->devicePixelRatioF(); | - | ||||||||||||
| 200 | generateCornerPixmap(); | - | ||||||||||||
| 201 | } never executed: end of block | 0 | ||||||||||||
| 202 | - | |||||||||||||
| 203 | if (painter->transform().isRotating()
| 0 | ||||||||||||
| 204 | - | |||||||||||||
| 205 | - | |||||||||||||
| 206 | - | |||||||||||||
| 207 | if (m_radius == 0
| 0 | ||||||||||||
| 208 | - | |||||||||||||
| 209 | - | |||||||||||||
| 210 | painter->setPen(Qt::NoPen); | - | ||||||||||||
| 211 | painter->setBrush(m_brush); | - | ||||||||||||
| 212 | painter->drawRect(m_rect); | - | ||||||||||||
| 213 | } never executed: else {end of block | 0 | ||||||||||||
| 214 | - | |||||||||||||
| 215 | - | |||||||||||||
| 216 | QPixmap pixmap = QPixmap(qRound(m_rect.width() * m_devicePixelRatio), qRound(m_rect.height() * m_devicePixelRatio)); | - | ||||||||||||
| 217 | pixmap.fill(Qt::transparent); | - | ||||||||||||
| 218 | pixmap.setDevicePixelRatio(m_devicePixelRatio); | - | ||||||||||||
| 219 | QPainter pixmapPainter(&pixmap); | - | ||||||||||||
| 220 | paintRectangle(&pixmapPainter, QRect(0, 0, m_rect.width(), m_rect.height())); | - | ||||||||||||
| 221 | - | |||||||||||||
| 222 | QPainter::RenderHints previousRenderHints = painter->renderHints(); | - | ||||||||||||
| 223 | painter->setRenderHint(QPainter::SmoothPixmapTransform, true); | - | ||||||||||||
| 224 | painter->drawPixmap(m_rect, pixmap); | - | ||||||||||||
| 225 | painter->setRenderHints(previousRenderHints); | - | ||||||||||||
| 226 | } never executed: end of block | 0 | ||||||||||||
| 227 | - | |||||||||||||
| 228 | - | |||||||||||||
| 229 | } else { | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | paintRectangle(painter, m_rect); | - | ||||||||||||
| 232 | } never executed: end of block | 0 | ||||||||||||
| 233 | - | |||||||||||||
| 234 | } | - | ||||||||||||
| 235 | - | |||||||||||||
| 236 | bool QSGSoftwareInternalRectangleNode::isOpaque() const | - | ||||||||||||
| 237 | { | - | ||||||||||||
| 238 | if (m_radius > 0.0f
| 0 | ||||||||||||
| 239 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 240 | if (m_color.alpha() < 255
| 0 | ||||||||||||
| 241 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 242 | if (m_penWidth > 0.0f
| 0 | ||||||||||||
| 243 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 244 | if (m_stops.count() > 0
| 0 | ||||||||||||
| 245 | for (const QGradientStop &stop : qAsConst(m_stops)) { | - | ||||||||||||
| 246 | if (stop.second.alpha() < 255
| 0 | ||||||||||||
| 247 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 248 | } never executed: end of block | 0 | ||||||||||||
| 249 | } never executed: end of block | 0 | ||||||||||||
| 250 | - | |||||||||||||
| 251 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 252 | } | - | ||||||||||||
| 253 | - | |||||||||||||
| 254 | QRectF QSGSoftwareInternalRectangleNode::rect() const | - | ||||||||||||
| 255 | { | - | ||||||||||||
| 256 | - | |||||||||||||
| 257 | return never executed: m_rect;return m_rect;never executed: return m_rect; | 0 | ||||||||||||
| 258 | } | - | ||||||||||||
| 259 | - | |||||||||||||
| 260 | void QSGSoftwareInternalRectangleNode::paintRectangle(QPainter *painter, const QRect &rect) | - | ||||||||||||
| 261 | { | - | ||||||||||||
| 262 | - | |||||||||||||
| 263 | int radius = qFloor(qMin(qMin(rect.width(), rect.height()) * 0.5, m_radius)); | - | ||||||||||||
| 264 | - | |||||||||||||
| 265 | QPainter::RenderHints previousRenderHints = painter->renderHints(); | - | ||||||||||||
| 266 | painter->setRenderHint(QPainter::Antialiasing, false); | - | ||||||||||||
| 267 | - | |||||||||||||
| 268 | if (m_penWidth > 0
| 0 | ||||||||||||
| 269 | - | |||||||||||||
| 270 | - | |||||||||||||
| 271 | - | |||||||||||||
| 272 | double borderWidth = qMin(m_penWidth, rect.width() * 0.5); | - | ||||||||||||
| 273 | double borderHeight = qMin(m_penWidth, rect.height() * 0.5); | - | ||||||||||||
| 274 | - | |||||||||||||
| 275 | - | |||||||||||||
| 276 | - | |||||||||||||
| 277 | if (borderWidth > radius
| 0 | ||||||||||||
| 278 | - | |||||||||||||
| 279 | QRectF borderTopOutside(QPointF(rect.x() + radius, rect.y()), | - | ||||||||||||
| 280 | QPointF(rect.x() + rect.width() - radius, rect.y() + radius)); | - | ||||||||||||
| 281 | QRectF borderTopInside(QPointF(rect.x() + borderWidth, rect.y() + radius), | - | ||||||||||||
| 282 | QPointF(rect.x() + rect.width() - borderWidth, rect.y() + borderHeight)); | - | ||||||||||||
| 283 | QRectF borderBottomOutside(QPointF(rect.x() + radius, rect.y() + rect.height() - radius), | - | ||||||||||||
| 284 | QPointF(rect.x() + rect.width() - radius, rect.y() + rect.height())); | - | ||||||||||||
| 285 | QRectF borderBottomInside(QPointF(rect.x() + borderWidth, rect.y() + rect.height() - borderHeight), | - | ||||||||||||
| 286 | QPointF(rect.x() + rect.width() - borderWidth, rect.y() + rect.height() - radius)); | - | ||||||||||||
| 287 | - | |||||||||||||
| 288 | if (borderTopOutside.isValid()
| 0 | ||||||||||||
| 289 | painter->fillRect(borderTopOutside, m_penColor); never executed: painter->fillRect(borderTopOutside, m_penColor); | 0 | ||||||||||||
| 290 | if (borderTopInside.isValid()
| 0 | ||||||||||||
| 291 | painter->fillRect(borderTopInside, m_penColor); never executed: painter->fillRect(borderTopInside, m_penColor); | 0 | ||||||||||||
| 292 | if (borderBottomOutside.isValid()
| 0 | ||||||||||||
| 293 | painter->fillRect(borderBottomOutside, m_penColor); never executed: painter->fillRect(borderBottomOutside, m_penColor); | 0 | ||||||||||||
| 294 | if (borderBottomInside.isValid()
| 0 | ||||||||||||
| 295 | painter->fillRect(borderBottomInside, m_penColor); never executed: painter->fillRect(borderBottomInside, m_penColor); | 0 | ||||||||||||
| 296 | - | |||||||||||||
| 297 | } never executed: else {end of block | 0 | ||||||||||||
| 298 | - | |||||||||||||
| 299 | QRectF borderTop(QPointF(rect.x() + radius, rect.y()), | - | ||||||||||||
| 300 | QPointF(rect.x() + rect.width() - radius, rect.y() + borderHeight)); | - | ||||||||||||
| 301 | QRectF borderBottom(QPointF(rect.x() + radius, rect.y() + rect.height() - borderHeight), | - | ||||||||||||
| 302 | QPointF(rect.x() + rect.width() - radius, rect.y() + rect.height())); | - | ||||||||||||
| 303 | if (borderTop.isValid()
| 0 | ||||||||||||
| 304 | painter->fillRect(borderTop, m_penColor); never executed: painter->fillRect(borderTop, m_penColor); | 0 | ||||||||||||
| 305 | if (borderBottom.isValid()
| 0 | ||||||||||||
| 306 | painter->fillRect(borderBottom, m_penColor); never executed: painter->fillRect(borderBottom, m_penColor); | 0 | ||||||||||||
| 307 | } never executed: end of block | 0 | ||||||||||||
| 308 | QRectF borderLeft(QPointF(rect.x(), rect.y() + radius), | - | ||||||||||||
| 309 | QPointF(rect.x() + borderWidth, rect.y() + rect.height() - radius)); | - | ||||||||||||
| 310 | QRectF borderRight(QPointF(rect.x() + rect.width() - borderWidth, rect.y() + radius), | - | ||||||||||||
| 311 | QPointF(rect.x() + rect.width(), rect.y() + rect.height() - radius)); | - | ||||||||||||
| 312 | if (borderLeft.isValid()
| 0 | ||||||||||||
| 313 | painter->fillRect(borderLeft, m_penColor); never executed: painter->fillRect(borderLeft, m_penColor); | 0 | ||||||||||||
| 314 | if (borderRight.isValid()
| 0 | ||||||||||||
| 315 | painter->fillRect(borderRight, m_penColor); never executed: painter->fillRect(borderRight, m_penColor); | 0 | ||||||||||||
| 316 | } never executed: end of block | 0 | ||||||||||||
| 317 | - | |||||||||||||
| 318 | - | |||||||||||||
| 319 | if (radius > 0
| 0 | ||||||||||||
| 320 | - | |||||||||||||
| 321 | if (radius * 2 >= rect.width()
| 0 | ||||||||||||
| 322 | - | |||||||||||||
| 323 | painter->drawPixmap(rect, m_cornerPixmap, m_cornerPixmap.rect()); | - | ||||||||||||
| 324 | } never executed: else {end of block | 0 | ||||||||||||
| 325 | - | |||||||||||||
| 326 | - | |||||||||||||
| 327 | int scaledRadius = qRound(radius * m_devicePixelRatio); | - | ||||||||||||
| 328 | QRectF topLeftCorner(QPointF(rect.x(), rect.y()), | - | ||||||||||||
| 329 | QPointF(rect.x() + radius, rect.y() + radius)); | - | ||||||||||||
| 330 | painter->drawPixmap(topLeftCorner, m_cornerPixmap, QRectF(0, 0, scaledRadius, scaledRadius)); | - | ||||||||||||
| 331 | QRectF topRightCorner(QPointF(rect.x() + rect.width() - radius, rect.y()), | - | ||||||||||||
| 332 | QPointF(rect.x() + rect.width(), rect.y() + radius)); | - | ||||||||||||
| 333 | painter->drawPixmap(topRightCorner, m_cornerPixmap, QRectF(scaledRadius, 0, scaledRadius, scaledRadius)); | - | ||||||||||||
| 334 | QRectF bottomLeftCorner(QPointF(rect.x(), rect.y() + rect.height() - radius), | - | ||||||||||||
| 335 | QPointF(rect.x() + radius, rect.y() + rect.height())); | - | ||||||||||||
| 336 | painter->drawPixmap(bottomLeftCorner, m_cornerPixmap, QRectF(0, scaledRadius, scaledRadius, scaledRadius)); | - | ||||||||||||
| 337 | QRectF bottomRightCorner(QPointF(rect.x() + rect.width() - radius, rect.y() + rect.height() - radius), | - | ||||||||||||
| 338 | QPointF(rect.x() + rect.width(), rect.y() + rect.height())); | - | ||||||||||||
| 339 | painter->drawPixmap(bottomRightCorner, m_cornerPixmap, QRectF(scaledRadius, scaledRadius, scaledRadius, scaledRadius)); | - | ||||||||||||
| 340 | - | |||||||||||||
| 341 | } never executed: end of block | 0 | ||||||||||||
| 342 | - | |||||||||||||
| 343 | } | - | ||||||||||||
| 344 | - | |||||||||||||
| 345 | QRectF brushRect = QRectF(rect).marginsRemoved(QMarginsF(m_penWidth, m_penWidth, m_penWidth, m_penWidth)); | - | ||||||||||||
| 346 | if (brushRect.width() < 0
| 0 | ||||||||||||
| 347 | brushRect.setWidth(0); never executed: brushRect.setWidth(0); | 0 | ||||||||||||
| 348 | if (brushRect.height() < 0
| 0 | ||||||||||||
| 349 | brushRect.setHeight(0); never executed: brushRect.setHeight(0); | 0 | ||||||||||||
| 350 | double innerRectRadius = qMax(0.0, radius - m_penWidth); | - | ||||||||||||
| 351 | - | |||||||||||||
| 352 | - | |||||||||||||
| 353 | if (m_color.alpha() > 0
| 0 | ||||||||||||
| 354 | if (innerRectRadius > 0
| 0 | ||||||||||||
| 355 | - | |||||||||||||
| 356 | if (m_stops.empty()
| 0 | ||||||||||||
| 357 | - | |||||||||||||
| 358 | QRectF centerRect(QPointF(brushRect.x() + innerRectRadius, brushRect.y()), | - | ||||||||||||
| 359 | QPointF(brushRect.x() + brushRect.width() - innerRectRadius, brushRect.y() + brushRect.height())); | - | ||||||||||||
| 360 | painter->fillRect(centerRect, m_color); | - | ||||||||||||
| 361 | QRectF leftRect(QPointF(brushRect.x(), brushRect.y() + innerRectRadius), | - | ||||||||||||
| 362 | QPointF(brushRect.x() + innerRectRadius, brushRect.y() + brushRect.height() - innerRectRadius)); | - | ||||||||||||
| 363 | painter->fillRect(leftRect, m_color); | - | ||||||||||||
| 364 | QRectF rightRect(QPointF(brushRect.x() + brushRect.width() - innerRectRadius, brushRect.y() + innerRectRadius), | - | ||||||||||||
| 365 | QPointF(brushRect.x() + brushRect.width(), brushRect.y() + brushRect.height() - innerRectRadius)); | - | ||||||||||||
| 366 | painter->fillRect(rightRect, m_color); | - | ||||||||||||
| 367 | } never executed: else {end of block | 0 | ||||||||||||
| 368 | - | |||||||||||||
| 369 | painter->setPen(Qt::NoPen); | - | ||||||||||||
| 370 | painter->setBrush(m_brush); | - | ||||||||||||
| 371 | painter->drawRoundedRect(brushRect, innerRectRadius, innerRectRadius); | - | ||||||||||||
| 372 | } never executed: end of block | 0 | ||||||||||||
| 373 | } else { | - | ||||||||||||
| 374 | - | |||||||||||||
| 375 | painter->fillRect(brushRect, m_brush); | - | ||||||||||||
| 376 | } never executed: end of block | 0 | ||||||||||||
| 377 | } | - | ||||||||||||
| 378 | - | |||||||||||||
| 379 | painter->setRenderHints(previousRenderHints); | - | ||||||||||||
| 380 | } never executed: end of block | 0 | ||||||||||||
| 381 | - | |||||||||||||
| 382 | void QSGSoftwareInternalRectangleNode::generateCornerPixmap() | - | ||||||||||||
| 383 | { | - | ||||||||||||
| 384 | - | |||||||||||||
| 385 | int radius = qFloor(qMin(qMin(m_rect.width(), m_rect.height()) * 0.5, m_radius)); | - | ||||||||||||
| 386 | - | |||||||||||||
| 387 | m_cornerPixmap = QPixmap(qRound(radius * 2 * m_devicePixelRatio), qRound(radius * 2 * m_devicePixelRatio)); | - | ||||||||||||
| 388 | m_cornerPixmap.setDevicePixelRatio(m_devicePixelRatio); | - | ||||||||||||
| 389 | m_cornerPixmap.fill(Qt::transparent); | - | ||||||||||||
| 390 | - | |||||||||||||
| 391 | if (radius > 0
| 0 | ||||||||||||
| 392 | QPainter cornerPainter(&m_cornerPixmap); | - | ||||||||||||
| 393 | cornerPainter.setRenderHint(QPainter::Antialiasing); | - | ||||||||||||
| 394 | cornerPainter.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||
| 395 | - | |||||||||||||
| 396 | - | |||||||||||||
| 397 | if (m_penWidth > 0
| 0 | ||||||||||||
| 398 | cornerPainter.setPen(Qt::NoPen); | - | ||||||||||||
| 399 | cornerPainter.setBrush(m_penColor); | - | ||||||||||||
| 400 | cornerPainter.drawRoundedRect(QRectF(0, 0, radius * 2, radius *2), radius, radius); | - | ||||||||||||
| 401 | } never executed: end of block | 0 | ||||||||||||
| 402 | - | |||||||||||||
| 403 | - | |||||||||||||
| 404 | if (radius > m_penWidth
| 0 | ||||||||||||
| 405 | cornerPainter.setPen(Qt::NoPen); | - | ||||||||||||
| 406 | if (m_stops.isEmpty()
| 0 | ||||||||||||
| 407 | cornerPainter.setBrush(m_brush); never executed: cornerPainter.setBrush(m_brush); | 0 | ||||||||||||
| 408 | else | - | ||||||||||||
| 409 | cornerPainter.setBrush(Qt::transparent); never executed: cornerPainter.setBrush(Qt::transparent); | 0 | ||||||||||||
| 410 | - | |||||||||||||
| 411 | QMarginsF adjustmentMargins(m_penWidth, m_penWidth, m_penWidth, m_penWidth); | - | ||||||||||||
| 412 | QRectF cornerCircleRect = QRectF(0, 0, radius * 2, radius * 2).marginsRemoved(adjustmentMargins); | - | ||||||||||||
| 413 | cornerPainter.drawRoundedRect(cornerCircleRect, radius, radius); | - | ||||||||||||
| 414 | } never executed: end of block | 0 | ||||||||||||
| 415 | cornerPainter.end(); | - | ||||||||||||
| 416 | } never executed: end of block | 0 | ||||||||||||
| 417 | } never executed: end of block | 0 | ||||||||||||
| 418 | - | |||||||||||||
| 419 | - | |||||||||||||
| Switch to Source code | Preprocessed file |