summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-04-17 13:32:44 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-18 09:18:43 +0200
commit1770f25857c7cfe21c36c0bda8a80a54b199bafe (patch)
tree946dfb81286191958296f8b74d3c12c1236f6aaa /src
parente25db968846432f087ca800048f5337fd534c159 (diff)
Fix GroupBox painting on Windows when not using widgets
This is simply removing some slow and rather ugly hacks that tried to reconstruct broken data from the windows xp theme. After testing without these hacks on both XP and Windows 7, I believe we can conclude that these workarounds are no longer required and even breaks our look and feel in several places. Task-number: QTBUG-29888 Change-Id: Ifaffd660e8d9ed6dfd43657745c3fa1606d33a7c Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp47
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p_p.h4
2 files changed, 3 insertions, 48 deletions
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index 64569cfd9b..31cf329262 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -570,30 +570,6 @@ void QWindowsXPStylePrivate::setTransparency(QWidget *widget, XPThemeData &theme
}
/*! \internal
- Returns true if the native doublebuffer contains a pixel which
- has a non-0xFF alpha value. Should only be use when its
- guaranteed that data painted into the buffer wasn't a proper
- alpha pixmap.
-*/
-bool QWindowsXPStylePrivate::hasAnyData(const QRect &rect)
-{
- const int startX = rect.left();
- const int startY = rect.top();
- const int w = rect.width();
- const int h = rect.height();
-
- for (int y = startY; y < h; ++y) {
- register DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
- for (int x = startX; x < w; ++x, ++buffer) {
- int alpha = (*buffer) >> 24;
- if (alpha != 0xFF) // buffer has been touched
- return true;
- }
- }
- return false;
-}
-
-/*! \internal
Returns true if the native doublebuffer contains pixels with
varying alpha value.
*/
@@ -857,7 +833,6 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
bool stateHasData = true; // We assume so;
bool hasAlpha = false;
bool partIsTransparent;
- bool inspectData;
bool potentialInvalidAlpha;
QString pixmapCacheKey = QStringLiteral("$qt_xp_");
@@ -882,9 +857,6 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
bool haveCachedPixmap = false;
bool isCached = data.dataValid;
if (isCached) {
- if (!(stateHasData = data.hasAnyData))
- return; // Cached NOOP
- inspectData = data.wasAlphaSwapped;
partIsTransparent = data.partIsTransparent;
hasAlpha = data.hasAlphaChannel;
alphaType = data.alphaType;
@@ -907,13 +879,6 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
pGetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERONLY, &tmt_borderonly);
pGetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, TMT_TRANSPARENTCOLOR, &tmt_transparentcolor);
pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_CAPTIONMARGINS, &proporigin);
- inspectData = (tmt_transparentcolor != 0 || tmt_borderonly || proporigin == PO_PART || proporigin == PO_STATE);
-
- // ### This is a vista-specific workaround for broken alpha in titlebar pixmaps
- if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) {
- if (themeData.partId == WP_CAPTION || themeData.partId == WP_SMALLCAPTION)
- inspectData = false;
- }
partIsTransparent = isTransparent(themeData);
@@ -922,14 +887,13 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
if (proporigin == PO_PART || proporigin == PO_STATE) {
int tmt_glyphtype = GT_NONE;
pGetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &tmt_glyphtype);
- potentialInvalidAlpha = partIsTransparent && !inspectData && tmt_glyphtype == GT_IMAGEGLYPH;
+ potentialInvalidAlpha = partIsTransparent && tmt_glyphtype == GT_IMAGEGLYPH;
}
#ifdef DEBUG_XP_STYLE
printf("---[ NOT CACHED ]-----------------------> Name(%-10s) Part(%d) State(%d)\n",
qPrintable(themeData.name), themeData.partId, themeData.stateId);
printf("-->partIsTransparen = %d\n", partIsTransparent);
- printf("-->inspectData = %d\n", inspectData);
printf("-->potentialInvalidAlpha = %d\n", potentialInvalidAlpha);
showProperties(themeData);
#endif
@@ -979,7 +943,7 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
// Clear the buffer
if (alphaType != NoAlpha) {
// Consider have separate "memset" function for small chunks for more speedup
- memset(bufferPixels, inspectData ? 0xFF : 0x00, bufferW * h * 4);
+ memset(bufferPixels, 0x00, bufferW * h * 4);
}
// Difference between area and rect
@@ -1021,8 +985,6 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
// If not cached, analyze the buffer data to figure
// out alpha type, and if it contains data
if (!isCached) {
- if (inspectData)
- stateHasData = hasAnyData(rect);
// SHORTCUT: If the part's state has no data, cache it for NOOP later
if (!stateHasData) {
memset(&data, 0, sizeof(data));
@@ -1038,10 +1000,6 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
#endif
}
- // Swap alpha values, if needed
- if (inspectData)
- wasAlphaSwapped = swapAlphaChannel(rect);
-
// Fix alpha values, if needed
if (potentialInvalidAlpha)
wasAlphaFixed = fixAlphaChannel(rect);
@@ -1143,7 +1101,6 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
data.partIsTransparent = partIsTransparent;
data.alphaType = alphaType;
data.hasAlphaChannel = hasAlpha;
- data.hasAnyData = stateHasData;
data.wasAlphaSwapped = wasAlphaSwapped;
data.hadInvalidAlpha = wasAlphaFixed;
alphaCache.insert(key, data);
diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h
index 783adc3085..27d9c9acc9 100644
--- a/src/widgets/styles/qwindowsxpstyle_p_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p_p.h
@@ -274,12 +274,11 @@ struct ThemeMapData {
bool dataValid : 1; // Only used to detect if hash value is ok
bool partIsTransparent : 1;
- bool hasAnyData : 1; // False = part & state has not data, NOP
bool hasAlphaChannel : 1; // True = part & state has real Alpha
bool wasAlphaSwapped : 1; // True = alpha channel needs to be swapped
bool hadInvalidAlpha : 1; // True = alpha channel contained invalid alpha values
- ThemeMapData() : dataValid(false), partIsTransparent(false), hasAnyData(false),
+ ThemeMapData() : dataValid(false), partIsTransparent(false),
hasAlphaChannel(false), wasAlphaSwapped(false), hadInvalidAlpha(false) {}
};
@@ -339,7 +338,6 @@ public:
void drawBackgroundThruNativeBuffer(XPThemeData &themeData);
void drawBackgroundDirectly(XPThemeData &themeData);
- bool hasAnyData(const QRect &rect);
bool hasAlphaChannel(const QRect &rect);
bool fixAlphaChannel(const QRect &rect);
bool swapAlphaChannel(const QRect &rect, bool allPixels = false);