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

Unified Diff: ui/gfx/codec/png_codec.cc

Issue 10386020: Revert r135533. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | « ui/base/x/x11_util.cc ('k') | ui/gfx/skia_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/codec/png_codec.cc
diff --git a/ui/gfx/codec/png_codec.cc b/ui/gfx/codec/png_codec.cc
index da73928384aefed3a54abce0c64ef6543748afe2..1ca139d1ceaf3163cda2432687ccd2470ba6d0a9 100644
--- a/ui/gfx/codec/png_codec.cc
+++ b/ui/gfx/codec/png_codec.cc
@@ -8,7 +8,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/string_util.h"
#include "ui/gfx/size.h"
-#include "ui/gfx/skia_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkUnPreMultiply.h"
#include "third_party/skia/include/core/SkColorPriv.h"
@@ -77,7 +76,25 @@ void ConvertSkiatoRGB(const unsigned char* skia, int pixel_width,
void ConvertSkiatoRGBA(const unsigned char* skia, int pixel_width,
unsigned char* rgba, bool* is_opaque) {
- gfx::ConvertSkiaToRGBA(skia, pixel_width, rgba);
+ int total_length = pixel_width * 4;
+ for (int i = 0; i < total_length; i += 4) {
+ const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[i]);
+
+ // Pack the components here.
+ int alpha = SkGetPackedA32(pixel_in);
+ if (alpha != 0 && alpha != 255) {
+ SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in);
+ rgba[i + 0] = SkColorGetR(unmultiplied);
+ rgba[i + 1] = SkColorGetG(unmultiplied);
+ rgba[i + 2] = SkColorGetB(unmultiplied);
+ rgba[i + 3] = alpha;
+ } else {
+ rgba[i + 0] = SkGetPackedR32(pixel_in);
+ rgba[i + 1] = SkGetPackedG32(pixel_in);
+ rgba[i + 2] = SkGetPackedB32(pixel_in);
+ rgba[i + 3] = alpha;
+ }
+ }
}
} // namespace
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/gfx/skia_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698