Qt 4.8
Public Functions | Protected Functions | Protected Variables | List of all members
QWSMemorySurface Class Reference

#include <qwindowsurface_qws_p.h>

Inheritance diagram for QWSMemorySurface:
QWSWindowSurface QWindowSurface QWSLocalMemSurface QWSOnScreenSurface QWSSharedMemSurface

Public Functions

void beginPaint (const QRegion &rgn)
 This function is called before painting onto the surface begins, with the region in which the painting will occur. More...
 
QImage image () const
 Implement this function to return an image of the top-level window. More...
 
bool isValid () const
 Implement this function to return true if the surface is a valid surface for the given top-level window; otherwise return false. More...
 
bool lock (int timeout=-1)
 
QPaintDevicepaintDevice ()
 Implement this function to return the appropriate paint device. More...
 
QPoint painterOffset () const
 Returns the offset to be used when painting. More...
 
 QWSMemorySurface ()
 
 QWSMemorySurface (QWidget *widget)
 
bool scroll (const QRegion &area, int dx, int dy)
 Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative. More...
 
void unlock ()
 
 ~QWSMemorySurface ()
 
- Public Functions inherited from QWSWindowSurface
const QRegion clipRegion () const
 Returns the region currently visible on the screen. More...
 
virtual void endPaint (const QRegion &)
 This function is called after painting onto the surface has ended, with the region in which the painting was performed. More...
 
virtual void flush (QWidget *widget, const QRegion &region, const QPoint &offset)
 Flushes the given region from the specified widget onto the screen. More...
 
bool isBuffered () const
 Returns true if the QWSWindowSurface::Buffered is set; otherwise returns false. More...
 
bool isOpaque () const
 Returns true if the QWSWindowSurface::Opaque is set; otherwise returns false. More...
 
bool isRegionReserved () const
 Returns true if the QWSWindowSurface::RegionReserved is set; otherwise returns false. More...
 
virtual QString key () const =0
 Implement this function to return a string that uniquely identifies the class of this surface. More...
 
virtual bool move (const QPoint &offset)
 Move the surface with the given offset. More...
 
virtual QRegion move (const QPoint &offset, const QRegion &newClip)
 Move the surface with the given offset. More...
 
virtual QByteArray permanentState () const
 Implement this function to return the data required for creating a server-side representation of the surface. More...
 
 QWSWindowSurface ()
 Constructs an empty surface. More...
 
 QWSWindowSurface (QWidget *widget)
 Constructs an empty surface for the given top-level widget. More...
 
virtual void releaseSurface ()
 
void setClipRegion (const QRegion &)
 Sets the region currently visible on the screen to be the given clip region. More...
 
virtual void setGeometry (const QRect &rect)
 Sets the currently allocated area to be the given rect. More...
 
virtual void setGeometry (const QRect &rect, const QRegion &mask)
 
virtual void setPermanentState (const QByteArray &state)
 Implement this function to attach a server-side surface instance to the corresponding client side instance using the given data. More...
 
virtual void setTransientState (const QByteArray &state)
 
SurfaceFlags surfaceFlags () const
 Returns the surface flags describing the contents of this surface. More...
 
virtual QByteArray transientState () const
 
int winId () const
 
 ~QWSWindowSurface ()
 
- Public Functions inherited from QWindowSurface
virtual QImagebuffer (const QWidget *widget)
 Returns a QImage pointer which represents the actual buffer the widget is drawn into or 0 if this is unavailable. More...
 
virtual WindowSurfaceFeatures features () const
 
QRect geometry () const
 Returns the currently allocated area on the screen. More...
 
virtual QPixmap grabWidget (const QWidget *widget, const QRect &rectangle=QRect()) const
 Returns a QPixmap generated from the part of the backing store corresponding to widget. More...
 
bool hasFeature (WindowSurfaceFeature feature) const
 
virtual QPoint offset (const QWidget *widget) const
 Returns the offset of widget in the coordinates of this window surface. More...
 
 QWindowSurface (QWidget *window, bool setDefaultSurface=true)
 Constructs an empty surface for the given top-level window. More...
 
QRect rect (const QWidget *widget) const
 Returns the rectangle for widget in the coordinates of this window surface. More...
 
void setStaticContents (const QRegion &region)
 
QRegion staticContents () const
 
QWidgetwindow () const
 Returns a pointer to the top-level window associated with this surface. More...
 
virtual ~QWindowSurface ()
 Destroys this surface. More...
 

Protected Functions

QImage::Format preferredImageFormat (const QWidget *widget) const
 
void setLock (int lockId)
 
- Protected Functions inherited from QWSWindowSurface
void setSurfaceFlags (SurfaceFlags type)
 Sets the surface flags describing the contents of this surface, to be the given flags. More...
 
void setWinId (int id)
 
- Protected Functions inherited from QWindowSurface
bool hasStaticContents () const
 

Protected Variables

QImage img
 
QWSLockmemlock
 
QMutex threadLock
 

Additional Inherited Members

- Public Types inherited from QWSWindowSurface
enum  SurfaceFlag { RegionReserved = 0x1, Buffered = 0x2, Opaque = 0x4 }
 This enum is used to describe the window surface's contents. More...
 
- Public Types inherited from QWindowSurface
enum  WindowSurfaceFeature { PartialUpdates = 0x00000001, PreservedContents = 0x00000002, StaticContents = 0x00000004, AllFeatures = 0xffffffff }
 

Detailed Description

Definition at line 164 of file qwindowsurface_qws_p.h.

Constructors and Destructors

◆ QWSMemorySurface() [1/2]

QWSMemorySurface::QWSMemorySurface ( )

Definition at line 813 of file qwindowsurface_qws.cpp.

814  : QWSWindowSurface()
815 #ifndef QT_NO_QWS_MULTIPROCESS
816  , memlock(0)
817 #endif
818 {
820 }
void setSurfaceFlags(SurfaceFlags type)
Sets the surface flags describing the contents of this surface, to be the given flags.
QWSWindowSurface()
Constructs an empty surface.

◆ QWSMemorySurface() [2/2]

QWSMemorySurface::QWSMemorySurface ( QWidget widget)

Definition at line 822 of file qwindowsurface_qws.cpp.

823  : QWSWindowSurface(w)
824 {
825  SurfaceFlags flags = Buffered;
826  if (isWidgetOpaque(w))
827  flags |= Opaque;
828  setSurfaceFlags(flags);
829 
830 #ifndef QT_NO_QWS_MULTIPROCESS
832 #endif
833 }
bool isWidgetOpaque(const QWidget *w)
void setSurfaceFlags(SurfaceFlags type)
Sets the surface flags describing the contents of this surface, to be the given flags.
static QWSLock * getClientLock()
QWSWindowSurface()
Constructs an empty surface.

◆ ~QWSMemorySurface()

QWSMemorySurface::~QWSMemorySurface ( )

Definition at line 835 of file qwindowsurface_qws.cpp.

836 {
837 #ifndef QT_NO_QWS_MULTIPROCESS
839  delete memlock;
840 #endif
841 }
static QWSLock * getClientLock()

Functions

◆ beginPaint()

void QWSMemorySurface::beginPaint ( const QRegion region)
virtual

This function is called before painting onto the surface begins, with the region in which the painting will occur.

See also
endPaint(), paintDevice()

Reimplemented from QWSWindowSurface.

Definition at line 909 of file qwindowsurface_qws.cpp.

910 {
911  if (!isWidgetOpaque(window())) {
912  QPainter p(&img);
913  p.setCompositionMode(QPainter::CompositionMode_Source);
914  const QVector<QRect> rects = rgn.rects();
915  const QColor blank = Qt::transparent;
916  for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
917  QRect r = *it;
918 #ifdef Q_BACKINGSTORE_SUBSURFACES
920 #endif
921  p.fillRect(r, blank);
922  }
923  }
925 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
bool isWidgetOpaque(const QWidget *w)
#define it(className, varName)
virtual void beginPaint(const QRegion &)
This function is called before painting onto the surface begins, with the region in which the paintin...
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:250
QPoint painterOffset() const
Returns the offset to be used when painting.
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
Definition: qvector.h:247
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.

◆ image()

QImage QWSMemorySurface::image ( ) const
inlinevirtual

Implement this function to return an image of the top-level window.

See also
geometry()

Implements QWSWindowSurface.

Definition at line 176 of file qwindowsurface_qws_p.h.

176 { return img; }

◆ isValid()

bool QWSMemorySurface::isValid ( ) const
virtual

Implement this function to return true if the surface is a valid surface for the given top-level window; otherwise return false.

Since
4.3
See also
window(), key()

Implements QWSWindowSurface.

Reimplemented in QWSOnScreenSurface.

Definition at line 893 of file qwindowsurface_qws.cpp.

894 {
895  if (img.isNull())
896  return true;
897 
898  const QWidget *win = window();
899  if (preferredImageFormat(win) != img.format())
900  return false;
901 
902  if (isOpaque() != isWidgetOpaque(win)) // XXX: use QWidgetPrivate::isOpaque()
903  return false;
904 
905  return true;
906 }
bool isWidgetOpaque(const QWidget *w)
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
QImage::Format preferredImageFormat(const QWidget *widget) const
bool isOpaque() const
Returns true if the QWSWindowSurface::Opaque is set; otherwise returns false.
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.

◆ lock()

bool QWSMemorySurface::lock ( int  timeout = -1)
virtual

Reimplemented from QWSWindowSurface.

Definition at line 789 of file qwindowsurface_qws.cpp.

790 {
791  Q_UNUSED(timeout);
792 #ifndef QT_NO_QWS_MULTIPROCESS
794  return false;
795 #endif
796 #ifndef QT_NO_THREAD
797  threadLock.lock();
798 #endif
799  return true;
800 }
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
bool lock(LockType type, int timeout=-1)
Definition: qwslock.cpp:224
#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

◆ paintDevice()

QPaintDevice* QWSMemorySurface::paintDevice ( )
inlinevirtual

Implement this function to return the appropriate paint device.

Implements QWSWindowSurface.

Definition at line 173 of file qwindowsurface_qws_p.h.

173 { return &img; }

◆ painterOffset()

QPoint QWSMemorySurface::painterOffset ( ) const
virtual

Returns the offset to be used when painting.

See also
paintDevice()

Reimplemented from QWSWindowSurface.

Reimplemented in QWSOnScreenSurface.

Definition at line 939 of file qwindowsurface_qws.cpp.

Referenced by beginPaint().

940 {
941  const QWidget *w = window();
942  if (!w)
943  return QPoint();
944 
945  if (w->mask().isEmpty())
947 
948  const QRegion region = w->mask()
949  & w->frameGeometry().translated(-w->geometry().topLeft());
950  return -region.boundingRect().topLeft();
951 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QRect frameGeometry
geometry of the widget relative to its parent including any window frame
Definition: qwidget.h:159
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
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QRegion mask() const
Returns the mask currently set on a widget.
Definition: qwidget.cpp:10058
virtual QPoint painterOffset() const
Returns the offset to be used when painting.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ preferredImageFormat()

QImage::Format QWSMemorySurface::preferredImageFormat ( const QWidget widget) const
protected

Definition at line 845 of file qwindowsurface_qws.cpp.

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

846 {
847  QScreen *screen = getScreen(widget);
848  const int depth = screen->depth();
849  const bool opaque = isWidgetOpaque(widget);
850 
851  if (!opaque) {
852  if (depth <= 12)
854  else if (depth <= 15)
856  else if (depth <= 16)
858  else if (depth <= 18)
860  else
862  }
863 
864  QImage::Format format = screen->pixelFormat();
865  if (format > QImage::Format_Indexed8) // ### assumes all new image formats supports a QPainter
866  return format;
867 
868  if (depth <= 12)
869  return QImage::Format_RGB444;
870  else if (depth <= 15)
871  return QImage::Format_RGB555;
872  else if (depth <= 16)
873  return QImage::Format_RGB16;
874  else if (depth <= 18)
875  return QImage::Format_RGB666;
876  else if (depth <= 24)
877  return QImage::Format_RGB888;
878  else
880 }
Format
The following image formats are available in Qt.
Definition: qimage.h:91
bool isWidgetOpaque(const QWidget *w)
static QScreen * getScreen(const QWidget *w)
QImage::Format pixelFormat() const
Returns the pixel format of the screen, or QImage::Format_Invalid if the pixel format is not a suppor...
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
int depth() const
Returns the depth of the framebuffer, in bits per pixel.
Definition: qscreen_qws.h:229

◆ scroll()

bool QWSMemorySurface::scroll ( const QRegion area,
int  dx,
int  dy 
)
virtual

Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative.

Returns true if the area was scrolled successfully; false otherwise.

Reimplemented from QWindowSurface.

Definition at line 930 of file qwindowsurface_qws.cpp.

931 {
932  const QVector<QRect> rects = area.rects();
933  for (int i = 0; i < rects.size(); ++i)
934  qt_scrollRectInImage(img, rects.at(i), QPoint(dx, dy));
935 
936  return true;
937 }
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
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
void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ setLock()

void QWSMemorySurface::setLock ( int  lockId)
protected

Definition at line 883 of file qwindowsurface_qws.cpp.

Referenced by QWSSharedMemSurface::setPermanentState().

884 {
885  if (memlock && memlock->id() == lockId)
886  return;
888  delete memlock;
889  memlock = (lockId == -1 ? 0 : new QWSLock(lockId));
890 }
static QWSLock * getClientLock()
int id() const
Definition: qwslock_p.h:78

◆ unlock()

void QWSMemorySurface::unlock ( )
virtual

Reimplemented from QWSWindowSurface.

Definition at line 802 of file qwindowsurface_qws.cpp.

803 {
804 #ifndef QT_NO_THREAD
805  threadLock.unlock();
806 #endif
807 #ifndef QT_NO_QWS_MULTIPROCESS
808  if (memlock)
810 #endif
811 }
void unlock(LockType type)
Definition: qwslock.cpp:250
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296

Properties

◆ img

QImage QWSMemorySurface::img
protected

◆ memlock

QWSLock* QWSMemorySurface::memlock
protected

◆ threadLock

QMutex QWSMemorySurface::threadLock
protected

Definition at line 192 of file qwindowsurface_qws_p.h.


The documentation for this class was generated from the following files: