Commit 11127567 authored by spang's avatar spang Committed by Commit bot

ozone: Remove CursorFactoryOzone::SetCursor, GetCursorWindow

Use PlatformWindow::SetCursor instead of CursorFactoryOzone::SetCursor.
The GetCursorWindow() function becomes an implementation detail of the
DRI platform.

BUG=none
TEST=compile, run on cros link_freon
NOTRY=true

Review URL: https://codereview.chromium.org/527293002

Cr-Commit-Position: refs/heads/master@{#293033}
parent 7c403e06
......@@ -26,6 +26,12 @@ BitmapCursorFactoryOzone::BitmapCursorFactoryOzone() {}
BitmapCursorFactoryOzone::~BitmapCursorFactoryOzone() {}
// static
scoped_refptr<BitmapCursorOzone> BitmapCursorFactoryOzone::GetBitmapCursor(
PlatformCursor platform_cursor) {
return make_scoped_refptr(ToBitmapCursorOzone(platform_cursor));
}
PlatformCursor BitmapCursorFactoryOzone::GetDefaultCursor(int type) {
if (type == kCursorNone)
return NULL; // NULL is used for hidden cursor.
......@@ -58,16 +64,4 @@ void BitmapCursorFactoryOzone::UnrefImageCursor(PlatformCursor cursor) {
ToBitmapCursorOzone(cursor)->Release();
}
void BitmapCursorFactoryOzone::SetCursor(gfx::AcceleratedWidget widget,
PlatformCursor platform_cursor) {
BitmapCursorOzone* cursor = ToBitmapCursorOzone(platform_cursor);
SetBitmapCursor(widget, make_scoped_refptr(cursor));
}
void BitmapCursorFactoryOzone::SetBitmapCursor(
gfx::AcceleratedWidget widget,
scoped_refptr<BitmapCursorOzone>) {
NOTIMPLEMENTED();
}
} // namespace ui
......@@ -48,19 +48,16 @@ class UI_BASE_EXPORT BitmapCursorFactoryOzone : public CursorFactoryOzone {
BitmapCursorFactoryOzone();
virtual ~BitmapCursorFactoryOzone();
// Convert PlatformCursor to BitmapCursorOzone.
static scoped_refptr<BitmapCursorOzone> GetBitmapCursor(
PlatformCursor platform_cursor);
// CursorFactoryOzone:
virtual PlatformCursor GetDefaultCursor(int type) OVERRIDE;
virtual PlatformCursor CreateImageCursor(const SkBitmap& bitmap,
const gfx::Point& hotspot) OVERRIDE;
virtual void RefImageCursor(PlatformCursor cursor) OVERRIDE;
virtual void UnrefImageCursor(PlatformCursor cursor) OVERRIDE;
virtual void SetCursor(gfx::AcceleratedWidget widget,
PlatformCursor cursor) OVERRIDE;
// Set a bitmap cursor for the given window. This must be overridden by
// subclasses. If the cursor is hidden (kCursorNone) then cursor is NULL.
virtual void SetBitmapCursor(gfx::AcceleratedWidget window,
scoped_refptr<BitmapCursorOzone> cursor);
private:
// Default cursors are cached & owned by the factory.
......
......@@ -19,10 +19,10 @@ source_set("dri_common") {
"chromeos/native_display_delegate_dri.h",
"crtc_state.cc",
"crtc_state.h",
"cursor_factory_evdev_dri.cc",
"cursor_factory_evdev_dri.h",
"dri_console_buffer.cc",
"dri_console_buffer.h",
"dri_cursor.cc",
"dri_cursor.h",
"dri_buffer.cc",
"dri_buffer.h",
"dri_surface.cc",
......
......@@ -43,12 +43,12 @@
'chromeos/native_display_delegate_dri.h',
'crtc_state.cc',
'crtc_state.h',
'cursor_factory_evdev_dri.cc',
'cursor_factory_evdev_dri.h',
'dri_console_buffer.cc',
'dri_console_buffer.h',
'dri_buffer.cc',
'dri_buffer.h',
'dri_cursor.cc',
'dri_cursor.h',
'dri_surface.cc',
'dri_surface.h',
'dri_surface_factory.cc',
......
......@@ -2,27 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h"
#include "ui/ozone/platform/dri/dri_cursor.h"
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/ozone/platform/dri/dri_surface_factory.h"
#include "ui/ozone/platform/dri/hardware_cursor_delegate.h"
namespace ui {
CursorFactoryEvdevDri::CursorFactoryEvdevDri(HardwareCursorDelegate* hardware)
: hardware_(hardware) {
DriCursor::DriCursor(HardwareCursorDelegate* hardware) : hardware_(hardware) {
// TODO(dnicoara) Assume the first widget since at this point there are no
// widgets initialized.
cursor_window_ = DriSurfaceFactory::kDefaultWidgetHandle;
cursor_location_ = gfx::PointF(2560 / 2, 1700 / 2); // TODO(spang): Argh!
}
CursorFactoryEvdevDri::~CursorFactoryEvdevDri() {}
DriCursor::~DriCursor() {
}
void CursorFactoryEvdevDri::SetBitmapCursor(
gfx::AcceleratedWidget widget,
scoped_refptr<BitmapCursorOzone> cursor) {
void DriCursor::SetCursor(gfx::AcceleratedWidget widget,
PlatformCursor platform_cursor) {
scoped_refptr<BitmapCursorOzone> cursor =
BitmapCursorFactoryOzone::GetBitmapCursor(platform_cursor);
if (cursor_ == cursor)
return;
......@@ -34,8 +38,8 @@ void CursorFactoryEvdevDri::SetBitmapCursor(
hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point());
}
void CursorFactoryEvdevDri::MoveCursorTo(gfx::AcceleratedWidget widget,
const gfx::PointF& location) {
void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget,
const gfx::PointF& location) {
if (widget != cursor_window_)
hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point());
......@@ -50,19 +54,23 @@ void CursorFactoryEvdevDri::MoveCursorTo(gfx::AcceleratedWidget widget,
hardware_->MoveHardwareCursor(cursor_window_, bitmap_location());
}
void CursorFactoryEvdevDri::MoveCursor(const gfx::Vector2dF& delta) {
void DriCursor::MoveCursor(const gfx::Vector2dF& delta) {
MoveCursorTo(cursor_window_, cursor_location_ + delta);
}
gfx::AcceleratedWidget CursorFactoryEvdevDri::GetCursorWindow() {
gfx::AcceleratedWidget DriCursor::GetCursorWindow() {
return cursor_window_;
}
bool CursorFactoryEvdevDri::IsCursorVisible() { return cursor_; }
bool DriCursor::IsCursorVisible() {
return cursor_;
}
gfx::PointF CursorFactoryEvdevDri::location() { return cursor_location_; }
gfx::PointF DriCursor::location() {
return cursor_location_;
}
gfx::Point CursorFactoryEvdevDri::bitmap_location() {
gfx::Point DriCursor::bitmap_location() {
return gfx::ToFlooredPoint(cursor_location_) -
cursor_->hotspot().OffsetFromOrigin();
}
......
......@@ -2,31 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_DRI_CURSOR_FACTORY_EVDEV_DRI_H_
#define UI_OZONE_PLATFORM_DRI_CURSOR_FACTORY_EVDEV_DRI_H_
#ifndef UI_OZONE_PLATFORM_DRI_DRI_CURSOR_H_
#define UI_OZONE_PLATFORM_DRI_DRI_CURSOR_H_
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#include "base/memory/ref_counted.h"
#include "ui/base/cursor/cursor.h"
#include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
class PointF;
class Vector2dF;
}
namespace ui {
class BitmapCursorOzone;
class BitmapCursorFactoryOzone;
class HardwareCursorDelegate;
class CursorFactoryEvdevDri : public BitmapCursorFactoryOzone,
public CursorDelegateEvdev {
class DriCursor : public CursorDelegateEvdev {
public:
CursorFactoryEvdevDri(HardwareCursorDelegate* cursor);
virtual ~CursorFactoryEvdevDri();
explicit DriCursor(HardwareCursorDelegate* hardware);
virtual ~DriCursor();
// BitmapCursorFactoryOzone:
virtual gfx::AcceleratedWidget GetCursorWindow() OVERRIDE;
virtual void SetBitmapCursor(gfx::AcceleratedWidget widget,
scoped_refptr<BitmapCursorOzone> cursor)
OVERRIDE;
void SetCursor(gfx::AcceleratedWidget widget, PlatformCursor platform_cursor);
gfx::AcceleratedWidget GetCursorWindow();
// CursorDelegateEvdev:
virtual void MoveCursorTo(gfx::AcceleratedWidget widget,
......@@ -54,4 +55,4 @@ class CursorFactoryEvdevDri : public BitmapCursorFactoryOzone,
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRI_CURSOR_FACTORY_EVDEV_DRI_H_
#endif // UI_OZONE_PLATFORM_DRI_DRI_CURSOR_H_
......@@ -7,6 +7,7 @@
#include "ui/events/event.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/ozone/platform/dri/dri_cursor.h"
#include "ui/ozone/platform/dri/dri_window_delegate.h"
#include "ui/ozone/platform/dri/dri_window_manager.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
......@@ -18,13 +19,15 @@ DriWindow::DriWindow(PlatformWindowDelegate* delegate,
const gfx::Rect& bounds,
scoped_ptr<DriWindowDelegate> dri_window_delegate,
EventFactoryEvdev* event_factory,
DriWindowManager* window_manager)
DriWindowManager* window_manager,
DriCursor* cursor)
: delegate_(delegate),
bounds_(bounds),
widget_(dri_window_delegate->GetAcceleratedWidget()),
dri_window_delegate_(dri_window_delegate.get()),
event_factory_(event_factory),
window_manager_(window_manager) {
window_manager_(window_manager),
cursor_(cursor) {
window_manager_->AddWindowDelegate(widget_, dri_window_delegate.Pass());
}
......@@ -70,7 +73,7 @@ void DriWindow::Minimize() {}
void DriWindow::Restore() {}
void DriWindow::SetCursor(PlatformCursor cursor) {
ui::CursorFactoryOzone::GetInstance()->SetCursor(widget_, cursor);
cursor_->SetCursor(widget_, cursor);
}
void DriWindow::MoveCursorTo(const gfx::Point& location) {
......@@ -81,7 +84,7 @@ bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) {
DCHECK(ne);
Event* event = static_cast<Event*>(ne);
if (event->IsMouseEvent() || event->IsScrollEvent())
return ui::CursorFactoryOzone::GetInstance()->GetCursorWindow() == widget_;
return cursor_->GetCursorWindow() == widget_;
return true;
}
......
......@@ -13,6 +13,7 @@
namespace ui {
class DriCursor;
class DriWindowDelegate;
class DriWindowManager;
class EventFactoryEvdev;
......@@ -24,7 +25,8 @@ class DriWindow : public PlatformWindow,
const gfx::Rect& bounds,
scoped_ptr<DriWindowDelegate> dri_window_delegate,
EventFactoryEvdev* event_factory,
DriWindowManager* window_manager);
DriWindowManager* window_manager,
DriCursor* cursor);
virtual ~DriWindow();
void Initialize();
......@@ -55,6 +57,7 @@ class DriWindow : public PlatformWindow,
DriWindowDelegate* dri_window_delegate_;
EventFactoryEvdev* event_factory_;
DriWindowManager* window_manager_;
DriCursor* cursor_;
DISALLOW_COPY_AND_ASSIGN(DriWindow);
};
......
......@@ -5,11 +5,12 @@
#include "ui/ozone/platform/dri/ozone_platform_dri.h"
#include "base/at_exit.h"
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#include "ui/events/ozone/device/device_manager.h"
#include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h"
#include "ui/ozone/platform/dri/dri_buffer.h"
#include "ui/ozone/platform/dri/dri_cursor.h"
#include "ui/ozone/platform/dri/dri_surface_factory.h"
#include "ui/ozone/platform/dri/dri_window.h"
#include "ui/ozone/platform/dri/dri_window_delegate_impl.h"
......@@ -70,7 +71,8 @@ class OzonePlatformDri : public OzonePlatform {
scoped_ptr<DriWindowDelegate>(new DriWindowDelegateImpl(
window_manager_.NextAcceleratedWidget(), screen_manager_.get())),
event_factory_ozone_.get(),
&window_manager_));
&window_manager_,
cursor_.get()));
platform_window->Initialize();
return platform_window.PassAs<PlatformWindow>();
}
......@@ -89,10 +91,10 @@ class OzonePlatformDri : public OzonePlatform {
virtual void InitializeUI() OVERRIDE {
surface_factory_ozone_.reset(new DriSurfaceFactory(
dri_.get(), screen_manager_.get(), &window_manager_));
cursor_factory_ozone_.reset(
new CursorFactoryEvdevDri(surface_factory_ozone_.get()));
event_factory_ozone_.reset(new EventFactoryEvdev(
cursor_factory_ozone_.get(), device_manager_.get()));
cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
cursor_.reset(new DriCursor(surface_factory_ozone_.get()));
event_factory_ozone_.reset(
new EventFactoryEvdev(cursor_.get(), device_manager_.get()));
if (surface_factory_ozone_->InitializeHardware() !=
DriSurfaceFactory::INITIALIZED)
LOG(FATAL) << "failed to initialize display hardware";
......@@ -109,7 +111,8 @@ class OzonePlatformDri : public OzonePlatform {
scoped_ptr<DeviceManager> device_manager_;
scoped_ptr<DriSurfaceFactory> surface_factory_ozone_;
scoped_ptr<CursorFactoryEvdevDri> cursor_factory_ozone_;
scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_;
scoped_ptr<DriCursor> cursor_;
scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
DriWindowManager window_manager_;
......
......@@ -10,9 +10,10 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#include "ui/events/ozone/device/device_manager.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h"
#include "ui/ozone/platform/dri/dri_cursor.h"
#include "ui/ozone/platform/dri/dri_window.h"
#include "ui/ozone/platform/dri/dri_window_delegate_proxy.h"
#include "ui/ozone/platform/dri/dri_window_manager.h"
......@@ -105,7 +106,8 @@ class OzonePlatformGbm : public OzonePlatform {
ui_window_manager_.NextAcceleratedWidget(),
gpu_platform_support_host_.get())),
event_factory_ozone_.get(),
&ui_window_manager_));
&ui_window_manager_,
cursor_.get()));
platform_window->Initialize();
return platform_window.PassAs<PlatformWindow>();
}
......@@ -128,10 +130,10 @@ class OzonePlatformGbm : public OzonePlatform {
surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_));
device_manager_ = CreateDeviceManager();
gpu_platform_support_host_.reset(new GpuPlatformSupportHostGbm());
cursor_factory_ozone_.reset(
new CursorFactoryEvdevDri(gpu_platform_support_host_.get()));
event_factory_ozone_.reset(new EventFactoryEvdev(
cursor_factory_ozone_.get(), device_manager_.get()));
cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
cursor_.reset(new DriCursor(gpu_platform_support_host_.get()));
event_factory_ozone_.reset(
new EventFactoryEvdev(cursor_.get(), device_manager_.get()));
}
virtual void InitializeGPU() OVERRIDE {
......@@ -172,7 +174,8 @@ class OzonePlatformGbm : public OzonePlatform {
scoped_ptr<DeviceManager> device_manager_;
scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_;
scoped_ptr<CursorFactoryEvdevDri> cursor_factory_ozone_;
scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_;
scoped_ptr<DriCursor> cursor_;
scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
scoped_ptr<GpuPlatformSupportGbm> gpu_platform_support_;
......
......@@ -141,7 +141,6 @@ void EgltestWindow::Restore() {
}
void EgltestWindow::SetCursor(PlatformCursor cursor) {
CursorFactoryOzone::GetInstance()->SetCursor(window_id_, cursor);
}
void EgltestWindow::MoveCursorTo(const gfx::Point& location) {
......
......@@ -6,8 +6,6 @@ source_set("test") {
sources = [
"ozone_platform_test.cc",
"ozone_platform_test.h",
"test_cursor_factory.cc",
"test_cursor_factory.h",
"test_window.cc",
"test_window.h",
"test_window_manager.cc",
......
......@@ -6,8 +6,8 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/ozone/platform/test/test_cursor_factory.h"
#include "ui/ozone/platform/test/test_window.h"
#include "ui/ozone/platform/test/test_window_manager.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
......@@ -72,7 +72,7 @@ class OzonePlatformTest : public OzonePlatform {
if (!PlatformEventSource::GetInstance())
platform_event_source_ = PlatformEventSource::CreateDefault();
cursor_factory_ozone_.reset(new TestCursorFactory());
cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
}
......
......@@ -26,8 +26,6 @@
'sources': [
'ozone_platform_test.cc',
'ozone_platform_test.h',
'test_cursor_factory.cc',
'test_cursor_factory.h',
'test_window.cc',
'test_window.h',
'test_window_manager.cc',
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/ozone/platform/test/test_cursor_factory.h"
namespace ui {
TestCursorFactory::TestCursorFactory()
: cursor_window_(gfx::kNullAcceleratedWidget) {}
TestCursorFactory::~TestCursorFactory() {}
gfx::AcceleratedWidget TestCursorFactory::GetCursorWindow() {
return cursor_window_;
}
void TestCursorFactory::SetBitmapCursor(
gfx::AcceleratedWidget widget,
scoped_refptr<BitmapCursorOzone> cursor) {
cursor_window_ = widget;
cursor_ = cursor;
}
} // namespace ui
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_TEST_TEST_CURSOR_FACTORY_H_
#define UI_OZONE_PLATFORM_TEST_TEST_CURSOR_FACTORY_H_
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
namespace ui {
class TestCursorFactory : public BitmapCursorFactoryOzone {
public:
TestCursorFactory();
virtual ~TestCursorFactory();
// BitmapCursorFactoryOzone:
virtual gfx::AcceleratedWidget GetCursorWindow() OVERRIDE;
virtual void SetBitmapCursor(
gfx::AcceleratedWidget widget,
scoped_refptr<BitmapCursorOzone> cursor) OVERRIDE;
private:
gfx::AcceleratedWidget cursor_window_;
scoped_refptr<BitmapCursorOzone> cursor_;
DISALLOW_COPY_AND_ASSIGN(TestCursorFactory);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_TEST_TEST_CURSOR_FACTORY_H_
......@@ -46,14 +46,4 @@ void CursorFactoryOzone::UnrefImageCursor(PlatformCursor cursor) {
NOTIMPLEMENTED();
}
void CursorFactoryOzone::SetCursor(gfx::AcceleratedWidget widget,
PlatformCursor cursor) {
NOTIMPLEMENTED();
}
gfx::AcceleratedWidget CursorFactoryOzone::GetCursorWindow() {
NOTIMPLEMENTED();
return 0;
}
} // namespace ui
......@@ -41,15 +41,6 @@ class OZONE_BASE_EXPORT CursorFactoryOzone {
// Decrement platform image cursor refcount.
virtual void UnrefImageCursor(PlatformCursor cursor);
// Change the active cursor for an AcceleratedWidget.
// TODO(spang): Move this.
virtual void SetCursor(gfx::AcceleratedWidget widget, PlatformCursor cursor);
// Returns the window on which the cursor is active.
// TODO(dnicoara) Move this once the WindowTreeHost refactoring finishes and
// WindowTreeHost::CanDispatchEvent() is no longer present.
virtual gfx::AcceleratedWidget GetCursorWindow();
private:
static CursorFactoryOzone* impl_; // not owned
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment