cpp层直接操作 surface

这个博客展示了如何在Android中从文件读取YUV数据并将其渲染到Surface上。通过使用SurfaceComposerClient、ANativeWindow和 GraphicBufferMapper等组件,实现了YUV数据的显示。代码中包含了内存对齐、图形缓冲区的申请和释放,以及YUV数据的拷贝到缓冲区的过程。

#include <utils/CallStack.h>
#include <ui/DisplayInfo.h>
#include <cutils/memory.h>  
#include <unistd.h>  
#include <utils/Log.h>  
  
#include <binder/IPCThreadState.h>  
#include <binder/ProcessState.h>  
#include <binder/IServiceManager.h>  
#include <media/stagefright/foundation/ADebug.h>  
#include <gui/Surface.h>  
#include <gui/SurfaceComposerClient.h>  
#include <gui/ISurfaceComposer.h>  
#include <ui/DisplayInfo.h>  
#include <android/native_window.h>  
#include <system/window.h>  
#include <ui/GraphicBufferMapper.h>  
//ANativeWindow 就是surface,对应surface.cpp里的code  

using namespace android;  

extern "C" int mainxx123(void);

//将x规整为y的倍数,也就是将x按y对齐  
static int ALIGN(int x, int y) {  
    // y must be a power of 2.  
    return (x + y - 1) & ~(y - 1);  
}  

void fill_color(void *vaddr)
{
    int cnt;
    unsigned int * p_data;

    p_data = (unsigned int *)vaddr;
    for( int i=0x00; i<60*640; i++ ){
         p_data[i] = 0xff0000ff;
    }
}

  
void render(  
        const void *data, size_t size, const sp<ANativeWindow> &nativeWindow,int width,int height) {  
    sp<ANativeWindow> mNativeWindow = nativeWindow;  
    int err;  
    int mCropWidth = width;  
    int mCropHeight = height;  

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值