Get rid of unused window surfaces.

This commit is contained in:
Samuel Rødal 2011-05-04 09:12:05 +02:00
parent 2e9fd1325f
commit ea6c6d711b
12 changed files with 1 additions and 1933 deletions

View File

@ -186,22 +186,8 @@ if(mmx|3dnow|sse|sse2|iwmmxt) {
IWMMXT_SOURCES += painting/qdrawhelper_iwmmxt.cpp
}
x11 {
HEADERS += painting/qwindowsurface_x11_p.h
SOURCES += painting/qwindowsurface_x11.cpp
}
!qpa:mac {
HEADERS += painting/qwindowsurface_mac_p.h \
painting/qunifiedtoolbarsurface_mac_p.h
SOURCES += painting/qwindowsurface_mac.cpp \
painting/qunifiedtoolbarsurface_mac.cpp
}
symbian {
HEADERS += painting/qwindowsurface_s60_p.h \
painting/qdrawhelper_arm_simd_p.h
SOURCES += painting/qwindowsurface_s60.cpp
HEADERS += painting/qdrawhelper_arm_simd_p.h
armccIfdefBlock = \
"$${LITERAL_HASH}if defined(ARMV6)" \
"MACRO QT_HAVE_ARM_SIMD" \

View File

@ -53,7 +53,6 @@
#include <QtGui/qgraphicsproxywidget.h>
#include <private/qwidget_p.h>
#include <private/qwindowsurface_raster_p.h>
#include <private/qapplication_p.h>
#include <private/qpaintengine_raster_p.h>
#include <private/qgraphicseffect_p.h>

View File

@ -1,264 +0,0 @@
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qunifiedtoolbarsurface_mac_p.h"
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qbackingstore_p.h>
#include <private/qmainwindowlayout_p.h>
#include <QDebug>
#ifdef QT_MAC_USE_COCOA
QT_BEGIN_NAMESPACE
QUnifiedToolbarSurface::QUnifiedToolbarSurface(QWidget *widget)
: QRasterWindowSurface(widget, false), d_ptr(new QUnifiedToolbarSurfacePrivate)
{
d_ptr->image = 0;
d_ptr->inSetGeometry = false;
setGeometry(QRect(QPoint(0, 0), QSize(widget->width(), 100))); // FIXME: Fix height.
}
QUnifiedToolbarSurface::~QUnifiedToolbarSurface()
{
if (d_ptr->image)
delete d_ptr->image;
}
QPaintDevice *QUnifiedToolbarSurface::paintDevice()
{
return &d_ptr->image->image;
}
void QUnifiedToolbarSurface::recursiveRedirect(QObject *object, QWidget *parent_toolbar, const QPoint &offset)
{
if (object != 0) {
if (object->isWidgetType()) {
QWidget *widget = qobject_cast<QWidget *>(object);
// We redirect the painting only if the widget is in the same window
// and is not a window in itself.
if (!(widget->windowType() & Qt::Window)) {
widget->d_func()->unifiedSurface = this;
widget->d_func()->isInUnifiedToolbar = true;
widget->d_func()->toolbar_offset = offset;
widget->d_func()->toolbar_ancestor = parent_toolbar;
for (int i = 0; i < object->children().size(); ++i) {
recursiveRedirect(object->children().at(i), parent_toolbar, offset);
}
}
}
}
}
void QUnifiedToolbarSurface::insertToolbar(QWidget *toolbar, const QPoint &offset)
{
setGeometry(QRect(QPoint(0, 0), QSize(offset.x() + toolbar->width(), 100))); // FIXME
recursiveRedirect(toolbar, toolbar, offset);
}
// We basically undo what we set in recursiveRedirect().
void QUnifiedToolbarSurface::recursiveRemoval(QObject *object)
{
if (object != 0) {
if (object->isWidgetType()) {
QWidget *widget = qobject_cast<QWidget *>(object);
// If it's a pop-up or something similar, we don't redirect it.
if (widget->windowType() & Qt::Window)
return;
widget->d_func()->unifiedSurface = 0;
widget->d_func()->isInUnifiedToolbar = false;
widget->d_func()->toolbar_offset = QPoint();
widget->d_func()->toolbar_ancestor = 0;
}
for (int i = 0; i < object->children().size(); ++i) {
recursiveRemoval(object->children().at(i));
}
}
}
void QUnifiedToolbarSurface::removeToolbar(QToolBar *toolbar)
{
recursiveRemoval(toolbar);
}
void QUnifiedToolbarSurface::setGeometry(const QRect &rect)
{
QWindowSurface::setGeometry(rect);
Q_D(QUnifiedToolbarSurface);
d->inSetGeometry = true;
if (d->image == 0 || d->image->width() < rect.width() || d->image->height() < rect.height())
prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
d->inSetGeometry = false;
// FIXME: set unified toolbar height.
}
void QUnifiedToolbarSurface::beginPaint(const QRegion &rgn)
{
QPainter p(&d_ptr->image->image);
p.setCompositionMode(QPainter::CompositionMode_Source);
const QVector<QRect> rects = rgn.rects();
const QColor blank = Qt::transparent;
for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
p.fillRect(*it, blank);
}
}
void QUnifiedToolbarSurface::updateToolbarOffset(QWidget *widget)
{
QMainWindowLayout *mlayout = qobject_cast<QMainWindowLayout*> (widget->window()->layout());
mlayout->updateUnifiedToolbarOffset();
}
void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(region);
Q_UNUSED(offset);
this->flush(widget);
}
void QUnifiedToolbarSurface::flush(QWidget *widget)
{
Q_D(QUnifiedToolbarSurface);
if (!d->image)
return;
if (widget->d_func()->flushRequested) {
// We call display: directly to avoid flickering in the toolbar.
qt_mac_display(widget);
}
}
void QUnifiedToolbarSurface::prepareBuffer(QImage::Format format, QWidget *widget)
{
Q_D(QUnifiedToolbarSurface);
int width = geometry().width();
int height = 100; // FIXME
if (d->image) {
width = qMax(d->image->width(), width);
height = qMax(d->image->height(), height);
}
if (width == 0 || height == 0) {
delete d->image;
d->image = 0;
return;
}
QNativeImage *oldImage = d->image;
d->image = new QNativeImage(width, height, format, false, widget);
if (oldImage && d->inSetGeometry && hasStaticContents()) {
// Make sure we use the const version of bits() (no detach).
const uchar *src = const_cast<const QImage &>(oldImage->image).bits();
uchar *dst = d->image->image.bits();
const int srcBytesPerLine = oldImage->image.bytesPerLine();
const int dstBytesPerLine = d->image->image.bytesPerLine();
const int bytesPerPixel = oldImage->image.depth() >> 3;
QRegion staticRegion(staticContents());
// Make sure we're inside the boundaries of the old image.
staticRegion &= QRect(0, 0, oldImage->image.width(), oldImage->image.height());
const QVector<QRect> &rects = staticRegion.rects();
const QRect *srcRect = rects.constData();
// Copy the static content of the old image into the new one.
int numRectsLeft = rects.size();
do {
const int bytesOffset = srcRect->x() * bytesPerPixel;
const int dy = srcRect->y();
// Adjust src and dst to point to the right offset.
const uchar *s = src + dy * srcBytesPerLine + bytesOffset;
uchar *d = dst + dy * dstBytesPerLine + bytesOffset;
const int numBytes = srcRect->width() * bytesPerPixel;
int numScanLinesLeft = srcRect->height();
do {
::memcpy(d, s, numBytes);
d += dstBytesPerLine;
s += srcBytesPerLine;
} while (--numScanLinesLeft);
++srcRect;
} while (--numRectsLeft);
}
delete oldImage;
}
CGContextRef QUnifiedToolbarSurface::imageContext()
{
Q_D(QUnifiedToolbarSurface);
return d->image->cg;
}
void QUnifiedToolbarSurface::renderToolbar(QWidget *widget, bool forceFlush)
{
QWidget *toolbar = widget->d_func()->toolbar_ancestor;
updateToolbarOffset(toolbar);
QRect beginPaintRect(toolbar->d_func()->toolbar_offset.x(), toolbar->d_func()->toolbar_offset.y(), toolbar->geometry().width(), toolbar->geometry().height());
QRegion beginPaintRegion(beginPaintRect);
beginPaint(beginPaintRegion);
toolbar->render(paintDevice(), toolbar->d_func()->toolbar_offset, QRegion(toolbar->geometry()), QWidget::DrawChildren);
toolbar->d_func()->flushRequested = true;
if (forceFlush)
flush(toolbar);
}
QT_END_NAMESPACE
#endif // QT_MAC_USE_COCOA

View File

@ -1,107 +0,0 @@
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QUNIFIEDTOOLBARSURFACE_MAC_P_H
#define QUNIFIEDTOOLBARSURFACE_MAC_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <private/qwindowsurface_raster_p.h>
#include <QWidget>
#include <QToolBar>
#include <private/qwidget_p.h>
#include <private/qnativeimage_p.h>
#ifdef QT_MAC_USE_COCOA
QT_BEGIN_NAMESPACE
class QNativeImage;
class QUnifiedToolbarSurfacePrivate
{
public:
QNativeImage *image;
uint inSetGeometry : 1;
};
class Q_GUI_EXPORT QUnifiedToolbarSurface : public QRasterWindowSurface
{
public:
QUnifiedToolbarSurface(QWidget *widget);
~QUnifiedToolbarSurface();
void flush(QWidget *widget);
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
void setGeometry(const QRect &rect);
void beginPaint(const QRegion &rgn);
void insertToolbar(QWidget *toolbar, const QPoint &offset);
void removeToolbar(QToolBar *toolbar);
void updateToolbarOffset(QWidget *widget);
void renderToolbar(QWidget *widget, bool forceFlush = false);
void recursiveRedirect(QObject *widget, QWidget *parent_toolbar, const QPoint &offset);
QPaintDevice *paintDevice();
CGContextRef imageContext();
private:
void prepareBuffer(QImage::Format format, QWidget *widget);
void recursiveRemoval(QObject *object);
Q_DECLARE_PRIVATE(QUnifiedToolbarSurface)
QScopedPointer<QUnifiedToolbarSurfacePrivate> d_ptr;
};
QT_END_NAMESPACE
#endif // QT_MAC_USE_COCOA
#endif // QUNIFIEDTOOLBARSURFACE_MAC_P_H

View File

@ -1,139 +0,0 @@
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwindowsurface_mac_p.h"
#include <private/qt_mac_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#include <QtGui/qwidget.h>
QT_BEGIN_NAMESPACE
struct QMacWindowSurfacePrivate
{
QWidget *widget;
QPixmap device;
};
QMacWindowSurface::QMacWindowSurface(QWidget *widget)
: QWindowSurface(widget), d_ptr(new QMacWindowSurfacePrivate)
{
d_ptr->widget = widget;
}
QMacWindowSurface::~QMacWindowSurface()
{
delete d_ptr;
}
QPaintDevice *QMacWindowSurface::paintDevice()
{
return &d_ptr->device;
}
void QMacWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
{
Q_UNUSED(offset);
// Get a context for the widget.
#ifndef QT_MAC_USE_COCOA
CGContextRef context;
CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
QDBeginCGContext(port, &context);
#else
extern CGContextRef qt_mac_graphicsContextFor(QWidget *);
CGContextRef context = qt_mac_graphicsContextFor(widget);
#endif
CGContextRetain(context);
CGContextSaveGState(context);
// Flip context.
CGContextTranslateCTM(context, 0, widget->height());
CGContextScaleCTM(context, 1, -1);
// Clip to region.
const QVector<QRect> &rects = rgn.rects();
for (int i = 0; i < rects.size(); ++i) {
const QRect &rect = rects.at(i);
CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
}
CGContextClip(context);
// Draw the image onto the window.
const CGRect dest = CGRectMake(0, 0, widget->width(), widget->height());
const CGImageRef image = d_ptr->device.toMacCGImageRef();
qt_mac_drawCGImage(context, &dest, image);
CFRelease(image);
// Restore context.
CGContextRestoreGState(context);
#ifndef QT_MAC_USE_COCOA
QDEndCGContext(port, &context);
#else
CGContextFlush(context);
#endif
CGContextRelease(context);
}
void QMacWindowSurface::setGeometry(const QRect &rect)
{
QWindowSurface::setGeometry(rect);
const QSize size = rect.size();
if (d_ptr->device.size() != size)
d_ptr->device = QPixmap(size);
}
bool QMacWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
if (d_ptr->device.size().isNull())
return false;
QCFType<CGImageRef> image = d_ptr->device.toMacCGImageRef();
const QRect rect(area.boundingRect());
const CGRect dest = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
QCFType<CGImageRef> subimage = CGImageCreateWithImageInRect(image, dest);
QCFType<CGContextRef> context = qt_mac_cg_context(&d_ptr->device);
CGContextTranslateCTM(context, dx, dy);
qt_mac_drawCGImage(context, &dest, subimage);
return true;
}
QT_END_NAMESPACE

View File

@ -1,84 +0,0 @@
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWINDOWSURFACE_MAC_P_H
#define QWINDOWSURFACE_MAC_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.
//
#include <qglobal.h>
#include "private/qwindowsurface_p.h"
QT_BEGIN_NAMESPACE
class QPaintDevice;
class QPoint;
class QRegion;
class QWidget;
struct QMacWindowSurfacePrivate;
class QMacWindowSurface : public QWindowSurface
{
public:
QMacWindowSurface(QWidget *widget);
~QMacWindowSurface();
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
void setGeometry(const QRect &rect);
bool scroll(const QRegion &area, int dx, int dy);
private:
QMacWindowSurfacePrivate *d_ptr;
};
QT_END_NAMESPACE
#endif // QWINDOWSURFACE_MAC_P_H

View File

@ -1,487 +0,0 @@
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <qdebug.h>
#include <qglobal.h> // for Q_WS_WIN define (non-PCH)
#ifdef Q_WS_WIN
#include <qlibrary.h>
#include <qt_windows.h>
#endif
#include <QtGui/qpaintdevice.h>
#include <QtGui/qwidget.h>
#include "private/qwindowsurface_raster_p.h"
#include "private/qnativeimage_p.h"
#include "private/qwidget_p.h"
#ifdef Q_WS_X11
#include "private/qpixmap_x11_p.h"
#include "private/qt_x11_p.h"
#include "private/qwidget_p.h"
#include "qx11info_x11.h"
#endif
#include "private/qdrawhelper_p.h"
#ifdef Q_WS_MAC
#include <private/qt_cocoa_helpers_mac_p.h>
#include <QMainWindow>
#include <private/qmainwindowlayout_p.h>
#include <QToolBar>
#endif
QT_BEGIN_NAMESPACE
class QRasterWindowSurfacePrivate
{
public:
QNativeImage *image;
#ifdef Q_WS_X11
GC gc;
#ifndef QT_NO_MITSHM
uint needsSync : 1;
#endif
#ifndef QT_NO_XRENDER
uint translucentBackground : 1;
#endif
#endif
uint inSetGeometry : 1;
};
QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurface)
: QWindowSurface(window, setDefaultSurface), d_ptr(new QRasterWindowSurfacePrivate)
{
#ifdef Q_WS_X11
d_ptr->gc = XCreateGC(X11->display, window->handle(), 0, 0);
#ifndef QT_NO_XRENDER
d_ptr->translucentBackground = X11->use_xrender
&& window->x11Info().depth() == 32;
#endif
#ifndef QT_NO_MITHSM
d_ptr->needsSync = false;
#endif
#endif
d_ptr->image = 0;
d_ptr->inSetGeometry = false;
#ifdef QT_MAC_USE_COCOA
needsFlush = false;
regionToFlush = QRegion();
#endif // QT_MAC_USE_COCOA
}
QRasterWindowSurface::~QRasterWindowSurface()
{
#ifdef Q_WS_X11
XFreeGC(X11->display, d_ptr->gc);
#endif
if (d_ptr->image)
delete d_ptr->image;
}
QPaintDevice *QRasterWindowSurface::paintDevice()
{
return &d_ptr->image->image;
}
#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
void QRasterWindowSurface::syncX()
{
// delay writing to the backbuffer until we know for sure X is done reading from it
if (d_ptr->needsSync) {
XSync(X11->display, false);
d_ptr->needsSync = false;
}
}
#endif
void QRasterWindowSurface::beginPaint(const QRegion &rgn)
{
#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
syncX();
#endif
#if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE))
if (!qt_widget_private(window())->isOpaque && window()->testAttribute(Qt::WA_TranslucentBackground)) {
#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
if (d_ptr->image->image.format() != QImage::Format_ARGB32_Premultiplied)
prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
#endif
QPainter p(&d_ptr->image->image);
p.setCompositionMode(QPainter::CompositionMode_Source);
const QVector<QRect> rects = rgn.rects();
const QColor blank = Qt::transparent;
for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
p.fillRect(*it, blank);
}
}
#else
Q_UNUSED(rgn);
#endif
}
void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
{
Q_D(QRasterWindowSurface);
// Not ready for painting yet, bail out. This can happen in
// QWidget::create_sys()
if (!d->image || rgn.rectCount() == 0)
return;
#ifdef Q_WS_WIN
QRect br = rgn.boundingRect();
#ifndef Q_WS_WINCE
if (!qt_widget_private(window())->isOpaque
&& window()->testAttribute(Qt::WA_TranslucentBackground)
&& (qt_widget_private(window())->data.window_flags & Qt::FramelessWindowHint))
{
QRect r = window()->frameGeometry();
QPoint frameOffset = qt_widget_private(window())->frameStrut().topLeft();
QRect dirtyRect = br.translated(offset + frameOffset);
SIZE size = {r.width(), r.height()};
POINT ptDst = {r.x(), r.y()};
POINT ptSrc = {0, 0};
BLENDFUNCTION blend = {AC_SRC_OVER, 0, (int)(255.0 * window()->windowOpacity()), Q_AC_SRC_ALPHA};
RECT dirty = {dirtyRect.x(), dirtyRect.y(),
dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()};
Q_UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, &ptDst, &size, d->image->hdc, &ptSrc, 0, &blend, Q_ULW_ALPHA, &dirty};
ptrUpdateLayeredWindowIndirect(window()->internalWinId(), &info);
} else
#endif
{
QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
HDC widget_dc = widget->getDC();
QRect wbr = br.translated(-wOffset);
BitBlt(widget_dc, wbr.x(), wbr.y(), wbr.width(), wbr.height(),
d->image->hdc, br.x() + offset.x(), br.y() + offset.y(), SRCCOPY);
widget->releaseDC(widget_dc);
}
#ifndef QT_NO_DEBUG
static bool flush = !qgetenv("QT_FLUSH_WINDOWSURFACE").isEmpty();
if (flush) {
SelectObject(qt_win_display_dc(), GetStockObject(BLACK_BRUSH));
Rectangle(qt_win_display_dc(), 0, 0, d->image->width() + 2, d->image->height() + 2);
BitBlt(qt_win_display_dc(), 1, 1, d->image->width(), d->image->height(),
d->image->hdc, 0, 0, SRCCOPY);
}
#endif
#endif
#ifdef Q_WS_X11
extern void *qt_getClipRects(const QRegion &r, int &num); // in qpaintengine_x11.cpp
extern QWidgetData* qt_widget_data(QWidget *);
QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
if (widget->window() != window()) {
XFreeGC(X11->display, d_ptr->gc);
d_ptr->gc = XCreateGC(X11->display, widget->handle(), 0, 0);
}
QRegion wrgn(rgn);
if (!wOffset.isNull())
wrgn.translate(-wOffset);
QRect wbr = wrgn.boundingRect();
if (wrgn.rectCount() != 1) {
int num;
XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
XSetClipRectangles(X11->display, d_ptr->gc, 0, 0, rects, num, YXBanded);
}
QRect br = rgn.boundingRect().translated(offset);
#ifndef QT_NO_MITSHM
if (d_ptr->image->xshmpm) {
XCopyArea(X11->display, d_ptr->image->xshmpm, widget->handle(), d_ptr->gc,
br.x(), br.y(), br.width(), br.height(), wbr.x(), wbr.y());
d_ptr->needsSync = true;
} else if (d_ptr->image->xshmimg) {
const QImage &src = d->image->image;
br = br.intersected(src.rect());
XShmPutImage(X11->display, widget->handle(), d_ptr->gc, d_ptr->image->xshmimg,
br.x(), br.y(), wbr.x(), wbr.y(), br.width(), br.height(), False);
d_ptr->needsSync = true;
} else
#endif
{
const QImage &src = d->image->image;
br = br.intersected(src.rect());
if (src.format() != QImage::Format_RGB32 || widget->x11Info().depth() < 24) {
Q_ASSERT(src.depth() >= 16);
const QImage sub_src(src.scanLine(br.y()) + br.x() * (uint(src.depth()) / 8),
br.width(), br.height(), src.bytesPerLine(), src.format());
QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
data->xinfo = widget->x11Info();
data->fromImage(sub_src, Qt::NoOpaqueDetection);
QPixmap pm = QPixmap(data);
XCopyArea(X11->display, pm.handle(), widget->handle(), d_ptr->gc, 0 , 0 , br.width(), br.height(), wbr.x(), wbr.y());
} else {
// qpaintengine_x11.cpp
extern void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth);
qt_x11_drawImage(br, wbr.topLeft(), src, widget->handle(), d_ptr->gc, X11->display, (Visual *)widget->x11Info().visual(), widget->x11Info().depth());
}
}
if (wrgn.rectCount() != 1)
XSetClipMask(X11->display, d_ptr->gc, XNone);
#endif // FALCON
#ifdef Q_WS_MAC
Q_UNUSED(offset);
// This is mainly done for native components like native "open file" dialog.
if (widget->testAttribute(Qt::WA_DontShowOnScreen)) {
return;
}
#ifdef QT_MAC_USE_COCOA
this->needsFlush = true;
this->regionToFlush += rgn;
// The actual flushing will be processed in [view drawRect:rect]
qt_mac_setNeedsDisplay(widget);
#else
// Get a context for the widget.
CGContextRef context;
CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
QDBeginCGContext(port, &context);
CGContextRetain(context);
CGContextSaveGState(context);
// Flip context.
CGContextTranslateCTM(context, 0, widget->height());
CGContextScaleCTM(context, 1, -1);
// Clip to region.
const QVector<QRect> &rects = rgn.rects();
for (int i = 0; i < rects.size(); ++i) {
const QRect &rect = rects.at(i);
CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
}
CGContextClip(context);
QRect r = rgn.boundingRect();
const CGRect area = CGRectMake(r.x(), r.y(), r.width(), r.height());
CGImageRef image = CGBitmapContextCreateImage(d->image->cg);
CGImageRef subImage = CGImageCreateWithImageInRect(image, area);
qt_mac_drawCGImage(context, &area, subImage);
CGImageRelease(subImage);
CGImageRelease(image);
QDEndCGContext(port, &context);
// Restore context.
CGContextRestoreGState(context);
CGContextRelease(context);
#endif // QT_MAC_USE_COCOA
#endif // Q_WS_MAC
#ifdef Q_OS_SYMBIAN
Q_UNUSED(widget);
Q_UNUSED(rgn);
Q_UNUSED(offset);
#endif
}
void QRasterWindowSurface::setGeometry(const QRect &rect)
{
QWindowSurface::setGeometry(rect);
Q_D(QRasterWindowSurface);
d->inSetGeometry = true;
if (d->image == 0 || d->image->width() < rect.width() || d->image->height() < rect.height()) {
#if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE))
#ifndef Q_WS_WIN
if (d_ptr->translucentBackground)
#else
if (!qt_widget_private(window())->isOpaque)
#endif
prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
else
#endif
prepareBuffer(QNativeImage::systemFormat(), window());
}
d->inSetGeometry = false;
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
QMainWindow* mWindow = qobject_cast<QMainWindow*>(window());
if (mWindow) {
QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout());
QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList;
for (int i = 0; i < toolbarList.size(); ++i) {
QToolBar* toolbar = toolbarList.at(i);
if (mLayout->toolBarArea(toolbar) == Qt::TopToolBarArea) {
QWidget* tbWidget = (QWidget*) toolbar;
if (tbWidget->d_func()->unifiedSurface) {
tbWidget->d_func()->unifiedSurface->setGeometry(rect);
}
}
}
}
#endif // Q_WS_MAC && QT_MAC_USE_COCOA
}
// from qwindowsurface.cpp
extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
bool QRasterWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
#ifdef Q_WS_WIN
Q_D(QRasterWindowSurface);
if (!d->image || !d->image->hdc)
return false;
QRect rect = area.boundingRect();
BitBlt(d->image->hdc, rect.x()+dx, rect.y()+dy, rect.width(), rect.height(),
d->image->hdc, rect.x(), rect.y(), SRCCOPY);
return true;
#else
Q_D(QRasterWindowSurface);
if (!d->image || d->image->image.isNull())
return false;
#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
syncX();
#endif
const QVector<QRect> rects = area.rects();
for (int i = 0; i < rects.size(); ++i)
qt_scrollRectInImage(d->image->image, rects.at(i), QPoint(dx, dy));
return true;
#endif
}
QWindowSurface::WindowSurfaceFeatures QRasterWindowSurface::features() const
{
return QWindowSurface::AllFeatures;
}
void QRasterWindowSurface::prepareBuffer(QImage::Format format, QWidget *widget)
{
Q_D(QRasterWindowSurface);
int width = window()->width();
int height = window()->height();
if (d->image) {
width = qMax(d->image->width(), width);
height = qMax(d->image->height(), height);
}
if (width == 0 || height == 0) {
delete d->image;
d->image = 0;
return;
}
QNativeImage *oldImage = d->image;
d->image = new QNativeImage(width, height, format, false, widget);
if (oldImage && d->inSetGeometry && hasStaticContents()) {
// Make sure we use the const version of bits() (no detach).
const uchar *src = const_cast<const QImage &>(oldImage->image).bits();
uchar *dst = d->image->image.bits();
const int srcBytesPerLine = oldImage->image.bytesPerLine();
const int dstBytesPerLine = d->image->image.bytesPerLine();
const int bytesPerPixel = oldImage->image.depth() >> 3;
QRegion staticRegion(staticContents());
// Make sure we're inside the boundaries of the old image.
staticRegion &= QRect(0, 0, oldImage->image.width(), oldImage->image.height());
const QVector<QRect> &rects = staticRegion.rects();
const QRect *srcRect = rects.constData();
// Copy the static content of the old image into the new one.
int numRectsLeft = rects.size();
do {
const int bytesOffset = srcRect->x() * bytesPerPixel;
const int dy = srcRect->y();
// Adjust src and dst to point to the right offset.
const uchar *s = src + dy * srcBytesPerLine + bytesOffset;
uchar *d = dst + dy * dstBytesPerLine + bytesOffset;
const int numBytes = srcRect->width() * bytesPerPixel;
int numScanLinesLeft = srcRect->height();
do {
::memcpy(d, s, numBytes);
d += dstBytesPerLine;
s += srcBytesPerLine;
} while (--numScanLinesLeft);
++srcRect;
} while (--numRectsLeft);
}
delete oldImage;
}
#ifdef QT_MAC_USE_COCOA
CGContextRef QRasterWindowSurface::imageContext()
{
Q_D(QRasterWindowSurface);
return d->image->cg;
}
#endif // QT_MAC_USE_COCOA
QT_END_NAMESPACE

View File

@ -1,132 +0,0 @@
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWINDOWSURFACE_RASTER_P_H
#define QWINDOWSURFACE_RASTER_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of the QLibrary class. This header file may change from
// version to version without notice, or even be removed.
//
// We mean it.
//
#include <qglobal.h>
#include "private/qwindowsurface_p.h"
#ifdef QT_MAC_USE_COCOA
# include <private/qt_cocoa_helpers_mac_p.h>
#endif // QT_MAC_USE_COCOA
QT_BEGIN_NAMESPACE
#ifdef Q_WS_WIN
#define Q_WS_EX_LAYERED 0x00080000 // copied from WS_EX_LAYERED in winuser.h
#define Q_LWA_ALPHA 0x00000002 // copied from LWA_ALPHA in winuser.h
#define Q_ULW_ALPHA 0x00000002 // copied from ULW_ALPHA in winuser.h
#define Q_AC_SRC_ALPHA 0x00000001 // copied from AC_SRC_ALPHA in winuser.h
struct Q_UPDATELAYEREDWINDOWINFO {
DWORD cbSize;
HDC hdcDst;
const POINT *pptDst;
const SIZE *psize;
HDC hdcSrc;
const POINT *pptSrc;
COLORREF crKey;
const BLENDFUNCTION *pblend;
DWORD dwFlags;
const RECT *prcDirty;
};
typedef BOOL (WINAPI *PtrUpdateLayeredWindow)(HWND hwnd, HDC hdcDst, const POINT *pptDst,
const SIZE *psize, HDC hdcSrc, const POINT *pptSrc, COLORREF crKey,
const BLENDFUNCTION *pblend, DWORD dwflags);
typedef BOOL (WINAPI *PtrUpdateLayeredWindowIndirect)(HWND hwnd, const Q_UPDATELAYEREDWINDOWINFO *pULWInfo);
extern PtrUpdateLayeredWindow ptrUpdateLayeredWindow;
extern PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect;
#endif
class QPaintDevice;
class QPoint;
class QRegion;
class QRegion;
class QSize;
class QWidget;
class QRasterWindowSurfacePrivate;
class QNativeImage;
class Q_GUI_EXPORT QRasterWindowSurface : public QWindowSurface
{
public:
QRasterWindowSurface(QWidget *widget, bool setDefaultSurface = true);
~QRasterWindowSurface();
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
void beginPaint(const QRegion &rgn);
void setGeometry(const QRect &rect);
bool scroll(const QRegion &area, int dx, int dy);
WindowSurfaceFeatures features() const;
#ifdef QT_MAC_USE_COCOA
CGContextRef imageContext();
bool needsFlush;
QRegion regionToFlush;
#endif // QT_MAC_USE_COCOA
private:
#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
void syncX();
#endif
void prepareBuffer(QImage::Format format, QWidget *widget);
Q_DECLARE_PRIVATE(QRasterWindowSurface)
QScopedPointer<QRasterWindowSurfacePrivate> d_ptr;
};
QT_END_NAMESPACE
#endif // QWINDOWSURFACE_RASTER_P_H

View File

@ -1,254 +0,0 @@
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <qglobal.h> // for Q_WS_WIN define (non-PCH)
#include <QtGui/qpaintdevice.h>
#include <private/qwidget_p.h>
#include <private/qwindowsurface_s60_p.h>
#include <private/qpixmap_s60_p.h>
#include <private/qt_s60_p.h>
#include <private/qapplication_p.h>
#include <private/qdrawhelper_p.h>
#ifdef QT_GRAPHICSSYSTEM_RUNTIME
#include <private/qgraphicssystem_runtime_p.h>
#endif
QT_BEGIN_NAMESPACE
struct QS60WindowSurfacePrivate
{
QPixmap device;
QList<QImage*> bufferImages;
};
TDisplayMode displayMode(bool opaque)
{
TDisplayMode mode = S60->screenDevice()->DisplayMode();
if (opaque) {
mode = EColor16MU;
} else {
if (QSysInfo::symbianVersion() >= QSysInfo::SV_SF_3)
mode = Q_SYMBIAN_ECOLOR16MAP; // Symbian^3 WServ has support for ARGB32_PRE
else
mode = EColor16MA; // Symbian prior to Symbian^3 sw accelerates EColor16MA
}
return mode;
}
bool blitWriteAlpha(QWidgetPrivate *widgetPrivate)
{
QWExtra *extra = widgetPrivate->extraData();
return extra ? extra->nativePaintMode == QWExtra::BlitWriteAlpha : false;
}
QS60WindowSurface::QS60WindowSurface(QWidget* widget)
: QWindowSurface(widget), d_ptr(new QS60WindowSurfacePrivate)
{
QWidgetPrivate *widgetPrivate = qt_widget_private(widget);
const bool opaque = widgetPrivate->isOpaque && !blitWriteAlpha(widgetPrivate);
TDisplayMode mode = displayMode(opaque);
// We create empty CFbsBitmap here -> it will be resized in setGeometry
CFbsBitmap *bitmap = new CFbsBitmap; // CBase derived object needs check on new
Q_CHECK_PTR(bitmap);
qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) );
QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType);
if (data) {
data->fromSymbianBitmap(bitmap, true);
d_ptr->device = QPixmap(data);
}
}
QS60WindowSurface::~QS60WindowSurface()
{
#if defined(QT_GRAPHICSSYSTEM_RUNTIME) && defined(Q_SYMBIAN_SUPPORTS_SURFACES)
if(QApplicationPrivate::runtime_graphics_system) {
QRuntimeGraphicsSystem *runtimeGraphicsSystem =
static_cast<QRuntimeGraphicsSystem*>(QApplicationPrivate::graphics_system);
if(runtimeGraphicsSystem->graphicsSystemName() == QLatin1String("openvg")) {
// Graphics system has been switched from raster to openvg.
// Issue empty redraw to clear the UI surface
QWidget *w = window();
if (w->testAttribute(Qt::WA_WState_Created)) {
RWindow *const window = static_cast<RWindow *>(w->winId()->DrawableWindow());
window->BeginRedraw();
window->EndRedraw();
}
}
}
#endif
delete d_ptr;
}
void QS60WindowSurface::beginPaint(const QRegion &rgn)
{
#ifdef Q_SYMBIAN_SUPPORTS_SURFACES
S60->wsSession().Finish();
#endif
QWidgetPrivate *windowPrivate = qt_widget_private(window());
if (!windowPrivate->isOpaque || blitWriteAlpha(windowPrivate)) {
QS60PixmapData *pixmapData = static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data());
TDisplayMode mode = displayMode(false);
if (pixmapData->cfbsBitmap->DisplayMode() != mode)
pixmapData->convertToDisplayMode(mode);
pixmapData->beginDataAccess();
if (!windowPrivate->isOpaque) {
QPainter p(&pixmapData->image);
p.setCompositionMode(QPainter::CompositionMode_Source);
const QVector<QRect> rects = rgn.rects();
const QColor blank = Qt::transparent;
for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
p.fillRect(*it, blank);
}
}
pixmapData->endDataAccess();
}
}
void QS60WindowSurface::endPaint(const QRegion &)
{
qDeleteAll(d_ptr->bufferImages);
d_ptr->bufferImages.clear();
}
QImage* QS60WindowSurface::buffer(const QWidget *widget)
{
if (widget->window() != window())
return 0;
QPaintDevice *pdev = paintDevice();
if (!pdev)
return 0;
const QPoint off = offset(widget);
QImage *img = &(static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data())->image);
QRect rect(off, widget->size());
rect &= QRect(QPoint(), img->size());
if (rect.isEmpty())
return 0;
img = new QImage(img->scanLine(rect.y()) + rect.x() * img->depth() / 8,
rect.width(), rect.height(),
img->bytesPerLine(), img->format());
d_ptr->bufferImages.append(img);
return img;
}
void QS60WindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &)
{
QWidget *window = widget->window();
Q_ASSERT(window);
QTLWExtra *topExtra = window->d_func()->maybeTopData();
Q_ASSERT(topExtra);
QRect qr = region.boundingRect();
if (!topExtra->inExpose) {
topExtra->inExpose = true; // Prevent DrawNow() from calling syncBackingStore() again
TRect tr = qt_QRect2TRect(qr);
widget->winId()->DrawNow(tr);
topExtra->inExpose = false;
} else {
// This handles the case when syncBackingStore updates content outside of the
// original drawing rectangle. This might happen if there are pending update()
// events at the same time as we get a Draw() from Symbian.
QRect drawRect = qt_TRect2QRect(widget->winId()->DrawableWindow()->GetDrawRect());
if (!drawRect.contains(qr))
widget->winId()->DrawDeferred();
}
}
bool QS60WindowSurface::scroll(const QRegion &area, int dx, int dy)
{
QRect rect = area.boundingRect();
if (dx == 0 && dy == 0)
return false;
if (d_ptr->device.isNull())
return false;
QS60PixmapData *data = static_cast<QS60PixmapData*>(d_ptr->device.data_ptr().data());
data->scroll(dx, dy, rect);
return true;
}
QPaintDevice* QS60WindowSurface::paintDevice()
{
return &d_ptr->device;
}
void QS60WindowSurface::setGeometry(const QRect& rect)
{
if (rect == geometry())
return;
QS60PixmapData *data = static_cast<QS60PixmapData*>(d_ptr->device.data_ptr().data());
data->resize(rect.width(), rect.height());
QWindowSurface::setGeometry(rect);
}
QWindowSurface::WindowSurfaceFeatures QS60WindowSurface::features() const
{
return QWindowSurface::AllFeatures;
}
CFbsBitmap* QS60WindowSurface::symbianBitmap() const
{
QS60PixmapData *data = static_cast<QS60PixmapData*>(d_ptr->device.data_ptr().data());
return data->cfbsBitmap;
}
QT_END_NAMESPACE

View File

@ -1,93 +0,0 @@
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWINDOWSURFACE_S60_P_H
#define QWINDOWSURFACE_S60_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.
//
#include <qglobal.h>
#include "private/qwindowsurface_p.h"
class CFbsBitmap;
QT_BEGIN_NAMESPACE
struct QS60WindowSurfacePrivate;
class QS60WindowSurface : public QWindowSurface
{
public:
QS60WindowSurface(QWidget *widget);
~QS60WindowSurface();
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
bool scroll(const QRegion &area, int dx, int dy);
void beginPaint(const QRegion &);
void endPaint(const QRegion &);
QImage* buffer(const QWidget *widget);
void setGeometry(const QRect &rect);
WindowSurfaceFeatures features() const;
CFbsBitmap *symbianBitmap() const;
private:
QS60WindowSurfacePrivate* d_ptr;
};
QT_END_NAMESPACE
#endif // QWINDOWSURFACE_S60_P_H

View File

@ -1,265 +0,0 @@
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtGui/QPaintDevice>
#include <QtGui/QPainter>
#include <QtGui/QPixmap>
#include <QtGui/QWidget>
#include "private/qt_x11_p.h"
#include "private/qpixmap_x11_p.h"
#include "private/qwidget_p.h"
#include "qx11info_x11.h"
#include "qwindowsurface_x11_p.h"
QT_BEGIN_NAMESPACE
extern void *qt_getClipRects(const QRegion &r, int &num); // in qpaintengine_x11.cpp
struct QX11WindowSurfacePrivate
{
QWidget *widget;
QPixmap device;
#ifndef QT_NO_XRENDER
bool translucentBackground;
#endif
};
QX11WindowSurface::QX11WindowSurface(QWidget *widget)
: QWindowSurface(widget), d_ptr(new QX11WindowSurfacePrivate), gc(0)
{
d_ptr->widget = widget;
#ifndef QT_NO_XRENDER
d_ptr->translucentBackground = X11->use_xrender
&& widget->x11Info().depth() == 32;
#endif
}
QX11WindowSurface::~QX11WindowSurface()
{
delete d_ptr;
if (gc) {
XFreeGC(X11->display, gc);
gc = 0;
}
}
QPaintDevice *QX11WindowSurface::paintDevice()
{
return &d_ptr->device;
}
void QX11WindowSurface::beginPaint(const QRegion &rgn)
{
#ifndef QT_NO_XRENDER
Q_ASSERT(!d_ptr->device.isNull());
if (d_ptr->translucentBackground) {
if (d_ptr->device.depth() != 32)
static_cast<QX11PixmapData *>(d_ptr->device.data_ptr().data())->convertToARGB32();
::Picture src = X11->getSolidFill(d_ptr->device.x11Info().screen(), Qt::transparent);
::Picture dst = d_ptr->device.x11PictureHandle();
const QVector<QRect> rects = rgn.rects();
const int w = d_ptr->device.width();
const int h = d_ptr->device.height();
for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it)
XRenderComposite(X11->display, PictOpSrc, src, 0, dst,
0, 0, w, h, it->x(), it->y(),
it->width(), it->height());
}
#endif
}
void QX11WindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
{
if (d_ptr->device.isNull())
return;
QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
QRegion wrgn(rgn);
QRect br = rgn.boundingRect();
if (!wOffset.isNull())
wrgn.translate(-wOffset);
QRect wbr = wrgn.boundingRect();
int num;
XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
if (num <= 0)
return;
// qDebug() << "XSetClipRectangles";
// for (int i = 0; i < num; ++i)
// qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height;
if (num != 1)
XSetClipRectangles(X11->display, gc, 0, 0, rects, num, YXBanded);
XCopyArea(X11->display, d_ptr->device.handle(), widget->handle(), gc,
br.x() + offset.x(), br.y() + offset.y(), br.width(), br.height(), wbr.x(), wbr.y());
if (num != 1)
XSetClipMask(X11->display, gc, XNone);
}
void QX11WindowSurface::setGeometry(const QRect &rect)
{
QWindowSurface::setGeometry(rect);
const QSize size = rect.size();
if (d_ptr->device.size() == size || size.width() <= 0 || size.height() <= 0)
return;
#ifndef QT_NO_XRENDER
if (d_ptr->translucentBackground) {
QPixmap::x11SetDefaultScreen(d_ptr->widget->x11Info().screen());
QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
data->xinfo = d_ptr->widget->x11Info();
data->resize(size.width(), size.height());
d_ptr->device = QPixmap(data);
} else
#endif
{
QPixmap::x11SetDefaultScreen(d_ptr->widget->x11Info().screen());
QX11PixmapData *oldData = static_cast<QX11PixmapData *>(d_ptr->device.pixmapData());
if (oldData && !(oldData->flags & QX11PixmapData::Uninitialized) && hasStaticContents()) {
// Copy the content of the old pixmap into the new one.
QX11PixmapData *newData = new QX11PixmapData(QPixmapData::PixmapType);
newData->resize(size.width(), size.height());
Q_ASSERT(oldData->d == newData->d);
QRegion staticRegion(staticContents());
// Make sure we're inside the boundaries of the old pixmap.
staticRegion &= QRect(0, 0, oldData->w, oldData->h);
const QRect boundingRect(staticRegion.boundingRect());
const int dx = boundingRect.x();
const int dy = boundingRect.y();
int num;
XRectangle *rects = (XRectangle *)qt_getClipRects(staticRegion, num);
GC tmpGc = XCreateGC(X11->display, oldData->hd, 0, 0);
XSetClipRectangles(X11->display, tmpGc, 0, 0, rects, num, YXBanded);
XCopyArea(X11->display, oldData->hd, newData->hd, tmpGc,
dx, dy, qMin(boundingRect.width(), size.width()),
qMin(boundingRect.height(), size.height()), dx, dy);
XFreeGC(X11->display, tmpGc);
newData->flags &= ~QX11PixmapData::Uninitialized;
d_ptr->device = QPixmap(newData);
} else {
d_ptr->device = QPixmap(size);
}
}
if (gc) {
XFreeGC(X11->display, gc);
gc = 0;
}
if (!d_ptr->device.isNull()) {
gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0);
XSetGraphicsExposures(X11->display, gc, False);
}
}
bool QX11WindowSurface::scroll(const QRegion &area, int dx, int dy)
{
QRect rect = area.boundingRect();
if (d_ptr->device.isNull())
return false;
GC gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0);
XCopyArea(X11->display, d_ptr->device.handle(), d_ptr->device.handle(), gc,
rect.x(), rect.y(), rect.width(), rect.height(),
rect.x()+dx, rect.y()+dy);
XFreeGC(X11->display, gc);
return true;
}
QPixmap QX11WindowSurface::grabWidget(const QWidget *widget,
const QRect& rect) const
{
if (!widget || d_ptr->device.isNull())
return QPixmap();
QRect srcRect;
// make sure the rect is inside the widget & clip to widget's rect
if (!rect.isEmpty())
srcRect = rect & widget->rect();
else
srcRect = widget->rect();
if (srcRect.isEmpty())
return QPixmap();
// If it's a child widget we have to translate the coordinates
if (widget != window())
srcRect.translate(widget->mapTo(window(), QPoint(0, 0)));
QPixmap::x11SetDefaultScreen(widget->x11Info().screen());
QPixmap px(srcRect.width(), srcRect.height());
GC tmpGc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0);
// Copy srcRect from the backing store to the new pixmap
XSetGraphicsExposures(X11->display, tmpGc, False);
XCopyArea(X11->display, d_ptr->device.handle(), px.handle(), tmpGc,
srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height(), 0, 0);
XFreeGC(X11->display, tmpGc);
return px;
}
QWindowSurface::WindowSurfaceFeatures QX11WindowSurface::features() const
{
WindowSurfaceFeatures features = QWindowSurface::PartialUpdates | QWindowSurface::PreservedContents;
#ifndef QT_NO_XRENDER
if (!d_ptr->translucentBackground)
features |= QWindowSurface::StaticContents;
#else
features |= QWindowSurface::StaticContents;
#endif
return features;
}
QT_END_NAMESPACE

View File

@ -1,92 +0,0 @@
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWINDOWSURFACE_X11_P_H
#define QWINDOWSURFACE_X11_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.
//
#include <qglobal.h>
#include "private/qwindowsurface_p.h"
QT_BEGIN_NAMESPACE
class QPaintDevice;
class QPoint;
class QRegion;
class QRegion;
class QSize;
class QWidget;
struct QX11WindowSurfacePrivate;
class QX11WindowSurface : public QWindowSurface
{
public:
QX11WindowSurface(QWidget *widget);
~QX11WindowSurface();
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
void beginPaint(const QRegion &rgn);
void setGeometry(const QRect &rect);
bool scroll(const QRegion &area, int dx, int dy);
QPixmap grabWidget(const QWidget *widget,
const QRect& rectangle = QRect()) const;
WindowSurfaceFeatures features() const;
private:
QX11WindowSurfacePrivate *d_ptr;
GC gc;
};
QT_END_NAMESPACE
#endif // QWINDOWSURFACE_X11_P_H