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

Side by Side Diff: chromecast/media/base/video_plane_controller.h

Issue 1838863004: [Chromecast] Clear cached video plane geometry parameters and don't run (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | chromecast/media/base/video_plane_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
12 #include "chromecast/public/graphics_types.h" 12 #include "chromecast/public/graphics_types.h"
13 #include "chromecast/public/video_plane.h" 13 #include "chromecast/public/video_plane.h"
14 14
15 namespace base { 15 namespace base {
16 class SingleThreadTaskRunner; 16 class SingleThreadTaskRunner;
17 } 17 }
18 18
19 namespace chromecast { 19 namespace chromecast {
20 namespace media { 20 namespace media {
21 21
22 // Provides main interface for setting video plane geometry. All callsites 22 // Provides main interface for setting video plane geometry. All callsites
23 // should use this over VideoPlane::SetGeometry. Reasons for this: 23 // should use this over VideoPlane::SetGeometry. Reasons for this:
24 // * provides conversion between graphics plane coordinates and screen 24 // * provides conversion between graphics plane coordinates and screen
25 // resolution coordinates 25 // resolution coordinates
26 // * updates VideoPlane when graphics plane or 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 // The class collects/caches the data it needs before it can start operating. 31 // All public methods should be called from the same thread that the class was
32 // This means SetGeometry, SetDeviceResolution, and SetGraphicsPlaneResolution 32 // constructed on.
33 // need to be called at least once in any order before the class starts making
34 // calls to VideoPlane::SetGeometry. All calls to these methods beforehand just
35 // set/update the cached parameters.
36 // All calls to public methods should be from the same thread.
37 class VideoPlaneController { 33 class VideoPlaneController {
38 public: 34 public:
39 explicit VideoPlaneController( 35 explicit VideoPlaneController(
40 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner); 36 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner);
41 ~VideoPlaneController(); 37 ~VideoPlaneController();
42 // Sets the video plane geometry (forwards to VideoPlane::SetGeometry) 38 // Sets the video plane geometry in *graphics plane coordinates*. If there is
43 // in *graphics plane coordinates*. 39 // no change to video plane parameters from the last call to this method, it
44 // * This should be called on UI thread (hopping to media thread is handled 40 // is a no-op.
45 // internally).
46 // If there is no change to video plane parameters from the last call to this
47 // method, it is a no-op.
48 void SetGeometry(const RectF& display_rect, VideoPlane::Transform transform); 41 void SetGeometry(const RectF& display_rect, VideoPlane::Transform transform);
49 42
50 // Sets physical screen resolution. This must be called at least once when 43 // Sets physical screen resolution. This must be called at least once when
51 // the final output resolution (HDMI signal or panel resolution) is known, 44 // the final output resolution (HDMI signal or panel resolution) is known,
52 // then later when it changes. If there is no change to the device resolution 45 // then later when it changes. If there is no change to the screen resolution
53 // from the last call to this method, it is a no-op. 46 // from the last call to this method, it is a no-op.
54 void SetDeviceResolution(const Size& resolution); 47 void SetScreenResolution(const Size& resolution);
55 48
56 // Sets graphics hardware plane resolution. This must be called at least once 49 // Sets graphics hardware plane resolution, and clears any cached video plane
57 // when the hardware graphics plane resolution (same resolution as 50 // geometry parameters. This must be called at least once when the hardware
58 // gfx::Screen) is known, then later when it changes. If there is no change to 51 // graphics plane resolution (same resolution as gfx::Screen) is known, then
59 // the graphics plane resolution from the last call to this method, it is a 52 // later when it changes. If there is no change to the graphics plane
60 // no-op. 53 // resolution from the last call to this method, it is a no-op.
61 void SetGraphicsPlaneResolution(const Size& resolution); 54 void SetGraphicsPlaneResolution(const Size& resolution);
62 55
63 // After Pause is called, no further calls to VideoPlane::SetGeometry will be 56 // After Pause is called, no further calls to VideoPlane::SetGeometry will be
64 // made except for any pending calls already scheduled on the media thread. 57 // made except for any pending calls already scheduled on the media thread.
65 // The Set methods will however update cached parameters that will take 58 // The Set methods will however update cached parameters that will take
66 // effect once the class is resumed. Safe to call multiple times. 59 // effect once the class is resumed. Safe to call multiple times.
67 // TODO(esum): Handle the case where there are pending calls already on the 60 // TODO(esum): Handle the case where there are pending calls already on the
68 // media thread. When this returns, the caller needs to know that absolutely 61 // media thread. When this returns, the caller needs to know that absolutely
69 // no more SetGeometry calls will be made. 62 // no more SetGeometry calls will be made.
70 void Pause(); 63 void Pause();
71 // Makes class active again. Also resets the video plane by posting a call to 64 // Makes class active again, and clears any cached video plane geometry
72 // VideoPlane::SetGeometry with most recent resolution and geometry parameters 65 // parameters. Safe to call multiple times.
73 // (assuming they are all set). Safe to call multiple times.
74 void Resume(); 66 void Resume();
75 bool is_paused() const; 67 bool is_paused() const;
76 68
77 private: 69 private:
78 class RateLimitedSetVideoPlaneGeometry; 70 class RateLimitedSetVideoPlaneGeometry;
79 friend struct base::DefaultSingletonTraits<VideoPlaneController>; 71 friend struct base::DefaultSingletonTraits<VideoPlaneController>;
80 72
81 // Check if HaveDataForSetGeometry. If not, this method is a no-op. Otherwise 73 // Check if HaveDataForSetGeometry. If not, this method is a no-op. Otherwise
82 // it scales the display rect from graphics to device resolution coordinates. 74 // it scales the display rect from graphics to device resolution coordinates.
83 // Then posts task to media thread for VideoPlane::SetGeometry. 75 // Then posts task to media thread for VideoPlane::SetGeometry.
84 void MaybeRunSetGeometry(); 76 void MaybeRunSetGeometry();
85 // Checks if all data has been collected to make calls to 77 // Checks if all data has been collected to make calls to
86 // VideoPlane::SetGeometry. 78 // VideoPlane::SetGeometry.
87 bool HaveDataForSetGeometry() const; 79 bool HaveDataForSetGeometry() const;
80 // Clears any cached video plane geometry parameters.
81 void ClearVideoPlaneGeometry();
88 82
89 bool is_paused_; 83 bool is_paused_;
90 84
91 // Current resolutions 85 // Current resolutions
92 bool have_output_res_; 86 bool have_screen_res_;
93 bool have_graphics_res_; 87 bool have_graphics_plane_res_;
94 Size output_res_; 88 Size screen_res_;
95 Size graphics_res_; 89 Size graphics_plane_res_;
96 90
97 // Saved video plane parameters (in graphics plane coordinates) 91 // Saved video plane parameters (in graphics plane coordinates)
98 // for use when screen resolution changes. 92 // for use when screen resolution changes.
99 bool have_video_plane_geometry_; 93 bool have_video_plane_geometry_;
100 RectF video_plane_display_rect_; 94 RectF video_plane_display_rect_;
101 VideoPlane::Transform video_plane_transform_; 95 VideoPlane::Transform video_plane_transform_;
102 96
103 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; 97 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
104 scoped_refptr<RateLimitedSetVideoPlaneGeometry> video_plane_wrapper_; 98 scoped_refptr<RateLimitedSetVideoPlaneGeometry> video_plane_wrapper_;
105 99
106 base::ThreadChecker thread_checker_; 100 base::ThreadChecker thread_checker_;
107 101
108 DISALLOW_COPY_AND_ASSIGN(VideoPlaneController); 102 DISALLOW_COPY_AND_ASSIGN(VideoPlaneController);
109 }; 103 };
110 104
111 } // namespace media 105 } // namespace media
112 } // namespace chromecast 106 } // namespace chromecast
113 107
114 #endif // CHROMECAST_MEDIA_VIDEO_PLANE_CONTROLLER_H_ 108 #endif // CHROMECAST_MEDIA_VIDEO_PLANE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | chromecast/media/base/video_plane_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698