Qt 4.8
qdirectfbwindowsurface.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qdirectfbwindowsurface.h"
43 #include "qdirectfbintegration.h"
44 #include "qdirectfbblitter.h"
45 #include "qdirectfbconvenience.h"
46 #include "qdirectfbwindow.h"
47 #include <private/qpixmap_blitter_p.h>
48 
49 #include <QtCore/qdebug.h>
50 
52 
54  : QWindowSurface(window), m_pixmap(0), m_pmdata(0)
55 {
56  IDirectFBWindow *dfbWindow = static_cast<QDirectFbWindow *>(window->platformWindow())->dfbWindow();
57  dfbWindow->GetSurface(dfbWindow, m_dfbSurface.outPtr());
58 
59 //WRONGSIZE
60  QDirectFbBlitter *blitter = new QDirectFbBlitter(window->size(), m_dfbSurface.data());
62  m_pmdata->setBlittable(blitter);
63  m_pixmap.reset(new QPixmap(m_pmdata));
64 }
65 
67 {
68  return m_pixmap.data();
69 }
70 
72 {
73  Q_UNUSED(widget);
75 
76  QVector<QRect> rects = region.rects();
77  for (int i = 0 ; i < rects.size(); i++) {
78  const QRect rect = rects.at(i);
79  DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()};
80  m_dfbSurface->Flip(m_dfbSurface.data(), &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC));
81  }
82 }
83 
85 {
86  if (size == QWindowSurface::size())
87  return;
88 
89  QWindowSurface::resize(size);
90  QDirectFbBlitter *blitter = new QDirectFbBlitter(size, m_dfbSurface.data());
91  m_pmdata->setBlittable(blitter);
92 }
93 
94 static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy)
95 {
96  const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() };
97  surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy);
98  const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy };
99  surface->Flip(surface, &region, DFBSurfaceFlipFlags(DSFLIP_BLIT));
100 }
101 
102 bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy)
103 {
104  m_pmdata->blittable()->unlock();
105 
106  if (!m_dfbSurface || area.isEmpty())
107  return false;
108  m_dfbSurface->SetBlittingFlags(m_dfbSurface.data(), DSBLIT_NOFX);
109  if (area.rectCount() == 1) {
110  scrollSurface(m_dfbSurface.data(), area.boundingRect(), dx, dy);
111  } else {
112  const QVector<QRect> rects = area.rects();
113  const int n = rects.size();
114  for (int i=0; i<n; ++i) {
115  scrollSurface(m_dfbSurface.data(), rects.at(i), dx, dy);
116  }
117  }
118  return true;
119 }
120 
122 {
123  Q_UNUSED(region);
124 }
125 
127 {
128  Q_UNUSED(region);
129 }
130 
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
T * data() const
Returns the value of the pointer referenced by this object.
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
void endPaint(const QRegion &region)
This function is called after painting onto the surface has ended, with the region in which the paint...
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.
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
void setBlittable(QBlittable *blittable)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
void resize(const QSize &size)
void beginPaint(const QRegion &region)
This function is called before painting onto the surface begins, with the region in which the paintin...
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Definition: qregion.cpp:4461
QScopedPointer< QPixmap > m_pixmap
NSWindow * window
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QBlittablePixmapData * m_pmdata
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
void flush(QWidget *widget, const QRegion &region, const QPoint &offset)
Flushes the given region from the specified widget onto the screen.
The QWindowSurface class provides the drawing area for top-level windows.
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QPaintDevice * paintDevice()
Implement this function to return the appropriate paint device.
QDirectFbWindowSurface(QWidget *window)
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
void unlock()
Definition: qblittable.cpp:100
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
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
static void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy)
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
QBlittable * blittable() const
QDirectFBPointer< IDirectFBSurface > m_dfbSurface
#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
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
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...
static int area(const QSize &s)
Definition: qicon.cpp:155