OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/views/mus/window_tree_host_mus.h" | 5 #include "ui/views/mus/window_tree_host_mus.h" |
6 | 6 |
7 #include "components/bitmap_uploader/bitmap_uploader.h" | |
7 #include "components/mus/public/cpp/property_type_converters.h" | 8 #include "components/mus/public/cpp/property_type_converters.h" |
8 #include "components/mus/public/cpp/window_observer.h" | 9 #include "components/mus/public/cpp/window_observer.h" |
9 #include "components/mus/public/cpp/window_property.h" | 10 #include "components/mus/public/cpp/window_property.h" |
10 #include "components/mus/public/cpp/window_tree_connection.h" | 11 #include "components/mus/public/cpp/window_tree_connection.h" |
11 #include "components/mus/public/interfaces/window_manager.mojom.h" | 12 #include "components/mus/public/interfaces/window_manager.mojom.h" |
12 #include "mojo/application/public/interfaces/shell.mojom.h" | 13 #include "mojo/application/public/interfaces/shell.mojom.h" |
13 #include "mojo/converters/geometry/geometry_type_converters.h" | 14 #include "mojo/converters/geometry/geometry_type_converters.h" |
14 #include "mojo/converters/input_events/input_events_type_converters.h" | 15 #include "mojo/converters/input_events/input_events_type_converters.h" |
15 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
17 #include "ui/aura/window_event_dispatcher.h" | 18 #include "ui/aura/window_event_dispatcher.h" |
19 #include "ui/base/view_prop.h" | |
18 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
19 #include "ui/events/event_constants.h" | 21 #include "ui/events/event_constants.h" |
20 #include "ui/platform_window/platform_window.h" | 22 #include "ui/platform_window/platform_window.h" |
21 #include "ui/platform_window/platform_window_delegate.h" | 23 #include "ui/platform_window/platform_window_delegate.h" |
22 #include "ui/views/mus/input_method_mus.h" | 24 #include "ui/views/mus/input_method_mus.h" |
23 #include "ui/views/mus/native_widget_mus.h" | 25 #include "ui/views/mus/native_widget_mus.h" |
24 #include "ui/views/mus/surface_context_factory.h" | 26 #include "ui/views/mus/surface_context_factory.h" |
25 #include "ui/views/mus/window_manager_connection.h" | 27 #include "ui/views/mus/window_manager_connection.h" |
26 | 28 |
27 namespace views { | 29 namespace views { |
28 namespace { | 30 namespace { |
29 | 31 |
32 static uint32_t accelerated_widget_count = 1; | |
33 | |
30 void WindowManagerCallback(mus::mojom::WindowManagerErrorCode error_code) {} | 34 void WindowManagerCallback(mus::mojom::WindowManagerErrorCode error_code) {} |
31 | 35 |
32 class PlatformWindowMus : public ui::PlatformWindow, | 36 class PlatformWindowMus : public ui::PlatformWindow, |
33 public mus::WindowObserver { | 37 public mus::WindowObserver { |
34 public: | 38 public: |
35 PlatformWindowMus(ui::PlatformWindowDelegate* delegate, | 39 PlatformWindowMus(ui::PlatformWindowDelegate* delegate, |
36 mus::Window* mus_window) | 40 mus::Window* mus_window) |
37 : delegate_(delegate), | 41 : delegate_(delegate), |
38 mus_window_(mus_window), | 42 mus_window_(mus_window), |
39 show_state_(mus::mojom::SHOW_STATE_RESTORED) { | 43 show_state_(mus::mojom::SHOW_STATE_RESTORED) { |
40 DCHECK(delegate_); | 44 DCHECK(delegate_); |
41 DCHECK(mus_window_); | 45 DCHECK(mus_window_); |
42 mus_window_->AddObserver(this); | 46 mus_window_->AddObserver(this); |
43 | 47 |
44 delegate_->OnAcceleratedWidgetAvailable(gfx::kNullAcceleratedWidget, | 48 // We need accelerated widget numbers to be different for each |
49 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t | |
50 // has this property. | |
51 delegate_->OnAcceleratedWidgetAvailable( | |
52 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++), | |
45 mus_window_->viewport_metrics().device_pixel_ratio); | 53 mus_window_->viewport_metrics().device_pixel_ratio); |
46 } | 54 } |
47 | 55 |
48 ~PlatformWindowMus() override { | 56 ~PlatformWindowMus() override { |
49 if (!mus_window_) | 57 if (!mus_window_) |
50 return; | 58 return; |
51 mus_window_->RemoveObserver(this); | 59 mus_window_->RemoveObserver(this); |
52 mus_window_->Destroy(); | 60 mus_window_->Destroy(); |
53 } | 61 } |
54 | 62 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 mus::mojom::SurfaceType surface_type) | 175 mus::mojom::SurfaceType surface_type) |
168 : native_widget_(native_widget), | 176 : native_widget_(native_widget), |
169 show_state_(ui::PLATFORM_WINDOW_STATE_UNKNOWN) { | 177 show_state_(ui::PLATFORM_WINDOW_STATE_UNKNOWN) { |
170 context_factory_.reset( | 178 context_factory_.reset( |
171 new SurfaceContextFactory(shell, window, surface_type)); | 179 new SurfaceContextFactory(shell, window, surface_type)); |
172 // WindowTreeHost creates the compositor using the ContextFactory from | 180 // WindowTreeHost creates the compositor using the ContextFactory from |
173 // aura::Env. Install |context_factory_| there so that |context_factory_| is | 181 // aura::Env. Install |context_factory_| there so that |context_factory_| is |
174 // picked up. | 182 // picked up. |
175 ui::ContextFactory* default_context_factory = | 183 ui::ContextFactory* default_context_factory = |
176 aura::Env::GetInstance()->context_factory(); | 184 aura::Env::GetInstance()->context_factory(); |
177 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 185 |
186 // For Chrome, we need the GpuProcessTransportFactory so that renderer and | |
187 // browser pixels are composited into a single backing | |
188 // SoftwareOutputDeviceMus. | |
189 if (!default_context_factory) { | |
Ben Goodger (Google)
2015/11/13 23:15:05
nit: no braces
rjkroege
2015/11/14 01:13:05
Done.
| |
190 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | |
191 } | |
192 | |
178 SetPlatformWindow(make_scoped_ptr(new PlatformWindowMus(this, window))); | 193 SetPlatformWindow(make_scoped_ptr(new PlatformWindowMus(this, window))); |
179 compositor()->SetHostHasTransparentBackground(true); | 194 compositor()->SetHostHasTransparentBackground(true); |
180 aura::Env::GetInstance()->set_context_factory(default_context_factory); | 195 aura::Env::GetInstance()->set_context_factory(default_context_factory); |
181 DCHECK_EQ(context_factory_.get(), compositor()->context_factory()); | 196 |
197 bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(window)); | |
198 bitmap_uploader_->Init(shell); | |
199 prop_.reset( | |
200 new ui::ViewProp(GetAcceleratedWidget(), | |
201 bitmap_uploader::kBitmapUploaderForAcceleratedWidget, | |
202 bitmap_uploader_.get())); | |
182 | 203 |
183 input_method_.reset(new InputMethodMUS(this, window)); | 204 input_method_.reset(new InputMethodMUS(this, window)); |
184 SetSharedInputMethod(input_method_.get()); | 205 SetSharedInputMethod(input_method_.get()); |
185 } | 206 } |
186 | 207 |
187 WindowTreeHostMus::~WindowTreeHostMus() { | 208 WindowTreeHostMus::~WindowTreeHostMus() { |
188 DestroyCompositor(); | 209 DestroyCompositor(); |
189 DestroyDispatcher(); | 210 DestroyDispatcher(); |
190 } | 211 } |
191 | 212 |
(...skipping 19 matching lines...) Expand all Loading... | |
211 if (active) | 232 if (active) |
212 GetInputMethod()->OnFocus(); | 233 GetInputMethod()->OnFocus(); |
213 else | 234 else |
214 GetInputMethod()->OnBlur(); | 235 GetInputMethod()->OnBlur(); |
215 if (native_widget_) | 236 if (native_widget_) |
216 native_widget_->OnActivationChanged(active); | 237 native_widget_->OnActivationChanged(active); |
217 WindowTreeHostPlatform::OnActivationChanged(active); | 238 WindowTreeHostPlatform::OnActivationChanged(active); |
218 } | 239 } |
219 | 240 |
220 } // namespace views | 241 } // namespace views |
OLD | NEW |