| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROMECAST_MEDIA_VIDEO_PLANE_CONTROLLER_H_ | 5 #ifndef CHROMECAST_MEDIA_VIDEO_PLANE_CONTROLLER_H_ |
| 6 #define CHROMECAST_MEDIA_VIDEO_PLANE_CONTROLLER_H_ | 6 #define CHROMECAST_MEDIA_VIDEO_PLANE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // from the last call to this method, it is a no-op. | 51 // from the last call to this method, it is a no-op. |
| 52 void SetDeviceResolution(const Size& resolution); | 52 void SetDeviceResolution(const Size& resolution); |
| 53 | 53 |
| 54 // Sets graphics hardware plane resolution. This must be called at least once | 54 // Sets graphics hardware plane resolution. This must be called at least once |
| 55 // when the hardware graphics plane resolution (same resolution as | 55 // when the hardware graphics plane resolution (same resolution as |
| 56 // gfx::Screen) is known, then later when it changes. If there is no change to | 56 // gfx::Screen) is known, then later when it changes. If there is no change to |
| 57 // the graphics plane resolution from the last call to this method, it is a | 57 // the graphics plane resolution from the last call to this method, it is a |
| 58 // no-op. | 58 // no-op. |
| 59 void SetGraphicsPlaneResolution(const Size& resolution); | 59 void SetGraphicsPlaneResolution(const Size& resolution); |
| 60 | 60 |
| 61 // After Pause is called, no further calls to VideoPlane::SetGeometry will be |
| 62 // made except for any pending calls already scheduled on the media thread. |
| 63 // The Set methods will however updated cached parameters that will take |
| 64 // effect once the class is resumed. Safe to call multiple times. |
| 65 void Pause(); |
| 66 // Makes class active again. Safe to call multiple times. |
| 67 void Resume(); |
| 68 bool is_paused() const { return is_paused_; } |
| 69 |
| 70 // Clears any cached geometry parameters or state so that next call to |
| 71 // SetGeometry is guaranteed to trigger VideoPlane::SetGeometry (assuming |
| 72 // resolutions have been set and class is active). Can be called in paused |
| 73 // state. |
| 74 void ClearGeometryState(); |
| 75 |
| 61 private: | 76 private: |
| 62 class RateLimitedSetVideoPlaneGeometry; | 77 class RateLimitedSetVideoPlaneGeometry; |
| 63 friend struct base::DefaultSingletonTraits<VideoPlaneController>; | 78 friend struct base::DefaultSingletonTraits<VideoPlaneController>; |
| 64 | 79 |
| 65 VideoPlaneController(); | 80 VideoPlaneController(); |
| 66 ~VideoPlaneController(); | 81 ~VideoPlaneController(); |
| 67 | 82 |
| 68 // Check if HaveDataForSetGeometry. If not, this method is a no-op. Otherwise | 83 // Check if HaveDataForSetGeometry. If not, this method is a no-op. Otherwise |
| 69 // it scales the display rect from graphics to device resolution coordinates. | 84 // it scales the display rect from graphics to device resolution coordinates. |
| 70 // Then posts task to media thread for VideoPlane::SetGeometry. | 85 // Then posts task to media thread for VideoPlane::SetGeometry. |
| 71 void MaybeRunSetGeometry(); | 86 void MaybeRunSetGeometry(); |
| 72 // Checks if all data has been collected to make calls to | 87 // Checks if all data has been collected to make calls to |
| 73 // VideoPlane::SetGeometry. | 88 // VideoPlane::SetGeometry. |
| 74 bool HaveDataForSetGeometry() const; | 89 bool HaveDataForSetGeometry() const; |
| 75 | 90 |
| 91 bool is_paused_; |
| 92 |
| 76 // Current resolutions | 93 // Current resolutions |
| 77 bool have_output_res_; | 94 bool have_output_res_; |
| 78 bool have_graphics_res_; | 95 bool have_graphics_res_; |
| 79 Size output_res_; | 96 Size output_res_; |
| 80 Size graphics_res_; | 97 Size graphics_res_; |
| 81 | 98 |
| 82 // Saved video plane parameters (in graphics plane coordinates) | 99 // Saved video plane parameters (in graphics plane coordinates) |
| 83 // for use when screen resolution changes. | 100 // for use when screen resolution changes. |
| 84 bool have_video_plane_geometry_; | 101 bool have_video_plane_geometry_; |
| 85 RectF video_plane_display_rect_; | 102 RectF video_plane_display_rect_; |
| 86 VideoPlane::Transform video_plane_transform_; | 103 VideoPlane::Transform video_plane_transform_; |
| 87 | 104 |
| 88 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 105 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 89 scoped_refptr<RateLimitedSetVideoPlaneGeometry> video_plane_wrapper_; | 106 scoped_refptr<RateLimitedSetVideoPlaneGeometry> video_plane_wrapper_; |
| 90 | 107 |
| 91 base::ThreadChecker thread_checker_; | 108 base::ThreadChecker thread_checker_; |
| 92 | 109 |
| 93 DISALLOW_COPY_AND_ASSIGN(VideoPlaneController); | 110 DISALLOW_COPY_AND_ASSIGN(VideoPlaneController); |
| 94 }; | 111 }; |
| 95 | 112 |
| 96 } // namespace media | 113 } // namespace media |
| 97 } // namespace chromecast | 114 } // namespace chromecast |
| 98 | 115 |
| 99 #endif // CHROMECAST_MEDIA_VIDEO_PLANE_CONTROLLER_H_ | 116 #endif // CHROMECAST_MEDIA_VIDEO_PLANE_CONTROLLER_H_ |
| OLD | NEW |