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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/ozone/platform/drm/gpu/crtc_commit_request.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"
#include "ui/ozone/platform/drm/gpu/drm_gpu_util.h"
#include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h"
namespace ui {
CrtcCommitRequest::CrtcCommitRequest(uint32_t crtc_id,
uint32_t connector_id,
drmModeModeInfo mode,
gfx::Point origin,
HardwareDisplayPlaneList* plane_list,
DrmOverlayPlaneList overlays,
bool enable_vrr,
bool should_enable_crtc)
: should_enable_crtc_(should_enable_crtc),
crtc_id_(crtc_id),
connector_id_(connector_id),
mode_(mode),
origin_(origin),
plane_list_(plane_list),
overlays_(std::move(overlays)),
enable_vrr_(enable_vrr) {
// Verify that at least one overlay plane is a primary plane if we're enabling
// a CRTC.
DCHECK(!should_enable_crtc || DrmOverlayPlane::GetPrimaryPlane(overlays_));
}
CrtcCommitRequest::CrtcCommitRequest(uint32_t crtc_id,
uint32_t connector_id,
drmModeModeInfo mode,
gfx::Point origin,
HardwareDisplayPlaneList* plane_list,
bool enable_vrr,
bool should_enable_crtc)
: should_enable_crtc_(should_enable_crtc),
crtc_id_(crtc_id),
connector_id_(connector_id),
mode_(mode),
origin_(origin),
plane_list_(plane_list),
enable_vrr_(enable_vrr) {}
CrtcCommitRequest::~CrtcCommitRequest() = default;
CrtcCommitRequest::CrtcCommitRequest(const CrtcCommitRequest& other)
: should_enable_crtc_(other.should_enable_crtc_),
crtc_id_(other.crtc_id_),
connector_id_(other.connector_id_),
mode_(other.mode_),
origin_(other.origin_),
plane_list_(other.plane_list_),
overlays_(DrmOverlayPlane::Clone(other.overlays_)),
enable_vrr_(other.enable_vrr_) {}
void CrtcCommitRequest::WriteIntoTrace(perfetto::TracedValue context) const {
auto dict = std::move(context).WriteDictionary();
dict.Add("should_enable_crtc", should_enable_crtc_);
dict.Add("crtc_id", crtc_id_);
dict.Add("connector_id", connector_id_);
dict.Add("origin", origin_.ToString());
DrmWriteIntoTraceHelper(mode_, dict.AddItem("mode"));
dict.Add("hardware_display_plane_list", plane_list_.get());
dict.Add("overlays", overlays_);
dict.Add("enable_vrr", enable_vrr_);
}
// static
CrtcCommitRequest CrtcCommitRequest::EnableCrtcRequest(
uint32_t crtc_id,
uint32_t connector_id,
drmModeModeInfo mode,
gfx::Point origin,
HardwareDisplayPlaneList* plane_list,
DrmOverlayPlaneList overlays,
bool enable_vrr) {
DCHECK(plane_list && !overlays.empty());
return CrtcCommitRequest(crtc_id, connector_id, mode, origin, plane_list,
std::move(overlays), enable_vrr,
/*should_enable_crtc_=*/true);
}
// static
CrtcCommitRequest CrtcCommitRequest::DisableCrtcRequest(
uint32_t crtc_id,
uint32_t connector_id,
HardwareDisplayPlaneList* plane_list) {
return CrtcCommitRequest(crtc_id, connector_id, {}, gfx::Point(), plane_list,
DrmOverlayPlaneList(), /*enable_vrr=*/false,
/*should_enable_crtc_=*/false);
}
// static
CrtcCommitRequest CrtcCommitRequest::DetachPlanesRequest(
uint32_t crtc_id,
uint32_t connector_id,
drmModeModeInfo mode,
gfx::Point origin,
HardwareDisplayPlaneList* plane_list,
bool enable_vrr) {
return CrtcCommitRequest(crtc_id, connector_id, mode, origin, plane_list,
enable_vrr,
/*should_enable_crtc_=*/true);
}
} // namespace ui
|