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

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

Issue 1263853002: Unified Desktop: Support 2xDSF display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « ash/display/display_util.cc ('k') | ash/display/unified_mouse_warp_controller.h » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/root_window_transformers.h" 5 #include "ash/display/root_window_transformers.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_info.h" 10 #include "ash/display/display_info.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // RootWindowTransformer for ash environment. 138 // RootWindowTransformer for ash environment.
139 class AshRootWindowTransformer : public RootWindowTransformer { 139 class AshRootWindowTransformer : public RootWindowTransformer {
140 public: 140 public:
141 AshRootWindowTransformer(aura::Window* root, 141 AshRootWindowTransformer(aura::Window* root,
142 const gfx::Display& display) 142 const gfx::Display& display)
143 : root_window_(root) { 143 : root_window_(root) {
144 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 144 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
145 DisplayInfo info = display_manager->GetDisplayInfo(display.id()); 145 DisplayInfo info = display_manager->GetDisplayInfo(display.id());
146 host_insets_ = info.GetOverscanInsetsInPixel(); 146 host_insets_ = info.GetOverscanInsetsInPixel();
147 root_window_ui_scale_ = info.GetEffectiveUIScale(); 147 root_window_ui_scale_ = info.GetEffectiveUIScale();
148 // In unified mode, the scaling happen when mirroring, so don't apply
149 // scaling to the root window.
150 const float apply_ui_scale =
151 display_manager->IsInUnifiedMode() ? 1.0f : root_window_ui_scale_;
152
153 root_window_bounds_transform_ = 148 root_window_bounds_transform_ =
154 CreateInsetsAndScaleTransform( 149 CreateInsetsAndScaleTransform(host_insets_,
155 host_insets_, display.device_scale_factor(), apply_ui_scale) * 150 display.device_scale_factor(),
151 root_window_ui_scale_) *
156 CreateRotationTransform(root, display); 152 CreateRotationTransform(root, display);
157 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 153 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
158 switches::kAshEnableMirroredScreen)) { 154 switches::kAshEnableMirroredScreen)) {
159 // Apply the tranform that flips the screen image horizontally so that 155 // Apply the tranform that flips the screen image horizontally so that
160 // the screen looks normal when reflected on a mirror. 156 // the screen looks normal when reflected on a mirror.
161 root_window_bounds_transform_ = 157 root_window_bounds_transform_ =
162 root_window_bounds_transform_ * CreateMirrorTransform(display); 158 root_window_bounds_transform_ * CreateMirrorTransform(display);
163 } 159 }
164 transform_ = root_window_bounds_transform_ * CreateMagnifierTransform(root); 160 transform_ = root_window_bounds_transform_ * CreateMagnifierTransform(root);
165 161
166 CHECK(transform_.GetInverse(&invert_transform_)); 162 CHECK(transform_.GetInverse(&invert_transform_));
167 } 163 }
168 164
169 // aura::RootWindowTransformer overrides: 165 // aura::RootWindowTransformer overrides:
170 gfx::Transform GetTransform() const override { return transform_; } 166 gfx::Transform GetTransform() const override { return transform_; }
171 gfx::Transform GetInverseTransform() const override { 167 gfx::Transform GetInverseTransform() const override {
172 return invert_transform_; 168 return invert_transform_;
173 } 169 }
174 gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const override { 170 gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const override {
175 gfx::Rect bounds(host_size); 171 gfx::Rect bounds(host_size);
176 bounds.Inset(host_insets_); 172 bounds.Inset(host_insets_);
177 bounds = ui::ConvertRectToDIP(root_window_->layer(), bounds); 173 bounds = ui::ConvertRectToDIP(root_window_->layer(), bounds);
178 gfx::RectF new_bounds(bounds); 174 gfx::RectF new_bounds(bounds);
179 root_window_bounds_transform_.TransformRect(&new_bounds); 175 root_window_bounds_transform_.TransformRect(&new_bounds);
180 if (Shell::GetInstance()->display_manager()->IsInUnifiedMode()) { 176 // Apply |root_window_scale_| twice as the downscaling
181 new_bounds.Scale(root_window_ui_scale_); 177 // is already applied once in |SetTransformInternal()|.
182 } else { 178 // TODO(oshima): This is a bit ugly. Consider specifying
183 // Apply |root_window_scale_| twice as the downscaling 179 // the pseudo host resolution instead.
184 // is already applied once in |SetTransformInternal()|. 180 new_bounds.Scale(root_window_ui_scale_ * root_window_ui_scale_);
185 // TODO(oshima): This is a bit ugly. Consider specifying
186 // the pseudo host resolution instead.
187 new_bounds.Scale(root_window_ui_scale_ * root_window_ui_scale_);
188 }
189 // Ignore the origin because RootWindow's insets are handled by 181 // Ignore the origin because RootWindow's insets are handled by
190 // the transform. 182 // the transform.
191 // Floor the size because the bounds is no longer aligned to 183 // Floor the size because the bounds is no longer aligned to
192 // backing pixel when |root_window_scale_| is specified 184 // backing pixel when |root_window_scale_| is specified
193 // (850 height at 1.25 scale becomes 1062.5 for example.) 185 // (850 height at 1.25 scale becomes 1062.5 for example.)
194 return gfx::Rect(gfx::ToFlooredSize(new_bounds.size())); 186 return gfx::Rect(gfx::ToFlooredSize(new_bounds.size()));
195 } 187 }
196 188
197 gfx::Insets GetHostInsets() const override { return host_insets_; } 189 gfx::Insets GetHostInsets() const override { return host_insets_; }
198 190
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 gfx::Rect root_bounds_; 272 gfx::Rect root_bounds_;
281 gfx::Insets insets_; 273 gfx::Insets insets_;
282 274
283 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer); 275 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer);
284 }; 276 };
285 277
286 class PartialBoundsRootWindowTransformer : public RootWindowTransformer { 278 class PartialBoundsRootWindowTransformer : public RootWindowTransformer {
287 public: 279 public:
288 PartialBoundsRootWindowTransformer(const gfx::Rect& screen_bounds, 280 PartialBoundsRootWindowTransformer(const gfx::Rect& screen_bounds,
289 const gfx::Display& display) { 281 const gfx::Display& display) {
282 gfx::Display unified_display =
283 Shell::GetInstance()->GetScreen()->GetPrimaryDisplay();
290 DisplayInfo display_info = 284 DisplayInfo display_info =
291 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); 285 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id());
292 root_bounds_ = gfx::Rect(display_info.bounds_in_native().size()); 286 root_bounds_ = gfx::Rect(display_info.bounds_in_native().size());
293 float scale = 287 float scale = root_bounds_.height() /
294 root_bounds_.height() / static_cast<float>(screen_bounds.height()); 288 static_cast<float>(screen_bounds.height()) /
289 unified_display.device_scale_factor();
295 transform_.Scale(scale, scale); 290 transform_.Scale(scale, scale);
296 transform_.Translate(-SkIntToMScalar(display.bounds().x()), 291 transform_.Translate(-SkIntToMScalar(display.bounds().x()),
297 -SkIntToMScalar(display.bounds().y())); 292 -SkIntToMScalar(display.bounds().y()));
298 } 293 }
299 294
300 // RootWindowTransformer: 295 // RootWindowTransformer:
301 gfx::Transform GetTransform() const override { return transform_; } 296 gfx::Transform GetTransform() const override { return transform_; }
302 gfx::Transform GetInverseTransform() const override { 297 gfx::Transform GetInverseTransform() const override {
303 gfx::Transform invert; 298 gfx::Transform invert;
304 CHECK(transform_.GetInverse(&invert)); 299 CHECK(transform_.GetInverse(&invert));
(...skipping 26 matching lines...) Expand all
331 mirror_display_info); 326 mirror_display_info);
332 } 327 }
333 328
334 RootWindowTransformer* CreateRootWindowTransformerForUnifiedDesktop( 329 RootWindowTransformer* CreateRootWindowTransformerForUnifiedDesktop(
335 const gfx::Rect& screen_bounds, 330 const gfx::Rect& screen_bounds,
336 const gfx::Display& display) { 331 const gfx::Display& display) {
337 return new PartialBoundsRootWindowTransformer(screen_bounds, display); 332 return new PartialBoundsRootWindowTransformer(screen_bounds, display);
338 } 333 }
339 334
340 } // namespace ash 335 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_util.cc ('k') | ash/display/unified_mouse_warp_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698