android中图像的显示是通过HWComposer合成的,(不支持硬件composer的不考虑,现在基本都支持)。 硬件支持合成就是你输入多路视频,图像信号,出来一路合成好的数据。
硬件合成只支持有限的记录信号,所有如何存在太多的信号,需要先通过软件进行合成,surfaceflinger是通过gpu合成的。
SurfaceFlinger::init(){
//包装了硬件合成的硬件抽象层
mHwc
=
new
HWComposer
(
this
,
*
static_cast
<
HWComposer
::
EventHandler
*>(
this
));
//初始化部分
for (size_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) {
DisplayDevice::DisplayType type((DisplayDevice::DisplayType)i);
if (mHwc->isConnected(i) || type==DisplayDevice::DISPLAY_PRIMARY) {
bool isSecure = true;
createBuiltinDisplayLocked(type);
wp<IBinder> token = mBuiltinDisplays[i];
sp<BufferQueue> bq = new BufferQueue(new GraphicBufferAlloc());
//数据加工好了以后FramebufferSurface内部把他送给HWComposer
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i, bq);
//数据生产者,每个屏幕都有一个,以后在这个屏幕上的绘制都是操作了bq
//DisplayDevice就是bufferqueue的生产者
sp<DisplayDevice> hw = new DisplayDevice(this, type, allocateHwcDisplayId(type), isSecure, token,
fbs, bq,
mEGLConfig);