Android-View绘制原理(06)-ASurfaceControl

ASurfaceControl是一个结构体,与SurfaceControl无继承关系但可相互转换。它们通过指针强制转换实现互转,ASurfaceControl有一系列全局函数用于操作。这些函数常用于Android系统的表面合成器操作中。
摘要由CSDN通过智能技术生成

更Surface很相似,SurfaceControl也有一个对应的定义ASurfaceControl,但是它和SurfaceControl之间并不存在继承关系,仅仅是可以相互转换而已。

1. 定义

frameworks/native/include/android/surface_control.h

struct ASurfaceControl;

/**
 * The SurfaceControl API can be used to provide a hierarchy of surfaces for
 * composition to the system compositor. ASurfaceControl represents a content node in
 * this hierarchy.
 */
typedef struct ASurfaceControl ASurfaceControl;

ASurfaceControl只是一个结构体,也没有属性。

2. 相互转换

他们之间只要进行指针强制转换就可以实现相互转换。

SurfaceControl转ASurfaeControl

ASurfaceControl* surfaceControl = reinterpret_cast<ASurfaceControl*>(surfaceControlPtr);

ASurfaceControl转SurfaeControl
frameworks/base/native/android/surface_control.cpp

SurfaceControl* ASurfaceControl_to_SurfaceControl(ASurfaceControl* aSurfaceControl) {
    return reinterpret_cast<SurfaceControl*>(aSurfaceControl);
}

3. 函数

关于ASurfaceControl定义了一系列的全局函数,他们主要在
frameworks/native/include/android/surface_control.h
frameworks/native/include/private/surface_control_private.h
这个函数的实现在
frameworks/base/native/android/surface_control.cpp,比如:

ASurfaceControl* ASurfaceControl_createFromWindow(ANativeWindow* window, const char* debug_name) {
ASurfaceControl* ASurfaceControl_create(ASurfaceControl* parent, const char* debug_name)  __INTRODUCED_IN(29);
void ASurfaceControl_acquire(ASurfaceControl* surface_control) __INTRODUCED_IN(31);
void ASurfaceControl_release(ASurfaceControl* surface_control) __INTRODUCED_IN(29);
void ASurfaceControl_registerSurfaceStatsListener(ASurfaceControl* control, void* context,
        ASurfaceControl_SurfaceStatsListener func);
void ASurfaceControl_unregisterSurfaceStatsListener(void* context,  ASurfaceControl_SurfaceStatsListener func);

int64_t ASurfaceControlStats_getAcquireTime(ASurfaceControlStats* stats);
uint64_t ASurfaceControlStats_getFrameNumber(ASurfaceControlStats* stats);

这些方法不是很复杂,主要是操作将ASurfaceControl转化成SurfaceControl之后再执行相对应的操作。

4. 结语

这个ASurfaceControl不是很复杂,但是因为分析后续绘制流程会涉及到这个概念,因此就简单介绍一下

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值