Skip to content

Commit

Permalink
libmythui: Fix rendering of gradient based rectangles.
Browse files Browse the repository at this point in the history
The recent UI refactor didn't provide sufficient distinction between
gradient type rects and hence was returning false positives. This in
turn caused the wrong image to be displayed on screen. Most obviously an
issue with the MythCenter themes.

The rectangle 'hashing' and associated cacheing now looks a little more
complicated (and hence expensive) than originally intended, so this
would probably benefit from some profiling and optimisation.
  • Loading branch information
Mark Kendall committed Mar 12, 2011
1 parent b402a54 commit 3d3c055
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions mythtv/libs/libmythui/mythpainter.cpp
Expand Up @@ -306,8 +306,29 @@ MythImage* MythPainter::GetImageFromRect(const QRect &area, int radius,
uint64_t hash3 = ((0xffffffff & (uint64_t)linePen.color().rgba())) +
((0xffffffff & (uint64_t)fillBrush.color().rgba()) << 32);

QString incoming = QString("RECT") + QString::number(hash1) +
QString::number(hash2) + QString::number(hash3);
QString incoming("R");
if (fillBrush.style() == Qt::LinearGradientPattern && fillBrush.gradient())
{
const QLinearGradient *gradient = static_cast<const QLinearGradient*>(fillBrush.gradient());
if (gradient)
{
incoming = QString::number(
((0xfff & (uint64_t)gradient->start().x())) +
((0xfff & (uint64_t)gradient->start().y()) << 12) +
((0xfff & (uint64_t)gradient->finalStop().x()) << 24) +
((0xfff & (uint64_t)gradient->finalStop().y()) << 36));
QGradientStops stops = gradient->stops();
for (int i = 0; i < stops.size(); i++)
{
incoming += QString::number(
((0xfff * (uint64_t)(stops[i].first * 100))) +
((uint64_t)stops[i].second.rgba() << 12));
}
}
}

incoming += QString::number(hash1) + QString::number(hash2) +
QString::number(hash3);

if (m_StringToImageMap.contains(incoming))
{
Expand Down

0 comments on commit 3d3c055

Please sign in to comment.