从handle得到GraphicBuffer

先定义一个宏:

cpp 复制代码
#ifndef container_of
#define container_of(ptr, type, member) \
    (type *)((char*)(ptr) - offsetof(type, member))
#endif

然后:

cpp 复制代码
ANativeWindowBuffer *anwBuffer = container_of(buffer, ANativeWindowBuffer, handle);

其中buffer的类型是:

cpp 复制代码
buffer_handle_t *buffer;

得到ANativeWindowBuffer以后:

cpp 复制代码
sp<GraphicBuffer> GraphicBuffer::from(ANativeWindowBuffer* anwb) {
    return static_cast<GraphicBuffer *>(anwb);
}
相关推荐
小兔薯了8 小时前
7. LNMP-wordpress
android·运维·服务器·数据库·nginx·php
L***d6709 小时前
mysql的主从配置
android·mysql·adb
Sammyyyyy10 小时前
PHP 8.5 新特性:10 大核心改进
android·php·android studio
TO_ZRG11 小时前
Unity 通过 NativePlugin 接入Android SDK 指南
android·unity·游戏引擎
n***840711 小时前
Springboot-配置文件中敏感信息的加密:三种加密保护方法比较
android·前端·后端
方白羽12 小时前
一次由 by lazy 引发的“数据倒灌”,深入理解 `by`关键字、`lazy`函数的本质
android·kotlin·app
v***553412 小时前
MySQL 中如何进行 SQL 调优
android·sql·mysql
vx_vxbs6614 小时前
【SSM高校普法系统】(免费领源码+演示录像)|可做计算机毕设Java、Python、PHP、小程序APP、C#、爬虫大数据、单片机、文案
android·java·python·mysql·小程序·php·idea
j***827015 小时前
【MyBatisPlus】MyBatisPlus介绍与使用
android·前端·后端
ljt272496066115 小时前
Compose笔记(五十八)--LinearOutSlowInEasing
android·笔记·android jetpack