drm_hwcomposer: Set return type to std::optional for BufferInfoGetters
This is a bit of code modernization. Further changes will require indication
that buffer_info is valid, and using std::optional is the most correct
approach to do that.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index 2aec440..7279c02 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -598,13 +598,16 @@
/* TODO: Do not update source_crop every call.
* It makes sense to do it once after every hotplug event. */
- BufferInfo bo{};
- BufferInfoGetter::GetInstance()->ConvertBoInfo(target, &bo);
+ auto bi = BufferInfoGetter::GetInstance()->GetBoInfo(target);
+
+ if (!bi) {
+ return HWC2::Error::BadParameter;
+ }
hwc_frect_t source_crop = {.left = 0.0F,
.top = 0.0F,
- .right = static_cast<float>(bo.width),
- .bottom = static_cast<float>(bo.height)};
+ .right = static_cast<float>(bi->width),
+ .bottom = static_cast<float>(bi->height)};
client_layer_.SetLayerSourceCrop(source_crop);
return HWC2::Error::None;