上一篇文章分析了回调注册监听的调用流程,对于数据的回调正好是注册监听的逆向调用。首先前面提到过在 HWC2On1Adapter 中就会直接转型为每一个回调到上层,这里我们就看一下屏幕热插拔回调(hotplugHook)的调用流程。
一、硬件回调
1、HWC2On1Adapter.cpp
源码位置:/hardware/interfaces/graphics/composer/2.1/utils/hwc2on1adapter/HWC2On1Adapter.cpp
class HWC2On1Adapter::Callbacks : public hwc_procs_t {
public:
explicit Callbacks(HWC2On1Adapter& adapter) : mAdapter(adapter) {
invalidate = &invalidateHook;
vsync = &vsyncHook;
hotplug = &hotplugHook;
}
……
static void hotplugHook(const hwc_procs_t* procs, int display, int connected) {
auto callbacks = static_cast<const Callbacks*>(procs);
callbacks->mAdapter.hwc1Hotplug(display, connected);
}
private:
HWC2On1Adapter& mAdapter;
};
这是我们传入底层的 Callback,当屏幕出现热插