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

Unified Diff: content/browser/media/capture/cursor_renderer.h

Issue 1412173003: cast: support cursor rendering for tab capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed left over logs Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..c18be93763a99921e6c6071a80210da5824a2fef
--- /dev/null
+++ b/content/browser/media/capture/cursor_renderer.h
@@ -0,0 +1,71 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_H_
+#define CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "content/common/content_export.h"
+#include "media/base/video_frame.h"
+#include "skia/ext/image_operations.h"
+#include "ui/aura/window.h"
+#include "ui/base/cursor/cursor.h"
+#include "ui/events/event_handler.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace content {
+
+enum {
+ 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
+};
+
+// Tracks state for making decisions on cursor display on a captured video
+// frame
+class CONTENT_EXPORT CursorRenderer : public ui::EventHandler {
+ public:
+ 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.
+ 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.
+ ~CursorRenderer() override;
+ void Clear();
+ bool Update(const gfx::Rect& region_in_frame);
+ void RenderOnVideoFrame(const scoped_refptr<media::VideoFrame>& target) const;
+ // Overridden from ui::EventHandler to make decision on when
+ // cursor gets rendered on a captured video frame
+ void OnMouseEvent(ui::MouseEvent* event) override;
+
+ private:
+ ui::Cursor last_cursor_;
+ gfx::Size window_size_when_cursor_last_updated_;
+ gfx::Point cursor_position_in_frame_;
+ SkBitmap scaled_cursor_bitmap_;
+ aura::Window* window_;
+
+ // This flag enables mouse event tracking for the purpose of disabling
+ // cursor rendering when there is no movement
+ const bool enable_mouse_events_;
miu 2015/10/20 02:12:44 ditto here: No need for a bool since |window_| wil
+
+ enum {
+ // Minium movement before cursor is rendered on frame
+ MIN_MOVEMENT = 15
+ };
+ 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
+ // Maximum idle time allowed before we stop rendering the cursor
+ // on frame
+ 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.
+ };
+
+ base::TimeDelta last_mouse_movement_timestamp_;
+ 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
+ float last_mouse_position_y_;
+ bool cursor_displayed_;
+ DISALLOW_COPY_AND_ASSIGN(CursorRenderer);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_H_

Powered by Google App Engine
This is Rietveld 408576698