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()), false)); | 30 source.height() + padding.height()), |
| 31 ui::SCALE_FACTOR_100P, |
| 32 false)); |
31 result->DrawImageInt( | 33 result->DrawImageInt( |
32 source, | 34 source, |
33 0, 0, source.width(), source.height(), | 35 0, 0, source.width(), source.height(), |
34 padding.left(), padding.top(), source.width(), source.height(), | 36 padding.left(), padding.top(), source.width(), source.height(), |
35 false); | 37 false); |
36 return result->ExtractBitmap(); | 38 return result->ExtractImageRep().sk_bitmap(); |
37 } | 39 } |
38 | 40 |
39 } // namespace | 41 } // namespace |
40 | 42 |
41 ExtensionIconManager::ExtensionIconManager() | 43 ExtensionIconManager::ExtensionIconManager() |
42 : ALLOW_THIS_IN_INITIALIZER_LIST(image_tracker_(this)), | 44 : ALLOW_THIS_IN_INITIALIZER_LIST(image_tracker_(this)), |
43 monochrome_(false) { | 45 monochrome_(false) { |
44 } | 46 } |
45 | 47 |
46 ExtensionIconManager::~ExtensionIconManager() { | 48 ExtensionIconManager::~ExtensionIconManager() { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if (monochrome_) { | 117 if (monochrome_) { |
116 color_utils::HSL shift = {-1, 0, 0.6}; | 118 color_utils::HSL shift = {-1, 0, 0.6}; |
117 result = SkBitmapOperations::CreateHSLShiftedBitmap(result, shift); | 119 result = SkBitmapOperations::CreateHSLShiftedBitmap(result, shift); |
118 } | 120 } |
119 | 121 |
120 if (!padding_.empty()) | 122 if (!padding_.empty()) |
121 result = ApplyPadding(result, padding_); | 123 result = ApplyPadding(result, padding_); |
122 | 124 |
123 return result; | 125 return result; |
124 } | 126 } |
OLD | NEW |