OLD | NEW |
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 "chrome/browser/extensions/extension_icon_manager.h" | 5 #include "chrome/browser/extensions/extension_icon_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/common/extensions/extension_icon_set.h" | 10 #include "chrome/common/extensions/extension_icon_set.h" |
11 #include "chrome/common/extensions/extension_resource.h" | 11 #include "chrome/common/extensions/extension_resource.h" |
12 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
13 #include "skia/ext/image_operations.h" | 13 #include "skia/ext/image_operations.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
16 #include "ui/gfx/color_utils.h" | 16 #include "ui/gfx/color_utils.h" |
17 #include "ui/gfx/favicon_size.h" | 17 #include "ui/gfx/favicon_size.h" |
18 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
19 #include "ui/gfx/size.h" | 19 #include "ui/gfx/size.h" |
20 #include "ui/gfx/skbitmap_operations.h" | 20 #include "ui/gfx/skbitmap_operations.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // Helper function to create a new bitmap with |padding| amount of empty space | 24 // Helper function to create a new bitmap with |padding| amount of empty space |
25 // around the original bitmap. | 25 // around the original bitmap. |
26 static SkBitmap ApplyPadding(const SkBitmap& source, | 26 static SkBitmap ApplyPadding(const SkBitmap& source, |
27 const gfx::Insets& padding) { | 27 const gfx::Insets& padding) { |
28 scoped_ptr<gfx::Canvas> result( | 28 scoped_ptr<gfx::Canvas> result( |
29 new gfx::Canvas(gfx::Size(source.width() + padding.width(), | 29 new gfx::Canvas(gfx::Size(source.width() + padding.width(), |
30 source.height() + padding.height()), | 30 source.height() + padding.height()), false)); |
31 ui::SCALE_FACTOR_100P, | |
32 false)); | |
33 result->DrawImageInt( | 31 result->DrawImageInt( |
34 source, | 32 source, |
35 0, 0, source.width(), source.height(), | 33 0, 0, source.width(), source.height(), |
36 padding.left(), padding.top(), source.width(), source.height(), | 34 padding.left(), padding.top(), source.width(), source.height(), |
37 false); | 35 false); |
38 return result->ExtractImageRep().sk_bitmap(); | 36 return result->ExtractBitmap(); |
39 } | 37 } |
40 | 38 |
41 } // namespace | 39 } // namespace |
42 | 40 |
43 ExtensionIconManager::ExtensionIconManager() | 41 ExtensionIconManager::ExtensionIconManager() |
44 : ALLOW_THIS_IN_INITIALIZER_LIST(image_tracker_(this)), | 42 : ALLOW_THIS_IN_INITIALIZER_LIST(image_tracker_(this)), |
45 monochrome_(false) { | 43 monochrome_(false) { |
46 } | 44 } |
47 | 45 |
48 ExtensionIconManager::~ExtensionIconManager() { | 46 ExtensionIconManager::~ExtensionIconManager() { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if (monochrome_) { | 115 if (monochrome_) { |
118 color_utils::HSL shift = {-1, 0, 0.6}; | 116 color_utils::HSL shift = {-1, 0, 0.6}; |
119 result = SkBitmapOperations::CreateHSLShiftedBitmap(result, shift); | 117 result = SkBitmapOperations::CreateHSLShiftedBitmap(result, shift); |
120 } | 118 } |
121 | 119 |
122 if (!padding_.empty()) | 120 if (!padding_.empty()) |
123 result = ApplyPadding(result, padding_); | 121 result = ApplyPadding(result, padding_); |
124 | 122 |
125 return result; | 123 return result; |
126 } | 124 } |
OLD | NEW |