summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-20 06:25:29 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-20 06:25:29 +0000
commit1e76b50130c7b40ad04eecaa0bc9b0b3d6e9afeb (patch)
tree0782e9be1a44505f5b150c8799cf8f8e7ac03cb5 /ui
parent4435d85a84dea66259432cf50e78eb9b97651ec8 (diff)
downloadchromium_src-1e76b50130c7b40ad04eecaa0bc9b0b3d6e9afeb.zip
chromium_src-1e76b50130c7b40ad04eecaa0bc9b0b3d6e9afeb.tar.gz
chromium_src-1e76b50130c7b40ad04eecaa0bc9b0b3d6e9afeb.tar.bz2
GetScaleFactorForNativeView should return scale factor in float
Step 1 to reduce the use of ui::ScaleFactor and eliminate ui::GetImageScale BUG=372212 R=ananta@chromium.org, sky@chromium.org TBR=jam@chromium.org Review URL: https://codereview.chromium.org/293563002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/app_list/views/app_list_main_view.cc7
-rw-r--r--ui/base/layout.cc6
-rw-r--r--ui/base/layout.h2
-rw-r--r--ui/base/layout_mac.mm4
-rw-r--r--ui/message_center/views/notification_view.cc10
5 files changed, 12 insertions, 17 deletions
diff --git a/ui/app_list/views/app_list_main_view.cc b/ui/app_list/views/app_list_main_view.cc
index 19b2983..dcb5780 100644
--- a/ui/app_list/views/app_list_main_view.cc
+++ b/ui/app_list/views/app_list_main_view.cc
@@ -188,11 +188,10 @@ bool AppListMainView::ShouldCenterWindow() const {
}
void AppListMainView::PreloadIcons(gfx::NativeView parent) {
- ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_100P;
+ float scale_factor = 1.0f;
if (parent)
scale_factor = ui::GetScaleFactorForNativeView(parent);
- float scale = ui::GetImageScale(scale_factor);
// |pagination_model| could have -1 as the initial selected page and
// assumes first page (i.e. index 0) will be used in this case.
const int selected_page = std::max(0, pagination_model_->selected_page());
@@ -206,10 +205,10 @@ void AppListMainView::PreloadIcons(gfx::NativeView parent) {
pending_icon_loaders_.clear();
for (int i = start_model_index; i < end_model_index; ++i) {
AppListItem* item = model_->top_level_item_list()->item_at(i);
- if (item->icon().HasRepresentation(scale))
+ if (item->icon().HasRepresentation(scale_factor))
continue;
- pending_icon_loaders_.push_back(new IconLoader(this, item, scale));
+ pending_icon_loaders_.push_back(new IconLoader(this, item, scale_factor));
}
}
diff --git a/ui/base/layout.cc b/ui/base/layout.cc
index 783ab5a..6ce0ccc 100644
--- a/ui/base/layout.cc
+++ b/ui/base/layout.cc
@@ -144,13 +144,13 @@ ScopedSetSupportedScaleFactors::~ScopedSetSupportedScaleFactors() {
} // namespace test
#if !defined(OS_MACOSX)
-ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view) {
+float GetScaleFactorForNativeView(gfx::NativeView view) {
gfx::Screen* screen = gfx::Screen::GetScreenFor(view);
if (screen->IsDIPEnabled()) {
gfx::Display display = screen->GetDisplayNearestWindow(view);
- return GetSupportedScaleFactor(display.device_scale_factor());
+ return display.device_scale_factor();
}
- return ui::SCALE_FACTOR_100P;
+ return 1.0f;
}
#endif // !defined(OS_MACOSX)
diff --git a/ui/base/layout.h b/ui/base/layout.h
index df9f6cc..846bb21 100644
--- a/ui/base/layout.h
+++ b/ui/base/layout.h
@@ -53,7 +53,7 @@ UI_BASE_EXPORT float GetImageScale(ScaleFactor scale_factor);
UI_BASE_EXPORT ScaleFactor GetSupportedScaleFactor(float image_scale);
// Returns the ScaleFactor used by |view|.
-UI_BASE_EXPORT ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view);
+UI_BASE_EXPORT float GetScaleFactorForNativeView(gfx::NativeView view);
// Returns true if |scale_factor| is supported by this platform.
UI_BASE_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor);
diff --git a/ui/base/layout_mac.mm b/ui/base/layout_mac.mm
index 6e50de1..62331e9 100644
--- a/ui/base/layout_mac.mm
+++ b/ui/base/layout_mac.mm
@@ -31,8 +31,8 @@ float GetScaleFactorScaleForNativeView(gfx::NativeView view) {
namespace ui {
-ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view) {
- return GetSupportedScaleFactor(GetScaleFactorScaleForNativeView(view));
+float GetScaleFactorForNativeView(gfx::NativeView view) {
+ return GetScaleFactorScaleForNativeView(view);
}
} // namespace ui
diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc
index 0884205..a0e78f7 100644
--- a/ui/message_center/views/notification_view.cc
+++ b/ui/message_center/views/notification_view.cc
@@ -82,16 +82,12 @@ scoped_ptr<views::Border> MakeSeparatorBorder(int top,
// Return true if and only if the image is null or has alpha.
bool HasAlpha(gfx::ImageSkia& image, views::Widget* widget) {
// Determine which bitmap to use.
- ui::ScaleFactor factor = ui::SCALE_FACTOR_100P;
- if (widget) {
+ float factor = 1.0f;
+ if (widget)
factor = ui::GetScaleFactorForNativeView(widget->GetNativeView());
- if (factor == ui::SCALE_FACTOR_NONE)
- factor = ui::SCALE_FACTOR_100P;
- }
// Extract that bitmap's alpha and look for a non-opaque pixel there.
- SkBitmap bitmap =
- image.GetRepresentation(ui::GetImageScale(factor)).sk_bitmap();
+ SkBitmap bitmap = image.GetRepresentation(factor).sk_bitmap();
if (!bitmap.isNull()) {
SkBitmap alpha;
bitmap.extractAlpha(&alpha);