Index: content/browser/media/capture/cursor_renderer.h |
diff --git a/content/browser/media/capture/cursor_renderer.h b/content/browser/media/capture/cursor_renderer.h |
index 9ac912e68febe2ab1d7a938d3c66f022f67647de..d5dbb718857956fee5f2d63f0a6553455b8fef80 100644 |
--- a/content/browser/media/capture/cursor_renderer.h |
+++ b/content/browser/media/capture/cursor_renderer.h |
@@ -8,12 +8,23 @@ |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/weak_ptr.h" |
+#include "base/time/default_tick_clock.h" |
+#include "base/time/tick_clock.h" |
#include "content/common/content_export.h" |
#include "media/base/video_frame.h" |
+#include "third_party/skia/include/core/SkBitmap.h" |
+#include "ui/base/cursor/cursor.h" |
#include "ui/gfx/native_widget_types.h" |
namespace content { |
+// Setting to control cursor display based on either mouse movement or always |
+// forced to be enabled. |
+enum CursorDisplaySetting { |
+ kCursorAlwaysEnabled, |
+ kCursorEnabledOnMouseMovement |
+}; |
+ |
// CursorRenderer is an interface that can be implememented to do cursor |
miu
2016/12/27 23:21:03
This class comment needs to be updated, since this
braveyao
2017/01/04 01:57:49
Done.
|
// rendering on a video frame. |
// |
@@ -23,33 +34,87 @@ class CONTENT_EXPORT CursorRenderer { |
public: |
static std::unique_ptr<CursorRenderer> Create(gfx::NativeView view); |
- virtual ~CursorRenderer() {} |
+ CursorRenderer(gfx::NativeView captured_view, |
+ CursorDisplaySetting cursor_display); |
+ |
+ virtual ~CursorRenderer(); |
// Clears the cursor state being tracked. Called when there is a need to |
// reset the state. |
- virtual void Clear() = 0; |
+ void Clear(); |
// Takes a snapshot of the current cursor state and determines whether |
// the cursor will be rendered, which cursor image to render, and at what |
// location within |region_in_frame| to render it. Returns true if cursor |
// needs to be rendered. |
- virtual bool SnapshotCursorState(const gfx::Rect& region_in_frame) = 0; |
+ bool SnapshotCursorState(const gfx::Rect& region_in_frame); |
// Renders cursor on the |target| video frame. |
- virtual void RenderOnVideoFrame( |
- const scoped_refptr<media::VideoFrame>& target) const = 0; |
+ void RenderOnVideoFrame(const scoped_refptr<media::VideoFrame>& target) const; |
miu
2016/12/27 23:21:03
style nit (per smart pointer guidelines): The old
braveyao
2017/01/04 01:57:49
Done.
|
// Returns a weak pointer. |
- virtual base::WeakPtr<CursorRenderer> GetWeakPtr() = 0; |
+ base::WeakPtr<CursorRenderer> GetWeakPtr(); |
protected: |
enum { |
// Minium movement before cursor is rendered on frame. |
MIN_MOVEMENT_PIXELS = 15, |
- // Maximum idle time allowed before we stop rendering the cursor |
- // on frame. |
+ // Maximum idle time allowed before we stop rendering the cursor on frame. |
MAX_IDLE_TIME_SECONDS = 2 |
}; |
+ |
+ // Returns true if the captured view is a part of an active application |
+ // window. |
+ virtual bool IsCapturedViewActive() = 0; |
+ |
+ // Returns the size of the captured view (view coordinates). |
+ virtual gfx::Size GetCapturedViewSize() = 0; |
+ |
+ // Returns the cursor's position within the captured view (view coordinates). |
+ virtual gfx::Point GetCursorPositionInView() = 0; |
+ |
+ // Returns the last-known mouse cursor. |
+ virtual gfx::NativeCursor GetLastKnownCursor() = 0; |
+ |
+ // Returns the image of the last-known mouse cursor. |
+ virtual SkBitmap GetLastKnownCursorImage() = 0; |
+ |
+ // Returns the hot point (in the cursor image) of the last-known mouse cursor. |
+ virtual gfx::Point GetLastKnownCursorHotPoint() = 0; |
+ |
+ // Called by subclasses to report mouse events within the captured view. |
+ void OnMouseMoved(const gfx::Point& location, base::TimeTicks timestamp); |
+ void OnMouseClicked(const gfx::Point& location, base::TimeTicks timestamp); |
+ |
+ private: |
+ friend class CursorRendererAuraTest; |
+ |
+ gfx::NativeView captured_view_; |
miu
2016/12/27 23:21:03
nit: Use const since this member doesn't change af
braveyao
2017/01/04 01:57:49
Done.
|
+ |
+ // Snapshot of cursor, source size, position, and cursor bitmap; as of the |
+ // last call to SnapshotCursorState. |
+ gfx::NativeCursor last_cursor_; |
+ gfx::Point cursor_position_in_frame_; |
+ gfx::Point last_cursor_hot_point_; |
+ gfx::Size window_size_when_cursor_last_updated_; |
miu
2016/12/27 23:21:03
naming nit: How about |view_size_when_cursor_last_
braveyao
2017/01/04 01:57:49
Done.
|
+ SkBitmap scaled_cursor_bitmap_; |
+ |
+ // Updated in mouse event listener and used to make a decision on |
+ // when the cursor is rendered. |
+ base::TimeTicks last_mouse_movement_timestamp_; |
+ float last_mouse_position_x_; |
+ float last_mouse_position_y_; |
+ bool cursor_displayed_; |
+ |
+ // Controls whether cursor is displayed based on active mouse movement. |
+ CursorDisplaySetting cursor_display_setting_; |
+ |
+ // Allows tests to replace the clock. |
+ base::DefaultTickClock default_tick_clock_; |
+ base::TickClock* tick_clock_; |
+ |
+ base::WeakPtrFactory<CursorRenderer> weak_factory_; |
+ DISALLOW_COPY_AND_ASSIGN(CursorRenderer); |
miu
2016/12/27 23:21:03
nit: Please add a blank line above this line.
braveyao
2017/01/04 01:57:49
Done.
|
}; |
} // namespace content |