Chromium Code Reviews| 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_H_ | |
| 6 #define CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "content/common/content_export.h" | |
| 11 #include "media/base/video_frame.h" | |
| 12 #include "skia/ext/image_operations.h" | |
| 13 #include "ui/aura/window.h" | |
| 14 #include "ui/base/cursor/cursor.h" | |
| 15 #include "ui/events/event_handler.h" | |
| 16 #include "ui/gfx/geometry/point.h" | |
| 17 #include "ui/gfx/geometry/rect.h" | |
| 18 #include "ui/gfx/geometry/size.h" | |
| 19 #include "ui/gfx/native_widget_types.h" | |
| 20 | |
| 21 namespace content { | |
| 22 | |
| 23 enum { | |
| 24 ENABLE_MOUSE_EVENTS = 1 | |
|
miu
2015/10/20 02:12:44
I suggest removing this for a number of technical
xjz
2015/10/20 17:12:08
I think we want to disable the mouse cursor while
Irfan
2015/10/21 23:01:07
Have gone with keeping the same code for all cases
Irfan
2015/10/21 23:01:08
I did consider keeping the mouse rendering logic f
| |
| 25 }; | |
| 26 | |
| 27 // Tracks state for making decisions on cursor display on a captured video | |
| 28 // frame | |
| 29 class CONTENT_EXPORT CursorRenderer : public ui::EventHandler { | |
| 30 public: | |
| 31 explicit CursorRenderer(aura::Window* window, | |
|
miu
2015/10/20 02:12:44
Please comment that |window| is expected to out-li
Irfan
2015/10/21 23:01:07
Done.
| |
| 32 bool enable_mouse_events = false); | |
|
miu
2015/10/20 02:12:44
Just need the |window| argument. If it's not null
Irfan
2015/10/21 23:01:07
Done.
| |
| 33 ~CursorRenderer() override; | |
| 34 void Clear(); | |
| 35 bool Update(const gfx::Rect& region_in_frame); | |
| 36 void RenderOnVideoFrame(const scoped_refptr<media::VideoFrame>& target) const; | |
| 37 // Overridden from ui::EventHandler to make decision on when | |
| 38 // cursor gets rendered on a captured video frame | |
| 39 void OnMouseEvent(ui::MouseEvent* event) override; | |
| 40 | |
| 41 private: | |
| 42 ui::Cursor last_cursor_; | |
| 43 gfx::Size window_size_when_cursor_last_updated_; | |
| 44 gfx::Point cursor_position_in_frame_; | |
| 45 SkBitmap scaled_cursor_bitmap_; | |
| 46 aura::Window* window_; | |
| 47 | |
| 48 // This flag enables mouse event tracking for the purpose of disabling | |
| 49 // cursor rendering when there is no movement | |
| 50 const bool enable_mouse_events_; | |
|
miu
2015/10/20 02:12:44
ditto here: No need for a bool since |window_| wil
| |
| 51 | |
| 52 enum { | |
| 53 // Minium movement before cursor is rendered on frame | |
| 54 MIN_MOVEMENT = 15 | |
| 55 }; | |
| 56 enum { | |
|
miu
2015/10/20 02:12:44
nit: These can both be in one enum block.
Irfan
2015/10/21 23:01:08
I had kept them separate since the values do not m
| |
| 57 // Maximum idle time allowed before we stop rendering the cursor | |
| 58 // on frame | |
| 59 MAX_IDLE_TIME = 2 | |
|
miu
2015/10/20 02:12:44
Please add units to naming of these two enums (i.e
Irfan
2015/10/21 23:01:07
Done.
| |
| 60 }; | |
| 61 | |
| 62 base::TimeDelta last_mouse_movement_timestamp_; | |
| 63 float last_mouse_position_x_; | |
|
miu
2015/10/20 02:12:44
The two floats and bool need initialization in the
xjz
2015/10/20 17:12:08
Are these two the mouse location? Why they are flo
Irfan
2015/10/21 23:01:07
Done.
Irfan
2015/10/21 23:01:08
those are the units in which MouseEVent tracks x a
| |
| 64 float last_mouse_position_y_; | |
| 65 bool cursor_displayed_; | |
| 66 DISALLOW_COPY_AND_ASSIGN(CursorRenderer); | |
| 67 }; | |
| 68 | |
| 69 } // namespace content | |
| 70 | |
| 71 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_H_ | |
| OLD | NEW |