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

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

Issue 2270553002: Move ash::DisplayInfo to ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 3 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
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/common/ash_switches.h" 9 #include "ash/common/ash_switches.h"
10 #include "ash/common/display/display_info.h"
11 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
12 #include "ash/host/root_window_transformer.h" 11 #include "ash/host/root_window_transformer.h"
13 #include "ash/magnifier/magnification_controller.h" 12 #include "ash/magnifier/magnification_controller.h"
14 #include "ash/shell.h" 13 #include "ash/shell.h"
15 #include "base/command_line.h" 14 #include "base/command_line.h"
16 #include "third_party/skia/include/core/SkMatrix44.h" 15 #include "third_party/skia/include/core/SkMatrix44.h"
17 #include "ui/aura/window_event_dispatcher.h" 16 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/aura/window_property.h" 17 #include "ui/aura/window_property.h"
19 #include "ui/compositor/dip_util.h" 18 #include "ui/compositor/dip_util.h"
20 #include "ui/display/display.h" 19 #include "ui/display/display.h"
20 #include "ui/display/manager/managed_display_info.h"
21 #include "ui/display/screen.h" 21 #include "ui/display/screen.h"
22 #include "ui/gfx/geometry/insets.h" 22 #include "ui/gfx/geometry/insets.h"
23 #include "ui/gfx/geometry/size_conversions.h" 23 #include "ui/gfx/geometry/size_conversions.h"
24 #include "ui/gfx/transform.h" 24 #include "ui/gfx/transform.h"
25 #include "ui/gfx/transform.h" 25 #include "ui/gfx/transform.h"
26 26
27 DECLARE_WINDOW_PROPERTY_TYPE(display::Display::Rotation); 27 DECLARE_WINDOW_PROPERTY_TYPE(display::Display::Rotation);
28 28
29 namespace ash { 29 namespace ash {
30 namespace { 30 namespace {
(...skipping 15 matching lines...) Expand all
46 } 46 }
47 } 47 }
48 } 48 }
49 49
50 // TODO(oshima): Transformers should be able to adjust itself 50 // TODO(oshima): Transformers should be able to adjust itself
51 // when the device scale factor is changed, instead of 51 // when the device scale factor is changed, instead of
52 // precalculating the transform using fixed value. 52 // precalculating the transform using fixed value.
53 53
54 gfx::Transform CreateRotationTransform(aura::Window* root_window, 54 gfx::Transform CreateRotationTransform(aura::Window* root_window,
55 const display::Display& display) { 55 const display::Display& display) {
56 DisplayInfo info = 56 display::ManagedDisplayInfo info =
57 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); 57 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id());
58 58
59 // TODO(oshima): Add animation. (crossfade+rotation, or just cross-fade) 59 // TODO(oshima): Add animation. (crossfade+rotation, or just cross-fade)
60 #if defined(OS_WIN) 60 #if defined(OS_WIN)
61 // Windows 8 bots refused to resize the host window, and 61 // Windows 8 bots refused to resize the host window, and
62 // updating the transform results in incorrectly resizing 62 // updating the transform results in incorrectly resizing
63 // the root window. Don't apply the transform unless 63 // the root window. Don't apply the transform unless
64 // necessary so that unit tests pass on win8 bots. 64 // necessary so that unit tests pass on win8 bots.
65 if (info.GetActiveRotation() == 65 if (info.GetActiveRotation() ==
66 root_window->GetProperty(kRotationPropertyKey)) { 66 root_window->GetProperty(kRotationPropertyKey)) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 transform.Translate(-display.size().width(), 0); 132 transform.Translate(-display.size().width(), 0);
133 return transform; 133 return transform;
134 } 134 }
135 135
136 // RootWindowTransformer for ash environment. 136 // RootWindowTransformer for ash environment.
137 class AshRootWindowTransformer : public RootWindowTransformer { 137 class AshRootWindowTransformer : public RootWindowTransformer {
138 public: 138 public:
139 AshRootWindowTransformer(aura::Window* root, const display::Display& display) 139 AshRootWindowTransformer(aura::Window* root, const display::Display& display)
140 : root_window_(root) { 140 : root_window_(root) {
141 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 141 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
142 DisplayInfo info = display_manager->GetDisplayInfo(display.id()); 142 display::ManagedDisplayInfo info =
143 display_manager->GetDisplayInfo(display.id());
143 host_insets_ = info.GetOverscanInsetsInPixel(); 144 host_insets_ = info.GetOverscanInsetsInPixel();
144 root_window_ui_scale_ = info.GetEffectiveUIScale(); 145 root_window_ui_scale_ = info.GetEffectiveUIScale();
145 root_window_bounds_transform_ = 146 root_window_bounds_transform_ =
146 CreateInsetsAndScaleTransform(host_insets_, 147 CreateInsetsAndScaleTransform(host_insets_,
147 display.device_scale_factor(), 148 display.device_scale_factor(),
148 root_window_ui_scale_) * 149 root_window_ui_scale_) *
149 CreateRotationTransform(root, display); 150 CreateRotationTransform(root, display);
150 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 151 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
151 switches::kAshEnableMirroredScreen)) { 152 switches::kAshEnableMirroredScreen)) {
152 // Apply the tranform that flips the screen image horizontally so that 153 // Apply the tranform that flips the screen image horizontally so that
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 209
209 DISALLOW_COPY_AND_ASSIGN(AshRootWindowTransformer); 210 DISALLOW_COPY_AND_ASSIGN(AshRootWindowTransformer);
210 }; 211 };
211 212
212 // RootWindowTransformer for mirror root window. We simply copy the 213 // RootWindowTransformer for mirror root window. We simply copy the
213 // texture (bitmap) of the source display into the mirror window, so 214 // texture (bitmap) of the source display into the mirror window, so
214 // the root window bounds is the same as the source display's 215 // the root window bounds is the same as the source display's
215 // pixel size (excluding overscan insets). 216 // pixel size (excluding overscan insets).
216 class MirrorRootWindowTransformer : public RootWindowTransformer { 217 class MirrorRootWindowTransformer : public RootWindowTransformer {
217 public: 218 public:
218 MirrorRootWindowTransformer(const DisplayInfo& source_display_info, 219 MirrorRootWindowTransformer(
219 const DisplayInfo& mirror_display_info) { 220 const display::ManagedDisplayInfo& source_display_info,
221 const display::ManagedDisplayInfo& mirror_display_info) {
220 root_bounds_ = gfx::Rect(source_display_info.bounds_in_native().size()); 222 root_bounds_ = gfx::Rect(source_display_info.bounds_in_native().size());
221 gfx::Rect mirror_display_rect = 223 gfx::Rect mirror_display_rect =
222 gfx::Rect(mirror_display_info.bounds_in_native().size()); 224 gfx::Rect(mirror_display_info.bounds_in_native().size());
223 225
224 bool letterbox = root_bounds_.width() * mirror_display_rect.height() > 226 bool letterbox = root_bounds_.width() * mirror_display_rect.height() >
225 root_bounds_.height() * mirror_display_rect.width(); 227 root_bounds_.height() * mirror_display_rect.width();
226 if (letterbox) { 228 if (letterbox) {
227 float mirror_scale_ratio = 229 float mirror_scale_ratio =
228 (static_cast<float>(root_bounds_.width()) / 230 (static_cast<float>(root_bounds_.width()) /
229 static_cast<float>(mirror_display_rect.width())); 231 static_cast<float>(mirror_display_rect.width()));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 273
272 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer); 274 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer);
273 }; 275 };
274 276
275 class PartialBoundsRootWindowTransformer : public RootWindowTransformer { 277 class PartialBoundsRootWindowTransformer : public RootWindowTransformer {
276 public: 278 public:
277 PartialBoundsRootWindowTransformer(const gfx::Rect& screen_bounds, 279 PartialBoundsRootWindowTransformer(const gfx::Rect& screen_bounds,
278 const display::Display& display) { 280 const display::Display& display) {
279 display::Display unified_display = 281 display::Display unified_display =
280 display::Screen::GetScreen()->GetPrimaryDisplay(); 282 display::Screen::GetScreen()->GetPrimaryDisplay();
281 DisplayInfo display_info = 283 display::ManagedDisplayInfo display_info =
282 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); 284 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id());
283 root_bounds_ = gfx::Rect(display_info.bounds_in_native().size()); 285 root_bounds_ = gfx::Rect(display_info.bounds_in_native().size());
284 float scale = root_bounds_.height() / 286 float scale = root_bounds_.height() /
285 static_cast<float>(screen_bounds.height()) / 287 static_cast<float>(screen_bounds.height()) /
286 unified_display.device_scale_factor(); 288 unified_display.device_scale_factor();
287 transform_.Scale(scale, scale); 289 transform_.Scale(scale, scale);
288 transform_.Translate(-SkIntToMScalar(display.bounds().x()), 290 transform_.Translate(-SkIntToMScalar(display.bounds().x()),
289 -SkIntToMScalar(display.bounds().y())); 291 -SkIntToMScalar(display.bounds().y()));
290 } 292 }
291 293
(...skipping 18 matching lines...) Expand all
310 312
311 } // namespace 313 } // namespace
312 314
313 RootWindowTransformer* CreateRootWindowTransformerForDisplay( 315 RootWindowTransformer* CreateRootWindowTransformerForDisplay(
314 aura::Window* root, 316 aura::Window* root,
315 const display::Display& display) { 317 const display::Display& display) {
316 return new AshRootWindowTransformer(root, display); 318 return new AshRootWindowTransformer(root, display);
317 } 319 }
318 320
319 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( 321 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay(
320 const DisplayInfo& source_display_info, 322 const display::ManagedDisplayInfo& source_display_info,
321 const DisplayInfo& mirror_display_info) { 323 const display::ManagedDisplayInfo& mirror_display_info) {
322 return new MirrorRootWindowTransformer(source_display_info, 324 return new MirrorRootWindowTransformer(source_display_info,
323 mirror_display_info); 325 mirror_display_info);
324 } 326 }
325 327
326 RootWindowTransformer* CreateRootWindowTransformerForUnifiedDesktop( 328 RootWindowTransformer* CreateRootWindowTransformerForUnifiedDesktop(
327 const gfx::Rect& screen_bounds, 329 const gfx::Rect& screen_bounds,
328 const display::Display& display) { 330 const display::Display& display) {
329 return new PartialBoundsRootWindowTransformer(screen_bounds, display); 331 return new PartialBoundsRootWindowTransformer(screen_bounds, display);
330 } 332 }
331 333
332 } // namespace ash 334 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/root_window_transformers.h ('k') | ash/display/root_window_transformers_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698