1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtOpenVG module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
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.
|
---|
23 | **
|
---|
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.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QVGIMAGEPOOL_P_H
|
---|
43 | #define QVGIMAGEPOOL_P_H
|
---|
44 |
|
---|
45 | //
|
---|
46 | // W A R N I N G
|
---|
47 | // -------------
|
---|
48 | //
|
---|
49 | // This file is not part of the Qt API. It exists for the convenience
|
---|
50 | // of other Qt classes. This header file may change from version to
|
---|
51 | // version without notice, or even be removed.
|
---|
52 | //
|
---|
53 | // We mean it.
|
---|
54 | //
|
---|
55 |
|
---|
56 | #include "qvg.h"
|
---|
57 | #include <QtCore/qscopedpointer.h>
|
---|
58 |
|
---|
59 | QT_BEGIN_NAMESPACE
|
---|
60 |
|
---|
61 | class QVGPixmapData;
|
---|
62 | class QVGImagePoolPrivate;
|
---|
63 |
|
---|
64 | class Q_OPENVG_EXPORT QVGImagePool
|
---|
65 | {
|
---|
66 | public:
|
---|
67 | QVGImagePool();
|
---|
68 | virtual ~QVGImagePool();
|
---|
69 |
|
---|
70 | static QVGImagePool *instance();
|
---|
71 |
|
---|
72 | // This function can be used from system-specific graphics system
|
---|
73 | // plugins to alter the image allocation strategy.
|
---|
74 | static void setImagePool(QVGImagePool *pool);
|
---|
75 |
|
---|
76 | // Create a new VGImage from the pool with the specified parameters
|
---|
77 | // that is not associated with a pixmap. The VGImage is returned to
|
---|
78 | // the pool when releaseImage() is called.
|
---|
79 | //
|
---|
80 | // This function will call reclaimSpace() when vgCreateImage() fails.
|
---|
81 | //
|
---|
82 | // This function is typically called when allocating temporary
|
---|
83 | // VGImage's for pixmap filters. The "keepData" object will not
|
---|
84 | // be reclaimed if reclaimSpace() needs to be called.
|
---|
85 | virtual VGImage createTemporaryImage(VGImageFormat format,
|
---|
86 | VGint width, VGint height,
|
---|
87 | VGbitfield allowedQuality,
|
---|
88 | QVGPixmapData *keepData = 0);
|
---|
89 |
|
---|
90 | // Create a new VGImage with the specified parameters and associate
|
---|
91 | // it with "data". The QVGPixmapData will be notified when the
|
---|
92 | // VGImage needs to be reclaimed by the pool.
|
---|
93 | //
|
---|
94 | // This function will call reclaimSpace() when vgCreateImage() fails.
|
---|
95 | virtual VGImage createImageForPixmap(VGImageFormat format,
|
---|
96 | VGint width, VGint height,
|
---|
97 | VGbitfield allowedQuality,
|
---|
98 | QVGPixmapData *data);
|
---|
99 |
|
---|
100 | // Create a permanent VGImage with the specified parameters.
|
---|
101 | // If there is insufficient space for the vgCreateImage call,
|
---|
102 | // then this function will call reclaimSpace() and try again.
|
---|
103 | //
|
---|
104 | // The caller is responsible for calling vgDestroyImage()
|
---|
105 | // when it no longer needs the VGImage, as the image is not
|
---|
106 | // recorded in the image pool.
|
---|
107 | //
|
---|
108 | // This function is typically used for pattern brushes where
|
---|
109 | // the OpenVG engine is responsible for managing the lifetime
|
---|
110 | // of the VGImage, destroying it automatically when the brush
|
---|
111 | // is no longer in use.
|
---|
112 | virtual VGImage createPermanentImage(VGImageFormat format,
|
---|
113 | VGint width, VGint height,
|
---|
114 | VGbitfield allowedQuality);
|
---|
115 |
|
---|
116 | // Release a VGImage that is no longer required.
|
---|
117 | virtual void releaseImage(QVGPixmapData *data, VGImage image);
|
---|
118 |
|
---|
119 | // Notify the pool that a QVGPixmapData object is using
|
---|
120 | // an image again. This allows the pool to move the image
|
---|
121 | // within a least-recently-used list of QVGPixmapData objects.
|
---|
122 | virtual void useImage(QVGPixmapData *data);
|
---|
123 |
|
---|
124 | // Notify the pool that the VGImage's associated with a
|
---|
125 | // QVGPixmapData are being detached from the pool. The caller
|
---|
126 | // will become responsible for calling vgDestroyImage().
|
---|
127 | virtual void detachImage(QVGPixmapData *data);
|
---|
128 |
|
---|
129 | // Reclaim space for an image allocation with the specified parameters.
|
---|
130 | // Returns true if space was reclaimed, or false if there is no
|
---|
131 | // further space that can be reclaimed. The "data" parameter
|
---|
132 | // indicates the pixmap that is trying to obtain space which should
|
---|
133 | // not itself be reclaimed.
|
---|
134 | virtual bool reclaimSpace(VGImageFormat format,
|
---|
135 | VGint width, VGint height,
|
---|
136 | QVGPixmapData *data);
|
---|
137 |
|
---|
138 | // Hibernate the image pool because the context is about to be
|
---|
139 | // destroyed. All VGImage's left in the pool should be released.
|
---|
140 | virtual void hibernate();
|
---|
141 |
|
---|
|
---|