1
0
Fork 0

drm_hwcomposer: Remove legacy GetDisplayName

Remove the HWC2 GetDisplayName hook from HwcDisplay and replace it with
a function that simply returns the std::string.

Implement the HWC2 and HWC3 frontends in terms of the new
HwcDisplay::GetDisplayName.

Change-Id: I8230294bb7195b6d011ea450fafb80db8c9c5f50
Signed-off-by: Drew Davenport <ddavenport@google.com>
This commit is contained in:
Drew Davenport 2025-04-15 12:07:09 -06:00
parent 0113d20d46
commit 9d43873b2b
4 changed files with 33 additions and 32 deletions

View file

@ -145,6 +145,16 @@ std::string HwcDisplay::Dump() {
return ss.str();
}
auto HwcDisplay::GetDisplayName() -> std::string {
std::ostringstream stream;
if (IsInHeadlessMode()) {
stream << "null-display";
} else {
stream << "display-" << GetPipe().connector->Get()->GetId();
}
return stream.str();
}
HwcDisplay::HwcDisplay(hwc2_display_t handle, bool is_virtual, DrmHwc *hwc)
: hwc_(hwc), handle_(handle), is_virtual_(is_virtual), client_layer_(this) {
// Create writeback layer for both virtual displays and potential readback
@ -667,25 +677,6 @@ HWC2::Error HwcDisplay::GetColorModes(uint32_t *num_modes, int32_t *modes) {
return HWC2::Error::None;
}
HWC2::Error HwcDisplay::GetDisplayName(uint32_t *size, char *name) {
std::ostringstream stream;
if (IsInHeadlessMode()) {
stream << "null-display";
} else {
stream << "display-" << GetPipe().connector->Get()->GetId();
}
auto string = stream.str();
auto length = string.length();
if (!name) {
*size = length;
return HWC2::Error::None;
}
*size = std::min<uint32_t>(static_cast<uint32_t>(length - 1), *size);
strncpy(name, string.c_str(), *size);
return HWC2::Error::None;
}
HWC2::Error HwcDisplay::GetHdrCapabilities(uint32_t *num_types, int32_t *types,
float *max_luminance,
float *max_average_luminance,

View file

@ -74,6 +74,8 @@ class HwcDisplay {
std::string Dump();
auto GetDisplayName() -> std::string;
const HwcDisplayConfigs &GetDisplayConfigs() const {
return configs_;
}
@ -152,7 +154,6 @@ class HwcDisplay {
// HWC2 Hooks - these should not be used outside of the hwc2 device.
HWC2::Error GetColorModes(uint32_t *num_modes, int32_t *modes);
HWC2::Error GetDisplayName(uint32_t *size, char *name);
#if __ANDROID_API__ > 27
HWC2::Error GetRenderIntents(int32_t mode, uint32_t *outNumIntents,
int32_t *outIntents);

View file

@ -508,6 +508,24 @@ static int32_t GetDisplayConfigs(hwc2_device_t *device, hwc2_display_t display,
return 0;
}
static int32_t GetDisplayName(hwc2_device_t *device, hwc2_display_t display,
uint32_t *size, char *name) {
ALOGV("GetDisplayName");
LOCK_COMPOSER(device);
GET_DISPLAY(display);
std::string name_str = idisplay->GetDisplayName();
auto length = name_str.length();
if (name == nullptr) {
*size = length;
return 0;
}
*size = std::min<uint32_t>(static_cast<uint32_t>(length - 1), *size);
strncpy(name, name_str.c_str(), *size);
return 0;
}
static int32_t SetOutputBuffer(hwc2_device_t *device, hwc2_display_t display,
buffer_handle_t buffer, int32_t release_fence) {
ALOGV("SetOutputBuffer");
@ -1147,9 +1165,7 @@ static hwc2_function_pointer_t HookDevGetFunction(struct hwc2_device * /*dev*/,
case HWC2::FunctionDescriptor::GetDisplayConfigs:
return (hwc2_function_pointer_t)GetDisplayConfigs;
case HWC2::FunctionDescriptor::GetDisplayName:
return ToHook<HWC2_PFN_GET_DISPLAY_NAME>(
DisplayHook<decltype(&HwcDisplay::GetDisplayName),
&HwcDisplay::GetDisplayName, uint32_t *, char *>);
return (hwc2_function_pointer_t)GetDisplayName;
case HWC2::FunctionDescriptor::GetDisplayRequests:
return (hwc2_function_pointer_t)GetDisplayRequests;
case HWC2::FunctionDescriptor::GetDisplayType:

View file

@ -1014,15 +1014,8 @@ ndk::ScopedAStatus ComposerClient::getDisplayName(int64_t display_id,
return ToBinderStatus(hwc3::Error::kBadDisplay);
}
uint32_t size = 0;
auto error = Hwc2toHwc3Error(display->GetDisplayName(&size, nullptr));
if (error != hwc3::Error::kNone) {
return ToBinderStatus(error);
}
name->resize(size);
error = Hwc2toHwc3Error(display->GetDisplayName(&size, name->data()));
return ToBinderStatus(error);
*name = display->GetDisplayName();
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus ComposerClient::getDisplayVsyncPeriod(