Qt 4.8
qwindowsurface_vg.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 QtOpenVG module 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 "qwindowsurface_vg_p.h"
43 #include "qwindowsurface_vgegl_p.h"
44 #include "qpaintengine_vg_p.h"
45 #include "qpixmapdata_vg_p.h"
46 #include "qvg_p.h"
47 
48 #if !defined(QT_NO_EGL)
49 
50 #include <QtGui/private/qeglcontext_p.h>
51 #include <QtGui/private/qwidget_p.h>
52 
54 
56  : QWindowSurface(window)
57 {
58  // Create the default type of EGL window surface for windows.
59  d_ptr = new QVGEGLWindowSurfaceDirect(this);
60 }
61 
64  : QWindowSurface(window), d_ptr(d)
65 {
66 }
67 
69 {
70  delete d_ptr;
71 }
72 
74 {
75  return this;
76 }
77 
79 {
80  Q_UNUSED(offset);
81 
82 #ifdef Q_OS_SYMBIAN
83  if (window() != widget) {
84  // For performance reasons we don't support
85  // flushing native child widgets on Symbian.
86  // It breaks overlapping native child widget
87  // rendering in some cases but we prefer performance.
88  return;
89  }
90 #endif
91 
92  QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
93  d_ptr->endPaint(parent, region);
94 }
95 
96 #if !defined(Q_WS_QPA)
98 {
100 }
101 #else
102 void QVGWindowSurface::resize(const QSize &size)
103 {
104  QWindowSurface::resize(size);
105 }
106 #endif
107 
108 bool QVGWindowSurface::scroll(const QRegion &area, int dx, int dy)
109 {
110  if (!d_ptr->scroll(window(), area, dx, dy))
111  return QWindowSurface::scroll(area, dx, dy);
112  return true;
113 }
114 
116 {
117  d_ptr->beginPaint(window());
118 
119  // If the window is not opaque, then fill the region we are about
120  // to paint with the transparent color.
121  if (!qt_widget_private(window())->isOpaque &&
122  window()->testAttribute(Qt::WA_TranslucentBackground)) {
123  QVGPaintEngine *engine = static_cast<QVGPaintEngine *>
124  (d_ptr->paintEngine());
125  engine->fillRegion(region, Qt::transparent, d_ptr->surfaceSize());
126  }
127 }
128 
130 {
131  // Nothing to do here.
132  Q_UNUSED(region);
133 }
134 
136 {
137  return d_ptr->paintEngine();
138 }
139 
140 QWindowSurface::WindowSurfaceFeatures QVGWindowSurface::features() const
141 {
142  WindowSurfaceFeatures features = PartialUpdates | PreservedContents;
144  features |= StaticContents;
145  return features;
146 }
147 
149 {
150  return qt_paint_device_metric(window(), met);
151 }
152 
154 
155 #endif
double d
Definition: qnumeric_p.h:62
void flush(QWidget *widget, const QRegion &region, const QPoint &offset)
Flushes the given region from the specified widget onto the screen.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
virtual bool scroll(QWidget *, const QRegion &, int, int)
virtual QSize surfaceSize() const =0
QRect rect(const QWidget *widget) const
Returns the rectangle for widget in the coordinates of this window surface.
bool scroll(const QRegion &area, int dx, int dy)
Q_WS_QPA.
int metric(PaintDeviceMetric metric) const
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
virtual QPoint offset(const QWidget *widget) const
Returns the offset of widget in the coordinates of this window surface.
virtual void endPaint(QWidget *widget, const QRegion &region, QImage *image=0)=0
void endPaint(const QRegion &region)
This function is called after painting onto the surface has ended, with the region in which the paint...
NSWindow * window
QPaintEngine * paintEngine() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
friend Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, PaintDeviceMetric metric)
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
The QWindowSurface class provides the drawing area for top-level windows.
WindowSurfaceFeatures features() const
QWindowSurface(QWidget *window, bool setDefaultSurface=true)
Constructs an empty surface for the given top-level window.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QPaintDevice * paintDevice()
Implement this function to return the appropriate paint device.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
QVGEGLWindowSurfacePrivate * d_ptr
void beginPaint(const QRegion &region)
This function is called before painting onto the surface begins, with the region in which the paintin...
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
virtual void beginPaint(QWidget *widget)=0
virtual bool supportsStaticContents() const
#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
QVGWindowSurface(QWidget *window)
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...
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.
void fillRegion(const QRegion &region, const QColor &color, const QSize &surfaceSize)
static int area(const QSize &s)
Definition: qicon.cpp:155