OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "media/video/capture/linux/video_capture_device_chromeos.h" | 5 #include "media/video/capture/linux/video_capture_device_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "ui/gfx/display.h" | 10 #include "ui/gfx/display.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 base::Bind(&ScreenObserverDelegate::RemoveObserverOnUIThread, this)); | 38 base::Bind(&ScreenObserverDelegate::RemoveObserverOnUIThread, this)); |
39 } | 39 } |
40 | 40 |
41 private: | 41 private: |
42 friend class base::RefCountedThreadSafe<ScreenObserverDelegate>; | 42 friend class base::RefCountedThreadSafe<ScreenObserverDelegate>; |
43 | 43 |
44 virtual ~ScreenObserverDelegate() { | 44 virtual ~ScreenObserverDelegate() { |
45 DCHECK(!capture_device_); | 45 DCHECK(!capture_device_); |
46 } | 46 } |
47 | 47 |
| 48 // gfx::DisplayObserver: |
| 49 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { |
| 50 SendDisplayRotation(display); |
| 51 } |
| 52 |
48 virtual void OnDisplayAdded(const gfx::Display& /*new_display*/) OVERRIDE {} | 53 virtual void OnDisplayAdded(const gfx::Display& /*new_display*/) OVERRIDE {} |
49 virtual void OnDisplayRemoved(const gfx::Display& /*old_display*/) OVERRIDE {} | 54 virtual void OnDisplayRemoved(const gfx::Display& /*old_display*/) OVERRIDE {} |
50 virtual void OnDisplayMetricsChanged(const gfx::Display& display, | |
51 uint32_t metrics) OVERRIDE { | |
52 if (!(metrics & DISPLAY_METRIC_ROTATION)) | |
53 return; | |
54 SendDisplayRotation(display); | |
55 } | |
56 | 55 |
57 void AddObserverOnUIThread() { | 56 void AddObserverOnUIThread() { |
58 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 57 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
59 gfx::Screen* screen = | 58 gfx::Screen* screen = |
60 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); | 59 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
61 if (screen) { | 60 if (screen) { |
62 screen->AddObserver(this); | 61 screen->AddObserver(this); |
63 SendDisplayRotation(screen->GetPrimaryDisplay()); | 62 SendDisplayRotation(screen->GetPrimaryDisplay()); |
64 } | 63 } |
65 } | 64 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 screen_observer_delegate_->RemoveObserver(); | 103 screen_observer_delegate_->RemoveObserver(); |
105 } | 104 } |
106 | 105 |
107 void VideoCaptureDeviceChromeOS::SetDisplayRotation( | 106 void VideoCaptureDeviceChromeOS::SetDisplayRotation( |
108 const gfx::Display& display) { | 107 const gfx::Display& display) { |
109 if (display.IsInternal()) | 108 if (display.IsInternal()) |
110 SetRotation(display.rotation() * 90); | 109 SetRotation(display.rotation() * 90); |
111 } | 110 } |
112 | 111 |
113 } // namespace media | 112 } // namespace media |
OLD | NEW |