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 QtQml 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 QSGPAINTERNODE_P_H
43 #define QSGPAINTERNODE_P_H
45 #include <QtQuick/qsgnode.h>
46 #include "qsgtexturematerial.h"
47 #include "qsgtexture_p.h"
49 #include <QtQuick/qquickpainteditem.h>
51 #include <QtGui/qcolor.h>
57 class QOpenGLFramebufferObject;
58 class QOpenGLPaintDevice;
60 class Q_QUICK_PRIVATE_EXPORT QSGPainterTexture : public QSGPlainTexture
65 void setDirtyRect(const QRect &rect) { m_dirty_rect = rect; }
73 class Q_QUICK_PRIVATE_EXPORT QSGPainterNode : public QSGGeometryNode
76 QSGPainterNode(QQuickPaintedItem *item);
77 virtual ~QSGPainterNode();
79 void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target);
81 void setSize(const QSize &size);
82 QSize size() const { return m_size; }
84 void setDirty(const QRect &dirtyRect = QRect());
86 void setOpaquePainting(bool opaque);
87 bool opaquePainting() const { return m_opaquePainting; }
89 void setLinearFiltering(bool linearFiltering);
90 bool linearFiltering() const { return m_linear_filtering; }
92 void setMipmapping(bool mipmapping);
93 bool mipmapping() const { return m_mipmapping; }
95 void setSmoothPainting(bool s);
96 bool smoothPainting() const { return m_smoothPainting; }
98 void setFillColor(const QColor &c);
99 QColor fillColor() const { return m_fillColor; }
101 void setContentsScale(qreal s);
102 qreal contentsScale() const { return m_contentsScale; }
104 void setFastFBOResizing(bool dynamic);
105 bool fastFBOResizing() const { return m_fastFBOResizing; }
107 QImage toImage() const;
113 void updateTexture();
114 void updateGeometry();
115 void updateRenderTarget();
116 void updateFBOSize();
118 QSGContext *m_context;
120 QQuickPaintedItem::RenderTarget m_preferredRenderTarget;
121 QQuickPaintedItem::RenderTarget m_actualRenderTarget;
123 QQuickPaintedItem *m_item;
125 QOpenGLFramebufferObject *m_fbo;
126 QOpenGLFramebufferObject *m_multisampledFbo;
129 QSGOpaqueTextureMaterial m_material;
130 QSGTextureMaterial m_materialO;
131 QSGGeometry m_geometry;
132 QSGPainterTexture *m_texture;
133 QOpenGLPaintDevice *m_gl_device;
137 bool m_dirtyContents;
139 bool m_opaquePainting;
140 bool m_linear_filtering;
142 bool m_smoothPainting;
143 bool m_extensionsChecked;
144 bool m_multisamplingSupported;
145 bool m_fastFBOResizing;
147 qreal m_contentsScale;
149 bool m_dirtyGeometry;
150 bool m_dirtyRenderTarget;
158 #endif // QSGPAINTERNODE_P_H