OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.h" | 5 #include "services/ui/ws/platform_display.h" |
6 | 6 |
7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "cc/ipc/quads.mojom.h" | 9 #include "cc/ipc/quads.mojom.h" |
10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
11 #include "cc/output/delegated_frame_data.h" | 11 #include "cc/output/delegated_frame_data.h" |
12 #include "services/shell/public/cpp/connection.h" | 12 #include "services/shell/public/cpp/connection.h" |
13 #include "services/shell/public/cpp/connector.h" | 13 #include "services/shell/public/cpp/connector.h" |
14 #include "services/ui/surfaces/display_compositor.h" | 14 #include "services/ui/surfaces/display_compositor.h" |
15 #include "services/ui/surfaces/surfaces_state.h" | 15 #include "services/ui/surfaces/surfaces_state.h" |
16 #include "services/ui/ws/display.h" | |
16 #include "services/ui/ws/platform_display_factory.h" | 17 #include "services/ui/ws/platform_display_factory.h" |
17 #include "services/ui/ws/platform_display_init_params.h" | 18 #include "services/ui/ws/platform_display_init_params.h" |
18 #include "services/ui/ws/server_window.h" | 19 #include "services/ui/ws/server_window.h" |
19 #include "services/ui/ws/window_coordinate_conversions.h" | 20 #include "services/ui/ws/window_coordinate_conversions.h" |
20 #include "third_party/skia/include/core/SkXfermode.h" | 21 #include "third_party/skia/include/core/SkXfermode.h" |
21 #include "ui/base/cursor/cursor_loader.h" | 22 #include "ui/base/cursor/image_cursors.h" |
22 #include "ui/display/display.h" | 23 #include "ui/display/display.h" |
23 #include "ui/events/event.h" | 24 #include "ui/events/event.h" |
24 #include "ui/events/event_utils.h" | 25 #include "ui/events/event_utils.h" |
25 #include "ui/platform_window/platform_ime_controller.h" | 26 #include "ui/platform_window/platform_ime_controller.h" |
26 #include "ui/platform_window/platform_window.h" | 27 #include "ui/platform_window/platform_window.h" |
27 | 28 |
28 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
29 #include "ui/platform_window/win/win_window.h" | 30 #include "ui/platform_window/win/win_window.h" |
30 #elif defined(USE_X11) | 31 #elif defined(USE_X11) |
31 #include "ui/platform_window/x11/x11_window.h" | 32 #include "ui/platform_window/x11/x11_window.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
49 return factory_->CreatePlatformDisplay(); | 50 return factory_->CreatePlatformDisplay(); |
50 | 51 |
51 return new DefaultPlatformDisplay(init_params); | 52 return new DefaultPlatformDisplay(init_params); |
52 } | 53 } |
53 | 54 |
54 DefaultPlatformDisplay::DefaultPlatformDisplay( | 55 DefaultPlatformDisplay::DefaultPlatformDisplay( |
55 const PlatformDisplayInitParams& init_params) | 56 const PlatformDisplayInitParams& init_params) |
56 : id_(init_params.display_id), | 57 : id_(init_params.display_id), |
57 platform_screen_(init_params.platform_screen), | 58 platform_screen_(init_params.platform_screen), |
58 #if !defined(OS_ANDROID) | 59 #if !defined(OS_ANDROID) |
59 cursor_loader_(ui::CursorLoader::Create()), | 60 image_cursors_(new ImageCursors), |
60 #endif | 61 #endif |
61 frame_generator_(new FrameGenerator(this, init_params.surfaces_state)) { | 62 frame_generator_(new FrameGenerator(this, init_params.surfaces_state)) { |
62 metrics_.bounds = init_params.display_bounds; | 63 metrics_.bounds = init_params.display_bounds; |
63 } | 64 } |
64 | 65 |
65 void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) { | 66 void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) { |
66 delegate_ = delegate; | 67 delegate_ = delegate; |
67 | 68 |
68 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
69 platform_window_.reset(new ui::WinWindow(this, metrics_.bounds)); | 70 platform_window_.reset(new ui::WinWindow(this, metrics_.bounds)); |
70 #elif defined(USE_X11) | 71 #elif defined(USE_X11) |
71 platform_window_.reset(new ui::X11Window(this)); | 72 platform_window_.reset(new ui::X11Window(this)); |
72 #elif defined(OS_ANDROID) | 73 #elif defined(OS_ANDROID) |
73 platform_window_.reset(new ui::PlatformWindowAndroid(this)); | 74 platform_window_.reset(new ui::PlatformWindowAndroid(this)); |
74 #elif defined(USE_OZONE) | 75 #elif defined(USE_OZONE) |
75 platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow( | 76 platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow( |
76 this, metrics_.bounds); | 77 this, metrics_.bounds); |
77 #else | 78 #else |
78 NOTREACHED() << "Unsupported platform"; | 79 NOTREACHED() << "Unsupported platform"; |
79 #endif | 80 #endif |
81 | |
82 #if !defined(OS_ANDROID) | |
83 image_cursors_->SetDisplay( | |
84 static_cast<ui::ws::Display*>(delegate_)->ToDisplay(), | |
sadrul
2016/08/22 15:18:14
Use the newly added delegate function.
Alex Z.
2016/08/22 15:26:02
Done.
| |
85 GetDeviceScaleFactor()); | |
86 #endif | |
80 platform_window_->SetBounds(metrics_.bounds); | 87 platform_window_->SetBounds(metrics_.bounds); |
81 platform_window_->Show(); | 88 platform_window_->Show(); |
82 } | 89 } |
83 | 90 |
84 int64_t DefaultPlatformDisplay::GetId() const { | 91 int64_t DefaultPlatformDisplay::GetId() const { |
85 return id_; | 92 return id_; |
86 } | 93 } |
87 | 94 |
88 DefaultPlatformDisplay::~DefaultPlatformDisplay() { | 95 DefaultPlatformDisplay::~DefaultPlatformDisplay() { |
89 // Don't notify the delegate from the destructor. | 96 // Don't notify the delegate from the destructor. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 } | 132 } |
126 | 133 |
127 void DefaultPlatformDisplay::SetCursorById(int32_t cursor_id) { | 134 void DefaultPlatformDisplay::SetCursorById(int32_t cursor_id) { |
128 #if !defined(OS_ANDROID) | 135 #if !defined(OS_ANDROID) |
129 // TODO(erg): This still isn't sufficient, and will only use native cursors | 136 // TODO(erg): This still isn't sufficient, and will only use native cursors |
130 // that chrome would use, not custom image cursors. For that, we should | 137 // that chrome would use, not custom image cursors. For that, we should |
131 // delegate to the window manager to load images from resource packs. | 138 // delegate to the window manager to load images from resource packs. |
132 // | 139 // |
133 // We probably also need to deal with different DPIs. | 140 // We probably also need to deal with different DPIs. |
134 ui::Cursor cursor(cursor_id); | 141 ui::Cursor cursor(cursor_id); |
135 cursor_loader_->SetPlatformCursor(&cursor); | 142 image_cursors_->SetPlatformCursor(&cursor); |
136 platform_window_->SetCursor(cursor.platform()); | 143 platform_window_->SetCursor(cursor.platform()); |
137 #endif | 144 #endif |
138 } | 145 } |
139 | 146 |
140 float DefaultPlatformDisplay::GetDeviceScaleFactor() { | 147 float DefaultPlatformDisplay::GetDeviceScaleFactor() { |
141 return metrics_.device_scale_factor; | 148 return metrics_.device_scale_factor; |
142 } | 149 } |
143 | 150 |
144 display::Display::Rotation DefaultPlatformDisplay::GetRotation() { | 151 display::Display::Rotation DefaultPlatformDisplay::GetRotation() { |
145 // TODO(sky): implement me. | 152 // TODO(sky): implement me. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 return delegate_ ? delegate_->IsInHighContrastMode() : false; | 301 return delegate_ ? delegate_->IsInHighContrastMode() : false; |
295 } | 302 } |
296 | 303 |
297 const ViewportMetrics& DefaultPlatformDisplay::GetViewportMetrics() { | 304 const ViewportMetrics& DefaultPlatformDisplay::GetViewportMetrics() { |
298 return metrics_; | 305 return metrics_; |
299 } | 306 } |
300 | 307 |
301 } // namespace ws | 308 } // namespace ws |
302 | 309 |
303 } // namespace ui | 310 } // namespace ui |
OLD | NEW |