blob: bf09c75a3b99cf1f2796edb170d4214d22109cec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_
#define UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_
#include "base/containers/mru_cache.h"
#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
namespace ui {
class DrmDevice;
class DrmWindow;
class HardwareDisplayController;
class ScanoutBufferGenerator;
struct OverlayCheck_Params;
class DrmOverlayValidator {
public:
DrmOverlayValidator(DrmWindow* window,
ScanoutBufferGenerator* buffer_generator);
~DrmOverlayValidator();
// Tests if configurations |params| are compatible with |window_| and finds
// which of these configurations can be promoted to Overlay composition
// without failing the page flip. It expects |params| to be sorted by z_order.
std::vector<OverlayCheck_Params> TestPageFlip(
const std::vector<OverlayCheck_Params>& params,
const OverlayPlaneList& last_used_planes);
// Checks if buffers bound to planes can be optimized (i.e. format, scaling)to
// reduce Display Read bandwidth. This should be called before an actual page
// flip. Expects |planes| to be sorted by Z order.
OverlayPlaneList PrepareBuffersForPageFlip(const OverlayPlaneList& planes);
// Clears internal cache of validated overlay configurations. This should be
// usually called when |window_| size has changed or moved controller.
void ClearCache();
private:
// Contains hints which can be used to reduce display read memory bandwidth,
// for a given OverlayPlane. These are useful in case of video to determine
// if converting the buffer storage format before composition could lead to
// any potential bandwidth savings. Other useful hint is to determine if
// scaling needs to be done before page flip or can be handled by plane.
struct OverlayHints {
OverlayHints(uint32_t optimal_format, bool handle_scaling);
~OverlayHints();
// Optimal buffer storage format supported by hardware for a given
// OverlayPlane. This hint can be ignored and still compositing an
// OverlayPlane should not fail page flip or cause any visual artifacts.
uint32_t optimal_format;
// Hints if buffer scaling needs to be done before page flip as plane cannot
// support it. Ignoring this hint may result in displaying buffer with wrong
// resolution.
bool handle_scaling;
};
using OverlayHintsList = std::vector<OverlayHints>;
// Check if we can optimize format for reducing Display controller read
// bandwidth for |plane_list| and cache the value.
void UpdateOverlayHintsCache(
const scoped_refptr<DrmDevice>& drm,
const OverlayPlaneList& plane_list,
std::vector<scoped_refptr<ScanoutBuffer>>* reusable_buffers);
DrmWindow* window_; // Not owned.
ScanoutBufferGenerator* buffer_generator_; // Not owned.
// List of all configurations which have been validated.
base::MRUCacheBase<OverlayPlaneList,
OverlayHintsList,
base::MRUCacheNullDeletor<OverlayHintsList>>
overlay_hints_cache_;
DISALLOW_COPY_AND_ASSIGN(DrmOverlayValidator);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_
|