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

Unified Diff: services/ui/ws/threaded_image_cursors.cc

Issue 2961403002: WIP fix for Ozone cursor woes in Mushrome: Numéro deux
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/threaded_image_cursors.h ('k') | services/ui/ws/window_server.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/threaded_image_cursors.cc
diff --git a/services/ui/ws/threaded_image_cursors.cc b/services/ui/ws/threaded_image_cursors.cc
index 0b51b2e0ab6f40585745b7ae3a3e2cc88a4da63c..9736213d3147181770859d86c32f1c465a0af476 100644
--- a/services/ui/ws/threaded_image_cursors.cc
+++ b/services/ui/ws/threaded_image_cursors.cc
@@ -6,26 +6,38 @@
#include "base/bind.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "ui/ozone/public/cursor_factory_ozone.h"
#include "ui/platform_window/platform_window.h"
namespace ui {
namespace ws {
namespace {
+void TakeOwnershipOnResourceThread(
+ base::WeakPtr<ui::ImageCursorsHolder> image_cursors_holder_weak_ptr,
+ std::unique_ptr<ui::ImageCursors> image_cursors) {
+ if (image_cursors_holder_weak_ptr)
+ image_cursors_holder_weak_ptr->SetImageCursors(std::move(image_cursors));
+}
+
// Executed on |resource_task_runner_|.
void SetDisplayOnResourceThread(
- base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr,
+ base::WeakPtr<ui::ImageCursorsHolder> image_cursors_holder_weak_ptr,
const display::Display& display,
float scale_factor) {
- if (image_cursors_weak_ptr)
- image_cursors_weak_ptr->SetDisplay(display, scale_factor);
+ if (image_cursors_holder_weak_ptr) {
+ image_cursors_holder_weak_ptr->GetImageCursors()->SetDisplay(display,
+ scale_factor);
+ }
}
void SetCursorSizeOnResourceThread(
- base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr,
+ base::WeakPtr<ui::ImageCursorsHolder> image_cursors_holder_weak_ptr,
CursorSize cursor_size) {
- if (image_cursors_weak_ptr)
- image_cursors_weak_ptr->SetCursorSize(cursor_size);
+ if (image_cursors_holder_weak_ptr) {
+ image_cursors_holder_weak_ptr->GetImageCursors()->SetCursorSize(
+ cursor_size);
+ }
}
// Executed on |resource_task_runner_|. Sets cursor type on
@@ -34,14 +46,15 @@ void SetCursorSizeOnResourceThread(
// |platform_window| pointer needs to be valid while
// |threaded_image_cursors_weak_ptr| is not invalidated.
void SetCursorOnResourceThread(
- base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr,
+ base::WeakPtr<ui::ImageCursorsHolder> image_cursors_holder_weak_ptr,
ui::CursorType cursor_type,
ui::PlatformWindow* platform_window,
scoped_refptr<base::SingleThreadTaskRunner> ws_task_runner,
base::WeakPtr<ThreadedImageCursors> threaded_image_cursors_weak_ptr) {
- if (image_cursors_weak_ptr) {
+ if (image_cursors_holder_weak_ptr) {
ui::Cursor native_cursor(cursor_type);
- image_cursors_weak_ptr->SetPlatformCursor(&native_cursor);
+ image_cursors_holder_weak_ptr->GetImageCursors()->SetPlatformCursor(
+ &native_cursor);
ws_task_runner->PostTask(
FROM_HERE, base::Bind(&ThreadedImageCursors::SetCursorOnPlatformWindow,
threaded_image_cursors_weak_ptr,
@@ -53,12 +66,19 @@ void SetCursorOnResourceThread(
ThreadedImageCursors::ThreadedImageCursors(
scoped_refptr<base::SingleThreadTaskRunner>& resource_task_runner,
- base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr)
+ base::WeakPtr<ui::ImageCursorsHolder> image_cursors_holder_weak_ptr)
: resource_task_runner_(resource_task_runner),
- image_cursors_weak_ptr_(image_cursors_weak_ptr),
+ image_cursors_holder_weak_ptr_(image_cursors_holder_weak_ptr),
weak_ptr_factory_(this) {
DCHECK(resource_task_runner_);
ws_task_runner_ = base::ThreadTaskRunnerHandle::Get();
+ std::unique_ptr<ui::ImageCursors> image_cursors =
+ base::MakeUnique<ui::ImageCursors>();
+ image_cursors->Initialize();
+ resource_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&TakeOwnershipOnResourceThread, image_cursors_holder_weak_ptr_,
+ base::Passed(std::move(image_cursors))));
}
ThreadedImageCursors::~ThreadedImageCursors() {}
@@ -66,22 +86,24 @@ ThreadedImageCursors::~ThreadedImageCursors() {}
void ThreadedImageCursors::SetDisplay(const display::Display& display,
float scale_factor) {
resource_task_runner_->PostTask(
- FROM_HERE, base::Bind(&SetDisplayOnResourceThread,
- image_cursors_weak_ptr_, display, scale_factor));
+ FROM_HERE,
+ base::Bind(&SetDisplayOnResourceThread, image_cursors_holder_weak_ptr_,
+ display, scale_factor));
}
void ThreadedImageCursors::SetCursorSize(CursorSize cursor_size) {
resource_task_runner_->PostTask(
FROM_HERE, base::Bind(&SetCursorSizeOnResourceThread,
- image_cursors_weak_ptr_, cursor_size));
+ image_cursors_holder_weak_ptr_, cursor_size));
}
void ThreadedImageCursors::SetCursor(ui::CursorType cursor_type,
ui::PlatformWindow* platform_window) {
resource_task_runner_->PostTask(
- FROM_HERE, base::Bind(&SetCursorOnResourceThread, image_cursors_weak_ptr_,
- cursor_type, platform_window, ws_task_runner_,
- weak_ptr_factory_.GetWeakPtr()));
+ FROM_HERE,
+ base::Bind(&SetCursorOnResourceThread, image_cursors_holder_weak_ptr_,
+ cursor_type, platform_window, ws_task_runner_,
+ weak_ptr_factory_.GetWeakPtr()));
}
void ThreadedImageCursors::SetCursorOnPlatformWindow(
« no previous file with comments | « services/ui/ws/threaded_image_cursors.h ('k') | services/ui/ws/window_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698