Qt 4.8
Public Functions | Private Functions | Properties | List of all members
PvrEglWindowSurface Class Reference

#include <pvreglwindowsurface.h>

Inheritance diagram for PvrEglWindowSurface:
QWSGLWindowSurface QWSWindowSurface QWindowSurface

Public Functions

void flush (QWidget *widget, const QRegion &region, const QPoint &offset)
 Flushes the given region from the specified widget onto the screen. 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...
 
QString key () const
 Implement this function to return a string that uniquely identifies the class of this surface. More...
 
bool move (const QPoint &offset)
 Move the surface with the given offset. More...
 
long nativeDrawable () const
 
QPaintDevicepaintDevice ()
 Implement this function to return the appropriate paint device. More...
 
QByteArray permanentState () const
 Implement this function to return the data required for creating a server-side representation of the surface. More...
 
 PvrEglWindowSurface (QWidget *widget, PvrEglScreen *screen, int screenNum)
 
 PvrEglWindowSurface ()
 
void setDirectRegion (const QRegion &region, int id)
 
void setGeometry (const QRect &rect)
 Sets the currently allocated area to be the given rect. More...
 
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...
 
 ~PvrEglWindowSurface ()
 
- Public Functions inherited from QWSGLWindowSurface
QGLContextcontext () const
 Returns the QGLContext of the window surface. More...
 
 QWSGLWindowSurface (QWidget *widget)
 Constructs an empty QWSGLWindowSurface for the given top-level window. More...
 
 QWSGLWindowSurface ()
 Constructs an empty QWSGLWindowSurface. More...
 
void setContext (QGLContext *context)
 Sets the QGLContext for this window surface to context. More...
 
 ~QWSGLWindowSurface ()
 Destroys the QWSGLWindowSurface object and frees any allocated resources. More...
 
- Public Functions inherited from QWSWindowSurface
virtual void beginPaint (const QRegion &)
 This function is called before painting onto the surface begins, with the region in which the painting will occur. More...
 
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...
 
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 lock (int timeout=-1)
 
virtual QRegion move (const QPoint &offset, const QRegion &newClip)
 Move the surface with the given offset. More...
 
virtual QPoint painterOffset () const
 Returns the offset to be used when painting. 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, 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
 
virtual void unlock ()
 
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...
 
virtual 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 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...
 

Private Functions

void transformRects (PvrQwsRect *rects, int count) const
 

Properties

PvrQwsDrawabledrawable
 
QPaintDevicepdevice
 
PvrEglScreenscreen
 
QWidgetwidget
 

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 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 50 of file pvreglwindowsurface.h.

Constructors and Destructors

◆ PvrEglWindowSurface() [1/2]

PvrEglWindowSurface::PvrEglWindowSurface ( QWidget widget,
PvrEglScreen screen,
int  screenNum 
)

Definition at line 49 of file pvreglwindowsurface.cpp.

50  : QWSGLWindowSurface(widget)
51 {
53 
54  this->widget = widget;
55  this->screen = screen;
56  this->pdevice = 0;
57 
58  QPoint pos = offset(widget);
59  QSize size = widget->size();
60 
61  PvrQwsRect pvrRect;
62  pvrRect.x = pos.x();
63  pvrRect.y = pos.y();
64  pvrRect.width = size.width();
65  pvrRect.height = size.height();
66  transformRects(&pvrRect, 1);
67 
68  // Try to recover a previous PvrQwsDrawable object for the widget
69  // if there is one. This can happen when a PvrEglWindowSurface
70  // is created for a widget, bound to a EGLSurface, and then destroyed.
71  // When a new PvrEglWindowSurface is created for the widget, it will
72  // pick up the previous PvrQwsDrawable if the EGLSurface has not been
73  // destroyed in the meantime.
74  drawable = pvrQwsFetchWindow((long)widget);
75  if (drawable)
76  pvrQwsSetGeometry(drawable, &pvrRect);
77  else
78  drawable = pvrQwsCreateWindow(screenNum, (long)widget, &pvrRect);
80 }
void pvrQwsSetGeometry(PvrQwsDrawable *drawable, const PvrQwsRect *rect)
QWSGLWindowSurface()
Constructs an empty QWSGLWindowSurface.
PvrQwsDrawable * pvrQwsFetchWindow(long winId)
virtual QPoint offset(const QWidget *widget) const
Returns the offset of widget in the coordinates of this window surface.
void setSurfaceFlags(SurfaceFlags type)
Sets the surface flags describing the contents of this surface, to be the given flags.
int width() const
Returns the width.
Definition: qsize.h:126
int transformation() const
PvrQwsDrawable * pvrQwsCreateWindow(int screen, long winId, const PvrQwsRect *rect)
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int height() const
Returns the height.
Definition: qsize.h:129
void transformRects(PvrQwsRect *rects, int count) const
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
PvrQwsDrawable * drawable

◆ PvrEglWindowSurface() [2/2]

PvrEglWindowSurface::PvrEglWindowSurface ( )

Definition at line 82 of file pvreglwindowsurface.cpp.

84 {
86  drawable = 0;
87  widget = 0;
88  screen = 0;
89  pdevice = 0;
90 }
QWSGLWindowSurface()
Constructs an empty QWSGLWindowSurface.
void setSurfaceFlags(SurfaceFlags type)
Sets the surface flags describing the contents of this surface, to be the given flags.
PvrQwsDrawable * drawable

◆ ~PvrEglWindowSurface()

PvrEglWindowSurface::~PvrEglWindowSurface ( )

Definition at line 92 of file pvreglwindowsurface.cpp.

93 {
94  // Release the PvrQwsDrawable. If it is bound to an EGLSurface,
95  // then it will stay around until a new PvrEglWindowSurface is
96  // created for the widget. If it is not bound to an EGLSurface,
97  // it will be destroyed immediately.
100 
101  delete pdevice;
102 }
int pvrQwsReleaseWindow(PvrQwsDrawable *drawable)
void pvrQwsDestroyDrawable(PvrQwsDrawable *drawable)
PvrQwsDrawable * drawable

Functions

◆ flush()

void PvrEglWindowSurface::flush ( QWidget widget,
const QRegion region,
const QPoint offset 
)
virtual

Flushes the given region from the specified widget onto the screen.

Note that the offset parameter is currently unused.

Reimplemented from QWSWindowSurface.

Definition at line 153 of file pvreglwindowsurface.cpp.

Referenced by key(), and setPermanentState().

154 {
155  // The GL paint engine is responsible for the swapBuffers() call.
156  // If we were to call the base class's implementation of flush()
157  // then it would fetch the image() and manually blit it to the
158  // screeen instead of using the fast PVR2D blit.
159  Q_UNUSED(widget);
160  Q_UNUSED(region);
161  Q_UNUSED(offset);
162 }
#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

◆ image()

QImage PvrEglWindowSurface::image ( ) const
virtual

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

See also
geometry()

Implements QWSWindowSurface.

Definition at line 164 of file pvreglwindowsurface.cpp.

Referenced by key().

165 {
166  if (drawable) {
167  PvrQwsRect pvrRect;
168  pvrQwsGetGeometry(drawable, &pvrRect);
170  if (data) {
171  return QImage((uchar *)data, pvrRect.width, pvrRect.height,
173  }
174  }
175  return QImage(16, 16, screen->pixelFormat());
176 }
void pvrQwsGetGeometry(PvrQwsDrawable *drawable, PvrQwsRect *rect)
int pvrQwsGetStride(PvrQwsDrawable *drawable)
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
static const char * data(const QByteArray &arr)
QImage::Format pixelFormat() const
Returns the pixel format of the screen, or QImage::Format_Invalid if the pixel format is not a suppor...
PvrQwsDrawable * drawable
void * pvrQwsGetRenderBuffer(PvrQwsDrawable *drawable)

◆ isValid()

bool PvrEglWindowSurface::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.

Definition at line 104 of file pvreglwindowsurface.cpp.

Referenced by key().

105 {
106  return (widget != 0);
107 }

◆ key()

QString PvrEglWindowSurface::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 57 of file pvreglwindowsurface.h.

57 { return QLatin1String("PvrEgl"); }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ move()

bool PvrEglWindowSurface::move ( const QPoint offset)
virtual

Move the surface with the given offset.

A subclass may reimplement this function to enable accelerated window move. It must return true if the move was successful and no repaint is necessary, false otherwise.

The default implementation updates the QWindowSurface geometry and returns true if the surface is buffered; false otherwise.

This function is called by the window system on the client instance.

See also
isBuffered()

Reimplemented from QWSWindowSurface.

Definition at line 125 of file pvreglwindowsurface.cpp.

Referenced by key().

126 {
127  QRect rect = geometry().translated(offset);
128  if (drawable) {
129  PvrQwsRect pvrRect;
130  pvrRect.x = rect.x();
131  pvrRect.y = rect.y();
132  pvrRect.width = rect.width();
133  pvrRect.height = rect.height();
134  transformRects(&pvrRect, 1);
135  pvrQwsSetGeometry(drawable, &pvrRect);
137  }
138  return QWSGLWindowSurface::move(offset);
139 }
void pvrQwsSetGeometry(PvrQwsDrawable *drawable, const PvrQwsRect *rect)
QRect geometry() const
Returns the currently allocated area on the screen.
QRect rect(const QWidget *widget) const
Returns the rectangle for widget in the coordinates of this window surface.
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 width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int transformation() const
virtual bool move(const QPoint &offset)
Move the surface with the given offset.
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle)
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void transformRects(PvrQwsRect *rects, int count) const
PvrQwsDrawable * drawable

◆ nativeDrawable()

long PvrEglWindowSurface::nativeDrawable ( ) const
inline

Definition at line 74 of file pvreglwindowsurface.h.

Referenced by PvrEglScreenSurfaceFunctions::createNativeWindow().

74 { return (long)widget; }

◆ paintDevice()

QPaintDevice * PvrEglWindowSurface::paintDevice ( )
virtual

Implement this function to return the appropriate paint device.

Implements QWSWindowSurface.

Definition at line 178 of file pvreglwindowsurface.cpp.

Referenced by key().

179 {
180  return widget;
181 }

◆ permanentState()

QByteArray PvrEglWindowSurface::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 141 of file pvreglwindowsurface.cpp.

Referenced by key().

142 {
143  // Nothing interesting to pass to the server just yet.
144  return QByteArray();
145 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135

◆ setDirectRegion()

void PvrEglWindowSurface::setDirectRegion ( const QRegion region,
int  id 
)

Definition at line 183 of file pvreglwindowsurface.cpp.

Referenced by key().

184 {
185  QWSGLWindowSurface::setDirectRegion(r, id);
186 
187  if (!drawable)
188  return;
189 
190  // Clip the region to the window boundaries in case the child
191  // is partially outside the geometry of the parent.
192  QWidget *window = widget->window();
193  QRegion region = r;
194  if (widget != window) {
195  QRect rect = window->geometry();
196  rect.moveTo(window->mapToGlobal(QPoint(0, 0)));
197  region = region.intersect(rect);
198  }
199 
200  if (region.isEmpty()) {
202  } else if (region.rectCount() == 1) {
203  QRect rect = region.boundingRect();
204  PvrQwsRect pvrRect;
205  pvrRect.x = rect.x();
206  pvrRect.y = rect.y();
207  pvrRect.width = rect.width();
208  pvrRect.height = rect.height();
209  transformRects(&pvrRect, 1);
210  pvrQwsSetVisibleRegion(drawable, &pvrRect, 1);
212  if (!pvrQwsSwapBuffers(drawable, 1))
213  screen->solidFill(QColor(0, 0, 0), region);
214  } else {
215  QVector<QRect> rects = region.rects();
216  PvrQwsRect *pvrRects = new PvrQwsRect [rects.size()];
217  for (int index = 0; index < rects.size(); ++index) {
218  QRect rect = rects[index];
219  pvrRects[index].x = rect.x();
220  pvrRects[index].y = rect.y();
221  pvrRects[index].width = rect.width();
222  pvrRects[index].height = rect.height();
223  }
224  transformRects(pvrRects, rects.size());
225  pvrQwsSetVisibleRegion(drawable, pvrRects, rects.size());
227  if (!pvrQwsSwapBuffers(drawable, 1))
228  screen->solidFill(QColor(0, 0, 0), region);
229  delete [] pvrRects;
230  }
231 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
void pvrQwsClearVisibleRegion(PvrQwsDrawable *drawable)
void solidFill(const QColor &color, const QRegion &region)
Fills the given region of the screen with the specified color.
QRect rect(const QWidget *widget) const
Returns the rectangle for widget in the coordinates of this window surface.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
void moveTo(int x, int t)
Moves the rectangle, leaving the top-left corner at the given position (x, y).
Definition: qrect.h:334
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Definition: qregion.cpp:4461
int transformation() const
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QRegion intersect(const QRegion &r) const
Use intersected(r) instead.
Definition: qregion.cpp:4249
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle)
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void transformRects(PvrQwsRect *rects, int count) const
quint16 index
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
int pvrQwsSwapBuffers(PvrQwsDrawable *drawable, int repaintOnly)
void pvrQwsSetVisibleRegion(PvrQwsDrawable *drawable, const PvrQwsRect *rects, int numRects)
PvrQwsDrawable * drawable
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.

◆ setGeometry()

void PvrEglWindowSurface::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 109 of file pvreglwindowsurface.cpp.

Referenced by key().

110 {
111  if (drawable) {
112  // XXX: adjust for the screen offset.
113  PvrQwsRect pvrRect;
114  pvrRect.x = rect.x();
115  pvrRect.y = rect.y();
116  pvrRect.width = rect.width();
117  pvrRect.height = rect.height();
118  transformRects(&pvrRect, 1);
119  pvrQwsSetGeometry(drawable, &pvrRect);
121  }
123 }
void pvrQwsSetGeometry(PvrQwsDrawable *drawable, const PvrQwsRect *rect)
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int transformation() const
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle)
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void transformRects(PvrQwsRect *rects, int count) const
PvrQwsDrawable * drawable
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.

◆ setPermanentState()

void PvrEglWindowSurface::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 147 of file pvreglwindowsurface.cpp.

Referenced by key().

148 {
149  Q_UNUSED(state);
150 }
#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

◆ transformRects()

void PvrEglWindowSurface::transformRects ( PvrQwsRect rects,
int  count 
) const
private

Definition at line 233 of file pvreglwindowsurface.cpp.

Referenced by move(), setDirectRegion(), and setGeometry().

234 {
235  switch (screen->transformation()) {
236  case 0: break;
237 
238  case 90:
239  {
240  for (int index = 0; index < count; ++index) {
241  int x = rects[index].y;
242  int y = screen->height() - (rects[index].x + rects[index].width);
243  rects[index].x = x;
244  rects[index].y = y;
245  qSwap(rects[index].width, rects[index].height);
246  }
247  }
248  break;
249 
250  case 180:
251  {
252  for (int index = 0; index < count; ++index) {
253  int x = screen->width() - (rects[index].x + rects[index].width);
254  int y = screen->height() - (rects[index].y + rects[index].height);
255  rects[index].x = x;
256  rects[index].y = y;
257  }
258  }
259  break;
260 
261  case 270:
262  {
263  for (int index = 0; index < count; ++index) {
264  int x = screen->width() - (rects[index].y + rects[index].height);
265  int y = rects[index].x;
266  rects[index].x = x;
267  rects[index].y = y;
268  qSwap(rects[index].width, rects[index].height);
269  }
270  }
271  break;
272  }
273 }
int height() const
Returns the logical height of the framebuffer in pixels.
Definition: qscreen_qws.h:228
int width() const
Returns the logical width of the framebuffer in pixels.
Definition: qscreen_qws.h:227
int transformation() const
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
quint16 index

Properties

◆ drawable

PvrQwsDrawable* PvrEglWindowSurface::drawable
private

◆ pdevice

QPaintDevice* PvrEglWindowSurface::pdevice
private

Definition at line 80 of file pvreglwindowsurface.h.

Referenced by PvrEglWindowSurface(), and ~PvrEglWindowSurface().

◆ screen

PvrEglScreen* PvrEglWindowSurface::screen
private

Definition at line 79 of file pvreglwindowsurface.h.

◆ widget

QWidget* PvrEglWindowSurface::widget
private

Definition at line 77 of file pvreglwindowsurface.h.

Referenced by nativeDrawable(), and paintDevice().


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