Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: content/browser/media/capture/cursor_renderer_aura.h

Issue 2553763002: Fix cursor missing in tabCapture on OSX Sierra (Closed)
Patch Set: rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
34 // frame.
35 class CONTENT_EXPORT CursorRendererAura : public CursorRenderer, 14 class CONTENT_EXPORT CursorRendererAura : public CursorRenderer,
36 public ui::EventHandler, 15 public ui::EventHandler,
37 public aura::WindowObserver { 16 public aura::WindowObserver {
38 public: 17 public:
39 explicit CursorRendererAura(aura::Window* window, 18 explicit CursorRendererAura(aura::Window* window,
40 CursorDisplaySetting cursor_display); 19 CursorDisplaySetting cursor_display);
41 ~CursorRendererAura() final; 20 ~CursorRendererAura() final;
42 21
43 // CursorRender implementation. 22 // CursorRender implementation.
44 void Clear() final; 23 bool IsCapturedViewActive() final;
45 bool SnapshotCursorState(const gfx::Rect& region_in_frame) final; 24 gfx::Size GetCapturedViewSize() final;
46 void RenderOnVideoFrame( 25 gfx::Point GetCursorPositionInView() final;
47 const scoped_refptr<media::VideoFrame>& target) const final; 26 gfx::NativeCursor GetLastKnownCursor() final;
48 base::WeakPtr<CursorRenderer> GetWeakPtr() final; 27 SkBitmap GetLastKnownCursorImage(gfx::Point* hot_point) final;
49 28
50 // ui::EventHandler overrides. 29 // ui::EventHandler overrides.
51 void OnMouseEvent(ui::MouseEvent* event) final; 30 void OnMouseEvent(ui::MouseEvent* event) final;
52 31
53 // aura::WindowObserver overrides. 32 // aura::WindowObserver overrides.
54 void OnWindowDestroying(aura::Window* window) final; 33 void OnWindowDestroying(aura::Window* window) final;
55 34
56 private: 35 private:
57 friend class CursorRendererAuraTest;
58
59 aura::Window* window_; 36 aura::Window* window_;
60 37
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
75 // Controls whether cursor is displayed based on active mouse movement.
76 const CursorDisplaySetting cursor_display_setting_;
77
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); 38 DISALLOW_COPY_AND_ASSIGN(CursorRendererAura);
85 }; 39 };
86 40
87 } // namespace content 41 } // namespace content
88 42
89 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_ 43 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_
OLDNEW
« no previous file with comments | « content/browser/media/capture/cursor_renderer.cc ('k') | content/browser/media/capture/cursor_renderer_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698