[556] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[651] | 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[556] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
| 6 | **
|
---|
| 7 | ** This file is part of the QtOpenGL module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
| 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
| 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include <QTime>
|
---|
| 43 | #include <QDebug>
|
---|
| 44 |
|
---|
| 45 | #include <private/qt_x11_p.h>
|
---|
| 46 | #include <private/qimagepixmapcleanuphooks_p.h>
|
---|
| 47 |
|
---|
| 48 | #include "qwindowsurface_x11gl_p.h"
|
---|
| 49 | #include "qpixmapdata_x11gl_p.h"
|
---|
| 50 |
|
---|
| 51 | QT_BEGIN_NAMESPACE
|
---|
| 52 |
|
---|
| 53 | QX11GLWindowSurface::QX11GLWindowSurface(QWidget* window)
|
---|
| 54 | : QWindowSurface(window), m_GC(0), m_window(window)
|
---|
| 55 | {
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | QX11GLWindowSurface::~QX11GLWindowSurface()
|
---|
| 59 | {
|
---|
| 60 | if (m_GC)
|
---|
| 61 | XFree(m_GC);
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | QPaintDevice *QX11GLWindowSurface::paintDevice()
|
---|
| 65 | {
|
---|
| 66 | return &m_backBuffer;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | extern void *qt_getClipRects(const QRegion &r, int &num); // in qpaintengine_x11.cpp
|
---|
| 70 |
|
---|
| 71 | void QX11GLWindowSurface::flush(QWidget *widget, const QRegion &widgetRegion, const QPoint &offset)
|
---|
| 72 | {
|
---|
| 73 | // qDebug("QX11GLWindowSurface::flush()");
|
---|
| 74 | QTime startTime = QTime::currentTime();
|
---|
| 75 | if (m_backBuffer.isNull()) {
|
---|
| 76 | qDebug("QHarmattanWindowSurface::flush() - backBuffer is null, not flushing anything");
|
---|
| 77 | return;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft();
|
---|
| 81 | QRegion windowRegion(widgetRegion);
|
---|
| 82 | QRect boundingRect = widgetRegion.boundingRect();
|
---|
| 83 | if (!widgetOffset.isNull())
|
---|
| 84 | windowRegion.translate(-widgetOffset);
|
---|
| 85 | QRect windowBoundingRect = windowRegion.boundingRect();
|
---|
| 86 |
|
---|
| 87 | int rectCount;
|
---|
| 88 | XRectangle *rects = (XRectangle *)qt_getClipRects(windowRegion, rectCount);
|
---|
| 89 | if (rectCount <= 0)
|
---|
| 90 | return;
|
---|
| 91 | // qDebug() << "XSetClipRectangles";
|
---|
| 92 | // for (int i = 0; i < num; ++i)
|
---|
| 93 | // qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height;
|
---|
| 94 |
|
---|
| 95 | if (m_GC == 0) {
|
---|
| 96 | m_GC = XCreateGC(X11->display, m_window->handle(), 0, 0);
|
---|
| 97 | XSetGraphicsExposures(X11->display, m_GC, False);
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | XSetClipRectangles(X11->display, m_GC, 0, 0, rects, rectCount, YXBanded);
|
---|
| 101 | XCopyArea(X11->display, m_backBuffer.handle(), m_window->handle(), m_GC,
|
---|
| 102 | boundingRect.x() + offset.x(), boundingRect.y() + offset.y(),
|
---|
| 103 | boundingRect.width(), boundingRect.height(),
|
---|
| 104 | windowBoundingRect.x(), windowBoundingRect.y());
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | void QX11GLWindowSurface::setGeometry(const QRect &rect)
|
---|
| 108 | {
|
---|
| 109 | if (rect.width() > m_backBuffer.size().width() || rect.height() > m_backBuffer.size().height()) {
|
---|
| 110 | QSize newSize = rect.size();
|
---|
| 111 | // QSize newSize(1024,512);
|
---|
| 112 | qDebug() << "QX11GLWindowSurface::setGeometry() - creating a pixmap of size" << newSize;
|
---|
| 113 | QX11GLPixmapData *pd = new QX11GLPixmapData;
|
---|
| 114 | pd->resize(newSize.width(), newSize.height());
|
---|
| 115 | m_backBuffer = QPixmap(pd);
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | // if (gc)
|
---|
| 119 | // XFreeGC(X11->display, gc);
|
---|
| 120 | // gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0);
|
---|
| 121 | // XSetGraphicsExposures(X11->display, gc, False);
|
---|
| 122 | QWindowSurface::setGeometry(rect);
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | bool QX11GLWindowSurface::scroll(const QRegion &area, int dx, int dy)
|
---|
| 126 | {
|
---|
| 127 | Q_UNUSED(area);
|
---|
| 128 | Q_UNUSED(dx);
|
---|
| 129 | Q_UNUSED(dy);
|
---|
| 130 | return false;
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | /*
|
---|
| 134 | void QX11GLWindowSurface::beginPaint(const QRegion ®ion)
|
---|
| 135 | {
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | void QX11GLWindowSurface::endPaint(const QRegion ®ion)
|
---|
| 139 | {
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | QImage *QX11GLWindowSurface::buffer(const QWidget *widget)
|
---|
| 143 | {
|
---|
| 144 | }
|
---|
| 145 | */
|
---|
| 146 |
|
---|
| 147 | QT_END_NAMESPACE
|
---|