diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-24 03:25:48 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-24 03:25:48 +0000 |
commit | 50b66263c3a926fd1de75248fb2100e72715696e (patch) | |
tree | a4ad06309d29bacf1c6de692a20f7d214f8ea7ab /chrome | |
parent | 2fa342b8ed9c8777f78b3ba8b344dab24a04ef97 (diff) | |
download | chromium_src-50b66263c3a926fd1de75248fb2100e72715696e.zip chromium_src-50b66263c3a926fd1de75248fb2100e72715696e.tar.gz chromium_src-50b66263c3a926fd1de75248fb2100e72715696e.tar.bz2 |
Remove dependency on ui::ScaleFactor from ui/gfx
As part of the work to removed dependencies on ui/base from ui/gfx I have
changed the public api to Canvas, ImageSkia, ImageSkiaRep and ImagePNGRep
to take float scale values instead of ui::ScaleFactor.
The notion of supported scale factors has been broken into 2 parts.
ui::SetSupportedScaleFactors remains and calls the
new ImageSkia::SetSupportedScales().
The initialization of the supported scale factors has been moved from layout.h
into ResourceBundle, and is done explicitly in tests that don't use
ResourceBundle.
BUG=103304
R=ben@chromium.org, oshima@chromium.org, sky@chromium.org
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=224473
Review URL: https://codereview.chromium.org/24175004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224876 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
79 files changed, 316 insertions, 316 deletions
diff --git a/chrome/browser/android/provider/chrome_browser_provider.cc b/chrome/browser/android/provider/chrome_browser_provider.cc index f319c66..2f82c13 100644 --- a/chrome/browser/android/provider/chrome_browser_provider.cc +++ b/chrome/browser/android/provider/chrome_browser_provider.cc @@ -39,6 +39,7 @@ #include "sql/statement.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/layout.h" +#include "ui/base/resource/resource_bundle.h" #include "ui/gfx/favicon_size.h" using base::android::AttachCurrentThread; @@ -676,7 +677,7 @@ class BookmarkIconFetchTask : public FaviconServiceTask { url, chrome::FAVICON | chrome::TOUCH_ICON, gfx::kFaviconSize), - ui::GetMaxScaleFactor(), + ResourceBundle::GetSharedInstance().GetMaxScaleFactor(), base::Bind( &BookmarkIconFetchTask::OnFaviconRetrieved, base::Unretained(this)), diff --git a/chrome/browser/chromeos/extensions/wallpaper_api.cc b/chrome/browser/chromeos/extensions/wallpaper_api.cc index 7bf7679..1f0f785 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_api.cc @@ -72,7 +72,7 @@ void WallpaperSetWallpaperFunction::OnWallpaperDecoded( unsafe_wallpaper_decoder_ = NULL; if (generate_thumbnail_) { - wallpaper.EnsureRepsForSupportedScaleFactors(); + wallpaper.EnsureRepsForSupportedScales(); scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy()); // Generates thumbnail before call api function callback. We can then // request thumbnail in the javascript callback. diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc index 27c82cf..9448649 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc @@ -370,7 +370,7 @@ void WallpaperPrivateSetWallpaperFunction::SaveToFile() { sequence_token_)); std::string file_name = GURL(url_).ExtractFileName(); if (SaveData(chrome::DIR_CHROMEOS_WALLPAPERS, file_name, image_data_)) { - wallpaper_.EnsureRepsForSupportedScaleFactors(); + wallpaper_.EnsureRepsForSupportedScales(); scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper_.DeepCopy()); // ImageSkia is not RefCountedThreadSafe. Use a deep copied ImageSkia if // post to another thread. @@ -502,7 +502,7 @@ void WallpaperPrivateSetCustomWallpaperFunction::OnWallpaperDecoded( unsafe_wallpaper_decoder_ = NULL; if (generate_thumbnail_) { - wallpaper.EnsureRepsForSupportedScaleFactors(); + wallpaper.EnsureRepsForSupportedScales(); scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy()); // Generates thumbnail before call api function callback. We can then // request thumbnail in the javascript callback. diff --git a/chrome/browser/chromeos/login/helper.cc b/chrome/browser/chromeos/login/helper.cc index 58e85a0..c75fb09 100644 --- a/chrome/browser/chromeos/login/helper.cc +++ b/chrome/browser/chromeos/login/helper.cc @@ -15,6 +15,7 @@ #include "third_party/cros_system_api/dbus/service_constants.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/screen.h" namespace chromeos { @@ -36,8 +37,7 @@ int GetCurrentUserImageSize() { float scale_factor = gfx::Display::GetForcedDeviceScaleFactor(); if (scale_factor > 1.0f) return static_cast<int>(scale_factor * kBaseUserImageSize); - return kBaseUserImageSize * - ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); + return kBaseUserImageSize * gfx::ImageSkia::GetMaxSupportedScale(); } namespace login { diff --git a/chrome/browser/chromeos/login/wallpaper_manager.cc b/chrome/browser/chromeos/login/wallpaper_manager.cc index 3692a2a..3920d71 100644 --- a/chrome/browser/chromeos/login/wallpaper_manager.cc +++ b/chrome/browser/chromeos/login/wallpaper_manager.cc @@ -420,7 +420,7 @@ void WallpaperManager::SetCustomWallpaper(const std::string& username, bool is_persistent = !UserManager::Get()->IsUserNonCryptohomeDataEphemeral(username); - wallpaper.image().EnsureRepsForSupportedScaleFactors(); + wallpaper.image().EnsureRepsForSupportedScales(); scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); WallpaperInfo wallpaper_info = { diff --git a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc index f9785f8..0601780 100644 --- a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc +++ b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc @@ -59,9 +59,9 @@ gfx::ImageSkia AddBackgroundForViews(const gfx::ImageSkia& icon) { bool ImagesAreEqualAtScale(const gfx::ImageSkia& i1, const gfx::ImageSkia& i2, - ui::ScaleFactor scale_factor) { - SkBitmap bitmap1 = i1.GetRepresentation(scale_factor).sk_bitmap(); - SkBitmap bitmap2 = i2.GetRepresentation(scale_factor).sk_bitmap(); + float scale) { + SkBitmap bitmap1 = i1.GetRepresentation(scale).sk_bitmap(); + SkBitmap bitmap2 = i2.GetRepresentation(scale).sk_bitmap(); return gfx::BitmapsAreEqual(bitmap1, bitmap2); } @@ -136,7 +136,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { std::vector<ui::ScaleFactor> supported_scale_factors; supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); supported_scale_factors.push_back(ui::SCALE_FACTOR_200P); - ui::test::SetSupportedScaleFactors(supported_scale_factors); + ui::SetSupportedScaleFactors(supported_scale_factors); #endif // We should not be creating icons asynchronously, so we don't need an @@ -171,13 +171,12 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { EXPECT_GT(action_icon_current_id, action_icon_last_id); action_icon_last_id = action_icon_current_id; - EXPECT_FALSE( - action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P)); + EXPECT_FALSE(action_icon.ToImageSkia()->HasRepresentation(2.0f)); EXPECT_TRUE(ImagesAreEqualAtScale( AddBackgroundForViews(*action_icon.ToImageSkia()), *GetBrowserActionsBar().GetIcon(0).ToImageSkia(), - ui::SCALE_FACTOR_100P)); + 1.0f)); // Tell the extension to update the icon using path. GetBrowserActionsBar().Press(0); @@ -190,12 +189,12 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { action_icon_last_id = action_icon_current_id; EXPECT_FALSE( - action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P)); + action_icon.ToImageSkia()->HasRepresentation(2.0f)); EXPECT_TRUE(ImagesAreEqualAtScale( AddBackgroundForViews(*action_icon.ToImageSkia()), *GetBrowserActionsBar().GetIcon(0).ToImageSkia(), - ui::SCALE_FACTOR_100P)); + 1.0f)); // Tell the extension to update the icon using dictionary of ImageData // objects. @@ -208,13 +207,12 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { EXPECT_GT(action_icon_current_id, action_icon_last_id); action_icon_last_id = action_icon_current_id; - EXPECT_TRUE( - action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P)); + EXPECT_TRUE(action_icon.ToImageSkia()->HasRepresentation(2.0f)); EXPECT_TRUE(ImagesAreEqualAtScale( AddBackgroundForViews(*action_icon.ToImageSkia()), *GetBrowserActionsBar().GetIcon(0).ToImageSkia(), - ui::SCALE_FACTOR_100P)); + 1.0f)); // Tell the extension to update the icon using dictionary of paths. GetBrowserActionsBar().Press(0); @@ -226,13 +224,12 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { EXPECT_GT(action_icon_current_id, action_icon_last_id); action_icon_last_id = action_icon_current_id; - EXPECT_TRUE( - action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P)); + EXPECT_TRUE(action_icon.ToImageSkia()->HasRepresentation(2.0f)); EXPECT_TRUE(ImagesAreEqualAtScale( AddBackgroundForViews(*action_icon.ToImageSkia()), *GetBrowserActionsBar().GetIcon(0).ToImageSkia(), - ui::SCALE_FACTOR_100P)); + 1.0f)); // Tell the extension to update the icon using dictionary of ImageData // objects, but setting only size 19. @@ -245,13 +242,12 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { EXPECT_GT(action_icon_current_id, action_icon_last_id); action_icon_last_id = action_icon_current_id; - EXPECT_FALSE( - action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P)); + EXPECT_FALSE(action_icon.ToImageSkia()->HasRepresentation(2.0f)); EXPECT_TRUE(ImagesAreEqualAtScale( AddBackgroundForViews(*action_icon.ToImageSkia()), *GetBrowserActionsBar().GetIcon(0).ToImageSkia(), - ui::SCALE_FACTOR_100P)); + 1.0f)); // Tell the extension to update the icon using dictionary of paths, but // setting only size 19. @@ -264,13 +260,12 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { EXPECT_GT(action_icon_current_id, action_icon_last_id); action_icon_last_id = action_icon_current_id; - EXPECT_FALSE( - action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P)); + EXPECT_FALSE(action_icon.ToImageSkia()->HasRepresentation(2.0f)); EXPECT_TRUE(ImagesAreEqualAtScale( AddBackgroundForViews(*action_icon.ToImageSkia()), *GetBrowserActionsBar().GetIcon(0).ToImageSkia(), - ui::SCALE_FACTOR_100P)); + 1.0f)); // Tell the extension to update the icon using dictionary of ImageData // objects, but setting only size 38. @@ -281,8 +276,8 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { const gfx::ImageSkia* action_icon_skia = action_icon.ToImageSkia(); - EXPECT_FALSE(action_icon_skia->HasRepresentation(ui::SCALE_FACTOR_100P)); - EXPECT_TRUE(action_icon_skia->HasRepresentation(ui::SCALE_FACTOR_200P)); + EXPECT_FALSE(action_icon_skia->HasRepresentation(1.0f)); + EXPECT_TRUE(action_icon_skia->HasRepresentation(2.0f)); action_icon_current_id = action_icon.ToSkBitmap()->getGenerationID(); EXPECT_GT(action_icon_current_id, action_icon_last_id); @@ -290,12 +285,12 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { EXPECT_TRUE(gfx::BitmapsAreEqual( *action_icon.ToSkBitmap(), - action_icon_skia->GetRepresentation(ui::SCALE_FACTOR_200P).sk_bitmap())); + action_icon_skia->GetRepresentation(2.0f).sk_bitmap())); EXPECT_TRUE(ImagesAreEqualAtScale( AddBackgroundForViews(*action_icon_skia), *GetBrowserActionsBar().GetIcon(0).ToImageSkia(), - ui::SCALE_FACTOR_200P)); + 2.0f)); // Try setting icon with empty dictionary of ImageData objects. GetBrowserActionsBar().Press(0); diff --git a/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chrome/browser/extensions/api/extension_action/extension_action_api.cc index 3d4c46d..488e852 100644 --- a/chrome/browser/extensions/api/extension_action/extension_action_api.cc +++ b/chrome/browser/extensions/api/extension_action/extension_action_api.cc @@ -100,8 +100,7 @@ bool StringToSkBitmap(const std::string& str, SkBitmap* bitmap) { } // Conversion function for reading/writing to storage. -std::string RepresentationToString(const gfx::ImageSkia& image, - ui::ScaleFactor scale) { +std::string RepresentationToString(const gfx::ImageSkia& image, float scale) { SkBitmap bitmap = image.GetRepresentation(scale).sk_bitmap(); IPC::Message bitmap_pickle; // Clear the header values so they don't vary in serialization. @@ -144,7 +143,8 @@ void SetDefaultsFromValue(const base::DictionaryValue* dict, if (icon_value->GetString(kIconSizes[i].size_string, &str_value) && StringToSkBitmap(str_value, &bitmap)) { CHECK(!bitmap.isNull()); - icon.AddRepresentation(gfx::ImageSkiaRep(bitmap, kIconSizes[i].scale)); + float scale = ui::GetImageScale(kIconSizes[i].scale); + icon.AddRepresentation(gfx::ImageSkiaRep(bitmap, scale)); } } action->SetIcon(kTabId, gfx::Image(icon)); @@ -172,10 +172,11 @@ scoped_ptr<base::DictionaryValue> DefaultsToValue(ExtensionAction* action) { if (!icon.isNull()) { base::DictionaryValue* icon_value = new base::DictionaryValue(); for (size_t i = 0; i < arraysize(kIconSizes); i++) { - if (icon.HasRepresentation(kIconSizes[i].scale)) { + float scale = ui::GetImageScale(kIconSizes[i].scale); + if (icon.HasRepresentation(scale)) { icon_value->SetString( kIconSizes[i].size_string, - RepresentationToString(icon, kIconSizes[i].scale)); + RepresentationToString(icon, scale)); } } dict->Set(kIconStorageKey, icon_value); @@ -696,7 +697,8 @@ bool ExtensionActionSetIconFunction::RunExtensionAction() { SkBitmap bitmap; EXTENSION_FUNCTION_VALIDATE(IPC::ReadParam(&pickle, &iter, &bitmap)); CHECK(!bitmap.isNull()); - icon.AddRepresentation(gfx::ImageSkiaRep(bitmap, kIconSizes[i].scale)); + float scale = ui::GetImageScale(kIconSizes[i].scale); + icon.AddRepresentation(gfx::ImageSkiaRep(bitmap, scale)); } } diff --git a/chrome/browser/extensions/api/notifications/notifications_api.cc b/chrome/browser/extensions/api/notifications/notifications_api.cc index e78798e..bd4054d 100644 --- a/chrome/browser/extensions/api/notifications/notifications_api.cc +++ b/chrome/browser/extensions/api/notifications/notifications_api.cc @@ -102,8 +102,7 @@ bool NotificationBitmapToGfxImage( } // TODO(dewittj): Handle HiDPI images. - ui::ScaleFactor scale_factor(ui::SCALE_FACTOR_100P); - gfx::ImageSkia skia(gfx::ImageSkiaRep(bitmap, scale_factor)); + gfx::ImageSkia skia(gfx::ImageSkiaRep(bitmap, 1.0f)); *return_image = gfx::Image(skia); return true; } diff --git a/chrome/browser/extensions/app_icon_loader_impl.cc b/chrome/browser/extensions/app_icon_loader_impl.cc index 4eb0fc2..1172b2b 100644 --- a/chrome/browser/extensions/app_icon_loader_impl.cc +++ b/chrome/browser/extensions/app_icon_loader_impl.cc @@ -67,7 +67,7 @@ void AppIconLoaderImpl::FetchImage(const std::string& id) { // Triggers image loading now instead of depending on paint message. This // makes the temp blank image be shown for shorter time and improves user // experience. See http://crbug.com/146114. - image->image_skia().EnsureRepsForSupportedScaleFactors(); + image->image_skia().EnsureRepsForSupportedScales(); } void AppIconLoaderImpl::ClearImage(const std::string& id) { diff --git a/chrome/browser/extensions/extension_action.cc b/chrome/browser/extensions/extension_action.cc index ccce0ca..50ac185 100644 --- a/chrome/browser/extensions/extension_action.cc +++ b/chrome/browser/extensions/extension_action.cc @@ -39,13 +39,12 @@ class GetAttentionImageSource : public gfx::ImageSkiaSource { : icon_(icon) {} // gfx::ImageSkiaSource overrides: - virtual gfx::ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) - OVERRIDE { - gfx::ImageSkiaRep icon_rep = icon_.GetRepresentation(scale_factor); + virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { + gfx::ImageSkiaRep icon_rep = icon_.GetRepresentation(scale); color_utils::HSL shift = {-1, 0, 0.5}; return gfx::ImageSkiaRep( SkBitmapOperations::CreateHSLShiftedBitmap(icon_rep.sk_bitmap(), shift), - icon_rep.scale_factor()); + icon_rep.scale()); } private: @@ -68,7 +67,7 @@ class AnimatedIconImageSource : public gfx::ImageSkiaSource { private: virtual ~AnimatedIconImageSource() {} - virtual gfx::ImageSkiaRep GetImageForScale(ui::ScaleFactor scale) OVERRIDE { + virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { gfx::ImageSkiaRep original_rep = image_.GetRepresentation(scale); if (!animation_.get()) return original_rep; @@ -77,8 +76,7 @@ class AnimatedIconImageSource : public gfx::ImageSkiaSource { // factor passed to this method. We want to use the former (since we are // using bitmap for that scale). return gfx::ImageSkiaRep( - animation_->Apply(original_rep.sk_bitmap()), - original_rep.scale_factor()); + animation_->Apply(original_rep.sk_bitmap()), original_rep.scale()); } gfx::ImageSkia image_; diff --git a/chrome/browser/extensions/extension_action_icon_factory_unittest.cc b/chrome/browser/extensions/extension_action_icon_factory_unittest.cc index 3eadffa..649ac62 100644 --- a/chrome/browser/extensions/extension_action_icon_factory_unittest.cc +++ b/chrome/browser/extensions/extension_action_icon_factory_unittest.cc @@ -38,7 +38,7 @@ namespace { bool ImageRepsAreEqual(const gfx::ImageSkiaRep& image_rep1, const gfx::ImageSkiaRep& image_rep2) { - return image_rep1.scale_factor() == image_rep2.scale_factor() && + return image_rep1.scale() == image_rep2.scale() && gfx::BitmapsAreEqual(image_rep1.sk_bitmap(), image_rep2.sk_bitmap()); } @@ -53,15 +53,14 @@ gfx::Image EnsureImageSize(const gfx::Image& original, int size) { return gfx::Image::CreateFrom1xBitmap(resized); } -gfx::ImageSkiaRep CreateBlankRep(int size_dip, ui::ScaleFactor scale_factor) { - SkBitmap bitmap; - const float scale = ui::GetScaleFactorScale(scale_factor); - bitmap.setConfig(SkBitmap::kARGB_8888_Config, - static_cast<int>(size_dip * scale), - static_cast<int>(size_dip * scale)); - bitmap.allocPixels(); - bitmap.eraseColor(SkColorSetARGB(0, 0, 0, 0)); - return gfx::ImageSkiaRep(bitmap, scale_factor); +gfx::ImageSkiaRep CreateBlankRep(int size_dip, float scale) { + SkBitmap bitmap; + bitmap.setConfig(SkBitmap::kARGB_8888_Config, + static_cast<int>(size_dip * scale), + static_cast<int>(size_dip * scale)); + bitmap.allocPixels(); + bitmap.eraseColor(SkColorSetARGB(0, 0, 0, 0)); + return gfx::ImageSkiaRep(bitmap, scale); } gfx::Image LoadIcon(const std::string& filename) { @@ -203,8 +202,8 @@ TEST_F(ExtensionActionIconFactoryTest, NoIcons) { gfx::Image icon = icon_factory.GetIcon(0); EXPECT_TRUE(ImageRepsAreEqual( - favicon.GetRepresentation(ui::SCALE_FACTOR_100P), - icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P))); + favicon.GetRepresentation(1.0f), + icon.ToImageSkia()->GetRepresentation(1.0f))); } // If the icon has been set using |SetIcon|, the factory should return that @@ -234,15 +233,15 @@ TEST_F(ExtensionActionIconFactoryTest, AfterSetIcon) { gfx::Image icon = icon_factory.GetIcon(0); EXPECT_TRUE(ImageRepsAreEqual( - set_icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P), - icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P))); + set_icon.ToImageSkia()->GetRepresentation(1.0f), + icon.ToImageSkia()->GetRepresentation(1.0f))); // It should still return favicon for another tabs. icon = icon_factory.GetIcon(1); EXPECT_TRUE(ImageRepsAreEqual( - GetFavicon().GetRepresentation(ui::SCALE_FACTOR_100P), - icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P))); + GetFavicon().GetRepresentation(1.0f), + icon.ToImageSkia()->GetRepresentation(1.0f))); } // If there is a default icon, and the icon has not been set using |SetIcon|, @@ -277,8 +276,8 @@ TEST_F(ExtensionActionIconFactoryTest, DefaultIcon) { // The icon should be loaded asynchronously. Initially a transparent icon // should be returned. EXPECT_TRUE(ImageRepsAreEqual( - CreateBlankRep(19, ui::SCALE_FACTOR_100P), - icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P))); + CreateBlankRep(19, 1.0f), + icon.ToImageSkia()->GetRepresentation(1.0f))); WaitForIconUpdate(); @@ -286,15 +285,15 @@ TEST_F(ExtensionActionIconFactoryTest, DefaultIcon) { // The default icon representation should be loaded at this point. EXPECT_TRUE(ImageRepsAreEqual( - default_icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P), - icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P))); + default_icon.ToImageSkia()->GetRepresentation(1.0f), + icon.ToImageSkia()->GetRepresentation(1.0f))); // The same icon should be returned for the other tabs. icon = icon_factory.GetIcon(1); EXPECT_TRUE(ImageRepsAreEqual( - default_icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P), - icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P))); + default_icon.ToImageSkia()->GetRepresentation(1.0f), + icon.ToImageSkia()->GetRepresentation(1.0f))); } diff --git a/chrome/browser/extensions/extension_icon_image.cc b/chrome/browser/extensions/extension_icon_image.cc index fbd1ee4..7b0b248 100644 --- a/chrome/browser/extensions/extension_icon_image.cc +++ b/chrome/browser/extensions/extension_icon_image.cc @@ -86,8 +86,7 @@ class IconImage::Source : public gfx::ImageSkiaSource { private: // gfx::ImageSkiaSource overrides: - virtual gfx::ImageSkiaRep GetImageForScale( - ui::ScaleFactor scale_factor) OVERRIDE; + virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE; // Used to load images, possibly asynchronously. NULLed out when the IconImage // is destroyed. @@ -112,16 +111,17 @@ void IconImage::Source::ResetHost() { host_ = NULL; } -gfx::ImageSkiaRep IconImage::Source::GetImageForScale( - ui::ScaleFactor scale_factor) { +gfx::ImageSkiaRep IconImage::Source::GetImageForScale(float scale) { gfx::ImageSkiaRep representation; - if (host_) - representation = host_->LoadImageForScaleFactor(scale_factor); + if (host_) { + representation = + host_->LoadImageForScaleFactor(ui::GetSupportedScaleFactor(scale)); + } if (!representation.is_null()) return representation; - return blank_image_.GetRepresentation(scale_factor); + return blank_image_.GetRepresentation(scale); } //////////////////////////////////////////////////////////////////////////////// @@ -163,7 +163,7 @@ gfx::ImageSkiaRep IconImage::LoadImageForScaleFactor( if (!extension_) return gfx::ImageSkiaRep(); - const float scale = ui::GetScaleFactorScale(scale_factor); + const float scale = ui::GetImageScale(scale_factor); const int resource_size_in_pixel = static_cast<int>(resource_size_in_dip_ * scale); @@ -184,7 +184,7 @@ gfx::ImageSkiaRep IconImage::LoadImageForScaleFactor( // If there is no resource found, return default icon. if (resource.empty()) - return default_icon_.GetRepresentation(scale_factor); + return default_icon_.GetRepresentation(scale); std::vector<ImageLoader::ImageRepresentation> info_list; info_list.push_back(ImageLoader::ImageRepresentation( @@ -198,13 +198,12 @@ gfx::ImageSkiaRep IconImage::LoadImageForScaleFactor( loader->LoadImagesAsync(extension_, info_list, base::Bind(&IconImage::OnImageLoaded, weak_ptr_factory_.GetWeakPtr(), - scale_factor)); + scale)); return gfx::ImageSkiaRep(); } -void IconImage::OnImageLoaded(ui::ScaleFactor scale_factor, - const gfx::Image& image_in) { +void IconImage::OnImageLoaded(float scale, const gfx::Image& image_in) { const gfx::ImageSkia* image = image_in.IsEmpty() ? &default_icon_ : image_in.ToImageSkia(); @@ -212,12 +211,12 @@ void IconImage::OnImageLoaded(ui::ScaleFactor scale_factor, if (image->isNull()) return; - gfx::ImageSkiaRep rep = image->GetRepresentation(scale_factor); + gfx::ImageSkiaRep rep = image->GetRepresentation(scale); DCHECK(!rep.is_null()); - DCHECK_EQ(scale_factor, rep.scale_factor()); + DCHECK_EQ(scale, rep.scale()); // Remove old representation if there is one. - image_skia_.RemoveRepresentation(rep.scale_factor()); + image_skia_.RemoveRepresentation(scale); image_skia_.AddRepresentation(rep); if (observer_) diff --git a/chrome/browser/extensions/extension_icon_image.h b/chrome/browser/extensions/extension_icon_image.h index d1ddd57..94cdae5 100644 --- a/chrome/browser/extensions/extension_icon_image.h +++ b/chrome/browser/extensions/extension_icon_image.h @@ -13,6 +13,7 @@ #include "chrome/common/extensions/extension_icon_set.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" +#include "ui/base/layout.h" #include "ui/gfx/image/image_skia.h" class Profile; @@ -81,7 +82,7 @@ class IconImage : public content::NotificationObserver { // observer's |OnExtensionIconImageLoaded| will be called. gfx::ImageSkiaRep LoadImageForScaleFactor(ui::ScaleFactor scale_factor); - void OnImageLoaded(ui::ScaleFactor scale_factor, const gfx::Image& image); + void OnImageLoaded(float scale_factor, const gfx::Image& image); // content::NotificationObserver overrides: virtual void Observe(int type, diff --git a/chrome/browser/extensions/extension_icon_image_unittest.cc b/chrome/browser/extensions/extension_icon_image_unittest.cc index 0d9b9a7..fd35ee9 100644 --- a/chrome/browser/extensions/extension_icon_image_unittest.cc +++ b/chrome/browser/extensions/extension_icon_image_unittest.cc @@ -31,7 +31,7 @@ namespace { SkBitmap CreateBlankBitmapForScale(int size_dip, ui::ScaleFactor scale_factor) { SkBitmap bitmap; - const float scale = ui::GetScaleFactorScale(scale_factor); + const float scale = ui::GetImageScale(scale_factor); bitmap.setConfig(SkBitmap::kARGB_8888_Config, static_cast<int>(size_dip * scale), static_cast<int>(size_dip * scale)); @@ -59,9 +59,8 @@ class MockImageSkiaSource : public gfx::ImageSkiaSource { } virtual ~MockImageSkiaSource() {} - virtual gfx::ImageSkiaRep GetImageForScale( - ui::ScaleFactor scale_factor) OVERRIDE { - return image_.GetRepresentation(scale_factor); + virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { + return image_.GetRepresentation(scale); } private: @@ -210,6 +209,10 @@ class ExtensionIconImageTest : public testing::Test, } // namespace TEST_F(ExtensionIconImageTest, Basic) { + std::vector<ui::ScaleFactor> supported_factors; + supported_factors.push_back(ui::SCALE_FACTOR_100P); + supported_factors.push_back(ui::SCALE_FACTOR_200P); + ui::test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors); scoped_ptr<Profile> profile(new TestingProfile()); scoped_refptr<Extension> extension(CreateExtension( "extension_icon_image", Manifest::INVALID_LOCATION)); @@ -240,8 +243,7 @@ TEST_F(ExtensionIconImageTest, Basic) { ASSERT_EQ(0u, image_reps.size()); // Gets representation for a scale factor. - gfx::ImageSkiaRep representation = - image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + gfx::ImageSkiaRep representation = image.image_skia().GetRepresentation(1.0f); // Before the image representation is loaded, image should contain blank // image representation. @@ -253,14 +255,14 @@ TEST_F(ExtensionIconImageTest, Basic) { EXPECT_EQ(1, ImageLoadedCount()); ASSERT_EQ(1u, image.image_skia().image_reps().size()); - representation = image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + representation = image.image_skia().GetRepresentation(1.0f); // We should get the right representation now. EXPECT_TRUE(gfx::BitmapsAreEqual(representation.sk_bitmap(), bitmap_16)); EXPECT_EQ(16, representation.pixel_width()); // Gets representation for an additional scale factor. - representation = image.image_skia().GetRepresentation(ui::SCALE_FACTOR_200P); + representation = image.image_skia().GetRepresentation(2.0f); EXPECT_TRUE(gfx::BitmapsAreEqual( representation.sk_bitmap(), @@ -270,7 +272,7 @@ TEST_F(ExtensionIconImageTest, Basic) { EXPECT_EQ(1, ImageLoadedCount()); ASSERT_EQ(2u, image.image_skia().image_reps().size()); - representation = image.image_skia().GetRepresentation(ui::SCALE_FACTOR_200P); + representation = image.image_skia().GetRepresentation(2.0f); // Image should have been resized. EXPECT_EQ(32, representation.pixel_width()); @@ -281,6 +283,10 @@ TEST_F(ExtensionIconImageTest, Basic) { // There is no resource with either exact or bigger size, but there is a smaller // resource. TEST_F(ExtensionIconImageTest, FallbackToSmallerWhenNoBigger) { + std::vector<ui::ScaleFactor> supported_factors; + supported_factors.push_back(ui::SCALE_FACTOR_100P); + supported_factors.push_back(ui::SCALE_FACTOR_200P); + ui::test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors); scoped_ptr<Profile> profile(new TestingProfile()); scoped_refptr<Extension> extension(CreateExtension( "extension_icon_image", Manifest::INVALID_LOCATION)); @@ -300,18 +306,17 @@ TEST_F(ExtensionIconImageTest, FallbackToSmallerWhenNoBigger) { default_icon, this); - gfx::ImageSkiaRep representation = - image.image_skia().GetRepresentation(ui::SCALE_FACTOR_200P); + gfx::ImageSkiaRep representation = image.image_skia().GetRepresentation(2.0f); WaitForImageLoad(); EXPECT_EQ(1, ImageLoadedCount()); ASSERT_EQ(1u, image.image_skia().image_reps().size()); - representation = image.image_skia().GetRepresentation(ui::SCALE_FACTOR_200P); + representation = image.image_skia().GetRepresentation(2.0f); // We should have loaded the biggest smaller resource resized to the actual // size. - EXPECT_EQ(ui::SCALE_FACTOR_200P, representation.scale_factor()); + EXPECT_EQ(2.0f, representation.scale()); EXPECT_EQ(64, representation.pixel_width()); EXPECT_TRUE(gfx::BitmapsAreEqual(representation.sk_bitmap(), EnsureBitmapSize(bitmap_48, 64))); @@ -340,17 +345,16 @@ TEST_F(ExtensionIconImageTest, FallbackToSmaller) { default_icon, this); - gfx::ImageSkiaRep representation = - image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + gfx::ImageSkiaRep representation = image.image_skia().GetRepresentation(1.0f); WaitForImageLoad(); EXPECT_EQ(1, ImageLoadedCount()); ASSERT_EQ(1u, image.image_skia().image_reps().size()); - representation = image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + representation = image.image_skia().GetRepresentation(1.0f); // We should have loaded smaller (resized) resource. - EXPECT_EQ(ui::SCALE_FACTOR_100P, representation.scale_factor()); + EXPECT_EQ(1.0f, representation.scale()); EXPECT_EQ(17, representation.pixel_width()); EXPECT_TRUE(gfx::BitmapsAreEqual(representation.sk_bitmap(), EnsureBitmapSize(bitmap_16, 17))); @@ -375,23 +379,22 @@ TEST_F(ExtensionIconImageTest, NoResources) { default_icon, this); - gfx::ImageSkiaRep representation = - image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + gfx::ImageSkiaRep representation = image.image_skia().GetRepresentation(1.0f); EXPECT_TRUE(gfx::BitmapsAreEqual( representation.sk_bitmap(), EnsureBitmapSize( - default_icon.GetRepresentation(ui::SCALE_FACTOR_100P).sk_bitmap(), + default_icon.GetRepresentation(1.0f).sk_bitmap(), kRequestedSize))); EXPECT_EQ(0, ImageLoadedCount()); // We should have a default icon representation. ASSERT_EQ(1u, image.image_skia().image_reps().size()); - representation = image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + representation = image.image_skia().GetRepresentation(1.0f); EXPECT_TRUE(gfx::BitmapsAreEqual( representation.sk_bitmap(), EnsureBitmapSize( - default_icon.GetRepresentation(ui::SCALE_FACTOR_100P).sk_bitmap(), + default_icon.GetRepresentation(1.0f).sk_bitmap(), kRequestedSize))); } @@ -417,8 +420,7 @@ TEST_F(ExtensionIconImageTest, InvalidResource) { default_icon, this); - gfx::ImageSkiaRep representation = - image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + gfx::ImageSkiaRep representation = image.image_skia().GetRepresentation(1.0f); EXPECT_TRUE(gfx::BitmapsAreEqual( representation.sk_bitmap(), CreateBlankBitmapForScale(kInvalidIconSize, ui::SCALE_FACTOR_100P))); @@ -428,11 +430,11 @@ TEST_F(ExtensionIconImageTest, InvalidResource) { // We should have default icon representation now. ASSERT_EQ(1u, image.image_skia().image_reps().size()); - representation = image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + representation = image.image_skia().GetRepresentation(1.0f); EXPECT_TRUE(gfx::BitmapsAreEqual( representation.sk_bitmap(), EnsureBitmapSize( - default_icon.GetRepresentation(ui::SCALE_FACTOR_100P).sk_bitmap(), + default_icon.GetRepresentation(1.0f).sk_bitmap(), kInvalidIconSize))); } @@ -458,17 +460,16 @@ TEST_F(ExtensionIconImageTest, LazyDefaultIcon) { lazy_default_icon, this); - ASSERT_FALSE(lazy_default_icon.HasRepresentation(ui::SCALE_FACTOR_100P)); + ASSERT_FALSE(lazy_default_icon.HasRepresentation(1.0f)); - gfx::ImageSkiaRep representation = - image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + gfx::ImageSkiaRep representation = image.image_skia().GetRepresentation(1.0f); // The resouce set is empty, so we should get the result right away. - EXPECT_TRUE(lazy_default_icon.HasRepresentation(ui::SCALE_FACTOR_100P)); + EXPECT_TRUE(lazy_default_icon.HasRepresentation(1.0f)); EXPECT_TRUE(gfx::BitmapsAreEqual( representation.sk_bitmap(), EnsureBitmapSize( - default_icon.GetRepresentation(ui::SCALE_FACTOR_100P).sk_bitmap(), + default_icon.GetRepresentation(1.0f).sk_bitmap(), kRequestedSize))); // We should have a default icon representation. @@ -498,23 +499,22 @@ TEST_F(ExtensionIconImageTest, LazyDefaultIcon_AsyncIconImage) { lazy_default_icon, this); - ASSERT_FALSE(lazy_default_icon.HasRepresentation(ui::SCALE_FACTOR_100P)); + ASSERT_FALSE(lazy_default_icon.HasRepresentation(1.0f)); - gfx::ImageSkiaRep representation = - image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + gfx::ImageSkiaRep representation = image.image_skia().GetRepresentation(1.0f); WaitForImageLoad(); EXPECT_EQ(1, ImageLoadedCount()); // We should have default icon representation now. ASSERT_EQ(1u, image.image_skia().image_reps().size()); - EXPECT_TRUE(lazy_default_icon.HasRepresentation(ui::SCALE_FACTOR_100P)); + EXPECT_TRUE(lazy_default_icon.HasRepresentation(1.0f)); - representation = image.image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + representation = image.image_skia().GetRepresentation(1.0f); EXPECT_TRUE(gfx::BitmapsAreEqual( representation.sk_bitmap(), EnsureBitmapSize( - default_icon.GetRepresentation(ui::SCALE_FACTOR_100P).sk_bitmap(), + default_icon.GetRepresentation(1.0f).sk_bitmap(), kInvalidIconSize))); } @@ -545,7 +545,7 @@ TEST_F(ExtensionIconImageTest, IconImageDestruction) { // Load an image representation. gfx::ImageSkiaRep representation = - image->image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); + image->image_skia().GetRepresentation(1.0f); WaitForImageLoad(); EXPECT_EQ(1, ImageLoadedCount()); @@ -557,14 +557,14 @@ TEST_F(ExtensionIconImageTest, IconImageDestruction) { extension = NULL; // Image skia should still be able to get previously loaded representation. - representation = image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); + representation = image_skia.GetRepresentation(1.0f); - EXPECT_EQ(ui::SCALE_FACTOR_100P, representation.scale_factor()); + EXPECT_EQ(1.0f, representation.scale()); EXPECT_EQ(16, representation.pixel_width()); EXPECT_TRUE(gfx::BitmapsAreEqual(representation.sk_bitmap(), bitmap_16)); // When requesting another representation, we should get blank image. - representation = image_skia.GetRepresentation(ui::SCALE_FACTOR_200P); + representation = image_skia.GetRepresentation(2.0f); EXPECT_TRUE(gfx::BitmapsAreEqual( representation.sk_bitmap(), diff --git a/chrome/browser/extensions/extension_icon_manager.cc b/chrome/browser/extensions/extension_icon_manager.cc index 66f42db..475f4cb 100644 --- a/chrome/browser/extensions/extension_icon_manager.cc +++ b/chrome/browser/extensions/extension_icon_manager.cc @@ -32,7 +32,7 @@ static SkBitmap ApplyPadding(const SkBitmap& source, scoped_ptr<gfx::Canvas> result( new gfx::Canvas(gfx::Size(source.width() + padding.width(), source.height() + padding.height()), - ui::SCALE_FACTOR_100P, + 1.0f, false)); result->DrawImageInt( gfx::ImageSkia::CreateFrom1xBitmap(source), diff --git a/chrome/browser/extensions/extension_install_prompt.cc b/chrome/browser/extensions/extension_install_prompt.cc index 309c28f..e4a08aa 100644 --- a/chrome/browser/extensions/extension_install_prompt.cc +++ b/chrome/browser/extensions/extension_install_prompt.cc @@ -122,9 +122,7 @@ const int kIconSize = 69; // Returns pixel size under maximal scale factor for the icon whose device // independent size is |size_in_dip| int GetSizeForMaxScaleFactor(int size_in_dip) { - float max_scale_factor_scale = - ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); - return static_cast<int>(size_in_dip * max_scale_factor_scale); + return static_cast<int>(size_in_dip * gfx::ImageSkia::GetMaxSupportedScale()); } // Returns bitmap for the default icon with size equal to the default icon's @@ -133,7 +131,8 @@ SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { const gfx::ImageSkia& image = is_app ? extensions::IconsInfo::GetDefaultAppIcon() : extensions::IconsInfo::GetDefaultExtensionIcon(); - return image.GetRepresentation(ui::GetMaxScaleFactor()).sk_bitmap(); + return image.GetRepresentation( + gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); } // If auto confirm is enabled then posts a task to proceed with or cancel the diff --git a/chrome/browser/extensions/extension_uninstall_dialog.cc b/chrome/browser/extensions/extension_uninstall_dialog.cc index 0eb8dcf..fb6bc92 100644 --- a/chrome/browser/extensions/extension_uninstall_dialog.cc +++ b/chrome/browser/extensions/extension_uninstall_dialog.cc @@ -21,14 +21,14 @@ #include "grit/theme_resources.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" namespace { // Returns pixel size under maximal scale factor for the icon whose device // independent size is |size_in_dip| int GetSizeForMaxScaleFactor(int size_in_dip) { - ui::ScaleFactor max_scale_factor = ui::GetMaxScaleFactor(); - float max_scale_factor_scale = ui::GetScaleFactorScale(max_scale_factor); + float max_scale_factor_scale = gfx::ImageSkia::GetMaxSupportedScale(); return static_cast<int>(size_in_dip * max_scale_factor_scale); } @@ -39,7 +39,8 @@ SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { const gfx::ImageSkia& image = is_app ? extensions::IconsInfo::GetDefaultAppIcon() : extensions::IconsInfo::GetDefaultExtensionIcon(); - return image.GetRepresentation(ui::GetMaxScaleFactor()).sk_bitmap(); + return image.GetRepresentation( + gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); } } // namespace diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc index 40a4deb..631ba56 100644 --- a/chrome/browser/extensions/extension_web_ui.cc +++ b/chrome/browser/extensions/extension_web_ui.cc @@ -404,7 +404,7 @@ void ExtensionWebUI::GetFaviconForURL( FaviconUtil::GetFaviconScaleFactors(); std::vector<extensions::ImageLoader::ImageRepresentation> info_list; for (size_t i = 0; i < scale_factors.size(); ++i) { - float scale = ui::GetScaleFactorScale(scale_factors[i]); + float scale = ui::GetImageScale(scale_factors[i]); int pixel_size = static_cast<int>(gfx::kFaviconSize * scale); extensions::ExtensionResource icon_resource = extensions::IconsInfo::GetIconResource(extension, diff --git a/chrome/browser/extensions/image_loader.cc b/chrome/browser/extensions/image_loader.cc index 2e2702e..2c8f77c 100644 --- a/chrome/browser/extensions/image_loader.cc +++ b/chrome/browser/extensions/image_loader.cc @@ -334,7 +334,8 @@ void ImageLoader::ReplyBack( const ImageRepresentation& image_rep = it->image_representation; image_skia.AddRepresentation(gfx::ImageSkiaRep( - bitmap, image_rep.scale_factor)); + bitmap, + ui::GetImageScale(image_rep.scale_factor))); } gfx::Image image; diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc index 8eb1897..5e1459c 100644 --- a/chrome/browser/favicon/favicon_handler.cc +++ b/chrome/browser/favicon/favicon_handler.cc @@ -67,7 +67,7 @@ int GetMaximalIconSize(chrome::IconType icon_type) { base_size = 0; break; } - return ui::GetScaleFactorScale(ui::GetMaxScaleFactor()) * base_size; + return gfx::ImageSkia::GetMaxSupportedScale() * base_size; } bool DoUrlAndIconMatch(const FaviconURL& favicon_url, @@ -148,7 +148,7 @@ bool HasExpiredOrIncompleteResult( FaviconUtil::GetFaviconScaleFactors(); for (size_t i = 0; i < scale_factors.size(); ++i) { int edge_size_in_pixel = floor( - desired_size_in_dip * ui::GetScaleFactorScale(scale_factors[i])); + desired_size_in_dip * ui::GetImageScale(scale_factors[i])); std::vector<gfx::Size>::iterator it = std::find(favicon_sizes.begin(), favicon_sizes.end(), gfx::Size(edge_size_in_pixel, edge_size_in_pixel)); if (it == favicon_sizes.end()) diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc index d89d45f..5671b73 100644 --- a/chrome/browser/favicon/favicon_handler_unittest.cc +++ b/chrome/browser/favicon/favicon_handler_unittest.cc @@ -410,7 +410,8 @@ class FaviconHandlerTest : public ChromeRenderViewHostTestHarness { // results on all platforms. std::vector<ui::ScaleFactor> scale_factors; scale_factors.push_back(ui::SCALE_FACTOR_100P); - ui::test::SetSupportedScaleFactors(scale_factors); + scoped_set_supported_scale_factors_.reset( + new ui::test::ScopedSetSupportedScaleFactors(scale_factors)); ChromeRenderViewHostTestHarness::SetUp(); } @@ -424,6 +425,9 @@ class FaviconHandlerTest : public ChromeRenderViewHostTestHarness { } private: + typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> + ScopedSetSupportedScaleFactors; + ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; DISALLOW_COPY_AND_ASSIGN(FaviconHandlerTest); }; diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc index 555cdb1..fd0f9eb 100644 --- a/chrome/browser/favicon/favicon_service.cc +++ b/chrome/browser/favicon/favicon_service.cc @@ -238,7 +238,7 @@ void FaviconService::SetFavicons(const GURL& page_url, return; gfx::ImageSkia image_skia = image.AsImageSkia(); - image_skia.EnsureRepsForSupportedScaleFactors(); + image_skia.EnsureRepsForSupportedScales(); const std::vector<gfx::ImageSkiaRep>& image_reps = image_skia.image_reps(); std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; for (size_t i = 0; i < image_reps.size(); ++i) { @@ -343,7 +343,7 @@ void FaviconService::RunFaviconRawCallbackWithBitmapResults( } // If history bitmap is already desired pixel size, return early. - float desired_scale = ui::GetScaleFactorScale(desired_scale_factor); + float desired_scale = ui::GetImageScale(desired_scale_factor); int desired_edge_width_in_pixel = static_cast<int>( desired_size_in_dip * desired_scale + 0.5f); gfx::Size desired_size_in_pixel(desired_edge_width_in_pixel, diff --git a/chrome/browser/favicon/favicon_util.cc b/chrome/browser/favicon/favicon_util.cc index 4f2db61..a34ffca 100644 --- a/chrome/browser/favicon/favicon_util.cc +++ b/chrome/browser/favicon/favicon_util.cc @@ -43,18 +43,17 @@ std::vector<gfx::ImagePNGRep> SelectFaviconFramesFromPNGsWithoutResizing( best_candidate = png_data[i].bitmap_data; } } - png_reps.push_back(gfx::ImagePNGRep(best_candidate, - ui::SCALE_FACTOR_100P)); + png_reps.push_back(gfx::ImagePNGRep(best_candidate, 1.0f)); return png_reps; } // Cache the scale factor for each pixel size as |scale_factors| may contain // any of GetFaviconScaleFactors() which may include scale factors not - // supported by the platform. (ui::GetScaleFactorFromScale() cannot be used.) + // supported by the platform. (ui::GetSupportedScaleFactor() cannot be used.) std::map<int, ui::ScaleFactor> desired_pixel_sizes; for (size_t i = 0; i < scale_factors.size(); ++i) { int pixel_size = floor(favicon_size * - ui::GetScaleFactorScale(scale_factors[i])); + ui::GetImageScale(scale_factors[i])); desired_pixel_sizes[pixel_size] = scale_factors[i]; } @@ -71,7 +70,9 @@ std::vector<gfx::ImagePNGRep> SelectFaviconFramesFromPNGsWithoutResizing( if (it == desired_pixel_sizes.end()) continue; - png_reps.push_back(gfx::ImagePNGRep(png_data[i].bitmap_data, it->second)); + png_reps.push_back( + gfx::ImagePNGRep(png_data[i].bitmap_data, + ui::GetImageScale(it->second))); } return png_reps; @@ -137,7 +138,7 @@ SkBitmap ResizeBitmapByDownsamplingIfPossible( // static std::vector<ui::ScaleFactor> FaviconUtil::GetFaviconScaleFactors() { - const float kScale1x = ui::GetScaleFactorScale(ui::SCALE_FACTOR_100P); + const float kScale1x = ui::GetImageScale(ui::SCALE_FACTOR_100P); std::vector<ui::ScaleFactor> favicon_scale_factors = ui::GetSupportedScaleFactors(); @@ -146,7 +147,7 @@ std::vector<ui::ScaleFactor> FaviconUtil::GetFaviconScaleFactors() { // well. size_t insert_index = favicon_scale_factors.size(); for (size_t i = 0; i < favicon_scale_factors.size(); ++i) { - float scale = ui::GetScaleFactorScale(favicon_scale_factors[i]); + float scale = ui::GetImageScale(favicon_scale_factors[i]); if (scale == kScale1x) { return favicon_scale_factors; } else if (scale > kScale1x) { @@ -201,7 +202,7 @@ gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs( std::vector<ui::ScaleFactor>::iterator it = std::find( scale_factors_to_generate.begin(), scale_factors_to_generate.end(), - png_reps[i].scale_factor); + ui::GetSupportedScaleFactor(png_reps[i].scale)); CHECK(it != scale_factors_to_generate.end()); scale_factors_to_generate.erase(it); } @@ -229,7 +230,7 @@ gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs( for (size_t i = 0; i < scale_factors_to_generate.size(); ++i) { ui::ScaleFactor scale_factor = scale_factors_to_generate[i]; int desired_size_in_pixel = - ceil(favicon_size * ui::GetScaleFactorScale(scale_factor)); + ceil(favicon_size * ui::GetImageScale(scale_factor)); SkBitmap bitmap = ResizeBitmapByDownsamplingIfPossible( bitmaps, desired_size_in_pixel); resized_image_skia.AddRepresentation( @@ -246,7 +247,7 @@ gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs( if (gfx::PNGCodec::EncodeBGRASkBitmap( resized_image_skia_reps[i].sk_bitmap(), false, &png_bytes->data())) { png_reps.push_back(gfx::ImagePNGRep(png_bytes, - resized_image_skia_reps[i].scale_factor())); + resized_image_skia_reps[i].scale())); } } diff --git a/chrome/browser/history/select_favicon_frames.cc b/chrome/browser/history/select_favicon_frames.cc index 09bf8ff..43a1fa4 100644 --- a/chrome/browser/history/select_favicon_frames.cc +++ b/chrome/browser/history/select_favicon_frames.cc @@ -58,7 +58,7 @@ size_t GetCandidateIndexWithBestScore( ResizeMethod* resize_method) { DCHECK_NE(desired_size_in_dip, 0); - float scale = ui::GetScaleFactorScale(scale_factor); + float scale = ui::GetImageScale(scale_factor); int desired_size_in_pixel = static_cast<int>(desired_size_in_dip * scale + 0.5f); @@ -179,7 +179,7 @@ SkBitmap GetResizedBitmap(const SkBitmap& source_bitmap, int desired_size_in_dip, ui::ScaleFactor scale_factor, ResizeMethod resize_method) { - float scale = ui::GetScaleFactorScale(scale_factor); + float scale = ui::GetImageScale(scale_factor); int desired_size_in_pixel = static_cast<int>( desired_size_in_dip * scale + 0.5f); @@ -216,7 +216,8 @@ gfx::ImageSkia SelectFaviconFrames( SkBitmap resized_bitmap = GetResizedBitmap(bitmaps[result.index], desired_size, result.scale_factor, result.resize_method); multi_image.AddRepresentation( - gfx::ImageSkiaRep(resized_bitmap, result.scale_factor)); + gfx::ImageSkiaRep(resized_bitmap, + ui::GetImageScale(result.scale_factor))); } return multi_image; } diff --git a/chrome/browser/history/select_favicon_frames_unittest.cc b/chrome/browser/history/select_favicon_frames_unittest.cc index f79e773..6936ece 100644 --- a/chrome/browser/history/select_favicon_frames_unittest.cc +++ b/chrome/browser/history/select_favicon_frames_unittest.cc @@ -43,7 +43,8 @@ SkBitmap MakeBitmap(SkColor color, int w, int h) { SkColor GetColor(const gfx::ImageSkia& image, ui::ScaleFactor factor, int x = -1, int y = -1) { - const SkBitmap& bitmap = image.GetRepresentation(factor).sk_bitmap(); + const SkBitmap& bitmap = + image.GetRepresentation(ui::GetImageScale(factor)).sk_bitmap(); if (x == -1) x = bitmap.width() / 2; if (y == -1) @@ -71,7 +72,7 @@ TEST(SelectFaviconFramesTest, ZeroSizePicksLargest) { gfx::ImageSkia image = SelectFaviconFrames(bitmaps, SizesFromBitmaps(bitmaps), Scale1x(), 0, NULL); EXPECT_EQ(1u, image.image_reps().size()); - ASSERT_TRUE(image.HasRepresentation(ui::SCALE_FACTOR_100P)); + ASSERT_TRUE(image.HasRepresentation(1.0f)); EXPECT_EQ(48, image.width()); EXPECT_EQ(48, image.height()); @@ -87,7 +88,7 @@ TEST(SelectFaviconFramesTest, _16From16) { gfx::ImageSkia image = SelectFaviconFrames(bitmaps, SizesFromBitmaps(bitmaps), Scale1x(), 16, NULL); EXPECT_EQ(1u, image.image_reps().size()); - ASSERT_TRUE(image.HasRepresentation(ui::SCALE_FACTOR_100P)); + ASSERT_TRUE(image.HasRepresentation(1.0f)); EXPECT_EQ(16, image.width()); EXPECT_EQ(16, image.height()); EXPECT_EQ(SK_ColorGREEN, GetColor1x(image)); @@ -102,7 +103,7 @@ TEST(SelectFaviconFramesTest, _16From17) { gfx::ImageSkia image = SelectFaviconFrames(bitmaps, SizesFromBitmaps(bitmaps), Scale1x(), 16, NULL); EXPECT_EQ(1u, image.image_reps().size()); - ASSERT_TRUE(image.HasRepresentation(ui::SCALE_FACTOR_100P)); + ASSERT_TRUE(image.HasRepresentation(1.0f)); EXPECT_EQ(16, image.width()); EXPECT_EQ(16, image.height()); EXPECT_EQ(SK_ColorGREEN, GetColor1x(image)); @@ -118,7 +119,7 @@ TEST(SelectFaviconFramesTest, _16From15) { gfx::ImageSkia image = SelectFaviconFrames(bitmaps, SizesFromBitmaps(bitmaps), Scale1x(), 16, NULL); EXPECT_EQ(1u, image.image_reps().size()); - ASSERT_TRUE(image.HasRepresentation(ui::SCALE_FACTOR_100P)); + ASSERT_TRUE(image.HasRepresentation(1.0f)); EXPECT_EQ(16, image.width()); EXPECT_EQ(16, image.height()); EXPECT_EQ(SK_ColorGREEN, GetColor1x(image)); @@ -131,8 +132,8 @@ TEST(SelectFaviconFramesTest, _16From16_Scale2x_32_From_16) { gfx::ImageSkia image = SelectFaviconFrames(bitmaps, SizesFromBitmaps(bitmaps), Scale1x2x(), 16, NULL); EXPECT_EQ(2u, image.image_reps().size()); - ASSERT_TRUE(image.HasRepresentation(ui::SCALE_FACTOR_100P)); - ASSERT_TRUE(image.HasRepresentation(ui::SCALE_FACTOR_200P)); + ASSERT_TRUE(image.HasRepresentation(1.0f)); + ASSERT_TRUE(image.HasRepresentation(2.0f)); EXPECT_EQ(16, image.width()); EXPECT_EQ(16, image.height()); EXPECT_EQ(SK_ColorGREEN, GetColor1x(image)); @@ -147,8 +148,8 @@ TEST(SelectFaviconFramesTest, _16From16_Scale2x_32_From_32) { gfx::ImageSkia image = SelectFaviconFrames(bitmaps, SizesFromBitmaps(bitmaps), Scale1x2x(), 16, NULL); EXPECT_EQ(2u, image.image_reps().size()); - ASSERT_TRUE(image.HasRepresentation(ui::SCALE_FACTOR_100P)); - ASSERT_TRUE(image.HasRepresentation(ui::SCALE_FACTOR_200P)); + ASSERT_TRUE(image.HasRepresentation(1.0f)); + ASSERT_TRUE(image.HasRepresentation(2.0f)); EXPECT_EQ(16, image.width()); EXPECT_EQ(16, image.height()); EXPECT_EQ(SK_ColorGREEN, GetColor1x(image)); diff --git a/chrome/browser/profiles/profile_info_util.cc b/chrome/browser/profiles/profile_info_util.cc index ba01fc3..1f56b3d 100644 --- a/chrome/browser/profiles/profile_info_util.cc +++ b/chrome/browser/profiles/profile_info_util.cc @@ -23,7 +23,7 @@ gfx::Image GetSizedAvatarIconWithBorder(const gfx::Image& image, int length = std::min(width, height) - kAvatarIconBorder; SkBitmap bmp = skia::ImageOperations::Resize( *image.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST, length, length); - gfx::Canvas canvas(gfx::Size(width, height), ui::SCALE_FACTOR_100P, false); + gfx::Canvas canvas(gfx::Size(width, height), 1.0f, false); // Draw the icon centered on the canvas. int x = (width - length) / 2; @@ -52,8 +52,8 @@ gfx::Image GetAvatarIconForWebUI(const gfx::Image& image, std::min(kAvatarIconWidth, kAvatarIconHeight) - kAvatarIconBorder; SkBitmap bmp = skia::ImageOperations::Resize( *image.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST, length, length); - gfx::Canvas canvas(gfx::Size(kAvatarIconWidth, kAvatarIconHeight), - ui::SCALE_FACTOR_100P, false); + gfx::Canvas canvas( + gfx::Size(kAvatarIconWidth, kAvatarIconHeight), 1.0f, false); // Draw the icon centered on the canvas. int x = (kAvatarIconWidth - length) / 2; @@ -74,8 +74,7 @@ gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, std::min(dst_width, dst_height)) - kAvatarIconBorder; SkBitmap bmp = skia::ImageOperations::Resize( *image.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST, length, length); - gfx::Canvas canvas(gfx::Size(dst_width, dst_height), ui::SCALE_FACTOR_100P, - false); + gfx::Canvas canvas(gfx::Size(dst_width, dst_height), 1.0f, false); // Draw the icon on the bottom center of the canvas. int x1 = (dst_width - length) / 2; diff --git a/chrome/browser/speech/speech_recognition_bubble.cc b/chrome/browser/speech/speech_recognition_bubble.cc index e93c4ec..2b28dd9 100644 --- a/chrome/browser/speech/speech_recognition_bubble.cc +++ b/chrome/browser/speech/speech_recognition_bubble.cc @@ -95,7 +95,7 @@ SpeechRecognitionBubbleImages::SpeechRecognitionBubbleImages() { // render properly and gets vertically squished in Linux due to a bug in // Skia. Until that gets fixed we work around by taking a real copy of it // below as the copied image has the correct rowBytes and renders fine. - frame.EnsureRepsForSupportedScaleFactors(); + frame.EnsureRepsForSupportedScales(); std::vector<gfx::ImageSkiaRep> image_reps = frame.image_reps(); gfx::ImageSkia frame_copy; for (size_t i = 0; i < image_reps.size(); ++i) { @@ -103,7 +103,7 @@ SpeechRecognitionBubbleImages::SpeechRecognitionBubbleImages() { SkBitmap copy_dst; copy_src.copyTo(©_dst, SkBitmap::kARGB_8888_Config); frame_copy.AddRepresentation(gfx::ImageSkiaRep( - copy_dst, image_reps[i].scale_factor())); + copy_dst, image_reps[i].scale())); } spinner_.push_back(frame_copy); @@ -140,16 +140,15 @@ SpeechRecognitionBubbleBase::SpeechRecognitionBubbleBase( animation_step_(0), display_mode_(DISPLAY_MODE_RECORDING), web_contents_(web_contents), - scale_factor_(ui::SCALE_FACTOR_NONE) { + scale_(1.0f) { gfx::NativeView view = web_contents_ ? web_contents_->GetView()->GetNativeView() : NULL; gfx::Screen* screen = gfx::Screen::GetScreenFor(view); gfx::Display display = screen->GetDisplayNearestWindow(view); - scale_factor_ = ui::GetScaleFactorFromScale( - display.device_scale_factor()); + scale_ = display.device_scale_factor(); const gfx::ImageSkiaRep& rep = - g_images.Get().mic_empty()->GetRepresentation(scale_factor_); + g_images.Get().mic_empty()->GetRepresentation(scale_); mic_image_.reset(new SkBitmap()); mic_image_->setConfig(SkBitmap::kARGB_8888_Config, rep.pixel_width(), rep.pixel_height()); @@ -235,13 +234,12 @@ void SpeechRecognitionBubbleBase::DrawVolumeOverlay(SkCanvas* canvas, (((1.0f - volume) * (width * (kVolumeSteps + 1))) - width) / kVolumeSteps; buffer_canvas.clipRect(SkRect::MakeLTRB(0, 0, SkIntToScalar(width) - clip_right, SkIntToScalar(height))); - buffer_canvas.drawBitmap( - image.GetRepresentation(scale_factor_).sk_bitmap(), 0, 0); + buffer_canvas.drawBitmap(image.GetRepresentation(scale_).sk_bitmap(), 0, 0); buffer_canvas.restore(); SkPaint multiply_paint; multiply_paint.setXfermodeMode(SkXfermode::kModulate_Mode); buffer_canvas.drawBitmap( - g_images.Get().mic_mask()->GetRepresentation(scale_factor_).sk_bitmap(), + g_images.Get().mic_mask()->GetRepresentation(scale_).sk_bitmap(), -clip_right, 0, &multiply_paint); canvas->drawBitmap(*buffer_image_.get(), 0, 0); @@ -255,12 +253,12 @@ void SpeechRecognitionBubbleBase::SetInputVolume(float volume, // Draw the empty volume image first and the current volume image on top, // and then the noise volume image on top of both. canvas.drawBitmap( - g_images.Get().mic_empty()->GetRepresentation(scale_factor_).sk_bitmap(), + g_images.Get().mic_empty()->GetRepresentation(scale_).sk_bitmap(), 0, 0); DrawVolumeOverlay(&canvas, *g_images.Get().mic_full(), volume); DrawVolumeOverlay(&canvas, *g_images.Get().mic_noise(), noise_volume); - gfx::ImageSkia image(gfx::ImageSkiaRep(*mic_image_.get(), scale_factor_)); + gfx::ImageSkia image(gfx::ImageSkiaRep(*mic_image_.get(), scale_)); SetImage(image); } diff --git a/chrome/browser/speech/speech_recognition_bubble.h b/chrome/browser/speech/speech_recognition_bubble.h index 2bb911f..08a741e 100644 --- a/chrome/browser/speech/speech_recognition_bubble.h +++ b/chrome/browser/speech/speech_recognition_bubble.h @@ -184,7 +184,7 @@ class SpeechRecognitionBubbleBase : public SpeechRecognitionBubble { // The current image displayed in the bubble's icon widget. gfx::ImageSkia icon_image_; // The scale factor used for the web-contents. - ui::ScaleFactor scale_factor_; + float scale_; DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionBubbleBase); }; diff --git a/chrome/browser/sync/test/integration/bookmarks_helper.cc b/chrome/browser/sync/test/integration/bookmarks_helper.cc index a59c28c..6340788 100644 --- a/chrome/browser/sync/test/integration/bookmarks_helper.cc +++ b/chrome/browser/sync/test/integration/bookmarks_helper.cc @@ -292,9 +292,9 @@ bool FaviconsMatch(BookmarkModel* model_a, // Compare only the 1x bitmaps as only those are synced. SkBitmap bitmap_a = image_a.AsImageSkia().GetRepresentation( - ui::SCALE_FACTOR_100P).sk_bitmap(); + 1.0f).sk_bitmap(); SkBitmap bitmap_b = image_b.AsImageSkia().GetRepresentation( - ui::SCALE_FACTOR_100P).sk_bitmap(); + 1.0f).sk_bitmap(); return FaviconBitmapsMatch(bitmap_a, bitmap_b); } @@ -714,14 +714,16 @@ gfx::Image CreateFavicon(SkColor color) { FaviconUtil::GetFaviconScaleFactors(); gfx::ImageSkia favicon; for (size_t i = 0; i < favicon_scale_factors.size(); ++i) { - float scale = ui::GetScaleFactorScale(favicon_scale_factors[i]); + float scale = ui::GetImageScale(favicon_scale_factors[i]); int pixel_width = dip_width * scale; int pixel_height = dip_height * scale; SkBitmap bmp; bmp.setConfig(SkBitmap::kARGB_8888_Config, pixel_width, pixel_height); bmp.allocPixels(); bmp.eraseColor(color); - favicon.AddRepresentation(gfx::ImageSkiaRep(bmp, favicon_scale_factors[i])); + favicon.AddRepresentation( + gfx::ImageSkiaRep(bmp, + ui::GetImageScale(favicon_scale_factors[i]))); } return gfx::Image(favicon); } diff --git a/chrome/browser/sync/test/integration/single_client_bookmarks_sync_test.cc b/chrome/browser/sync/test/integration/single_client_bookmarks_sync_test.cc index 83ca050..771b1a6 100644 --- a/chrome/browser/sync/test/integration/single_client_bookmarks_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_bookmarks_sync_test.cc @@ -163,7 +163,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, std::vector<ui::ScaleFactor> supported_scale_factors; supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); supported_scale_factors.push_back(ui::SCALE_FACTOR_200P); - ui::test::SetSupportedScaleFactors(supported_scale_factors); + ui::SetSupportedScaleFactors(supported_scale_factors); ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; ASSERT_TRUE(ModelMatchesVerifier(0)); diff --git a/chrome/browser/sync/test/integration/two_client_bookmarks_sync_test.cc b/chrome/browser/sync/test/integration/two_client_bookmarks_sync_test.cc index 171f0f5..367f209 100644 --- a/chrome/browser/sync/test/integration/two_client_bookmarks_sync_test.cc +++ b/chrome/browser/sync/test/integration/two_client_bookmarks_sync_test.cc @@ -165,7 +165,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_SetFaviconHiDPI) { std::vector<ui::ScaleFactor> supported_scale_factors; supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); supported_scale_factors.push_back(ui::SCALE_FACTOR_200P); - ui::test::SetSupportedScaleFactors(supported_scale_factors); + ui::SetSupportedScaleFactors(supported_scale_factors); const GURL page_url(kGenericURL); const GURL icon_url1("http://www.google.com/favicon1.ico"); diff --git a/chrome/browser/task_manager/browser_process_resource_provider.cc b/chrome/browser/task_manager/browser_process_resource_provider.cc index 21cec0b..6d898b7 100644 --- a/chrome/browser/task_manager/browser_process_resource_provider.cc +++ b/chrome/browser/task_manager/browser_process_resource_provider.cc @@ -40,8 +40,7 @@ BrowserProcessResource::BrowserProcessResource() HICON icon = GetAppIcon(); if (icon) { scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(icon)); - default_icon_ = new gfx::ImageSkia( - gfx::ImageSkiaRep(*bitmap, ui::SCALE_FACTOR_100P)); + default_icon_ = new gfx::ImageSkia(gfx::ImageSkiaRep(*bitmap, 1.0f)); } } #elif defined(OS_POSIX) && !defined(OS_MACOSX) diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index 988450e..6f163af 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -245,7 +245,7 @@ bool InputScalesValid(const base::StringPiece& input, // Do a memcpy to avoid misaligned memory access. memcpy(scales.get(), input.data(), input.size()); for (size_t index = 0; index < scales_size; ++index) { - if (scales[index] != ui::GetScaleFactorScale(expected[index])) + if (scales[index] != ui::GetImageScale(expected[index])) return false; } return true; @@ -256,7 +256,7 @@ std::string GetScaleFactorsAsString( const std::vector<ui::ScaleFactor>& scale_factors) { scoped_ptr<float[]> scales(new float[scale_factors.size()]); for (size_t i = 0; i < scale_factors.size(); ++i) - scales[i] = ui::GetScaleFactorScale(scale_factors[i]); + scales[i] = ui::GetImageScale(scale_factors[i]); std::string out_string = std::string( reinterpret_cast<const char*>(scales.get()), scale_factors.size() * sizeof(float)); @@ -452,8 +452,8 @@ SkBitmap CreateLowQualityResizedBitmap(const SkBitmap& source_bitmap, gfx::Size scaled_size = gfx::ToCeiledSize( gfx::ScaleSize(gfx::Size(source_bitmap.width(), source_bitmap.height()), - ui::GetScaleFactorScale(desired_scale_factor) / - ui::GetScaleFactorScale(source_scale_factor))); + ui::GetImageScale(desired_scale_factor) / + ui::GetImageScale(source_scale_factor))); SkBitmap scaled_bitmap; scaled_bitmap.setConfig(SkBitmap::kARGB_8888_Config, scaled_size.width(), @@ -477,17 +477,15 @@ class ThemeImageSource: public gfx::ImageSkiaSource { } virtual ~ThemeImageSource() {} - virtual gfx::ImageSkiaRep GetImageForScale( - ui::ScaleFactor scale_factor) OVERRIDE { - if (source_.HasRepresentation(scale_factor)) - return source_.GetRepresentation(scale_factor); - const gfx::ImageSkiaRep& rep_100p = - source_.GetRepresentation(ui::SCALE_FACTOR_100P); + virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { + if (source_.HasRepresentation(scale)) + return source_.GetRepresentation(scale); + const gfx::ImageSkiaRep& rep_100p = source_.GetRepresentation(1.0f); SkBitmap scaled_bitmap = CreateLowQualityResizedBitmap( rep_100p.sk_bitmap(), ui::SCALE_FACTOR_100P, - scale_factor); - return gfx::ImageSkiaRep(scaled_bitmap, scale_factor); + ui::GetSupportedScaleFactor(scale)); + return gfx::ImageSkiaRep(scaled_bitmap, scale); } private: @@ -509,13 +507,13 @@ class ThemeImagePngSource : public gfx::ImageSkiaSource { virtual ~ThemeImagePngSource() {} private: - virtual gfx::ImageSkiaRep GetImageForScale( - ui::ScaleFactor scale_factor) OVERRIDE { + virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { + ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactor(scale); // Look up the bitmap for |scale factor| in the bitmap map. If found // return it. BitmapMap::const_iterator exact_bitmap_it = bitmap_map_.find(scale_factor); if (exact_bitmap_it != bitmap_map_.end()) - return gfx::ImageSkiaRep(exact_bitmap_it->second, scale_factor); + return gfx::ImageSkiaRep(exact_bitmap_it->second, scale); // Look up the raw PNG data for |scale_factor| in the png map. If found, // decode it, store the result in the bitmap map and return it. @@ -529,7 +527,7 @@ class ThemeImagePngSource : public gfx::ImageSkiaSource { return gfx::ImageSkiaRep(); } bitmap_map_[scale_factor] = bitmap; - return gfx::ImageSkiaRep(bitmap, scale_factor); + return gfx::ImageSkiaRep(bitmap, scale); } // Find an available PNG for another scale factor. We want to use the @@ -538,8 +536,8 @@ class ThemeImagePngSource : public gfx::ImageSkiaSource { for (PngMap::const_iterator png_it = png_map_.begin(); png_it != png_map_.end(); ++png_it) { if (available_png_it == png_map_.end() || - ui::GetScaleFactorScale(png_it->first) > - ui::GetScaleFactorScale(available_png_it->first)) { + ui::GetImageScale(png_it->first) > + ui::GetImageScale(available_png_it->first)) { available_png_it = png_it; } } @@ -571,7 +569,7 @@ class ThemeImagePngSource : public gfx::ImageSkiaSource { available_scale_factor, scale_factor); bitmap_map_[scale_factor] = scaled_bitmap; - return gfx::ImageSkiaRep(scaled_bitmap, scale_factor); + return gfx::ImageSkiaRep(scaled_bitmap, scale); } PngMap png_map_; @@ -1285,7 +1283,8 @@ bool BrowserThemePack::LoadRawBitmapsTo( if (gfx::PNGCodec::Decode(raw_data->front(), raw_data->size(), &bitmap)) { image_skia.AddRepresentation( - gfx::ImageSkiaRep(bitmap, scale_factor)); + gfx::ImageSkiaRep(bitmap, + ui::GetImageScale(scale_factor))); } else { NOTREACHED() << "Unable to decode theme image resource " << it->first; @@ -1473,7 +1472,9 @@ void BrowserThemePack::RepackImages(const ImageCache& images, NOTREACHED() << "Image file for resource " << it->first << " could not be encoded."; } - int raw_id = GetRawIDByPersistentID(it->first, rep_it->scale_factor()); + int raw_id = GetRawIDByPersistentID( + it->first, + ui::GetSupportedScaleFactor(rep_it->scale())); (*reencoded_images)[raw_id] = base::RefCountedBytes::TakeVector(&bitmap_data); } @@ -1533,7 +1534,7 @@ bool BrowserThemePack::GetScaleFactorFromManifestKey( if (base::StringToInt(key, &percent)) { float scale = static_cast<float>(percent) / 100.0f; for (size_t i = 0; i < scale_factors_.size(); ++i) { - if (fabs(ui::GetScaleFactorScale(scale_factors_[i]) - scale) < 0.001) { + if (fabs(ui::GetImageScale(scale_factors_[i]) - scale) < 0.001) { *scale_factor = scale_factors_[i]; return true; } @@ -1570,8 +1571,8 @@ void BrowserThemePack::GenerateRawImageForAllSupportedScales(int prs_id) { for (size_t i = 0; i < scale_factors_.size(); ++i) { int raw_id = GetRawIDByPersistentID(prs_id, scale_factors_[i]); if ((available_scale_factor == ui::SCALE_FACTOR_NONE || - (ui::GetScaleFactorScale(scale_factors_[i]) > - ui::GetScaleFactorScale(available_scale_factor))) && + (ui::GetImageScale(scale_factors_[i]) > + ui::GetImageScale(available_scale_factor))) && image_memory_.find(raw_id) != image_memory_.end()) { available_scale_factor = scale_factors_[i]; } diff --git a/chrome/browser/themes/browser_theme_pack_unittest.cc b/chrome/browser/themes/browser_theme_pack_unittest.cc index b2fd658..7d41e55 100644 --- a/chrome/browser/themes/browser_theme_pack_unittest.cc +++ b/chrome/browser/themes/browser_theme_pack_unittest.cc @@ -36,8 +36,13 @@ class BrowserThemePackTest : public ::testing::Test { BrowserThemePackTest() : message_loop(), fake_ui_thread(BrowserThread::UI, &message_loop), - fake_file_thread(BrowserThread::FILE, &message_loop), - theme_pack_(new BrowserThemePack) { + fake_file_thread(BrowserThread::FILE, &message_loop) { + std::vector<ui::ScaleFactor> scale_factors; + scale_factors.push_back(ui::SCALE_FACTOR_100P); + scale_factors.push_back(ui::SCALE_FACTOR_200P); + scoped_set_supported_scale_factors_.reset( + new ui::test::ScopedSetSupportedScaleFactors(scale_factors)); + theme_pack_ = new BrowserThemePack(); } // Transformation for link underline colors. @@ -270,8 +275,7 @@ class BrowserThemePackTest : public ::testing::Test { const gfx::ImageSkia* image_skia = image.ToImageSkia(); ASSERT_TRUE(image_skia); // Scale 100%. - const gfx::ImageSkiaRep& rep1 = image_skia->GetRepresentation( - ui::SCALE_FACTOR_100P); + const gfx::ImageSkiaRep& rep1 = image_skia->GetRepresentation(1.0f); ASSERT_FALSE(rep1.is_null()); EXPECT_EQ(80, rep1.sk_bitmap().width()); EXPECT_EQ(80, rep1.sk_bitmap().height()); @@ -283,8 +287,7 @@ class BrowserThemePackTest : public ::testing::Test { EXPECT_EQ(SkColorSetRGB( 0, 241, 237), rep1.sk_bitmap().getColor(32, 32)); rep1.sk_bitmap().unlockPixels(); // Scale 200%. - const gfx::ImageSkiaRep& rep2 = image_skia->GetRepresentation( - ui::SCALE_FACTOR_200P); + const gfx::ImageSkiaRep& rep2 = image_skia->GetRepresentation(2.0f); ASSERT_FALSE(rep2.is_null()); EXPECT_EQ(160, rep2.sk_bitmap().width()); EXPECT_EQ(160, rep2.sk_bitmap().height()); @@ -312,8 +315,7 @@ class BrowserThemePackTest : public ::testing::Test { image_skia = image.ToImageSkia(); ASSERT_TRUE(image_skia); // Scale 100%. - const gfx::ImageSkiaRep& rep3 = image_skia->GetRepresentation( - ui::SCALE_FACTOR_100P); + const gfx::ImageSkiaRep& rep3 = image_skia->GetRepresentation(1.0f); ASSERT_FALSE(rep3.is_null()); EXPECT_EQ(80, rep3.sk_bitmap().width()); EXPECT_EQ(80, rep3.sk_bitmap().height()); @@ -335,8 +337,7 @@ class BrowserThemePackTest : public ::testing::Test { EXPECT_EQ(static_cast<size_t>(9), normal.size()); rep3.sk_bitmap().unlockPixels(); // Scale 200%. - const gfx::ImageSkiaRep& rep4 = image_skia->GetRepresentation( - ui::SCALE_FACTOR_200P); + const gfx::ImageSkiaRep& rep4 = image_skia->GetRepresentation(2.0f); ASSERT_FALSE(rep4.is_null()); EXPECT_EQ(160, rep4.sk_bitmap().width()); EXPECT_EQ(160, rep4.sk_bitmap().height()); @@ -355,6 +356,9 @@ class BrowserThemePackTest : public ::testing::Test { content::TestBrowserThread fake_ui_thread; content::TestBrowserThread fake_file_thread; + typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> + ScopedSetSupportedScaleFactors; + ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; scoped_refptr<BrowserThemePack> theme_pack_; }; @@ -584,10 +588,6 @@ TEST_F(BrowserThemePackTest, CanBuildAndReadPack) { } TEST_F(BrowserThemePackTest, HiDpiThemeTest) { - std::vector<ui::ScaleFactor> scale_factors; - scale_factors.push_back(ui::SCALE_FACTOR_100P); - scale_factors.push_back(ui::SCALE_FACTOR_200P); - ui::test::ScopedSetSupportedScaleFactors test_scale_factors(scale_factors); base::ScopedTempDir dir; ASSERT_TRUE(dir.CreateUniqueTempDir()); base::FilePath file = dir.path().AppendASCII("theme_data.pak"); diff --git a/chrome/browser/thumbnails/content_analysis_unittest.cc b/chrome/browser/thumbnails/content_analysis_unittest.cc index dc8f2c8..a45708d 100644 --- a/chrome/browser/thumbnails/content_analysis_unittest.cc +++ b/chrome/browser/thumbnails/content_analysis_unittest.cc @@ -78,7 +78,7 @@ class ThumbnailContentAnalysisTest : public testing::Test { }; TEST_F(ThumbnailContentAnalysisTest, ApplyGradientMagnitudeOnImpulse) { - gfx::Canvas canvas(gfx::Size(800, 600), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(800, 600), 1.0f, true); // The image consists of vertical non-overlapping stripes 100 pixels wide. canvas.FillRect(gfx::Rect(0, 0, 800, 600), SkColorSetARGB(0, 10, 10, 10)); @@ -129,7 +129,7 @@ TEST_F(ThumbnailContentAnalysisTest, ApplyGradientMagnitudeOnImpulse) { #define MAYBE_ApplyGradientMagnitudeOnFrame ApplyGradientMagnitudeOnFrame #endif TEST_F(ThumbnailContentAnalysisTest, MAYBE_ApplyGradientMagnitudeOnFrame) { - gfx::Canvas canvas(gfx::Size(800, 600), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(800, 600), 1.0f, true); // The image consists of a single white block in the centre. gfx::Rect draw_rect(300, 200, 200, 200); @@ -168,7 +168,7 @@ TEST_F(ThumbnailContentAnalysisTest, MAYBE_ApplyGradientMagnitudeOnFrame) { } TEST_F(ThumbnailContentAnalysisTest, ExtractImageProfileInformation) { - gfx::Canvas canvas(gfx::Size(800, 600), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(800, 600), 1.0f, true); // The image consists of a white frame drawn in the centre. gfx::Rect draw_rect(100, 100, 200, 100); @@ -240,7 +240,7 @@ TEST_F(ThumbnailContentAnalysisTest, ExtractImageProfileInformation) { #endif TEST_F(ThumbnailContentAnalysisTest, MAYBE_ExtractImageProfileInformationWithClosing) { - gfx::Canvas canvas(gfx::Size(800, 600), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(800, 600), 1.0f, true); // The image consists of a two white frames drawn side by side, with a // single-pixel vertical gap in between. @@ -575,7 +575,7 @@ TEST_F(ThumbnailContentAnalysisTest, ConstrainedProfileSegmentation) { TEST_F(ThumbnailContentAnalysisTest, ComputeDecimatedImage) { gfx::Size image_size(1600, 1200); - gfx::Canvas canvas(image_size, ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(image_size, 1.0f, true); // Make some content we will later want to keep. canvas.FillRect(gfx::Rect(100, 200, 100, 100), SkColorSetARGB(0, 125, 0, 0)); @@ -625,7 +625,7 @@ TEST_F(ThumbnailContentAnalysisTest, ComputeDecimatedImage) { TEST_F(ThumbnailContentAnalysisTest, CreateRetargetedThumbnailImage) { gfx::Size image_size(1200, 1300); - gfx::Canvas canvas(image_size, ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(image_size, 1.0f, true); // The following will create a 'fake image' consisting of color blocks placed // on a neutral background. The entire layout is supposed to mimic a diff --git a/chrome/browser/thumbnails/content_based_thumbnailing_algorithm_unittest.cc b/chrome/browser/thumbnails/content_based_thumbnailing_algorithm_unittest.cc index 07e033f..1e8eae7 100644 --- a/chrome/browser/thumbnails/content_based_thumbnailing_algorithm_unittest.cc +++ b/chrome/browser/thumbnails/content_based_thumbnailing_algorithm_unittest.cc @@ -134,7 +134,7 @@ TEST_F(ContentBasedThumbnailingAlgorithmTest, CreateRetargetedThumbnail) { // This tests the invocation of the main thumbnail-making apparatus. // The actual content is not really of concern here, just check the plumbing. const gfx::Size image_size(1200, 800); - gfx::Canvas canvas(image_size, ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(image_size, 1.0f, true); // The image consists of vertical non-overlapping stripes 150 pixels wide. canvas.FillRect(gfx::Rect(200, 200, 800, 400), SkColorSetRGB(255, 255, 255)); diff --git a/chrome/browser/thumbnails/render_widget_snapshot_taker.cc b/chrome/browser/thumbnails/render_widget_snapshot_taker.cc index da2606c..f9e2263 100644 --- a/chrome/browser/thumbnails/render_widget_snapshot_taker.cc +++ b/chrome/browser/thumbnails/render_widget_snapshot_taker.cc @@ -45,7 +45,7 @@ void RenderWidgetSnapshotTaker::AskForSnapshot( // this callback for later lookup when the rendering is done. static int sequence_num = 0; sequence_num++; - float scale_factor = ui::GetScaleFactorScale(ui::GetScaleFactorForNativeView( + float scale_factor = ui::GetImageScale(ui::GetScaleFactorForNativeView( renderer->GetView()->GetNativeView())); gfx::Size desired_size_in_pixel = gfx::ToFlooredSize( gfx::ScaleSize(desired_size, scale_factor)); diff --git a/chrome/browser/thumbnails/render_widget_snapshot_taker_unittest.cc b/chrome/browser/thumbnails/render_widget_snapshot_taker_unittest.cc index 5a33ed1..d44a69b 100644 --- a/chrome/browser/thumbnails/render_widget_snapshot_taker_unittest.cc +++ b/chrome/browser/thumbnails/render_widget_snapshot_taker_unittest.cc @@ -75,7 +75,8 @@ TEST_F(RenderWidgetSnapshotTakerTest, size); EXPECT_EQ(1U, snapshot_taker.callback_map_.size()); const int sequence_num = 1; - const gfx::Size size2(200, 200); + // Ensure this is bigger than the max scale factor X the size. + const gfx::Size size2(300, 300); snapshot_taker.WidgetDidReceivePaintAtSizeAck( content::RenderViewHostTestHarness::rvh(), sequence_num, diff --git a/chrome/browser/thumbnails/simple_thumbnail_crop.cc b/chrome/browser/thumbnails/simple_thumbnail_crop.cc index c427b90..b2128ef 100644 --- a/chrome/browser/thumbnails/simple_thumbnail_crop.cc +++ b/chrome/browser/thumbnails/simple_thumbnail_crop.cc @@ -8,6 +8,7 @@ #include "content/public/browser/browser_thread.h" #include "skia/ext/platform_canvas.h" #include "ui/gfx/color_utils.h" +#include "ui/gfx/image/image_skia.h" #include "ui/gfx/screen.h" #include "ui/gfx/scrollbar_size.h" #include "ui/gfx/size_conversions.h" @@ -121,7 +122,7 @@ gfx::Size SimpleThumbnailCrop::GetCopySizeForThumbnail( switch (scale_factor) { case ui::SCALE_FACTOR_100P: copy_size = gfx::ToFlooredSize(gfx::ScaleSize( - copy_size, ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P))); + copy_size, ui::GetImageScale(ui::SCALE_FACTOR_200P))); break; case ui::SCALE_FACTOR_200P: // Use the size as-is. @@ -130,7 +131,7 @@ gfx::Size SimpleThumbnailCrop::GetCopySizeForThumbnail( DLOG(WARNING) << "Unsupported scale factor. Use the same copy size as " << "ui::SCALE_FACTOR_100P"; copy_size = gfx::ToFlooredSize(gfx::ScaleSize( - copy_size, ui::GetMaxScaleFactor())); + copy_size, gfx::ImageSkia::GetMaxSupportedScale())); break; } return copy_size; @@ -183,8 +184,7 @@ gfx::Size SimpleThumbnailCrop::ComputeTargetSizeAtMaximumScale( const gfx::Size& given_size) { // TODO(mazda|oshima): Update thumbnail when the max scale factor changes. // crbug.com/159157. - float max_scale_factor = - ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); + float max_scale_factor = gfx::ImageSkia::GetMaxSupportedScale(); return gfx::ToFlooredSize(gfx::ScaleSize(given_size, max_scale_factor)); } diff --git a/chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc b/chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc index b0324a4..c00abb2 100644 --- a/chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc +++ b/chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc @@ -30,7 +30,7 @@ TEST_F(SimpleThumbnailCropTest, CalculateBoringScore_Empty) { TEST_F(SimpleThumbnailCropTest, CalculateBoringScore_SingleColor) { const gfx::Size kSize(20, 10); - gfx::Canvas canvas(kSize, ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(kSize, 1.0f, true); // Fill all pixels in black. canvas.FillRect(gfx::Rect(kSize), SK_ColorBLACK); @@ -43,7 +43,7 @@ TEST_F(SimpleThumbnailCropTest, CalculateBoringScore_SingleColor) { TEST_F(SimpleThumbnailCropTest, CalculateBoringScore_TwoColors) { const gfx::Size kSize(20, 10); - gfx::Canvas canvas(kSize, ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(kSize, 1.0f, true); // Fill all pixels in black. canvas.FillRect(gfx::Rect(kSize), SK_ColorBLACK); // Fill the left half pixels in white. @@ -60,7 +60,7 @@ TEST_F(SimpleThumbnailCropTest, CalculateBoringScore_TwoColors) { TEST_F(SimpleThumbnailCropTest, GetClippedBitmap_TallerThanWide) { // The input bitmap is vertically long. - gfx::Canvas canvas(gfx::Size(40, 90), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(40, 90), 1.0f, true); SkBitmap bitmap = skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); @@ -77,7 +77,7 @@ TEST_F(SimpleThumbnailCropTest, GetClippedBitmap_TallerThanWide) { TEST_F(SimpleThumbnailCropTest, GetClippedBitmap_WiderThanTall) { // The input bitmap is horizontally long. - gfx::Canvas canvas(gfx::Size(70, 40), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(70, 40), 1.0f, true); SkBitmap bitmap = skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); @@ -94,7 +94,7 @@ TEST_F(SimpleThumbnailCropTest, GetClippedBitmap_WiderThanTall) { TEST_F(SimpleThumbnailCropTest, GetClippedBitmap_TooWiderThanTall) { // The input bitmap is horizontally very long. - gfx::Canvas canvas(gfx::Size(90, 40), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(90, 40), 1.0f, true); SkBitmap bitmap = skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); @@ -111,7 +111,7 @@ TEST_F(SimpleThumbnailCropTest, GetClippedBitmap_TooWiderThanTall) { TEST_F(SimpleThumbnailCropTest, GetClippedBitmap_NotClipped) { // The input bitmap is square. - gfx::Canvas canvas(gfx::Size(40, 40), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(40, 40), 1.0f, true); SkBitmap bitmap = skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); @@ -128,7 +128,7 @@ TEST_F(SimpleThumbnailCropTest, GetClippedBitmap_NotClipped) { TEST_F(SimpleThumbnailCropTest, GetClippedBitmap_NonSquareOutput) { // The input bitmap is square. - gfx::Canvas canvas(gfx::Size(40, 40), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(40, 40), 1.0f, true); SkBitmap bitmap = skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false); diff --git a/chrome/browser/ui/app_list/fast_show_pickler.cc b/chrome/browser/ui/app_list/fast_show_pickler.cc index 2ef48ef..d282aab 100644 --- a/chrome/browser/ui/app_list/fast_show_pickler.cc +++ b/chrome/browser/ui/app_list/fast_show_pickler.cc @@ -88,7 +88,7 @@ bool PickleImage(Pickle* pickle, const gfx::ImageSkia& image) { pickle->WriteInt(static_cast<int>(reps.size())); for (std::vector<gfx::ImageSkiaRep>::const_iterator it = reps.begin(); it != reps.end(); ++it) { - pickle->WriteInt(static_cast<int>(it->scale_factor())); + pickle->WriteInt(static_cast<int>(ui::GetSupportedScaleFactor(it->scale()))); pickle->WriteInt(it->pixel_width()); pickle->WriteInt(it->pixel_height()); ImageFormat format = NONE; @@ -147,8 +147,8 @@ bool UnpickleImage(PickleIterator* it, gfx::ImageSkia* out) { SkAutoLockPixels lock(bitmap); memcpy(bitmap.getPixels(), pixels, bitmap.getSize()); } - result.AddRepresentation( - gfx::ImageSkiaRep(bitmap, static_cast<ui::ScaleFactor>(scale_factor))); + float scale = ui::GetImageScale(static_cast<ui::ScaleFactor>(scale_factor)); + result.AddRepresentation(gfx::ImageSkiaRep(bitmap, scale)); } *out = result; diff --git a/chrome/browser/ui/app_list/search/common/url_icon_source.cc b/chrome/browser/ui/app_list/search/common/url_icon_source.cc index 443da12..acb2d28 100644 --- a/chrome/browser/ui/app_list/search/common/url_icon_source.cc +++ b/chrome/browser/ui/app_list/search/common/url_icon_source.cc @@ -47,17 +47,15 @@ void UrlIconSource::StartIconFetch() { icon_fetcher_->Start(); } -gfx::ImageSkiaRep UrlIconSource::GetImageForScale( - ui::ScaleFactor scale_factor) { +gfx::ImageSkiaRep UrlIconSource::GetImageForScale(float scale) { if (!icon_fetch_attempted_) StartIconFetch(); if (!icon_.isNull()) - return icon_.GetRepresentation(scale_factor); + return icon_.GetRepresentation(scale); return ui::ResourceBundle::GetSharedInstance() - .GetImageSkiaNamed(default_icon_resource_id_)->GetRepresentation( - scale_factor); + .GetImageSkiaNamed(default_icon_resource_id_)->GetRepresentation(scale); } void UrlIconSource::OnURLFetchComplete( diff --git a/chrome/browser/ui/app_list/search/common/url_icon_source.h b/chrome/browser/ui/app_list/search/common/url_icon_source.h index de94f28..32465e8 100644 --- a/chrome/browser/ui/app_list/search/common/url_icon_source.h +++ b/chrome/browser/ui/app_list/search/common/url_icon_source.h @@ -45,8 +45,7 @@ class UrlIconSource : public gfx::ImageSkiaSource, void StartIconFetch(); // gfx::ImageSkiaSource overrides: - virtual gfx::ImageSkiaRep GetImageForScale( - ui::ScaleFactor scale_factor) OVERRIDE; + virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE; // net::URLFetcherDelegate overrides: virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; diff --git a/chrome/browser/ui/app_list/search/people/people_result.cc b/chrome/browser/ui/app_list/search/people/people_result.cc index e4394c0..01e54cf 100644 --- a/chrome/browser/ui/app_list/search/people/people_result.cc +++ b/chrome/browser/ui/app_list/search/people/people_result.cc @@ -95,7 +95,7 @@ void PeopleResult::OnIconLoaded() { // need to be re-created. const std::vector<gfx::ImageSkiaRep>& image_reps = image_.image_reps(); for (size_t i = 0; i < image_reps.size(); ++i) - image_.RemoveRepresentation(image_reps[i].scale_factor()); + image_.RemoveRepresentation(image_reps[i].scale()); SetIcon(image_); } diff --git a/chrome/browser/ui/app_list/search/webstore/webstore_result.cc b/chrome/browser/ui/app_list/search/webstore/webstore_result.cc index 27310c2..56c4a2d 100644 --- a/chrome/browser/ui/app_list/search/webstore/webstore_result.cc +++ b/chrome/browser/ui/app_list/search/webstore/webstore_result.cc @@ -147,7 +147,7 @@ void WebstoreResult::OnIconLoaded() { // need to be re-created. const std::vector<gfx::ImageSkiaRep>& image_reps = icon_.image_reps(); for (size_t i = 0; i < image_reps.size(); ++i) - icon_.RemoveRepresentation(image_reps[i].scale_factor()); + icon_.RemoveRepresentation(image_reps[i].scale()); icon_ = gfx::ImageSkia(new BadgedIconSource(icon_), gfx::Size(kIconSize, kIconSize)); diff --git a/chrome/browser/ui/app_list/test/fast_show_pickler_unittest.cc b/chrome/browser/ui/app_list/test/fast_show_pickler_unittest.cc index 56a8f48..6f2d8da 100644 --- a/chrome/browser/ui/app_list/test/fast_show_pickler_unittest.cc +++ b/chrome/browser/ui/app_list/test/fast_show_pickler_unittest.cc @@ -39,7 +39,7 @@ class AppListModelPicklerUnitTest : public testing::Test { for (size_t i = 0; i < reps1.size(); ++i) { ASSERT_TRUE( gfx::BitmapsAreEqual(reps1[i].sk_bitmap(), reps2[i].sk_bitmap())); - ASSERT_EQ(reps1[i].scale_factor(), reps2[i].scale_factor()); + ASSERT_EQ(reps1[i].scale(), reps2[i].scale()); } } diff --git a/chrome/browser/ui/ash/launcher/launcher_item_controller.h b/chrome/browser/ui/ash/launcher/launcher_item_controller.h index 1ab1f66..e035aa5 100644 --- a/chrome/browser/ui/ash/launcher/launcher_item_controller.h +++ b/chrome/browser/ui/ash/launcher/launcher_item_controller.h @@ -10,6 +10,7 @@ #include "base/compiler_specific.h" #include "base/memory/scoped_vector.h" #include "base/strings/string16.h" +#include "ui/events/event.h" class ChromeLauncherController; class ChromeLauncherAppMenuItem; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc index 6872a86..34193e7 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc @@ -472,7 +472,7 @@ gfx::Image GetGeneratedCardImage(const base::string16& card_number, const int kCardWidthPx = 300; const int kCardHeightPx = 190; const gfx::Size size(kCardWidthPx, kCardHeightPx); - gfx::Canvas canvas(size, ui::SCALE_FACTOR_100P, false); + gfx::Canvas canvas(size, 1.0f, false); gfx::Rect display_rect(size); diff --git a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm index 2df80ef..b27a21a 100644 --- a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm @@ -109,7 +109,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver { scoped_ptr<gfx::Canvas> canvas( new gfx::Canvas( gfx::Size(image_size + kDropArrowLeftMarginPx + drop_image->width(), - image_size), ui::SCALE_FACTOR_100P, false)); + image_size), 1.0f, false)); canvas->DrawImageInt(*icon, 0, 0, icon->width(), icon->height(), 0, 0, image_size, image_size, diff --git a/chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.mm b/chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.mm index 90ba6e0..a4601eb 100644 --- a/chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.mm @@ -293,7 +293,7 @@ void PanelStackWindowCocoa::Minimize() { // Provide the custom miniwindow image since there is nothing painted for // the background stack window. gfx::Size stack_window_size = GetStackWindowBounds().size(); - gfx::Canvas canvas(stack_window_size, ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(stack_window_size, 1.0f, true); int y = 0; Panels::const_iterator iter = panels_.begin(); for (; iter != panels_.end(); ++iter) { diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm index 95f2e54..1a15f6f 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm @@ -164,7 +164,7 @@ NSImage* CreateImageWithSize(NSSize size, base::scoped_nsobject<NSImage> result([[NSImage alloc] initWithSize:size]); [NSGraphicsContext saveGraphicsState]; for (ui::ScaleFactor scale_factor : ui::GetSupportedScaleFactors()) { - float scale = GetScaleFactorScale(scale_factor); + float scale = GetImageScale(scale_factor); NSBitmapImageRep *bmpImageRep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:size.width * scale diff --git a/chrome/browser/ui/gtk/avatar_menu_item_gtk.cc b/chrome/browser/ui/gtk/avatar_menu_item_gtk.cc index b708d03..f5b8bc1 100644 --- a/chrome/browser/ui/gtk/avatar_menu_item_gtk.cc +++ b/chrome/browser/ui/gtk/avatar_menu_item_gtk.cc @@ -201,8 +201,7 @@ void AvatarMenuItemGtk::Init(GtkThemeService* theme_service) { // of the profile icon. if (item_.active) { const SkBitmap* avatar_image = item_.icon.ToSkBitmap(); - gfx::ImageSkiaRep avatar_image_rep = - gfx::ImageSkiaRep(*avatar_image, ui::SCALE_FACTOR_100P); + gfx::ImageSkiaRep avatar_image_rep = gfx::ImageSkiaRep(*avatar_image, 1.0f); gfx::Canvas canvas(avatar_image_rep, /* is_opaque */ true); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc index 97e0ec5..a4d3562 100644 --- a/chrome/browser/ui/gtk/gtk_theme_service.cc +++ b/chrome/browser/ui/gtk/gtk_theme_service.cc @@ -1040,7 +1040,7 @@ SkBitmap GtkThemeService::GenerateFrameImage( SkColor base = it->second; gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), - ui::SCALE_FACTOR_100P, true); + 1.0f, true); int gradient_size; GdkColor* gradient_top_color = NULL; diff --git a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc index c12d975c..0575aea 100644 --- a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc @@ -171,7 +171,7 @@ void ExtensionInfoBarGtk::OnImageLoaded(const gfx::Image& image) { static const int kDropArrowLeftMargin = 3; scoped_ptr<gfx::Canvas> canvas(new gfx::Canvas( gfx::Size(image_size + kDropArrowLeftMargin + drop_image->width(), - image_size), ui::SCALE_FACTOR_100P, false)); + image_size), 1.0f, false)); canvas->DrawImageInt(*icon, 0, 0, icon->width(), icon->height(), 0, 0, image_size, image_size, false); canvas->DrawImageInt(*drop_image, image_size + kDropArrowLeftMargin, diff --git a/chrome/browser/ui/gtk/panels/panel_gtk.cc b/chrome/browser/ui/gtk/panels/panel_gtk.cc index 54b0c3b..c45b6ea 100644 --- a/chrome/browser/ui/gtk/panels/panel_gtk.cc +++ b/chrome/browser/ui/gtk/panels/panel_gtk.cc @@ -144,7 +144,7 @@ const AcceleratorMap& GetAcceleratorTable() { } gfx::Image CreateImageForColor(SkColor color) { - gfx::Canvas canvas(gfx::Size(1, 1), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(1, 1), 1.0f, true); canvas.DrawColor(color); return gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep())); } diff --git a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc index 5c66d9d..4a6ce2d 100644 --- a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc +++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc @@ -868,7 +868,7 @@ SkBitmap Gtk2UI::GenerateFrameImage( SkColor base = it->second; gfx::Canvas canvas(gfx::Size(kToolbarImageWidth, kToolbarImageHeight), - ui::SCALE_FACTOR_100P, true); + 1.0f, true); int gradient_size; GdkColor* gradient_top_color = NULL; diff --git a/chrome/browser/ui/metro_pin_tab_helper_win.cc b/chrome/browser/ui/metro_pin_tab_helper_win.cc index 064bccf..58255d7 100644 --- a/chrome/browser/ui/metro_pin_tab_helper_win.cc +++ b/chrome/browser/ui/metro_pin_tab_helper_win.cc @@ -85,7 +85,7 @@ bool CreateSiteSpecificLogo(const SkBitmap& bitmap, SkColor dominant_color = color_utils::CalculateKMeanColorOfBitmap(bitmap); SkPaint paint; paint.setColor(dominant_color); - gfx::Canvas canvas(gfx::Size(kLogoWidth, kLogoHeight), ui::SCALE_FACTOR_100P, + gfx::Canvas canvas(gfx::Size(kLogoWidth, kLogoHeight), 1.0f, true); canvas.DrawRect(gfx::Rect(0, 0, kLogoWidth, kLogoHeight), paint); @@ -381,7 +381,7 @@ void MetroPinTabHelper::TogglePinnedToStartScreen() { if (favicon_tab_helper->FaviconIsValid()) { // Only the 1x bitmap data is needed. favicon = favicon_tab_helper->GetFavicon().AsImageSkia().GetRepresentation( - ui::SCALE_FACTOR_100P).sk_bitmap(); + 1.0f).sk_bitmap(); } favicon_chooser_.reset(new FaviconChooser(this, title, url_str, favicon)); diff --git a/chrome/browser/ui/toolbar/wrench_icon_painter_unittest.cc b/chrome/browser/ui/toolbar/wrench_icon_painter_unittest.cc index 43b30f9..f513aaa 100644 --- a/chrome/browser/ui/toolbar/wrench_icon_painter_unittest.cc +++ b/chrome/browser/ui/toolbar/wrench_icon_painter_unittest.cc @@ -37,7 +37,7 @@ class WrenchIconPainterTest : public testing::Test, // leaks or crashes. TEST_F(WrenchIconPainterTest, Paint) { gfx::Rect rect(0, 0, 29, 29); - gfx::Canvas canvas(rect.size(), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(rect.size(), 1.0f, true); painter_.Paint(&canvas, theme_provider_, rect, WrenchIconPainter::BEZEL_NONE); painter_.Paint( diff --git a/chrome/browser/ui/views/dropdown_bar_view.cc b/chrome/browser/ui/views/dropdown_bar_view.cc index eece8aa..235bbef 100644 --- a/chrome/browser/ui/views/dropdown_bar_view.cc +++ b/chrome/browser/ui/views/dropdown_bar_view.cc @@ -112,7 +112,7 @@ void DropdownBarView::OnPaint(gfx::Canvas* canvas) { if (animation_offset() > 0) { gfx::Canvas animating_edges( gfx::Size(bounds().width(), kAnimatingEdgeHeight), - canvas->scale_factor(), + canvas->image_scale(), false); canvas->Translate(bounds().OffsetFromOrigin()); OnPaintBackground(&animating_edges); diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 58d24c7..e216446 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -209,7 +209,7 @@ void PaintDetachedBookmarkBar(gfx::Canvas* canvas, // Calculate thickness of bottom border as per current scale factor to // determine where to draw the 1-px thick border. float thickness = views::NonClientFrameView::kClientEdgeThickness / - ui::GetScaleFactorScale(canvas->scale_factor()); + canvas->image_scale(); SkScalar y = SkIntToScalar(view->height()) - SkFloatToScalar(thickness); canvas->sk_canvas()->drawLine(SkIntToScalar(0), y, SkIntToScalar(view->width()), y, paint); diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc index 2916c5f..5962fb0 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc @@ -84,7 +84,7 @@ class TestLayoutDelegate : public OpaqueBrowserFrameViewLayoutDelegate { // The calculations depend on the size of the OTR resource, and chromeos // uses a different sized image, so hard code the size of the current // windows/linux one. - gfx::ImageSkiaRep rep(gfx::Size(40, 29), ui::SCALE_FACTOR_100P); + gfx::ImageSkiaRep rep(gfx::Size(40, 29), 1.0f); gfx::ImageSkia image(rep); return image; } @@ -173,7 +173,7 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase { views::ImageButton* InitWindowCaptionButton(ViewID view_id, const gfx::Size& size) { views::ImageButton* button = new views::ImageButton(NULL); - gfx::ImageSkiaRep rep(size, ui::SCALE_FACTOR_100P); + gfx::ImageSkiaRep rep(size, 1.0f); gfx::ImageSkia image(rep); button->SetImage(views::CustomButton::STATE_NORMAL, &image); button->set_id(view_id); diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc index 9e38e7a..6734411 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc @@ -65,8 +65,7 @@ ContentSettingImageView::ContentSettingImageView( // sit atop. const SkBitmap& bitmap( ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( - kBackgroundImages[4])->GetRepresentation( - ui::SCALE_FACTOR_100P).sk_bitmap()); + kBackgroundImages[4])->GetRepresentation(1.0f).sk_bitmap()); SkAutoLockPixels pixel_lock(bitmap); SkColor background_image_color = bitmap.getColor(bitmap.width() / 2, bitmap.height() / 2); diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc index 6a49136..f279f24 100644 --- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc +++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc @@ -54,8 +54,7 @@ IconLabelBubbleView::IconLabelBubbleView(const int background_images[], // sit atop. const SkBitmap& bitmap( ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( - background_images[4])->GetRepresentation( - ui::SCALE_FACTOR_100P).sk_bitmap()); + background_images[4])->GetRepresentation(1.0f).sk_bitmap()); SkAutoLockPixels pixel_lock(bitmap); SkColor background_image_color = bitmap.getColor(bitmap.width() / 2, bitmap.height() / 2); diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc index 43bf0c7..e2c98ce 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc @@ -2514,7 +2514,7 @@ void OmniboxViewWin::DrawSlashForInsecureScheme(HDC hdc, // it to fully transparent so any antialiasing will look nice when painted // atop the edit. gfx::Canvas canvas(gfx::Size(scheme_rect.Width(), scheme_rect.Height()), - ui::SCALE_FACTOR_100P, false); + 1.0f, false); SkCanvas* sk_canvas = canvas.sk_canvas(); sk_canvas->getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0); diff --git a/chrome/browser/ui/views/panels/panel_frame_view.cc b/chrome/browser/ui/views/panels/panel_frame_view.cc index 5359e72..7b9ed29 100644 --- a/chrome/browser/ui/views/panels/panel_frame_view.cc +++ b/chrome/browser/ui/views/panels/panel_frame_view.cc @@ -64,7 +64,7 @@ const SkColor kMinimizeBorderDefaultColor = SkColorSetRGB(0xc9, 0xc9, 0xc9); const SkColor kTitleTextDefaultColor = SkColorSetRGB(0xf9, 0xf9, 0xf9); gfx::ImageSkia* CreateImageForColor(SkColor color) { - gfx::Canvas canvas(gfx::Size(1, 1), ui::SCALE_FACTOR_100P, true); + gfx::Canvas canvas(gfx::Size(1, 1), 1.0f, true); canvas.DrawColor(color); return new gfx::ImageSkia(canvas.ExtractImageRep()); } diff --git a/chrome/browser/ui/views/panels/taskbar_window_thumbnailer_win.cc b/chrome/browser/ui/views/panels/taskbar_window_thumbnailer_win.cc index e6946bb..29c2a5f 100644 --- a/chrome/browser/ui/views/panels/taskbar_window_thumbnailer_win.cc +++ b/chrome/browser/ui/views/panels/taskbar_window_thumbnailer_win.cc @@ -188,7 +188,7 @@ SkBitmap* TaskbarWindowThumbnailerWin::CaptureWindowImage() const { if (!width || !height) return NULL; - gfx::Canvas canvas(gfx::Size(width, height), ui::SCALE_FACTOR_100P, false); + gfx::Canvas canvas(gfx::Size(width, height), 1.0f, false); { skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas()); HDC target_dc = scoped_platform_paint.GetPlatformSurface(); diff --git a/chrome/browser/ui/views/tab_icon_view.cc b/chrome/browser/ui/views/tab_icon_view.cc index 433e36f..ab13cd6 100644 --- a/chrome/browser/ui/views/tab_icon_view.cc +++ b/chrome/browser/ui/views/tab_icon_view.cc @@ -39,8 +39,7 @@ void TabIconView::InitializeIfNeeded() { HICON app_icon = GetAppIcon(); scoped_ptr<SkBitmap> bitmap( IconUtil::CreateSkBitmapFromHICON(app_icon, gfx::Size(16, 16))); - g_default_favicon = new gfx::ImageSkia( - gfx::ImageSkiaRep(*bitmap, ui::SCALE_FACTOR_100P)); + g_default_favicon = new gfx::ImageSkia(gfx::ImageSkiaRep(*bitmap, 1.0f)); DestroyIcon(app_icon); #else ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); diff --git a/chrome/browser/ui/views/tabs/dragged_tab_view.cc b/chrome/browser/ui/views/tabs/dragged_tab_view.cc index bb3b8a6..d7b8cf8 100644 --- a/chrome/browser/ui/views/tabs/dragged_tab_view.cc +++ b/chrome/browser/ui/views/tabs/dragged_tab_view.cc @@ -138,7 +138,7 @@ gfx::Size DraggedTabView::GetPreferredSize() { void DraggedTabView::PaintDetachedView(gfx::Canvas* canvas) { gfx::Size ps = GetPreferredSize(); // TODO(pkotwicz): DIP enable this class. - gfx::Canvas scale_canvas(ps, ui::SCALE_FACTOR_100P, false); + gfx::Canvas scale_canvas(ps, 1.0f, false); SkBitmap& bitmap_device = const_cast<SkBitmap&>( skia::GetTopDevice(*scale_canvas.sk_canvas())->accessBitmap(true)); bitmap_device.eraseARGB(0, 0, 0, 0); diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc index 2492f4e..23590ae 100644 --- a/chrome/browser/ui/views/tabs/tab.cc +++ b/chrome/browser/ui/views/tabs/tab.cc @@ -1202,13 +1202,13 @@ void Tab::PaintInactiveTabBackgroundWithTitleChange( gfx::Canvas* canvas, gfx::MultiAnimation* animation) { // Render the inactive tab background. We'll use this for clipping. - gfx::Canvas background_canvas(size(), canvas->scale_factor(), false); + gfx::Canvas background_canvas(size(), canvas->image_scale(), false); PaintInactiveTabBackground(&background_canvas); gfx::ImageSkia background_image(background_canvas.ExtractImageRep()); // Draw a radial gradient to hover_canvas. - gfx::Canvas hover_canvas(size(), canvas->scale_factor(), false); + gfx::Canvas hover_canvas(size(), canvas->image_scale(), false); int radius = kMiniTitleChangeGradientRadius; int x0 = width() + radius - kMiniTitleChangeInitialXOffset; int x1 = radius; @@ -1271,13 +1271,14 @@ void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { !hover_controller_.ShouldDraw(); if (can_cache) { - gfx::ImageSkia cached_image( - GetCachedImage(tab_id, size(), canvas->scale_factor())); + ui::ScaleFactor scale_factor = + ui::GetSupportedScaleFactor(canvas->image_scale()); + gfx::ImageSkia cached_image(GetCachedImage(tab_id, size(), scale_factor)); if (cached_image.width() == 0) { - gfx::Canvas tmp_canvas(size(), canvas->scale_factor(), false); + gfx::Canvas tmp_canvas(size(), canvas->image_scale(), false); PaintInactiveTabBackgroundUsingResourceId(&tmp_canvas, tab_id); cached_image = gfx::ImageSkia(tmp_canvas.ExtractImageRep()); - SetCachedImage(tab_id, canvas->scale_factor(), cached_image); + SetCachedImage(tab_id, scale_factor, cached_image); } canvas->DrawImageInt(cached_image, 0, 0); } else { @@ -1310,7 +1311,7 @@ void Tab::PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas, // We need a gfx::Canvas object to be able to extract the image from. // We draw everything to this canvas and then output it to the canvas // parameter in addition to using it to mask the hover glow if needed. - gfx::Canvas background_canvas(size(), canvas->scale_factor(), false); + gfx::Canvas background_canvas(size(), canvas->image_scale(), false); // Draw left edge. Don't draw over the toolbar, as we're not the foreground // tab. diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index f59e661..5e40997 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -394,7 +394,8 @@ void NewTabButton::OnMouseReleased(const ui::MouseEvent& event) { #endif void NewTabButton::OnPaint(gfx::Canvas* canvas) { - gfx::ImageSkia image = GetImageForScale(canvas->scale_factor()); + gfx::ImageSkia image = + GetImageForScale(ui::GetSupportedScaleFactor(canvas->image_scale())); canvas->DrawImageInt(image, 0, height() - image.height()); } @@ -444,12 +445,12 @@ gfx::ImageSkia NewTabButton::GetBackgroundImage( GetThemeProvider()->GetImageSkiaNamed(IDR_NEWTAB_BUTTON_MASK); int height = mask->height(); int width = mask->width(); - + float scale = ui::GetImageScale(scale_factor); // The canvas and mask has to use the same scale factor. - if (!mask->HasRepresentation(scale_factor)) + if (!mask->HasRepresentation(scale)) scale_factor = ui::SCALE_FACTOR_100P; - gfx::Canvas canvas(gfx::Size(width, height), scale_factor, false); + gfx::Canvas canvas(gfx::Size(width, height), scale, false); // For custom images the background starts at the top of the tab strip. // Otherwise the background starts at the top of the frame. @@ -495,7 +496,9 @@ gfx::ImageSkia NewTabButton::GetImageForState( gfx::ImageSkia* overlay = GetThemeProvider()->GetImageSkiaNamed(overlay_id); gfx::Canvas canvas( - gfx::Size(overlay->width(), overlay->height()), scale_factor, false); + gfx::Size(overlay->width(), overlay->height()), + ui::GetImageScale(scale_factor), + false); canvas.DrawImageInt(GetBackgroundImage(state, scale_factor), 0, 0); // Draw the button border with a slight alpha. diff --git a/chrome/browser/ui/web_applications/web_app_ui.cc b/chrome/browser/ui/web_applications/web_app_ui.cc index 4834b3f..2e7b6c4 100644 --- a/chrome/browser/ui/web_applications/web_app_ui.cc +++ b/chrome/browser/ui/web_applications/web_app_ui.cc @@ -364,7 +364,7 @@ void OnImageLoaded(ShellIntegration::ShortcutInfo shortcut_info, // the icons, hackily put into a single ImageSkia. Separate them out into // individual ImageSkias and insert them into the icon family. const gfx::ImageSkia& multires_image_skia = image.AsImageSkia(); - // NOTE: We do not call ImageSkia::EnsureRepsForSupportedScaleFactors here. + // NOTE: We do not call ImageSkia::EnsureRepsForSupportedScales here. // The image reps here are not really for different scale factors (ImageSkia // is just being used as a handy container for multiple images). std::vector<gfx::ImageSkiaRep> image_reps = diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index e7257aa..4003e73 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -548,7 +548,7 @@ void ChromeWebUIControllerFactory::GetFaviconForURL( // Assume that |bitmap| is |gfx::kFaviconSize| x |gfx::kFaviconSize| // DIP. - float scale = ui::GetScaleFactorScale(scale_factors[i]); + float scale = ui::GetImageScale(scale_factors[i]); int edge_pixel_size = static_cast<int>(gfx::kFaviconSize * scale + 0.5f); bitmap_result.pixel_size = gfx::Size(edge_pixel_size, edge_pixel_size); diff --git a/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc b/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc index 57af9b5..b220e31 100644 --- a/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc +++ b/chrome/browser/ui/webui/chromeos/login/network_dropdown.cc @@ -90,7 +90,8 @@ base::ListValue* NetworkMenuWebUI::ConvertMenuModel(ui::MenuModel* model) { gfx::Image icon; if (model->GetIconAt(i, &icon)) { SkBitmap icon_bitmap = icon.ToImageSkia()->GetRepresentation( - web_ui_->GetDeviceScaleFactor()).sk_bitmap(); + ui::GetImageScale( + web_ui_->GetDeviceScaleFactor())).sk_bitmap(); item->SetString("icon", webui::GetBitmapDataUrl(icon_bitmap)); } if (id >= 0) { @@ -192,7 +193,7 @@ void NetworkDropdown::SetNetworkIconAndText() { RemoveObserver(this); } SkBitmap icon_bitmap = icon_image.GetRepresentation( - web_ui_->GetDeviceScaleFactor()).sk_bitmap(); + ui::GetImageScale(web_ui_->GetDeviceScaleFactor())).sk_bitmap(); std::string icon_str; if (!icon_image.isNull()) icon_str = webui::GetBitmapDataUrl(icon_bitmap); diff --git a/chrome/browser/ui/webui/fileicon_source.cc b/chrome/browser/ui/webui/fileicon_source.cc index ee0cb11..1705c41 100644 --- a/chrome/browser/ui/webui/fileicon_source.cc +++ b/chrome/browser/ui/webui/fileicon_source.cc @@ -103,7 +103,8 @@ void FileIconSource::FetchFileIcon( if (icon) { scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); gfx::PNGCodec::EncodeBGRASkBitmap( - icon->ToImageSkia()->GetRepresentation(scale_factor).sk_bitmap(), + icon->ToImageSkia()->GetRepresentation( + ui::GetImageScale(scale_factor)).sk_bitmap(), false, &icon_data->data()); callback.Run(icon_data.get()); @@ -150,8 +151,8 @@ void FileIconSource::OnFileIconDataAvailable(const IconRequestDetails& details, if (icon) { scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); gfx::PNGCodec::EncodeBGRASkBitmap( - icon->ToImageSkia()->GetRepresentation(details.scale_factor) - .sk_bitmap(), + icon->ToImageSkia()->GetRepresentation( + ui::GetImageScale(details.scale_factor)).sk_bitmap(), false, &icon_data->data()); diff --git a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc index db212ec..dbe8373 100644 --- a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc +++ b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc @@ -58,8 +58,7 @@ SkBitmap GetGAIAPictureForNTP(const gfx::Image& image) { SkBitmap bmp = skia::ImageOperations::Resize(*image.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST, kLength, kLength); - gfx::Canvas canvas(gfx::Size(kLength, kLength), ui::SCALE_FACTOR_100P, - false); + gfx::Canvas canvas(gfx::Size(kLength, kLength), 1.0f, false); canvas.DrawImageInt(gfx::ImageSkia::CreateFrom1xBitmap(bmp), 0, 0); // Draw a gray border on the inside of the icon. diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc index bc82a94..218d24a 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc @@ -416,7 +416,8 @@ void SetCommonNetworkInfo(const ManagedState* state, const gfx::ImageSkia& icon, ui::ScaleFactor icon_scale_factor, base::DictionaryValue* network_info) { - gfx::ImageSkiaRep image_rep = icon.GetRepresentation(icon_scale_factor); + gfx::ImageSkiaRep image_rep = + icon.GetRepresentation(ui::GetImageScale(icon_scale_factor)); std::string icon_url = icon.isNull() ? "" : webui::GetBitmapDataUrl(image_rep.sk_bitmap()); network_info->SetString(kNetworkInfoKeyIconURL, icon_url); @@ -1217,7 +1218,7 @@ std::string InternetOptionsHandler::GetIconDataUrl(int resource_id) const { gfx::ImageSkia* icon = ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); gfx::ImageSkiaRep image_rep = icon->GetRepresentation( - web_ui()->GetDeviceScaleFactor()); + ui::GetImageScale(web_ui()->GetDeviceScaleFactor())); return webui::GetBitmapDataUrl(image_rep.sk_bitmap()); } diff --git a/chrome/common/badge_util.cc b/chrome/common/badge_util.cc index ccbaca1..a762a6f 100644 --- a/chrome/common/badge_util.cc +++ b/chrome/common/badge_util.cc @@ -124,7 +124,7 @@ SkBitmap DrawBadgeIconOverlay(const SkBitmap& icon, // Render the badge bitmap and overlay into a canvas. scoped_ptr<gfx::Canvas> canvas(new gfx::Canvas( - gfx::Size(badge_width, icon.height()), ui::SCALE_FACTOR_100P, false)); + gfx::Size(badge_width, icon.height()), 1.0f, false)); canvas->DrawImageInt(gfx::ImageSkia::CreateFrom1xBitmap(icon), 0, 0); // Draw the text overlay centered horizontally and vertically. Skia expects diff --git a/chrome/common/icon_with_badge_image_source.cc b/chrome/common/icon_with_badge_image_source.cc index 1665030..007292c 100644 --- a/chrome/common/icon_with_badge_image_source.cc +++ b/chrome/common/icon_with_badge_image_source.cc @@ -5,6 +5,7 @@ #include "chrome/common/icon_with_badge_image_source.h" #include "chrome/common/badge_util.h" +//#include "ui/base/layout.h" #include "ui/gfx/canvas.h" #include "ui/gfx/rect.h" diff --git a/chrome/renderer/pepper/pepper_pdf_host.cc b/chrome/renderer/pepper/pepper_pdf_host.cc index 9b78c93..e187c52 100644 --- a/chrome/renderer/pepper/pepper_pdf_host.cc +++ b/chrome/renderer/pepper/pepper_pdf_host.cc @@ -296,18 +296,15 @@ int32_t PepperPDFHost::OnHostMsgGetResourceImage( if (res_id == 0) return PP_ERROR_FAILED; - ui::ScaleFactor scale_factor = ui::GetScaleFactorFromScale(scale); - gfx::ImageSkia* res_image_skia = ResourceBundle::GetSharedInstance().GetImageSkiaNamed(res_id); if (!res_image_skia) return PP_ERROR_FAILED; - gfx::ImageSkiaRep image_skia_rep = res_image_skia->GetRepresentation( - scale_factor); + gfx::ImageSkiaRep image_skia_rep = res_image_skia->GetRepresentation(scale); - if (image_skia_rep.is_null() || image_skia_rep.scale_factor() != scale_factor) + if (image_skia_rep.is_null() || image_skia_rep.scale() != scale) return PP_ERROR_FAILED; PP_Size pp_size; |