Qt 4.8
qvgimagepool_p.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 QtOpenVG module 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 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 
60 
61 class QVGPixmapData;
63 
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,
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 
142 protected:
143  // Helper functions for managing the LRU list of QVGPixmapData objects.
144  void moveToHeadOfLRU(QVGPixmapData *data);
145  void removeFromLRU(QVGPixmapData *data);
146  QVGPixmapData *pixmapLRU();
147 
148 private:
150 
153 };
154 
156 
157 #endif
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static const char * data(const QByteArray &arr)
QScopedPointer< QVGImagePoolPrivate > d_ptr
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
#define Q_OPENVG_EXPORT
Definition: qglobal.h:1457