android6.0图片,Android6.0 显示系统(六) 图像的输出过程.doc

本文解析了Android 6.0中SurfaceFlinger处理图像输出的过程,重点关注preComposition、rebuildLayerStacks等关键函数,探讨Layer管理和屏幕刷新机制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Android6.0 显示系统(六) 图像的输出过程

Android6.0 显示系统(六) 图像的输出过程

主要就是分析这个函数,我们先看看它的代码:

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片

void SurfaceFlinger::handleMessageRefresh() {

ATRACE_CALL();

static nsecs_t previousExpectedPresent = 0;

nsecs_t expectedPresent = mPrimaryDispSputeNextRefresh(0);

static bool previousFrameMissed = false;

bool frameMissed = (expectedPresent == previousExpectedPresent);

if (frameMissed != previousFrameMissed) {

ATRACE_INT("FrameMissed", static_cast(frameMissed));

}

previousFrameMissed = frameMissed;

if (CC_UNLIKELY(mDropMissedFrames && frameMissed)) {

// Latch buffers, but don't send anything to HWC, then signal another

// wakeup for the next vsync

preComposition();

repaintEverything();

} else {

preComposition();

rebuildLayerStacks();

setUpHWComposer();

doDebugFlashRegions();

doComposition();

postComposition();

}

previousExpectedPresent = mPrimaryDispSputeNextRefresh(0);

}

我们主要看下下面几个函数。

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片

preComposition();

rebuildLayerStacks();

setUpHWComposer();

doDebugFlashRegions();

doComposition();

postComposition();

一、preComposition函数

我们先来看第一个函数preComposition

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片

void SurfaceFlinger::preComposition()

{

bool needExtraInvalidate = false;

const LayerVector& layers(mDrawingState.layersSortedByZ);

const size_t count = layers.size();

for (size_t i=0 ; i

if (layers[i]->onPreComposition()) {

needExtraInvalidate = true;

}

}

if (needExtraInvalidate) {

signalLayerUpdate();

}

}

上面函数先是调用了mDrawingState的layersSortedByZ来得到上次绘图的Layer层列表。并不是所有的Layer都会参与屏幕图像的绘制,因此SurfaceFlinger用state对象来记录参与绘制的Layer对象。

记得在之前的博客,我们分析过createLayer函数来创建Layer,创建之后会调用addClientLayer函数。

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片

status_t Surface

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值