Qt 4.8
Public Functions | Protected Variables | Properties | List of all members
QGLContextGroupResourceBase Class Referenceabstract

#include <qgl_p.h>

Inheritance diagram for QGLContextGroupResourceBase:
QGLContextGroupResource< T > QGLContextGroupResource< QGL2GradientCache > QGLContextGroupResource< QGLGlyphTexture > QGLTextureGlyphCache

Public Functions

virtual void freeResource (void *value)=0
 
 QGLContextGroupResourceBase ()
 
virtual ~QGLContextGroupResourceBase ()
 
void insert (const QGLContext *context, void *value)
 
void * value (const QGLContext *context)
 
void cleanup (const QGLContext *context)
 
void cleanup (const QGLContext *context, void *value)
 
virtual void contextDeleted (const QGLContext *ctx)
 

Protected Variables

QList< QGLContextGroup * > m_groups
 

Properties

QAtomicInt active
 

Detailed Description

Definition at line 730 of file qgl_p.h.

Constructors and Destructors

◆ QGLContextGroupResourceBase()

QGLContextGroupResourceBase::QGLContextGroupResourceBase ( )

Definition at line 5884 of file qgl.cpp.

5885  : active(0)
5886 {
5887 #ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
5888  qDebug("Creating context group resource object %p.", this);
5889 #endif
5890 }
Q_CORE_EXPORT void qDebug(const char *,...)

◆ ~QGLContextGroupResourceBase()

QGLContextGroupResourceBase::~QGLContextGroupResourceBase ( )
virtual

Definition at line 5892 of file qgl.cpp.

5893 {
5894 #ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
5895  qDebug("Deleting context group resource %p. Group size: %d.", this, m_groups.size());
5896 #endif
5897  for (int i = 0; i < m_groups.size(); ++i) {
5898  m_groups.at(i)->m_resources.remove(this);
5899  active.deref();
5900  }
5901 #ifndef QT_NO_DEBUG
5902  if (active != 0) {
5903  qWarning("QtOpenGL: Resources are still available at program shutdown.\n"
5904  " This is possibly caused by a leaked QGLWidget, \n"
5905  " QGLFramebufferObject or QGLPixelBuffer.");
5906  }
5907 #endif
5908 }
Q_CORE_EXPORT void qDebug(const char *,...)
QList< QGLContextGroup * > m_groups
Definition: qgl_p.h:743
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool deref()
Atomically decrements the value of this QAtomicInt.
Q_CORE_EXPORT void qWarning(const char *,...)
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QHash< QGLContextGroupResourceBase *, void * > m_resources
Definition: qgl_p.h:268

Functions

◆ cleanup() [1/2]

void QGLContextGroupResourceBase::cleanup ( const QGLContext context)

Definition at line 5928 of file qgl.cpp.

Referenced by QGLTextureGlyphCache::clear().

5929 {
5930  void *resource = value(ctx);
5931 
5932  if (resource != 0) {
5933  QGLShareContextScope scope(ctx);
5934  freeResource(resource);
5935 
5937  group->m_resources.remove(this);
5938  m_groups.removeOne(group);
5939  active.deref();
5940  }
5941 }
void * value(const QGLContext *context)
Definition: qgl.cpp:5922
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796
QList< QGLContextGroup * > m_groups
Definition: qgl_p.h:743
bool deref()
Atomically decrements the value of this QAtomicInt.
static QGLContextGroup * contextGroup(const QGLContext *ctx)
Definition: qgl_p.h:464
#define ctx
Definition: qgl.cpp:6094
virtual void freeResource(void *value)=0
QHash< QGLContextGroupResourceBase *, void * > m_resources
Definition: qgl_p.h:268

◆ cleanup() [2/2]

void QGLContextGroupResourceBase::cleanup ( const QGLContext context,
void *  value 
)

Definition at line 5948 of file qgl.cpp.

5949 {
5950 #ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
5951  qDebug("Cleaning up context group resource %p, for context %p in thread %p.", this, ctx, QThread::currentThread());
5952 #endif
5953  QGLShareContextScope scope(ctx);
5955  active.deref();
5956 
5958  m_groups.removeOne(group);
5959 }
void * value(const QGLContext *context)
Definition: qgl.cpp:5922
Q_CORE_EXPORT void qDebug(const char *,...)
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
QList< QGLContextGroup * > m_groups
Definition: qgl_p.h:743
bool deref()
Atomically decrements the value of this QAtomicInt.
static QGLContextGroup * contextGroup(const QGLContext *ctx)
Definition: qgl_p.h:464
#define ctx
Definition: qgl.cpp:6094
virtual void freeResource(void *value)=0

◆ contextDeleted()

void QGLContextGroupResourceBase::contextDeleted ( const QGLContext ctx)
virtual

Reimplemented in QGLTextureGlyphCache.

Definition at line 5943 of file qgl.cpp.

5944 {
5945  Q_UNUSED(ctx);
5946 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ freeResource()

virtual void QGLContextGroupResourceBase::freeResource ( void *  value)
pure virtual

◆ insert()

void QGLContextGroupResourceBase::insert ( const QGLContext context,
void *  value 
)

Definition at line 5910 of file qgl.cpp.

Referenced by QGL2PaintEngineExPrivate::drawCachedGlyphs().

5911 {
5912 #ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
5913  qDebug("Inserting context group resource %p for context %p, managed by %p.", value, context, this);
5914 #endif
5916  Q_ASSERT(!group->m_resources.contains(this));
5917  group->m_resources.insert(this, value);
5918  m_groups.append(group);
5919  active.ref();
5920 }
void * value(const QGLContext *context)
Definition: qgl.cpp:5922
bool ref()
Atomically increments the value of this QAtomicInt.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT void qDebug(const char *,...)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QGLContextGroup * > m_groups
Definition: qgl_p.h:743
static QGLContextGroup * contextGroup(const QGLContext *ctx)
Definition: qgl_p.h:464
QHash< QGLContextGroupResourceBase *, void * > m_resources
Definition: qgl_p.h:268

◆ value()

void * QGLContextGroupResourceBase::value ( const QGLContext context)

Definition at line 5922 of file qgl.cpp.

Referenced by QGLContextGroupResource< QGL2GradientCache >::value(), and QGLContextGroupResource< QGL2GradientCache >::~QGLContextGroupResource().

5923 {
5925  return group->m_resources.value(this, 0);
5926 }
static QGLContextGroup * contextGroup(const QGLContext *ctx)
Definition: qgl_p.h:464
QHash< QGLContextGroupResourceBase *, void * > m_resources
Definition: qgl_p.h:268

Properties

◆ active

QAtomicInt QGLContextGroupResourceBase::active
private

Definition at line 746 of file qgl_p.h.

◆ m_groups

QList<QGLContextGroup *> QGLContextGroupResourceBase::m_groups
protected

Definition at line 743 of file qgl_p.h.


The documentation for this class was generated from the following files: