Index: ui/base/resource/resource_bundle.cc |
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc |
index 420330af497ae4b21ac944646247dde0cc210868..7b53c132c1d76b2613c71eca7048631e45bfc581 100644 |
--- a/ui/base/resource/resource_bundle.cc |
+++ b/ui/base/resource/resource_bundle.cc |
@@ -109,7 +109,7 @@ class ResourceBundle::ResourceBundleImageSource : public gfx::ImageSkiaSource { |
ui::ScaleFactor scale_factor) OVERRIDE { |
SkBitmap image; |
bool fell_back_to_1x = false; |
- bool found = rb_->LoadBitmap(resource_id_, scale_factor, |
+ bool found = rb_->LoadBitmap(resource_id_, &scale_factor, |
&image, &fell_back_to_1x); |
if (!found) |
return gfx::ImageSkiaRep(); |
@@ -361,14 +361,11 @@ gfx::Image& ResourceBundle::GetImageNamed(int resource_id) { |
DCHECK(!delegate_ && !data_packs_.empty()) << |
"Missing call to SetResourcesDataDLL?"; |
- // TODO(oshima): This should be GetPrimaryDisplay().device_scale_factor(), |
- // but GetPrimaryDisplay() crashes at startup. |
- ScaleFactor primary_scale_factor = SCALE_FACTOR_100P; |
// ResourceBundle::GetSharedInstance() is destroyed after the |
// BrowserMainLoop has finished running. |image_skia| is guaranteed to be |
// destroyed before the resource bundle is destroyed. |
gfx::ImageSkia image_skia(new ResourceBundleImageSource(this, resource_id), |
- primary_scale_factor); |
+ max_scale_factor()); |
if (image_skia.isNull()) { |
LOG(WARNING) << "Unable to load image with id " << resource_id; |
NOTREACHED(); // Want to assert in debug mode. |
@@ -438,7 +435,8 @@ base::StringPiece ResourceBundle::GetRawDataResourceForScale( |
} |
} |
for (size_t i = 0; i < data_packs_.size(); i++) { |
- if (data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_100P && |
+ if ((data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_100P || |
+ data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_NONE) && |
data_packs_[i]->GetStringPiece(resource_id, &data)) |
return data; |
} |
@@ -660,14 +658,23 @@ bool ResourceBundle::LoadBitmap(const ResourceHandle& data_handle, |
} |
bool ResourceBundle::LoadBitmap(int resource_id, |
- ScaleFactor scale_factor, |
+ ScaleFactor* scale_factor, |
SkBitmap* bitmap, |
bool* fell_back_to_1x) const { |
DCHECK(fell_back_to_1x); |
for (size_t i = 0; i < data_packs_.size(); ++i) { |
- if (data_packs_[i]->GetScaleFactor() == scale_factor) { |
- if (LoadBitmap(*data_packs_[i], resource_id, bitmap, fell_back_to_1x)) |
- return true; |
+ // If the resource is in the package with SCALE_FACTOR_NONE, it |
+ // can be used in any scale factor, but set 100P in ImageSkia so |
+ // that it will be scaled property. |
+ if (data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_NONE && |
+ LoadBitmap(*data_packs_[i], resource_id, bitmap, fell_back_to_1x)) { |
+ *scale_factor = ui::SCALE_FACTOR_100P; |
+ DCHECK(!*fell_back_to_1x); |
+ return true; |
+ } |
+ if (data_packs_[i]->GetScaleFactor() == *scale_factor && |
+ LoadBitmap(*data_packs_[i], resource_id, bitmap, fell_back_to_1x)) { |
+ return true; |
} |
} |
return false; |