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

Side by Side Diff: ash/display/display_manager.cc

Issue 789583002: Updates subpixel positioning and hinting when DSF is changed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GN Created 6 years 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
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 "ash/display/display_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 static gfx::Display* invalid_display = new gfx::Display(); 104 static gfx::Display* invalid_display = new gfx::Display();
105 return *invalid_display; 105 return *invalid_display;
106 } 106 }
107 107
108 void MaybeInitInternalDisplay(int64 id) { 108 void MaybeInitInternalDisplay(int64 id) {
109 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 109 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
110 if (command_line->HasSwitch(switches::kAshUseFirstDisplayAsInternal)) 110 if (command_line->HasSwitch(switches::kAshUseFirstDisplayAsInternal))
111 gfx::Display::SetInternalDisplayId(id); 111 gfx::Display::SetInternalDisplayId(id);
112 } 112 }
113 113
114 class FontRenderParamsRewriterAsh : public gfx::FontRenderParamsRewriter {
115 public:
116 FontRenderParamsRewriterAsh() {}
117 ~FontRenderParamsRewriterAsh() override {}
118
119 private:
120 bool IsBrowserTextSubpixelPositioningEnabled() {
121 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
122 if (!display_manager->HasInternalDisplay())
123 return false;
124 int64 internal_id = gfx::Display::InternalDisplayId();
125 const gfx::Display& internal_display =
126 display_manager->GetDisplayForId(internal_id);
127 // The internal display ID exists but the display object does not exist in
128 // case of the docked mode.
129 if (!internal_display.is_valid())
130 return false;
131 const DisplayInfo& display_info =
132 display_manager->GetDisplayInfo(internal_id);
133 return display_info.GetEffectiveDeviceScaleFactor() > 1.0f;
134 }
135
136 // gfx::FontRenderParamsRewriter:
137 void RewriteParams(gfx::FontRenderParams* params) override {
138 #if defined(OS_CHROMEOS)
139 if (params->antialiasing) {
140 params->subpixel_positioning = IsBrowserTextSubpixelPositioningEnabled();
141 if (params->subpixel_positioning)
142 params->hinting = gfx::FontRenderParams::HINTING_NONE;
143 }
144 #endif
145 }
146 };
147
114 } // namespace 148 } // namespace
115 149
116 using std::string; 150 using std::string;
117 using std::vector; 151 using std::vector;
118 152
119 DisplayManager::DisplayManager() 153 DisplayManager::DisplayManager()
120 : delegate_(NULL), 154 : delegate_(NULL),
121 screen_ash_(new ScreenAsh), 155 screen_ash_(new ScreenAsh),
122 screen_(screen_ash_.get()), 156 screen_(screen_ash_.get()),
123 layout_store_(new DisplayLayoutStore), 157 layout_store_(new DisplayLayoutStore),
(...skipping 21 matching lines...) Expand all
145 // If there is no native, or the native was for shutdown, 179 // If there is no native, or the native was for shutdown,
146 // use ash's screen. 180 // use ash's screen.
147 if (!current_native || 181 if (!current_native ||
148 current_native == screen_for_shutdown) { 182 current_native == screen_for_shutdown) {
149 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, 183 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
150 screen_ash_.get()); 184 screen_ash_.get());
151 } 185 }
152 } 186 }
153 187
154 DisplayManager::~DisplayManager() { 188 DisplayManager::~DisplayManager() {
155 #if defined(OS_CHROMEOS) 189 gfx::FontRenderParamsRewriter::Shutdown();
156 // Reset the font params.
157 gfx::SetFontRenderParamsDeviceScaleFactor(1.0f);
158 #endif
159 } 190 }
160 191
161 // static 192 // static
162 std::vector<float> DisplayManager::GetScalesForDisplay( 193 std::vector<float> DisplayManager::GetScalesForDisplay(
163 const DisplayInfo& info) { 194 const DisplayInfo& info) {
164 195
165 #define ASSIGN_ARRAY(v, a) v.assign(a, a + arraysize(a)) 196 #define ASSIGN_ARRAY(v, a) v.assign(a, a + arraysize(a))
166 197
167 std::vector<float> ret; 198 std::vector<float> ret;
168 if (info.device_scale_factor() == 2.0f) { 199 if (info.device_scale_factor() == 2.0f) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 262
232 void DisplayManager::InitDefaultDisplay() { 263 void DisplayManager::InitDefaultDisplay() {
233 DisplayInfoList info_list; 264 DisplayInfoList info_list;
234 info_list.push_back(DisplayInfo::CreateFromSpec(std::string())); 265 info_list.push_back(DisplayInfo::CreateFromSpec(std::string()));
235 info_list.back().set_native(true); 266 info_list.back().set_native(true);
236 MaybeInitInternalDisplay(info_list[0].id()); 267 MaybeInitInternalDisplay(info_list[0].id());
237 OnNativeDisplaysChanged(info_list); 268 OnNativeDisplaysChanged(info_list);
238 } 269 }
239 270
240 void DisplayManager::InitFontParams() { 271 void DisplayManager::InitFontParams() {
241 #if defined(OS_CHROMEOS) 272 gfx::FontRenderParamsRewriter::SetInstance(new FontRenderParamsRewriterAsh());
242 if (!HasInternalDisplay())
243 return;
244 const DisplayInfo& display_info =
245 GetDisplayInfo(gfx::Display::InternalDisplayId());
246 gfx::SetFontRenderParamsDeviceScaleFactor(
247 display_info.GetEffectiveDeviceScaleFactor());
248 #endif // OS_CHROMEOS
249 } 273 }
250 274
251 // static 275 // static
252 void DisplayManager::UpdateDisplayBoundsForLayoutById( 276 void DisplayManager::UpdateDisplayBoundsForLayoutById(
253 const DisplayLayout& layout, 277 const DisplayLayout& layout,
254 const gfx::Display& primary_display, 278 const gfx::Display& primary_display,
255 int64 secondary_display_id) { 279 int64 secondary_display_id) {
256 DCHECK_NE(gfx::Display::kInvalidDisplayID, secondary_display_id); 280 DCHECK_NE(gfx::Display::kInvalidDisplayID, secondary_display_id);
257 UpdateDisplayBoundsForLayout( 281 UpdateDisplayBoundsForLayout(
258 layout, primary_display, 282 layout, primary_display,
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 new_secondary_origin.Offset(-secondary_bounds.width(), offset); 1321 new_secondary_origin.Offset(-secondary_bounds.width(), offset);
1298 break; 1322 break;
1299 } 1323 }
1300 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); 1324 gfx::Insets insets = secondary_display->GetWorkAreaInsets();
1301 secondary_display->set_bounds( 1325 secondary_display->set_bounds(
1302 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 1326 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
1303 secondary_display->UpdateWorkAreaFromInsets(insets); 1327 secondary_display->UpdateWorkAreaFromInsets(insets);
1304 } 1328 }
1305 1329
1306 } // namespace ash 1330 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698