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

Side by Side Diff: ui/gfx/codec/png_codec.cc

Issue 10831031: Fix the PNCodec error on Android caused by different Skia color format. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/codec/png_codec.h" 5 #include "ui/gfx/codec/png_codec.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "ui/gfx/size.h" 10 #include "ui/gfx/size.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 void ConvertSkiatoRGB(const unsigned char* skia, int pixel_width, 58 void ConvertSkiatoRGB(const unsigned char* skia, int pixel_width,
59 unsigned char* rgb, bool* is_opaque) { 59 unsigned char* rgb, bool* is_opaque) {
60 for (int x = 0; x < pixel_width; x++) { 60 for (int x = 0; x < pixel_width; x++) {
61 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[x * 4]); 61 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[x * 4]);
62 unsigned char* pixel_out = &rgb[x * 3]; 62 unsigned char* pixel_out = &rgb[x * 3];
63 63
64 int alpha = SkGetPackedA32(pixel_in); 64 int alpha = SkGetPackedA32(pixel_in);
65 if (alpha != 0 && alpha != 255) { 65 if (alpha != 0 && alpha != 255) {
66 SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in); 66 SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in);
67 pixel_out[0] = SkColorGetR(unmultiplied); 67 pixel_out[0] = SkGetPackedR32(unmultiplied);
68 pixel_out[1] = SkColorGetG(unmultiplied); 68 pixel_out[1] = SkGetPackedG32(unmultiplied);
69 pixel_out[2] = SkColorGetB(unmultiplied); 69 pixel_out[2] = SkGetPackedB32(unmultiplied);
tony 2012/07/26 17:38:21 Since the else block does the same as this, I woul
70 } else { 70 } else {
71 pixel_out[0] = SkGetPackedR32(pixel_in); 71 pixel_out[0] = SkGetPackedR32(pixel_in);
72 pixel_out[1] = SkGetPackedG32(pixel_in); 72 pixel_out[1] = SkGetPackedG32(pixel_in);
73 pixel_out[2] = SkGetPackedB32(pixel_in); 73 pixel_out[2] = SkGetPackedB32(pixel_in);
74 } 74 }
75 } 75 }
76 } 76 }
77 77
78 void ConvertSkiatoRGBA(const unsigned char* skia, int pixel_width, 78 void ConvertSkiatoRGBA(const unsigned char* skia, int pixel_width,
79 unsigned char* rgba, bool* is_opaque) { 79 unsigned char* rgba, bool* is_opaque) {
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 } 783 }
784 784
785 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) 785 PNGCodec::Comment::Comment(const std::string& k, const std::string& t)
786 : key(k), text(t) { 786 : key(k), text(t) {
787 } 787 }
788 788
789 PNGCodec::Comment::~Comment() { 789 PNGCodec::Comment::~Comment() {
790 } 790 }
791 791
792 } // namespace gfx 792 } // namespace gfx
OLDNEW
« 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