Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(672)

Side by Side Diff: ui/base/layout.cc

Issue 10412004: Revert "Revert 137734 - Select theme resources from ResourceBundle at requested scale factor." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass float scale_factor to ImageSkia. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "ui/base/ui_base_switches.h" 11 #include "ui/base/ui_base_switches.h"
12 12
13 #if defined(USE_AURA) && defined(USE_X11) 13 #if defined(USE_AURA) && defined(USE_X11)
14 #include "ui/base/touch/touch_factory.h" 14 #include "ui/base/touch/touch_factory.h"
15 #endif // defined(USE_AURA) && defined(USE_X11) 15 #endif // defined(USE_AURA) && defined(USE_X11)
16 16
17 #if defined(OS_WIN) 17 #if defined(OS_WIN)
18 #include "base/win/metro.h" 18 #include "base/win/metro.h"
19 #include <Windows.h> 19 #include <Windows.h>
20 #endif // defined(OS_WIN) 20 #endif // defined(OS_WIN)
21 21
22 namespace { 22 namespace {
23
23 // Helper function that determines whether we want to optimize the UI for touch. 24 // Helper function that determines whether we want to optimize the UI for touch.
24 bool UseTouchOptimizedUI() { 25 bool UseTouchOptimizedUI() {
25 // If --touch-optimized-ui is specified and not set to "auto", then override 26 // If --touch-optimized-ui is specified and not set to "auto", then override
26 // the hardware-determined setting (eg. for testing purposes). 27 // the hardware-determined setting (eg. for testing purposes).
27 if (CommandLine::ForCurrentProcess()->HasSwitch( 28 if (CommandLine::ForCurrentProcess()->HasSwitch(
28 switches::kTouchOptimizedUI)) { 29 switches::kTouchOptimizedUI)) {
29 const std::string switch_value = CommandLine::ForCurrentProcess()-> 30 const std::string switch_value = CommandLine::ForCurrentProcess()->
30 GetSwitchValueASCII(switches::kTouchOptimizedUI); 31 GetSwitchValueASCII(switches::kTouchOptimizedUI);
31 32
32 // Note that simply specifying the switch is the same as enabled. 33 // Note that simply specifying the switch is the same as enabled.
(...skipping 14 matching lines...) Expand all
47 return false; 48 return false;
48 #elif defined(USE_AURA) && defined(USE_X11) 49 #elif defined(USE_AURA) && defined(USE_X11)
49 // Determine whether touch-screen hardware is currently available. 50 // Determine whether touch-screen hardware is currently available.
50 // For now we assume this won't change over the life of the process, but 51 // For now we assume this won't change over the life of the process, but
51 // we'll probably want to support that. crbug.com/124399 52 // we'll probably want to support that. crbug.com/124399
52 return ui::TouchFactory::GetInstance()->IsTouchDevicePresent(); 53 return ui::TouchFactory::GetInstance()->IsTouchDevicePresent();
53 #else 54 #else
54 return false; 55 return false;
55 #endif 56 #endif
56 } 57 }
58
59 const float kScaleFactorScales[] = {1.0, 2.0};
60
57 } 61 }
58 62
59 namespace ui { 63 namespace ui {
60 64
61 // Note that this function should be extended to select 65 // Note that this function should be extended to select
62 // LAYOUT_TOUCH when appropriate on more platforms than just 66 // LAYOUT_TOUCH when appropriate on more platforms than just
63 // Windows and Ash. 67 // Windows and Ash.
64 DisplayLayout GetDisplayLayout() { 68 DisplayLayout GetDisplayLayout() {
65 #if defined(USE_ASH) 69 #if defined(USE_ASH)
66 if (UseTouchOptimizedUI()) 70 if (UseTouchOptimizedUI())
67 return LAYOUT_TOUCH; 71 return LAYOUT_TOUCH;
68 return LAYOUT_ASH; 72 return LAYOUT_ASH;
69 #elif defined(OS_WIN) 73 #elif defined(OS_WIN)
70 if (UseTouchOptimizedUI()) 74 if (UseTouchOptimizedUI())
71 return LAYOUT_TOUCH; 75 return LAYOUT_TOUCH;
72 return LAYOUT_DESKTOP; 76 return LAYOUT_DESKTOP;
73 #else 77 #else
74 return LAYOUT_DESKTOP; 78 return LAYOUT_DESKTOP;
75 #endif 79 #endif
76 } 80 }
77 81
82 float GetScaleFactorScale(ScaleFactor scale_factor) {
83 return kScaleFactorScales[scale_factor];
sky 2012/05/22 15:49:45 If you're going to use ScaleFactor as an index int
flackr 2012/05/22 17:29:40 Done.
84 }
85
78 } // namespace ui 86 } // namespace ui
OLDNEW
« ui/base/layout.h ('K') | « ui/base/layout.h ('k') | ui/base/resource/data_pack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698