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

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

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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/dri_cursor.h ('k') | ui/ozone/platform/dri/dri_gpu_platform_support.h » ('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/dri_cursor.h"
6
7 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
8 #include "ui/gfx/geometry/point.h"
9 #include "ui/gfx/geometry/point_conversions.h"
10 #include "ui/gfx/geometry/point_f.h"
11 #include "ui/ozone/platform/dri/dri_surface_factory.h"
12 #include "ui/ozone/platform/dri/dri_window.h"
13 #include "ui/ozone/platform/dri/dri_window_manager.h"
14 #include "ui/ozone/platform/dri/hardware_cursor_delegate.h"
15
16 namespace ui {
17
18 DriCursor::DriCursor(HardwareCursorDelegate* hardware,
19 DriWindowManager* window_manager)
20 : hardware_(hardware),
21 window_manager_(window_manager),
22 cursor_window_(gfx::kNullAcceleratedWidget) {
23 }
24
25 DriCursor::~DriCursor() {
26 }
27
28 void DriCursor::SetCursor(gfx::AcceleratedWidget widget,
29 PlatformCursor platform_cursor) {
30 DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
31 scoped_refptr<BitmapCursorOzone> cursor =
32 BitmapCursorFactoryOzone::GetBitmapCursor(platform_cursor);
33 if (cursor_ == cursor || cursor_window_ != widget)
34 return;
35
36 cursor_ = cursor;
37 ShowCursor();
38 }
39
40 void DriCursor::ShowCursor() {
41 DCHECK_NE(cursor_window_, gfx::kNullAcceleratedWidget);
42 if (cursor_.get())
43 hardware_->SetHardwareCursor(cursor_window_,
44 cursor_->bitmaps(),
45 bitmap_location(),
46 cursor_->frame_delay_ms());
47 else
48 HideCursor();
49 }
50
51 void DriCursor::HideCursor() {
52 DCHECK_NE(cursor_window_, gfx::kNullAcceleratedWidget);
53 hardware_->SetHardwareCursor(
54 cursor_window_, std::vector<SkBitmap>(), gfx::Point(), 0);
55 }
56
57 void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget,
58 const gfx::PointF& location) {
59 if (widget != cursor_window_ && cursor_window_ != gfx::kNullAcceleratedWidget)
60 HideCursor();
61
62 cursor_window_ = widget;
63 cursor_location_ = location;
64
65 if (cursor_window_ == gfx::kNullAcceleratedWidget)
66 return;
67
68 DriWindow* window = window_manager_->GetWindow(cursor_window_);
69 const gfx::Size& size = window->GetBounds().size();
70 cursor_location_.SetToMax(gfx::PointF(0, 0));
71 // Right and bottom edges are exclusive.
72 cursor_location_.SetToMin(gfx::PointF(size.width() - 1, size.height() - 1));
73
74 if (cursor_.get())
75 hardware_->MoveHardwareCursor(cursor_window_, bitmap_location());
76 }
77
78 void DriCursor::MoveCursor(const gfx::Vector2dF& delta) {
79 MoveCursorTo(cursor_window_, cursor_location_ + delta);
80 }
81
82 gfx::AcceleratedWidget DriCursor::GetCursorWindow() {
83 return cursor_window_;
84 }
85
86 bool DriCursor::IsCursorVisible() {
87 return cursor_.get();
88 }
89
90 gfx::PointF DriCursor::location() {
91 return cursor_location_;
92 }
93
94 gfx::Point DriCursor::bitmap_location() {
95 return gfx::ToFlooredPoint(cursor_location_) -
96 cursor_->hotspot().OffsetFromOrigin();
97 }
98
99 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/dri_cursor.h ('k') | ui/ozone/platform/dri/dri_gpu_platform_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698