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 CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_MAC_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_MAC_H_ |
6 #define CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_MAC_H_ | 6 #define CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_MAC_H_ |
7 | 7 |
8 #include "base/mac/scoped_cftyperef.h" | 8 #import <AppKit/AppKit.h> |
9 #include "base/macros.h" | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/mac/scoped_nsobject.h" |
11 #include "content/browser/media/capture/cursor_renderer.h" | 11 #include "content/browser/media/capture/cursor_renderer.h" |
12 #include "content/common/content_export.h" | 12 #import "ui/base/cocoa/tracking_area.h" |
13 #include "media/base/video_frame.h" | 13 |
| 14 @interface CursorRendererMouseTracker : NSObject { |
| 15 @private |
| 16 ui::ScopedCrTrackingArea trackingArea_; |
| 17 |
| 18 // The view on which mouse movement is detected. |
| 19 base::scoped_nsobject<NSView> capturedView_; |
| 20 |
| 21 // Runs on any mouse interaction from user. |
| 22 base::Closure mouseInteractionObserver_; |
| 23 } |
| 24 |
| 25 - (instancetype)initWithView:(NSView*)nsView; |
| 26 |
| 27 // Register an observer for mouse interaction. |
| 28 - (void)registerMouseInteractionObserver:(const base::Closure&)observer; |
| 29 |
| 30 @end |
14 | 31 |
15 namespace content { | 32 namespace content { |
16 | 33 |
17 // Tracks state for making decisions on cursor display on a captured video | |
18 // frame. | |
19 class CONTENT_EXPORT CursorRendererMac : public CursorRenderer { | 34 class CONTENT_EXPORT CursorRendererMac : public CursorRenderer { |
20 public: | 35 public: |
21 explicit CursorRendererMac(NSView* view); | 36 explicit CursorRendererMac(gfx::NativeView view); |
22 ~CursorRendererMac() final; | 37 ~CursorRendererMac() final; |
23 | 38 |
24 // CursorRender implementation. | 39 // CursorRender implementation. |
25 void Clear() final; | 40 bool IsCapturedViewActive() final; |
26 bool SnapshotCursorState(const gfx::Rect& region_in_frame) final; | 41 gfx::Size GetCapturedViewSize() final; |
27 void RenderOnVideoFrame( | 42 gfx::Point GetCursorPositionInView() final; |
28 const scoped_refptr<media::VideoFrame>& target) const final; | 43 gfx::NativeCursor GetLastKnownCursor() final; |
29 base::WeakPtr<CursorRenderer> GetWeakPtr() final; | 44 SkBitmap GetLastKnownCursorImage(gfx::Point* hot_point) final; |
30 | 45 |
31 private: | 46 private: |
| 47 // Called for mouse activity events. |
| 48 void OnMouseEvent(); |
| 49 |
32 NSView* const view_; | 50 NSView* const view_; |
33 base::ScopedCFTypeRef<CFDataRef> last_cursor_data_; | |
34 int last_cursor_width_; | |
35 int last_cursor_height_; | |
36 gfx::Point cursor_position_in_frame_; | |
37 | 51 |
38 base::TimeTicks last_mouse_movement_timestamp_; | 52 base::scoped_nsobject<CursorRendererMouseTracker> mouse_tracker_; |
39 float last_mouse_location_x_; | |
40 float last_mouse_location_y_; | |
41 | 53 |
42 base::WeakPtrFactory<CursorRendererMac> weak_factory_; | |
43 DISALLOW_COPY_AND_ASSIGN(CursorRendererMac); | 54 DISALLOW_COPY_AND_ASSIGN(CursorRendererMac); |
44 }; | 55 }; |
45 | 56 |
46 } // namespace content | 57 } // namespace content |
47 | 58 |
48 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_MAC_H_ | 59 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_MAC_H_ |
OLD | NEW |