Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: ui/base/resource/resource_bundle.cc

Issue 2406763002: In test code, allow any 100% data pack to provide fallbacks. (Closed)
Patch Set: separate loop Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/base/resource/resource_bundle.h ('K') | « ui/base/resource/resource_bundle.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle.cc
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index 899a8a45cb95aaf05737504cde5e9780fdf25afd..54489c1c33fd922e0eef1999e57024528940ca91 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -822,31 +822,30 @@ bool ResourceBundle::LoadBitmap(int resource_id,
SkBitmap* bitmap,
bool* fell_back_to_1x) const {
DCHECK(fell_back_to_1x);
- ResourceHandle* data_handle_100_percent = nullptr;
- for (size_t i = 0; i < data_packs_.size(); ++i) {
- if (data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_NONE &&
- LoadBitmap(*data_packs_[i], resource_id, bitmap, fell_back_to_1x)) {
+ for (const auto& pack : data_packs_) {
+ if (pack->GetScaleFactor() == ui::SCALE_FACTOR_NONE &&
+ LoadBitmap(*pack, resource_id, bitmap, fell_back_to_1x)) {
DCHECK(!*fell_back_to_1x);
*scale_factor = ui::SCALE_FACTOR_NONE;
return true;
}
- if (data_packs_[i]->GetScaleFactor() == ui::SCALE_FACTOR_100P)
- data_handle_100_percent = data_packs_[i];
- if (data_packs_[i]->GetScaleFactor() == *scale_factor &&
- LoadBitmap(*data_packs_[i], resource_id, bitmap, fell_back_to_1x)) {
+ if (pack->GetScaleFactor() == *scale_factor &&
+ LoadBitmap(*pack, resource_id, bitmap, fell_back_to_1x)) {
return true;
}
}
// Unit tests may only have 1x data pack. Allow them to fallback to 1x
// resources.
- if (*scale_factor != ui::SCALE_FACTOR_100P && is_test_resources_ &&
- data_handle_100_percent &&
- LoadBitmap(*data_handle_100_percent, resource_id, bitmap,
- fell_back_to_1x)) {
- *fell_back_to_1x = true;
- return true;
+ if (is_test_resources_ && *scale_factor != ui::SCALE_FACTOR_100P) {
+ for (const auto& pack : data_packs_) {
+ if (pack->GetScaleFactor() == ui::SCALE_FACTOR_100P &&
+ LoadBitmap(*pack, resource_id, bitmap, fell_back_to_1x)) {
+ *fell_back_to_1x = true;
+ return true;
+ }
+ }
}
return false;
« ui/base/resource/resource_bundle.h ('K') | « ui/base/resource/resource_bundle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698