| 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/icon_loader.h" | 5 #include "chrome/browser/icon_loader.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/memory/ref_counted_memory.h" | 13 #include "base/memory/ref_counted_memory.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "chrome/browser/icon_loader.h" | 15 #include "chrome/browser/icon_loader.h" |
| 16 #include "grit/component_extension_resources.h" | 16 #include "grit/component_extension_resources.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 #include "ui/base/layout.h" | 18 #include "ui/base/layout.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/codec/png_codec.h" | 21 #include "ui/gfx/codec/png_codec.h" |
| 22 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| 23 #include "ui/gfx/image/image_skia.h" |
| 23 #include "ui/gfx/image/image_skia_operations.h" | 24 #include "ui/gfx/image/image_skia_operations.h" |
| 24 #include "webkit/glue/image_decoder.h" | 25 #include "webkit/glue/image_decoder.h" |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // Used with GenerateImageWithSize() to indicate that the image shouldn't be | 29 // Used with GenerateImageWithSize() to indicate that the image shouldn't be |
| 29 // resized. | 30 // resized. |
| 30 const int kDoNotResize = -1; | 31 const int kDoNotResize = -1; |
| 31 | 32 |
| 32 struct IdrBySize { | 33 struct IdrBySize { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 | 177 |
| 177 } // namespace | 178 } // namespace |
| 178 | 179 |
| 179 void IconLoader::ReadIcon() { | 180 void IconLoader::ReadIcon() { |
| 180 static base::LazyInstance<IconMapper>::Leaky icon_mapper = | 181 static base::LazyInstance<IconMapper>::Leaky icon_mapper = |
| 181 LAZY_INSTANCE_INITIALIZER; | 182 LAZY_INSTANCE_INITIALIZER; |
| 182 int idr = icon_mapper.Get().Lookup(group_, icon_size_); | 183 int idr = icon_mapper.Get().Lookup(group_, icon_size_); |
| 183 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 184 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 184 const gfx::ImageSkia* image_skia = rb.GetImageNamed(idr).ToImageSkia(); | 185 gfx::ImageSkia image_skia(ResizeImage(*(rb.GetImageNamed(idr)).ToImageSkia(), |
| 185 image_.reset(new gfx::Image( | 186 IconSizeToDIPSize(icon_size_))); |
| 186 ResizeImage(*image_skia, IconSizeToDIPSize(icon_size_)))); | 187 image_skia.MakeThreadSafe(); |
| 188 image_.reset(new gfx::Image(image_skia)); |
| 187 target_message_loop_->PostTask( | 189 target_message_loop_->PostTask( |
| 188 FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this)); | 190 FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this)); |
| 189 } | 191 } |
| OLD | NEW |