Qt 4.8
shadereffectsource.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QML Shaders plugin of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef SHADEREFFECTSOURCE_H
43 #define SHADEREFFECTSOURCE_H
44 
45 #include <QDeclarativeItem>
46 #include <QtOpenGL>
47 
49 
51 
52 class ShaderEffectBuffer;
53 
55 {
56  Q_OBJECT
60  bool live;
61  bool hideSource;
65 
66 public:
67  enum WrapMode {
72  };
73 
74  enum Format {
78  };
79 
81  virtual ~ShaderEffectSource();
82 
84  void setSourceItem(QDeclarativeItem *item);
85 
86  QRectF sourceRect() const { return m_sourceRect; };
87  void setSourceRect(const QRectF &rect);
88 
89  QSize textureSize() const { return m_textureSize; }
90  void setTextureSize(const QSize &size);
91 
92  bool isLive() const { return m_live; }
93  void setLive(bool s);
94 
95  bool hideSource() const { return m_hideSource; }
96  void setHideSource(bool hide);
97 
98  WrapMode wrapMode() const { return m_wrapMode; };
99  void setWrapMode(WrapMode mode);
100 
101  bool isActive() const { return m_refs; }
102  void bind();
103  void refFromEffectItem();
104  void derefFromEffectItem();
105  void updateBackbuffer();
106 
107  ShaderEffectBuffer* fbo() { return m_fbo; }
108  bool isDirtyTexture() { return m_dirtyTexture; }
109  bool isMirrored() { return m_mirrored; }
110 
111  Q_INVOKABLE void grab();
112 
113 Q_SIGNALS:
114  void sourceItemChanged();
115  void sourceRectChanged();
116  void textureSizeChanged();
117  void formatChanged();
118  void liveChanged();
119  void hideSourceChanged();
120  void activeChanged();
121  void repaintRequired();
122  void wrapModeChanged();
123 
124 public Q_SLOTS:
125  void markSceneGraphDirty();
126  void markSourceSizeDirty();
127  void markSourceItemDirty();
128 
129 private:
130  void updateSizeAndTexture();
131  void attachSourceItem();
132  void detachSourceItem();
133 
134 private:
141 
144  int m_refs;
145  bool m_dirtyTexture : 1;
149  bool m_live : 1;
150  bool m_hideSource : 1;
151  bool m_mirrored : 1;
152 };
153 
155 
157 
158 
159 #endif // SHADEREFFECTSOURCE_H
bool live
This property holds the optimization flag to define whether the source item content is changing or st...
#define GL_RGB
bool hideSource
This property holds the flag to define whether the original source item is hidden when the effect ite...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
WrapMode wrapMode() const
WrapMode wrapMode
This property defines the wrap parameter for the source after it has been mapped as a texture...
#define Q_INVOKABLE
Definition: qobjectdefs.h:90
void setTextureSize(const QSize &size)
QPointer< QDeclarativeItem > m_sourceItem
#define Q_SLOTS
Definition: qobjectdefs.h:71
QSize textureSize() const
#define Q_SIGNALS
Definition: qobjectdefs.h:72
ShaderEffectBuffer * m_multisampledFbo
void setSourceItem(QDeclarativeItem *item)
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
QDeclarativeItem * sourceItem
This property holds the Item which is used as the source for the shader effect.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QDeclarativeItem class provides the most basic of all visual items in QML.
#define GL_ALPHA
QRectF sourceRect
This property can be used to specify margins for the source content.
QRectF sourceRect() const
QSize textureSize
This property holds the size for the texture containing the source content.
#define Q_OBJECT
Definition: qobjectdefs.h:157
The ShaderEffectSource object encapsulates the source content for the ShaderEffectItem.
void setHideSource(bool hide)
ShaderEffectSource(QDeclarativeItem *parent=0)
QDeclarativeItem * sourceItem() const
ShaderEffectBuffer * fbo()
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void hide()
Hides the item.
Q_INVOKABLE void grab()
Repaints the source item content into the texture.
T * data() const
Definition: qpointer.h:79
#define GL_RGBA
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setSourceRect(const QRectF &rect)
ShaderEffectBuffer * m_fbo
#define QT_END_HEADER
Definition: qglobal.h:137
void setWrapMode(WrapMode mode)