ef1f3f1ddea9685e950cd7928a0321fc29692dc5
[profile/ivi/qtdeclarative.git] / src / declarative / scenegraph / util / qsgpainternode_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file.  Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 **
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **
32 **
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 "qsgnode.h"
46 #include "qsgtexturematerial.h"
47 #include "qsgtexture_p.h"
48 #include "qsgpainteditem.h"
49
50 QT_BEGIN_HEADER
51
52 QT_BEGIN_NAMESPACE
53
54 QT_MODULE(Declarative)
55
56 class QGLFramebufferObject;
57
58 class Q_DECLARATIVE_EXPORT QSGPainterTexture : public QSGPlainTexture
59 {
60 public:
61     QSGPainterTexture();
62
63     void setDirtyRect(const QRect &rect) { m_dirty_rect = rect; }
64
65     void bind();
66
67 private:
68     QRect m_dirty_rect;
69 };
70
71 class Q_DECLARATIVE_EXPORT QSGPainterNode : public QSGGeometryNode
72 {
73 public:
74     QSGPainterNode(QSGPaintedItem *item);
75     virtual ~QSGPainterNode();
76
77     void setPreferredRenderTarget(QSGPaintedItem::RenderTarget target);
78
79     void setSize(const QSize &size);
80     QSize size() const { return m_size; }
81
82     void setDirty(bool d, const QRect &dirtyRect = QRect());
83
84     void setOpaquePainting(bool opaque);
85     bool opaquePainting() const { return m_opaquePainting; }
86
87     void setLinearFiltering(bool linearFiltering);
88     bool linearFiltering() const { return m_linear_filtering; }
89
90     void setSmoothPainting(bool s);
91     bool smoothPainting() const { return m_smoothPainting; }
92
93     void setFillColor(const QColor &c);
94     QColor fillColor() const { return m_fillColor; }
95
96     void update();
97
98     void preprocess();
99
100 private:
101     void updateTexture();
102     void updateGeometry();
103     void updateRenderTarget();
104     void updateFBOSize();
105
106     QSGPaintedItem::RenderTarget m_preferredRenderTarget;
107     QSGPaintedItem::RenderTarget m_actualRenderTarget;
108
109     QSGPaintedItem *m_item;
110
111     QGLFramebufferObject *m_fbo;
112     QGLFramebufferObject *m_multisampledFbo;
113     QImage m_image;
114
115     QSGTextureMaterial m_material;
116     QSGTextureMaterialWithOpacity m_materialO;
117     QSGGeometry m_geometry;
118     QSGPainterTexture *m_texture;
119
120     QSize m_size;
121     QSize m_fboSize;
122     bool m_dirtyContents;
123     QRect m_dirtyRect;
124     bool m_opaquePainting;
125     bool m_linear_filtering;
126     bool m_smoothPainting;
127     bool m_extensionsChecked;
128     bool m_multisamplingSupported;
129     QColor m_fillColor;
130
131     bool m_dirtyGeometry;
132     bool m_dirtyRenderTarget;
133     bool m_dirtyTexture;
134 };
135
136 QT_END_HEADER
137
138 QT_END_NAMESPACE
139
140 #endif // QSGPAINTERNODE_P_H