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

#include <qxcbwindowsurface.h>

Inheritance diagram for QXcbWindowSurface:
QXcbObject QWindowSurface

Public Functions

void beginPaint (const QRegion &)
 This function is called before painting onto the surface begins, with the region in which the painting will occur. More...
 
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...
 
void flush (QWidget *widget, const QRegion &region, const QPoint &offset)
 Flushes the given region from the specified widget onto the screen. More...
 
QPaintDevicepaintDevice ()
 Implement this function to return the appropriate paint device. More...
 
 QXcbWindowSurface (QWidget *widget, bool setDefaultSurface=true)
 
void resize (const QSize &size)
 
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...
 
 ~QXcbWindowSurface ()
 
- Public Functions inherited from QXcbObject
xcb_atom_t atom (QXcbAtom::Atom atom) const
 
QXcbConnectionconnection () const
 
 QXcbObject (QXcbConnection *connection=0)
 
void setConnection (QXcbConnection *connection)
 
xcb_connection_t * xcb_connection () const
 
- 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 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...
 

Properties

QXcbShmImagem_image
 
bool m_syncingResize
 

Additional Inherited Members

- Public Types inherited from QWindowSurface
enum  WindowSurfaceFeature { PartialUpdates = 0x00000001, PreservedContents = 0x00000002, StaticContents = 0x00000004, AllFeatures = 0xffffffff }
 
- Protected Functions inherited from QWindowSurface
bool hasStaticContents () const
 

Detailed Description

Definition at line 53 of file qxcbwindowsurface.h.

Constructors and Destructors

◆ QXcbWindowSurface()

QXcbWindowSurface::QXcbWindowSurface ( QWidget widget,
bool  setDefaultSurface = true 
)

Definition at line 171 of file qxcbwindowsurface.cpp.

172  : QWindowSurface(widget, setDefaultSurface)
173  , m_image(0)
174  , m_syncingResize(false)
175 {
176  QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
177  setConnection(screen->connection());
178 }
QXcbShmImage * m_image
void setConnection(QXcbConnection *connection)
Definition: qxcbobject.h:52
QXcbConnection * connection() const
Definition: qxcbobject.h:53
static QPlatformScreen * platformScreenForWidget(const QWidget *widget)
QWindowSurface(QWidget *window, bool setDefaultSurface=true)
Constructs an empty surface for the given top-level window.

◆ ~QXcbWindowSurface()

QXcbWindowSurface::~QXcbWindowSurface ( )

Definition at line 180 of file qxcbwindowsurface.cpp.

181 {
182  delete m_image;
183 }
QXcbShmImage * m_image

Functions

◆ beginPaint()

void QXcbWindowSurface::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 QWindowSurface.

Definition at line 190 of file qxcbwindowsurface.cpp.

191 {
192  m_image->preparePaint(region);
193 
194  if (m_image->image()->hasAlphaChannel()) {
195  QPainter p(m_image->image());
197  const QVector<QRect> rects = region.rects();
198  const QColor blank = Qt::transparent;
199  for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
200  p.fillRect(*it, blank);
201  }
202  }
203 }
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
#define it(className, varName)
QXcbShmImage * m_image
void preparePaint(const QRegion &region)
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false...
Definition: qimage.cpp:6495
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:250
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
Definition: qpainter.cpp:2422
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
Definition: qvector.h:247
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412

◆ endPaint()

void QXcbWindowSurface::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 from QWindowSurface.

Definition at line 205 of file qxcbwindowsurface.cpp.

206 {
207 }

◆ flush()

void QXcbWindowSurface::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.

Implements QWindowSurface.

Definition at line 209 of file qxcbwindowsurface.cpp.

210 {
211  QRect bounds = region.boundingRect();
212 
213  if (size().isEmpty() || !geometry().contains(bounds))
214  return;
215 
217 
218  QXcbWindow *window = static_cast<QXcbWindow *>(widget->window()->platformWindow());
219 
220  extern QWidgetData* qt_widget_data(QWidget *);
221  QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft();
222 
223  QVector<QRect> rects = region.rects();
224  for (int i = 0; i < rects.size(); ++i)
225  m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset));
226 
228 
229  if (m_syncingResize) {
230  xcb_flush(xcb_connection());
231  connection()->sync();
232  m_syncingResize = false;
233  window->updateSyncRequestCounter();
234  }
235 }
QRect geometry() const
Returns the currently allocated area on the screen.
xcb_connection_t * xcb_connection() const
Definition: qxcbobject.h:56
QXcbShmImage * m_image
void put(xcb_window_t window, const QPoint &dst, const QRect &source)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
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
QXcbConnection * connection() const
Definition: qxcbobject.h:53
static bool isEmpty(const char *str)
QRect wrect
Definition: qwidget.h:145
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
xcb_window_t window() const
Definition: qxcbwindow.h:77
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
#define Q_XCB_NOOP(c)
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
Q_GUI_EXPORT QWidgetData * qt_qwidget_data(QWidget *widget)
Definition: qwidget.cpp:12915
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
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
void updateSyncRequestCounter()
Definition: qxcbwindow.cpp:705

◆ paintDevice()

QPaintDevice * QXcbWindowSurface::paintDevice ( )
virtual

Implement this function to return the appropriate paint device.

Implements QWindowSurface.

Definition at line 185 of file qxcbwindowsurface.cpp.

186 {
187  return m_image->image();
188 }
QXcbShmImage * m_image

◆ resize()

void QXcbWindowSurface::resize ( const QSize size)

Definition at line 237 of file qxcbwindowsurface.cpp.

238 {
239  if (size == QWindowSurface::size())
240  return;
241 
243  QWindowSurface::resize(size);
244 
246  QXcbWindow* win = static_cast<QXcbWindow *>(window()->platformWindow());
247 
248  delete m_image;
249  m_image = new QXcbShmImage(screen, size, win->depth(), win->format());
251 
252  m_syncingResize = true;
253 }
QXcbShmImage * m_image
QXcbConnection * connection() const
Definition: qxcbobject.h:53
static QPlatformScreen * platformScreenForWidget(const QWidget *widget)
QImage::Format format() const
Definition: qxcbwindow.h:79
#define Q_XCB_NOOP(c)
uint depth() const
Definition: qxcbwindow.h:78
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.

◆ scroll()

bool QXcbWindowSurface::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 257 of file qxcbwindowsurface.cpp.

258 {
259  if (m_image->image()->isNull())
260  return false;
261 
262  m_image->preparePaint(area);
263 
264  const QVector<QRect> rects = area.rects();
265  for (int i = 0; i < rects.size(); ++i)
266  qt_scrollRectInImage(*m_image->image(), rects.at(i), QPoint(dx, dy));
267 
268  return true;
269 }
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
QXcbShmImage * m_image
void preparePaint(const QRegion &region)
void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
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
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

Properties

◆ m_image

QXcbShmImage* QXcbWindowSurface::m_image
private

Definition at line 68 of file qxcbwindowsurface.h.

Referenced by beginPaint(), flush(), paintDevice(), resize(), scroll(), and ~QXcbWindowSurface().

◆ m_syncingResize

bool QXcbWindowSurface::m_syncingResize
private

Definition at line 69 of file qxcbwindowsurface.h.

Referenced by flush(), and resize().


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