From 07fe43e1752afec7878db5a6a0e63b795ed09a6c Mon Sep 17 00:00:00 2001 From: Sam Cake Date: Fri, 15 May 2015 15:26:40 -0700 Subject: [PATCH] moving forward with the void* hack for gpu::Texture --- libraries/render-utils/src/TextureCache.cpp | 10 +++++----- libraries/render-utils/src/TextureCache.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/libraries/render-utils/src/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp index 1de8493dc6..c1817169c9 100644 --- a/libraries/render-utils/src/TextureCache.cpp +++ b/libraries/render-utils/src/TextureCache.cpp @@ -484,6 +484,7 @@ void ImageReader::run() { int opaquePixels = 0; int translucentPixels = 0; + bool isTransparent = false; int redTotal = 0, greenTotal = 0, blueTotal = 0, alphaTotal = 0; const int EIGHT_BIT_MAXIMUM = 255; QColor averageColor(EIGHT_BIT_MAXIMUM, EIGHT_BIT_MAXIMUM, EIGHT_BIT_MAXIMUM); @@ -535,6 +536,8 @@ void ImageReader::run() { averageColor = QColor(redTotal / imageArea, greenTotal / imageArea, blueTotal / imageArea, alphaTotal / imageArea); + + isTransparent = (translucentPixels >= imageArea / 2); } gpu::Texture* theTexture = nullptr; @@ -703,14 +706,11 @@ void ImageReader::run() { QMetaObject::invokeMethod(texture.data(), "setImage", Q_ARG(const QImage&, image), Q_ARG(void*, theTexture), - Q_ARG(bool, translucentPixels >= imageArea / 2), Q_ARG(const QColor&, averageColor), + Q_ARG(bool, isTransparent), + Q_ARG(const QColor&, averageColor), Q_ARG(int, originalWidth), Q_ARG(int, originalHeight)); -/* QMetaObject::invokeMethod(texture.data(), "setImage", Q_ARG(const QImage&, image), Q_ARG(bool, false), - Q_ARG(const QColor&, averageColor), Q_ARG(int, originalWidth), Q_ARG(int, originalHeight)); - return; -*/ } void NetworkTexture::setImage(const QImage& image, void* voidTexture, bool translucent, const QColor& averageColor, int originalWidth, diff --git a/libraries/render-utils/src/TextureCache.h b/libraries/render-utils/src/TextureCache.h index 6779a2c988..381359ef80 100644 --- a/libraries/render-utils/src/TextureCache.h +++ b/libraries/render-utils/src/TextureCache.h @@ -149,8 +149,6 @@ private: /// A texture loaded from the network. -Q_DECLARE_METATYPE(gpu::Texture); - class NetworkTexture : public Resource, public Texture { Q_OBJECT @@ -175,6 +173,7 @@ protected: virtual void downloadFinished(QNetworkReply* reply); Q_INVOKABLE void loadContent(const QByteArray& content); + // FIXME: This void* should be a gpu::Texture* but i cannot get it to work for now, moving on... Q_INVOKABLE void setImage(const QImage& image, void* texture, bool translucent, const QColor& averageColor, int originalWidth, int originalHeight);