| 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 "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 base::AutoLock lock_scope(*locale_resources_data_lock_); | 205 base::AutoLock lock_scope(*locale_resources_data_lock_); |
| 206 UnloadLocaleResources(); | 206 UnloadLocaleResources(); |
| 207 return LoadLocaleResources(pref_locale); | 207 return LoadLocaleResources(pref_locale); |
| 208 } | 208 } |
| 209 | 209 |
| 210 SkBitmap* ResourceBundle::GetBitmapNamed(int resource_id) { | 210 SkBitmap* ResourceBundle::GetBitmapNamed(int resource_id) { |
| 211 const SkBitmap* bitmap = GetImageNamed(resource_id).ToSkBitmap(); | 211 const SkBitmap* bitmap = GetImageNamed(resource_id).ToSkBitmap(); |
| 212 return const_cast<SkBitmap*>(bitmap); | 212 return const_cast<SkBitmap*>(bitmap); |
| 213 } | 213 } |
| 214 | 214 |
| 215 gfx::ImageSkia* ResourceBundle::GetImageSkiaNamed(int resource_id) { |
| 216 const gfx::ImageSkia* image = GetImageNamed(resource_id).ToImageSkia(); |
| 217 return const_cast<gfx::ImageSkia*>(image); |
| 218 } |
| 219 |
| 215 gfx::Image& ResourceBundle::GetImageNamed(int resource_id) { | 220 gfx::Image& ResourceBundle::GetImageNamed(int resource_id) { |
| 216 // Check to see if the image is already in the cache. | 221 // Check to see if the image is already in the cache. |
| 217 { | 222 { |
| 218 base::AutoLock lock_scope(*images_and_fonts_lock_); | 223 base::AutoLock lock_scope(*images_and_fonts_lock_); |
| 219 if (images_.count(resource_id)) | 224 if (images_.count(resource_id)) |
| 220 return images_[resource_id]; | 225 return images_[resource_id]; |
| 221 } | 226 } |
| 222 | 227 |
| 223 gfx::Image image; | 228 gfx::Image image; |
| 224 if (delegate_) | 229 if (delegate_) |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 SkBitmap* bitmap = new SkBitmap(); | 470 SkBitmap* bitmap = new SkBitmap(); |
| 466 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 32, 32); | 471 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 32, 32); |
| 467 bitmap->allocPixels(); | 472 bitmap->allocPixels(); |
| 468 bitmap->eraseARGB(255, 255, 0, 0); | 473 bitmap->eraseARGB(255, 255, 0, 0); |
| 469 empty_image_ = gfx::Image(bitmap); | 474 empty_image_ = gfx::Image(bitmap); |
| 470 } | 475 } |
| 471 return empty_image_; | 476 return empty_image_; |
| 472 } | 477 } |
| 473 | 478 |
| 474 } // namespace ui | 479 } // namespace ui |
| OLD | NEW |