| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 | 103 |
| 104 gfx::Image image; | 104 gfx::Image image; |
| 105 if (delegate_) | 105 if (delegate_) |
| 106 image = delegate_->GetNativeImageNamed(resource_id, rtl); | 106 image = delegate_->GetNativeImageNamed(resource_id, rtl); |
| 107 | 107 |
| 108 if (image.IsEmpty()) { | 108 if (image.IsEmpty()) { |
| 109 // Load the raw data from the resource pack at the current supported scale | 109 // Load the raw data from the resource pack at the current supported scale |
| 110 // factor. This code assumes that only one of the possible scale factors is | 110 // factor. This code assumes that only one of the possible scale factors is |
| 111 // supported at runtime, based on the device resolution. | 111 // supported at runtime, based on the device resolution. |
| 112 ui::ScaleFactor scale_factor = ui::GetMaxScaleFactor(); | 112 ui::ScaleFactor scale_factor = ui::GetMaxSupportedScaleFactor(); |
| 113 | 113 |
| 114 scoped_refptr<base::RefCountedStaticMemory> data( | 114 scoped_refptr<base::RefCountedStaticMemory> data( |
| 115 LoadDataResourceBytesForScale(resource_id, scale_factor)); | 115 LoadDataResourceBytesForScale(resource_id, scale_factor)); |
| 116 | 116 |
| 117 if (!data.get()) { | 117 if (!data.get()) { |
| 118 LOG(WARNING) << "Unable to load image with id " << resource_id; | 118 LOG(WARNING) << "Unable to load image with id " << resource_id; |
| 119 return GetEmptyImage(); | 119 return GetEmptyImage(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 // Create a data object from the raw bytes. | 122 // Create a data object from the raw bytes. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 // Another thread raced the load and has already cached the image. | 181 // Another thread raced the load and has already cached the image. |
| 182 if (images_.count(resource_id)) | 182 if (images_.count(resource_id)) |
| 183 return images_[resource_id]; | 183 return images_[resource_id]; |
| 184 | 184 |
| 185 images_[resource_id] = image; | 185 images_[resource_id] = image; |
| 186 return images_[resource_id]; | 186 return images_[resource_id]; |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace ui | 189 } // namespace ui |
| OLD | NEW |