Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_ | 6 #define CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_ |
| 7 | 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" | 8 #include "content/browser/media/capture/cursor_renderer.h" |
| 14 #include "content/common/content_export.h" | |
| 15 #include "media/base/video_frame.h" | |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | |
| 17 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 18 #include "ui/base/cursor/cursor.h" | |
| 19 #include "ui/events/event_handler.h" | 10 #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 | 11 |
| 24 namespace content { | 12 namespace content { |
| 25 | 13 |
| 26 // Setting to control cursor display based on either mouse movement or always | |
| 27 // forced to be enabled. | |
| 28 enum CursorDisplaySetting { | |
| 29 kCursorAlwaysEnabled, | |
| 30 kCursorEnabledOnMouseMovement | |
| 31 }; | |
| 32 | |
| 33 // Tracks state for making decisions on cursor display on a captured video | 14 // Tracks state for making decisions on cursor display on a captured video |
|
miu
2016/12/27 23:21:03
This class comment is incomplete. However, all the
braveyao
2017/01/04 01:57:49
Done.
| |
| 34 // frame. | 15 // frame. |
| 35 class CONTENT_EXPORT CursorRendererAura : public CursorRenderer, | 16 class CONTENT_EXPORT CursorRendererAura : public CursorRenderer, |
| 36 public ui::EventHandler, | 17 public ui::EventHandler, |
| 37 public aura::WindowObserver { | 18 public aura::WindowObserver { |
| 38 public: | 19 public: |
| 39 explicit CursorRendererAura(aura::Window* window, | 20 explicit CursorRendererAura(aura::Window* window, |
| 40 CursorDisplaySetting cursor_display); | 21 CursorDisplaySetting cursor_display); |
| 41 ~CursorRendererAura() final; | 22 ~CursorRendererAura() final; |
| 42 | 23 |
| 43 // CursorRender implementation. | 24 // CursorRender implementation. |
| 44 void Clear() final; | 25 bool IsCapturedViewActive() final; |
| 45 bool SnapshotCursorState(const gfx::Rect& region_in_frame) final; | 26 gfx::Size GetCapturedViewSize() final; |
| 46 void RenderOnVideoFrame( | 27 gfx::Point GetCursorPositionInView() final; |
| 47 const scoped_refptr<media::VideoFrame>& target) const final; | 28 gfx::NativeCursor GetLastKnownCursor() final; |
| 48 base::WeakPtr<CursorRenderer> GetWeakPtr() final; | 29 gfx::Point GetLastKnownCursorHotPoint() final; |
| 30 SkBitmap GetLastKnownCursorImage() final; | |
| 49 | 31 |
| 50 // ui::EventHandler overrides. | 32 // ui::EventHandler overrides. |
| 51 void OnMouseEvent(ui::MouseEvent* event) final; | 33 void OnMouseEvent(ui::MouseEvent* event) final; |
| 52 | 34 |
| 53 // aura::WindowObserver overrides. | 35 // aura::WindowObserver overrides. |
| 54 void OnWindowDestroying(aura::Window* window) final; | 36 void OnWindowDestroying(aura::Window* window) final; |
| 55 | 37 |
| 56 private: | 38 private: |
| 57 friend class CursorRendererAuraTest; | |
| 58 | |
| 59 aura::Window* window_; | 39 aura::Window* window_; |
| 60 | 40 gfx::Point last_cursor_hot_point_; |
|
miu
2016/12/27 23:21:03
You can remove this member (see comments in .cc fi
braveyao
2017/01/04 01:57:49
Done.
| |
| 61 // Snapshot of cursor, source size, position, and cursor bitmap; as of the | |
| 62 // last call to SnapshotCursorState. | |
| 63 ui::Cursor last_cursor_; | |
| 64 gfx::Size window_size_when_cursor_last_updated_; | |
| 65 gfx::Point cursor_position_in_frame_; | |
| 66 SkBitmap scaled_cursor_bitmap_; | |
| 67 | |
| 68 // Updated in mouse event listener and used to make a decision on | |
| 69 // when the cursor is rendered. | |
| 70 base::TimeTicks last_mouse_movement_timestamp_; | |
| 71 float last_mouse_position_x_; | |
| 72 float last_mouse_position_y_; | |
| 73 bool cursor_displayed_; | |
| 74 | 41 |
| 75 // Controls whether cursor is displayed based on active mouse movement. | 42 // Controls whether cursor is displayed based on active mouse movement. |
| 76 const CursorDisplaySetting cursor_display_setting_; | 43 const CursorDisplaySetting cursor_display_setting_; |
|
miu
2016/12/27 23:21:03
ditto: You can remove this member too.
braveyao
2017/01/04 01:57:49
Done.
| |
| 77 | 44 |
| 78 // Allows tests to replace the clock. | |
| 79 base::DefaultTickClock default_tick_clock_; | |
| 80 base::TickClock* tick_clock_; | |
| 81 | |
| 82 base::WeakPtrFactory<CursorRendererAura> weak_factory_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(CursorRendererAura); | 45 DISALLOW_COPY_AND_ASSIGN(CursorRendererAura); |
| 85 }; | 46 }; |
| 86 | 47 |
| 87 } // namespace content | 48 } // namespace content |
| 88 | 49 |
| 89 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_ | 50 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_ |
| OLD | NEW |