| OLD | NEW |
| 1 // Copyright (c) 2011 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 "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.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 "base/string_piece.h" | 9 #include "base/string_piece.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 gfx::Image& ResourceBundle::GetImageNamed(int resource_id) { | 111 gfx::Image& ResourceBundle::GetImageNamed(int resource_id) { |
| 112 // Check to see if the image is already in the cache. | 112 // Check to see if the image is already in the cache. |
| 113 { | 113 { |
| 114 base::AutoLock lock_scope(*lock_); | 114 base::AutoLock lock_scope(*lock_); |
| 115 ImageMap::const_iterator found = images_.find(resource_id); | 115 ImageMap::const_iterator found = images_.find(resource_id); |
| 116 if (found != images_.end()) | 116 if (found != images_.end()) |
| 117 return *found->second; | 117 return *found->second; |
| 118 } | 118 } |
| 119 | 119 |
| 120 DCHECK(resources_data_) << "Missing call to SetResourcesDataDLL?"; |
| 120 scoped_ptr<SkBitmap> bitmap(LoadBitmap(resources_data_, resource_id)); | 121 scoped_ptr<SkBitmap> bitmap(LoadBitmap(resources_data_, resource_id)); |
| 121 if (bitmap.get()) { | 122 if (bitmap.get()) { |
| 122 // Check if there's a large version of the image as well. | 123 // Check if there's a large version of the image as well. |
| 123 scoped_ptr<SkBitmap> large_bitmap; | 124 scoped_ptr<SkBitmap> large_bitmap; |
| 124 if (large_icon_resources_data_) | 125 if (large_icon_resources_data_) |
| 125 large_bitmap.reset(LoadBitmap(large_icon_resources_data_, resource_id)); | 126 large_bitmap.reset(LoadBitmap(large_icon_resources_data_, resource_id)); |
| 126 | 127 |
| 127 // The load was successful, so cache the image. | 128 // The load was successful, so cache the image. |
| 128 base::AutoLock lock_scope(*lock_); | 129 base::AutoLock lock_scope(*lock_); |
| 129 | 130 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 295 } |
| 295 | 296 |
| 296 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory( | 297 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory( |
| 297 int resource_id) const { | 298 int resource_id) const { |
| 298 if (!data_pack_.get()) | 299 if (!data_pack_.get()) |
| 299 return NULL; | 300 return NULL; |
| 300 return data_pack_->GetStaticMemory(resource_id); | 301 return data_pack_->GetStaticMemory(resource_id); |
| 301 } | 302 } |
| 302 | 303 |
| 303 } // namespace ui | 304 } // namespace ui |
| OLD | NEW |