| 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/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // resolution coordinates | 25 // resolution coordinates |
| 26 // * updates VideoPlane when screen resolution changes | 26 // * updates VideoPlane when screen resolution changes |
| 27 // * handles threading correctly (posting SetGeometry to media thread). | 27 // * handles threading correctly (posting SetGeometry to media thread). |
| 28 // * coalesces multiple calls in short space of time to prevent flooding the | 28 // * coalesces multiple calls in short space of time to prevent flooding the |
| 29 // media thread with SetGeometry calls (which are expensive on many | 29 // media thread with SetGeometry calls (which are expensive on many |
| 30 // platforms). | 30 // platforms). |
| 31 // All public methods should be called from the same thread that the class was | 31 // All public methods should be called from the same thread that the class was |
| 32 // constructed on. | 32 // constructed on. |
| 33 class VideoPlaneController { | 33 class VideoPlaneController { |
| 34 public: | 34 public: |
| 35 explicit VideoPlaneController( | 35 VideoPlaneController( |
| 36 const Size& graphics_resolution, |
| 36 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner); | 37 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner); |
| 37 ~VideoPlaneController(); | 38 ~VideoPlaneController(); |
| 38 // Sets the video plane geometry in *graphics plane coordinates*. If there is | 39 // Sets the video plane geometry in *graphics plane coordinates*. If there is |
| 39 // no change to video plane parameters from the last call to this method, it | 40 // no change to video plane parameters from the last call to this method, it |
| 40 // is a no-op. | 41 // is a no-op. |
| 41 void SetGeometry(const RectF& display_rect, VideoPlane::Transform transform); | 42 void SetGeometry(const RectF& display_rect, VideoPlane::Transform transform); |
| 42 | 43 |
| 43 // Sets physical screen resolution. This must be called at least once when | 44 // Sets physical screen resolution. This must be called at least once when |
| 44 // the final output resolution (HDMI signal or panel resolution) is known, | 45 // the final output resolution (HDMI signal or panel resolution) is known, |
| 45 // then later when it changes. If there is no change to the screen resolution | 46 // then later when it changes. If there is no change to the screen resolution |
| 46 // from the last call to this method, it is a no-op. | 47 // from the last call to this method, it is a no-op. |
| 47 void SetScreenResolution(const Size& resolution); | 48 void SetScreenResolution(const Size& resolution); |
| 48 | 49 |
| 49 // Sets graphics hardware plane resolution, and clears any cached video plane | |
| 50 // geometry parameters. This must be called at least once when the hardware | |
| 51 // graphics plane resolution (same resolution as display::Screen) is known, | |
| 52 // then later when it changes. If there is no change to the graphics plane | |
| 53 // resolution from the last call to this method, it is a no-op. | |
| 54 void SetGraphicsPlaneResolution(const Size& resolution); | |
| 55 | |
| 56 // After Pause is called, no further calls to VideoPlane::SetGeometry will be | 50 // After Pause is called, no further calls to VideoPlane::SetGeometry will be |
| 57 // made except for any pending calls already scheduled on the media thread. | 51 // made except for any pending calls already scheduled on the media thread. |
| 58 // The Set methods will however update cached parameters that will take | 52 // The Set methods will however update cached parameters that will take |
| 59 // effect once the class is resumed. Safe to call multiple times. | 53 // effect once the class is resumed. Safe to call multiple times. |
| 60 // TODO(esum): Handle the case where there are pending calls already on the | 54 // TODO(esum): Handle the case where there are pending calls already on the |
| 61 // media thread. When this returns, the caller needs to know that absolutely | 55 // media thread. When this returns, the caller needs to know that absolutely |
| 62 // no more SetGeometry calls will be made. | 56 // no more SetGeometry calls will be made. |
| 63 void Pause(); | 57 void Pause(); |
| 64 // Makes class active again, and clears any cached video plane geometry | 58 // Makes class active again, and clears any cached video plane geometry |
| 65 // parameters. Safe to call multiple times. | 59 // parameters. Safe to call multiple times. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 77 // Checks if all data has been collected to make calls to | 71 // Checks if all data has been collected to make calls to |
| 78 // VideoPlane::SetGeometry. | 72 // VideoPlane::SetGeometry. |
| 79 bool HaveDataForSetGeometry() const; | 73 bool HaveDataForSetGeometry() const; |
| 80 // Clears any cached video plane geometry parameters. | 74 // Clears any cached video plane geometry parameters. |
| 81 void ClearVideoPlaneGeometry(); | 75 void ClearVideoPlaneGeometry(); |
| 82 | 76 |
| 83 bool is_paused_; | 77 bool is_paused_; |
| 84 | 78 |
| 85 // Current resolutions | 79 // Current resolutions |
| 86 bool have_screen_res_; | 80 bool have_screen_res_; |
| 87 bool have_graphics_plane_res_; | |
| 88 Size screen_res_; | 81 Size screen_res_; |
| 89 Size graphics_plane_res_; | 82 const Size graphics_plane_res_; |
| 90 | 83 |
| 91 // Saved video plane parameters (in graphics plane coordinates) | 84 // Saved video plane parameters (in graphics plane coordinates) |
| 92 // for use when screen resolution changes. | 85 // for use when screen resolution changes. |
| 93 bool have_video_plane_geometry_; | 86 bool have_video_plane_geometry_; |
| 94 RectF video_plane_display_rect_; | 87 RectF video_plane_display_rect_; |
| 95 VideoPlane::Transform video_plane_transform_; | 88 VideoPlane::Transform video_plane_transform_; |
| 96 | 89 |
| 97 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 90 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 98 scoped_refptr<RateLimitedSetVideoPlaneGeometry> video_plane_wrapper_; | 91 scoped_refptr<RateLimitedSetVideoPlaneGeometry> video_plane_wrapper_; |
| 99 | 92 |
| 100 base::ThreadChecker thread_checker_; | 93 base::ThreadChecker thread_checker_; |
| 101 | 94 |
| 102 DISALLOW_COPY_AND_ASSIGN(VideoPlaneController); | 95 DISALLOW_COPY_AND_ASSIGN(VideoPlaneController); |
| 103 }; | 96 }; |
| 104 | 97 |
| 105 } // namespace media | 98 } // namespace media |
| 106 } // namespace chromecast | 99 } // namespace chromecast |
| 107 | 100 |
| 108 #endif // CHROMECAST_MEDIA_VIDEO_PLANE_CONTROLLER_H_ | 101 #endif // CHROMECAST_MEDIA_VIDEO_PLANE_CONTROLLER_H_ |
| OLD | NEW |