| OLD | NEW |
| 1 // Copyright (c) 2010 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/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-inl.h" | 8 #include "base/stl_util-inl.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_skia.h" | 15 #include "ui/gfx/canvas_skia.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/size.h" | 18 #include "ui/gfx/size.h" |
| 19 #include "ui/gfx/skbitmap_operations.h" | 19 #include "ui/gfx/skbitmap_operations.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Helper function to create a new bitmap with |padding| amount of empty space | 23 // Helper function to create a new bitmap with |padding| amount of empty space |
| 24 // around the original bitmap. | 24 // around the original bitmap. |
| 25 static SkBitmap ApplyPadding(const SkBitmap& source, | 25 static SkBitmap ApplyPadding(const SkBitmap& source, |
| 26 const gfx::Insets& padding) { | 26 const gfx::Insets& padding) { |
| 27 scoped_ptr<gfx::CanvasSkia> result( | 27 scoped_ptr<gfx::CanvasSkia> result(new gfx::CanvasSkia); |
| 28 new gfx::CanvasSkia(source.width() + padding.width(), | 28 result->Init(source.width() + padding.width(), |
| 29 source.height() + padding.height(), false)); | 29 source.height() + padding.height(), |
| 30 false); |
| 30 result->DrawBitmapInt( | 31 result->DrawBitmapInt( |
| 31 source, | 32 source, |
| 32 0, 0, source.width(), source.height(), | 33 0, 0, source.width(), source.height(), |
| 33 padding.left(), padding.top(), source.width(), source.height(), | 34 padding.left(), padding.top(), source.width(), source.height(), |
| 34 false); | 35 false); |
| 35 return result->ExtractBitmap(); | 36 return result->ExtractBitmap(); |
| 36 } | 37 } |
| 37 | 38 |
| 38 } // namespace | 39 } // namespace |
| 39 | 40 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 if (monochrome_) { | 116 if (monochrome_) { |
| 116 color_utils::HSL shift = {-1, 0, 0.6}; | 117 color_utils::HSL shift = {-1, 0, 0.6}; |
| 117 result = SkBitmapOperations::CreateHSLShiftedBitmap(result, shift); | 118 result = SkBitmapOperations::CreateHSLShiftedBitmap(result, shift); |
| 118 } | 119 } |
| 119 | 120 |
| 120 if (!padding_.empty()) | 121 if (!padding_.empty()) |
| 121 result = ApplyPadding(result, padding_); | 122 result = ApplyPadding(result, padding_); |
| 122 | 123 |
| 123 return result; | 124 return result; |
| 124 } | 125 } |
| OLD | NEW |