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

Side by Side Diff: ash/laser/laser_pointer_view.h

Issue 2745953002: ash: Add basic prediction code to the laser pointer. (Closed)
Patch Set: more tests and nits Created 3 years, 9 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 | « ash/laser/laser_pointer_points_unittest.cc ('k') | ash/laser/laser_pointer_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_LASER_LASER_POINTER_VIEW_H_ 5 #ifndef ASH_LASER_LASER_POINTER_VIEW_H_
6 #define ASH_LASER_LASER_POINTER_VIEW_H_ 6 #define ASH_LASER_LASER_POINTER_VIEW_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <memory> 9 #include <memory>
10 #include <unordered_map> 10 #include <unordered_map>
11 11
12 #include "ash/laser/laser_pointer_points.h" 12 #include "ash/laser/laser_pointer_points.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/time/time.h"
15 #include "cc/ipc/compositor_frame.mojom.h" 16 #include "cc/ipc/compositor_frame.mojom.h"
16 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" 17 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h"
17 #include "cc/resources/texture_mailbox.h" 18 #include "cc/resources/texture_mailbox.h"
18 #include "cc/surfaces/compositor_frame_sink_support.h" 19 #include "cc/surfaces/compositor_frame_sink_support.h"
19 #include "cc/surfaces/compositor_frame_sink_support_client.h" 20 #include "cc/surfaces/compositor_frame_sink_support_client.h"
20 #include "cc/surfaces/local_surface_id_allocator.h" 21 #include "cc/surfaces/local_surface_id_allocator.h"
21 #include "mojo/public/cpp/bindings/strong_binding.h" 22 #include "mojo/public/cpp/bindings/strong_binding.h"
22 #include "ui/views/view.h" 23 #include "ui/views/view.h"
23 24
24 namespace aura { 25 namespace aura {
(...skipping 12 matching lines...) Expand all
37 namespace ash { 38 namespace ash {
38 struct LaserResource; 39 struct LaserResource;
39 40
40 // LaserPointerView displays the palette tool laser pointer. It draws the laser, 41 // LaserPointerView displays the palette tool laser pointer. It draws the laser,
41 // which consists of a point where the mouse cursor should be, as well as a 42 // which consists of a point where the mouse cursor should be, as well as a
42 // trail of lines to help users track. 43 // trail of lines to help users track.
43 class LaserPointerView : public views::View, 44 class LaserPointerView : public views::View,
44 public cc::mojom::MojoCompositorFrameSink, 45 public cc::mojom::MojoCompositorFrameSink,
45 public cc::CompositorFrameSinkSupportClient { 46 public cc::CompositorFrameSinkSupportClient {
46 public: 47 public:
47 LaserPointerView(base::TimeDelta life_duration, aura::Window* root_window); 48 LaserPointerView(base::TimeDelta life_duration,
49 base::TimeDelta presentation_delay,
50 aura::Window* root_window);
48 ~LaserPointerView() override; 51 ~LaserPointerView() override;
49 52
50 void AddNewPoint(const gfx::PointF& new_point); 53 void AddNewPoint(const gfx::PointF& new_point,
54 const base::TimeTicks& new_time);
51 void UpdateTime(); 55 void UpdateTime();
52 void Stop(); 56 void Stop();
53 57
54 // Overridden from cc::mojom::MojoCompositorFrameSink: 58 // Overridden from cc::mojom::MojoCompositorFrameSink:
55 void SetNeedsBeginFrame(bool needs_begin_frame) override; 59 void SetNeedsBeginFrame(bool needs_begin_frame) override;
56 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, 60 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id,
57 cc::CompositorFrame frame) override; 61 cc::CompositorFrame frame) override;
58 void EvictFrame() override; 62 void EvictFrame() override;
59 63
60 // Overridden from cc::CompositorFrameSinkSupportClient: 64 // Overridden from cc::CompositorFrameSinkSupportClient:
61 void DidReceiveCompositorFrameAck() override; 65 void DidReceiveCompositorFrameAck() override;
62 void OnBeginFrame(const cc::BeginFrameArgs& args) override {} 66 void OnBeginFrame(const cc::BeginFrameArgs& args) override {}
63 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; 67 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
64 void WillDrawSurface(const cc::LocalSurfaceId& local_surface_id, 68 void WillDrawSurface(const cc::LocalSurfaceId& local_surface_id,
65 const gfx::Rect& damage_rect) override {} 69 const gfx::Rect& damage_rect) override {}
66 70
67 private: 71 private:
68 friend class LaserPointerControllerTestApi; 72 friend class LaserPointerControllerTestApi;
69 73
70 gfx::Rect GetBoundingBox(); 74 gfx::Rect GetBoundingBox();
71 void OnPointsUpdated(); 75 void OnPointsUpdated();
72 void UpdateBuffer(); 76 void UpdateBuffer();
73 void OnBufferUpdated(); 77 void OnBufferUpdated();
74 void UpdateSurface(); 78 void UpdateSurface();
75 void OnDidDrawSurface(); 79 void OnDidDrawSurface();
76 80
77 LaserPointerPoints laser_points_; 81 LaserPointerPoints laser_points_;
82 LaserPointerPoints predicted_laser_points_;
78 std::unique_ptr<views::Widget> widget_; 83 std::unique_ptr<views::Widget> widget_;
79 float scale_factor_ = 1.0f; 84 float scale_factor_ = 1.0f;
85 const base::TimeDelta presentation_delay_;
80 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; 86 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
81 gfx::Rect buffer_damage_rect_; 87 gfx::Rect buffer_damage_rect_;
82 bool pending_update_buffer_ = false; 88 bool pending_update_buffer_ = false;
83 gfx::Rect surface_damage_rect_; 89 gfx::Rect surface_damage_rect_;
84 bool needs_update_surface_ = false; 90 bool needs_update_surface_ = false;
85 bool pending_draw_surface_ = false; 91 bool pending_draw_surface_ = false;
86 const cc::FrameSinkId frame_sink_id_; 92 const cc::FrameSinkId frame_sink_id_;
87 cc::CompositorFrameSinkSupport frame_sink_support_; 93 cc::CompositorFrameSinkSupport frame_sink_support_;
88 cc::LocalSurfaceId local_surface_id_; 94 cc::LocalSurfaceId local_surface_id_;
89 cc::LocalSurfaceIdAllocator id_allocator_; 95 cc::LocalSurfaceIdAllocator id_allocator_;
90 int next_resource_id_ = 1; 96 int next_resource_id_ = 1;
91 std::unordered_map<int, std::unique_ptr<LaserResource>> resources_; 97 std::unordered_map<int, std::unique_ptr<LaserResource>> resources_;
92 std::deque<std::unique_ptr<LaserResource>> returned_resources_; 98 std::deque<std::unique_ptr<LaserResource>> returned_resources_;
93 base::WeakPtrFactory<LaserPointerView> weak_ptr_factory_; 99 base::WeakPtrFactory<LaserPointerView> weak_ptr_factory_;
94 100
95 DISALLOW_COPY_AND_ASSIGN(LaserPointerView); 101 DISALLOW_COPY_AND_ASSIGN(LaserPointerView);
96 }; 102 };
97 103
98 } // namespace ash 104 } // namespace ash
99 105
100 #endif // ASH_LASER_LASER_POINTER_VIEW_H_ 106 #endif // ASH_LASER_LASER_POINTER_VIEW_H_
OLDNEW
« no previous file with comments | « ash/laser/laser_pointer_points_unittest.cc ('k') | ash/laser/laser_pointer_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698