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

Unified Diff: media/capture/video/chromeos/display_rotation_observer.h

Issue 2837273004: media: add video capture device for ARC++ camera HAL v3 (Closed)
Patch Set: RELAND: media: add video capture device for ARC++ camera HAL v3 Created 3 years, 6 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: media/capture/video/chromeos/display_rotation_observer.h
diff --git a/media/capture/video/chromeos/display_rotation_observer.h b/media/capture/video/chromeos/display_rotation_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..4cdb873969d114cd582591ac2f3c5ba5b8da0044
--- /dev/null
+++ b/media/capture/video/chromeos/display_rotation_observer.h
@@ -0,0 +1,64 @@
+// Copyright 2017 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 MEDIA_CAPTURE_VIDEO_CHROMEOS_DISPLAY_ROTATION_OBSERVER_H_
+#define MEDIA_CAPTURE_VIDEO_CHROMEOS_DISPLAY_ROTATION_OBSERVER_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/single_thread_task_runner.h"
+#include "ui/display/display.h"
+#include "ui/display/display_observer.h"
+#include "ui/display/screen.h"
+
+namespace media {
+
+class DisplayRotationObserver {
+ public:
+ virtual void SetDisplayRotation(const display::Display& display) = 0;
+};
+
+// Registers itself as an observer at |display::Screen::GetScreen()| and
+// forwards rotation change events to the given DisplayRotationObserver on the
+// thread where ScreenObserverDelegate was created.
+class ScreenObserverDelegate
+ : public display::DisplayObserver,
+ public base::RefCountedThreadSafe<ScreenObserverDelegate> {
+ public:
+ ScreenObserverDelegate(
+ DisplayRotationObserver* observer,
+ scoped_refptr<base::SingleThreadTaskRunner> display_task_runner);
+
+ // The user must call RemoveObserver() to drop the reference to |observer_| in
+ // ScreenObserverDelegate before deleting |observer_|.
+ void RemoveObserver();
+
+ private:
+ friend class base::RefCountedThreadSafe<ScreenObserverDelegate>;
+
+ ~ScreenObserverDelegate() override;
+
+ // DisplayObserver implementations.
+ void OnDisplayAdded(const display::Display& /*new_display*/) override;
+ void OnDisplayRemoved(const display::Display& /*old_display*/) override;
+ void OnDisplayMetricsChanged(const display::Display& display,
+ uint32_t metrics) override;
+
+ void AddObserverOnDisplayThread();
+ void RemoveObserverOnDisplayThread();
+
+ // Post the screen rotation change from the display thread to capture thread
+ void SendDisplayRotation(const display::Display& display);
+ void SendDisplayRotationOnCaptureThread(const display::Display& display);
+
+ DisplayRotationObserver* observer_;
+ // The task runner where the calls to display::Display must be serialized on.
+ const scoped_refptr<base::SingleThreadTaskRunner> display_task_runner_;
+ // The task runner on which the ScreenObserverDelegate is created.
+ const scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_;
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ScreenObserverDelegate);
+};
+
+} // namespace media
+
+#endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_DISPLAY_ROTATION_OBSERVER_H_
« no previous file with comments | « media/capture/video/chromeos/camera_metadata_utils.cc ('k') | media/capture/video/chromeos/display_rotation_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698