1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QQUICKCANVAS_P_H
43 #define QQUICKCANVAS_P_H
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
56 #include "qquickitem.h"
57 #include "qquickcanvas.h"
58 #include <private/qdeclarativeguard_p.h>
60 #include <QtQuick/private/qsgcontext_p.h>
61 #include <private/qquickdrag_p.h>
63 #include <QtCore/qthread.h>
64 #include <QtCore/qmutex.h>
65 #include <QtCore/qwaitcondition.h>
66 #include <private/qwindow_p.h>
67 #include <private/qopengl_p.h>
68 #include <qopenglcontext.h>
69 #include <QtGui/qopenglframebufferobject.h>
70 #include <QtGui/qevent.h>
71 #include <QtGui/qinputpanel.h>
75 //Make it easy to identify and customize the root item if needed
77 class QQuickWindowManager;
79 class QQuickRootItem : public QQuickItem
85 void setWidth(int w) {QQuickItem::setWidth(qreal(w));}
86 void setHeight(int h) {QQuickItem::setHeight(qreal(h));}
89 class QQuickItemPrivate;
90 class QQuickCanvasPrivate;
93 class QQuickCanvasRenderLoop;
94 class QQuickCanvasIncubationController;
96 class Q_QUICK_EXPORT QQuickCanvasPrivate : public QWindowPrivate
99 Q_DECLARE_PUBLIC(QQuickCanvas)
101 static inline QQuickCanvasPrivate *get(QQuickCanvas *c) { return c->d_func(); }
103 QQuickCanvasPrivate();
104 virtual ~QQuickCanvasPrivate();
106 void init(QQuickCanvas *);
107 void initRootItem();//Currently only used if items added in QML
109 QQuickRootItem *rootItem;
110 QSet<QQuickItem *> parentlessItems;
111 QDeclarativeListProperty<QObject> data();
113 QQuickItem *activeFocusItem;
114 QQuickItem *mouseGrabberItem;
115 QQuickDragGrabber dragGrabber;
117 // Mouse positions are saved in widget coordinates
118 QPointF lastMousePosition;
119 void translateTouchEvent(QTouchEvent *touchEvent);
120 static void transformTouchPoints(QList<QTouchEvent::TouchPoint> &touchPoints, const QTransform &transform);
121 bool deliverInitialMousePressEvent(QQuickItem *, QMouseEvent *);
122 bool deliverMouseEvent(QMouseEvent *);
123 bool sendFilteredMouseEvent(QQuickItem *, QQuickItem *, QEvent *);
124 bool deliverWheelEvent(QQuickItem *, QWheelEvent *);
125 bool deliverTouchPoints(QQuickItem *, QTouchEvent *, const QList<QTouchEvent::TouchPoint> &, QSet<int> *,
126 QHash<QQuickItem *, QList<QTouchEvent::TouchPoint> > *);
127 bool deliverTouchEvent(QTouchEvent *);
128 bool deliverHoverEvent(QQuickItem *, const QPointF &scenePos, const QPointF &lastScenePos, Qt::KeyboardModifiers modifiers, bool &accepted);
129 bool sendHoverEvent(QEvent::Type, QQuickItem *, const QPointF &scenePos, const QPointF &lastScenePos,
130 Qt::KeyboardModifiers modifiers, bool accepted);
132 void deliverDragEvent(QQuickDragGrabber *, QEvent *);
133 bool deliverDragEvent(QQuickDragGrabber *, QQuickItem *, QDragMoveEvent *);
135 QList<QQuickItem*> hoverItems;
137 DontChangeFocusProperty = 0x01,
138 DontChangeSubFocusItem = 0x02
140 Q_DECLARE_FLAGS(FocusOptions, FocusOption)
142 void setFocusInScope(QQuickItem *scope, QQuickItem *item, FocusOptions = 0);
143 void clearFocusInScope(QQuickItem *scope, QQuickItem *item, FocusOptions = 0);
144 void notifyFocusChangesRecur(QQuickItem **item, int remaining);
146 void updateFocusItemTransform();
148 void dirtyItem(QQuickItem *);
149 void cleanup(QSGNode *);
152 void syncSceneGraph();
153 void renderSceneGraph(const QSize &size);
155 bool renderWithoutShowing;
156 void setRenderWithoutShowing(bool enabled);
158 QQuickItem::UpdatePaintNodeData updatePaintNodeData;
160 QQuickItem *dirtyItemList;
161 QList<QSGNode *> cleanupNodeList;
163 QSet<QQuickItem *> itemsToPolish;
165 void updateDirtyNodes();
167 void cleanupNodesOnShutdown();
168 bool updateEffectiveOpacity(QQuickItem *);
169 void updateEffectiveOpacityRoot(QQuickItem *, qreal);
170 void updateDirtyNode(QQuickItem *);
172 void fireFrameSwapped() { emit q_func()->frameSwapped(); }
176 QSGRenderer *renderer;
178 QQuickWindowManager *windowManager;
182 uint clearBeforeRendering : 1;
184 QOpenGLFramebufferObject *renderTarget;
186 QSize renderTargetSize;
188 QHash<int, QQuickItem *> itemForTouchPointId;
190 mutable QQuickCanvasIncubationController *incubationController;
193 static void cleanupNodesOnShutdown(QQuickItem *);
197 Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickCanvasPrivate::FocusOptions)
201 #endif // QQUICKCANVAS_P_H