Commit 3da48de3 authored by Jens Bache-Wiig's avatar Jens Bache-Wiig
Browse files

Don't cache toolbars twice. Fix flickering.

There was a flicker problem with the tool bars because of
missing information in the cache key. We added this info
and removed the redundant caching of toolbar gradients.

Done-with: thorbjorn
parent 751d7d04
...@@ -231,9 +231,9 @@ void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, c ...@@ -231,9 +231,9 @@ void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, c
if (StyleHelper::usePixmapCache()) { if (StyleHelper::usePixmapCache()) {
QString key; QString key;
QColor keyColor = baseColor(lightColored); QColor keyColor = baseColor(lightColored);
key.sprintf("mh_horizontal %d %d %d %d %d", key.sprintf("mh_horizontal %d %d %d %d %d %d",
spanRect.width(), spanRect.height(), clipRect.width(), spanRect.width(), spanRect.height(), clipRect.width(),
clipRect.height(), keyColor.rgb()); clipRect.height(), keyColor.rgb(), spanRect.x());
QPixmap pixmap; QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) { if (!QPixmapCache::find(key, pixmap)) {
......
...@@ -78,8 +78,6 @@ public: ...@@ -78,8 +78,6 @@ public:
static void horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false); static void horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false); static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect); static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
// Pixmap cache should only be enabled for X11 due to slow gradients
static bool usePixmapCache() { return true; } static bool usePixmapCache() { return true; }
static void drawIconWithShadow(const QPixmap &px, const QPoint &pos, QPainter *p, static void drawIconWithShadow(const QPixmap &px, const QPoint &pos, QPainter *p,
......
...@@ -763,42 +763,22 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt ...@@ -763,42 +763,22 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
case CE_ToolBar: case CE_ToolBar:
{ {
QString key;
QColor keyColor = Utils::StyleHelper::baseColor(lightColored(widget));
key.sprintf("mh_toolbar %d %d %d", option->rect.width(), option->rect.height(), keyColor.rgb());;
QPixmap pixmap;
QPainter *p = painter;
QRect rect = option->rect; QRect rect = option->rect;
bool horizontal = option->state & State_Horizontal; bool horizontal = option->state & State_Horizontal;
if (Utils::StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) { rect = option->rect;
pixmap = QPixmap(option->rect.size());
p = new QPainter(&pixmap); // Map offset for global window gradient
rect = QRect(0, 0, option->rect.width(), option->rect.height()); QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
} widget->mapToGlobal(option->rect.topLeft());
QRect gradientSpan;
if (!Utils::StyleHelper::usePixmapCache() || !QPixmapCache::find(key, pixmap)) { if (widget)
// Map offset for global window gradient gradientSpan = QRect(offset, widget->window()->size());
QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
widget->mapToGlobal(option->rect.topLeft()); bool drawLightColored = lightColored(widget);
QRect gradientSpan; if (horizontal)
if (widget) { Utils::StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
gradientSpan = QRect(offset, widget->window()->size()); else
} Utils::StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored);
bool drawLightColored = lightColored(widget);
if (horizontal)
Utils::StyleHelper::horizontalGradient(p, gradientSpan, rect, drawLightColored);
else
Utils::StyleHelper::verticalGradient(p, gradientSpan, rect, drawLightColored);
}
if (Utils::StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
delete p;
QPixmapCache::insert(key, pixmap);
}
if (Utils::StyleHelper::usePixmapCache()) {
painter->drawPixmap(rect.topLeft(), pixmap);
}
painter->setPen(Utils::StyleHelper::borderColor()); painter->setPen(Utils::StyleHelper::borderColor());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment