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

Side by Side Diff: services/ui/ws/platform_display_default.cc

Issue 2916823002: Move Mus into chrome's process when running with --mus.
Patch Set: Undo Screen TLS change, don't use Screen::GetScreen() in Mus. Created 3 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/ui/ws/platform_display_default.h" 5 #include "services/ui/ws/platform_display_default.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "gpu/ipc/client/gpu_channel_host.h" 10 #include "gpu/ipc/client/gpu_channel_host.h"
11 #include "services/ui/display/screen_manager.h" 11 #include "services/ui/display/screen_manager.h"
12 #include "services/ui/public/interfaces/cursor/cursor_struct_traits.h" 12 #include "services/ui/public/interfaces/cursor/cursor_struct_traits.h"
13 #include "services/ui/ws/server_window.h" 13 #include "services/ui/ws/server_window.h"
14 #include "services/ui/ws/threaded_image_cursors.h"
14 #include "ui/base/cursor/image_cursors.h" 15 #include "ui/base/cursor/image_cursors.h"
15 #include "ui/display/display.h" 16 #include "ui/display/display.h"
16 #include "ui/events/event.h" 17 #include "ui/events/event.h"
17 #include "ui/events/event_utils.h" 18 #include "ui/events/event_utils.h"
18 #include "ui/platform_window/platform_ime_controller.h" 19 #include "ui/platform_window/platform_ime_controller.h"
19 #include "ui/platform_window/platform_window.h" 20 #include "ui/platform_window/platform_window.h"
20 21
21 #if defined(OS_WIN) 22 #if defined(OS_WIN)
22 #include "ui/platform_window/win/win_window.h" 23 #include "ui/platform_window/win/win_window.h"
23 #elif defined(USE_X11) && !defined(OS_CHROMEOS) 24 #elif defined(USE_X11) && !defined(OS_CHROMEOS)
24 #include "ui/platform_window/x11/x11_window.h" 25 #include "ui/platform_window/x11/x11_window.h"
25 #elif defined(OS_ANDROID) 26 #elif defined(OS_ANDROID)
26 #include "ui/platform_window/android/platform_window_android.h" 27 #include "ui/platform_window/android/platform_window_android.h"
27 #elif defined(USE_OZONE) 28 #elif defined(USE_OZONE)
28 #include "ui/ozone/public/cursor_factory_ozone.h" 29 #include "ui/ozone/public/cursor_factory_ozone.h"
29 #include "ui/ozone/public/ozone_platform.h" 30 #include "ui/ozone/public/ozone_platform.h"
30 #endif 31 #endif
31 32
32 namespace ui { 33 namespace ui {
33 namespace ws { 34 namespace ws {
34 35
35 PlatformDisplayDefault::PlatformDisplayDefault( 36 PlatformDisplayDefault::PlatformDisplayDefault(
36 ServerWindow* root_window, 37 ServerWindow* root_window,
37 const display::ViewportMetrics& metrics, 38 const display::ViewportMetrics& metrics,
38 std::unique_ptr<ImageCursors> image_cursors) 39 std::unique_ptr<ThreadedImageCursors> image_cursors)
39 : root_window_(root_window), 40 : root_window_(root_window),
40 image_cursors_(std::move(image_cursors)), 41 image_cursors_(std::move(image_cursors)),
41 metrics_(metrics), 42 metrics_(metrics),
42 widget_(gfx::kNullAcceleratedWidget) {} 43 widget_(gfx::kNullAcceleratedWidget) {}
43 44
44 PlatformDisplayDefault::~PlatformDisplayDefault() { 45 PlatformDisplayDefault::~PlatformDisplayDefault() {
45 // Don't notify the delegate from the destructor. 46 // Don't notify the delegate from the destructor.
46 delegate_ = nullptr; 47 delegate_ = nullptr;
47 48
48 frame_generator_.reset(); 49 frame_generator_.reset();
50 image_cursors_.reset();
49 // Destroy the PlatformWindow early on as it may call us back during 51 // Destroy the PlatformWindow early on as it may call us back during
50 // destruction and we want to be in a known state. But destroy the surface 52 // destruction and we want to be in a known state. But destroy the surface
51 // first because it can still be using the platform window. 53 // and ImageCursorsAsync first because they can still be using the platform
sky 2017/06/27 19:58:57 Is the 'Async' intentional here?
mfomitchev 2017/07/11 21:47:00 Oops, old name. Fixed.
54 // window.
52 platform_window_.reset(); 55 platform_window_.reset();
53 } 56 }
54 57
55 EventSink* PlatformDisplayDefault::GetEventSink() { 58 EventSink* PlatformDisplayDefault::GetEventSink() {
56 return delegate_->GetEventSink(); 59 return delegate_->GetEventSink();
57 } 60 }
58 61
59 void PlatformDisplayDefault::Init(PlatformDisplayDelegate* delegate) { 62 void PlatformDisplayDefault::Init(PlatformDisplayDelegate* delegate) {
60 DCHECK(delegate); 63 DCHECK(delegate);
61 delegate_ = delegate; 64 delegate_ = delegate;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 100 }
98 101
99 void PlatformDisplayDefault::ReleaseCapture() { 102 void PlatformDisplayDefault::ReleaseCapture() {
100 platform_window_->ReleaseCapture(); 103 platform_window_->ReleaseCapture();
101 } 104 }
102 105
103 void PlatformDisplayDefault::SetCursor(const ui::CursorData& cursor_data) { 106 void PlatformDisplayDefault::SetCursor(const ui::CursorData& cursor_data) {
104 if (!image_cursors_) 107 if (!image_cursors_)
105 return; 108 return;
106 109
107 ui::Cursor native_cursor(cursor_data.cursor_type()); 110 ui::CursorType cursor_type = cursor_data.cursor_type();
108 111
109 #if defined(USE_OZONE) 112 #if defined(USE_OZONE)
110 if (cursor_data.cursor_type() != ui::CursorType::kCustom) { 113 if (cursor_type != ui::CursorType::kCustom) {
111 image_cursors_->SetPlatformCursor(&native_cursor); 114 // platform_window_ is destroyed after image_cursors_, so it is guaranteed
sky 2017/06/27 19:58:57 |platform_window_|
mfomitchev 2017/07/11 21:47:00 Done.
115 // to outlive image_cursors_.
sky 2017/06/27 19:58:56 |image_cursors_|
mfomitchev 2017/07/11 21:47:00 Done.
116 image_cursors_->SetCursor(cursor_type, platform_window_.get());
112 } else { 117 } else {
118 ui::Cursor native_cursor(cursor_type);
113 // In Ozone builds, we have an interface available which turns bitmap data 119 // In Ozone builds, we have an interface available which turns bitmap data
114 // into platform cursors. 120 // into platform cursors.
115 ui::CursorFactoryOzone* cursor_factory = 121 ui::CursorFactoryOzone* cursor_factory =
116 delegate_->GetOzonePlatform()->GetCursorFactoryOzone(); 122 delegate_->GetOzonePlatform()->GetCursorFactoryOzone();
117 native_cursor.SetPlatformCursor(cursor_factory->CreateAnimatedCursor( 123 native_cursor.SetPlatformCursor(cursor_factory->CreateAnimatedCursor(
118 cursor_data.cursor_frames(), cursor_data.hotspot_in_pixels(), 124 cursor_data.cursor_frames(), cursor_data.hotspot_in_pixels(),
119 cursor_data.frame_delay().InMilliseconds(), 125 cursor_data.frame_delay().InMilliseconds(),
120 cursor_data.scale_factor())); 126 cursor_data.scale_factor()));
127 platform_window_->SetCursor(native_cursor.platform());
121 } 128 }
122 #else 129 #else
123 // Outside of ozone builds, there isn't a single interface for creating 130 // Outside of ozone builds, there isn't a single interface for creating
124 // PlatformCursors. The closest thing to one is in //content/ instead of 131 // PlatformCursors. The closest thing to one is in //content/ instead of
125 // //ui/ which means we can't use it from here. For now, just don't handle 132 // //ui/ which means we can't use it from here. For now, just don't handle
126 // custom image cursors. 133 // custom image cursors.
127 // 134 //
128 // TODO(erg): Once blink speaks directly to mus, make blink perform its own 135 // TODO(erg): Once blink speaks directly to mus, make blink perform its own
129 // cursor management on its own mus windows so we can remove Webcursor from 136 // cursor management on its own mus windows so we can remove Webcursor from
130 // //content/ and do this in way that's safe cross-platform, instead of as an 137 // //content/ and do this in way that's safe cross-platform, instead of as an
131 // ozone-specific hack. 138 // ozone-specific hack.
132 if (cursor_data.cursor_type() == ui::CursorType::kCustom) { 139 if (cursor_type == ui::CursorType::kCustom) {
133 NOTIMPLEMENTED() << "No custom cursor support on non-ozone yet."; 140 NOTIMPLEMENTED() << "No custom cursor support on non-ozone yet.";
134 native_cursor = ui::Cursor(ui::CursorType::kPointer); 141 cursor_type = ui::CursorType::kPointer;
135 } 142 }
136 image_cursors_->SetPlatformCursor(&native_cursor); 143 image_cursors_->SetCursor(cursor_type, platform_window_.get());
137 #endif 144 #endif
138
139 platform_window_->SetCursor(native_cursor.platform());
140 } 145 }
141 146
142 void PlatformDisplayDefault::MoveCursorTo( 147 void PlatformDisplayDefault::MoveCursorTo(
143 const gfx::Point& window_pixel_location) { 148 const gfx::Point& window_pixel_location) {
144 platform_window_->MoveCursorTo(window_pixel_location); 149 platform_window_->MoveCursorTo(window_pixel_location);
145 } 150 }
146 151
147 void PlatformDisplayDefault::SetCursorSize(const ui::CursorSize& cursor_size) { 152 void PlatformDisplayDefault::SetCursorSize(const ui::CursorSize& cursor_size) {
148 image_cursors_->SetCursorSize(cursor_size); 153 image_cursors_->SetCursorSize(cursor_size);
149 } 154 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 278 }
274 279
275 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { 280 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() {
276 NOTREACHED(); 281 NOTREACHED();
277 } 282 }
278 283
279 void PlatformDisplayDefault::OnActivationChanged(bool active) {} 284 void PlatformDisplayDefault::OnActivationChanged(bool active) {}
280 285
281 } // namespace ws 286 } // namespace ws
282 } // namespace ui 287 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698