diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 23:40:06 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 23:40:06 +0000 |
commit | 64954877e3e7fca9ffa936aee508ee338d78a293 (patch) | |
tree | b192f9f00d51f4c4a2231a4d569c1b736b50974b /ui/gfx/image/image_unittest_util.cc | |
parent | a5061244d407a27683b36e4d1ed35d895722805d (diff) | |
download | chromium_src-64954877e3e7fca9ffa936aee508ee338d78a293.zip chromium_src-64954877e3e7fca9ffa936aee508ee338d78a293.tar.gz chromium_src-64954877e3e7fca9ffa936aee508ee338d78a293.tar.bz2 |
Sets the proper device scale factor on iOS.
iOS sets a single supported scale factor at runtime, either 100P or 200P
depending on whether the device is hidpi. This CL also corrects some conversion
methods that did not properly support 200P scale factors.
BUG=None
TEST=Image unittests all pass on hidpi devices.
Review URL: https://chromiumcodereview.appspot.com/11233040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163725 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/image/image_unittest_util.cc')
-rw-r--r-- | ui/gfx/image/image_unittest_util.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ui/gfx/image/image_unittest_util.cc b/ui/gfx/image/image_unittest_util.cc index 3dd5b60..fc4b6cf 100644 --- a/ui/gfx/image/image_unittest_util.cc +++ b/ui/gfx/image/image_unittest_util.cc @@ -84,9 +84,20 @@ 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]; + float scale = ui::GetScaleFactorScale(scale_factor); + base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space( CGColorSpaceCreateDeviceRGB()); - UIImage* image = gfx::SkBitmapToUIImageWithColorSpace(bitmap, color_space); + UIImage* image = + gfx::SkBitmapToUIImageWithColorSpace(bitmap, scale, color_space); base::mac::NSObjectRetain(image); return image; #elif defined(OS_MACOSX) |