| 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 |
| 11 namespace ui { | 11 namespace ui { |
| 12 | 12 |
| 13 class DrmDevice; | 13 class DrmDevice; |
| 14 class DrmWindow; | 14 class DrmWindow; |
| 15 class HardwareDisplayController; | 15 class HardwareDisplayController; |
| 16 class ScanoutBufferGenerator; | 16 class ScanoutBufferGenerator; |
| 17 struct OverlayCheck_Params; | 17 struct OverlayCheck_Params; |
| 18 | 18 |
| 19 class DrmOverlayValidator { | 19 class DrmOverlayValidator { |
| 20 public: | 20 public: |
| 21 explicit DrmOverlayValidator(DrmWindow* window); | 21 explicit DrmOverlayValidator(DrmWindow* window, |
| 22 ScanoutBufferGenerator* buffer_generator); |
| 22 ~DrmOverlayValidator(); | 23 ~DrmOverlayValidator(); |
| 23 | 24 |
| 24 // Tests if configurations |params| are compatible with |window_| and finds | 25 // Tests if configurations |params| are compatible with |window_| and finds |
| 25 // which of these configurations can be promoted to Overlay composition | 26 // 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. | 27 // without failing the page flip. It expects |params| to be sorted by z_order. |
| 27 std::vector<OverlayCheck_Params> TestPageFlip( | 28 std::vector<OverlayCheck_Params> TestPageFlip( |
| 28 const std::vector<OverlayCheck_Params>& params, | 29 const std::vector<OverlayCheck_Params>& params, |
| 29 const OverlayPlaneList& last_used_planes, | 30 const OverlayPlaneList& last_used_planes); |
| 30 ScanoutBufferGenerator* buffer_generator); | |
| 31 | 31 |
| 32 // Tries to predict preferred format supported by hardware planes for |plane| | 32 // Checks if buffers bound to planes can be optimized (i.e. format, scaling)to |
| 33 // for the given combination of |plane_list|. Using this format can help | 33 // reduce Display Read bandwidth. This should be called before an actual page |
| 34 // reduce read memory bandwidth during scanout for this plane. | 34 // flip. Expects |planes| to be sorted by Z order. |
| 35 uint32_t GetOptimalBufferFormat(const OverlayPlane& plane, | 35 OverlayPlaneList PrepareBuffersForPageFlip(const OverlayPlaneList& planes); |
| 36 const OverlayPlaneList& plane_list) const; | |
| 37 | 36 |
| 38 // Clears internal cache of validated overlay configurations. This should be | 37 // Clears internal cache of validated overlay configurations. This should be |
| 39 // usually called when |window_| size has changed or moved controller. | 38 // usually called when |window_| size has changed or moved controller. |
| 40 void ClearCache(); | 39 void ClearCache(); |
| 41 | 40 |
| 42 private: | 41 private: |
| 43 // Contains hints which can be used to reduce display read memory bandwidth, | 42 // 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 | 43 // 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 | 44 // if converting the buffer storage format before composition could lead to |
| 46 // any potential bandwidth savings. Other useful hint is to determine if | 45 // any potential bandwidth savings. Other useful hint is to determine if |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 bool handle_scaling; | 57 bool handle_scaling; |
| 59 }; | 58 }; |
| 60 | 59 |
| 61 using OverlayHintsList = std::vector<OverlayHints>; | 60 using OverlayHintsList = std::vector<OverlayHints>; |
| 62 | 61 |
| 63 // Check if we can optimize format for reducing Display controller read | 62 // Check if we can optimize format for reducing Display controller read |
| 64 // bandwidth for |plane_list| and cache the value. | 63 // bandwidth for |plane_list| and cache the value. |
| 65 void UpdateOverlayHintsCache( | 64 void UpdateOverlayHintsCache( |
| 66 const scoped_refptr<DrmDevice>& drm, | 65 const scoped_refptr<DrmDevice>& drm, |
| 67 const OverlayPlaneList& plane_list, | 66 const OverlayPlaneList& plane_list, |
| 68 ScanoutBufferGenerator* buffer_generator, | |
| 69 std::vector<scoped_refptr<ScanoutBuffer>>* reusable_buffers); | 67 std::vector<scoped_refptr<ScanoutBuffer>>* reusable_buffers); |
| 70 | 68 |
| 71 DrmWindow* window_; // Not owned. | 69 DrmWindow* window_; // Not owned. |
| 70 ScanoutBufferGenerator* buffer_generator_; // Not owned. |
| 72 | 71 |
| 73 // List of all configurations which have been validated. | 72 // List of all configurations which have been validated. |
| 74 base::MRUCacheBase<OverlayPlaneList, | 73 base::MRUCacheBase<OverlayPlaneList, |
| 75 OverlayHintsList, | 74 OverlayHintsList, |
| 76 base::MRUCacheNullDeletor<OverlayHintsList>> | 75 base::MRUCacheNullDeletor<OverlayHintsList>> |
| 77 overlay_hints_cache_; | 76 overlay_hints_cache_; |
| 78 | 77 |
| 79 DISALLOW_COPY_AND_ASSIGN(DrmOverlayValidator); | 78 DISALLOW_COPY_AND_ASSIGN(DrmOverlayValidator); |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 } // namespace ui | 81 } // namespace ui |
| 83 | 82 |
| 84 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_ | 83 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_ |
| OLD | NEW |