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

Unified Diff: ui/base/resource/resource_bundle_ios.mm

Issue 574663003: Enables 300P support for iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review. Created 6 years, 3 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
Index: ui/base/resource/resource_bundle_ios.mm
diff --git a/ui/base/resource/resource_bundle_ios.mm b/ui/base/resource/resource_bundle_ios.mm
index 736e6ba7603a1408a9e9771b33d5866645245277..64b8527f77fccfc2e0b0b10675eefe610183e8b0 100644
--- a/ui/base/resource/resource_bundle_ios.mm
+++ b/ui/base/resource/resource_bundle_ios.mm
@@ -56,6 +56,13 @@ void ResourceBundle::LoadCommonResources() {
AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_200_percent", nil),
SCALE_FACTOR_200P);
}
+
+ // TODO(rohitrao): Add a chrome_300_percent file and load it here. For now,
+ // we are simply falling back to the 200P resources. http://crbug.com/413300.
+ if (IsScaleFactorSupported(SCALE_FACTOR_300P)) {
+ AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_200_percent", nil),
+ SCALE_FACTOR_200P);
+ }
}
base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale,
@@ -127,6 +134,14 @@ gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
// Create the image from the data.
CGFloat target_scale = ui::GetScaleForScaleFactor(scale_factor);
CGFloat source_scale = is_fallback ? 1.0 : target_scale;
+ // Hack: The 200P pak file is the only pak file loaded on iOS devices with
+ // an @3x scale factor. Force |source_scale| to be 2.0 to handle this case,
+ // since it cannot be anything else.
+ // TODO(rohitrao): Support proper fallback by using the actual scale factor
+ // of the source image, rather than assuming it is 1.0 or 2.0.
+ if (scale_factor == SCALE_FACTOR_300P) {
+ source_scale = 2.0;
+ }
base::scoped_nsobject<UIImage> ui_image(
[[UIImage alloc] initWithData:ns_data scale:source_scale]);

Powered by Google App Engine
This is Rietveld 408576698