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..9676c90134ec4ec4ad5c62738da6bfa38aa123b7 100644 |
--- a/services/ui/ws/platform_display_default.cc |
+++ b/services/ui/ws/platform_display_default.cc |
@@ -11,7 +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 "ui/base/cursor/image_cursors.h" |
+#include "services/ui/ws/threaded_image_cursors.h" |
#include "ui/display/display.h" |
#include "ui/events/event.h" |
#include "ui/events/event_utils.h" |
@@ -35,7 +35,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 +46,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 ThreadedImageCursors first because they can still be using the platform |
+ // window. |
platform_window_.reset(); |
} |
@@ -104,12 +106,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 to outlive |image_cursors_|. |
+ 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 +123,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 +135,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( |