drm_hwcomposer: Extract DrmHwc abstract base class
DrmHwc holds implementation details that can be shared between hwc2 and
hwc3. It exposes abstract functions for implementing callbacks to hwc
clients.
Leave the HWC2 specific implementation details in the DrmHwcTwo class, such
as the client callback implementation, and implement the DrmHwc abstract
functions in terms of hwc2.
DrmHwc is based on the DrmHwcInterface extracted in
(drm_hwcomposer: Connect ComposerClient with HwcDisplay) from !238
Co-authored-by: Dennis Tsiang <dennis.tsiang@arm.com>
Co-authored-by: Normunds Rieksts <normunds.rieksts@arm.com>
Signed-off-by: Drew Davenport <ddavenport@chromium.org>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index 89a8c3f..dad568c 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -19,10 +19,10 @@
#include "HwcDisplay.h"
-#include "DrmHwcTwo.h"
#include "backend/Backend.h"
#include "backend/BackendManager.h"
#include "bufferinfo/BufferInfoGetter.h"
+#include "drm/DrmHwc.h"
#include "utils/log.h"
#include "utils/properties.h"
@@ -66,8 +66,8 @@
}
HwcDisplay::HwcDisplay(hwc2_display_t handle, HWC2::DisplayType type,
- DrmHwcTwo *hwc2)
- : hwc2_(hwc2), handle_(handle), type_(type), client_layer_(this) {
+ DrmHwc *hwc)
+ : hwc_(hwc), handle_(handle), type_(type), client_layer_(this) {
if (type_ == HWC2::DisplayType::Virtual) {
writeback_layer_ = std::make_unique<HwcLayer>(this);
}
@@ -94,9 +94,9 @@
if (pipeline_ != nullptr || handle_ == kPrimaryDisplay) {
Init();
- hwc2_->ScheduleHotplugEvent(handle_, /*connected = */ true);
+ hwc_->ScheduleHotplugEvent(handle_, /*connected = */ true);
} else {
- hwc2_->ScheduleHotplugEvent(handle_, /*connected = */ false);
+ hwc_->ScheduleHotplugEvent(handle_, /*connected = */ false);
}
}
@@ -144,11 +144,11 @@
auto vsw_callbacks = (VSyncWorkerCallbacks){
.out_event =
[this](int64_t timestamp) {
- const std::unique_lock lock(hwc2_->GetResMan().GetMainLock());
+ const std::unique_lock lock(hwc_->GetResMan().GetMainLock());
if (vsync_event_en_) {
uint32_t period_ns{};
GetDisplayVsyncPeriod(&period_ns);
- hwc2_->SendVsyncEventToClient(handle_, timestamp, period_ns);
+ hwc_->SendVsyncEventToClient(handle_, timestamp, period_ns);
}
if (vsync_tracking_en_) {
last_vsync_ts_ = timestamp;
@@ -178,12 +178,8 @@
ALOGE("Failed to set backend for d=%d %d\n", int(handle_), ret);
return HWC2::Error::BadDisplay;
}
- auto flatcbk = (struct FlatConCallbacks){.trigger = [this]() {
- if (hwc2_->refresh_callback_.first != nullptr &&
- hwc2_->refresh_callback_.second != nullptr)
- hwc2_->refresh_callback_.first(hwc2_->refresh_callback_.second,
- handle_);
- }};
+ auto flatcbk = (struct FlatConCallbacks){
+ .trigger = [this]() { hwc_->SendRefreshEventToClient(handle_); }};
flatcon_ = FlatteningController::CreateInstance(flatcbk);
}
@@ -564,9 +560,9 @@
staged_mode_.reset();
vsync_tracking_en_ = false;
if (last_vsync_ts_ != 0) {
- hwc2_->SendVsyncPeriodTimingChangedEventToClient(handle_,
- last_vsync_ts_ +
- prev_vperiod_ns);
+ hwc_->SendVsyncPeriodTimingChangedEventToClient(handle_,
+ last_vsync_ts_ +
+ prev_vperiod_ns);
}
}
@@ -731,7 +727,7 @@
if (GetPipe().crtc->Get()->GetCtmProperty())
return false;
- if (GetHwc2()->GetResMan().GetCtmHandling() == CtmHandling::kDrmOrIgnore)
+ if (GetHwc()->GetResMan().GetCtmHandling() == CtmHandling::kDrmOrIgnore)
return false;
return true;
@@ -963,7 +959,7 @@
bool skip_ctm = false;
// Skip client CTM if user requested DRM_OR_IGNORE
- if (GetHwc2()->GetResMan().GetCtmHandling() == CtmHandling::kDrmOrIgnore)
+ if (GetHwc()->GetResMan().GetCtmHandling() == CtmHandling::kDrmOrIgnore)
skip_ctm = true;
// Skip client CTM if DRM can handle it