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

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

Issue 201573015: Introdcue AshWindowTreeHost and move ash/chrome specific code in WTH to ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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 | « ash/display/mirror_window_controller.h ('k') | ash/display/root_window_transformers.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/mirror_window_controller.h" 5 #include "ash/display/mirror_window_controller.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 // Xlib.h defines RootWindow. 10 // Xlib.h defines RootWindow.
11 #undef RootWindow 11 #undef RootWindow
12 #endif 12 #endif
13 13
14 #include "ash/display/cursor_window_controller.h" 14 #include "ash/display/cursor_window_controller.h"
15 #include "ash/display/display_controller.h" 15 #include "ash/display/display_controller.h"
16 #include "ash/display/display_info.h" 16 #include "ash/display/display_info.h"
17 #include "ash/display/display_manager.h" 17 #include "ash/display/display_manager.h"
18 #include "ash/display/root_window_transformers.h" 18 #include "ash/display/root_window_transformers.h"
19 #include "ash/host/window_tree_host_factory.h" 19 #include "ash/host/ash_window_tree_host.h"
20 #include "ash/host/root_window_transformer.h"
20 #include "ash/root_window_settings.h" 21 #include "ash/root_window_settings.h"
21 #include "ash/shell.h" 22 #include "ash/shell.h"
22 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
23 #include "ui/aura/client/capture_client.h" 24 #include "ui/aura/client/capture_client.h"
24 #include "ui/aura/root_window_transformer.h"
25 #include "ui/aura/window_delegate.h" 25 #include "ui/aura/window_delegate.h"
26 #include "ui/aura/window_event_dispatcher.h" 26 #include "ui/aura/window_event_dispatcher.h"
27 #include "ui/aura/window_tree_host.h"
27 #include "ui/base/layout.h" 28 #include "ui/base/layout.h"
28 #include "ui/compositor/reflector.h" 29 #include "ui/compositor/reflector.h"
29 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
30 #include "ui/gfx/native_widget_types.h" 31 #include "ui/gfx/native_widget_types.h"
31 32
32 #if defined(USE_X11) 33 #if defined(USE_X11)
33 #include "ui/gfx/x/x11_types.h" 34 #include "ui/gfx/x/x11_types.h"
34 #endif 35 #endif
35 36
36 namespace ash { 37 namespace ash {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 73
73 MirrorWindowController::MirrorWindowController() {} 74 MirrorWindowController::MirrorWindowController() {}
74 75
75 MirrorWindowController::~MirrorWindowController() { 76 MirrorWindowController::~MirrorWindowController() {
76 // Make sure the root window gets deleted before cursor_window_delegate. 77 // Make sure the root window gets deleted before cursor_window_delegate.
77 Close(); 78 Close();
78 } 79 }
79 80
80 void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) { 81 void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) {
81 static int mirror_host_count = 0; 82 static int mirror_host_count = 0;
82 83 if (!ash_host_.get()) {
83 if (!host_.get()) {
84 const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); 84 const gfx::Rect& bounds_in_native = display_info.bounds_in_native();
85 host_.reset(Shell::GetInstance()->window_tree_host_factory()-> 85 ash_host_.reset(AshWindowTreeHost::Create(bounds_in_native));
86 CreateWindowTreeHost(bounds_in_native)); 86 aura::WindowTreeHost* host = ash_host_->AsWindowTreeHost();
87 host_->window()->SetName( 87 host->window()->SetName(
88 base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++)); 88 base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++));
89 host_->compositor()->SetBackgroundColor(SK_ColorBLACK); 89 host->compositor()->SetBackgroundColor(SK_ColorBLACK);
90 // No need to remove the observer because the DisplayController outlives the 90 // No need to remove the observer because the DisplayController outlives the
91 // host. 91 // host.
92 host_->AddObserver(Shell::GetInstance()->display_controller()); 92 host->AddObserver(Shell::GetInstance()->display_controller());
93 host_->AddObserver(this); 93 host->AddObserver(this);
94 // TODO(oshima): TouchHUD is using idkey. 94 // TODO(oshima): TouchHUD is using idkey.
95 InitRootWindowSettings(host_->window())->display_id = display_info.id(); 95 InitRootWindowSettings(host->window())->display_id = display_info.id();
96 host_->InitHost(); 96 host->InitHost();
97 #if defined(USE_X11) 97 #if defined(USE_X11)
98 DisableInput(host_->GetAcceleratedWidget()); 98 DisableInput(host->GetAcceleratedWidget());
99 #endif 99 #endif
100 100
101 aura::client::SetCaptureClient(host_->window(), new NoneCaptureClient()); 101 aura::client::SetCaptureClient(host->window(), new NoneCaptureClient());
102 host_->Show(); 102 host->Show();
103 103
104 // TODO(oshima): Start mirroring. 104 // TODO(oshima): Start mirroring.
105 aura::Window* mirror_window = new aura::Window(NULL); 105 aura::Window* mirror_window = new aura::Window(NULL);
106 mirror_window->Init(aura::WINDOW_LAYER_TEXTURED); 106 mirror_window->Init(aura::WINDOW_LAYER_TEXTURED);
107 host_->window()->AddChild(mirror_window); 107 host->window()->AddChild(mirror_window);
108 mirror_window->SetBounds(host_->window()->bounds()); 108 mirror_window->SetBounds(host->window()->bounds());
109 mirror_window->Show(); 109 mirror_window->Show();
110 reflector_ = ui::ContextFactory::GetInstance()->CreateReflector( 110 reflector_ = ui::ContextFactory::GetInstance()->CreateReflector(
111 Shell::GetPrimaryRootWindow()->GetHost()->compositor(), 111 Shell::GetPrimaryRootWindow()->GetHost()->compositor(),
112 mirror_window->layer()); 112 mirror_window->layer());
113 } else { 113 } else {
114 GetRootWindowSettings(host_->window())->display_id = display_info.id(); 114 aura::WindowTreeHost* host = ash_host_->AsWindowTreeHost();
115 host_->SetBounds(display_info.bounds_in_native()); 115 GetRootWindowSettings(host->window())->display_id = display_info.id();
116 host->SetBounds(display_info.bounds_in_native());
116 } 117 }
117 118
118 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 119 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
119 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( 120 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo(
120 Shell::GetScreen()->GetPrimaryDisplay().id()); 121 Shell::GetScreen()->GetPrimaryDisplay().id());
121 DCHECK(display_manager->IsMirrored()); 122 DCHECK(display_manager->IsMirrored());
122 scoped_ptr<aura::RootWindowTransformer> transformer( 123 scoped_ptr<RootWindowTransformer> transformer(
123 CreateRootWindowTransformerForMirroredDisplay(source_display_info, 124 CreateRootWindowTransformerForMirroredDisplay(source_display_info,
124 display_info)); 125 display_info));
125 host_->SetRootWindowTransformer(transformer.Pass()); 126 ash_host_->SetRootWindowTransformer(transformer.Pass());
126 } 127 }
127 128
128 void MirrorWindowController::UpdateWindow() { 129 void MirrorWindowController::UpdateWindow() {
129 if (host_.get()) { 130 if (ash_host_.get()) {
130 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 131 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
131 const DisplayInfo& mirror_display_info = display_manager->GetDisplayInfo( 132 const DisplayInfo& mirror_display_info = display_manager->GetDisplayInfo(
132 display_manager->mirrored_display_id()); 133 display_manager->mirrored_display_id());
133 UpdateWindow(mirror_display_info); 134 UpdateWindow(mirror_display_info);
134 } 135 }
135 } 136 }
136 137
137 void MirrorWindowController::Close() { 138 void MirrorWindowController::Close() {
138 if (host_.get()) { 139 if (ash_host_.get()) {
140 aura::WindowTreeHost* host = ash_host_->AsWindowTreeHost();
139 ui::ContextFactory::GetInstance()->RemoveReflector(reflector_); 141 ui::ContextFactory::GetInstance()->RemoveReflector(reflector_);
140 reflector_ = NULL; 142 reflector_ = NULL;
141 NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>( 143 NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>(
142 aura::client::GetCaptureClient(host_->window())); 144 aura::client::GetCaptureClient(host->window()));
143 aura::client::SetCaptureClient(host_->window(), NULL); 145 aura::client::SetCaptureClient(host->window(), NULL);
144 delete capture_client; 146 delete capture_client;
145 147
146 host_->RemoveObserver(Shell::GetInstance()->display_controller()); 148 host->RemoveObserver(Shell::GetInstance()->display_controller());
147 host_->RemoveObserver(this); 149 host->RemoveObserver(this);
148 host_.reset(); 150 ash_host_.reset();
149 } 151 }
150 } 152 }
151 153
152 void MirrorWindowController::OnHostResized(const aura::WindowTreeHost* host) { 154 void MirrorWindowController::OnHostResized(const aura::WindowTreeHost* host) {
153 if (mirror_window_host_size_ == host->GetBounds().size()) 155 if (mirror_window_host_size_ == host->GetBounds().size())
154 return; 156 return;
155 mirror_window_host_size_ = host->GetBounds().size(); 157 mirror_window_host_size_ = host->GetBounds().size();
156 reflector_->OnMirroringCompositorResized(); 158 reflector_->OnMirroringCompositorResized();
157 host_->SetRootWindowTransformer(CreateRootWindowTransformer().Pass()); 159 ash_host_->SetRootWindowTransformer(CreateRootWindowTransformer().Pass());
158 Shell::GetInstance()->display_controller()->cursor_window_controller()-> 160 Shell::GetInstance()->display_controller()->cursor_window_controller()->
159 UpdateLocation(); 161 UpdateLocation();
160 } 162 }
161 163
164 aura::Window* MirrorWindowController::GetWindow() {
165 return ash_host_.get() ? ash_host_->AsWindowTreeHost()->window() : NULL;
166 }
162 167
163 scoped_ptr<aura::RootWindowTransformer> 168 scoped_ptr<RootWindowTransformer>
164 MirrorWindowController::CreateRootWindowTransformer() const { 169 MirrorWindowController::CreateRootWindowTransformer() const {
165 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 170 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
166 const DisplayInfo& mirror_display_info = display_manager->GetDisplayInfo( 171 const DisplayInfo& mirror_display_info = display_manager->GetDisplayInfo(
167 display_manager->mirrored_display_id()); 172 display_manager->mirrored_display_id());
168 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( 173 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo(
169 Shell::GetScreen()->GetPrimaryDisplay().id()); 174 Shell::GetScreen()->GetPrimaryDisplay().id());
170 DCHECK(display_manager->IsMirrored()); 175 DCHECK(display_manager->IsMirrored());
171 return scoped_ptr<aura::RootWindowTransformer>( 176 return scoped_ptr<RootWindowTransformer>(
172 CreateRootWindowTransformerForMirroredDisplay(source_display_info, 177 CreateRootWindowTransformerForMirroredDisplay(source_display_info,
173 mirror_display_info)); 178 mirror_display_info));
174 } 179 }
175 180
176 } // namespace ash 181 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/mirror_window_controller.h ('k') | ash/display/root_window_transformers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698