从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);
}
相关推荐
林北北的霸霸2 小时前
django初识与安装
android·mysql·adb
Java 码农3 小时前
MySQL EXPLAIN 详解与优化指南
android·mysql·adb
stevenzqzq8 小时前
Android Hilt 入门教程_传统写法和Hilt写法的比较
android
wuwu_q8 小时前
用通俗易懂方式,详细讲讲 Kotlin Flow 中的 map 操作符
android·开发语言·kotlin
_李小白8 小时前
【Android FrameWork】第五天:init加载RC文件
android
2501_916007479 小时前
手机使用过的痕迹能查到吗?完整查询指南与步骤
android·ios·智能手机·小程序·uni-app·iphone·webview
黄毛火烧雪下9 小时前
React Native (RN)项目在web、Android和IOS上运行
android·前端·react native
下位子10 小时前
『OpenGL学习滤镜相机』- Day7: FBO(帧缓冲对象)
android·opengl
從南走到北10 小时前
JAVA国际版同城外卖跑腿团购到店跑腿多合一APP系统源码支持Android+IOS+H5
android·java·ios·微信小程序·小程序
空白格9710 小时前
组件化攻略
android