From 59653437cbc37f9644aa540c46701c2142939198 Mon Sep 17 00:00:00 2001 From: jasplin Date: Thu, 4 Jun 2009 11:37:08 +0200 Subject: Removed the internal UsePixmapCache flag in the style code. In the style code, the internal UsePixmapCache flag made no sense in practice, so it was removed. A fortunate side-effect of the patch is that the code is now accepted by Sun CC 5.5. Reviewed-by: jbache --- src/gui/styles/qcleanlooksstyle.cpp | 30 ++++++++----------- src/gui/styles/qgtkstyle.cpp | 1 - src/gui/styles/qplastiquestyle.cpp | 57 ++++++++++++++----------------------- src/gui/styles/qstyle_p.h | 2 +- src/gui/styles/qstylehelper.cpp | 1 - src/gui/styles/qstylehelper_p.h | 1 - 6 files changed, 35 insertions(+), 57 deletions(-) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 5c37794..b33dfc1 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -1664,7 +1664,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o } painter->fillRect(r, gradient); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(r.size()); cache.fill(Qt::transparent); QRect pixmapRect(0, 0, r.width(), r.height()); @@ -1683,8 +1683,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o cachePainter.drawLine(pixmapRect.topRight() + QPoint(-1, 3), pixmapRect.bottomRight() + QPoint(-1, -3)); cachePainter.setPen(QPen(option->palette.light().color())); cachePainter.drawLine(pixmapRect.topRight() + QPoint(0, 3), pixmapRect.bottomRight() + QPoint(0, -3)); } cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(r.topLeft(), cache); } @@ -2438,7 +2437,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { QPixmap cache; QString pixmapName = QStyleHelper::uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size()); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(spinBox->rect.size()); cache.fill(Qt::transparent); QRect pixmapRect(0, 0, spinBox->rect.width(), spinBox->rect.height()); @@ -2655,8 +2654,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp cachePainter.fillRect(downRect.adjusted(1, 0, 0, 0), disabledColor); } cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(spinBox->rect.topLeft(), cache); } @@ -3187,7 +3185,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (isEnabled) pixmapName += QLatin1String("-enabled"); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(comboBox->rect.size()); cache.fill(Qt::transparent); QPainter cachePainter(&cache); @@ -3314,8 +3312,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp drawPrimitive(PE_FrameFocusRect, &focus, &cachePainter, widget); } cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(comboBox->rect.topLeft(), cache); } @@ -3406,7 +3403,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp QRect pixmapRect(0, 0, groove.width(), groove.height()); // draw background groove - if (!UsePixmapCache || !QPixmapCache::find(groovePixmapName, cache)) { + if (!QPixmapCache::find(groovePixmapName, cache)) { cache = QPixmap(pixmapRect.size()); cache.fill(Qt::transparent); QPainter groovePainter(&cache); @@ -3433,15 +3430,14 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp groovePainter.setBrush(gradient); groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2)); groovePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(groovePixmapName, cache); + QPixmapCache::insert(groovePixmapName, cache); } painter->drawPixmap(groove.topLeft(), cache); // draw blue groove highlight QRect clipRect; groovePixmapName += QLatin1String("_blue"); - if (!UsePixmapCache || !QPixmapCache::find(groovePixmapName, cache)) { + if (!QPixmapCache::find(groovePixmapName, cache)) { cache = QPixmap(pixmapRect.size()); cache.fill(Qt::transparent); QPainter groovePainter(&cache); @@ -3460,8 +3456,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp groovePainter.setBrush(gradient); groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2)); groovePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(groovePixmapName, cache); + QPixmapCache::insert(groovePixmapName, cache); } if (horizontal) { if (slider->upsideDown) @@ -3483,7 +3478,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // draw handle if ((option->subControls & SC_SliderHandle) ) { QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); - if (!UsePixmapCache || !QPixmapCache::find(handlePixmapName, cache)) { + if (!QPixmapCache::find(handlePixmapName, cache)) { cache = QPixmap(handle.size()); cache.fill(Qt::transparent); QRect pixmapRect(0, 0, handle.width(), handle.height()); @@ -3564,8 +3559,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp } } handlePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(handlePixmapName, cache); + QPixmapCache::insert(handlePixmapName, cache); } painter->drawPixmap(handle.topLeft(), cache); diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 151dab0..1fe4627 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -176,7 +176,6 @@ public: static const int groupBoxBottomMargin = 2; // space below the groupbox static const int groupBoxTitleMargin = 6; // space between contents and title static const int groupBoxTopMargin = 2; -static bool UsePixmapCache = true; // Get size of the arrow controls in a GtkSpinButton static int spinboxArrowSize() diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index 91ad64e..01c0e44 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -43,7 +43,6 @@ #if !defined(QT_NO_STYLE_PLASTIQUE) || defined(QT_PLUGIN) -static bool UsePixmapCache = true; static const bool AnimateBusyProgressBar = true; static const bool AnimateProgressBar = false; // #define QPlastique_MaskButtons @@ -491,7 +490,7 @@ static void qBrushSetAlphaF(QBrush *brush, qreal alpha) QPixmap texture = brush->texture(); QPixmap pixmap; QString name = QString::fromLatin1("qbrushtexture-alpha-%1-%2").arg(alpha).arg(texture.cacheKey()); - if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) { + if (!QPixmapCache::find(name, pixmap)) { QImage image = texture.toImage(); QRgb *rgb = reinterpret_cast(image.bits()); int pixels = image.width() * image.height(); @@ -552,7 +551,7 @@ static QBrush qBrushLight(QBrush brush, int light) QPixmap texture = brush.texture(); QPixmap pixmap; QString name = QString::fromLatin1("qbrushtexture-light-%1-%2").arg(light).arg(texture.cacheKey()); - if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) { + if (!QPixmapCache::find(name, pixmap)) { QImage image = texture.toImage(); QRgb *rgb = reinterpret_cast(image.bits()); int pixels = image.width() * image.height(); @@ -611,7 +610,7 @@ static QBrush qBrushDark(QBrush brush, int dark) QPixmap texture = brush.texture(); QPixmap pixmap; QString name = QString::fromLatin1("qbrushtexture-dark-%1-%2").arg(dark).arg(brush.texture().cacheKey()); - if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) { + if (!QPixmapCache::find(name, pixmap)) { QImage image = texture.toImage(); QRgb *rgb = reinterpret_cast(image.bits()); int pixels = image.width() * image.height(); @@ -750,8 +749,7 @@ static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, con QPainter *p = painter; QRect r = rect; - bool doPixmapCache = UsePixmapCache - && painter->deviceTransform().isIdentity() + bool doPixmapCache = painter->deviceTransform().isIdentity() && painter->worldMatrix().isIdentity(); if (doPixmapCache && QPixmapCache::find(gradientName, cache)) { painter->drawPixmap(rect, cache); @@ -1006,8 +1004,6 @@ QPlastiqueStylePrivate::QPlastiqueStylePrivate() : , progressBarAnimateTimer(0) #endif { - if (!qgetenv("QT_STYLE_NO_PIXMAPCACHE").isNull()) - UsePixmapCache = false; } /*! @@ -1517,7 +1513,7 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption } #endif QString pixmapName = uniqueName(QLatin1String("toolbarhandle"), option, rect.size()); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(rect.size()); cache.fill(Qt::transparent); QPainter cachePainter(&cache); @@ -1547,8 +1543,7 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption handle); } cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(rect.topLeft(), cache); break; @@ -2786,7 +2781,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op QString progressBarName = uniqueName(QLatin1String("progressBarContents"), option, rect.size()); QPixmap cache; - if ((!UsePixmapCache || !QPixmapCache::find(progressBarName, cache)) && rect.height() > 7) { + if (!QPixmapCache::find(progressBarName, cache) && rect.height() > 7) { QSize size = rect.size(); cache = QPixmap(QSize(size.width() - 6 + 30, size.height() - 6)); cache.fill(Qt::white); @@ -2819,8 +2814,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op leftEdge += 10; } - if (UsePixmapCache) - QPixmapCache::insert(progressBarName, cache); + QPixmapCache::insert(progressBarName, cache); } painter->setClipRect(progressBar.adjusted(1, 0, -1, -1)); @@ -2848,7 +2842,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op pixmapName += QString::number(- int(header->position)); pixmapName += QString::number(- int(header->orientation)); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, option->rect.width(), option->rect.height()); @@ -2892,8 +2886,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op cachePainter.drawLines(lines, 2); cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(option->rect.topLeft(), cache); @@ -3093,7 +3086,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op if ((option->state & State_Selected)) { QPixmap cache; QString pixmapName = uniqueName(QLatin1String("menubaritem"), option, option->rect.size()); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, option->rect.width(), option->rect.height()); @@ -3143,8 +3136,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op lines[1] = QLine(rect.right() - 1, rect.top() + 1, rect.right() - 1, rect.bottom() - 2); cachePainter.drawLines(lines, 2); cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(option->rect.topLeft(), cache); } else { @@ -3458,7 +3450,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op QString addLinePixmapName = uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size()); QPixmap cache; - if (!UsePixmapCache || !QPixmapCache::find(addLinePixmapName, cache)) { + if (!QPixmapCache::find(addLinePixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, cache.width(), cache.height()); @@ -3517,8 +3509,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op addLinePainter.drawImage(QPoint(pixmapRect.center().x() - 3, pixmapRect.center().y() - 2), arrow); } addLinePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(addLinePixmapName, cache); + QPixmapCache::insert(addLinePixmapName, cache); } painter->drawPixmap(option->rect.topLeft(), cache); } @@ -3536,7 +3527,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op groovePixmapName += QLatin1String("-addpage"); QPixmap cache; - if (!UsePixmapCache || !QPixmapCache::find(groovePixmapName, cache)) { + if (!QPixmapCache::find(groovePixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(option->palette.background().color()); QPainter groovePainter(&cache); @@ -3562,8 +3553,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op } groovePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(groovePixmapName, cache); + QPixmapCache::insert(groovePixmapName, cache); } painter->drawPixmap(option->rect.topLeft(), cache); } @@ -3591,7 +3581,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op QString subLinePixmapName = uniqueName(QLatin1String("scrollbar_subline"), option, button1.size()); QPixmap cache; - if (!UsePixmapCache || !QPixmapCache::find(subLinePixmapName, cache)) { + if (!QPixmapCache::find(subLinePixmapName, cache)) { cache = QPixmap(button1.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, cache.width(), cache.height()); @@ -3651,8 +3641,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op subLinePainter.drawImage(QPoint(pixmapRect.center().x() - 3, pixmapRect.center().y() - 2), arrow); } subLinePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(subLinePixmapName, cache); + QPixmapCache::insert(subLinePixmapName, cache); } painter->drawPixmap(button1.topLeft(), cache); painter->drawPixmap(button2.topLeft(), cache); @@ -3670,7 +3659,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op sliderPixmapName += QLatin1String("-horizontal"); QPixmap cache; - if (!UsePixmapCache || !QPixmapCache::find(sliderPixmapName, cache)) { + if (!QPixmapCache::find(sliderPixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, cache.width(), cache.height()); @@ -3741,8 +3730,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op } sliderPainter.end(); // insert the slider into the cache - if (UsePixmapCache) - QPixmapCache::insert(sliderPixmapName, cache); + QPixmapCache::insert(sliderPixmapName, cache); } painter->drawPixmap(option->rect.topLeft(), cache); } @@ -3892,7 +3880,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt if ((option->activeSubControls & SC_SliderHandle) && (option->state & State_Sunken)) handlePixmapName += QLatin1String("-sunken"); - if (!UsePixmapCache || !QPixmapCache::find(handlePixmapName, cache)) { + if (!QPixmapCache::find(handlePixmapName, cache)) { cache = QPixmap(handle.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, handle.width(), handle.height()); @@ -3975,8 +3963,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt } handlePainter.drawImage(pixmapRect, image); handlePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(handlePixmapName, cache); + QPixmapCache::insert(handlePixmapName, cache); } painter->drawPixmap(handle.topLeft(), cache); diff --git a/src/gui/styles/qstyle_p.h b/src/gui/styles/qstyle_p.h index 848bad6..154321a 100644 --- a/src/gui/styles/qstyle_p.h +++ b/src/gui/styles/qstyle_p.h @@ -77,7 +77,7 @@ public: QPainter *p = painter; \ QString unique = uniqueName((a), option, option->rect.size()); \ int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \ - bool doPixmapCache = UsePixmapCache && txType <= QTransform::TxTranslate; \ + bool doPixmapCache = txType <= QTransform::TxTranslate; \ if (doPixmapCache && QPixmapCache::find(unique, internalPixmapCache)) { \ painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \ } else { \ diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index 69f8cd2..20de892 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -51,7 +51,6 @@ QT_BEGIN_NAMESPACE namespace QStyleHelper { -const bool UsePixmapCache = true; QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) { diff --git a/src/gui/styles/qstylehelper_p.h b/src/gui/styles/qstylehelper_p.h index 5385d9f..ef6e66c 100644 --- a/src/gui/styles/qstylehelper_p.h +++ b/src/gui/styles/qstylehelper_p.h @@ -66,7 +66,6 @@ class QStyleOption; namespace QStyleHelper { - extern const bool UsePixmapCache; QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size); #ifndef QT_NO_DIAL qreal angle(const QPointF &p1, const QPointF &p2); -- cgit v0.12