#include <qgl_p.h>
Collaboration diagram for QGLContextPrivate:

Definition at line 185 of file qgl_p.h.
Public Member Functions | |
| QGLContextPrivate (QGLContext *context) | |
| ~QGLContextPrivate () | |
| GLuint | bindTexture (const QImage &image, GLenum target, GLint format, const QString &key, qint64 qt_id, bool clean=false) |
| GLuint | bindTexture (const QPixmap &pixmap, GLenum target, GLint format, bool clean) |
| GLuint | bindTexture (const QImage &image, GLenum target, GLint format, bool clean) |
| bool | textureCacheLookup (const QString &key, GLuint *id, qint64 *qt_id) |
| void | init (QPaintDevice *dev, const QGLFormat &format) |
| QImage | convertToBGRA (const QImage &image, bool force_premul) |
Public Attributes | |
| QGLFormat | glFormat |
| QGLFormat | reqFormat |
| uint | valid: 1 |
| uint | sharing: 1 |
| uint | initDone: 1 |
| uint | crWin: 1 |
| QPaintDevice * | paintDevice |
| QColor | transpColor |
| QGLContext * | q_ptr |
| QGLContextPrivate::QGLContextPrivate | ( | QGLContext * | context | ) | [inline, explicit] |
Definition at line 189 of file qgl_p.h.
References qt_glAttachShader, qt_glBindFramebufferEXT, qt_glBindProgramARB, qt_glBindRenderbufferEXT, qt_glCheckFramebufferStatusEXT, qt_glCompileShader, qt_glCreateProgram, qt_glCreateShader, qt_glDeleteFramebuffersEXT, qt_glDeleteProgram, qt_glDeleteProgramsARB, qt_glDeleteRenderbuffersEXT, qt_glDeleteShader, qt_glDetachShader, qt_glFramebufferRenderbufferEXT, qt_glFramebufferTexture1DEXT, qt_glFramebufferTexture2DEXT, qt_glFramebufferTexture3DEXT, qt_glGenerateMipmapEXT, qt_glGenFramebuffersEXT, qt_glGenProgramsARB, qt_glGenRenderbuffersEXT, qt_glGetFramebufferAttachmentParameterivEXT, qt_glGetProgramiv, qt_glGetRenderbufferParameterivEXT, qt_glGetShaderInfoLog, qt_glGetUniformLocation, qt_glIsFramebufferEXT, qt_glIsRenderbufferEXT, qt_glLinkProgram, qt_glProgramLocalParameter4fvARB, qt_glProgramStringARB, qt_glRenderbufferStorageEXT, qt_glShaderSource, qt_glUniform1fv, qt_glUniform1i, qt_glUniform2fv, qt_glUniform3fv, qt_glUniform4fv, and qt_glUseProgram.
00189 : q_ptr(context) 00190 { 00191 #ifdef Q_WS_WIN 00192 qt_glProgramStringARB = 0; 00193 qt_glBindProgramARB = 0; 00194 qt_glDeleteProgramsARB = 0; 00195 qt_glGenProgramsARB = 0; 00196 qt_glProgramLocalParameter4fvARB = 0; 00197 00198 qt_glCreateShader = 0; 00199 qt_glShaderSource = 0; 00200 qt_glCompileShader = 0; 00201 qt_glDeleteShader = 0; 00202 00203 qt_glCreateProgram = 0; 00204 qt_glAttachShader = 0; 00205 qt_glDetachShader = 0; 00206 qt_glLinkProgram = 0; 00207 qt_glUseProgram = 0; 00208 qt_glDeleteProgram = 0; 00209 00210 qt_glGetShaderInfoLog = 0; 00211 qt_glGetProgramiv = 0; 00212 00213 qt_glGetUniformLocation = 0; 00214 qt_glUniform4fv = 0; 00215 qt_glUniform3fv = 0; 00216 qt_glUniform2fv = 0; 00217 qt_glUniform1fv = 0; 00218 qt_glUniform1i = 0; 00219 00220 qt_glIsRenderbufferEXT = 0; 00221 qt_glBindRenderbufferEXT = 0; 00222 qt_glDeleteRenderbuffersEXT = 0; 00223 qt_glGenRenderbuffersEXT = 0; 00224 qt_glRenderbufferStorageEXT = 0; 00225 qt_glGetRenderbufferParameterivEXT = 0; 00226 qt_glIsFramebufferEXT = 0; 00227 qt_glBindFramebufferEXT = 0; 00228 qt_glDeleteFramebuffersEXT = 0; 00229 qt_glGenFramebuffersEXT = 0; 00230 qt_glCheckFramebufferStatusEXT = 0; 00231 qt_glFramebufferTexture1DEXT = 0; 00232 qt_glFramebufferTexture2DEXT = 0; 00233 qt_glFramebufferTexture3DEXT = 0; 00234 qt_glFramebufferRenderbufferEXT = 0; 00235 qt_glGetFramebufferAttachmentParameterivEXT = 0; 00236 qt_glGenerateMipmapEXT = 0; 00237 #endif 00238 }
| GLuint QGLContextPrivate::bindTexture | ( | const QImage & | image, | |
| GLenum | target, | |||
| GLint | format, | |||
| const QString & | key, | |||
| qint64 | qt_id, | |||
| bool | clean = false | |||
| ) |
Definition at line 1642 of file qgl.cpp.
References QGLTexture::context, convertToBGRA(), QGLExtensions::GenerateMipmap, GL_BGRA, GL_GENERATE_MIPMAP_HINT_SGIS, GL_GENERATE_MIPMAP_SGIS, QGLExtensions::glExtensions, i, image, QCache< Key, T >::insert(), key, QCache< Key, T >::keys(), QCache< Key, T >::maxCost(), nearest_gl_texture_size(), QCache< Key, T >::object(), qt_gl_image_cleanup(), qt_gl_pixmap_cleanup(), qt_image_cleanup_hook, qt_pixmap_cleanup_hook, qt_tex_cache, qt_tex_cache_limit, QCache< Key, T >::remove(), and QCache< Key, T >::totalCost().
Referenced by bindTexture().
01644 { 01645 Q_Q(QGLContext); 01646 01647 if (!qt_tex_cache) { 01648 qt_tex_cache = new QGLTextureCache(qt_tex_cache_limit); 01649 qt_pixmap_cleanup_hook = qt_gl_pixmap_cleanup; 01650 qt_image_cleanup_hook = qt_gl_image_cleanup; 01651 } 01652 01653 // Scale the pixmap if needed. GL textures needs to have the 01654 // dimensions 2^n+2(border) x 2^m+2(border). 01655 QImage tx; 01656 int tx_w = nearest_gl_texture_size(image.width()); 01657 int tx_h = nearest_gl_texture_size(image.height()); 01658 01659 // Note: the clean param is only true when a texture is bound 01660 // from the QOpenGLPaintEngine - in that case we have to force 01661 // a premultiplied texture format 01662 if (target == GL_TEXTURE_2D && (tx_w != image.width() || tx_h != image.height())) 01663 tx = convertToBGRA(image.scaled(tx_w, tx_h), clean); 01664 else 01665 tx = convertToBGRA(image, clean); 01666 01667 GLuint tx_id; 01668 glGenTextures(1, &tx_id); 01669 glBindTexture(target, tx_id); 01670 glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 01671 if (QGLExtensions::glExtensions & QGLExtensions::GenerateMipmap 01672 && target == GL_TEXTURE_2D) 01673 { 01674 glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST); 01675 glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); 01676 glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 01677 } else { 01678 glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 01679 } 01680 01681 glTexImage2D(target, 0, format, tx.width(), tx.height(), 0, GL_BGRA, 01682 GL_UNSIGNED_BYTE, tx.bits()); 01683 01684 // this assumes the size of a texture is always smaller than the max cache size 01685 int cost = tx.width()*tx.height()*4/1024; 01686 if (qt_tex_cache->totalCost() + cost > qt_tex_cache->maxCost()) { 01687 // the cache is full - make an attempt to remove something 01688 const QList<QString> keys = qt_tex_cache->keys(); 01689 int i = 0; 01690 while (i < qt_tex_cache->count() 01691 && (qt_tex_cache->totalCost() + cost > qt_tex_cache->maxCost())) { 01692 QGLTexture *tex = qt_tex_cache->object(keys.at(i)); 01693 if (tex->context == q) 01694 qt_tex_cache->remove(keys.at(i)); 01695 ++i; 01696 } 01697 } 01698 qt_tex_cache->insert(key, new QGLTexture(q, tx_id, qt_id, clean), cost); 01699 return tx_id; 01700 }
Here is the call graph for this function:

| GLuint QGLContextPrivate::bindTexture | ( | const QPixmap & | pixmap, | |
| GLenum | target, | |||
| GLint | format, | |||
| bool | clean | |||
| ) |
Definition at line 1735 of file qgl.cpp.
References bindTexture(), id, key, qt_pixmap_id(), QPixmap::serialNumber(), textureCacheLookup(), and QPixmap::toImage().
01736 { 01737 Q_Q(QGLContext); 01738 const QString key = QString(QLatin1String("%1_%2_%3")).arg(QString().sprintf("p%08x",pixmap.serialNumber())).arg(target).arg(format); 01739 GLuint id; 01740 qint64 qt_id; 01741 if (textureCacheLookup(key, &id, &qt_id)) { 01742 if (qt_pixmap_id(pixmap) == qt_id) { 01743 glBindTexture(target, id); 01744 return id; 01745 } else { 01746 q->deleteTexture(id); 01747 } 01748 } 01749 return bindTexture(pixmap.toImage(), target, format, key, qt_pixmap_id(pixmap), clean); 01750 }
Here is the call graph for this function:

| GLuint QGLContextPrivate::bindTexture | ( | const QImage & | image, | |
| GLenum | target, | |||
| GLint | format, | |||
| bool | clean | |||
| ) |
Definition at line 1717 of file qgl.cpp.
References bindTexture(), id, image, key, qt_image_id(), and textureCacheLookup().
01718 { 01719 Q_Q(QGLContext); 01720 const QString key = QString(QLatin1String("%1_%2_%3")).arg(QString().sprintf("i%08x",image.serialNumber())).arg(target).arg(format); 01721 GLuint id; 01722 qint64 qt_id; 01723 if (textureCacheLookup(key, &id, &qt_id)) { 01724 if (qt_image_id(image) == qt_id) { 01725 glBindTexture(target, id); 01726 return id; 01727 } else { 01728 q->deleteTexture(id); 01729 } 01730 } 01731 return bindTexture(image, target, format, key, qt_image_id(image), clean); 01732 }
Here is the call graph for this function:

Definition at line 1702 of file qgl.cpp.
References key, QCache< Key, T >::object(), and qt_tex_cache.
Referenced by bindTexture().
01703 { 01704 Q_Q(QGLContext); 01705 if (qt_tex_cache) { 01706 QGLTexture *texture = qt_tex_cache->object(key); 01707 if (texture && texture->context == q) { 01708 *id = texture->id; 01709 *qt_id = texture->qt_id; 01710 return true; 01711 } 01712 } 01713 return false; 01714 }
Here is the call graph for this function:

| void QGLContextPrivate::init | ( | QPaintDevice * | dev, | |
| const QGLFormat & | format | |||
| ) |
Definition at line 1239 of file qgl.cpp.
References crWin, glFormat, initDone, reqFormat, sharing, and valid.
01240 { 01241 Q_Q(QGLContext); 01242 glFormat = reqFormat = format; 01243 valid = false; 01244 q->setDevice(dev); 01245 #if defined(Q_WS_X11) 01246 gpm = 0; 01247 #endif 01248 #if defined(Q_WS_WIN) 01249 dc = 0; 01250 win = 0; 01251 pixelFormatId = 0; 01252 cmap = 0; 01253 hbitmap = 0; 01254 hbitmap_hdc = 0; 01255 #endif 01256 #if defined(Q_WS_MAC) 01257 update = false; 01258 #endif 01259 #if defined(Q_WS_QWS) 01260 dpy = 0; 01261 cx = 0; 01262 config = 0; 01263 surface = 0; 01264 #endif 01265 crWin = false; 01266 initDone = false; 01267 sharing = false; 01268 }
Definition at line 1610 of file qgl.cpp.
References QImage::copy(), QImage::Format_ARGB32, QImage::Format_ARGB32_Premultiplied, QImage::height(), i, image, QImage::mirrored(), p, QImage::scanLine(), and QImage::width().
Referenced by bindTexture().
01611 { 01612 QImage img = image; 01613 01614 if ((force_premul && image.format() != QImage::Format_ARGB32_Premultiplied) 01615 || (!force_premul && image.format() != QImage::Format_ARGB32_Premultiplied 01616 && image.format() != QImage::Format_ARGB32)) { 01617 img = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); 01618 } 01619 01620 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { 01621 // mirror + swizzle 01622 QImage res = img.copy(); 01623 for (int i=0; i < img.height(); i++) { 01624 uint *p = (uint*) img.scanLine(i); 01625 uint *q = (uint*) res.scanLine(img.height() - i - 1); 01626 uint *end = p + img.width(); 01627 while (p < end) { 01628 *q = ((*p << 24) & 0xff000000) 01629 | ((*p >> 24) & 0x000000ff) 01630 | ((*p << 8) & 0x00ff0000) 01631 | ((*p >> 8) & 0x0000ff00); 01632 p++; 01633 q++; 01634 } 01635 } 01636 return res; 01637 } else { 01638 return img.mirrored(); 01639 } 01640 }
Here is the call graph for this function:

1.5.1