From 6ce6b8a378b0d97ba950240ffb048a4b7e485235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 20 Jun 2011 13:29:26 +0200 Subject: Rename QWindowSurface -> QBackingStore and split into platform / public. Also get rid of GL window surface and related classes. --- src/gui/painting/qbackingstore.cpp | 250 +++++++++++++++++++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 src/gui/painting/qbackingstore.cpp (limited to 'src/gui/painting/qbackingstore.cpp') diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp new file mode 100644 index 0000000000..776e33a1a8 --- /dev/null +++ b/src/gui/painting/qbackingstore.cpp @@ -0,0 +1,250 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QBackingStorePrivate +{ +public: + QBackingStorePrivate(QWindow *w) + : window(w) + { + } + + QWindow *window; + QPlatformBackingStore *platformBackingStore; + QRegion staticContents; + QSize size; +}; + +/*! + \class QBackingStore + \since 5.0 + + \brief The QBackingStore class provides the drawing area for top-level windows. +*/ + + +/*! + \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. + + \sa endPaint(), paintDevice() +*/ + +/*! + \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. + + \sa beginPaint(), paintDevice() +*/ + +/*! + \fn void QBackingStore::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. +*/ +void QBackingStore::flush(const QRegion ®ion, QWindow *win, const QPoint &offset) +{ + if (!win) + win = window(); + d_ptr->platformBackingStore->flush(win, region, offset); +} + +/*! + \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. +*/ +QBackingStore::QBackingStore(QWindow *window) + : d_ptr(new QBackingStorePrivate(window)) +{ + d_ptr->platformBackingStore = QGuiApplicationPrivate::platformIntegration()->createPlatformBackingStore(window); +} + +/*! + Destroys this surface. +*/ +QBackingStore::~QBackingStore() +{ + delete d_ptr->platformBackingStore; +} + +/*! + Returns a pointer to the top-level window associated with this + surface. +*/ +QWindow* QBackingStore::window() const +{ + return d_ptr->window; +} + +void QBackingStore::beginPaint(const QRegion ®ion) +{ + d_ptr->platformBackingStore->beginPaint(region); +} + +void QBackingStore::endPaint() +{ + d_ptr->platformBackingStore->endPaint(); +} + +/*! + Sets the size of the windowsurface to be \a size. + + \sa 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 QBackingStore::size() const +{ + return d_ptr->size; +} + +/*! + 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 QBackingStore::scroll(const QRegion &area, int dx, int dy) +{ + Q_UNUSED(area); + Q_UNUSED(dx); + Q_UNUSED(dy); + + return d_ptr->platformBackingStore->scroll(area, dx, dy); +} + +void QBackingStore::setStaticContents(const QRegion ®ion) +{ + d_ptr->staticContents = region; +} + +QRegion QBackingStore::staticContents() const +{ + return d_ptr->staticContents; +} + +bool QBackingStore::hasStaticContents() const +{ + return !d_ptr->staticContents.isEmpty(); +} + +void Q_GUI_EXPORT qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) +{ + // make sure we don't detach + uchar *mem = const_cast(const_cast(img).bits()); + + int lineskip = img.bytesPerLine(); + int depth = img.depth() >> 3; + + const QRect imageRect(0, 0, img.width(), img.height()); + const QRect r = rect & imageRect & imageRect.translated(-offset); + const QPoint p = rect.topLeft() + offset; + + if (r.isEmpty()) + return; + + const uchar *src; + uchar *dest; + + if (r.top() < p.y()) { + src = mem + r.bottom() * lineskip + r.left() * depth; + dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth; + lineskip = -lineskip; + } else { + src = mem + r.top() * lineskip + r.left() * depth; + dest = mem + p.y() * lineskip + p.x() * depth; + } + + const int w = r.width(); + int h = r.height(); + const int bytes = w * depth; + + // overlapping segments? + if (offset.y() == 0 && qAbs(offset.x()) < w) { + do { + ::memmove(dest, src, bytes); + dest += lineskip; + src += lineskip; + } while (--h); + } else { + do { + ::memcpy(dest, src, bytes); + dest += lineskip; + src += lineskip; + } while (--h); + } +} + +QT_END_NAMESPACE -- cgit v1.2.3