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

#include <qwindowsurface_qws_p.h>

Inheritance diagram for QWSLocalMemSurface:
QWSMemorySurface QWSWindowSurface QWindowSurface

Public Functions

QString key () const
 Implement this function to return a string that uniquely identifies the class of this surface. More...
 
QByteArray permanentState () const
 Implement this function to return the data required for creating a server-side representation of the surface. More...
 
 QWSLocalMemSurface ()
 
 QWSLocalMemSurface (QWidget *widget)
 
virtual void releaseSurface ()
 
void setGeometry (const QRect &rect)
 Sets the currently allocated area to be the given rect. More...
 
void setPermanentState (const QByteArray &data)
 Implement this function to attach a server-side surface instance to the corresponding client side instance using the given data. More...
 
 ~QWSLocalMemSurface ()
 
- Public Functions inherited from QWSMemorySurface
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 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...
 
 QWSWindowSurface ()
 Constructs an empty surface. More...
 
 QWSWindowSurface (QWidget *widget)
 Constructs an empty surface for the given top-level widget. More...
 
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, const QRegion &mask)
 
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 Variables

ucharmem
 
int memsize
 
- Protected Variables inherited from QWSMemorySurface
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 }
 
- Protected Functions inherited from QWSMemorySurface
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
 

Detailed Description

Definition at line 198 of file qwindowsurface_qws_p.h.

Constructors and Destructors

◆ QWSLocalMemSurface() [1/2]

QWSLocalMemSurface::QWSLocalMemSurface ( )

Definition at line 953 of file qwindowsurface_qws.cpp.

◆ QWSLocalMemSurface() [2/2]

QWSLocalMemSurface::QWSLocalMemSurface ( QWidget widget)

Definition at line 958 of file qwindowsurface_qws.cpp.

◆ ~QWSLocalMemSurface()

QWSLocalMemSurface::~QWSLocalMemSurface ( )

Definition at line 963 of file qwindowsurface_qws.cpp.

964 {
965  if (memsize)
966  delete[] mem;
967 }

Functions

◆ key()

QString QWSLocalMemSurface::key ( ) const
inlinevirtual

Implement this function to return a string that uniquely identifies the class of this surface.

See also
window(), isValid()

Implements QWSWindowSurface.

Definition at line 207 of file qwindowsurface_qws_p.h.

207 { return QLatin1String("mem"); }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ permanentState()

QByteArray QWSLocalMemSurface::permanentState ( ) const
virtual

Implement this function to return the data required for creating a server-side representation of the surface.

Since
4.3
See also
attach()

Reimplemented from QWSWindowSurface.

Definition at line 1011 of file qwindowsurface_qws.cpp.

1012 {
1013  QByteArray array(sizeof(uchar*) + 3 * sizeof(int) + sizeof(SurfaceFlags), Qt::Uninitialized);
1014 
1015  char *ptr = array.data();
1016 
1017  *reinterpret_cast<uchar**>(ptr) = mem;
1018  ptr += sizeof(uchar*);
1019 
1020  reinterpret_cast<int*>(ptr)[0] = img.width();
1021  reinterpret_cast<int*>(ptr)[1] = img.height();
1022  ptr += 2 * sizeof(int);
1023 
1024  *reinterpret_cast<int *>(ptr) = img.format();
1025  ptr += sizeof(int);
1026 
1027  *reinterpret_cast<SurfaceFlags*>(ptr) = surfaceFlags();
1028 
1029  return array;
1030 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
unsigned char uchar
Definition: qglobal.h:994
const T * ptr(const T &t)
SurfaceFlags surfaceFlags() const
Returns the surface flags describing the contents of this surface.
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572

◆ releaseSurface()

void QWSLocalMemSurface::releaseSurface ( )
virtual

Reimplemented from QWSWindowSurface.

Definition at line 1063 of file qwindowsurface_qws.cpp.

1064 {
1065  if (memsize) {
1066  delete[] mem;
1067  memsize = 0;
1068  }
1069  mem = 0;
1070  img = QImage();
1071 }
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87

◆ setGeometry()

void QWSLocalMemSurface::setGeometry ( const QRect rect)
virtual

Sets the currently allocated area to be the given rect.

This function is called whenever area covered by the top-level window changes.

See also
geometry()

Reimplemented from QWSWindowSurface.

Definition at line 969 of file qwindowsurface_qws.cpp.

970 {
971  QSize size = rect.size();
972 
973  QWidget *win = window();
974  if (win && !win->mask().isEmpty()) {
975  const QRegion region = win->mask()
976  & rect.translated(-win->geometry().topLeft());
977  size = region.boundingRect().size();
978  }
979 
980  uchar *deleteLater = 0;
981 
982  if (img.size() != size) {
983  if (size.isEmpty()) {
984  if (memsize) {
985  // In case of a Hide event we need to delete the memory after sending the
986  // event to the server in order to let the server animate the event.
987  deleteLater = mem;
988  memsize = 0;
989  }
990  mem = 0;
991  img = QImage();
992  } else {
994  const int bpl = nextMulOf4(bytesPerPixel(format) * size.width());
995  const int imagesize = bpl * size.height();
996  if (memsize < imagesize) {
997  delete[] mem;
998  memsize = imagesize;
999  mem = new uchar[memsize];
1000  }
1001  img = QImage(mem, size.width(), size.height(), bpl, format);
1002  setImageMetrics(img, win);
1003  }
1004  }
1005 
1007 
1008  delete[] deleteLater;
1009 }
Format
The following image formats are available in Qt.
Definition: qimage.h:91
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static int bytesPerPixel(QImage::Format format)
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
static int nextMulOf4(int n)
unsigned char uchar
Definition: qglobal.h:994
int width() const
Returns the width.
Definition: qsize.h:126
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QImage::Format preferredImageFormat(const QWidget *widget) const
QRegion mask() const
Returns the mask currently set on a widget.
Definition: qwidget.cpp:10058
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
static void setImageMetrics(QImage &img, QWidget *window)
int height() const
Returns the height.
Definition: qsize.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Definition: qsize.h:120
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.
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ setPermanentState()

void QWSLocalMemSurface::setPermanentState ( const QByteArray data)
virtual

Implement this function to attach a server-side surface instance to the corresponding client side instance using the given data.

Since
4.3

Return true if successful; otherwise return false.

See also
data()

Reimplemented from QWSWindowSurface.

Definition at line 1032 of file qwindowsurface_qws.cpp.

1033 {
1034  if (memsize) {
1035  delete[] mem;
1036  memsize = 0;
1037  }
1038 
1039  int width;
1040  int height;
1042  SurfaceFlags flags;
1043 
1044  const char *ptr = data.constData();
1045 
1046  mem = *reinterpret_cast<uchar* const*>(ptr);
1047  ptr += sizeof(uchar*);
1048 
1049  width = reinterpret_cast<const int*>(ptr)[0];
1050  height = reinterpret_cast<const int*>(ptr)[1];
1051  ptr += 2 * sizeof(int);
1052 
1053  format = QImage::Format(*reinterpret_cast<const int*>(ptr));
1054  ptr += sizeof(int);
1055 
1056  flags = *reinterpret_cast<const SurfaceFlags*>(ptr);
1057 
1058  const int bpl = nextMulOf4(bytesPerPixel(format) * width);
1059  QWSMemorySurface::img = QImage(mem, width, height, bpl, format);
1060  setSurfaceFlags(flags);
1061 }
Format
The following image formats are available in Qt.
Definition: qimage.h:91
static int bytesPerPixel(QImage::Format format)
void setSurfaceFlags(SurfaceFlags type)
Sets the surface flags describing the contents of this surface, to be the given flags.
static int nextMulOf4(int n)
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
const T * ptr(const T &t)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433

Properties

◆ mem

uchar* QWSLocalMemSurface::mem
protected

◆ memsize

int QWSLocalMemSurface::memsize
protected

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