Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/layout.h" | 5 #include "ui/base/layout.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 | 71 |
| 72 std::vector<ScaleFactor>& GetSupportedScaleFactorsInternal() { | 72 std::vector<ScaleFactor>& GetSupportedScaleFactorsInternal() { |
| 73 static std::vector<ScaleFactor>* supported_scale_factors = | 73 static std::vector<ScaleFactor>* supported_scale_factors = |
| 74 new std::vector<ScaleFactor>(); | 74 new std::vector<ScaleFactor>(); |
| 75 if (supported_scale_factors->empty()) { | 75 if (supported_scale_factors->empty()) { |
| 76 #if !defined(OS_IOS) | 76 #if !defined(OS_IOS) |
| 77 // On platforms other than iOS, 100P is always a supported scale factor. | 77 // On platforms other than iOS, 100P is always a supported scale factor. |
| 78 supported_scale_factors->push_back(SCALE_FACTOR_100P); | 78 supported_scale_factors->push_back(SCALE_FACTOR_100P); |
| 79 #endif | 79 #endif |
| 80 | 80 |
| 81 #if defined(OS_IOS) | 81 #if defined(OS_ANDROID) |
| 82 const gfx::Display display = | |
| 83 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | |
| 84 const float display_density = display.device_scale_factor(); | |
| 85 for (int i = NUM_SCALE_FACTORS - 1; i > SCALE_FACTOR_100P; --i) { | |
| 86 if (display_density >= kScaleFactorScales[i]) { | |
|
Nico
2013/01/17 06:31:33
Is 2.0 high enough for android? Nexus 10 has close
aruslan
2013/01/17 23:01:10
1.5 and 3.0 are closer matches for 240 (mdpi) and
| |
| 87 supported_scale_factors->push_back(static_cast<ScaleFactor>(i)); | |
| 88 break; | |
| 89 } | |
| 90 } | |
| 91 #elif defined(OS_IOS) | |
| 82 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 92 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 83 if (display.device_scale_factor() > 1.0) { | 93 if (display.device_scale_factor() > 1.0) { |
| 84 DCHECK_EQ(2.0, display.device_scale_factor()); | 94 DCHECK_EQ(2.0, display.device_scale_factor()); |
| 85 supported_scale_factors->push_back(SCALE_FACTOR_200P); | 95 supported_scale_factors->push_back(SCALE_FACTOR_200P); |
| 86 } else { | 96 } else { |
| 87 supported_scale_factors->push_back(SCALE_FACTOR_100P); | 97 supported_scale_factors->push_back(SCALE_FACTOR_100P); |
| 88 } | 98 } |
| 89 #elif defined(OS_MACOSX) | 99 #elif defined(OS_MACOSX) |
| 90 if (base::mac::IsOSLionOrLater()) | 100 if (base::mac::IsOSLionOrLater()) |
| 91 supported_scale_factors->push_back(SCALE_FACTOR_200P); | 101 supported_scale_factors->push_back(SCALE_FACTOR_200P); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); | 191 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); |
| 182 if (screen->IsDIPEnabled()) { | 192 if (screen->IsDIPEnabled()) { |
| 183 gfx::Display display = screen->GetDisplayNearestWindow(view); | 193 gfx::Display display = screen->GetDisplayNearestWindow(view); |
| 184 return GetScaleFactorFromScale(display.device_scale_factor()); | 194 return GetScaleFactorFromScale(display.device_scale_factor()); |
| 185 } | 195 } |
| 186 return ui::SCALE_FACTOR_100P; | 196 return ui::SCALE_FACTOR_100P; |
| 187 } | 197 } |
| 188 #endif // !defined(OS_MACOSX) | 198 #endif // !defined(OS_MACOSX) |
| 189 | 199 |
| 190 } // namespace ui | 200 } // namespace ui |
| OLD | NEW |