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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return gfx::GetDPIScale(); | 85 return gfx::GetDPIScale(); |
86 #else | 86 #else |
87 return GetScaleForScaleFactor(scale_factor); | 87 return GetScaleForScaleFactor(scale_factor); |
88 #endif | 88 #endif |
89 } | 89 } |
90 | 90 |
91 float GetScaleForScaleFactor(ScaleFactor scale_factor) { | 91 float GetScaleForScaleFactor(ScaleFactor scale_factor) { |
92 return kScaleFactorScales[scale_factor]; | 92 return kScaleFactorScales[scale_factor]; |
93 } | 93 } |
94 | 94 |
| 95 bool IsSupportedScale(float scale) { |
| 96 for (auto scale_factor_idx : *g_supported_scale_factors) { |
| 97 if (kScaleFactorScales[scale_factor_idx] == scale) |
| 98 return true; |
| 99 } |
| 100 return false; |
| 101 } |
| 102 |
95 namespace test { | 103 namespace test { |
96 | 104 |
97 ScopedSetSupportedScaleFactors::ScopedSetSupportedScaleFactors( | 105 ScopedSetSupportedScaleFactors::ScopedSetSupportedScaleFactors( |
98 const std::vector<ui::ScaleFactor>& new_scale_factors) { | 106 const std::vector<ui::ScaleFactor>& new_scale_factors) { |
99 if (g_supported_scale_factors) { | 107 if (g_supported_scale_factors) { |
100 original_scale_factors_ = | 108 original_scale_factors_ = |
101 new std::vector<ScaleFactor>(*g_supported_scale_factors); | 109 new std::vector<ScaleFactor>(*g_supported_scale_factors); |
102 } else { | 110 } else { |
103 original_scale_factors_ = NULL; | 111 original_scale_factors_ = NULL; |
104 } | 112 } |
(...skipping 14 matching lines...) Expand all Loading... |
119 | 127 |
120 #if !defined(OS_MACOSX) | 128 #if !defined(OS_MACOSX) |
121 float GetScaleFactorForNativeView(gfx::NativeView view) { | 129 float GetScaleFactorForNativeView(gfx::NativeView view) { |
122 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); | 130 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); |
123 gfx::Display display = screen->GetDisplayNearestWindow(view); | 131 gfx::Display display = screen->GetDisplayNearestWindow(view); |
124 return display.device_scale_factor(); | 132 return display.device_scale_factor(); |
125 } | 133 } |
126 #endif // !defined(OS_MACOSX) | 134 #endif // !defined(OS_MACOSX) |
127 | 135 |
128 } // namespace ui | 136 } // namespace ui |
OLD | NEW |