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