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.0f, 1.4f, 1.8f, 2.0f}; | 67 const float kScaleFactorScales[] = {1.0f, 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 // 100P is always a supported scale factor. | 76 #if !defined(OS_IOS) |
| 77 // On platforms other than iOS, 100P is always a supported scale factor. |
77 supported_scale_factors->push_back(SCALE_FACTOR_100P); | 78 supported_scale_factors->push_back(SCALE_FACTOR_100P); |
| 79 #endif |
78 | 80 |
79 #if defined(OS_IOS) | 81 #if defined(OS_IOS) |
80 // TODO(ios): 100p should not be necessary on iOS retina devices. However | 82 // TODO(ios): 100p should not be necessary on iOS retina devices. However |
81 // the sync service only supports syncing 100p favicons. Until sync supports | 83 // the sync service only supports syncing 100p favicons. Until sync supports |
82 // other scales 100p is needed in the list of scale factors to retrieve and | 84 // other scales 100p is needed in the list of scale factors to retrieve and |
83 // store the favicons in both 100p for sync and 200p for display. cr/160503. | 85 // store the favicons in both 100p for sync and 200p for display. cr/160503. |
84 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 86 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
85 if (display.device_scale_factor() > 1.0) { | 87 if (display.device_scale_factor() > 1.0) { |
86 DCHECK_EQ(2.0, display.device_scale_factor()); | 88 DCHECK_EQ(2.0, display.device_scale_factor()); |
87 supported_scale_factors->push_back(SCALE_FACTOR_200P); | 89 supported_scale_factors->push_back(SCALE_FACTOR_200P); |
| 90 } else { |
| 91 supported_scale_factors->push_back(SCALE_FACTOR_100P); |
88 } | 92 } |
89 #elif defined(OS_MACOSX) | 93 #elif defined(OS_MACOSX) |
90 if (base::mac::IsOSLionOrLater()) | 94 if (base::mac::IsOSLionOrLater()) |
91 supported_scale_factors->push_back(SCALE_FACTOR_200P); | 95 supported_scale_factors->push_back(SCALE_FACTOR_200P); |
92 #elif defined(OS_WIN) && defined(ENABLE_HIDPI) | 96 #elif defined(OS_WIN) && defined(ENABLE_HIDPI) |
93 if (base::win::IsMetroProcess() && base::win::IsTouchEnabled()) { | 97 if (base::win::IsMetroProcess() && base::win::IsTouchEnabled()) { |
94 supported_scale_factors->push_back(SCALE_FACTOR_140P); | 98 supported_scale_factors->push_back(SCALE_FACTOR_140P); |
95 supported_scale_factors->push_back(SCALE_FACTOR_180P); | 99 supported_scale_factors->push_back(SCALE_FACTOR_180P); |
96 } | 100 } |
97 #elif defined(OS_CHROMEOS) | 101 #elif defined(OS_CHROMEOS) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); | 185 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); |
182 if (screen->IsDIPEnabled()) { | 186 if (screen->IsDIPEnabled()) { |
183 gfx::Display display = screen->GetDisplayNearestWindow(view); | 187 gfx::Display display = screen->GetDisplayNearestWindow(view); |
184 return GetScaleFactorFromScale(display.device_scale_factor()); | 188 return GetScaleFactorFromScale(display.device_scale_factor()); |
185 } | 189 } |
186 return ui::SCALE_FACTOR_100P; | 190 return ui::SCALE_FACTOR_100P; |
187 } | 191 } |
188 #endif // !defined(OS_MACOSX) | 192 #endif // !defined(OS_MACOSX) |
189 | 193 |
190 } // namespace ui | 194 } // namespace ui |
OLD | NEW |