1 /****************************************************************************
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
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
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef SHADEREFFECTSOURCE_H
43 #define SHADEREFFECTSOURCE_H
46 #include <private/qsgtextureprovider_p.h>
47 #include <private/qsgadaptationlayer_p.h>
48 #include <private/qsgcontext_p.h>
54 #define QSG_DEBUG_FBO_OVERLAY
60 QT_MODULE(Declarative)
63 class UpdatePaintNodeData;
64 class QGLFramebufferObject;
66 class QSGShaderEffectTexture : public QSGDynamicTexture
70 QSGShaderEffectTexture(QSGItem *shaderSource);
71 ~QSGShaderEffectTexture();
73 virtual bool updateTexture();
75 // The item's "paint node", not effect node.
76 QSGNode *item() const { return m_item; }
77 void setItem(QSGNode *item);
79 QRectF rect() const { return m_rect; }
80 void setRect(const QRectF &rect);
82 QSize size() const { return m_size; }
83 void setSize(const QSize &size);
85 void setHasMipmaps(QSGTexture::Filtering filtering);
89 bool hasAlphaChannel() const;
90 bool hasMipmaps() const;
91 int textureId() const;
92 QSize textureSize() const { return m_size; }
94 GLenum format() const { return m_format; }
95 void setFormat(GLenum format);
97 bool live() const { return bool(m_live); }
98 void setLive(bool live);
103 void markDirtyTexture();
111 QSGItem *m_shaderSource;
112 QSGRenderer *m_renderer;
113 QGLFramebufferObject *m_fbo;
114 QGLFramebufferObject *m_multisampledFbo;
116 #ifdef QSG_DEBUG_FBO_OVERLAY
117 QSGRectangleNode *m_debugOverlay;
120 uint m_hWrapMode : 1;
121 uint m_vWrapMode : 1;
122 uint m_filtering : 2;
123 uint m_mipmapFiltering : 2;
126 uint m_dirtyTexture : 1;
127 uint m_multisamplingSupportChecked : 1;
128 uint m_multisampling : 1;
131 class QSGShaderEffectSource : public QSGItem, public QSGTextureProvider
134 Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
135 Q_PROPERTY(QSGItem *sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged)
136 Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged)
137 Q_PROPERTY(QSize textureSize READ textureSize WRITE setTextureSize NOTIFY textureSizeChanged)
138 Q_PROPERTY(Format format READ format WRITE setFormat NOTIFY formatChanged)
139 Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged)
140 Q_PROPERTY(bool hideSource READ hideSource WRITE setHideSource NOTIFY hideSourceChanged)
141 Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged)
142 Q_INTERFACES(QSGTextureProvider)
143 Q_ENUMS(Format WrapMode)
158 QSGShaderEffectSource(QSGItem *parent = 0);
159 ~QSGShaderEffectSource();
161 WrapMode wrapMode() const;
162 void setWrapMode(WrapMode mode);
164 QSGItem *sourceItem() const;
165 void setSourceItem(QSGItem *item);
167 QRectF sourceRect() const;
168 void setSourceRect(const QRectF &rect);
170 QSize textureSize() const;
171 void setTextureSize(const QSize &size);
173 Format format() const;
174 void setFormat(Format format);
177 void setLive(bool live);
179 bool hideSource() const;
180 void setHideSource(bool hide);
183 void setMipmap(bool enabled);
185 QSGTexture *texture() const;
186 const char *textureChangedSignal() const { return SIGNAL(textureChanged); }
188 Q_INVOKABLE void grab();
191 void wrapModeChanged();
192 void sourceItemChanged();
193 void sourceRectChanged();
194 void textureSizeChanged();
195 void formatChanged();
197 void hideSourceChanged();
198 void mipmapChanged();
201 virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
204 QSGTexture *m_texture;
206 QPointer<QSGItem> m_sourceItem;
211 uint m_hideSource : 1;
219 #endif // SHADEREFFECTSOURCE_H