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

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

Issue 1412173003: cast: support cursor rendering for tab capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing cursor renderer files in repo 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_aura.h
diff --git a/content/browser/media/capture/cursor_renderer_aura.h b/content/browser/media/capture/cursor_renderer_aura.h
new file mode 100644
index 0000000000000000000000000000000000000000..0f28804e499af53d66dcfec20bd527411e9dc486
--- /dev/null
+++ b/content/browser/media/capture/cursor_renderer_aura.h
@@ -0,0 +1,73 @@
+// 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_AURA_H_
+#define CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "content/browser/media/capture/cursor_renderer.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 {
+
+// Tracks state for making decisions on cursor display on a captured video
+// frame
+class CONTENT_EXPORT CursorRendererAura :
+ public CursorRenderer,
+ public ui::EventHandler,
+ public aura::WindowObserver {
+ public:
+ explicit CursorRendererAura(gfx::NativeWindow window);
+ ~CursorRendererAura() override;
miu 2015/10/23 01:55:12 For all these methods, try to use 'final' instead
Irfan 2015/10/26 23:10:31 Done.
+ void Clear() override;
miu 2015/10/23 01:55:12 style: These three methods should be headed by a c
Irfan 2015/10/26 23:10:31 Done.
+ bool Update(const gfx::Rect& region_in_frame) override;
+ void RenderOnVideoFrame(
+ const scoped_refptr<media::VideoFrame>& target) const override;
+
+ // Overridden from ui::EventHandler to make decision on when
miu 2015/10/23 01:55:12 style: No need to document overridden interface me
Irfan 2015/10/26 23:10:31 Done.
+ // cursor gets rendered on a captured video frame
+ void OnMouseEvent(ui::MouseEvent* event) override;
+
+ // Overridden from aura::WindowObserver to clean up before window is destroyed
+ void OnWindowDestroying(aura::Window* window) override;
+
+ base::WeakPtr<CursorRenderer> GetWeakPtr() override;
miu 2015/10/23 01:55:12 This should be next to the other three methods bei
Irfan 2015/10/26 23:10:31 Done.
+ private:
+ ui::Cursor last_cursor_;
miu 2015/10/23 01:55:12 Please add a comment for these four members. Like
Irfan 2015/10/26 23:10:31 Done.
+ gfx::Size window_size_when_cursor_last_updated_;
+ gfx::Point cursor_position_in_frame_;
+ SkBitmap scaled_cursor_bitmap_;
+ gfx::NativeView window_;
miu 2015/10/23 01:55:12 nit: |window_| should go first since it's injected
Irfan 2015/10/26 23:10:31 Done.
+
+ enum {
miu 2015/10/23 01:55:12 Consider moving these values to the CursorRenderer
Irfan 2015/10/26 23:10:31 Done.
+ // Minium movement before cursor is rendered on frame
miu 2015/10/23 01:55:12 style nit: In Chromium code, all comments must be
Irfan 2015/10/26 23:10:31 Done.
+ MIN_MOVEMENT_PIXELS = 15,
+ // Maximum idle time allowed before we stop rendering the cursor
+ // on frame
+ MAX_IDLE_TIME_SECONDS = 2
+ };
+
+ base::TimeDelta last_mouse_movement_timestamp_;
miu 2015/10/23 01:55:12 Short comment needed here too about when these are
Irfan 2015/10/26 23:10:31 Done.
+ float last_mouse_position_x_;
+ float last_mouse_position_y_;
+ bool cursor_displayed_;
+
+ base::WeakPtrFactory<CursorRendererAura> weak_factory_;
+ DISALLOW_COPY_AND_ASSIGN(CursorRendererAura);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_AURA_H_

Powered by Google App Engine
This is Rietveld 408576698