Qt 4.8
qgltexturepool_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 QGLTEXTUREPOOL_P_H
43 #define QGLTEXTUREPOOL_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 "qgl.h"
57 #include <QtCore/qscopedpointer.h>
58 
60 
61 class QGLTexture;
63 
65 {
66 public:
68  virtual ~QGLTexturePool();
69 
70  static QGLTexturePool *instance();
71 
72  // Create a new texture with the specified parameters and associate
73  // it with "texture". The QGLTexture will be notified when the
74  // texture needs to be reclaimed by the pool.
75  //
76  // This function will call reclaimSpace() when texture creation fails.
77  GLuint createTexture(GLenum target,
78  GLint level,
79  GLint internalformat,
80  GLsizei width,
81  GLsizei height,
82  GLenum format,
83  GLenum type,
84  QGLTexture *texture);
85 
86  // Create a permanent texture with the specified parameters.
87  // If there is insufficient space for the texture,
88  // then this function will call reclaimSpace() and try again.
89  //
90  // The caller is responsible for calling glDeleteTextures()
91  // when it no longer needs the texture, as the texture is not
92  // recorded in the texture pool.
93  bool createPermanentTexture(GLuint texture,
94  GLenum target,
95  GLint level,
96  GLint internalformat,
97  GLsizei width,
98  GLsizei height,
99  GLenum format,
100  GLenum type,
101  const GLvoid *data);
102 
103  // Notify the pool that a QGLTexture object is using
104  // an texture again. This allows the pool to move the texture
105  // within a least-recently-used list of QGLTexture objects.
106  void useTexture(QGLTexture *texture);
107 
108  // Notify the pool that the texture associated with a
109  // QGLTexture is being detached from the pool. The caller
110  // will become responsible for calling glDeleteTextures().
111  void detachTexture(QGLTexture *texture);
112 
113  // Reclaim space for an image allocation with the specified parameters.
114  // Returns true if space was reclaimed, or false if there is no
115  // further space that can be reclaimed. The "texture" parameter
116  // indicates the texture that is trying to obtain space which should
117  // not itself be reclaimed.
118  bool reclaimSpace(GLint internalformat,
119  GLsizei width,
120  GLsizei height,
121  GLenum format,
122  GLenum type,
123  QGLTexture *data);
124 
125  // Hibernate the texture pool because the context is about to be
126  // destroyed. All textures left in the pool should be released.
127  void hibernate();
128 
129 protected:
130  // Helper functions for managing the LRU list of QGLTexture objects.
131  void moveToHeadOfLRU(QGLTexture *texture);
132  void removeFromLRU(QGLTexture *texture);
134 
135 private:
137 
140 };
141 
143 
144 #endif
bool createPermanentTexture(GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data)
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void moveToHeadOfLRU(QGLTexture *texture)
void useTexture(QGLTexture *texture)
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
void removeFromLRU(QGLTexture *texture)
void detachTexture(QGLTexture *texture)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual ~QGLTexturePool()
static const char * data(const QByteArray &arr)
static QGLTexturePool * instance()
bool reclaimSpace(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, QGLTexture *data)
unsigned int GLenum
Definition: main.cpp:50
QGLTexture * textureLRU()
QScopedPointer< QGLTexturePoolPrivate > d_ptr
int GLsizei
Definition: main.cpp:49
typedef GLint
Definition: glfunctions.h:67
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
GLuint createTexture(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, QGLTexture *texture)