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 UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_ |
6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_ | 6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_ |
7 | 7 |
8 #include "base/containers/mru_cache.h" | 8 #include "base/containers/mru_cache.h" |
9 #include "ui/ozone/platform/drm/gpu/overlay_plane.h" | 9 #include "ui/ozone/platform/drm/gpu/overlay_plane.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... | |
22 ~DrmOverlayValidator(); | 22 ~DrmOverlayValidator(); |
23 | 23 |
24 // Tests if configurations |params| are compatible with |window_| and finds | 24 // Tests if configurations |params| are compatible with |window_| and finds |
25 // which of these configurations can be promoted to Overlay composition | 25 // which of these configurations can be promoted to Overlay composition |
26 // without failing the page flip. It expects |params| to be sorted by z_order. | 26 // without failing the page flip. It expects |params| to be sorted by z_order. |
27 std::vector<OverlayCheck_Params> TestPageFlip( | 27 std::vector<OverlayCheck_Params> TestPageFlip( |
28 const std::vector<OverlayCheck_Params>& params, | 28 const std::vector<OverlayCheck_Params>& params, |
29 const OverlayPlaneList& last_used_planes, | 29 const OverlayPlaneList& last_used_planes, |
30 ScanoutBufferGenerator* buffer_generator); | 30 ScanoutBufferGenerator* buffer_generator); |
31 | 31 |
32 // Tries to predict preferred format supported by hardware planes for |plane| | 32 OverlayPlaneList ValidatePlanesForPageFlip( |
dnicoara
2016/01/13 17:26:51
Could you please add some comments describing this
kalyank
2016/01/13 19:52:33
Done.
| |
33 // for the given combination of |plane_list|. Using this format can help | 33 const OverlayPlaneList& planes, |
34 // reduce read memory bandwidth during scanout for this plane. | 34 ScanoutBufferGenerator* buffer_generator); |
dnicoara
2016/01/13 17:26:51
Maybe we should pass in the buffer generator in th
kalyank
2016/01/13 19:52:33
Done.
| |
35 uint32_t GetOptimalBufferFormat(const OverlayPlane& plane, | |
36 const OverlayPlaneList& plane_list) const; | |
37 | 35 |
38 // Clears internal cache of validated overlay configurations. This should be | 36 // Clears internal cache of validated overlay configurations. This should be |
39 // usually called when |window_| size has changed or moved controller. | 37 // usually called when |window_| size has changed or moved controller. |
40 void ClearCache(); | 38 void ClearCache(); |
41 | 39 |
42 private: | 40 private: |
43 // Contains hints which can be used to reduce display read memory bandwidth, | 41 // Contains hints which can be used to reduce display read memory bandwidth, |
44 // for a given OverlayPlane. These are useful in case of video to determine | 42 // for a given OverlayPlane. These are useful in case of video to determine |
45 // if converting the buffer storage format before composition could lead to | 43 // if converting the buffer storage format before composition could lead to |
46 // any potential bandwidth savings. Other useful hint is to determine if | 44 // any potential bandwidth savings. Other useful hint is to determine if |
47 // scaling needs to be done before page flip or can be handled by plane. | 45 // scaling needs to be done before page flip or can be handled by plane. |
48 struct OverlayHints { | 46 struct OverlayHints { |
49 OverlayHints(uint32_t optimal_format, bool handle_scaling); | 47 OverlayHints(uint32_t optimal_format, bool handle_scaling); |
50 ~OverlayHints(); | 48 ~OverlayHints(); |
51 // Optimal buffer storage format supported by hardware for a given | 49 // Optimal buffer storage format supported by hardware for a given |
52 // OverlayPlane. This hint can be ignored and still compositing an | 50 // OverlayPlane. This hint can be ignored and still compositing an |
53 // OverlayPlane should not fail page flip or cause any visual artifacts. | 51 // OverlayPlane should not fail page flip or cause any visual artifacts. |
54 uint32_t optimal_format; | 52 uint32_t optimal_format; |
55 // Hints if buffer scaling needs to be done before page flip as plane cannot | 53 // Hints if buffer scaling needs to be done before page flip as plane cannot |
56 // support it. Ignoring this hint may result in displaying buffer with wrong | 54 // support it. Ignoring this hint may result in displaying buffer with wrong |
57 // resolution. | 55 // resolution. |
58 bool handle_scaling; | 56 bool handle_scaling; |
59 }; | 57 }; |
60 | 58 |
59 // Expectation is that we have same combination of layers being used over | |
dnicoara
2016/01/13 17:26:51
Do you have an idea of what the overhead would be?
kalyank
2016/01/13 19:52:33
We would end up allocating new buffers every frame
dnicoara
2016/01/13 20:21:53
I think we can just drop this. The more I read it
kalyank
2016/01/14 06:24:05
Done.
| |
60 // a period of time. If this combination needs to process buffers in | |
61 // ValidatePlanesForPageFlip, it would be beneficial to hold on to these | |
62 // buffers so that they can be recycled instead of re-creating them for every | |
63 // frame. | |
64 struct OverlayBuffer { | |
65 OverlayBuffer(const scoped_refptr<ScanoutBuffer>& buffer, bool is_in_use); | |
66 ~OverlayBuffer(); | |
67 | |
68 scoped_refptr<ScanoutBuffer> buffer; | |
69 bool is_in_use; | |
70 }; | |
71 | |
61 using OverlayHintsList = std::vector<OverlayHints>; | 72 using OverlayHintsList = std::vector<OverlayHints>; |
62 | 73 |
63 // Check if we can optimize format for reducing Display controller read | 74 // Check if we can optimize format for reducing Display controller read |
64 // bandwidth for |plane_list| and cache the value. | 75 // bandwidth for |plane_list| and cache the value. |
65 void UpdateOverlayHintsCache( | 76 void UpdateOverlayHintsCache( |
66 const scoped_refptr<DrmDevice>& drm, | 77 const scoped_refptr<DrmDevice>& drm, |
67 const OverlayPlaneList& plane_list, | 78 const OverlayPlaneList& plane_list, |
68 ScanoutBufferGenerator* buffer_generator, | 79 ScanoutBufferGenerator* buffer_generator, |
69 std::vector<scoped_refptr<ScanoutBuffer>>* reusable_buffers); | 80 std::vector<scoped_refptr<ScanoutBuffer>>* reusable_buffers); |
70 | 81 |
82 scoped_refptr<ScanoutBuffer> GetBufferForPageFlip( | |
83 const scoped_refptr<DrmDevice>& drm_device, | |
84 ScanoutBufferGenerator* buffer_generator, | |
85 const gfx::Size& size, | |
86 uint32_t format); | |
87 | |
71 DrmWindow* window_; // Not owned. | 88 DrmWindow* window_; // Not owned. |
72 | 89 |
90 std::vector<OverlayBuffer> overlay_buffers_cache_; | |
91 | |
73 // List of all configurations which have been validated. | 92 // List of all configurations which have been validated. |
74 base::MRUCacheBase<OverlayPlaneList, | 93 base::MRUCacheBase<OverlayPlaneList, |
75 OverlayHintsList, | 94 OverlayHintsList, |
76 base::MRUCacheNullDeletor<OverlayHintsList>> | 95 base::MRUCacheNullDeletor<OverlayHintsList>> |
77 overlay_hints_cache_; | 96 overlay_hints_cache_; |
78 | 97 |
79 DISALLOW_COPY_AND_ASSIGN(DrmOverlayValidator); | 98 DISALLOW_COPY_AND_ASSIGN(DrmOverlayValidator); |
80 }; | 99 }; |
81 | 100 |
82 } // namespace ui | 101 } // namespace ui |
83 | 102 |
84 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_ | 103 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_ |
OLD | NEW |