Chromium Code Reviews| Index: services/ui/ws/platform_display_default.cc |
| diff --git a/services/ui/ws/platform_display_default.cc b/services/ui/ws/platform_display_default.cc |
| index 0b4bf025b6efdbcee7683c0389be84a67daafb22..32c921b957321b51851b7b364eff53424b2decde 100644 |
| --- a/services/ui/ws/platform_display_default.cc |
| +++ b/services/ui/ws/platform_display_default.cc |
| @@ -11,6 +11,7 @@ |
| #include "services/ui/display/screen_manager.h" |
| #include "services/ui/public/interfaces/cursor/cursor_struct_traits.h" |
| #include "services/ui/ws/server_window.h" |
| +#include "services/ui/ws/threaded_image_cursors.h" |
| #include "ui/base/cursor/image_cursors.h" |
| #include "ui/display/display.h" |
| #include "ui/events/event.h" |
| @@ -35,7 +36,7 @@ namespace ws { |
| PlatformDisplayDefault::PlatformDisplayDefault( |
| ServerWindow* root_window, |
| const display::ViewportMetrics& metrics, |
| - std::unique_ptr<ImageCursors> image_cursors) |
| + std::unique_ptr<ThreadedImageCursors> image_cursors) |
| : root_window_(root_window), |
| image_cursors_(std::move(image_cursors)), |
| metrics_(metrics), |
| @@ -46,9 +47,11 @@ PlatformDisplayDefault::~PlatformDisplayDefault() { |
| delegate_ = nullptr; |
| frame_generator_.reset(); |
| + image_cursors_.reset(); |
| // Destroy the PlatformWindow early on as it may call us back during |
| // destruction and we want to be in a known state. But destroy the surface |
| - // first because it can still be using the platform window. |
| + // 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.
|
| + // window. |
| platform_window_.reset(); |
| } |
| @@ -104,12 +107,15 @@ void PlatformDisplayDefault::SetCursor(const ui::CursorData& cursor_data) { |
| if (!image_cursors_) |
| return; |
| - ui::Cursor native_cursor(cursor_data.cursor_type()); |
| + ui::CursorType cursor_type = cursor_data.cursor_type(); |
| #if defined(USE_OZONE) |
| - if (cursor_data.cursor_type() != ui::CursorType::kCustom) { |
| - image_cursors_->SetPlatformCursor(&native_cursor); |
| + if (cursor_type != ui::CursorType::kCustom) { |
| + // 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.
|
| + // to outlive image_cursors_. |
|
sky
2017/06/27 19:58:56
|image_cursors_|
mfomitchev
2017/07/11 21:47:00
Done.
|
| + image_cursors_->SetCursor(cursor_type, platform_window_.get()); |
| } else { |
| + ui::Cursor native_cursor(cursor_type); |
| // In Ozone builds, we have an interface available which turns bitmap data |
| // into platform cursors. |
| ui::CursorFactoryOzone* cursor_factory = |
| @@ -118,6 +124,7 @@ void PlatformDisplayDefault::SetCursor(const ui::CursorData& cursor_data) { |
| cursor_data.cursor_frames(), cursor_data.hotspot_in_pixels(), |
| cursor_data.frame_delay().InMilliseconds(), |
| cursor_data.scale_factor())); |
| + platform_window_->SetCursor(native_cursor.platform()); |
| } |
| #else |
| // Outside of ozone builds, there isn't a single interface for creating |
| @@ -129,14 +136,12 @@ void PlatformDisplayDefault::SetCursor(const ui::CursorData& cursor_data) { |
| // cursor management on its own mus windows so we can remove Webcursor from |
| // //content/ and do this in way that's safe cross-platform, instead of as an |
| // ozone-specific hack. |
| - if (cursor_data.cursor_type() == ui::CursorType::kCustom) { |
| + if (cursor_type == ui::CursorType::kCustom) { |
| NOTIMPLEMENTED() << "No custom cursor support on non-ozone yet."; |
| - native_cursor = ui::Cursor(ui::CursorType::kPointer); |
| + cursor_type = ui::CursorType::kPointer; |
| } |
| - image_cursors_->SetPlatformCursor(&native_cursor); |
| + image_cursors_->SetCursor(cursor_type, platform_window_.get()); |
| #endif |
| - |
| - platform_window_->SetCursor(native_cursor.platform()); |
| } |
| void PlatformDisplayDefault::MoveCursorTo( |