| 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 <cmath> | 7 #include <cmath> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 return has_touch_device; | 67 return has_touch_device; |
| 68 #else | 68 #else |
| 69 return false; | 69 return false; |
| 70 #endif | 70 #endif |
| 71 } | 71 } |
| 72 | 72 |
| 73 const float kScaleFactorScales[] = {1.0, 2.0}; | 73 const float kScaleFactorScales[] = {1.0, 2.0}; |
| 74 const size_t kScaleFactorScalesLength = arraysize(kScaleFactorScales); | 74 const size_t kScaleFactorScalesLength = arraysize(kScaleFactorScales); |
| 75 | 75 |
| 76 #if defined(OS_MACOSX) | |
| 77 std::vector<ui::ScaleFactor>& GetSupportedScaleFactorsInternal() { | 76 std::vector<ui::ScaleFactor>& GetSupportedScaleFactorsInternal() { |
| 78 static std::vector<ui::ScaleFactor>* supported_scale_factors = | 77 static std::vector<ui::ScaleFactor>* supported_scale_factors = |
| 79 new std::vector<ui::ScaleFactor>(); | 78 new std::vector<ui::ScaleFactor>(); |
| 80 if (supported_scale_factors->empty()) { | 79 if (supported_scale_factors->empty()) { |
| 81 supported_scale_factors->push_back(ui::SCALE_FACTOR_100P); | 80 supported_scale_factors->push_back(ui::SCALE_FACTOR_100P); |
| 81 #if defined(USE_ASH) || defined(OS_MACOSX) |
| 82 supported_scale_factors->push_back(ui::SCALE_FACTOR_200P); | 82 supported_scale_factors->push_back(ui::SCALE_FACTOR_200P); |
| 83 #endif |
| 83 } | 84 } |
| 84 return *supported_scale_factors; | 85 return *supported_scale_factors; |
| 85 } | 86 } |
| 86 #endif // OS_MACOSX | |
| 87 | 87 |
| 88 } // namespace | 88 } // namespace |
| 89 | 89 |
| 90 namespace ui { | 90 namespace ui { |
| 91 | 91 |
| 92 // Note that this function should be extended to select | 92 // Note that this function should be extended to select |
| 93 // LAYOUT_TOUCH when appropriate on more platforms than just | 93 // LAYOUT_TOUCH when appropriate on more platforms than just |
| 94 // Windows and Ash. | 94 // Windows and Ash. |
| 95 DisplayLayout GetDisplayLayout() { | 95 DisplayLayout GetDisplayLayout() { |
| 96 #if defined(USE_ASH) | 96 #if defined(USE_ASH) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 116 smallest_diff = diff; | 116 smallest_diff = diff; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 return static_cast<ui::ScaleFactor>(closest_match); | 119 return static_cast<ui::ScaleFactor>(closest_match); |
| 120 } | 120 } |
| 121 | 121 |
| 122 float GetScaleFactorScale(ScaleFactor scale_factor) { | 122 float GetScaleFactorScale(ScaleFactor scale_factor) { |
| 123 return kScaleFactorScales[scale_factor]; | 123 return kScaleFactorScales[scale_factor]; |
| 124 } | 124 } |
| 125 | 125 |
| 126 #if defined(OS_MACOSX) | |
| 127 std::vector<ScaleFactor> GetSupportedScaleFactors() { | 126 std::vector<ScaleFactor> GetSupportedScaleFactors() { |
| 128 return GetSupportedScaleFactorsInternal(); | 127 return GetSupportedScaleFactorsInternal(); |
| 129 } | 128 } |
| 130 | 129 |
| 131 namespace test { | 130 namespace test { |
| 132 | 131 |
| 133 void SetSupportedScaleFactors( | 132 void SetSupportedScaleFactors( |
| 134 const std::vector<ui::ScaleFactor>& scale_factors) { | 133 const std::vector<ui::ScaleFactor>& scale_factors) { |
| 135 std::vector<ui::ScaleFactor>& supported_scale_factors = | 134 std::vector<ui::ScaleFactor>& supported_scale_factors = |
| 136 GetSupportedScaleFactorsInternal(); | 135 GetSupportedScaleFactorsInternal(); |
| 137 supported_scale_factors.clear(); | 136 supported_scale_factors.clear(); |
| 138 | 137 |
| 139 for (size_t i = 0; i < scale_factors.size(); ++i) | 138 for (size_t i = 0; i < scale_factors.size(); ++i) |
| 140 supported_scale_factors.push_back(scale_factors[i]); | 139 supported_scale_factors.push_back(scale_factors[i]); |
| 141 } | 140 } |
| 142 | 141 |
| 143 } // namespace test | 142 } // namespace test |
| 144 | 143 |
| 145 #endif // OS_MACOSX | |
| 146 | |
| 147 } // namespace ui | 144 } // namespace ui |
| OLD | NEW |