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

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

Issue 11886074: Use correct favicon scale factor on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split DeviceTelephonyInfo from DeviceDisplayInfo; added SCALE_FACTOR_150P and 300P. Created 7 years, 11 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
« no previous file with comments | « ui/base/layout.h ('k') | ui/base/layout_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } else if (switch_value != switches::kTouchOptimizedUIAuto) { 57 } else if (switch_value != switches::kTouchOptimizedUIAuto) {
58 LOG(ERROR) << "Invalid --touch-optimized-ui option: " << switch_value; 58 LOG(ERROR) << "Invalid --touch-optimized-ui option: " << switch_value;
59 } 59 }
60 } 60 }
61 61
62 // We use the touch layout only when we are running in Metro mode. 62 // We use the touch layout only when we are running in Metro mode.
63 return base::win::IsMetroProcess() && base::win::IsTouchEnabled(); 63 return base::win::IsMetroProcess() && base::win::IsTouchEnabled();
64 } 64 }
65 #endif // defined(OS_WIN) 65 #endif // defined(OS_WIN)
66 66
67 const float kScaleFactorScales[] = {1.0f, 1.0f, 1.4f, 1.8f, 2.0f}; 67 const float kScaleFactorScales[] = {1.0f, 1.0f, 1.4f, 1.5f, 1.8f, 2.0f, 3.0f};
68 COMPILE_ASSERT(NUM_SCALE_FACTORS == arraysize(kScaleFactorScales), 68 COMPILE_ASSERT(NUM_SCALE_FACTORS == arraysize(kScaleFactorScales),
69 kScaleFactorScales_incorrect_size); 69 kScaleFactorScales_incorrect_size);
70 const size_t kScaleFactorScalesLength = arraysize(kScaleFactorScales); 70 const size_t kScaleFactorScalesLength = arraysize(kScaleFactorScales);
71 71
72 std::vector<ScaleFactor>& GetSupportedScaleFactorsInternal() { 72 std::vector<ScaleFactor>& GetSupportedScaleFactorsInternal() {
73 static std::vector<ScaleFactor>* supported_scale_factors = 73 static std::vector<ScaleFactor>* supported_scale_factors =
74 new std::vector<ScaleFactor>(); 74 new std::vector<ScaleFactor>();
75 if (supported_scale_factors->empty()) { 75 if (supported_scale_factors->empty()) {
76 #if !defined(OS_IOS) 76 #if !defined(OS_IOS)
77 // On platforms other than iOS, 100P is always a supported scale factor. 77 // On platforms other than iOS, 100P is always a supported scale factor.
78 supported_scale_factors->push_back(SCALE_FACTOR_100P); 78 supported_scale_factors->push_back(SCALE_FACTOR_100P);
79 #endif 79 #endif
80 80
81 #if defined(OS_IOS) 81 #if defined(OS_ANDROID)
82 const gfx::Display display =
83 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
84 const float display_density = display.device_scale_factor();
85 for (int i = SCALE_FACTOR_100P; i < NUM_SCALE_FACTORS - 1; ++i) {
Nico 2013/01/18 01:27:33 nit: I'd start with 0
aruslan 2013/01/18 03:21:07 Discussed off-line; keeping as is.
86 if (display_density <= kScaleFactorScales[i]) {
87 if (i != SCALE_FACTOR_100P)
Nico 2013/01/18 01:27:33 do you need to static_cast<ScaleFactor>(i) here?
aruslan 2013/01/18 03:21:07 Done.
88 supported_scale_factors->push_back(static_cast<ScaleFactor>(i));
89 break;
90 }
91 }
92 #elif defined(OS_IOS)
82 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); 93 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
83 if (display.device_scale_factor() > 1.0) { 94 if (display.device_scale_factor() > 1.0) {
84 DCHECK_EQ(2.0, display.device_scale_factor()); 95 DCHECK_EQ(2.0, display.device_scale_factor());
85 supported_scale_factors->push_back(SCALE_FACTOR_200P); 96 supported_scale_factors->push_back(SCALE_FACTOR_200P);
86 } else { 97 } else {
87 supported_scale_factors->push_back(SCALE_FACTOR_100P); 98 supported_scale_factors->push_back(SCALE_FACTOR_100P);
88 } 99 }
89 #elif defined(OS_MACOSX) 100 #elif defined(OS_MACOSX)
90 if (base::mac::IsOSLionOrLater()) 101 if (base::mac::IsOSLionOrLater())
91 supported_scale_factors->push_back(SCALE_FACTOR_200P); 102 supported_scale_factors->push_back(SCALE_FACTOR_200P);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); 192 gfx::Screen* screen = gfx::Screen::GetScreenFor(view);
182 if (screen->IsDIPEnabled()) { 193 if (screen->IsDIPEnabled()) {
183 gfx::Display display = screen->GetDisplayNearestWindow(view); 194 gfx::Display display = screen->GetDisplayNearestWindow(view);
184 return GetScaleFactorFromScale(display.device_scale_factor()); 195 return GetScaleFactorFromScale(display.device_scale_factor());
185 } 196 }
186 return ui::SCALE_FACTOR_100P; 197 return ui::SCALE_FACTOR_100P;
187 } 198 }
188 #endif // !defined(OS_MACOSX) 199 #endif // !defined(OS_MACOSX)
189 200
190 } // namespace ui 201 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/layout.h ('k') | ui/base/layout_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698