diff options
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/painting.pri | 6 | ||||
-rw-r--r-- | src/gui/painting/qbackingstore.cpp (renamed from src/gui/painting/qwindowsurface.cpp) | 187 | ||||
-rw-r--r-- | src/gui/painting/qbackingstore.h | 90 | ||||
-rw-r--r-- | src/gui/painting/qplatformbackingstore_qpa.cpp | 155 | ||||
-rw-r--r-- | src/gui/painting/qplatformbackingstore_qpa.h (renamed from src/gui/painting/qwindowsurface_p.h) | 78 |
5 files changed, 307 insertions, 209 deletions
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 4be0553843..dfc1f88d6d 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -1,6 +1,7 @@ # Qt gui library, paint module HEADERS += \ + painting/qbackingstore.h \ painting/qbezier_p.h \ painting/qbrush.h \ painting/qcolor.h \ @@ -38,11 +39,12 @@ HEADERS += \ painting/qtessellator_p.h \ painting/qtextureglyphcache_p.h \ painting/qtransform.h \ - painting/qwindowsurface_p.h \ + painting/qplatformbackingstore_qpa.h \ painting/qpaintbuffer_p.h SOURCES += \ + painting/qbackingstore.cpp \ painting/qbezier.cpp \ painting/qblendfunctions.cpp \ painting/qbrush.cpp \ @@ -74,7 +76,7 @@ SOURCES += \ painting/qtessellator.cpp \ painting/qtextureglyphcache.cpp \ painting/qtransform.cpp \ - painting/qwindowsurface.cpp \ + painting/qplatformbackingstore_qpa.cpp \ painting/qpaintbuffer.cpp SOURCES += \ diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qbackingstore.cpp index 743621be7b..776e33a1a8 100644 --- a/src/gui/painting/qwindowsurface.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -39,44 +39,40 @@ ** ****************************************************************************/ -#include <private/qwindowsurface_p.h> +#include <qbackingstore.h> #include <qwindow.h> #include <qpixmap.h> +#include <qplatformbackingstore_qpa.h> + +#include <private/qguiapplication_p.h> #include <private/qwindow_p.h> QT_BEGIN_NAMESPACE -class QWindowSurfacePrivate +class QBackingStorePrivate { public: - QWindowSurfacePrivate(QWindow *w) + QBackingStorePrivate(QWindow *w) : window(w) { } QWindow *window; -#if !defined(Q_WS_QPA) - QRect geometry; -#else - QSize size; -#endif //Q_WS_QPA + QPlatformBackingStore *platformBackingStore; QRegion staticContents; + QSize size; }; /*! - \class QWindowSurface - \since 4.3 - \internal - \preliminary - \ingroup qws qpa - - \brief The QWindowSurface class provides the drawing area for top-level - windows. + \class QBackingStore + \since 5.0 + + \brief The QBackingStore class provides the drawing area for top-level windows. */ /*! - \fn void QWindowSurface::beginPaint(const QRegion ®ion) + \fn void QBackingStore::beginPaint(const QRegion ®ion) This function is called before painting onto the surface begins, with the \a region in which the painting will occur. @@ -85,7 +81,7 @@ public: */ /*! - \fn void QWindowSurface::endPaint(const QRegion ®ion) + \fn void QBackingStore::endPaint(const QRegion ®ion) This function is called after painting onto the surface has ended, with the \a region in which the painting was performed. @@ -94,7 +90,7 @@ public: */ /*! - \fn void QWindowSurface::flush(QWindow *window, const QRegion ®ion, + \fn void QBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) Flushes the given \a region from the specified \a window onto the @@ -102,91 +98,77 @@ public: Note that the \a offset parameter is currently unused. */ +void QBackingStore::flush(const QRegion ®ion, QWindow *win, const QPoint &offset) +{ + if (!win) + win = window(); + d_ptr->platformBackingStore->flush(win, region, offset); +} /*! - \fn QPaintDevice* QWindowSurface::paintDevice() + \fn QPaintDevice* QBackingStore::paintDevice() Implement this function to return the appropriate paint device. */ +QPaintDevice *QBackingStore::paintDevice() +{ + return d_ptr->platformBackingStore->paintDevice(); +} /*! Constructs an empty surface for the given top-level \a window. */ -QWindowSurface::QWindowSurface(QWindow *window, bool /*setDefaultSurface*/) - : d_ptr(new QWindowSurfacePrivate(window)) +QBackingStore::QBackingStore(QWindow *window) + : d_ptr(new QBackingStorePrivate(window)) { - if (window) - window->d_func()->surface = this; + d_ptr->platformBackingStore = QGuiApplicationPrivate::platformIntegration()->createPlatformBackingStore(window); } /*! Destroys this surface. */ -QWindowSurface::~QWindowSurface() +QBackingStore::~QBackingStore() { -// if (d_ptr->window) -// d_ptr->window->d_func()->extra->topextra->windowSurface = 0; - delete d_ptr; + delete d_ptr->platformBackingStore; } /*! Returns a pointer to the top-level window associated with this surface. */ -QWindow* QWindowSurface::window() const +QWindow* QBackingStore::window() const { return d_ptr->window; } -void QWindowSurface::beginPaint(const QRegion &) -{ -} - -void QWindowSurface::endPaint(const QRegion &) -{ -} - -#if !defined(Q_WS_QPA) -/*! - Sets the currently allocated area to be the given \a rect. - - This function is called whenever area covered by the top-level - window changes. - - \sa geometry() -*/ -void QWindowSurface::setGeometry(const QRect &rect) +void QBackingStore::beginPaint(const QRegion ®ion) { - d_ptr->geometry = rect; + d_ptr->platformBackingStore->beginPaint(region); } -/*! - Returns the currently allocated area on the screen. -*/ -QRect QWindowSurface::geometry() const +void QBackingStore::endPaint() { - return d_ptr->geometry; + d_ptr->platformBackingStore->endPaint(); } -#else /*! Sets the size of the windowsurface to be \a size. \sa size() */ -void QWindowSurface::resize(const QSize &size) +void QBackingStore::resize(const QSize &size) { d_ptr->size = size; + d_ptr->platformBackingStore->resize(size, d_ptr->staticContents); } /*! Returns the current size of the windowsurface. */ -QSize QWindowSurface::size() const +QSize QBackingStore::size() const { return d_ptr->size; } -#endif //Q_WS_QPA /*! Scrolls the given \a area \a dx pixels to the right and \a dy @@ -194,108 +176,31 @@ QSize QWindowSurface::size() const Returns true if the area was scrolled successfully; false otherwise. */ -bool QWindowSurface::scroll(const QRegion &area, int dx, int dy) +bool QBackingStore::scroll(const QRegion &area, int dx, int dy) { Q_UNUSED(area); Q_UNUSED(dx); Q_UNUSED(dy); - return false; -} - -/*! - Returns a QPixmap generated from the part of the backing store - corresponding to \a window. Returns a null QPixmap if an error - occurs. The contents of the pixmap are only defined for the regions - of \a window that have received paint events since the last resize - of the backing store. - - If \a rectangle is a null rectangle (the default), the entire window - is grabbed. Otherwise, the grabbed area is limited to \a rectangle. - - The default implementation uses QWindowSurface::buffer(). - - \sa QPixmap::grabWindow() -*/ -QPixmap QWindowSurface::grabWindow(const QWindow *, const QRect &) const -{ - QPixmap result; - -#if 0 - if (window->window() != window()) - return result; - - const QImage *img = const_cast<QWindowSurface *>(this)->buffer(window->window()); - - if (!img || img->isNull()) - return result; - - QRect rect = rectangle.isEmpty() ? window->rect() : (window->rect() & rectangle); - - rect.translate(offset(window) - offset(window->window())); - rect &= QRect(QPoint(), img->size()); - - if (rect.isEmpty()) - return result; - - QImage subimg(img->scanLine(rect.y()) + rect.x() * img->depth() / 8, - rect.width(), rect.height(), - img->bytesPerLine(), img->format()); - subimg.detach(); //### expensive -- maybe we should have a real SubImage that shares reference count - - result = QPixmap::fromImage(subimg); -#endif - return result; + return d_ptr->platformBackingStore->scroll(area, dx, dy); } -/*! - Returns the offset of \a window in the coordinates of this - window surface. - */ -QPoint QWindowSurface::offset(const QWindow *) const -{ - QPoint offset; -#if 0 - QWindow *window = d_ptr->window; - QPoint offset = window->mapTo(window, QPoint()); -#endif - return offset; -} - -/*! - \fn QRect QWindowSurface::rect(const QWindow *window) const - - Returns the rectangle for \a window in the coordinates of this - window surface. -*/ - -void QWindowSurface::setStaticContents(const QRegion ®ion) +void QBackingStore::setStaticContents(const QRegion ®ion) { d_ptr->staticContents = region; } -QRegion QWindowSurface::staticContents() const +QRegion QBackingStore::staticContents() const { return d_ptr->staticContents; } -bool QWindowSurface::hasStaticContents() const -{ - return hasFeature(QWindowSurface::StaticContents) && !d_ptr->staticContents.isEmpty(); -} - -QWindowSurface::WindowSurfaceFeatures QWindowSurface::features() const +bool QBackingStore::hasStaticContents() const { - return PartialUpdates | PreservedContents; + return !d_ptr->staticContents.isEmpty(); } -#ifdef Q_WS_QPA -#define Q_EXPORT_SCROLLRECT Q_GUI_EXPORT -#else -#define Q_EXPORT_SCROLLRECT -#endif - -void Q_EXPORT_SCROLLRECT qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) +void Q_GUI_EXPORT qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) { // make sure we don't detach uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits()); diff --git a/src/gui/painting/qbackingstore.h b/src/gui/painting/qbackingstore.h new file mode 100644 index 0000000000..3ab0264b17 --- /dev/null +++ b/src/gui/painting/qbackingstore.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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 QtGui module 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$ +** +****************************************************************************/ + +#ifndef QBACKINGSTORE_H +#define QBACKINGSTORE_H + +#include <QtCore/qrect.h> + +#include <QtGui/qwindow.h> +#include <QtGui/qregion.h> + +QT_BEGIN_NAMESPACE + +class QRegion; +class QRect; +class QPoint; +class QImage; +class QBackingStorePrivate; + +class Q_GUI_EXPORT QBackingStore +{ +public: + QBackingStore(QWindow *window); + ~QBackingStore(); + + QWindow *window() const; + + QPaintDevice *paintDevice(); + + // 'window' can be a child window, in which case 'region' is in child window coordinates and + // offset is the (child) window's offset in relation to the window surface. + void flush(const QRegion ®ion, QWindow *window = 0, const QPoint &offset = QPoint()); + + void resize(const QSize &size); + QSize size() const; + + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion &); + void endPaint(); + + void setStaticContents(const QRegion ®ion); + QRegion staticContents() const; + bool hasStaticContents() const; + +private: + QScopedPointer<QBackingStorePrivate> d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QBACKINGSTORE_H diff --git a/src/gui/painting/qplatformbackingstore_qpa.cpp b/src/gui/painting/qplatformbackingstore_qpa.cpp new file mode 100644 index 0000000000..fa85661f31 --- /dev/null +++ b/src/gui/painting/qplatformbackingstore_qpa.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** 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 QtGui module 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 <qplatformbackingstore_qpa.h> +#include <qwindow.h> +#include <qpixmap.h> +#include <private/qwindow_p.h> + +QT_BEGIN_NAMESPACE + +class QPlatformBackingStorePrivate +{ +public: + QPlatformBackingStorePrivate(QWindow *w) + : window(w) + { + } + + QWindow *window; + QSize size; +}; + +/*! + \class QPlatformBackingStore + \since 5.0 + \internal + \preliminary + \ingroup qpa + + \brief The QPlatformBackingStore class provides the drawing area for top-level + windows. +*/ + + +/*! + \fn void QPlatformBackingStore::beginPaint(const QRegion ®ion) + + This function is called before painting onto the surface begins, + with the \a region in which the painting will occur. + + \sa endPaint(), paintDevice() +*/ + +/*! + \fn void QPlatformBackingStore::endPaint(const QRegion ®ion) + + This function is called after painting onto the surface has ended, + with the \a region in which the painting was performed. + + \sa beginPaint(), paintDevice() +*/ + +/*! + \fn void QPlatformBackingStore::flush(QWindow *window, const QRegion ®ion, + const QPoint &offset) + + Flushes the given \a region from the specified \a window onto the + screen. + + Note that the \a offset parameter is currently unused. +*/ + +/*! + \fn QPaintDevice* QPlatformBackingStore::paintDevice() + + Implement this function to return the appropriate paint device. +*/ + +/*! + Constructs an empty surface for the given top-level \a window. +*/ +QPlatformBackingStore::QPlatformBackingStore(QWindow *window) + : d_ptr(new QPlatformBackingStorePrivate(window)) +{ +} + +/*! + Destroys this surface. +*/ +QPlatformBackingStore::~QPlatformBackingStore() +{ + delete d_ptr; +} + +/*! + Returns a pointer to the top-level window associated with this + surface. +*/ +QWindow* QPlatformBackingStore::window() const +{ + return d_ptr->window; +} + +void QPlatformBackingStore::beginPaint(const QRegion &) +{ +} + +void QPlatformBackingStore::endPaint() +{ +} + +/*! + Scrolls the given \a area \a dx pixels to the right and \a dy + downward; both \a dx and \a dy may be negative. + + Returns true if the area was scrolled successfully; false otherwise. +*/ +bool QPlatformBackingStore::scroll(const QRegion &area, int dx, int dy) +{ + Q_UNUSED(area); + Q_UNUSED(dx); + Q_UNUSED(dy); + + return false; +} + +QT_END_NAMESPACE diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qplatformbackingstore_qpa.h index 068df2e70f..29730167b4 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qplatformbackingstore_qpa.h @@ -39,19 +39,8 @@ ** ****************************************************************************/ -#ifndef QWINDOWSURFACE_P_H -#define QWINDOWSURFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// +#ifndef QPLATFORMBACKINGSTORE_QPA_H +#define QPLATFORMBACKINGSTORE_QPA_H #include <QtCore/qrect.h> @@ -60,81 +49,38 @@ QT_BEGIN_NAMESPACE -class QPaintDevice; class QRegion; class QRect; class QPoint; class QImage; -class QWindowSurfacePrivate; +class QPlatformBackingStorePrivate; class QPlatformWindow; -class Q_GUI_EXPORT QWindowSurface +class Q_GUI_EXPORT QPlatformBackingStore { public: - enum WindowSurfaceFeature { - PartialUpdates = 0x00000001, // Supports doing partial updates. - PreservedContents = 0x00000002, // Supports doing flush without first doing a repaint. - StaticContents = 0x00000004, // Supports having static content regions when being resized. - AllFeatures = 0xffffffff // For convenience - }; - Q_DECLARE_FLAGS(WindowSurfaceFeatures, WindowSurfaceFeature) - - QWindowSurface(QWindow *window, bool setDefaultSurface = true); - virtual ~QWindowSurface(); + QPlatformBackingStore(QWindow *window); + virtual ~QPlatformBackingStore(); QWindow *window() const; virtual QPaintDevice *paintDevice() = 0; // 'window' can be a child window, in which case 'region' is in child window coordinates and - // offset is the (child) window's offset in relation to the window surface. On QWS, 'offset' - // can be larger than just the offset from the top-level window as there may also be window - // decorations which are painted into the window surface. + // offset is the (child) window's offset in relation to the window surface. virtual void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) = 0; -#if !defined(Q_WS_QPA) - virtual void setGeometry(const QRect &rect); - QRect geometry() const; -#else - virtual void resize(const QSize &size); - QSize size() const; - inline QRect geometry() const { return QRect(QPoint(), size()); } //### cleanup before Qt 5 -#endif + + virtual void resize(const QSize &size, const QRegion &staticContents) = 0; virtual bool scroll(const QRegion &area, int dx, int dy); virtual void beginPaint(const QRegion &); - virtual void endPaint(const QRegion &); - - virtual QPixmap grabWindow(const QWindow *window, const QRect& rectangle = QRect()) const; - - virtual QPoint offset(const QWindow *window) const; - inline QRect rect(const QWindow *window) const; - - bool hasFeature(WindowSurfaceFeature feature) const; - virtual WindowSurfaceFeatures features() const; - - void setStaticContents(const QRegion ®ion); - QRegion staticContents() const; - -protected: - bool hasStaticContents() const; + virtual void endPaint(); private: - QWindowSurfacePrivate *d_ptr; + QPlatformBackingStorePrivate *d_ptr; }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowSurface::WindowSurfaceFeatures) - -inline QRect QWindowSurface::rect(const QWindow *window) const -{ - return window->geometry().translated(offset(window)); -} - -inline bool QWindowSurface::hasFeature(WindowSurfaceFeature feature) const -{ - return (features() & feature) != 0; -} - QT_END_NAMESPACE -#endif // QWINDOWSURFACE_P_H +#endif // QPLATFORMBACKINGSTORE_QPA_H |