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 "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 if (images_.count(key)) | 82 if (images_.count(key)) |
83 return images_[key]; | 83 return images_[key]; |
84 } | 84 } |
85 | 85 |
86 gfx::Image image; | 86 gfx::Image image; |
87 if (delegate_) | 87 if (delegate_) |
88 image = delegate_->GetNativeImageNamed(resource_id, rtl); | 88 image = delegate_->GetNativeImageNamed(resource_id, rtl); |
89 | 89 |
90 if (image.IsEmpty()) { | 90 if (image.IsEmpty()) { |
91 scoped_refptr<base::RefCountedStaticMemory> data( | 91 scoped_refptr<base::RefCountedStaticMemory> data( |
92 LoadDataResourceBytes(resource_id)); | 92 LoadDataResourceBytes(resource_id, ResourceHandle::kScaleFactor100x)); |
93 GdkPixbuf* pixbuf = LoadPixbuf(data.get(), rtl == RTL_ENABLED); | 93 GdkPixbuf* pixbuf = LoadPixbuf(data.get(), rtl == RTL_ENABLED); |
94 | 94 |
95 if (!pixbuf) { | 95 if (!pixbuf) { |
96 LOG(WARNING) << "Unable to load pixbuf with id " << resource_id; | 96 LOG(WARNING) << "Unable to load pixbuf with id " << resource_id; |
97 NOTREACHED(); // Want to assert in debug mode. | 97 NOTREACHED(); // Want to assert in debug mode. |
98 return GetEmptyImage(); | 98 return GetEmptyImage(); |
99 } | 99 } |
100 | 100 |
101 image = gfx::Image(pixbuf); // Takes ownership. | 101 image = gfx::Image(pixbuf); // Takes ownership. |
102 } | 102 } |
103 | 103 |
104 base::AutoLock lock_scope(*images_and_fonts_lock_); | 104 base::AutoLock lock_scope(*images_and_fonts_lock_); |
105 | 105 |
106 // Another thread raced the load and has already cached the image. | 106 // Another thread raced the load and has already cached the image. |
107 if (images_.count(key)) | 107 if (images_.count(key)) |
108 return images_[key]; | 108 return images_[key]; |
109 | 109 |
110 images_[key] = image; | 110 images_[key] = image; |
111 return images_[key]; | 111 return images_[key]; |
112 } | 112 } |
113 | 113 |
114 } // namespace ui | 114 } // namespace ui |
OLD | NEW |