8fc757a7137f78a00a427d30307ac23d54180617
[profile/ivi/qtdeclarative.git] / src / quick / scenegraph / util / qsgpainternode_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QSGPAINTERNODE_P_H
43 #define QSGPAINTERNODE_P_H
44
45 #include <QtQuick/qsgnode.h>
46 #include "qsgtexturematerial.h"
47 #include "qsgtexture_p.h"
48
49 #include <QtQuick/qquickpainteditem.h>
50
51 #include <QtGui/qcolor.h>
52
53 QT_BEGIN_HEADER
54
55 QT_BEGIN_NAMESPACE
56
57 class QOpenGLFramebufferObject;
58 class QOpenGLPaintDevice;
59
60 class Q_QUICK_EXPORT QSGPainterTexture : public QSGPlainTexture
61 {
62 public:
63     QSGPainterTexture();
64
65     void setDirtyRect(const QRect &rect) { m_dirty_rect = rect; }
66
67     void bind();
68
69 private:
70     QRect m_dirty_rect;
71 };
72
73 class Q_QUICK_EXPORT QSGPainterNode : public QSGGeometryNode
74 {
75 public:
76     QSGPainterNode(QQuickPaintedItem *item);
77     virtual ~QSGPainterNode();
78
79     void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target);
80
81     void setSize(const QSize &size);
82     QSize size() const { return m_size; }
83
84     void setDirty(const QRect &dirtyRect = QRect());
85
86     void setOpaquePainting(bool opaque);
87     bool opaquePainting() const { return m_opaquePainting; }
88
89     void setLinearFiltering(bool linearFiltering);
90     bool linearFiltering() const { return m_linear_filtering; }
91
92     void setMipmapping(bool mipmapping);
93     bool mipmapping() const { return m_mipmapping; }
94
95     void setSmoothPainting(bool s);
96     bool smoothPainting() const { return m_smoothPainting; }
97
98     void setFillColor(const QColor &c);
99     QColor fillColor() const { return m_fillColor; }
100
101     void setContentsScale(qreal s);
102     qreal contentsScale() const { return m_contentsScale; }
103
104     void setFastFBOResizing(bool dynamic);
105     bool fastFBOResizing() const { return m_fastFBOResizing; }
106
107     QImage toImage() const;
108     void update();
109
110     void paint();
111
112 private:
113     void updateTexture();
114     void updateGeometry();
115     void updateRenderTarget();
116     void updateFBOSize();
117
118     QSGContext *m_context;
119
120     QQuickPaintedItem::RenderTarget m_preferredRenderTarget;
121     QQuickPaintedItem::RenderTarget m_actualRenderTarget;
122
123     QQuickPaintedItem *m_item;
124
125     QOpenGLFramebufferObject *m_fbo;
126     QOpenGLFramebufferObject *m_multisampledFbo;
127     QImage m_image;
128
129     QSGOpaqueTextureMaterial m_material;
130     QSGTextureMaterial m_materialO;
131     QSGGeometry m_geometry;
132     QSGPainterTexture *m_texture;
133     QOpenGLPaintDevice *m_gl_device;
134
135     QSize m_size;
136     QSize m_fboSize;
137     bool m_dirtyContents;
138     QRect m_dirtyRect;
139     bool m_opaquePainting;
140     bool m_linear_filtering;
141     bool m_mipmapping;
142     bool m_smoothPainting;
143     bool m_extensionsChecked;
144     bool m_multisamplingSupported;
145     bool m_fastFBOResizing;
146     QColor m_fillColor;
147     qreal m_contentsScale;
148
149     bool m_dirtyGeometry;
150     bool m_dirtyRenderTarget;
151     bool m_dirtyTexture;
152 };
153
154 QT_END_HEADER
155
156 QT_END_NAMESPACE
157
158 #endif // QSGPAINTERNODE_P_H