Qt 4.8
Public Functions | Private Functions | Properties | Friends | List of all members
QGLContextGroup Class Reference

#include <qgl_p.h>

Public Functions

void addGuard (QGLSharedResourceGuard *guard)
 
const QGLContextcontext () const
 
QGLExtensionFuncsextensionFuncs ()
 
bool isSharing () const
 
void removeGuard (QGLSharedResourceGuard *guard)
 
QList< const QGLContext * > shares () const
 
 ~QGLContextGroup ()
 

Private Functions

 QGLContextGroup (const QGLContext *context)
 

Properties

const QGLContextm_context
 
QGLExtensionFuncs m_extensionFuncs
 
QGLSharedResourceGuardm_guards
 
QAtomicInt m_refs
 
QHash< QGLContextGroupResourceBase *, void * > m_resources
 
QList< const QGLContext * > m_shares
 

Friends

class QGLContext
 
class QGLContextGroupResourceBase
 
class QGLContextPrivate
 
static void addShare (const QGLContext *context, const QGLContext *share)
 
static void removeShare (const QGLContext *context)
 
void cleanupResources (const QGLContext *ctx)
 

Detailed Description

Definition at line 246 of file qgl_p.h.

Constructors and Destructors

◆ ~QGLContextGroup()

QGLContextGroup::~QGLContextGroup ( )

Definition at line 1685 of file qgl.cpp.

1686 {
1687  // Clear any remaining QGLSharedResourceGuard objects on the group.
1689  while (guard != 0) {
1690  guard->m_group = 0;
1691  guard->m_id = 0;
1692  guard = guard->m_next;
1693  }
1694  qt_context_groups()->remove(this);
1695 }
QGLSharedResourceGuard * m_guards
Definition: qgl_p.h:269
QGLContextGroup * m_group
Definition: qgl_p.h:891
QGLSharedResourceGuard * m_next
Definition: qgl_p.h:893

◆ QGLContextGroup()

QGLContextGroup::QGLContextGroup ( const QGLContext context)
private

Definition at line 1679 of file qgl.cpp.

1680  : m_context(context), m_guards(0), m_refs(1)
1681 {
1682  qt_context_groups()->append(this);
1683 }
const QGLContext * m_context
Definition: qgl_p.h:266
QGLSharedResourceGuard * m_guards
Definition: qgl_p.h:269
QAtomicInt m_refs
Definition: qgl_p.h:270

Functions

◆ addGuard()

void QGLContextGroup::addGuard ( QGLSharedResourceGuard guard)

Definition at line 1697 of file qgl.cpp.

1698 {
1699  if (m_guards)
1700  m_guards->m_prev = guard;
1701  guard->m_next = m_guards;
1702  guard->m_prev = 0;
1703  m_guards = guard;
1704 }
QGLSharedResourceGuard * m_guards
Definition: qgl_p.h:269
QGLSharedResourceGuard * m_prev
Definition: qgl_p.h:894
QGLSharedResourceGuard * m_next
Definition: qgl_p.h:893

◆ addShare()

void QGLContextGroup::addShare ( const QGLContext context,
const QGLContext share 
)
static

Definition at line 5846 of file qgl.cpp.

Referenced by QGLPixelBufferPrivate::common_init(), and QX11GLPixmapData::paintEngine().

5846  {
5847  Q_ASSERT(context && share);
5848  if (context->d_ptr->group == share->d_ptr->group)
5849  return;
5850 
5851  // Make sure 'context' is not already shared with another group of contexts.
5852  Q_ASSERT(context->d_ptr->group->m_refs == 1);
5853 
5854  // Free 'context' group resources and make it use the same resources as 'share'.
5855  QGLContextGroup *group = share->d_ptr->group;
5856  delete context->d_ptr->group;
5857  context->d_ptr->group = group;
5858  group->m_refs.ref();
5859 
5860  // Maintain a list of all the contexts in each group of sharing contexts.
5861  // The list is empty if the "share" context wasn't sharing already.
5862  if (group->m_shares.isEmpty())
5863  group->m_shares.append(share);
5864  group->m_shares.append(context);
5865 }
QScopedPointer< QGLContextPrivate > d_ptr
Definition: qgl.h:430
QGLContextGroup * group
Definition: qgl_p.h:453
bool ref()
Atomically increments the value of this QAtomicInt.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QAtomicInt m_refs
Definition: qgl_p.h:270
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< const QGLContext * > m_shares
Definition: qgl_p.h:267

◆ cleanupResources()

void QGLContextGroup::cleanupResources ( const QGLContext ctx)
private

Definition at line 5961 of file qgl.cpp.

5962 {
5963  // Notify all resources that a context has been deleted
5965  for (it = m_resources.begin(); it != m_resources.end(); ++it)
5966  it.key()->contextDeleted(context);
5967 
5968  // If there are still shares, then no cleanup to be done yet.
5969  if (m_shares.size() > 1)
5970  return;
5971 
5972  // Iterate over all resources and free each in turn.
5973  for (it = m_resources.begin(); it != m_resources.end(); ++it)
5974  it.key()->cleanup(context, it.value());
5975 }
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
const Key & key() const
Returns the current item&#39;s key.
Definition: qhash.h:419
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
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
QList< const QGLContext * > m_shares
Definition: qgl_p.h:267
const QGLContext * context() const
Definition: qgl_p.h:252

◆ context()

const QGLContext* QGLContextGroup::context ( ) const
inline

Definition at line 252 of file qgl_p.h.

Referenced by QGL2PaintEngineExPrivate::drawCachedGlyphs().

252 {return m_context;}
const QGLContext * m_context
Definition: qgl_p.h:266

◆ extensionFuncs()

QGLExtensionFuncs& QGLContextGroup::extensionFuncs ( )
inline

Definition at line 251 of file qgl_p.h.

Referenced by QGLContextPrivate::extensionFuncs().

251 {return m_extensionFuncs;}
QGLExtensionFuncs m_extensionFuncs
Definition: qgl_p.h:265

◆ isSharing()

bool QGLContextGroup::isSharing ( ) const
inline

Definition at line 253 of file qgl_p.h.

253 { return m_shares.size() >= 2; }
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< const QGLContext * > m_shares
Definition: qgl_p.h:267

◆ removeGuard()

void QGLContextGroup::removeGuard ( QGLSharedResourceGuard guard)

Definition at line 1706 of file qgl.cpp.

1707 {
1708  if (guard->m_next)
1709  guard->m_next->m_prev = guard->m_prev;
1710  if (guard->m_prev)
1711  guard->m_prev->m_next = guard->m_next;
1712  else
1713  m_guards = guard->m_next;
1714 }
QGLSharedResourceGuard * m_guards
Definition: qgl_p.h:269
QGLSharedResourceGuard * m_prev
Definition: qgl_p.h:894
QGLSharedResourceGuard * m_next
Definition: qgl_p.h:893

◆ removeShare()

void QGLContextGroup::removeShare ( const QGLContext context)
static

Definition at line 5867 of file qgl.cpp.

Referenced by QGLContext::chooseMacVisual(), QGLContext::choosePixelFormat(), qDeleteQGLContext(), QGLContext::reset(), and QGLContext::tryVisual().

5867  {
5868  // Remove the context from the group.
5869  QGLContextGroup *group = context->d_ptr->group;
5870  if (group->m_shares.isEmpty())
5871  return;
5872  group->m_shares.removeAll(context);
5873 
5874  // Update context group representative.
5875  Q_ASSERT(group->m_shares.size() != 0);
5876  if (group->m_context == context)
5877  group->m_context = group->m_shares[0];
5878 
5879  // If there is only one context left, then make the list empty.
5880  if (group->m_shares.size() == 1)
5881  group->m_shares.clear();
5882 }
const QGLContext * m_context
Definition: qgl_p.h:266
QScopedPointer< QGLContextPrivate > d_ptr
Definition: qgl.h:430
QGLContextGroup * group
Definition: qgl_p.h:453
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void clear()
Removes all items from the list.
Definition: qlist.h:764
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< const QGLContext * > m_shares
Definition: qgl_p.h:267
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770

◆ shares()

QList<const QGLContext *> QGLContextGroup::shares ( ) const
inline

Definition at line 254 of file qgl_p.h.

254 { return m_shares; }
QList< const QGLContext * > m_shares
Definition: qgl_p.h:267

Friends and Related Functions

◆ QGLContext

friend class QGLContext
friend

Definition at line 274 of file qgl_p.h.

◆ QGLContextGroupResourceBase

Definition at line 276 of file qgl_p.h.

◆ QGLContextPrivate

friend class QGLContextPrivate
friend

Definition at line 275 of file qgl_p.h.

Properties

◆ m_context

const QGLContext* QGLContextGroup::m_context
private

Definition at line 266 of file qgl_p.h.

◆ m_extensionFuncs

QGLExtensionFuncs QGLContextGroup::m_extensionFuncs
private

Definition at line 265 of file qgl_p.h.

◆ m_guards

QGLSharedResourceGuard* QGLContextGroup::m_guards
private

Definition at line 269 of file qgl_p.h.

◆ m_refs

QAtomicInt QGLContextGroup::m_refs
private

Definition at line 270 of file qgl_p.h.

◆ m_resources

QHash<QGLContextGroupResourceBase *, void *> QGLContextGroup::m_resources
private

Definition at line 268 of file qgl_p.h.

◆ m_shares

QList<const QGLContext *> QGLContextGroup::m_shares
private

Definition at line 267 of file qgl_p.h.


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