56 #include "QtOpenGL/qgl.h" 57 #include "QtOpenGL/qglcolormap.h" 58 #include "QtCore/qmap.h" 59 #include "QtCore/qthread.h" 60 #include "QtCore/qthreadstorage.h" 61 #include "QtCore/qhash.h" 62 #include "QtCore/qatomic.h" 63 #include "private/qwidget_p.h" 74 #include <QtGui/private/qegl_p.h> 78 #include <QtGui/QPlatformGLContext> 89 # define old_qDebug qDebug 93 #ifndef QT_MAC_USE_COCOA 99 # define qDebug QT_NO_QDEBUG_MACRO 118 #include <QtOpenGL/private/qglextensions_p.h> 177 , disable_clear_on_painter_begin(false)
178 #
if defined(Q_WS_QWS)
181 #
if defined(Q_WS_X11) && !defined(QT_NO_EGL)
182 , eglSurfaceWindowId(0)
184 #
if defined(Q_OS_SYMBIAN)
185 , eglSurfaceWindowId(0)
186 , surfaceSizeInitialized(false)
190 #if defined(Q_OS_SYMBIAN) 192 isGLGlobalShareWidget = 1;
200 bool renderCxPm(
QPixmap *pixmap);
201 void cleanupColormaps();
218 #if defined(Q_WS_WIN) 219 void updateColormap();
221 #elif defined(Q_WS_X11) 224 void recreateEglSurface();
225 WId eglSurfaceWindowId;
227 #elif defined(Q_WS_MAC) 229 void updatePaintDevice();
230 #elif defined(Q_WS_QWS) 234 void recreateEglSurface();
235 WId eglSurfaceWindowId;
236 bool surfaceSizeInitialized : 1;
260 static void removeShare(
const QGLContext *context);
287 TextureRectangle = 0x00000001,
289 GenerateMipmap = 0x00000004,
290 TextureCompression = 0x00000008,
291 FragmentProgram = 0x00000010,
292 MirroredRepeat = 0x00000020,
293 FramebufferObject = 0x00000040,
294 StencilTwoSide = 0x00000080,
295 StencilWrap = 0x00000100,
296 PackedDepthStencil = 0x00000200,
297 NVFloatBuffer = 0x00000400,
298 PixelBufferObject = 0x00000800,
299 FramebufferBlit = 0x00001000,
300 NPOTTextures = 0x00002000,
301 BGRATextureFormat = 0x00004000,
302 DDSTextureCompression = 0x00008000,
303 ETC1TextureCompression = 0x00010000,
304 PVRTCTextureCompression = 0x00020000,
305 FragmentShader = 0x00040000,
306 ElementIndexUint = 0x00080000,
307 Depth24 = 0x00100000,
308 SRGBFrameBuffer = 0x00200000
312 static Extensions glExtensions();
313 static Extensions currentContextExtensions();
343 #define QT_GL_VERTEX_ARRAY_TRACKED_COUNT 3 354 QGLContext::BindOptions options);
356 QGLContext::BindOptions options);
358 QGLContext::BindOptions options);
361 QImage convertToGLFormat(
const QImage &image,
bool force_premul,
GLenum texture_format);
362 int maxTextureSize();
366 void setVertexAttribArrayEnabled(
int arrayIndex,
bool enabled =
true);
368 void swapRegion(
const QRegion ®ion);
370 #if defined(Q_WS_WIN) 371 void updateFormatVersion();
374 #if defined(Q_WS_WIN) 387 void destroyEglSurfaceForDevice();
388 EGLSurface eglSurfaceForDevice()
const;
390 static void setExtraWindowSurfaceCreationProps(
QEglProperties *props);
393 #if defined(Q_WS_QPA) 397 #elif defined(Q_WS_X11) || defined(Q_WS_MAC) 400 #if defined(Q_WS_X11) || defined(Q_WS_MAC) 403 #if defined(Q_WS_X11) 409 QGLContext::BindOptions options);
410 static void destroyGlSurfaceForPixmap(
QPixmapData*);
413 #if defined(Q_WS_MAC) 415 void *tryFormat(
const QGLFormat &format);
416 void clearDrawable();
470 #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) 475 static void setCurrentContext(
QGLContext *context);
491 m_oldContext = currentContext;
495 m_ctx = currentContext;
512 m_oldContext->makeCurrent();
525 qRegisterMetaType<GLuint>(
"GLuint");
530 emit freeTexture(context, boundPixmap,
id);
539 #if defined(Q_WS_X11) 548 glDeleteTextures(1, &
id);
555 glDeleteTextures(1, &
id);
565 emit aboutToDestroyContext(context);
569 void aboutToDestroyContext(
const QGLContext *context);
580 #
if defined(Q_WS_X11)
582 #elif defined(Q_OS_SYMBIAN)
588 , failedToAlloc(false)
589 , inTexturePool(false)
599 #if !defined(Q_WS_X11) 602 context->d_ptr->texture_destroyer->emitFreeTexture(context, boundPixmap,
id);
613 #if defined(Q_WS_X11) 617 bool canBindCompressedTexture
618 (
const char *buf,
int len,
const char *
format,
bool *hasAlpha);
619 QSize bindCompressedTexture
621 QSize bindCompressedTexture
622 (
const char *buf,
int len,
const char *
format = 0);
623 QSize bindCompressedTextureDDS(
const char *buf,
int len);
624 QSize bindCompressedTexturePVR(
const char *buf,
int len);
635 mutable bool failedToAlloc;
636 mutable bool inTexturePool;
664 inline void setMaxCost(
int newMax);
665 inline int maxCost();
671 static void cleanupTexturesForCacheKey(
qint64 cacheKey);
672 static void cleanupTexturesForPixampData(
QPixmapData* pixmap);
673 static void cleanupBeforePixmapDestruction(
QPixmapData* pixmap);
682 return m_cache.size();
688 m_cache.setMaxCost(newMax);
694 return m_cache.maxCost();
702 return m_cache.object(cacheKey);
717 #if defined(QT_OPENGL_ES_2) 735 void insert(
const QGLContext *context,
void *value);
739 virtual void freeResource(
void *value) = 0;
765 for (
int i = 0; i < m_groups.size(); ++i) {
766 const QGLContext *context = m_groups.at(i)->context();
778 resource =
new T(context);
779 insert(context, resource);
786 delete reinterpret_cast<T *
>(resource);
797 for (
int i = 0; i < m_contexts.size(); ++i)
798 m_contexts.at(i)->d_ptr->m_resources.remove(
this);
808 virtual void freeResource(
void *value) = 0;
828 for (
int i = 0; i < m_contexts.size(); ++i) {
841 resource =
new T(context);
842 insert(context, resource);
849 delete reinterpret_cast<T *
>(resource);
862 : m_group(0), m_id(0), m_next(0), m_prev(0)
867 : m_group(0), m_id(id), m_next(0), m_prev(0)
875 return m_group ? m_group->context() : 0;
913 for (
int i = 0; i < m_offsets.size(); ++i) {
914 const char *extension = m_extensions.constData() + m_offsets.at(i);
915 if (
qstrncmp(extension, str, str_length) == 0 && extension[str_length] ==
' ')
922 void init(
const char *str);
const QGLContext * m_context
The QColor class provides colors based on RGB, HSV or CMYK values.
~QGLContextGroupResource()
QScopedPointer< QGLContextPrivate > d_ptr
const QGLContext * context() const
void * value(const QGLContext *context)
QGLSharedResourceGuard(const QGLContext *context, GLuint id)
void setMaxCost(int newMax)
T * value(const QGLContext *context)
#define QT_END_NAMESPACE
This macro expands to.
static Q_OPENGL_EXPORT QGLExtensionFuncs qt_extensionFuncs
void emitAboutToDestroyContext(const QGLContext *context)
void emitFreeTexture(QGLContext *context, QPixmapData *boundPixmap, GLuint id)
QScopedPointer< QGLTemporaryContextPrivate > d
uint workaround_needsFullClearOnEveryFrame
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
QCache< QGLTextureCacheKey, QGLTexture > m_cache
virtual ~QGLContextResourceBase()
The QAtomicInt class provides platform-independent atomic operations on integers. ...
bool qt_gl_preferGL2Engine()
QGLContext * operator->()
The QByteArray class provides an array of bytes.
T * value(const QGLContext *context)
void freeResource(void *resource)
QGLTexture * getTexture(QGLContext *ctx, qint64 key)
bool qt_initializing_gl_share_widget()
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
long ASN1_INTEGER_get ASN1_INTEGER * a
QGLTexture(QGLContext *ctx=0, GLuint tx_id=0, GLenum tx_target=GL_TEXTURE_2D, QGLContext::BindOptions opt=QGLContext::DefaultBindOption)
uint workaround_brokenTexSubImage
QGLSharedResourceGuard * m_guards
QHash< QPixmapData *, QPixmap > boundPixmaps
The QString class provides a Unicode character string.
The QHash class is a template class that provides a hash-table-based dictionary.
The QObject class is the base class of all Qt objects.
QGLSharedResourceGuard * m_prev
QPaintDevice * paintDevice
QGLContext::BindOptions options
uint workaround_brokenAlphaTexSubImage
static const QGLContext * currentContext()
Returns the current context, i.e.
QThreadStorage< QPaintEngine * > storage
static bool areSharing(const QGLContext *context1, const QGLContext *context2)
Returns true if context1 and context2 are sharing their GL resources such as textures, shader programs, etc; otherwise returns false.
uint workaround_brokenTextureFromPixmap_init
GLenum qt_gl_preferredTextureTarget()
#define QT_BEGIN_NAMESPACE
This macro expands to.
QList< QGLContextGroup * > m_groups
#define QT_GL_VERTEX_ARRAY_TRACKED_COUNT
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
The QGLContext class encapsulates an OpenGL rendering context.
QGLExtensions::Extensions extension_flags
QGLContextGroup * m_group
uint workaround_brokenAlphaTexSubImage_init
QHash< QGLContextResourceBase *, void * > m_resources
The QImage class provides a hardware-independent image representation that allows direct access to th...
The QRegion class specifies a clip region for a painter.
Q_OPENGL_EXPORT QPaintEngine * qt_qgl_paint_engine()
The QReadLocker class is a convenience class that simplifies locking and unlocking read-write locks f...
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
The QGLColormap class is used for installing custom colormaps into a QGLWidget.
The QWriteLocker class is a convenience class that simplifies locking and unlocking read-write locks ...
QPixmapData * boundPixmap
uint qstrlen(const char *str)
static QGLContextGroup * contextGroup(const QGLContext *ctx)
#define Q_DECLARE_PUBLIC(Class)
void freeTexture_slot(QGLContext *context, QPixmapData *boundPixmap, GLuint id)
QGLContext * m_oldContext
The QPlatformGLContext class provides an abstraction for native GL contexts.
QGLFormat::OpenGLVersionFlags version_flags
The QReadWriteLock class provides read-write locking.
The QPixmapFilter class provides the basic functionality for pixmap filter classes.
QGLSharedResourceGuard * m_next
static QEglProperties * extraWindowSurfaceCreationProps
uint extension_flags_cached
QList< const QGLContext * > m_contexts
#define GL_TEXTURE_RECTANGLE_NV
bool operator==(const QGLTextureCacheKey &a, const QGLTextureCacheKey &b)
int qstrncmp(const char *str1, const char *str2, uint len)
Q_OPENGL_EXPORT const QGLContext * qt_gl_transfer_context(const QGLContext *)
if(void) toggleToolbarShown
uint workaround_brokenScissor
#define Q_AUTOTEST_EXPORT
QList< const QGLContext * > shares() const
virtual void makeCurrent()
Makes this context the current OpenGL rendering context.
uint qHash(const QGLTextureCacheKey &key)
bool match(const char *str) const
static Extensions glExtensions()
void * value(const QGLContext *context)
The QPixmap class is an off-screen image representation that can be used as a paint device...
QGLTextureDestroyer * texture_destroyer
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
QGLExtensionFuncs m_extensionFuncs
void freeResource(void *resource)
The QSize class defines the size of a two-dimensional object using integer point precision.
void insert(const QGLContext *context, void *value)
QHash< QGLContextGroupResourceBase *, void * > m_resources
QGLExtensionFuncs & extensionFuncs()
static void unbindPixmapFromTexture(QPixmapData *)
QPaintEngine * active_engine
QGLShareContextScope(const QGLContext *ctx)
uint workaround_brokenTextureFromPixmap
uint version_flags_cached
GLenum qt_gl_preferredTextureFormat()
The QThreadStorage class provides per-thread data storage.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static QString fileName(const QString &fileUrl)
static QGLExtensionFuncs & extensionFuncs(const QGLContext *ctx)
The QWSGLWindowSurface class provides the drawing area for top-level windows with Qt for Embedded Lin...
QList< const QGLContext * > m_shares
const QGLContext * context() const
QGLSharedResourceGuard(const QGLContext *context)
The QList class is a template class that provides lists.
uint workaround_brokenFBOReadBack