Showing the changes to interface/src/renderer/TextureCache.cpp (1 of 6 files). Show all
Unified · Split
| @@ -257,7 +257,6 @@ Texture::~Texture() { · 256 unmodified lines | ||
| 257 | 257 | |
| 258 | 258 | NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap) : |
| 259 | 259 | Resource(url), |
| 260 | − _averageColor(1.0f, 1.0f, 1.0f, 1.0f), | |
| 261 | 260 | _translucent(false) { |
| 262 | 261 | |
| 263 | 262 | if (!url.isValid()) { |
| @@ -300,27 +299,20 @@ void ImageReader::run() { · 36 unmodified lines | ||
| 300 | 299 | image = image.convertToFormat(QImage::Format_ARGB32); |
| 301 | 300 | } |
| 302 | 301 | |
| 303 | − // sum up the colors for the average and check for translucency | |
| 304 | − glm::vec4 accumulated; | |
| 302 | + // check for translucency | |
| 305 | 303 | int translucentPixels = 0; |
| 306 | 304 | const int EIGHT_BIT_MAXIMUM = 255; |
| 305 | + const int RGB_BITS = 24; | |
| 307 | 306 | for (int y = 0; y < image.height(); y++) { |
| 308 | 307 | for (int x = 0; x < image.width(); x++) { |
| 309 | − QRgb pixel = image.pixel(x, y); | |
| 310 | − accumulated.r += qRed(pixel); | |
| 311 | − accumulated.g += qGreen(pixel); | |
| 312 | − accumulated.b += qBlue(pixel); | |
| 313 | − | |
| 314 | − int alpha = qAlpha(pixel); | |
| 308 | + int alpha = image.pixel(x, y) >> RGB_BITS; | |
| 315 | 309 | if (alpha != 0 && alpha != EIGHT_BIT_MAXIMUM) { |
| 316 | 310 | translucentPixels++; |
| 317 | 311 | } |
| 318 | − accumulated.a += alpha; | |
| 319 | 312 | } |
| 320 | 313 | } |
| 321 | 314 | int imageArea = image.width() * image.height(); |
| 322 | 315 | QMetaObject::invokeMethod(texture.data(), "setImage", Q_ARG(const QImage&, image), |
| 323 | − Q_ARG(const glm::vec4&, accumulated / (float) (imageArea * EIGHT_BIT_MAXIMUM)), | |
| 324 | 316 | Q_ARG(bool, translucentPixels >= imageArea / 2)); |
| 325 | 317 | _reply->deleteLater(); |
| 326 | 318 | } |
| @@ -330,8 +322,7 @@ void NetworkTexture::downloadFinished(QNetworkReply* reply) { · 3 unmodified lines | ||
| 330 | 322 | QThreadPool::globalInstance()->start(new ImageReader(_self, reply)); |
| 331 | 323 | } |
| 332 | 324 | |
| 333 | −void NetworkTexture::setImage(const QImage& image, const glm::vec4& averageColor, bool translucent) { | |
| 334 | − _averageColor = averageColor; | |
| 325 | +void NetworkTexture::setImage(const QImage& image, bool translucent) { | |
| 335 | 326 | _translucent = translucent; |
| 336 | 327 | |
| 337 | 328 | finishedLoading(true); |