Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: ui/gfx/color_analysis.cc

Issue 1141503003: Revert color analysis optimization which breaks on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_analysis.cc
diff --git a/ui/gfx/color_analysis.cc b/ui/gfx/color_analysis.cc
index 354ca84bdabee492c8309c3d7262b2e718985eed..16695c9a0b9c997214fab6bb47a2329d7a40ea54 100644
--- a/ui/gfx/color_analysis.cc
+++ b/ui/gfx/color_analysis.cc
@@ -11,7 +11,6 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkUnPreMultiply.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/color_utils.h"
@@ -130,19 +129,15 @@ class KMeanCluster {
uint32_t weight_;
};
-// Un-premultiplies each pixel in |bitmap| into an output |buffer|.
+// Un-premultiplies each pixel in |bitmap| into an output |buffer|. Requires
+// approximately 10 microseconds for a 16x16 icon on an Intel Core i5.
void UnPreMultiply(const SkBitmap& bitmap, uint32_t* buffer, int buffer_size) {
SkAutoLockPixels auto_lock(bitmap);
uint32_t* in = static_cast<uint32_t*>(bitmap.getPixels());
uint32_t* out = buffer;
int pixel_count = std::min(bitmap.width() * bitmap.height(), buffer_size);
- for (int i = 0; i < pixel_count; ++i) {
- int alpha = SkGetPackedA32(*in);
- if (alpha != 0 && alpha != 255)
- *out++ = SkUnPreMultiply::PMColorToColor(*in++);
- else
- *out++ = *in++;
- }
+ for (int i = 0; i < pixel_count; ++i)
+ *out++ = SkUnPreMultiply::PMColorToColor(*in++);
}
} // namespace
@@ -439,13 +434,7 @@ gfx::Matrix3F ComputeColorCovariance(const SkBitmap& bitmap) {
for (int y = 0; y < bitmap.height(); ++y) {
SkPMColor* current_color = static_cast<uint32_t*>(bitmap.getAddr32(0, y));
for (int x = 0; x < bitmap.width(); ++x, ++current_color) {
- SkColor c;
- int alpha = SkGetPackedA32(*current_color);
- if (alpha != 0 && alpha != 255)
- c = SkUnPreMultiply::PMColorToColor(*current_color);
- else
- c = *current_color;
-
+ SkColor c = SkUnPreMultiply::PMColorToColor(*current_color);
SkColor r = SkColorGetR(c);
SkColor g = SkColorGetG(c);
SkColor b = SkColorGetB(c);
@@ -531,13 +520,7 @@ bool ApplyColorReduction(const SkBitmap& source_bitmap,
const SkPMColor* source_color_row = static_cast<SkPMColor*>(
source_bitmap.getAddr32(0, y));
for (int x = 0; x < source_bitmap.width(); ++x) {
- SkColor c;
- int alpha = SkGetPackedA32(source_color_row[x]);
- if (alpha != 0 && alpha != 255)
- c = SkUnPreMultiply::PMColorToColor(source_color_row[x]);
- else
- c = source_color_row[x];
-
+ SkColor c = SkUnPreMultiply::PMColorToColor(source_color_row[x]);
uint8_t r = SkColorGetR(c);
uint8_t g = SkColorGetG(c);
uint8_t b = SkColorGetB(c);
@@ -563,13 +546,7 @@ bool ApplyColorReduction(const SkBitmap& source_bitmap,
source_bitmap.getAddr32(0, y));
uint8_t* target_color_row = target_bitmap->getAddr8(0, y);
for (int x = 0; x < source_bitmap.width(); ++x) {
- SkColor c;
- int alpha = SkGetPackedA32(source_color_row[x]);
- if (alpha != 0 && alpha != 255)
- c = SkUnPreMultiply::PMColorToColor(source_color_row[x]);
- else
- c = source_color_row[x];
-
+ SkColor c = SkUnPreMultiply::PMColorToColor(source_color_row[x]);
uint8_t r = SkColorGetR(c);
uint8_t g = SkColorGetG(c);
uint8_t b = SkColorGetB(c);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698