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

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

Issue 10316019: Aura: Adds custom cursors for drag and drop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch 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 unified diff | Download patch | Annotate | Revision Log
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"
11 #include "ui/gfx/skia_util.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "third_party/skia/include/core/SkUnPreMultiply.h" 13 #include "third_party/skia/include/core/SkUnPreMultiply.h"
13 #include "third_party/skia/include/core/SkColorPriv.h" 14 #include "third_party/skia/include/core/SkColorPriv.h"
14 15
15 extern "C" { 16 extern "C" {
16 #if defined(USE_SYSTEM_LIBPNG) 17 #if defined(USE_SYSTEM_LIBPNG)
17 #include <png.h> 18 #include <png.h>
18 #else 19 #else
19 #include "third_party/libpng/png.h" 20 #include "third_party/libpng/png.h"
20 #endif 21 #endif
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } else { 70 } else {
70 pixel_out[0] = SkGetPackedR32(pixel_in); 71 pixel_out[0] = SkGetPackedR32(pixel_in);
71 pixel_out[1] = SkGetPackedG32(pixel_in); 72 pixel_out[1] = SkGetPackedG32(pixel_in);
72 pixel_out[2] = SkGetPackedB32(pixel_in); 73 pixel_out[2] = SkGetPackedB32(pixel_in);
73 } 74 }
74 } 75 }
75 } 76 }
76 77
77 void ConvertSkiatoRGBA(const unsigned char* skia, int pixel_width, 78 void ConvertSkiatoRGBA(const unsigned char* skia, int pixel_width,
78 unsigned char* rgba, bool* is_opaque) { 79 unsigned char* rgba, bool* is_opaque) {
79 int total_length = pixel_width * 4; 80 gfx::ConvertSkiaToRGBA(skia, pixel_width, rgba);
80 for (int i = 0; i < total_length; i += 4) {
81 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[i]);
82
83 // Pack the components here.
84 int alpha = SkGetPackedA32(pixel_in);
85 if (alpha != 0 && alpha != 255) {
86 SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in);
87 rgba[i + 0] = SkColorGetR(unmultiplied);
88 rgba[i + 1] = SkColorGetG(unmultiplied);
89 rgba[i + 2] = SkColorGetB(unmultiplied);
90 rgba[i + 3] = alpha;
91 } else {
92 rgba[i + 0] = SkGetPackedR32(pixel_in);
93 rgba[i + 1] = SkGetPackedG32(pixel_in);
94 rgba[i + 2] = SkGetPackedB32(pixel_in);
95 rgba[i + 3] = alpha;
96 }
97 }
98 } 81 }
99 82
100 } // namespace 83 } // namespace
101 84
102 // Decoder -------------------------------------------------------------------- 85 // Decoder --------------------------------------------------------------------
103 // 86 //
104 // This code is based on WebKit libpng interface (PNGImageDecoder), which is 87 // This code is based on WebKit libpng interface (PNGImageDecoder), which is
105 // in turn based on the Mozilla png decoder. 88 // in turn based on the Mozilla png decoder.
106 89
107 namespace { 90 namespace {
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 779 }
797 780
798 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) 781 PNGCodec::Comment::Comment(const std::string& k, const std::string& t)
799 : key(k), text(t) { 782 : key(k), text(t) {
800 } 783 }
801 784
802 PNGCodec::Comment::~Comment() { 785 PNGCodec::Comment::~Comment() {
803 } 786 }
804 787
805 } // namespace gfx 788 } // namespace gfx
OLDNEW
« content/test/DEPS ('K') | « 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