| 125 | // ============================================================================ |
| 126 | |
| 127 | TextureCache::TextureCache() |
| 128 | // ---------------------------------------------------------------------------- |
| 129 | // Initialize cache |
| 130 | // ---------------------------------------------------------------------------- |
| 131 | : memSize(0), GLSize(0), |
| 132 | maxMemSize(PerformancesPage::textureCacheMaxMem()), |
| 133 | maxGLSize(PerformancesPage::textureCacheMaxGLMem()), |
| 134 | purgeRatio(0.8), mipmap(PerformancesPage::texture2DMipmap()), |
| 135 | compress(PerformancesPage::texture2DCompress()), |
| 136 | minFilt(PerformancesPage::texture2DMinFilter()), |
| 137 | magFilt(PerformancesPage::texture2DMagFilter()), |
| 138 | network(NULL), texChangedEvent(QEvent::registerEventType()), |
| 139 | fileMonitor("tex"), saveCompressed(false) |
| 140 | |
| 141 | { |
| 142 | statTimer.setSingleShot(true); |
| 143 | connect(&statTimer, SIGNAL(timeout()), this, SLOT(doPrintStatistics())); |
| 144 | IFTRACE2(texturecache, layoutevents) |
| 145 | debug() << "ID of 'refresh' user event: " << texChangedEvent << "\n"; |
| 146 | |
| 147 | { |
| 148 | QGLWidget gl; |
| 149 | gl.makeCurrent(); |
| 150 | |
| 151 | GLint *fmt, n = 0; |
| 152 | if (QGLContext::currentContext()->isValid()) |
| 153 | { |
| 154 | glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &n); |
| 155 | fmt = (GLint*)malloc(n * sizeof(GLint)); |
| 156 | glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, fmt); |
| 157 | for (int i = 0; i < n; ++i) |
| 158 | cmpFormats.insert(fmt[i]); |
| 159 | free(fmt); |
| 160 | } |
| 161 | IFTRACE(texturecache) |
| 162 | debug() << "GL implementation supports " << n |
| 163 | << " compressed texture formats\n"; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | |
| 168 | QSharedPointer<TextureCache> TextureCache::instance() |