| 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 "base/memory/weak_ptr.h" |
| 15 #include "cc/ipc/compositor_frame.mojom.h" |
| 16 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" |
| 17 #include "cc/resources/texture_mailbox.h" |
| 18 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 19 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
| 20 #include "cc/surfaces/local_surface_id_allocator.h" |
| 21 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 12 #include "ui/views/view.h" | 22 #include "ui/views/view.h" |
| 13 | 23 |
| 14 namespace aura { | 24 namespace aura { |
| 15 class Window; | 25 class Window; |
| 16 } | 26 } |
| 17 | 27 |
| 18 namespace gfx { | 28 namespace gfx { |
| 29 class GpuMemoryBuffer; |
| 19 class Point; | 30 class Point; |
| 20 } | 31 } |
| 21 | 32 |
| 22 namespace views { | 33 namespace views { |
| 23 class Widget; | 34 class Widget; |
| 24 } | 35 } |
| 25 | 36 |
| 26 namespace ash { | 37 namespace ash { |
| 38 struct LaserResource; |
| 27 | 39 |
| 28 // LaserPointerView displays the palette tool laser pointer. It draws the laser, | 40 // 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 | 41 // which consists of a point where the mouse cursor should be, as well as a |
| 30 // trail of lines to help users track. | 42 // trail of lines to help users track. |
| 31 class LaserPointerView : public views::View { | 43 class LaserPointerView : public views::View, |
| 44 public cc::mojom::MojoCompositorFrameSink, |
| 45 public cc::CompositorFrameSinkSupportClient { |
| 32 public: | 46 public: |
| 33 LaserPointerView(base::TimeDelta life_duration, aura::Window* root_window); | 47 LaserPointerView(base::TimeDelta life_duration, aura::Window* root_window); |
| 34 ~LaserPointerView() override; | 48 ~LaserPointerView() override; |
| 35 | 49 |
| 36 void AddNewPoint(const gfx::Point& new_point); | 50 void AddNewPoint(const gfx::Point& new_point); |
| 37 void UpdateTime(); | 51 void UpdateTime(); |
| 38 void Stop(); | 52 void Stop(); |
| 39 | 53 |
| 54 // Overridden from cc::mojom::MojoCompositorFrameSink: |
| 55 void SetNeedsBeginFrame(bool needs_begin_frame) override; |
| 56 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, |
| 57 cc::CompositorFrame frame) override; |
| 58 void EvictFrame() override; |
| 59 |
| 60 // Overridden from cc::CompositorFrameSinkSupportClient: |
| 61 void DidReceiveCompositorFrameAck() override; |
| 62 void OnBeginFrame(const cc::BeginFrameArgs& args) override {} |
| 63 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; |
| 64 void WillDrawSurface(const cc::LocalSurfaceId& local_surface_id, |
| 65 const gfx::Rect& damage_rect) override {} |
| 66 |
| 40 private: | 67 private: |
| 41 friend class LaserPointerControllerTestApi; | 68 friend class LaserPointerControllerTestApi; |
| 42 | 69 |
| 43 // view::View: | 70 gfx::Rect GetBoundingBox(); |
| 44 void OnPaint(gfx::Canvas* canvas) override; | |
| 45 | |
| 46 void OnPointsUpdated(); | 71 void OnPointsUpdated(); |
| 72 void UpdateBuffer(); |
| 73 void OnBufferUpdated(); |
| 74 void UpdateSurface(); |
| 75 void OnDidDrawSurface(); |
| 47 | 76 |
| 48 LaserPointerPoints laser_points_; | 77 LaserPointerPoints laser_points_; |
| 49 std::unique_ptr<views::Widget> widget_; | 78 std::unique_ptr<views::Widget> widget_; |
| 79 float scale_factor_ = 1.0f; |
| 80 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; |
| 81 gfx::Rect buffer_damage_rect_; |
| 82 bool pending_update_buffer_ = false; |
| 83 gfx::Rect surface_damage_rect_; |
| 84 bool needs_update_surface_ = false; |
| 85 bool pending_draw_surface_ = false; |
| 86 const cc::FrameSinkId frame_sink_id_; |
| 87 cc::CompositorFrameSinkSupport frame_sink_support_; |
| 88 cc::LocalSurfaceId local_surface_id_; |
| 89 cc::LocalSurfaceIdAllocator id_allocator_; |
| 90 int next_resource_id_ = 1; |
| 91 std::unordered_map<int, std::unique_ptr<LaserResource>> resources_; |
| 92 std::deque<std::unique_ptr<LaserResource>> returned_resources_; |
| 93 base::WeakPtrFactory<LaserPointerView> weak_ptr_factory_; |
| 50 | 94 |
| 51 DISALLOW_COPY_AND_ASSIGN(LaserPointerView); | 95 DISALLOW_COPY_AND_ASSIGN(LaserPointerView); |
| 52 }; | 96 }; |
| 53 | 97 |
| 54 } // namespace ash | 98 } // namespace ash |
| 55 | 99 |
| 56 #endif // ASH_LASER_LASER_POINTER_VIEW_H_ | 100 #endif // ASH_LASER_LASER_POINTER_VIEW_H_ |
| OLD | NEW |