~loic.molinari/+junk/qtdeclarative-shadereffectsource-changes

« back to all changes in this revision

Viewing changes to src/quick/scenegraph/util/qsgpainternode_p.h

  • Committer: Loïc Molinari
  • Date: 2012-04-21 17:59:51 UTC
  • Revision ID: loic.molinari@canonical.com-20120421175951-bqx68caaf5zrp76l
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/
 
5
**
 
6
** This file is part of the QtQml module of the Qt Toolkit.
 
7
**
 
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.
 
16
**
 
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.
 
20
**
 
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.
 
28
**
 
29
** Other Usage
 
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.
 
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 <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