From cf1a53cf3c5b5849efc7e024c07b08afb8686f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 20 Jun 2011 14:14:34 +0200 Subject: [PATCH] Port Cocoa plugin to new backing store interface. --- src/plugins/platforms/cocoa/cocoa.pro | 4 ++-- ...cocoawindowsurface.h => qcocoabackingstore.h} | 14 +++++++------- ...coawindowsurface.mm => qcocoabackingstore.mm} | 16 +++++++--------- src/plugins/platforms/cocoa/qcocoaintegration.h | 2 +- src/plugins/platforms/cocoa/qcocoaintegration.mm | 6 +++--- src/plugins/platforms/cocoa/qcocoawindow.h | 2 +- 6 files changed, 21 insertions(+), 23 deletions(-) rename src/plugins/platforms/cocoa/{qcocoawindowsurface.h => qcocoabackingstore.h} (88%) rename src/plugins/platforms/cocoa/{qcocoawindowsurface.mm => qcocoabackingstore.mm} (86%) diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 1136739397..b0e7e73dc7 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -4,7 +4,7 @@ DESTDIR = $$QT.gui.plugins/platforms OBJECTIVE_SOURCES = main.mm \ qcocoaintegration.mm \ - qcocoawindowsurface.mm \ + qcocoabackingstore.mm \ qcocoawindow.mm \ qnsview.mm \ qcocoaautoreleasepool.mm \ @@ -14,7 +14,7 @@ OBJECTIVE_SOURCES = main.mm \ OBJECTIVE_HEADERS = qcocoaintegration.h \ - qcocoawindowsurface.h \ + qcocoabackingstore.h \ qcocoawindow.h \ qnsview.h \ qcocoaautoreleasepool.h \ diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h similarity index 88% rename from src/plugins/platforms/cocoa/qcocoawindowsurface.h rename to src/plugins/platforms/cocoa/qcocoabackingstore.h index 01c6ccde3e..938e27347c 100644 --- a/src/plugins/platforms/cocoa/qcocoawindowsurface.h +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h @@ -39,27 +39,27 @@ ** ****************************************************************************/ -#ifndef QWINDOWSURFACE_COCOA_H -#define QWINDOWSURFACE_COCOA_H +#ifndef QBACKINGSTORE_COCOA_H +#define QBACKINGSTORE_COCOA_H #include #include "qcocoawindow.h" #include "qnsview.h" -#include +#include QT_BEGIN_NAMESPACE -class QCocoaWindowSurface : public QWindowSurface +class QCocoaBackingStore : public QPlatformBackingStore { public: - QCocoaWindowSurface(QWindow *window, WId wid); - ~QCocoaWindowSurface(); + QCocoaBackingStore(QWindow *window); + ~QCocoaBackingStore(); QPaintDevice *paintDevice(); void flush(QWindow *widget, const QRegion ®ion, const QPoint &offset); - void resize (const QSize &size); + void resize (const QSize &size, const QRegion &); private: QCocoaWindow *m_cocoaWindow; diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm similarity index 86% rename from src/plugins/platforms/cocoa/qcocoawindowsurface.mm rename to src/plugins/platforms/cocoa/qcocoabackingstore.mm index 9a4b42b31e..1cd1fa3776 100644 --- a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qcocoawindowsurface.h" +#include "qcocoabackingstore.h" #include #include @@ -55,10 +55,9 @@ QRect flipedRect(const QRect &sourceRect,int height) return flippedRect; } -QCocoaWindowSurface::QCocoaWindowSurface(QWindow *window, WId wId) - : QWindowSurface(window) +QCocoaBackingStore::QCocoaBackingStore(QWindow *window) + : QPlatformBackingStore(window) { - Q_UNUSED(wId); m_cocoaWindow = static_cast(window->handle()); const QRect geo = window->geometry(); @@ -67,17 +66,17 @@ QCocoaWindowSurface::QCocoaWindowSurface(QWindow *window, WId wId) m_image = new QImage(window->geometry().size(),QImage::Format_ARGB32); } -QCocoaWindowSurface::~QCocoaWindowSurface() +QCocoaBackingStore::~QCocoaBackingStore() { delete m_image; } -QPaintDevice *QCocoaWindowSurface::paintDevice() +QPaintDevice *QCocoaBackingStore::paintDevice() { return m_image; } -void QCocoaWindowSurface::flush(QWindow *widget, const QRegion ®ion, const QPoint &offset) +void QCocoaBackingStore::flush(QWindow *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(widget); Q_UNUSED(offset); @@ -88,9 +87,8 @@ void QCocoaWindowSurface::flush(QWindow *widget, const QRegion ®ion, const QP [m_cocoaWindow->m_windowSurfaceView displayRect:rect]; } -void QCocoaWindowSurface::resize(const QSize &size) +void QCocoaBackingStore::resize(const QSize &size, const QRegion &) { - QWindowSurface::resize(size); delete m_image; m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied); NSSize newSize = NSMakeSize(size.width(),size.height()); diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 59008b4e3f..0100fee1bf 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -79,7 +79,7 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; - QWindowSurface *createWindowSurface(QWindow *widget, WId winId) const; + QPlatformBackingStore *createPlatformBackingStore(QWindow *widget) const; QList screens() const { return mScreens; } diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index c6ace531a9..89aa0033b8 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -42,7 +42,7 @@ #include "qcocoaintegration.h" #include "qcocoawindow.h" -#include "qcocoawindowsurface.h" +#include "qcocoabackingstore.h" #include "qcocoanativeinterface.h" #include @@ -117,9 +117,9 @@ QPlatformGLContext *QCocoaIntegration::createPlatformGLContext(const QGuiGLForma return new QCocoaGLContext(glFormat, share); } -QWindowSurface *QCocoaIntegration::createWindowSurface(QWindow *window, WId winId) const +QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *window) const { - return new QCocoaWindowSurface(window, winId); + return new QCocoaBackingStore(window, winId); } QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 9d7d37c2ee..82fd35ee18 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -76,7 +76,7 @@ public: QCocoaGLContext *currentContext() const; private: - friend class QCocoaWindowSurface; + friend class QCocoaBackingStore; NSWindow *m_nsWindow; QNSView *m_contentView; NSView *m_windowSurfaceView;