Use PlatformNativeInterface to obtain backingStore's dc

Change-Id: I6ec2fc0b8e7696fdfe4468920228df2d21c933fd
Reviewed-on: http://codereview.qt.nokia.com/1501
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
bb10
Olli Werwolff 2011-07-12 13:02:54 +02:00 committed by Oliver Wolff
parent 54ec6d177e
commit 992ef929df
7 changed files with 37 additions and 11 deletions

View File

@ -57,4 +57,11 @@ void *QPlatformNativeInterface::nativeResourceForContext(const QByteArray &resou
return 0;
}
void * QPlatformNativeInterface::nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore)
{
Q_UNUSED(resource);
Q_UNUSED(backingStore);
return 0;
}
QT_END_NAMESPACE

View File

@ -52,12 +52,14 @@ QT_MODULE(Gui)
class QGuiGLContext;
class QWindow;
class QBackingStore;
class Q_GUI_EXPORT QPlatformNativeInterface
{
public:
virtual void *nativeResourceForContext(const QByteArray &resource, QGuiGLContext *context);
virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window);
virtual void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore);
};
QT_END_NAMESPACE

View File

@ -247,4 +247,9 @@ void Q_GUI_EXPORT qt_scrollRectInImage(QImage &img, const QRect &rect, const QPo
}
}
QPlatformBackingStore *QBackingStore::handle() const
{
return d_ptr->platformBackingStore;
}
QT_END_NAMESPACE

View File

@ -54,6 +54,7 @@ class QRect;
class QPoint;
class QImage;
class QBackingStorePrivate;
class QPlatformBackingStore;
class Q_GUI_EXPORT QBackingStore
{
@ -81,6 +82,8 @@ public:
QRegion staticContents() const;
bool hasStaticContents() const;
QPlatformBackingStore *handle() const;
private:
QScopedPointer<QBackingStorePrivate> d_ptr;
};

View File

@ -232,7 +232,9 @@ void QVistaBackButton::paintEvent(QPaintEvent *)
else if (underMouse())
state = WIZ_NAV_BB_HOT;
pDrawThemeBackground(theme, p.paintEngine()->getDC(), WIZ_NAV_BACKBUTTON, state, &clipRect, &clipRect);
QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
HDC hdc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore()));
pDrawThemeBackground(theme, hdc, WIZ_NAV_BACKBUTTON, state, &clipRect, &clipRect);
}
/******************************************************************************
@ -318,12 +320,14 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type)
void QVistaHelper::drawTitleBar(QPainter *painter)
{
HDC hdc = static_cast<QRasterPaintEngine *>(painter->paintEngine())->getDC();
Q_ASSERT(backButton_);
QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
QBackingStore *backingStore = backButton_->backingStore();
HDC hdc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore));
if (vistaState() == VistaAero)
drawBlackRect(QRect(0, 0, wizard->width(),
titleBarSize() + topOffset()), hdc);
Q_ASSERT(backButton_);
const int btnTop = backButton_->mapToParent(QPoint()).y();
const int btnHeight = backButton_->size().height();
const int verticalCenter = (btnTop + btnHeight / 2) - 1;

View File

@ -190,17 +190,17 @@ RECT XPThemeData::toRECT(const QRect &qr)
Returns the native region of a part, if the part is considered
transparent. The region is scaled to the parts size (rect).
*/
HRGN XPThemeData::mask()
HRGN XPThemeData::mask(QWidget *widget)
{
if (!pIsThemeBackgroundPartiallyTransparent(handle(), partId, stateId))
return 0;
HRGN hrgn;
HDC dc = painter == 0 ? 0 : painter->paintEngine()->getDC();
QBackingStore *backingStore = widget->backingStore();
QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
HDC dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore));
RECT nativeRect = toRECT(rect);
pGetThemeBackgroundRegion(handle(), dc, partId, stateId, &nativeRect, &hrgn);
if (dc)
painter->paintEngine()->releaseDC(dc);
return hrgn;
}
@ -505,7 +505,7 @@ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData)
*/
void QWindowsXPStylePrivate::setTransparency(QWidget *widget, XPThemeData &themeData)
{
HRGN hrgn = themeData.mask();
HRGN hrgn = themeData.mask(widget);
if (hrgn && widget)
SetWindowRgn(winId(widget), hrgn, true);
}
@ -657,7 +657,10 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
translucentToplevel = win->testAttribute(Qt::WA_TranslucentBackground);
}
bool useFallback = painter->paintEngine()->getDC() == 0
QBackingStore *backingStore = themeData.widget->backingStore();
QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
HDC dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore ));
bool useFallback = dc == 0
|| painter->opacity() != 1.0
|| themeData.rotate
|| complexXForm
@ -681,7 +684,9 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
void QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData)
{
QPainter *painter = themeData.painter;
HDC dc = painter->paintEngine()->getDC();
QBackingStore *backingStore= themeData.widget->backingStore();
QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
HDC dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore));
QPoint redirectionDelta(int(painter->deviceMatrix().dx()),
int(painter->deviceMatrix().dy()));

View File

@ -216,7 +216,7 @@ public:
noContent(false), rotate(0), rect(r)
{}
HRGN mask();
HRGN mask(QWidget *widget);
HTHEME handle();
RECT toRECT(const QRect &qr);