diff options
author | noyau@chromium.org <noyau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-12 12:31:12 +0000 |
---|---|---|
committer | noyau@chromium.org <noyau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-12 12:31:12 +0000 |
commit | a369c2f2af88d590c4a309f7c2e92b707f7c5ed6 (patch) | |
tree | f54b73753785f5f33d033b242ae9d400734b49d0 /ui | |
parent | a38bdda0c894ea19e90d5c37589943c9e08c15ef (diff) | |
download | chromium_src-a369c2f2af88d590c4a309f7c2e92b707f7c5ed6.zip chromium_src-a369c2f2af88d590c4a309f7c2e92b707f7c5ed6.tar.gz chromium_src-a369c2f2af88d590c4a309f7c2e92b707f7c5ed6.tar.bz2 |
Always add 100P scale format in the supported format list.
Align iOS with the other platforms and add 100P to the list of supported
scale formats.
BUG=None
Review URL: https://chromiumcodereview.appspot.com/11293147
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167165 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/layout.cc | 10 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle_ios.mm | 5 | ||||
-rw-r--r-- | ui/gfx/image/image_ios.mm | 9 | ||||
-rw-r--r-- | ui/gfx/image/image_skia_util_ios.mm | 21 | ||||
-rw-r--r-- | ui/gfx/image/image_unittest_util.cc | 9 |
5 files changed, 11 insertions, 43 deletions
diff --git a/ui/base/layout.cc b/ui/base/layout.cc index 6fef499..98df1e1 100644 --- a/ui/base/layout.cc +++ b/ui/base/layout.cc @@ -73,18 +73,18 @@ std::vector<ScaleFactor>& GetSupportedScaleFactorsInternal() { static std::vector<ScaleFactor>* supported_scale_factors = new std::vector<ScaleFactor>(); if (supported_scale_factors->empty()) { -#if !defined(OS_IOS) - // On platforms other than iOS, 100P is always a supported scale factor. + // 100P is always a supported scale factor. supported_scale_factors->push_back(SCALE_FACTOR_100P); -#endif #if defined(OS_IOS) + // TODO(ios): 100p should not be necessary on iOS retina devices. However + // the sync service only supports syncing 100p favicons. Until sync supports + // other scales 100p is needed in the list of scale factors to retrieve and + // store the favicons in both 100p for sync and 200p for display. cr/160503. gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); if (display.device_scale_factor() > 1.0) { DCHECK_EQ(2.0, display.device_scale_factor()); supported_scale_factors->push_back(SCALE_FACTOR_200P); - } else { - supported_scale_factors->push_back(SCALE_FACTOR_100P); } #elif defined(OS_MACOSX) if (base::mac::IsOSLionOrLater()) diff --git a/ui/base/resource/resource_bundle_ios.mm b/ui/base/resource/resource_bundle_ios.mm index 06da17d..8ff7347 100644 --- a/ui/base/resource/resource_bundle_ios.mm +++ b/ui/base/resource/resource_bundle_ios.mm @@ -107,10 +107,7 @@ gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { // Load the raw data from the resource pack at the current supported scale // factor. This code assumes that only one of the possible scale factors is // supported at runtime, based on the device resolution. - std::vector<ui::ScaleFactor> supported_scale_factors = - ui::GetSupportedScaleFactors(); - DCHECK_EQ(1U, supported_scale_factors.size()); - ui::ScaleFactor scale_factor = supported_scale_factors[0]; + ui::ScaleFactor scale_factor = ui::GetMaxScaleFactor(); scoped_refptr<base::RefCountedStaticMemory> data( LoadDataResourceBytesForScale(resource_id, scale_factor)); diff --git a/ui/gfx/image/image_ios.mm b/ui/gfx/image/image_ios.mm index cdc921d..f844d881 100644 --- a/ui/gfx/image/image_ios.mm +++ b/ui/gfx/image/image_ios.mm @@ -26,14 +26,7 @@ void PNGFromUIImage(UIImage* uiimage, std::vector<unsigned char>* png) { } UIImage* CreateUIImageFromPNG(const std::vector<unsigned char>& png) { - // iOS only supports one scale factor. - std::vector<ui::ScaleFactor> supported_scale_factors = - ui::GetSupportedScaleFactors(); - DCHECK_EQ(1U, supported_scale_factors.size()); - if (supported_scale_factors.size() < 1) - return nil; - - ui::ScaleFactor scale_factor = supported_scale_factors[0]; + ui::ScaleFactor scale_factor = ui::GetMaxScaleFactor(); float scale = ui::GetScaleFactorScale(scale_factor); NSData* data = [NSData dataWithBytes:&png.front() length:png.size()]; diff --git a/ui/gfx/image/image_skia_util_ios.mm b/ui/gfx/image/image_skia_util_ios.mm index c037e5c..78c8baf 100644 --- a/ui/gfx/image/image_skia_util_ios.mm +++ b/ui/gfx/image/image_skia_util_ios.mm @@ -19,14 +19,7 @@ gfx::ImageSkia ImageSkiaFromUIImage(UIImage* image) { if (!image) return image_skia; - // iOS only supports one scale factor. - std::vector<ui::ScaleFactor> supported_scale_factors = - ui::GetSupportedScaleFactors(); - DCHECK_EQ(1U, supported_scale_factors.size()); - if (supported_scale_factors.size() < 1) - return image_skia; - - ui::ScaleFactor scale_factor = supported_scale_factors[0]; + ui::ScaleFactor scale_factor = ui::GetMaxScaleFactor(); float scale = ui::GetScaleFactorScale(scale_factor); CGSize size = image.size; CGSize desired_size_for_scale = @@ -43,18 +36,10 @@ UIImage* UIImageFromImageSkia(const gfx::ImageSkia& image_skia) { if (image_skia.isNull()) return nil; - // iOS only supports one scale factor. - std::vector<ui::ScaleFactor> supported_scale_factors = - ui::GetSupportedScaleFactors(); - DCHECK_EQ(1U, supported_scale_factors.size()); - if (supported_scale_factors.size() < 1) - return nil; - - ui::ScaleFactor scale_factor = supported_scale_factors[0]; + ui::ScaleFactor scale_factor = ui::GetMaxScaleFactor(); float scale = ui::GetScaleFactorScale(scale_factor); image_skia.EnsureRepsForSupportedScaleFactors(); - const ImageSkiaRep& rep = - image_skia.GetRepresentation(supported_scale_factors[0]); + const ImageSkiaRep& rep = image_skia.GetRepresentation(scale_factor); base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space( CGColorSpaceCreateDeviceRGB()); return gfx::SkBitmapToUIImageWithColorSpace(rep.sk_bitmap(), scale, diff --git a/ui/gfx/image/image_unittest_util.cc b/ui/gfx/image/image_unittest_util.cc index fc4b6cf..2f2dcf3 100644 --- a/ui/gfx/image/image_unittest_util.cc +++ b/ui/gfx/image/image_unittest_util.cc @@ -84,14 +84,7 @@ bool IsEmpty(const gfx::Image& image) { PlatformImage CreatePlatformImage() { const SkBitmap bitmap(CreateBitmap(25, 25)); #if defined(OS_IOS) - // iOS only supports one scale factor. - std::vector<ui::ScaleFactor> supported_scale_factors = - ui::GetSupportedScaleFactors(); - DCHECK_EQ(1U, supported_scale_factors.size()); - if (supported_scale_factors.size() < 1) - return nil; - - ui::ScaleFactor scale_factor = supported_scale_factors[0]; + ui::ScaleFactor scale_factor = ui::GetMaxScaleFactor(); float scale = ui::GetScaleFactorScale(scale_factor); base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space( |