| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2015 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 #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/time/default_tick_clock.h" |
| 12 #include "base/time/tick_clock.h" |
| 13 #include "content/browser/media/capture/cursor_renderer.h" |
| 14 #include "content/common/content_export.h" |
| 15 #include "media/base/video_frame.h" |
| 16 #include "skia/ext/image_operations.h" |
| 17 #include "ui/aura/window.h" |
| 18 #include "ui/base/cursor/cursor.h" |
| 19 #include "ui/events/event_handler.h" |
| 20 #include "ui/gfx/geometry/point.h" |
| 21 #include "ui/gfx/geometry/rect.h" |
| 22 #include "ui/gfx/geometry/size.h" |
| 23 |
| 24 namespace content { |
| 25 |
| 26 // Tracks state for making decisions on cursor display on a captured video |
| 27 // frame. |
| 28 class CONTENT_EXPORT CursorRendererAura : public CursorRenderer, |
| 29 public ui::EventHandler, |
| 30 public aura::WindowObserver { |
| 31 public: |
| 32 explicit CursorRendererAura(aura::Window* window); |
| 33 ~CursorRendererAura() final; |
| 34 |
| 35 // CursorRender implementation. |
| 36 void Clear() final; |
| 37 bool SnapshotCursorState(const gfx::Rect& region_in_frame) final; |
| 38 void RenderOnVideoFrame( |
| 39 const scoped_refptr<media::VideoFrame>& target) const final; |
| 40 base::WeakPtr<CursorRenderer> GetWeakPtr() final; |
| 41 |
| 42 // ui::EventHandler overrides. |
| 43 void OnMouseEvent(ui::MouseEvent* event) final; |
| 44 |
| 45 // aura::WindowObserver overrides. |
| 46 void OnWindowDestroying(aura::Window* window) final; |
| 47 |
| 48 private: |
| 49 friend class CursorRendererAuraTest; |
| 50 |
| 51 aura::Window* window_; |
| 52 |
| 53 // Snapshot of cursor, source size, position, and cursor bitmap; as of the |
| 54 // last call to SnapshotCursorState. |
| 55 ui::Cursor last_cursor_; |
| 56 gfx::Size window_size_when_cursor_last_updated_; |
| 57 gfx::Point cursor_position_in_frame_; |
| 58 SkBitmap scaled_cursor_bitmap_; |
| 59 |
| 60 // Updated in mouse event listener and used to make a decision on |
| 61 // when the cursor is rendered. |
| 62 base::TimeDelta last_mouse_movement_timestamp_; |
| 63 float last_mouse_position_x_; |
| 64 float last_mouse_position_y_; |
| 65 bool cursor_displayed_; |
| 66 |
| 67 // Allows tests to replace the clock. |
| 68 base::DefaultTickClock default_tick_clock_; |
| 69 base::TickClock* tick_clock_; |
| 70 |
| 71 base::WeakPtrFactory<CursorRendererAura> weak_factory_; |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(CursorRendererAura); |
| 74 }; |
| 75 |
| 76 } // namespace content |
| 77 |
| 78 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_ |
| OLD | NEW |