OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/webui/extension_icon_source.h" | 5 #include "chrome/browser/ui/webui/extension_icon_source.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "skia/ext/image_operations.h" | 24 #include "skia/ext/image_operations.h" |
25 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/gfx/codec/png_codec.h" | 26 #include "ui/gfx/codec/png_codec.h" |
27 #include "ui/gfx/color_utils.h" | 27 #include "ui/gfx/color_utils.h" |
28 #include "ui/gfx/skbitmap_operations.h" | 28 #include "ui/gfx/skbitmap_operations.h" |
29 #include "webkit/glue/image_decoder.h" | 29 #include "webkit/glue/image_decoder.h" |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 scoped_refptr<RefCountedMemory> BitmapToMemory(SkBitmap* image) { | 33 scoped_refptr<RefCountedMemory> BitmapToMemory(SkBitmap* image) { |
34 std::vector<unsigned char> output; | 34 RefCountedBytes* image_bytes = new RefCountedBytes; |
35 gfx::PNGCodec::EncodeBGRASkBitmap(*image, false, &output); | 35 gfx::PNGCodec::EncodeBGRASkBitmap(*image, false, &image_bytes->data()); |
36 | |
37 scoped_refptr<RefCountedBytes> image_bytes(new RefCountedBytes); | |
38 image_bytes->data.resize(output.size()); | |
39 std::copy(output.begin(), output.end(), image_bytes->data.begin()); | |
40 return image_bytes; | 36 return image_bytes; |
41 } | 37 } |
42 | 38 |
43 void DesaturateImage(SkBitmap* image) { | 39 void DesaturateImage(SkBitmap* image) { |
44 color_utils::HSL shift = {-1, 0, 0.6}; | 40 color_utils::HSL shift = {-1, 0, 0.6}; |
45 *image = SkBitmapOperations::CreateHSLShiftedBitmap(*image, shift); | 41 *image = SkBitmapOperations::CreateHSLShiftedBitmap(*image, shift); |
46 } | 42 } |
47 | 43 |
48 SkBitmap* ToBitmap(const unsigned char* data, size_t size) { | 44 SkBitmap* ToBitmap(const unsigned char* data, size_t size) { |
49 webkit_glue::ImageDecoder decoder; | 45 webkit_glue::ImageDecoder decoder; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 317 |
322 void ExtensionIconSource::ClearData(int request_id) { | 318 void ExtensionIconSource::ClearData(int request_id) { |
323 std::map<int, ExtensionIconRequest*>::iterator i = | 319 std::map<int, ExtensionIconRequest*>::iterator i = |
324 request_map_.find(request_id); | 320 request_map_.find(request_id); |
325 if (i == request_map_.end()) | 321 if (i == request_map_.end()) |
326 return; | 322 return; |
327 | 323 |
328 delete i->second; | 324 delete i->second; |
329 request_map_.erase(i); | 325 request_map_.erase(i); |
330 } | 326 } |
OLD | NEW |