drm_hwcomposer: Simplify DrmHwcTwo::GetDisplay()
Cosmetic change: make GetDisplay() non-static class method + use
deduced return type.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/hwc2_device/DrmHwcTwo.h b/hwc2_device/DrmHwcTwo.h
index f38ba05..fa13170 100644
--- a/hwc2_device/DrmHwcTwo.h
+++ b/hwc2_device/DrmHwcTwo.h
@@ -37,14 +37,6 @@
#endif
std::pair<HWC2_PFN_REFRESH, hwc2_callback_data_t> refresh_callback_{};
- static HwcDisplay *GetDisplay(DrmHwcTwo *hwc, hwc2_display_t display_handle) {
- auto it = hwc->displays_.find(display_handle);
- if (it == hwc->displays_.end())
- return nullptr;
-
- return &it->second;
- }
-
// Device functions
HWC2::Error CreateVirtualDisplay(uint32_t width, uint32_t height,
int32_t *format, hwc2_display_t *display);
@@ -55,6 +47,11 @@
hwc2_function_pointer_t function);
HWC2::Error CreateDisplay(hwc2_display_t displ, HWC2::DisplayType type);
+ auto GetDisplay(hwc2_display_t display_handle) {
+ return displays_.count(display_handle) != 0 ? &displays_.at(display_handle)
+ : nullptr;
+ }
+
auto &GetResMan() {
return resource_manager_;
}
diff --git a/hwc2_device/hwc2_device.cpp b/hwc2_device/hwc2_device.cpp
index 6d258e8..57bc205 100644
--- a/hwc2_device/hwc2_device.cpp
+++ b/hwc2_device/hwc2_device.cpp
@@ -74,8 +74,8 @@
GetFuncName(__PRETTY_FUNCTION__).c_str());
DrmHwcTwo *hwc = ToDrmHwcTwo(dev);
const std::lock_guard<std::mutex> lock(hwc->GetResMan().GetMainLock());
- HwcDisplay *display = DrmHwcTwo::GetDisplay(hwc, display_handle);
- if (!display)
+ auto *display = hwc->GetDisplay(display_handle);
+ if (display == nullptr)
return static_cast<int32_t>(HWC2::Error::BadDisplay);
return static_cast<int32_t>((display->*func)(std::forward<Args>(args)...));
@@ -88,8 +88,8 @@
layer_handle, GetFuncName(__PRETTY_FUNCTION__).c_str());
DrmHwcTwo *hwc = ToDrmHwcTwo(dev);
const std::lock_guard<std::mutex> lock(hwc->GetResMan().GetMainLock());
- HwcDisplay *display = DrmHwcTwo::GetDisplay(hwc, display_handle);
- if (!display)
+ auto *display = hwc->GetDisplay(display_handle);
+ if (display == nullptr)
return static_cast<int32_t>(HWC2::Error::BadDisplay);
HwcLayer *layer = display->get_layer(layer_handle);