Qt 4.8
qscreenproxy_qws.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include <qscreenproxy_qws.h>
43 
44 #ifndef QT_NO_QWS_PROXYSCREEN
45 
46 #include <qregexp.h>
47 
49 #ifndef QT_NO_QWS_CURSOR
50 
66  : QScreenCursor(), realCursor(0), d_ptr(0)
67 {
68 }
69 
74 {
75 }
76 
84 {
86  configure();
87 }
88 
95 {
96  return realCursor;
97 }
98 
102 void QProxyScreenCursor::set(const QImage &image, int hotx, int hoty)
103 {
104  if (realCursor) {
105  hotspot = QPoint(hotx, hoty);
106  cursor = image;
107  size = image.size();
108  realCursor->set(image, hotx, hoty);
109  } else {
110  QScreenCursor::set(image, hotx, hoty);
111  }
112 }
113 
117 void QProxyScreenCursor::move(int x, int y)
118 {
119  if (realCursor) {
120  pos = QPoint(x, y);
121  realCursor->move(x, y);
122  } else {
123  QScreenCursor::move(x, y);
124  }
125 }
126 
131 {
132  if (realCursor) {
133  realCursor->show();
134  enable = true;
135  } else {
137  }
138 }
139 
144 {
145  if (realCursor) {
146  realCursor->hide();
147  enable = false;
148  } else {
150  }
151 }
152 
157 {
158  if (!realCursor)
159  return;
160 
162  size = realCursor->size;
163  pos = realCursor->pos;
168 }
169 
170 #endif // QT_NO_QWS_CURSOR
171 
190  : QScreen(displayId, classId), realScreen(0), d_ptr(0)
191 {
192 }
193 
198 {
199 }
200 
207 {
208  realScreen = screen;
209  configure();
210 }
211 
218 {
219  return realScreen;
220 }
221 
222 
227 {
228  if (!realScreen)
229  return;
230 
231  d = realScreen->depth();
232  w = realScreen->width();
233  h = realScreen->height();
237  data = realScreen->base();
243 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
245 #endif
246 
249 
250 #ifdef QT_QWS_CLIENTBLIT
251  setSupportsBlitInClients(realScreen->supportsBlitInClients());
252 #endif
253 }
254 
262 static int getDisplayId(const QString &spec)
263 {
264  QRegExp regexp(QLatin1String(":(\\d+)\\b"));
265  if (regexp.lastIndexIn(spec) != -1) {
266  const QString capture = regexp.cap(1);
267  return capture.toInt();
268  }
269  return 0;
270 }
271 
275 bool QProxyScreen::connect(const QString &displaySpec)
276 {
277  const int id = getDisplayId(displaySpec);
278  realScreen = qt_get_screen(id, displaySpec.toLatin1().constData());
279  configure();
280 
281  return true;
282 }
283 
287 void QProxyScreen::exposeRegion(QRegion r, int changing)
288 {
289  if (!realScreen) {
290  QScreen::exposeRegion(r, changing);
291  return;
292  }
293 
294  realScreen->exposeRegion(r, changing);
295  r &= realScreen->region();
296 
297  const QVector<QRect> rects = r.rects();
298  for (int i = 0; i < rects.size(); ++i)
299  setDirty(rects.at(i));
300 }
301 
305 void QProxyScreen::blit(const QImage &image, const QPoint &topLeft,
306  const QRegion &region)
307 {
308  if (!realScreen) {
309  QScreen::blit(image, topLeft, region);
310  return;
311  }
312 
313  realScreen->blit(image, topLeft, region);
314 }
315 
319 void QProxyScreen::solidFill(const QColor &color, const QRegion &region)
320 {
321  if (!realScreen) {
322  QScreen::solidFill(color, region);
323  return;
324  }
325  realScreen->solidFill(color, region);
326 }
327 
332 {
333  if (!realScreen)
334  return QScreen::mapToDevice(s);
335 
336  return realScreen->mapToDevice(s);
337 }
338 
343 {
344  if (!realScreen)
345  return QScreen::mapFromDevice(s);
346 
347  return realScreen->mapFromDevice(s);
348 }
349 
353 QPoint QProxyScreen::mapToDevice(const QPoint &p, const QSize &s) const
354 {
355  if (!realScreen)
356  return QScreen::mapToDevice(p, s);
357 
358  return realScreen->mapToDevice(p, s);
359 }
360 
365 {
366  if (!realScreen)
367  return QScreen::mapFromDevice(p, s);
368 
369  return realScreen->mapFromDevice(p, s);
370 }
371 
375 QRect QProxyScreen::mapToDevice(const QRect &r, const QSize &s) const
376 {
377  if (!realScreen)
378  return QScreen::mapToDevice(r, s);
379 
380  return realScreen->mapToDevice(r, s);
381 }
382 
386 QRect QProxyScreen::mapFromDevice(const QRect &r, const QSize &s) const
387 {
388  if (!realScreen)
389  return QScreen::mapFromDevice(r, s);
390 
391  return realScreen->mapFromDevice(r, s);
392 }
393 
398 {
399  if (!realScreen)
400  return QScreen::mapToDevice(r, s);
401 
402  return realScreen->mapToDevice(r, s);
403 }
404 
409 {
410  if (!realScreen)
411  return QScreen::mapFromDevice(r, s);
412 
413  return realScreen->mapFromDevice(r, s);
414 }
415 
420 {
421  if (realScreen) {
423  delete realScreen;
424  realScreen = 0;
425  }
426 }
427 
431 {
432  if (realScreen)
433  return realScreen->initDevice();
434 
435  return false;
436 }
437 
442 {
443  if (realScreen)
445 }
446 
450 void QProxyScreen::setMode(int w,int h, int d)
451 {
452  if (realScreen) {
453  realScreen->setMode(w, h, d);
454  } else {
457  QScreen::d = d;
458  }
459  configure();
460  exposeRegion(region(), 0);
461 }
462 
467 {
468  if (realScreen)
469  return realScreen->supportsDepth(depth);
470  return false;
471 }
472 
477 {
478  if (realScreen)
479  realScreen->save();
480  QScreen::save();
481 }
482 
487 {
488  if (realScreen)
489  realScreen->restore();
491 }
492 
496 void QProxyScreen::blank(bool on)
497 {
498  if (realScreen)
499  realScreen->blank(on);
500 }
501 
505 bool QProxyScreen::onCard(const unsigned char *ptr) const
506 {
507  if (realScreen)
508  return realScreen->onCard(ptr);
509  return false;
510 }
511 
515 bool QProxyScreen::onCard(const unsigned char *ptr, ulong &offset) const
516 {
517  if (realScreen)
518  return realScreen->onCard(ptr, offset);
519  return false;
520 }
521 
526 {
527  if (realScreen)
528  return realScreen->isInterlaced();
529  return false;
530 }
531 
536 {
537  if (realScreen)
538  return realScreen->isTransformed();
539  return QScreen::isTransformed();
540 }
541 
546 {
547  if (realScreen)
550 }
551 
556 {
557  if (realScreen)
558  return realScreen->memoryNeeded(str);
559  else
560  return QScreen::memoryNeeded(str);
561 }
562 
567 {
568  if (realScreen)
569  return realScreen->sharedRamSize(ptr);
570  else
571  return QScreen::sharedRamSize(ptr);
572 }
573 
578 {
579  if (realScreen)
581 }
582 
587 {
588  if (realScreen)
590 }
591 
595 void QProxyScreen::setDirty(const QRect &rect)
596 {
597  if (realScreen)
598  realScreen->setDirty(rect);
599 }
600 
605 {
606  if (realScreen)
607  return realScreen->createSurface(widget);
608 
609  return QScreen::createSurface(widget);
610 }
611 
616 {
617  if (realScreen)
618  return realScreen->createSurface(key);
619 
620  return QScreen::createSurface(key);
621 }
622 
627 {
628  if (realScreen)
629  return realScreen->subScreens();
630 
631  return QScreen::subScreens();
632 }
633 
638 {
639  if (realScreen)
640  return realScreen->region();
641  else
642  return QScreen::region();
643 }
644 
646 
647 #endif // QT_NO_QWS_PROXYSCREEN
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QScreenCursor class is a base class for screen cursors in Qt for Embedded Linux.
Definition: qscreen_qws.h:135
QScreenCursor * screenCursor() const
Returns the real screen cursor used by the proxy screen cursor.
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
virtual void move(int x, int y)
Moves the mouse cursor to the given position, i.e., (x, y).
bool frameBufferLittleEndian() const
int height() const
Returns the logical height of the framebuffer in pixels.
Definition: qscreen_qws.h:228
void setOffset(const QPoint &p)
QString cap(int nth=0) const
Returns the text captured by the nth subexpression.
Definition: qregexp.cpp:4310
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void disconnect()
Reimplemented Function
void setScreen(QScreen *screen)
Sets the real screen to be used by the proxy screen.
int lastIndexIn(const QString &str, int offset=-1, CaretMode caretMode=CaretAtZero) const
Attempts to find a match backwards in str from position offset.
Definition: qregexp.cpp:4167
QPointer< QWidget > widget
virtual int sharedRamSize(void *)
Definition: qscreen_qws.h:215
void blank(bool on)
Reimplemented Function
int physicalHeight() const
Returns the physical height of the screen in millimeters.
Definition: qscreen_qws.h:291
int d
the pixel depth
Definition: qscreen_qws.h:327
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
QProxyScreen(int display_id, ClassId=ProxyClass)
Constructs a proxy screen with the given displayId and classId.
int sharedRamSize(void *)
void setScreenCursor(QScreenCursor *cursor)
Sets the real screen cursor to be used for the proxy screen cursor to the cursor specified.
void save()
Reimplemented Function
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual void restore()
Restores the previously saved state of the graphics card.
bool isInterlaced() const
Reimplemented Function
QPoint hotspot
Definition: qscreen_qws.h:163
QRegion region() const
Reimplemented Function
virtual void setMode(int, int, int)=0
Implement this function to reset the framebuffer&#39;s resolution (width and height) and bit depth...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Q_GUI_EXPORT QScreen * qt_get_screen(int display_id, const char *spec)
int deviceWidth() const
Returns the physical width of the framebuffer device in pixels.
Definition: qscreen_qws.h:233
virtual QSize mapFromDevice(const QSize &) const
Maps the given size from the framebuffer coordinate system to the coordinate space used by the applic...
int physHeight
the physical height of the screen in millimeters.
Definition: qscreen_qws.h:340
The QString class provides a Unicode character string.
Definition: qstring.h:83
int size
the number of bytes in the visible region of the frame buffer
Definition: qscreen_qws.h:334
QProxyScreenCursorPrivate * d_ptr
bool isTransformed() const
Reimplemented Function
virtual void setDirty(const QRect &)
Marks the given rectangle as dirty.
PixelType pixeltype
set to BGRPixel
Definition: qscreen_qws.h:328
int physWidth
the physical width of the screen in millimeters.
Definition: qscreen_qws.h:339
QImage image() const
Returns the cursor&#39;s image.
Definition: qscreen_qws.h:151
virtual QSize mapToDevice(const QSize &) const
Maps the given size from the coordinate space used by the application to the framebuffer coordinate s...
void setPixelFormat(QImage::Format format)
Sets the screen&#39;s pixel format to format.
bool initDevice()
This function is called by the Qt for Embedded Linux server to initialize the framebuffer.
virtual void blit(const QImage &img, const QPoint &topLeft, const QRegion &region)
Copies the given region in the given image to the point specified by topLeft using device coordinates...
virtual void disconnect()=0
This function is called by every Qt for Embedded Linux application before exiting, and must be implemented to unmap the framebuffer.
virtual QRegion region() const
Returns the region covered by this screen driver.
Definition: qscreen_qws.h:284
int width() const
Returns the logical width of the framebuffer in pixels.
Definition: qscreen_qws.h:227
uchar * data
points to the first visible pixel in the frame buffer.
Definition: qscreen_qws.h:311
int transformOrientation() const
Reimplemented Function
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
PixelType pixelType() const
Returns the pixel storage format of the screen.
Definition: qscreen_qws.h:231
int linestep() const
Returns the length of each scanline of the framebuffer in bytes.
Definition: qscreen_qws.h:232
virtual void resumeUpdates()
QScreenCursor * realCursor
void exposeRegion(QRegion r, int changing)
Reimplemented Function
virtual bool initDevice()=0
This function is called by the Qt for Embedded Linux server to initialize the framebuffer.
int w
the logical width of the screen.
Definition: qscreen_qws.h:324
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void setDirty(const QRect &)
Reimplemented Function
QScreen * realScreen
void hide()
Reimplemented Function
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
const T * ptr(const T &t)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
unsigned long ulong
Definition: qglobal.h:997
~QProxyScreenCursor()
Destroys the proxy screen cursor.
QSize mapFromDevice(const QSize &s) const
Reimplemented Function
int memoryNeeded(const QString &)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
virtual void hide()
Hides the cursor from the screen.
bool supportsDepth(int) const
Reimplemented Function
virtual QWSWindowSurface * createSurface(QWidget *widget) const
Creates and returns a new window surface for the given widget.
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static int getDisplayId(const QString &spec)
Returns the display ID that corresponds to the given spec.
void show()
Reimplemented Function
uchar * base() const
Returns a pointer to the beginning of the framebuffer.
Definition: qscreen_qws.h:235
int dw
the device width
Definition: qscreen_qws.h:331
int dh
the device height
Definition: qscreen_qws.h:332
virtual void blank(bool on)
Prevents the screen driver form displaying any content on the screen.
void blit(const QImage &img, const QPoint &topLeft, const QRegion &region)
Reimplemented Function
QImage::Format pixelFormat() const
Returns the pixel format of the screen, or QImage::Format_Invalid if the pixel format is not a suppor...
virtual void save()
Saves the current state of the graphics card.
virtual int memoryNeeded(const QString &)
void set(const QImage &image, int hotx, int hoty)
Reimplemented Function
bool onCard(const unsigned char *) const
Reimplemented Function
int deviceHeight() const
Returns the full height of the framebuffer device in pixels.
Definition: qscreen_qws.h:234
virtual void haltUpdates()
void restore()
Reimplemented Function
ClassId
This enum defines the class identifiers for the known screen subclasses.
Definition: qscreen_qws.h:194
virtual bool isInterlaced() const
Returns true if the display is interlaced (i.
void setFrameBufferLittleEndian(bool littleEndian)
virtual QList< QScreen * > subScreens() const
Definition: qscreen_qws.h:283
virtual bool isTransformed() const
Returns true if the screen is transformed (for instance, rotated 90 degrees); otherwise returns false...
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
QProxyScreenCursor()
Constructs a proxy screen cursor.
~QProxyScreen()
Destroys the proxy screen.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
virtual void shutdownDevice()
This function is called by the Qt for Embedded Linux server before it calls the disconnect() function...
void shutdownDevice()
Reimplemented Function
virtual int transformOrientation() const
Returns the current rotation as an integer value.
QWSWindowSurface * createSurface(QWidget *widget) const
Reimplemented Function
virtual bool onCard(const unsigned char *) const
Returns true if the specified buffer is within the graphics card&#39;s memory; otherwise returns false (i...
QSize mapToDevice(const QSize &s) const
Reimplemented Function
int lstep
the number of bytes representing a line in the frame buffer.
Definition: qscreen_qws.h:325
uint supportsAlpha
Definition: qscreen_qws.h:166
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QList< QScreen * > subScreens() const
Reimplemented Function
int h
the logical height of the screen.
Definition: qscreen_qws.h:326
QScreen * screen() const
Returns the real screen used by the proxy screen.
virtual bool supportsDepth(int) const
Returns true if the screen supports the specified color depth; otherwise returns false.
virtual void exposeRegion(QRegion r, int changing)
This function is called by the Qt for Embedded Linux server whenever a screen update is required...
virtual void show()
Shows the mouse cursor.
int physicalWidth() const
Returns the physical width of the screen in millimeters.
Definition: qscreen_qws.h:290
int screenSize() const
Returns the size of the screen in bytes.
Definition: qscreen_qws.h:242
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
void move(int x, int y)
Reimplemented Function
void setMode(int width, int height, int depth)
Reimplemented Function
bool connect(const QString &displaySpec)
Reimplemented Function
virtual void solidFill(const QColor &color, const QRegion &region)
Fills the given region of the screen with the specified color.
virtual void set(const QImage &image, int hotx, int hoty)
Sets the cursor&#39;s image to be the given image.
QPoint offset() const
Returns the logical offset of the screen, i.
int depth() const
Returns the depth of the framebuffer, in bits per pixel.
Definition: qscreen_qws.h:229
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
void solidFill(const QColor &color, const QRegion &region)
Reimplemented Function