0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtOpenGL module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
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 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
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 |
return false;
|
|
128 |
}
|
|
129 |
|
|
130 |
/*
|
|
131 |
void QX11GLWindowSurface::beginPaint(const QRegion ®ion)
|
|
132 |
{
|
|
133 |
}
|
|
134 |
|
|
135 |
void QX11GLWindowSurface::endPaint(const QRegion ®ion)
|
|
136 |
{
|
|
137 |
}
|
|
138 |
|
|
139 |
QImage *QX11GLWindowSurface::buffer(const QWidget *widget)
|
|
140 |
{
|
|
141 |
}
|
|
142 |
*/
|
|
143 |
|
|
144 |
QT_END_NAMESPACE
|