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

Side by Side Diff: ui/ozone/platform/dri/cursor_factory_evdev_dri.cc

Issue 527293002: ozone: Remove CursorFactoryOzone::SetCursor, GetCursorWindow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/dri/cursor_factory_evdev_dri.h ('k') | ui/ozone/platform/dri/dri.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h"
6
7 #include "ui/gfx/geometry/point_conversions.h"
8 #include "ui/ozone/platform/dri/dri_surface_factory.h"
9 #include "ui/ozone/platform/dri/hardware_cursor_delegate.h"
10
11 namespace ui {
12
13 CursorFactoryEvdevDri::CursorFactoryEvdevDri(HardwareCursorDelegate* hardware)
14 : hardware_(hardware) {
15 // TODO(dnicoara) Assume the first widget since at this point there are no
16 // widgets initialized.
17 cursor_window_ = DriSurfaceFactory::kDefaultWidgetHandle;
18 cursor_location_ = gfx::PointF(2560 / 2, 1700 / 2); // TODO(spang): Argh!
19 }
20
21 CursorFactoryEvdevDri::~CursorFactoryEvdevDri() {}
22
23 void CursorFactoryEvdevDri::SetBitmapCursor(
24 gfx::AcceleratedWidget widget,
25 scoped_refptr<BitmapCursorOzone> cursor) {
26 if (cursor_ == cursor)
27 return;
28
29 cursor_ = cursor;
30 if (cursor_)
31 hardware_->SetHardwareCursor(
32 cursor_window_, cursor_->bitmap(), bitmap_location());
33 else
34 hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point());
35 }
36
37 void CursorFactoryEvdevDri::MoveCursorTo(gfx::AcceleratedWidget widget,
38 const gfx::PointF& location) {
39 if (widget != cursor_window_)
40 hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point());
41
42 cursor_window_ = widget;
43 cursor_location_ = location;
44
45 gfx::Size size = gfx::Size(2560, 1700); // TODO(spang): Fix.
46 cursor_location_.SetToMax(gfx::PointF(0, 0));
47 cursor_location_.SetToMin(gfx::PointF(size.width(), size.height()));
48
49 if (cursor_)
50 hardware_->MoveHardwareCursor(cursor_window_, bitmap_location());
51 }
52
53 void CursorFactoryEvdevDri::MoveCursor(const gfx::Vector2dF& delta) {
54 MoveCursorTo(cursor_window_, cursor_location_ + delta);
55 }
56
57 gfx::AcceleratedWidget CursorFactoryEvdevDri::GetCursorWindow() {
58 return cursor_window_;
59 }
60
61 bool CursorFactoryEvdevDri::IsCursorVisible() { return cursor_; }
62
63 gfx::PointF CursorFactoryEvdevDri::location() { return cursor_location_; }
64
65 gfx::Point CursorFactoryEvdevDri::bitmap_location() {
66 return gfx::ToFlooredPoint(cursor_location_) -
67 cursor_->hotspot().OffsetFromOrigin();
68 }
69
70 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/cursor_factory_evdev_dri.h ('k') | ui/ozone/platform/dri/dri.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698