| 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 14 matching lines...) Expand all Loading... |
| 25 #endif // defined(OS_WIN) | 25 #endif // defined(OS_WIN) |
| 26 | 26 |
| 27 namespace ui { | 27 namespace ui { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 std::vector<ScaleFactor>* g_supported_scale_factors = NULL; | 31 std::vector<ScaleFactor>* g_supported_scale_factors = NULL; |
| 32 | 32 |
| 33 const float kScaleFactorScales[] = {1.0f, 1.0f, 1.25f, 1.33f, 1.4f, 1.5f, 1.8f, | 33 const float kScaleFactorScales[] = {1.0f, 1.0f, 1.25f, 1.33f, 1.4f, 1.5f, 1.8f, |
| 34 2.0f, 2.5f, 3.0f}; | 34 2.0f, 2.5f, 3.0f}; |
| 35 COMPILE_ASSERT(NUM_SCALE_FACTORS == arraysize(kScaleFactorScales), | 35 static_assert(NUM_SCALE_FACTORS == arraysize(kScaleFactorScales), |
| 36 kScaleFactorScales_incorrect_size); | 36 "kScaleFactorScales has incorrect size"); |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 void SetSupportedScaleFactors( | 40 void SetSupportedScaleFactors( |
| 41 const std::vector<ui::ScaleFactor>& scale_factors) { | 41 const std::vector<ui::ScaleFactor>& scale_factors) { |
| 42 if (g_supported_scale_factors != NULL) | 42 if (g_supported_scale_factors != NULL) |
| 43 delete g_supported_scale_factors; | 43 delete g_supported_scale_factors; |
| 44 | 44 |
| 45 g_supported_scale_factors = new std::vector<ScaleFactor>(scale_factors); | 45 g_supported_scale_factors = new std::vector<ScaleFactor>(scale_factors); |
| 46 std::sort(g_supported_scale_factors->begin(), | 46 std::sort(g_supported_scale_factors->begin(), |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 #if !defined(OS_MACOSX) | 120 #if !defined(OS_MACOSX) |
| 121 float GetScaleFactorForNativeView(gfx::NativeView view) { | 121 float GetScaleFactorForNativeView(gfx::NativeView view) { |
| 122 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); | 122 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); |
| 123 gfx::Display display = screen->GetDisplayNearestWindow(view); | 123 gfx::Display display = screen->GetDisplayNearestWindow(view); |
| 124 return display.device_scale_factor(); | 124 return display.device_scale_factor(); |
| 125 } | 125 } |
| 126 #endif // !defined(OS_MACOSX) | 126 #endif // !defined(OS_MACOSX) |
| 127 | 127 |
| 128 } // namespace ui | 128 } // namespace ui |
| OLD | NEW |