| OLD | NEW |
| 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 <memory> | 9 #include <memory> |
| 10 #include <unordered_map> |
| 9 | 11 |
| 10 #include "ash/laser/laser_pointer_points.h" | 12 #include "ash/laser/laser_pointer_points.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "cc/resources/texture_mailbox.h" |
| 15 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 16 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
| 17 #include "cc/surfaces/surface_id_allocator.h" |
| 12 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
| 13 | 19 |
| 14 namespace aura { | 20 namespace aura { |
| 15 class Window; | 21 class Window; |
| 16 } | 22 } |
| 17 | 23 |
| 18 namespace gfx { | 24 namespace gfx { |
| 25 class GpuMemoryBuffer; |
| 19 class Point; | 26 class Point; |
| 20 } | 27 } |
| 21 | 28 |
| 22 namespace views { | 29 namespace views { |
| 23 class Widget; | 30 class Widget; |
| 24 } | 31 } |
| 25 | 32 |
| 26 namespace ash { | 33 namespace ash { |
| 34 struct LaserResource; |
| 27 | 35 |
| 28 // LaserPointerView displays the palette tool laser pointer. It draws the laser, | 36 // LaserPointerView displays the palette tool laser pointer. It draws the laser, |
| 29 // which consists of a point where the mouse cursor should be, as well as a | 37 // which consists of a point where the mouse cursor should be, as well as a |
| 30 // trail of lines to help users track. | 38 // trail of lines to help users track. |
| 31 class LaserPointerView : public views::View { | 39 class LaserPointerView : public views::View, |
| 40 public cc::CompositorFrameSinkSupportClient { |
| 32 public: | 41 public: |
| 33 LaserPointerView(base::TimeDelta life_duration, aura::Window* root_window); | 42 LaserPointerView(base::TimeDelta life_duration, aura::Window* root_window); |
| 34 ~LaserPointerView() override; | 43 ~LaserPointerView() override; |
| 35 | 44 |
| 36 void AddNewPoint(const gfx::Point& new_point); | 45 void AddNewPoint(const gfx::Point& new_point); |
| 37 void UpdateTime(); | 46 void UpdateTime(); |
| 38 void Stop(); | 47 void Stop(); |
| 39 | 48 |
| 49 // Overridden from cc::CompositorFrameSinkSupportClient: |
| 50 void DidReceiveCompositorFrameAck() override {} |
| 51 void OnBeginFrame(const cc::BeginFrameArgs& args) override {} |
| 52 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; |
| 53 void WillDrawSurface(const cc::LocalSurfaceId& local_surface_id, |
| 54 const gfx::Rect& damage_rect) override {} |
| 55 |
| 40 private: | 56 private: |
| 41 friend class LaserPointerControllerTestApi; | 57 friend class LaserPointerControllerTestApi; |
| 42 | 58 |
| 43 // view::View: | 59 gfx::Rect GetBoundingBox(); |
| 44 void OnPaint(gfx::Canvas* canvas) override; | 60 void OnPointsUpdated(const gfx::Rect& damage_rect); |
| 45 | 61 void UpdateSurface(); |
| 46 void OnPointsUpdated(); | |
| 47 | 62 |
| 48 LaserPointerPoints laser_points_; | 63 LaserPointerPoints laser_points_; |
| 49 std::unique_ptr<views::Widget> widget_; | 64 std::unique_ptr<views::Widget> widget_; |
| 65 float scale_factor_ = 1.0f; |
| 66 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; |
| 67 const cc::FrameSinkId frame_sink_id_; |
| 68 cc::CompositorFrameSinkSupport frame_sink_support_; |
| 69 cc::LocalSurfaceId local_surface_id_; |
| 70 cc::SurfaceIdAllocator id_allocator_; |
| 71 gfx::Rect damage_rect_; |
| 72 int next_resource_id_ = 1; |
| 73 bool needs_update_surface_ = false; |
| 74 std::unordered_map<int, std::unique_ptr<LaserResource>> resources_; |
| 75 std::deque<std::unique_ptr<LaserResource>> returned_resources_; |
| 50 | 76 |
| 51 DISALLOW_COPY_AND_ASSIGN(LaserPointerView); | 77 DISALLOW_COPY_AND_ASSIGN(LaserPointerView); |
| 52 }; | 78 }; |
| 53 | 79 |
| 54 } // namespace ash | 80 } // namespace ash |
| 55 | 81 |
| 56 #endif // ASH_LASER_LASER_POINTER_VIEW_H_ | 82 #endif // ASH_LASER_LASER_POINTER_VIEW_H_ |
| OLD | NEW |