本文主要是介绍Android图形系统之HWComposer、ComposerHal、ComposerImpl、Composer、Hwc2::Composer实例总结(十四),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长!
优质专栏:Audio工程师进阶系列【原创干货持续更新中……】🚀
人生格言: 人生从来没有捷径,只有行动才是治疗恐惧和懒惰的唯一良药.
1.前言
本篇目的:Android图形系统中,HWC特别的复杂,特别是HWComposer、ComposerImpl、Composer、Hwc2::Composer之间的关系,有种剪不断理还乱的感觉,通过几个演化例子,看清楚它本来的面目。
2.HWComposer、ComposerImpl、Composer、Hwc2::Composer定义与实现
1.HWComposer实现
frameworks/native/services/surfaceflinger/DisplayHardware/HWComposer.h
<1>.android::HWComposer定义
namespace Hwc2 {
class Composer;
}namespace android {
class HWComposer {virtual ~HWComposer();virtual void setCallback(HWC2::ComposerCallback*) = 0;....
};
}
<2>.impl::HWComposer定义(继承自android::HWComposer)
namespace impl {class HWComposer final : public android::HWComposer {
public:explicit HWComposer(std::unique_ptr<Hwc2::Composer> composer);explicit HWComposer(const std::string& composerServiceName);~HWComposer() override;
};
}
<3>.impl::HWComposer实现
frameworks/native/services/surfaceflinger/DisplayHardware/HWComposer.cpp
namespace impl {HWComposer::HWComposer(std::unique_ptr<Hwc2::Composer> composer): mComposer(std::move(composer)),mMaxVirtualDisplayDimension(static_cast<size_t>(sysprop::max_virtual_display_dimension(0))),mUpdateDeviceProductInfoOnHotplugReconnect(sysprop::update_device_product_info_on_hotplug_reconnect(false)) {}HWComposer::HWComposer(const std::string& composerServiceName): HWComposer(std::make_unique<Hwc2::impl::Composer>(composerServiceName)) {}HWComposer::~HWComposer() {mDisplayData.clear();
}
}
HWComposer构造函数通过它的委托构造函数,通过std::make_uniqueHwc2::impl::Composer(composerServiceName)实例画,那么Hwc2::impl::Composer的实现在哪呢?
2.ComposerImpl实现(Hwc2::Composer是它的别名)
hardware/interfaces/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/Composer.h
<1>.Composer定义,它是ComposerImpl的别名
using Composer = detail::ComposerImpl<IComposer, ComposerHal>;
template <typename Interface, typename Hal>
class ComposerImpl : public Interface {public:static std::unique_ptr<ComposerImpl> create(std::unique_ptr<Hal> hal) {
这篇关于Android图形系统之HWComposer、ComposerHal、ComposerImpl、Composer、Hwc2::Composer实例总结(十四)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!