History

Removing access to the gl widget and display managers

Brad Davis committed 11 years ago

Commit 302aa9d1 parent 539063035 files · +401 −440Browse files

Showing the changes to libraries/render-utils/src/TextureCache.cpp (1 of 35 files). Show all

Unified · Split

libraries/render-utils/src/TextureCache.cpp+17−26
@@ -19,6 +19,7 @@ · 18 unmodified lines
19#include <QResizeEvent>19#include <QResizeEvent>
20#include <QRunnable>20#include <QRunnable>
21#include <QThreadPool>21#include <QThreadPool>
22#include <QOpenGLContext>
22 23
23#include <glm/glm.hpp>24#include <glm/glm.hpp>
24#include <glm/gtc/random.hpp>25#include <glm/gtc/random.hpp>
@@ -32,8 +33,7 @@ TextureCache::TextureCache() : · 7 unmodified lines
32 _permutationNormalTexture(0),33 _permutationNormalTexture(0),
33 _whiteTexture(0),34 _whiteTexture(0),
34 _blueTexture(0),35 _blueTexture(0),
35 _frameBufferSize(100, 100),36 _frameBufferSize(100, 100)
36 _associatedWidget(NULL)
37{37{
38 const qint64 TEXTURE_DEFAULT_UNUSED_MAX_SIZE = DEFAULT_UNUSED_MAX_SIZE;38 const qint64 TEXTURE_DEFAULT_UNUSED_MAX_SIZE = DEFAULT_UNUSED_MAX_SIZE;
39 setUnusedResourceCacheSize(TEXTURE_DEFAULT_UNUSED_MAX_SIZE);39 setUnusedResourceCacheSize(TEXTURE_DEFAULT_UNUSED_MAX_SIZE);
@@ -290,22 +290,21 @@ GLuint TextureCache::getShadowDepthTextureID() { · 250 unmodified lines
290 return gpu::GLBackend::getTextureID(_shadowTexture);290 return gpu::GLBackend::getTextureID(_shadowTexture);
291}291}
292 292
293bool TextureCache::eventFilter(QObject* watched, QEvent* event) {293/// Returns a texture version of an image file
294 if (event->type() == QEvent::Resize) {294gpu::TexturePointer TextureCache::getImageTexture(const QString & path) {
295 QSize size = static_cast<QResizeEvent*>(event)->size();295 QImage image(path);
296 if (_frameBufferSize != size) {296 gpu::Element formatGPU = gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB);
297 _primaryFramebuffer.reset();297 gpu::Element formatMip = gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB);
298 _primaryColorTexture.reset();298 if (image.hasAlphaChannel()) {
299 _primaryDepthTexture.reset();299 formatGPU = gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA);
300 _primaryNormalTexture.reset();300 formatMip = gpu::Element(gpu::VEC4, gpu::UINT8, gpu::BGRA);
301 _primarySpecularTexture.reset();301 }
302 302 gpu::TexturePointer texture = gpu::TexturePointer(
303 _secondaryFramebuffer.reset();303 gpu::Texture::create2D(formatGPU, image.width(), image.height(),
304 304 gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
305 _tertiaryFramebuffer.reset();305 texture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits());
306 }306 texture->autoGenerateMips(-1);
307 }307 return texture;
308 return false;
309}308}
310 309
311QSharedPointer<Resource> TextureCache::createResource(const QUrl& url,310QSharedPointer<Resource> TextureCache::createResource(const QUrl& url,
@@ -315,14 +314,6 @@ QSharedPointer<Resource> TextureCache::createResource(const QUrl& url, · 3 unmodified lines
315 &Resource::allReferencesCleared);314 &Resource::allReferencesCleared);
316}315}
317 316
318void TextureCache::associateWithWidget(QGLWidget* widget) {
319 if (_associatedWidget) {
320 _associatedWidget->removeEventFilter(this);
321 }
322 _associatedWidget = widget;
323 _associatedWidget->installEventFilter(this);
324}
325
326Texture::Texture() {317Texture::Texture() {
327}318}
328 319