| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui 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 | #ifndef QWINDOWSURFACE_QWS_P_H
|
|---|
| 43 | #define QWINDOWSURFACE_QWS_P_H
|
|---|
| 44 |
|
|---|
| 45 | //
|
|---|
| 46 | // W A R N I N G
|
|---|
| 47 | // -------------
|
|---|
| 48 | //
|
|---|
| 49 | // This file is not part of the Qt API. It exists purely as an
|
|---|
| 50 | // implementation detail. This header file may change from version to
|
|---|
| 51 | // version without notice, or even be removed.
|
|---|
| 52 | //
|
|---|
| 53 | // We mean it.
|
|---|
| 54 | //
|
|---|
| 55 |
|
|---|
| 56 | #include "qwindowsurface_p.h"
|
|---|
| 57 | #include <qregion.h>
|
|---|
| 58 | #include <qimage.h>
|
|---|
| 59 | #include <qdirectpainter_qws.h>
|
|---|
| 60 | #include <qmutex.h>
|
|---|
| 61 | #include <private/qwssharedmemory_p.h>
|
|---|
| 62 |
|
|---|
| 63 | QT_BEGIN_NAMESPACE
|
|---|
| 64 |
|
|---|
| 65 | class QScreen;
|
|---|
| 66 | class QWSWindowSurfacePrivate;
|
|---|
| 67 |
|
|---|
| 68 | class Q_GUI_EXPORT QWSWindowSurface : public QWindowSurface
|
|---|
| 69 | {
|
|---|
| 70 | public:
|
|---|
| 71 | QWSWindowSurface();
|
|---|
| 72 | QWSWindowSurface(QWidget *widget);
|
|---|
| 73 | ~QWSWindowSurface();
|
|---|
| 74 |
|
|---|
| 75 | virtual bool isValid() const = 0;
|
|---|
| 76 |
|
|---|
| 77 | virtual void setGeometry(const QRect &rect);
|
|---|
| 78 | virtual void setGeometry(const QRect &rect, const QRegion &mask);
|
|---|
| 79 | virtual void flush(QWidget *widget, const QRegion ®ion,
|
|---|
| 80 | const QPoint &offset);
|
|---|
| 81 |
|
|---|
| 82 | virtual bool move(const QPoint &offset);
|
|---|
| 83 | virtual QRegion move(const QPoint &offset, const QRegion &newClip);
|
|---|
| 84 |
|
|---|
| 85 | virtual QPoint painterOffset() const; // remove!!!
|
|---|
| 86 |
|
|---|
| 87 | virtual void beginPaint(const QRegion &);
|
|---|
| 88 | virtual void endPaint(const QRegion &);
|
|---|
| 89 |
|
|---|
| 90 | virtual bool lock(int timeout = -1);
|
|---|
| 91 | virtual void unlock();
|
|---|
| 92 |
|
|---|
| 93 | virtual QString key() const = 0;
|
|---|
| 94 |
|
|---|
| 95 | // XXX: not good enough
|
|---|
| 96 | virtual QByteArray transientState() const;
|
|---|
| 97 | virtual QByteArray permanentState() const;
|
|---|
| 98 | virtual void setTransientState(const QByteArray &state);
|
|---|
| 99 | virtual void setPermanentState(const QByteArray &state);
|
|---|
| 100 |
|
|---|
| 101 | virtual QImage image() const = 0;
|
|---|
| 102 | virtual QPaintDevice *paintDevice() = 0;
|
|---|
| 103 |
|
|---|
| 104 | const QRegion clipRegion() const;
|
|---|
| 105 | void setClipRegion(const QRegion &);
|
|---|
| 106 |
|
|---|
| 107 | #ifdef QT_QWS_CLIENTBLIT
|
|---|
| 108 | virtual const QRegion directRegion() const;
|
|---|
| 109 | virtual int directRegionId() const;
|
|---|
| 110 | virtual void setDirectRegion(const QRegion &, int);
|
|---|
| 111 | #endif
|
|---|
| 112 |
|
|---|
| 113 | enum SurfaceFlag {
|
|---|
| 114 | RegionReserved = 0x1,
|
|---|
| 115 | Buffered = 0x2,
|
|---|
| 116 | Opaque = 0x4
|
|---|
| 117 | };
|
|---|
| 118 | Q_DECLARE_FLAGS(SurfaceFlags, SurfaceFlag)
|
|---|
| 119 |
|
|---|
| 120 | SurfaceFlags surfaceFlags() const;
|
|---|
| 121 |
|
|---|
| 122 | inline bool isRegionReserved() const {
|
|---|
| 123 | return surfaceFlags() & RegionReserved;
|
|---|
| 124 | }
|
|---|
| 125 | inline bool isBuffered() const { return surfaceFlags() & Buffered; }
|
|---|
| 126 | inline bool isOpaque() const { return surfaceFlags() & Opaque; }
|
|---|
| 127 |
|
|---|
| 128 | int winId() const;
|
|---|
| 129 | virtual void releaseSurface();
|
|---|
| 130 |
|
|---|
| 131 | protected:
|
|---|
| 132 | void setSurfaceFlags(SurfaceFlags type);
|
|---|
| 133 | void setWinId(int id);
|
|---|
| 134 |
|
|---|
| 135 | private:
|
|---|
| 136 | friend class QWidgetPrivate;
|
|---|
| 137 |
|
|---|
| 138 | void invalidateBuffer();
|
|---|
| 139 |
|
|---|
| 140 | QWSWindowSurfacePrivate *d_ptr;
|
|---|
| 141 | };
|
|---|
| 142 |
|
|---|
| 143 | Q_DECLARE_OPERATORS_FOR_FLAGS(QWSWindowSurface::SurfaceFlags)
|
|---|
| 144 |
|
|---|
| 145 | class QWSWindowSurfacePrivate
|
|---|
| 146 | {
|
|---|
| 147 | public:
|
|---|
| 148 | QWSWindowSurfacePrivate();
|
|---|
| 149 |
|
|---|
| 150 | void setWinId(int id);
|
|---|
| 151 |
|
|---|
| 152 | QWSWindowSurface::SurfaceFlags flags;
|
|---|
| 153 | QRegion clip;
|
|---|
| 154 | #ifdef QT_QWS_CLIENTBLIT
|
|---|
| 155 | QRegion direct;
|
|---|
| 156 | int directId;
|
|---|
| 157 | #endif
|
|---|
| 158 |
|
|---|
| 159 | int winId;
|
|---|
| 160 | };
|
|---|
| 161 |
|
|---|
| 162 | class QWSLock;
|
|---|
| 163 |
|
|---|
| 164 | class Q_GUI_EXPORT QWSMemorySurface : public QWSWindowSurface
|
|---|
| 165 | {
|
|---|
| 166 | public:
|
|---|
| 167 | QWSMemorySurface();
|
|---|
| 168 | QWSMemorySurface(QWidget *widget);
|
|---|
| 169 | ~QWSMemorySurface();
|
|---|
| 170 |
|
|---|
| 171 | bool isValid() const;
|
|---|
| 172 |
|
|---|
| 173 | QPaintDevice *paintDevice() { return &img; }
|
|---|
| 174 | bool scroll(const QRegion &area, int dx, int dy);
|
|---|
| 175 |
|
|---|
| 176 | QImage image() const { return img; }
|
|---|
| 177 | QPoint painterOffset() const;
|
|---|
| 178 |
|
|---|
| 179 | bool lock(int timeout = -1);
|
|---|
| 180 | void unlock();
|
|---|
| 181 |
|
|---|
| 182 | protected:
|
|---|
| 183 | QImage::Format preferredImageFormat(const QWidget *widget) const;
|
|---|
| 184 |
|
|---|
| 185 | #ifndef QT_NO_QWS_MULTIPROCESS
|
|---|
| 186 | void setLock(int lockId);
|
|---|
| 187 | QWSLock *memlock;
|
|---|
| 188 | #endif
|
|---|
| 189 | #ifndef QT_NO_THREAD
|
|---|
| 190 | QMutex threadLock;
|
|---|
| 191 | #endif
|
|---|
| 192 |
|
|---|
| 193 | QImage img;
|
|---|
| 194 | };
|
|---|
| 195 |
|
|---|
| 196 | class Q_GUI_EXPORT QWSLocalMemSurface : public QWSMemorySurface
|
|---|
| 197 | {
|
|---|
| 198 | public:
|
|---|
| 199 | QWSLocalMemSurface();
|
|---|
| 200 | QWSLocalMemSurface(QWidget *widget);
|
|---|
| 201 | ~QWSLocalMemSurface();
|
|---|
| 202 |
|
|---|
| 203 | void setGeometry(const QRect &rect);
|
|---|
| 204 |
|
|---|
| 205 | QString key() const { return QLatin1String("mem"); }
|
|---|
| 206 | QByteArray permanentState() const;
|
|---|
| 207 |
|
|---|
| 208 | void setPermanentState(const QByteArray &data);
|
|---|
| 209 | virtual void releaseSurface();
|
|---|
| 210 | protected:
|
|---|
| 211 | uchar *mem;
|
|---|
| 212 | int memsize;
|
|---|
| 213 | };
|
|---|
| 214 |
|
|---|
| 215 | #ifndef QT_NO_QWS_MULTIPROCESS
|
|---|
| 216 | class Q_GUI_EXPORT QWSSharedMemSurface : public QWSMemorySurface
|
|---|
| 217 | {
|
|---|
| 218 | public:
|
|---|
| 219 | QWSSharedMemSurface();
|
|---|
| 220 | QWSSharedMemSurface(QWidget *widget);
|
|---|
| 221 | ~QWSSharedMemSurface();
|
|---|
| 222 |
|
|---|
| 223 | void setGeometry(const QRect &rect);
|
|---|
| 224 |
|
|---|
| 225 | QString key() const { return QLatin1String("shm"); }
|
|---|
| 226 | QByteArray permanentState() const;
|
|---|
| 227 |
|
|---|
| 228 | void setPermanentState(const QByteArray &data);
|
|---|
| 229 |
|
|---|
| 230 | #ifdef QT_QWS_CLIENTBLIT
|
|---|
| 231 | virtual void setDirectRegion(const QRegion &, int);
|
|---|
| 232 | virtual const QRegion directRegion() const;
|
|---|
| 233 | #endif
|
|---|
| 234 | virtual void releaseSurface();
|
|---|
| 235 |
|
|---|
| 236 | private:
|
|---|
| 237 | bool setMemory(int memId);
|
|---|
| 238 |
|
|---|
| 239 | QWSSharedMemory mem;
|
|---|
| 240 | };
|
|---|
| 241 | #endif // QT_NO_QWS_MULTIPROCESS
|
|---|
| 242 |
|
|---|
| 243 | #ifndef QT_NO_PAINTONSCREEN
|
|---|
| 244 | class Q_GUI_EXPORT QWSOnScreenSurface : public QWSMemorySurface
|
|---|
| 245 | {
|
|---|
| 246 | public:
|
|---|
| 247 | QWSOnScreenSurface();
|
|---|
| 248 | QWSOnScreenSurface(QWidget *widget);
|
|---|
| 249 | ~QWSOnScreenSurface();
|
|---|
| 250 |
|
|---|
| 251 | bool isValid() const;
|
|---|
| 252 | QPoint painterOffset() const;
|
|---|
| 253 |
|
|---|
| 254 | QString key() const { return QLatin1String("OnScreen"); }
|
|---|
| 255 | QByteArray permanentState() const;
|
|---|
| 256 |
|
|---|
| 257 | void setPermanentState(const QByteArray &data);
|
|---|
| 258 |
|
|---|
| 259 | private:
|
|---|
| 260 | void attachToScreen(const QScreen *screen);
|
|---|
| 261 |
|
|---|
| 262 | const QScreen *screen;
|
|---|
| 263 | };
|
|---|
| 264 | #endif // QT_NO_PAINTONSCREEN
|
|---|
| 265 |
|
|---|
| 266 | #ifndef QT_NO_PAINT_DEBUG
|
|---|
| 267 | class Q_GUI_EXPORT QWSYellowSurface : public QWSWindowSurface
|
|---|
| 268 | {
|
|---|
| 269 | public:
|
|---|
| 270 | QWSYellowSurface(bool isClient = false);
|
|---|
| 271 | ~QWSYellowSurface();
|
|---|
| 272 |
|
|---|
| 273 | void setDelay(int msec) { delay = msec; }
|
|---|
| 274 |
|
|---|
| 275 | bool isValid() const { return true; }
|
|---|
| 276 |
|
|---|
| 277 | void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset);
|
|---|
| 278 |
|
|---|
| 279 | QString key() const { return QLatin1String("Yellow"); }
|
|---|
| 280 | QByteArray permanentState() const;
|
|---|
| 281 |
|
|---|
| 282 | void setPermanentState(const QByteArray &data);
|
|---|
| 283 |
|
|---|
| 284 | QPaintDevice *paintDevice() { return &img; }
|
|---|
| 285 | QImage image() const { return img; }
|
|---|
| 286 |
|
|---|
| 287 | private:
|
|---|
| 288 | int delay;
|
|---|
| 289 | QSize surfaceSize; // client side
|
|---|
| 290 | QImage img; // server side
|
|---|
| 291 | };
|
|---|
| 292 | #endif // QT_NO_PAINT_DEBUG
|
|---|
| 293 |
|
|---|
| 294 | #ifndef QT_NO_DIRECTPAINTER
|
|---|
| 295 |
|
|---|
| 296 | class QScreen;
|
|---|
| 297 |
|
|---|
| 298 | class Q_GUI_EXPORT QWSDirectPainterSurface : public QWSWindowSurface
|
|---|
| 299 | {
|
|---|
| 300 | public:
|
|---|
| 301 | QWSDirectPainterSurface(bool isClient = false,
|
|---|
| 302 | QDirectPainter::SurfaceFlag flags = QDirectPainter::NonReserved);
|
|---|
| 303 | ~QWSDirectPainterSurface();
|
|---|
| 304 |
|
|---|
| 305 | void setReserved() { setSurfaceFlags(RegionReserved); }
|
|---|
| 306 |
|
|---|
| 307 | void setGeometry(const QRect &rect) { setRegion(rect); }
|
|---|
| 308 |
|
|---|
| 309 | void setRegion(const QRegion ®ion);
|
|---|
| 310 | QRegion region() const { return clipRegion(); }
|
|---|
| 311 |
|
|---|
| 312 | void flush(QWidget*, const QRegion &, const QPoint &);
|
|---|
| 313 |
|
|---|
| 314 | bool isValid() const { return false; }
|
|---|
| 315 |
|
|---|
| 316 | QString key() const { return QLatin1String("DirectPainter"); }
|
|---|
| 317 | QByteArray permanentState() const;
|
|---|
| 318 |
|
|---|
| 319 | void setPermanentState(const QByteArray &);
|
|---|
| 320 |
|
|---|
| 321 | QImage image() const { return QImage(); }
|
|---|
| 322 | QPaintDevice *paintDevice() { return 0; }
|
|---|
| 323 |
|
|---|
| 324 | // hw: get rid of this
|
|---|
| 325 | WId windowId() const { return static_cast<WId>(winId()); }
|
|---|
| 326 |
|
|---|
| 327 | QScreen *screen() const { return _screen; }
|
|---|
| 328 |
|
|---|
| 329 | void beginPaint(const QRegion &);
|
|---|
| 330 | bool lock(int timeout = -1);
|
|---|
| 331 | void unlock();
|
|---|
| 332 |
|
|---|
| 333 | void setLocking(bool b) { doLocking = b; }
|
|---|
| 334 |
|
|---|
| 335 | bool hasPendingRegionEvents() const;
|
|---|
| 336 |
|
|---|
| 337 | private:
|
|---|
| 338 | QScreen *_screen;
|
|---|
| 339 | #ifndef QT_NO_THREAD
|
|---|
| 340 | QMutex threadLock;
|
|---|
| 341 | #endif
|
|---|
| 342 |
|
|---|
| 343 | friend void qt_directpainter_region(QDirectPainter*, const QRegion&, int);
|
|---|
| 344 | bool flushingRegionEvents;
|
|---|
| 345 | bool synchronous;
|
|---|
| 346 | bool doLocking;
|
|---|
| 347 | };
|
|---|
| 348 |
|
|---|
| 349 | #endif // QT_NO_DIRECTPAINTER
|
|---|
| 350 |
|
|---|
| 351 | QT_END_NAMESPACE
|
|---|
| 352 |
|
|---|
| 353 | #endif // QWINDOWSURFACE_QWS_P_H
|
|---|