Qt 4.8
Public Types | Public Functions | Protected Functions | Properties | List of all members
QWindowSurface Class Referenceabstract

The QWindowSurface class provides the drawing area for top-level windows. More...

#include <qwindowsurface_p.h>

Inheritance diagram for QWindowSurface:
QBBGLWindowSurface QBBRasterWindowSurface QCocoaWindowSurface QDirectFbWindowSurface QDummyWindowSurface QEglFSWindowSurface QFbWindowSurface QGLWindowSurface QMacWindowSurface QMinimalWindowSurface QRasterWindowSurface QRuntimeWindowSurface QUIKitWindowSurface QVFbWindowSurface QVGWindowSurface QWaylandGLWindowSurface QWaylandShmWindowSurface QWSWindowSurface QX11GLWindowSurface QX11WindowSurface QXcbWindowSurface QXlibWindowSurface ShivaVGWindowSurface

Public Types

enum  WindowSurfaceFeature { PartialUpdates = 0x00000001, PreservedContents = 0x00000002, StaticContents = 0x00000004, AllFeatures = 0xffffffff }
 

Public Functions

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...
 
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 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 WindowSurfaceFeatures features () const
 
virtual void flush (QWidget *widget, const QRegion &region, const QPoint &offset)=0
 Flushes the given region from the specified widget onto the screen. More...
 
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...
 
virtual QPaintDevicepaintDevice ()=0
 Implement this function to return the appropriate paint device. 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...
 
virtual void setGeometry (const QRect &rect)
 Sets the currently allocated area to be the given rect. 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

bool hasStaticContents () const
 

Properties

QWindowSurfacePrivated_ptr
 

Detailed Description

The QWindowSurface class provides the drawing area for top-level windows.

Since
4.3
Warning
This function is not part of the public interface. This function is under development and subject to change.

Definition at line 68 of file qwindowsurface_p.h.

Enumerations

◆ WindowSurfaceFeature

Enumerator
PartialUpdates 
PreservedContents 
StaticContents 
AllFeatures 

Definition at line 71 of file qwindowsurface_p.h.

71  {
72  PartialUpdates = 0x00000001, // Supports doing partial updates.
73  PreservedContents = 0x00000002, // Supports doing flush without first doing a repaint.
74  StaticContents = 0x00000004, // Supports having static content regions when being resized.
75  AllFeatures = 0xffffffff // For convenience
76  };

Constructors and Destructors

◆ QWindowSurface()

QWindowSurface::QWindowSurface ( QWidget window,
bool  setDefaultSurface = true 
)

Constructs an empty surface for the given top-level window.

Definition at line 126 of file qwindowsurface.cpp.

127  : d_ptr(new QWindowSurfacePrivate(window))
128 {
130  if(setDefaultSurface && window)
131  window->setWindowSurface(this);
132  }
133 }
void setWindowSurface(QWindowSurface *surface)
Sets the window surface to be the surface specified.
Definition: qwidget.cpp:12774
static bool runtime_graphics_system
QWindowSurfacePrivate * d_ptr

◆ ~QWindowSurface()

QWindowSurface::~QWindowSurface ( )
virtual

Destroys this surface.

Definition at line 138 of file qwindowsurface.cpp.

139 {
140  if (d_ptr->window)
141  d_ptr->window->d_func()->extra->topextra->windowSurface = 0;
142  delete d_ptr;
143 }
QWindowSurface * windowSurface() const
Returns the QWindowSurface this widget will be drawn into.
Definition: qwidget.cpp:12819
QWindowSurfacePrivate * d_ptr

Functions

◆ beginPaint()

void QWindowSurface::beginPaint ( const QRegion region)
virtual

◆ buffer()

QImage * QWindowSurface::buffer ( const QWidget widget)
virtual

Returns a QImage pointer which represents the actual buffer the widget is drawn into or 0 if this is unavailable.

You must call beginPaint() before you call this function and the returned pointer is only valid until endPaint() is called.

Reimplemented in QRuntimeWindowSurface, and QGLWindowSurface.

Definition at line 229 of file qwindowsurface.cpp.

Referenced by QRuntimeWindowSurface::buffer(), and grabWidget().

230 {
231  if (widget->window() != window())
232  return 0;
233 
234  QPaintDevice *pdev = paintDevice();
235  if (!pdev || pdev->devType() != QInternal::Image)
236  return 0;
237 
238  const QPoint off = offset(widget);
239  QImage *img = static_cast<QImage*>(pdev);
240 
241  QRect rect(off, widget->size());
242  rect &= QRect(QPoint(), img->size());
243 
244  if (rect.isEmpty())
245  return 0;
246 
247  img = new QImage(img->scanLine(rect.y()) + rect.x() * img->depth() / 8,
248  rect.width(), rect.height(),
249  img->bytesPerLine(), img->format());
250  d_ptr->bufferImages.append(img);
251 
252  return img;
253 }
QRect rect(const QWidget *widget) const
Returns the rectangle for widget in the coordinates of this window surface.
virtual QPoint offset(const QWidget *widget) const
Returns the offset of widget in the coordinates of this window surface.
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
virtual int devType() const
Definition: qpaintdevice.h:167
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
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
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QList< QImage * > bufferImages
QWindowSurfacePrivate * d_ptr
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886
virtual QPaintDevice * paintDevice()=0
Implement this function to return the appropriate paint device.

◆ endPaint()

void QWindowSurface::endPaint ( const QRegion region)
virtual

This function is called after painting onto the surface has ended, with the region in which the painting was performed.

See also
beginPaint(), paintDevice()

Reimplemented in QRuntimeWindowSurface, QFbWindowSurface, QGLWindowSurface, QDirectFBWindowSurface, QWSWindowSurface, QVGWindowSurface, QBBGLWindowSurface, QXlibWindowSurface, QXcbWindowSurface, QBBRasterWindowSurface, QDirectFbWindowSurface, ShivaVGWindowSurface, and QTraceWindowSurface.

Definition at line 158 of file qwindowsurface.cpp.

Referenced by QTraceWindowSurface::endPaint(), QRuntimeWindowSurface::endPaint(), QWidgetBackingStore::endPaint(), and QWidgetBackingStore::removeDirtyWidget().

159 {
160 // QApplication::syncX();
163 }
void clear()
Removes all items from the list.
Definition: qlist.h:764
QList< QImage * > bufferImages
QWindowSurfacePrivate * d_ptr
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ features()

QWindowSurface::WindowSurfaceFeatures QWindowSurface::features ( ) const
virtual

◆ flush()

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

◆ geometry()

QRect QWindowSurface::geometry ( ) const

◆ grabWidget()

QPixmap QWindowSurface::grabWidget ( const QWidget widget,
const QRect rectangle = QRect() 
) const
virtual

Returns a QPixmap generated from the part of the backing store corresponding to widget.

Returns a null QPixmap if an error occurs. The contents of the pixmap are only defined for the regions of widget that have received paint events since the last resize of the backing store.

If rectangle is a null rectangle (the default), the entire widget is grabbed. Otherwise, the grabbed area is limited to rectangle.

The default implementation uses QWindowSurface::buffer().

See also
QPixmap::grabWidget()

Reimplemented in QRuntimeWindowSurface, QX11WindowSurface, QX11GLWindowSurface, and QBBRasterWindowSurface.

Definition at line 269 of file qwindowsurface.cpp.

Referenced by QBBRasterWindowSurface::grabWidget(), and QRuntimeWindowSurface::grabWidget().

270 {
271  QPixmap result;
272 
273  if (widget->window() != window())
274  return result;
275 
276  const QImage *img = const_cast<QWindowSurface *>(this)->buffer(widget->window());
277 
278  if (!img || img->isNull())
279  return result;
280 
281  QRect rect = rectangle.isEmpty() ? widget->rect() : (widget->rect() & rectangle);
282 
283  rect.translate(offset(widget) - offset(widget->window()));
284  rect &= QRect(QPoint(), img->size());
285 
286  if (rect.isEmpty())
287  return result;
288 
289  QImage subimg(img->scanLine(rect.y()) + rect.x() * img->depth() / 8,
290  rect.width(), rect.height(),
291  img->bytesPerLine(), img->format());
292  subimg.detach(); //### expensive -- maybe we should have a real SubImage that shares reference count
293 
294  result = QPixmap::fromImage(subimg);
295  return result;
296 }
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
QRect rect(const QWidget *widget) const
Returns the rectangle for widget in the coordinates of this window surface.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
virtual QPoint offset(const QWidget *widget) const
Returns the offset of widget in the coordinates of this window surface.
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
void detach()
If multiple images share common data, this image makes a copy of the data and detaches itself from th...
Definition: qimage.cpp:1359
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
The QWindowSurface class provides the drawing area for top-level windows.
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual QImage * buffer(const QWidget *widget)
Returns a QImage pointer which represents the actual buffer the widget is drawn into or 0 if this is ...
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886

◆ hasFeature()

bool QWindowSurface::hasFeature ( WindowSurfaceFeature  feature) const
inline

Definition at line 131 of file qwindowsurface_p.h.

Referenced by hasStaticContents(), QWidgetBackingStore::hasStaticContents(), QWidgetBackingStore::markDirty(), and QWidgetBackingStore::sync().

132 {
133  return (features() & feature) != 0;
134 }
virtual WindowSurfaceFeatures features() const

◆ hasStaticContents()

bool QWindowSurface::hasStaticContents ( ) const
protected

Definition at line 329 of file qwindowsurface.cpp.

Referenced by QRasterWindowSurface::prepareBuffer(), and QX11WindowSurface::setGeometry().

330 {
332 }
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
bool hasFeature(WindowSurfaceFeature feature) const
QWindowSurfacePrivate * d_ptr

◆ offset()

QPoint QWindowSurface::offset ( const QWidget widget) const
virtual

Returns the offset of widget in the coordinates of this window surface.

Reimplemented in QRuntimeWindowSurface.

Definition at line 302 of file qwindowsurface.cpp.

Referenced by addCircle(), QWSMemorySurface::beginPaint(), buffer(), QXlibWindowSurface::flush(), good_offset(), grabWidget(), PvrEglWindowSurface::key(), QRuntimeWindowSurface::offset(), QEglFSWindowSurface::paintDevice(), qt_scrollRectInImage(), QXcbWindowSurface::resize(), QRasterWindowSurface::setGeometry(), and shift().

303 {
305  QPoint offset = widget->mapTo(window, QPoint());
306 #ifdef Q_WS_QWS
307  offset += window->geometry().topLeft() - window->frameGeometry().topLeft();
308 #endif
309  return offset;
310 }
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
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
virtual QPoint offset(const QWidget *widget) const
Returns the offset of widget in the coordinates of this window surface.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QWindowSurfacePrivate * d_ptr
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

◆ paintDevice()

QPaintDevice * QWindowSurface::paintDevice ( )
pure virtual

◆ rect()

QRect QWindowSurface::rect ( const QWidget widget) const
inline

Returns the rectangle for widget in the coordinates of this window surface.

Definition at line 126 of file qwindowsurface_p.h.

Referenced by QWSMemorySurface::beginPaint(), buffer(), QDirectFbWindowSurface::flush(), QWaylandGLWindowSurface::flush(), QCocoaWindowSurface::flush(), QXlibWindowSurface::flush(), QWaylandShmWindowSurface::flush(), QMacWindowSurface::flush(), QGLWindowSurface::flush(), QRasterWindowSurface::flush(), grabWidget(), PvrEglWindowSurface::key(), PvrEglWindowSurface::move(), QGLWindowSurface::paintDevice(), QCocoaWindowSurface::QCocoaWindowSurface(), rect(), QXcbWindowSurface::resize(), QVFbWindowSurface::resize(), QX11GLWindowSurface::scroll(), QMacWindowSurface::scroll(), QX11WindowSurface::scroll(), QDirectFBWindowSurface::scroll(), scrollSurface(), PvrEglWindowSurface::setDirectRegion(), QWSWindowSurface::setGeometry(), setGeometry(), and QRasterWindowSurface::setGeometry().

127 {
128  return widget->rect().translated(offset(widget));
129 }
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
virtual QPoint offset(const QWidget *widget) const
Returns the offset of widget in the coordinates of this window surface.
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168

◆ scroll()

bool QWindowSurface::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 in QWSMemorySurface, QRuntimeWindowSurface, QRasterWindowSurface, QFbWindowSurface, QGLWindowSurface, QDirectFBWindowSurface, QX11WindowSurface, QVGWindowSurface, QMacWindowSurface, QX11GLWindowSurface, QTraceWindowSurface, QXlibWindowSurface, QBBRasterWindowSurface, QXcbWindowSurface, QDirectFbWindowSurface, and ShivaVGWindowSurface.

Definition at line 213 of file qwindowsurface.cpp.

Referenced by QWidgetBackingStore::bltRect(), QWSMemorySurface::paintDevice(), ShivaVGWindowSurface::scroll(), QVGWindowSurface::scroll(), QFbWindowSurface::scroll(), and QRuntimeWindowSurface::scroll().

214 {
215  Q_UNUSED(area);
216  Q_UNUSED(dx);
217  Q_UNUSED(dy);
218 
219  return false;
220 }
#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

◆ setGeometry()

void QWindowSurface::setGeometry ( const QRect rect)
virtual

◆ setStaticContents()

void QWindowSurface::setStaticContents ( const QRegion region)

Definition at line 319 of file qwindowsurface.cpp.

Referenced by QWidgetBackingStore::sync().

320 {
321  d_ptr->staticContents = region;
322 }
QWindowSurfacePrivate * d_ptr

◆ staticContents()

QRegion QWindowSurface::staticContents ( ) const

Definition at line 324 of file qwindowsurface.cpp.

Referenced by QRasterWindowSurface::prepareBuffer(), and QX11WindowSurface::setGeometry().

325 {
326  return d_ptr->staticContents;
327 }
QWindowSurfacePrivate * d_ptr

◆ window()

QWidget * QWindowSurface::window ( ) const

Returns a pointer to the top-level window associated with this surface.

Definition at line 149 of file qwindowsurface.cpp.

Referenced by QWaylandGLWindowSurface::beginPaint(), QBBRasterWindowSurface::beginPaint(), QWaylandShmWindowSurface::beginPaint(), QBBGLWindowSurface::beginPaint(), QVGWindowSurface::beginPaint(), QDirectFBWindowSurface::beginPaint(), QGLWindowSurface::beginPaint(), QRasterWindowSurface::beginPaint(), QWidgetBackingStore::beginPaint(), QWSMemorySurface::beginPaint(), buffer(), QDirectFBWindowSurface::createWindow(), QGLWindowSurface::deleted(), QTraceWindowSurface::endPaint(), QBBRasterWindowSurface::endPaint(), QBBGLWindowSurface::endPaint(), QXcbWindowSurface::flush(), QBBRasterWindowSurface::flush(), QXlibWindowSurface::flush(), QX11GLWindowSurface::flush(), QVGWindowSurface::flush(), QWaylandShmWindowSurface::flush(), QBBGLWindowSurface::flush(), QWSWindowSurface::flush(), QDirectFBWindowSurface::flush(), QGLWindowSurface::flush(), QRasterWindowSurface::flush(), QX11GLWindowSurface::grabWidget(), QX11WindowSurface::grabWidget(), grabWidget(), QWSWindowSurface::invalidateBuffer(), EGLNullWSWindowSurface::isValid(), QWSMemorySurface::isValid(), QWSOnScreenSurface::isValid(), ShivaVGWindowSurface::metric(), QVGWindowSurface::metric(), offset(), ShivaVGWindowSurface::paintDevice(), QGLWindowSurface::paintDevice(), QWSWindowSurface::painterOffset(), QWSMemorySurface::painterOffset(), QWSOnScreenSurface::permanentState(), QRasterWindowSurface::prepareBuffer(), QBBGLWindowSurface::QBBGLWindowSurface(), QBBRasterWindowSurface::QBBRasterWindowSurface(), QCocoaWindowSurface::QCocoaWindowSurface(), QApplication::qwsProcessEvent(), QDirectFBWindowSurface::raise(), QXcbWindowSurface::resize(), QBBRasterWindowSurface::resize(), QWaylandGLWindowSurface::resize(), QWaylandShmWindowSurface::resize(), QBBGLWindowSurface::resize(), QBBRasterWindowSurface::scroll(), QGLWindowSurface::scroll(), QWSWindowSurface::setClipRegion(), PvrEglWindowSurface::setDirectRegion(), QX11GLWindowSurface::setGeometry(), QDirectFBWindowSurface::setGeometry(), QWSWindowSurface::setGeometry(), QRasterWindowSurface::setGeometry(), QWSLocalMemSurface::setGeometry(), QWSSharedMemSurface::setGeometry(), QRuntimeGraphicsSystem::setGraphicsSystem(), QDirectFBWindowSurface::surfaceForWidget(), QWidgetBackingStore::sync(), QGLWindowSurface::updateGeometry(), QDirectFBWindowSurface::updateIsOpaque(), QWidget::visibleRegion(), QBBGLWindowSurface::~QBBGLWindowSurface(), and QBBRasterWindowSurface::~QBBRasterWindowSurface().

150 {
151  return d_ptr->window;
152 }
QWindowSurfacePrivate * d_ptr

Properties

◆ d_ptr

QWindowSurfacePrivate* QWindowSurface::d_ptr
private

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