You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.8 KiB
71 lines
1.8 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2016-2019. All rights reserved.
|
|
* Description: Some callback interfaces of hwcomposer
|
|
* Author: Hisilicon
|
|
* Created: 2016.08.12
|
|
*/
|
|
|
|
#include "HWCCallbacks.h"
|
|
#include <log/log.h>
|
|
|
|
namespace android {
|
|
HWCCallbacks::HWCCallbacks()
|
|
: m_hotplugData(nullptr),
|
|
m_refreshData(nullptr),
|
|
m_vsyncData(nullptr),
|
|
m_hotplug(nullptr),
|
|
m_refresh(nullptr),
|
|
m_vsync(nullptr)
|
|
{
|
|
}
|
|
|
|
HWCCallbacks::~HWCCallbacks()
|
|
{
|
|
}
|
|
|
|
void HWCCallbacks::Hotplug(hwc2_display_t display, HWC2::Connection state) const
|
|
{
|
|
if (m_hotplug != nullptr) {
|
|
m_hotplug(m_hotplugData, display, int32_t(state));
|
|
} else {
|
|
ALOGI("ignore Hotplug event because surfaceflinger have not RegisterCallback yet");
|
|
}
|
|
}
|
|
|
|
void HWCCallbacks::Refresh(hwc2_display_t display) const
|
|
{
|
|
if (m_refresh != nullptr) {
|
|
m_refresh(m_refreshData, display);
|
|
}
|
|
}
|
|
|
|
void HWCCallbacks::Vsync(hwc2_display_t display, int64_t timestamp) const
|
|
{
|
|
if (m_vsync != nullptr) {
|
|
m_vsync(m_vsyncData, display, timestamp);
|
|
}
|
|
}
|
|
|
|
HWC2::Error HWCCallbacks::Register(HWC2::Callback descriptor, hwc2_callback_data_t callbackData,
|
|
hwc2_function_pointer_t pointer)
|
|
{
|
|
switch (descriptor) {
|
|
case HWC2::Callback::Hotplug:
|
|
m_hotplugData = callbackData;
|
|
m_hotplug = reinterpret_cast<HWC2_PFN_HOTPLUG>(pointer);
|
|
break;
|
|
case HWC2::Callback::Refresh:
|
|
m_refreshData = callbackData;
|
|
m_refresh = reinterpret_cast<HWC2_PFN_REFRESH>(pointer);
|
|
break;
|
|
case HWC2::Callback::Vsync:
|
|
m_vsyncData = callbackData;
|
|
m_vsync = reinterpret_cast<HWC2_PFN_VSYNC>(pointer);
|
|
break;
|
|
default:
|
|
return HWC2::Error::BadParameter;
|
|
}
|
|
return HWC2::Error::None;
|
|
}
|
|
} // namespace android
|