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: Port Cocoa plugin to new backing store interface. --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 98 +++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/plugins/platforms/cocoa/qcocoabackingstore.mm (limited to 'src/plugins/platforms/cocoa/qcocoabackingstore.mm') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm new file mode 100644 index 0000000000..1cd1fa3776 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoabackingstore.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +QRect flipedRect(const QRect &sourceRect,int height) +{ + if (!sourceRect.isValid()) + return QRect(); + QRect flippedRect = sourceRect; + flippedRect.moveTop(height - sourceRect.y()); + return flippedRect; +} + +QCocoaBackingStore::QCocoaBackingStore(QWindow *window) + : QPlatformBackingStore(window) +{ + m_cocoaWindow = static_cast(window->handle()); + + const QRect geo = window->geometry(); + NSRect rect = NSMakeRect(geo.x(),geo.y(),geo.width(),geo.height()); + + m_image = new QImage(window->geometry().size(),QImage::Format_ARGB32); +} + +QCocoaBackingStore::~QCocoaBackingStore() +{ + delete m_image; +} + +QPaintDevice *QCocoaBackingStore::paintDevice() +{ + return m_image; +} + +void QCocoaBackingStore::flush(QWindow *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + + QRect geo = region.boundingRect(); + + NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height()); + [m_cocoaWindow->m_windowSurfaceView displayRect:rect]; +} + +void QCocoaBackingStore::resize(const QSize &size, const QRegion &) +{ + delete m_image; + m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied); + NSSize newSize = NSMakeSize(size.width(),size.height()); + [m_cocoaWindow->m_windowSurfaceView setImage:m_image]; +} + +QT_END_NAMESPACE -- cgit v1.2.3 From 272daebaa07b21e372ad4274fafb51ce0be92396 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 21 Jun 2011 13:53:21 +0200 Subject: Cocoa: fix compiler warning --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa/qcocoabackingstore.mm') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 1cd1fa3776..1a25608a7a 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -92,7 +92,7 @@ void QCocoaBackingStore::resize(const QSize &size, const QRegion &) delete m_image; m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied); NSSize newSize = NSMakeSize(size.width(),size.height()); - [m_cocoaWindow->m_windowSurfaceView setImage:m_image]; + [static_cast(m_cocoaWindow->m_windowSurfaceView) setImage:m_image]; } QT_END_NAMESPACE -- cgit v1.2.3 From d610fbc13e589b36ce8f1e1af7166d215f0ccc90 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 30 Aug 2011 10:41:54 +0200 Subject: Cocoa: Make the hellowindow opengl example work. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You're not supposed to use NSOpenGLView and NSOpenGLContext at the same time - it's one or the other. Qmlscene worked because it was hitting the raster path that doesn't have a NSOpenGLView. Remove the NSOpenGLView path and m_windowSurfaceView. Change-Id: I10358851a94cd1780a312af09bbb7cf5db8f984f Reviewed-on: http://codereview.qt.nokia.com/3862 Reviewed-by: Qt Sanity Bot Reviewed-by: Gunnar Sletta Reviewed-by: Samuel Rødal --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/cocoa/qcocoabackingstore.mm') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 1a25608a7a..5a59fb5c49 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -84,7 +84,7 @@ void QCocoaBackingStore::flush(QWindow *widget, const QRegion ®ion, const QPo QRect geo = region.boundingRect(); NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height()); - [m_cocoaWindow->m_windowSurfaceView displayRect:rect]; + [m_cocoaWindow->m_contentView displayRect:rect]; } void QCocoaBackingStore::resize(const QSize &size, const QRegion &) @@ -92,7 +92,7 @@ void QCocoaBackingStore::resize(const QSize &size, const QRegion &) delete m_image; m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied); NSSize newSize = NSMakeSize(size.width(),size.height()); - [static_cast(m_cocoaWindow->m_windowSurfaceView) setImage:m_image]; + [static_cast(m_cocoaWindow->m_contentView) setImage:m_image]; } QT_END_NAMESPACE -- cgit v1.2.3