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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 | 66 |
| 67 const float kScaleFactorScales[] = {1.0f, 1.4f, 1.8f, 2.0f}; | 67 const float kScaleFactorScales[] = {1.0f, 1.4f, 1.8f, 2.0f}; |
| 68 COMPILE_ASSERT(NUM_SCALE_FACTORS == arraysize(kScaleFactorScales), | 68 COMPILE_ASSERT(NUM_SCALE_FACTORS == arraysize(kScaleFactorScales), |
| 69 kScaleFactorScales_incorrect_size); | 69 kScaleFactorScales_incorrect_size); |
| 70 const size_t kScaleFactorScalesLength = arraysize(kScaleFactorScales); | 70 const size_t kScaleFactorScalesLength = arraysize(kScaleFactorScales); |
| 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 // 100P is always a supported scale factor. |
|
Nico
2012/11/09 19:16:37
Explain why this is enabled on iOS, which technica
| |
| 77 // On platforms other than iOS, 100P is always a supported scale factor. | |
| 78 supported_scale_factors->push_back(SCALE_FACTOR_100P); | 77 supported_scale_factors->push_back(SCALE_FACTOR_100P); |
| 79 #endif | |
| 80 | 78 |
| 81 #if defined(OS_IOS) | 79 #if defined(OS_IOS) |
| 82 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 80 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 83 if (display.device_scale_factor() > 1.0) { | 81 if (display.device_scale_factor() > 1.0) { |
| 84 DCHECK_EQ(2.0, display.device_scale_factor()); | 82 DCHECK_EQ(2.0, display.device_scale_factor()); |
| 85 supported_scale_factors->push_back(SCALE_FACTOR_200P); | 83 supported_scale_factors->push_back(SCALE_FACTOR_200P); |
| 86 } else { | |
| 87 supported_scale_factors->push_back(SCALE_FACTOR_100P); | |
| 88 } | 84 } |
| 89 #elif defined(OS_MACOSX) | 85 #elif defined(OS_MACOSX) |
| 90 if (base::mac::IsOSLionOrLater()) | 86 if (base::mac::IsOSLionOrLater()) |
| 91 supported_scale_factors->push_back(SCALE_FACTOR_200P); | 87 supported_scale_factors->push_back(SCALE_FACTOR_200P); |
| 92 #elif defined(OS_WIN) && defined(ENABLE_HIDPI) | 88 #elif defined(OS_WIN) && defined(ENABLE_HIDPI) |
| 93 if (base::win::IsMetroProcess() && base::win::IsTouchEnabled()) { | 89 if (base::win::IsMetroProcess() && base::win::IsTouchEnabled()) { |
| 94 supported_scale_factors->push_back(SCALE_FACTOR_140P); | 90 supported_scale_factors->push_back(SCALE_FACTOR_140P); |
| 95 supported_scale_factors->push_back(SCALE_FACTOR_180P); | 91 supported_scale_factors->push_back(SCALE_FACTOR_180P); |
| 96 } | 92 } |
| 97 #elif defined(USE_ASH) | 93 #elif defined(USE_ASH) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); | 175 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); |
| 180 if (screen->IsDIPEnabled()) { | 176 if (screen->IsDIPEnabled()) { |
| 181 gfx::Display display = screen->GetDisplayNearestWindow(view); | 177 gfx::Display display = screen->GetDisplayNearestWindow(view); |
| 182 return GetScaleFactorFromScale(display.device_scale_factor()); | 178 return GetScaleFactorFromScale(display.device_scale_factor()); |
| 183 } | 179 } |
| 184 return ui::SCALE_FACTOR_100P; | 180 return ui::SCALE_FACTOR_100P; |
| 185 } | 181 } |
| 186 #endif // !defined(OS_MACOSX) | 182 #endif // !defined(OS_MACOSX) |
| 187 | 183 |
| 188 } // namespace ui | 184 } // namespace ui |
| OLD | NEW |