remove code for always false condition in QPainterPrivate

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2020-08-03 01:20:49 +03:00
parent 18a974dcfe
commit bc299e7af0
2 changed files with 13 additions and 19 deletions

View file

@ -252,7 +252,7 @@ void QPainterPrivate::detachPainterPrivate(QPainter *q)
} }
void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperation op) void QPainterPrivate::draw_helper(const QPainterPath &originalPath)
{ {
#ifdef QT_DEBUG_DRAW #ifdef QT_DEBUG_DRAW
printf("QPainter::drawHelper\n"); printf("QPainter::drawHelper\n");
@ -262,7 +262,7 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio
return; return;
if (!extended) { if (!extended) {
drawStretchedGradient(originalPath, op); drawStretchedGradient(originalPath);
return; return;
} }
@ -273,7 +273,7 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio
QPainterPath path = originalPath * state->matrix; QPainterPath path = originalPath * state->matrix;
QRectF pathBounds = path.boundingRect(); QRectF pathBounds = path.boundingRect();
QRectF strokeBounds; QRectF strokeBounds;
bool doStroke = (op & StrokeDraw) && (state->pen.style() != Qt::NoPen); bool doStroke = (state->pen.style() != Qt::NoPen);
if (doStroke) { if (doStroke) {
qreal penWidth = state->pen.widthF(); qreal penWidth = state->pen.widthF();
if (penWidth == 0) { if (penWidth == 0) {
@ -352,7 +352,7 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio
p.translate(-absPathRect.x(), -absPathRect.y()); p.translate(-absPathRect.x(), -absPathRect.y());
p.setTransform(state->matrix, true); p.setTransform(state->matrix, true);
p.setPen(doStroke ? state->pen : QPen(Qt::NoPen)); p.setPen(doStroke ? state->pen : QPen(Qt::NoPen));
p.setBrush((op & FillDraw) ? state->brush : QBrush(Qt::NoBrush)); p.setBrush(state->brush);
p.setBackground(state->bgBrush); p.setBackground(state->bgBrush);
p.setBackgroundMode(state->bgMode); p.setBackgroundMode(state->bgMode);
p.setBrushOrigin(state->brushOrigin); p.setBrushOrigin(state->brushOrigin);
@ -395,18 +395,18 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio
q->restore(); q->restore();
} }
void QPainterPrivate::drawOpaqueBackground(const QPainterPath &path, DrawOperation op) void QPainterPrivate::drawOpaqueBackground(const QPainterPath &path)
{ {
Q_Q(QPainter); Q_Q(QPainter);
q->setBackgroundMode(Qt::TransparentMode); q->setBackgroundMode(Qt::TransparentMode);
if (op & FillDraw && state->brush.style() != Qt::NoBrush) { if (state->brush.style() != Qt::NoBrush) {
q->fillPath(path, state->bgBrush.color()); q->fillPath(path, state->bgBrush.color());
q->fillPath(path, state->brush); q->fillPath(path, state->brush);
} }
if (op & StrokeDraw && state->pen.style() != Qt::NoPen) { if (state->pen.style() != Qt::NoPen) {
q->strokePath(path, QPen(state->bgBrush.color(), state->pen.width())); q->strokePath(path, QPen(state->bgBrush.color(), state->pen.width()));
q->strokePath(path, state->pen); q->strokePath(path, state->pen);
} }
@ -430,7 +430,7 @@ static inline QBrush stretchGradientToUserSpace(const QBrush &brush, const QRect
return b; return b;
} }
void QPainterPrivate::drawStretchedGradient(const QPainterPath &path, DrawOperation op) void QPainterPrivate::drawStretchedGradient(const QPainterPath &path)
{ {
Q_Q(QPainter); Q_Q(QPainter);
@ -450,7 +450,7 @@ void QPainterPrivate::drawStretchedGradient(const QPainterPath &path, DrawOperat
QRectF boundingRect; QRectF boundingRect;
// Draw the xformed fill if the brush is a stretch gradient. // Draw the xformed fill if the brush is a stretch gradient.
if ((op & FillDraw) && brush.style() != Qt::NoBrush) { if (brush.style() != Qt::NoBrush) {
if (brushMode == QGradient::StretchToDeviceMode) { if (brushMode == QGradient::StretchToDeviceMode) {
q->setPen(Qt::NoPen); q->setPen(Qt::NoPen);
changedPen = pen.style() != Qt::NoPen; changedPen = pen.style() != Qt::NoPen;
@ -474,7 +474,7 @@ void QPainterPrivate::drawStretchedGradient(const QPainterPath &path, DrawOperat
} }
} }
if ((op & StrokeDraw) && pen.style() != Qt::NoPen) { if (pen.style() != Qt::NoPen) {
// Draw the xformed outline if the pen is a stretch gradient. // Draw the xformed outline if the pen is a stretch gradient.
if (penMode == QGradient::StretchToDeviceMode) { if (penMode == QGradient::StretchToDeviceMode) {
q->setPen(Qt::NoPen); q->setPen(Qt::NoPen);

View file

@ -175,12 +175,6 @@ public:
int d_ptrs_size; int d_ptrs_size;
uint refcount; uint refcount;
enum DrawOperation {
StrokeDraw = 0x1,
FillDraw = 0x2,
StrokeAndFillDraw = 0x3
};
QPainterDummyState *fakeState() const { QPainterDummyState *fakeState() const {
if (!dummyState) if (!dummyState)
dummyState = new QPainterDummyState(); dummyState = new QPainterDummyState();
@ -190,9 +184,9 @@ public:
void updateStateImpl(QPainterState *state); void updateStateImpl(QPainterState *state);
void updateState(QPainterState *state); void updateState(QPainterState *state);
void draw_helper(const QPainterPath &path, DrawOperation operation = StrokeAndFillDraw); void draw_helper(const QPainterPath &path);
void drawStretchedGradient(const QPainterPath &path, DrawOperation operation); void drawStretchedGradient(const QPainterPath &path);
void drawOpaqueBackground(const QPainterPath &path, DrawOperation operation); void drawOpaqueBackground(const QPainterPath &path);
void updateMatrix(); void updateMatrix();
void updateInvMatrix(); void updateInvMatrix();