Refactor QWindowsXPStylePrivate::drawBackground() and helpers.

Pass the DC obtained drawBackground() to drawBackgroundDirectly(),
saving a call to hdcForWidgetBackingStore() to find it.
Pass the error code from the Win32 API DrawThemeBackground()
to the calling functions.

Change-Id: I1c25241f53d87e4429ad924f7b2e29da215d7e4f
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
bb10
Friedemann Kleint 2016-04-06 09:41:54 +02:00
parent e4e62496ac
commit 1e69d4e3ac
2 changed files with 7 additions and 9 deletions

View File

@ -774,7 +774,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0);
const bool result = dc
? drawBackgroundDirectly(themeData, qRound(aditionalDevicePixelRatio))
? drawBackgroundDirectly(dc, themeData, qRound(aditionalDevicePixelRatio))
: drawBackgroundThruNativeBuffer(themeData, qRound(aditionalDevicePixelRatio));
painter->restore();
return result;
@ -804,12 +804,9 @@ static QRegion scaleRegion(const QRegion &region, int factor)
Do not use this if you need to perform other transformations on the
resulting data.
*/
bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData, int additionalDevicePixelRatio)
bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int additionalDevicePixelRatio)
{
QPainter *painter = themeData.painter;
HDC dc = 0;
if (themeData.widget)
dc = hdcForWidgetBackingStore(themeData.widget);
QPoint redirectionDelta(int(painter->deviceMatrix().dx()),
int(painter->deviceMatrix().dy()));
@ -841,8 +838,9 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData, int
| (themeData.noContent ? DTBG_OMITCONTENT : 0)
| (themeData.mirrorHorizontally ? DTBG_MIRRORDC : 0);
HRESULT result = S_FALSE;
if (pDrawThemeBackgroundEx != 0) {
pDrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions);
result = pDrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions);
} else {
// We are running on a system where the uxtheme.dll does not have
// the DrawThemeBackgroundEx function, so we need to clip away
@ -876,11 +874,11 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData, int
}
}
pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &(drawOptions.rcClip));
result = pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &(drawOptions.rcClip));
}
SelectClipRgn(dc, 0);
DeleteObject(hrgn);
return true;
return SUCCEEDED(result);
}
/*! \internal

View File

@ -388,7 +388,7 @@ public:
void setTransparency(QWidget *widget, XPThemeData &themeData);
bool drawBackground(XPThemeData &themeData);
bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, int aditionalDevicePixelRatio);
bool drawBackgroundDirectly(XPThemeData &themeData, int aditionalDevicePixelRatio);
bool drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int aditionalDevicePixelRatio);
bool hasAlphaChannel(const QRect &rect);
bool fixAlphaChannel(const QRect &rect);