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

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

Issue 715543004: Add mirrored screen option (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/ash_switches.h"
9 #include "ash/display/display_info.h" 10 #include "ash/display/display_info.h"
10 #include "ash/display/display_manager.h" 11 #include "ash/display/display_manager.h"
11 #include "ash/host/root_window_transformer.h" 12 #include "ash/host/root_window_transformer.h"
12 #include "ash/magnifier/magnification_controller.h" 13 #include "ash/magnifier/magnification_controller.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/command_line.h"
15 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
16 #include "third_party/skia/include/utils/SkMatrix44.h" 18 #include "third_party/skia/include/utils/SkMatrix44.h"
17 #include "ui/aura/window_event_dispatcher.h" 19 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/aura/window_property.h" 20 #include "ui/aura/window_property.h"
19 #include "ui/compositor/dip_util.h" 21 #include "ui/compositor/dip_util.h"
20 #include "ui/gfx/display.h" 22 #include "ui/gfx/display.h"
21 #include "ui/gfx/insets.h" 23 #include "ui/gfx/insets.h"
22 #include "ui/gfx/size_conversions.h" 24 #include "ui/gfx/size_conversions.h"
23 #include "ui/gfx/transform.h" 25 #include "ui/gfx/transform.h"
24 #include "ui/gfx/transform.h" 26 #include "ui/gfx/transform.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (insets.top() != 0 || insets.left() != 0) { 117 if (insets.top() != 0 || insets.left() != 0) {
116 float x_offset = insets.left() / device_scale_factor; 118 float x_offset = insets.left() / device_scale_factor;
117 float y_offset = insets.top() / device_scale_factor; 119 float y_offset = insets.top() / device_scale_factor;
118 transform.Translate(x_offset, y_offset); 120 transform.Translate(x_offset, y_offset);
119 } 121 }
120 float inverted_scale = 1.0f / ui_scale; 122 float inverted_scale = 1.0f / ui_scale;
121 transform.Scale(inverted_scale, inverted_scale); 123 transform.Scale(inverted_scale, inverted_scale);
122 return transform; 124 return transform;
123 } 125 }
124 126
127 gfx::Transform CreateMirrorTransform(const gfx::Display& display) {
Jun Mukai 2014/11/13 17:36:59 one more nit: could you write a comment for this f
oshima 2014/11/13 20:30:34 Added comment where the transform is applied.
128 gfx::Transform transform;
129 transform.matrix().set3x3(-1, 0, 0,
130 0, 1, 0,
131 0, 0, 1);
132 transform.Translate(-display.size().width(), 0);
133 return transform;
134 }
135
125 // RootWindowTransformer for ash environment. 136 // RootWindowTransformer for ash environment.
126 class AshRootWindowTransformer : public RootWindowTransformer { 137 class AshRootWindowTransformer : public RootWindowTransformer {
127 public: 138 public:
128 AshRootWindowTransformer(aura::Window* root, 139 AshRootWindowTransformer(aura::Window* root,
129 const gfx::Display& display) 140 const gfx::Display& display)
130 : root_window_(root) { 141 : root_window_(root) {
131 DisplayInfo info = Shell::GetInstance()->display_manager()-> 142 DisplayInfo info = Shell::GetInstance()->display_manager()->
132 GetDisplayInfo(display.id()); 143 GetDisplayInfo(display.id());
133 host_insets_ = info.GetOverscanInsetsInPixel(); 144 host_insets_ = info.GetOverscanInsetsInPixel();
134 root_window_ui_scale_ = info.GetEffectiveUIScale(); 145 root_window_ui_scale_ = info.GetEffectiveUIScale();
135 root_window_bounds_transform_ = 146 root_window_bounds_transform_ =
136 CreateInsetsAndScaleTransform(host_insets_, 147 CreateInsetsAndScaleTransform(host_insets_,
137 display.device_scale_factor(), 148 display.device_scale_factor(),
138 root_window_ui_scale_) * 149 root_window_ui_scale_) *
139 CreateRotationTransform(root, display); 150 CreateRotationTransform(root, display);
151 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
152 switches::kAshEnableMirroredScreen)) {
153 root_window_bounds_transform_ =
154 root_window_bounds_transform_ * CreateMirrorTransform(display);
155 }
140 transform_ = root_window_bounds_transform_ * CreateMagnifierTransform(root); 156 transform_ = root_window_bounds_transform_ * CreateMagnifierTransform(root);
157
141 CHECK(transform_.GetInverse(&invert_transform_)); 158 CHECK(transform_.GetInverse(&invert_transform_));
142 } 159 }
143 160
144 // aura::RootWindowTransformer overrides: 161 // aura::RootWindowTransformer overrides:
145 gfx::Transform GetTransform() const override { return transform_; } 162 gfx::Transform GetTransform() const override { return transform_; }
146 gfx::Transform GetInverseTransform() const override { 163 gfx::Transform GetInverseTransform() const override {
147 return invert_transform_; 164 return invert_transform_;
148 } 165 }
149 gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const override { 166 gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const override {
150 gfx::Rect bounds(host_size); 167 gfx::Rect bounds(host_size);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 280 }
264 281
265 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( 282 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay(
266 const DisplayInfo& source_display_info, 283 const DisplayInfo& source_display_info,
267 const DisplayInfo& mirror_display_info) { 284 const DisplayInfo& mirror_display_info) {
268 return new MirrorRootWindowTransformer(source_display_info, 285 return new MirrorRootWindowTransformer(source_display_info,
269 mirror_display_info); 286 mirror_display_info);
270 } 287 }
271 288
272 } // namespace ash 289 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698