| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "ui/base/touch/touch_device.h" | 15 #include "ui/base/touch/touch_device.h" |
| 16 #include "ui/base/ui_base_switches.h" | 16 #include "ui/base/ui_base_switches.h" |
| 17 #include "ui/gfx/display.h" | 17 #include "ui/gfx/display.h" |
| 18 #include "ui/gfx/dpi.h" |
| 18 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
| 19 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 20 | 21 |
| 21 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 22 #include "base/win/metro.h" | 23 #include "base/win/metro.h" |
| 23 #include "ui/gfx/win/dpi.h" | |
| 24 #include <Windows.h> | 24 #include <Windows.h> |
| 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 bool ScaleFactorComparator(const ScaleFactor& lhs, const ScaleFactor& rhs){ | 31 bool ScaleFactorComparator(const ScaleFactor& lhs, const ScaleFactor& rhs){ |
| 32 return GetScaleForScaleFactor(lhs) < GetScaleForScaleFactor(rhs); | 32 return GetScaleForScaleFactor(lhs) < GetScaleForScaleFactor(rhs); |
| 33 } | 33 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 smallest_diff = diff; | 78 smallest_diff = diff; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 DCHECK_NE(closest_match, SCALE_FACTOR_NONE); | 81 DCHECK_NE(closest_match, SCALE_FACTOR_NONE); |
| 82 return closest_match; | 82 return closest_match; |
| 83 } | 83 } |
| 84 | 84 |
| 85 float GetImageScale(ScaleFactor scale_factor) { | 85 float GetImageScale(ScaleFactor scale_factor) { |
| 86 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
| 87 if (gfx::IsHighDPIEnabled()) | 87 if (gfx::IsHighDPIEnabled()) |
| 88 return gfx::win::GetDeviceScaleFactor(); | 88 return gfx::GetDeviceScaleFactor(); |
| 89 #endif | 89 #endif |
| 90 return GetScaleForScaleFactor(scale_factor); | 90 return GetScaleForScaleFactor(scale_factor); |
| 91 } | 91 } |
| 92 | 92 |
| 93 float GetScaleForScaleFactor(ScaleFactor scale_factor) { | 93 float GetScaleForScaleFactor(ScaleFactor scale_factor) { |
| 94 return kScaleFactorScales[scale_factor]; | 94 return kScaleFactorScales[scale_factor]; |
| 95 } | 95 } |
| 96 | 96 |
| 97 namespace test { | 97 namespace test { |
| 98 | 98 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 124 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); | 124 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); |
| 125 if (screen->IsDIPEnabled()) { | 125 if (screen->IsDIPEnabled()) { |
| 126 gfx::Display display = screen->GetDisplayNearestWindow(view); | 126 gfx::Display display = screen->GetDisplayNearestWindow(view); |
| 127 return display.device_scale_factor(); | 127 return display.device_scale_factor(); |
| 128 } | 128 } |
| 129 return 1.0f; | 129 return 1.0f; |
| 130 } | 130 } |
| 131 #endif // !defined(OS_MACOSX) | 131 #endif // !defined(OS_MACOSX) |
| 132 | 132 |
| 133 } // namespace ui | 133 } // namespace ui |
| OLD | NEW |