OSDN Git Service

optimize QPainter::fillRect() methods
authorIvailo Monev <xakepa10@gmail.com>
Sun, 2 Aug 2020 20:23:10 +0000 (23:23 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 2 Aug 2020 20:23:10 +0000 (23:23 +0300)
solid brushes do not have neither texture nor gradient

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/painting/qpainter.cpp
src/gui/painting/qpainter_p.h

index 22caa6f..86dde0e 100644 (file)
@@ -6082,14 +6082,7 @@ void QPainter::fillRect(const QRectF &r, const QBrush &brush)
     QPen oldPen = pen();
     QBrush oldBrush = this->brush();
     setPen(Qt::NoPen);
-    if (brush.style() == Qt::SolidPattern) {
-        d->colorBrush.setStyle(Qt::SolidPattern);
-        d->colorBrush.setColor(brush.color());
-        setBrush(d->colorBrush);
-    } else {
-        setBrush(brush);
-    }
-
+    setBrush(brush);
     drawRect(r);
     setBrush(oldBrush);
     setPen(oldPen);
@@ -6120,14 +6113,7 @@ void QPainter::fillRect(const QRect &r, const QBrush &brush)
     QPen oldPen = pen();
     QBrush oldBrush = this->brush();
     setPen(Qt::NoPen);
-    if (brush.style() == Qt::SolidPattern) {
-        d->colorBrush.setStyle(Qt::SolidPattern);
-        d->colorBrush.setColor(brush.color());
-        setBrush(d->colorBrush);
-    } else {
-        setBrush(brush);
-    }
-
+    setBrush(brush);
     drawRect(r);
     setBrush(oldBrush);
     setPen(oldPen);
index 7d1b68a..b293a86 100644 (file)
@@ -210,7 +210,6 @@ public:
     QPaintDevice *helper_device;
     QPaintEngine *engine;
     QPaintEngineEx *extended;
-    QBrush colorBrush;          // for fill with solid color
 };
 
 QString qt_generate_brush_key(const QBrush &brush);