Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / quick / items / context2d / qquickcanvasitem_p.h
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 QtDeclarative 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 QQUICKCANVASITEM_P_H
43 #define QQUICKCANVASITEM_P_H
44
45 #include <QtQuick/qquickitem.h>
46 #include <private/qv8engine_p.h>
47
48 QT_BEGIN_HEADER
49
50 QT_BEGIN_NAMESPACE
51
52 class QQuickContext2D;
53 class QQuickCanvasItemPrivate;
54 class Q_QUICK_EXPORT QQuickCanvasItem : public QQuickItem
55 {
56     Q_OBJECT
57     Q_ENUMS(RenderTarget)
58     Q_ENUMS(ImageFilterMode)
59
60     Q_PROPERTY(QSizeF canvasSize READ canvasSize WRITE setCanvasSize NOTIFY canvasSizeChanged)
61     Q_PROPERTY(QSize tileSize READ tileSize WRITE setTileSize NOTIFY tileSizeChanged)
62     Q_PROPERTY(QRectF canvasWindow READ canvasWindow WRITE setCanvasWindow NOTIFY canvasWindowChanged)
63     Q_PROPERTY(bool renderInThread READ renderInThread WRITE setRenderInThread NOTIFY renderInThreadChanged)
64     Q_PROPERTY(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged)
65 public:
66     enum RenderTarget {
67         Image,
68         FramebufferObject
69     };
70
71     enum ImageFilterMode {
72         Threshold,
73         Mono,
74         GrayScale,
75         Brightness,
76         Invert,
77         Blur,
78         Opaque,
79         Convolute
80     };
81
82     QQuickCanvasItem(QQuickItem *parent = 0);
83     ~QQuickCanvasItem();
84
85     QSizeF canvasSize() const;
86     void setCanvasSize(const QSizeF &);
87
88     QSize tileSize() const;
89     void setTileSize(const QSize &);
90
91     QRectF canvasWindow() const;
92     void setCanvasWindow(const QRectF& rect);
93
94     bool renderInThread() const;
95     void setRenderInThread(bool renderInThread);
96
97     RenderTarget renderTarget() const;
98     void setRenderTarget(RenderTarget target);
99
100     QQuickContext2D* context() const;
101     QImage toImage(const QRectF& region = QRectF()) const;
102
103     QImage loadedImage(const QUrl& url);
104
105 Q_SIGNALS:
106     void paint(QDeclarativeV8Handle context, const QRect &region);
107     void painted();
108     void canvasSizeChanged();
109     void tileSizeChanged();
110     void renderInThreadChanged();
111     void textureChanged();
112     void canvasWindowChanged();
113     void renderTargetChanged();
114     void imageLoaded();
115 public Q_SLOTS:
116     QString toDataURL(const QString& type = QLatin1String("image/png")) const;
117     QDeclarativeV8Handle getContext(const QString & = QLatin1String("2d"));
118     void markDirty(const QRectF& region);
119     void requestPaint() {markDirty(canvasWindow());}
120     // Save current canvas to disk
121     bool save(const QString& filename) const;
122     void loadImage(const QUrl& url);
123     void unloadImage(const QUrl& url);
124     bool isImageLoaded(const QUrl& url) const;
125     bool isImageLoading(const QUrl& url) const;
126     bool isImageError(const QUrl& url) const;
127 private Q_SLOTS:
128     void _doPainting(const QRectF& region);
129 protected:
130     virtual void componentComplete();
131     virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
132     virtual void geometryChanged(const QRectF &newGeometry,
133                                  const QRectF &oldGeometry);
134     virtual void updatePolish();
135 private:
136     void createContext();
137     void createTexture();
138     Q_DECLARE_PRIVATE(QQuickCanvasItem)
139     friend class QQuickContext2D;
140     friend class QQuickContext2DTexture;
141 };
142 QT_END_NAMESPACE
143
144 QML_DECLARE_TYPE(QQuickCanvasItem)
145
146 QT_END_HEADER
147
148 #endif //QQUICKCANVASITEM_P_H