History

Get rid of unused, expensive "average color" nonsense.

Andrzej Kapolka committed 12 years ago

Commit bc3bba91 parent 35d0fa76 files · +5 −52Browse files

Showing the changes to interface/src/renderer/TextureCache.cpp (1 of 6 files). Show all

Unified · Split

interface/src/renderer/TextureCache.cpp+4−13
@@ -257,7 +257,6 @@ Texture::~Texture() { · 256 unmodified lines
257257
258258 NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap) :
259259 Resource(url),
260− _averageColor(1.0f, 1.0f, 1.0f, 1.0f),
261260 _translucent(false) {
262261
263262 if (!url.isValid()) {
@@ -300,27 +299,20 @@ void ImageReader::run() { · 36 unmodified lines
300299 image = image.convertToFormat(QImage::Format_ARGB32);
301300 }
302301
303− // sum up the colors for the average and check for translucency
304− glm::vec4 accumulated;
302+ // check for translucency
305303 int translucentPixels = 0;
306304 const int EIGHT_BIT_MAXIMUM = 255;
305+ const int RGB_BITS = 24;
307306 for (int y = 0; y < image.height(); y++) {
308307 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;
315309 if (alpha != 0 && alpha != EIGHT_BIT_MAXIMUM) {
316310 translucentPixels++;
317311 }
318− accumulated.a += alpha;
319312 }
320313 }
321314 int imageArea = image.width() * image.height();
322315 QMetaObject::invokeMethod(texture.data(), "setImage", Q_ARG(const QImage&, image),
323− Q_ARG(const glm::vec4&, accumulated / (float) (imageArea * EIGHT_BIT_MAXIMUM)),
324316 Q_ARG(bool, translucentPixels >= imageArea / 2));
325317 _reply->deleteLater();
326318 }
@@ -330,8 +322,7 @@ void NetworkTexture::downloadFinished(QNetworkReply* reply) { · 3 unmodified lines
330322 QThreadPool::globalInstance()->start(new ImageReader(_self, reply));
331323 }
332324
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) {
335326 _translucent = translucent;
336327
337328 finishedLoading(true);