Qt 4.8
Functions
qwindowsurface_qws.cpp File Reference
#include "qwindowsurface_qws_p.h"
#include <qwidget.h>
#include <qscreen_qws.h>
#include <qwsmanager_qws.h>
#include <qapplication.h>
#include <qwsdisplay_qws.h>
#include <qrgb.h>
#include <qpaintengine.h>
#include <qdesktopwidget.h>
#include <private/qapplication_p.h>
#include <private/qwsdisplay_qws_p.h>
#include <private/qwidget_p.h>
#include <private/qwsmanager_p.h>
#include <private/qwslock_p.h>
#include <private/qbackingstore_p.h>
#include <stdio.h>

Go to the source code of this file.

Functions

static int bytesPerPixel (QImage::Format format)
 
static void flushUpdate (QWidget *widget, const QRegion &region, const QPoint &offset)
 
static QScreengetPrimaryScreen ()
 
static QScreengetScreen (const QWidget *w)
 
bool isWidgetOpaque (const QWidget *w)
 
static int nextMulOf4 (int n)
 
void qt_scrollRectInImage (QImage &img, const QRect &rect, const QPoint &offset)
 
static void setImageMetrics (QImage &img, QWidget *window)
 

Function Documentation

◆ bytesPerPixel()

static int bytesPerPixel ( QImage::Format  format)
static

Definition at line 97 of file qwindowsurface_qws.cpp.

Referenced by buttonChange(), QVNCServer::convertPixels(), drawImageTiled(), QVNCIntegration::grabWindow(), QRasterWindowSurface::prepareBuffer(), pvrQwsInitFbScreen(), QWSLocalMemSurface::setGeometry(), QWSSharedMemSurface::setGeometry(), QWSLocalMemSurface::setPermanentState(), QWSSharedMemSurface::setPermanentState(), QRfbRawEncoder::write(), and QRfbHextileEncoder< SRC >::write().

98 {
99  switch (format) {
101  return 0;
102 #ifndef QT_NO_DEBUG
103  case QImage::Format_Mono:
105  qFatal("QWSWindowSurface: Invalid backingstore format: %i",
106  int(format));
107 #endif
109  return 1;
113  return 4;
118  return 2;
124  return 3;
125  default:
126 #ifndef QT_NO_DEBUG
127  qFatal("QWSWindowSurface: Invalid backingstore format: %i",
128  int(format));
129 #endif
130  return 0;
131  }
132 }
Q_CORE_EXPORT void qFatal(const char *,...)

◆ flushUpdate()

static void flushUpdate ( QWidget widget,
const QRegion region,
const QPoint offset 
)
inlinestatic

Definition at line 670 of file qwindowsurface_qws.cpp.

Referenced by QWSWindowSurface::flush(), and qt_flush().

672 {
673 #ifdef QT_NO_PAINT_DEBUG
674  Q_UNUSED(widget);
675  Q_UNUSED(region);
676  Q_UNUSED(offset);
677 #else
678  static int delay = -1;
679 
680  if (delay == -1)
681  delay = qgetenv("QT_FLUSH_UPDATE").toInt() * 10;
682 
683  if (delay == 0)
684  return;
685 
686  static QWSYellowSurface surface(true);
687  surface.setDelay(delay);
688  surface.flush(widget, region, offset);
689 #endif // QT_NO_PAINT_DEBUG
690 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ getPrimaryScreen()

static QScreen* getPrimaryScreen ( )
inlinestatic

Definition at line 1356 of file qwindowsurface_qws.cpp.

1357 {
1358  QScreen *screen = QScreen::instance();
1359  if (!screen->base()) {
1360  QList<QScreen*> subScreens = screen->subScreens();
1361  if (subScreens.size() < 1)
1362  return 0;
1363  screen = subScreens.at(0);
1364  }
1365  return screen;
1366 }
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QScreen * instance()
Returns a pointer to the application&#39;s QScreen instance.
Definition: qscreen_qws.h:201
uchar * base() const
Returns a pointer to the beginning of the framebuffer.
Definition: qscreen_qws.h:235
virtual QList< QScreen * > subScreens() const
Definition: qscreen_qws.h:283
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ getScreen()

static QScreen* getScreen ( const QWidget w)
inlinestatic

Definition at line 86 of file qwindowsurface_qws.cpp.

Referenced by effectiveState(), QWSWindowSurface::flush(), QWSOnScreenSurface::isValid(), QWSMemorySurface::preferredImageFormat(), QWSOnScreenSurface::QWSOnScreenSurface(), and setImageMetrics().

87 {
88  const QList<QScreen*> subScreens = qt_screen->subScreens();
89  if (subScreens.isEmpty())
90  return qt_screen;
91 
92  const int screen = QApplication::desktop()->screenNumber(w);
93 
94  return qt_screen->subScreens().at(screen < 0 ? 0 : screen);
95 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
virtual QList< QScreen * > subScreens() const
Definition: qscreen_qws.h:283
int screenNumber(const QWidget *widget=0) const
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ isWidgetOpaque()

bool isWidgetOpaque ( const QWidget w)
inline

Definition at line 81 of file qwindowsurface_qws.cpp.

Referenced by QWSMemorySurface::beginPaint(), QWSMemorySurface::isValid(), QWSMemorySurface::preferredImageFormat(), and QWSMemorySurface::QWSMemorySurface().

82 {
83  return w->d_func()->isOpaque && !w->testAttribute(Qt::WA_TranslucentBackground);
84 }
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ nextMulOf4()

static int nextMulOf4 ( int  n)
inlinestatic

◆ qt_scrollRectInImage()

void qt_scrollRectInImage ( QImage img,
const QRect rect,
const QPoint offset 
)

Definition at line 345 of file qwindowsurface.cpp.

Referenced by QWSMemorySurface::beginPaint(), and QWSMemorySurface::scroll().

346 {
347  // make sure we don't detach
348  uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits());
349 
350  int lineskip = img.bytesPerLine();
351  int depth = img.depth() >> 3;
352 
353  const QRect imageRect(0, 0, img.width(), img.height());
354  const QRect r = rect & imageRect & imageRect.translated(-offset);
355  const QPoint p = rect.topLeft() + offset;
356 
357  if (r.isEmpty())
358  return;
359 
360  const uchar *src;
361  uchar *dest;
362 
363  if (r.top() < p.y()) {
364  src = mem + r.bottom() * lineskip + r.left() * depth;
365  dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth;
366  lineskip = -lineskip;
367  } else {
368  src = mem + r.top() * lineskip + r.left() * depth;
369  dest = mem + p.y() * lineskip + p.x() * depth;
370  }
371 
372  const int w = r.width();
373  int h = r.height();
374  const int bytes = w * depth;
375 
376  // overlapping segments?
377  if (offset.y() == 0 && qAbs(offset.x()) < w) {
378  do {
379  ::memmove(dest, src, bytes);
380  dest += lineskip;
381  src += lineskip;
382  } while (--h);
383  } else {
384  do {
385  ::memcpy(dest, src, bytes);
386  dest += lineskip;
387  src += lineskip;
388  } while (--h);
389  }
390 }
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
unsigned char uchar
Definition: qglobal.h:994
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ setImageMetrics()

static void setImageMetrics ( QImage img,
QWidget window 
)
inlinestatic

Definition at line 139 of file qwindowsurface_qws.cpp.

Referenced by QWSLocalMemSurface::setGeometry(), and QWSSharedMemSurface::setGeometry().

139  {
140  QScreen *myScreen = getScreen(window);
141  if (myScreen) {
142  int dpmx = myScreen->width()*1000 / myScreen->physicalWidth();
143  int dpmy = myScreen->height()*1000 / myScreen->physicalHeight();
144  img.setDotsPerMeterX(dpmx);
145  img.setDotsPerMeterY(dpmy);
146  }
147 }
int height() const
Returns the logical height of the framebuffer in pixels.
Definition: qscreen_qws.h:228
int physicalHeight() const
Returns the physical height of the screen in millimeters.
Definition: qscreen_qws.h:291
static QScreen * getScreen(const QWidget *w)
int width() const
Returns the logical width of the framebuffer in pixels.
Definition: qscreen_qws.h:227
void setDotsPerMeterY(int)
Sets the number of pixels that fit vertically in a physical meter, to y.
Definition: qimage.cpp:5667
void setDotsPerMeterX(int)
Sets the number of pixels that fit horizontally in a physical meter, to x.
Definition: qimage.cpp:5645
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
int physicalWidth() const
Returns the physical width of the screen in millimeters.
Definition: qscreen_qws.h:290