Chromium Code Reviews| Index: ui/base/scale.cc |
| diff --git a/ui/base/scale.cc b/ui/base/scale.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3f4e4d7b050a7e1814f8a16d5c0c4acd63ea3c1f |
| --- /dev/null |
| +++ b/ui/base/scale.cc |
| @@ -0,0 +1,55 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/base/scale.h" |
| + |
| +#include "base/basictypes.h" |
| +#include "build/build_config.h" |
| + |
| +#if defined(OS_WIN) |
| +#include "ui/base/win/dpi.h" |
| +#include "ui/base/win/metro.h" |
| +#include <Windows.h> |
| +#endif // defined(OS_WIN) |
| + |
| +namespace { |
| + |
| +#if defined(OS_WIN) |
| + |
| +void GetScaleImplWin(bool* use_metro, bool* use_hidpi) { |
|
sky
2012/04/18 21:50:32
nit: Since it seems that metro and hidpi are mutut
|
| +#if defined(ENABLE_METRO) |
| + *use_metro = ui::IsInMetroMode(); |
| +#endif // defined(ENABLE_METRO) |
| +#if defined(ENABLE_HIDPI) |
| + *use_hidpi = ui::GetDPIScale() > 1.5; |
| +#endif // defined(ENABLE_HIDPI) |
| +} |
| + |
| +#endif // defined(OS_WIN) |
| + |
| +} // namespace |
| + |
| +namespace ui { |
| + |
| +const DisplayScale GetDisplayScale() { |
| +#if defined(USE_ASH) |
| + return DS_ASH; |
| +#elif !defined(OS_WIN) |
| + return DS_DESKTOP_100; |
| +#else // On Windows. |
| + bool use_metro = false; |
| + bool use_hidpi = false; |
| + GetScaleImplWin(&use_metro, &use_hidpi); |
| + if (use_metro) { |
| + // TODO(joi): Other Metro scales. |
| + return DS_METRO_100; |
| + } else if (use_hidpi) { |
| + return DS_DESKTOP_200; |
| + } else { |
| + return DS_DESKTOP_100; |
| + } |
| +#endif // On Windows. |
| +} |
| + |
| +} // namespace ui |