diff options
author | Roman Stratiienko <roman.o.stratiienko@globallogic.com> | 2022-01-29 00:10:07 +0200 |
---|---|---|
committer | Roman Stratiienko <roman.o.stratiienko@globallogic.com> | 2022-01-31 21:31:31 +0200 |
commit | 938a74244d7afbff431a0430e37f462968ed55a3 (patch) | |
tree | 088b796100ab165387f375110fe575a0bcfc3a80 | |
parent | dfac456143276fd2e148e76a29165a9ed6c73b8c (diff) | |
download | drm_hwcomposer-938a74244d7afbff431a0430e37f462968ed55a3.tar.gz |
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>
-rw-r--r-- | hwc2_device/DrmHwcTwo.h | 13 | ||||
-rw-r--r-- | hwc2_device/hwc2_device.cpp | 8 |
2 files changed, 9 insertions, 12 deletions
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 @@ class DrmHwcTwo { #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 @@ class DrmHwcTwo { 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 @@ static int32_t DisplayHook(hwc2_device_t *dev, hwc2_display_t display_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); return static_cast<int32_t>((display->*func)(std::forward<Args>(args)...)); @@ -88,8 +88,8 @@ static int32_t LayerHook(hwc2_device_t *dev, hwc2_display_t display_handle, 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); |