surfaceflinger测试程序 [英] surfaceflinger test program

查看:280
本文介绍了surfaceflinger测试程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写在Android中用于测试的本地应用程序 surfaceflinger。有没有简单的程序,说明如何创建 表面上,登记的缓冲区和后缓冲区上Surfaceflinger。

I want to write a native application in Android for testing surfaceflinger. Is there any simple program that shows how to create surface, register buffers and post buffers on Surfaceflinger.

推荐答案

框架/基/库/ surfaceflinger /测试/调整/ resize.cpp 是个好地方开始。 但我的测试程序的版本(Eclair的来自供应商)是过时的,有些表面 API已经被移动到 SurfaceControl 你必须:
SurfaceComposerClient :: createSurface() => SurfaceControl
SurfaceControl-> getSurface() => 表面

frameworks/base/libs/surfaceflinger/tests/resize/resize.cpp is a good place to start. But my version (Eclair from vendor) of the test app is out-dated, some Surface API has been moved to SurfaceControl and you have to:
SurfaceComposerClient::createSurface() => SurfaceControl
SurfaceControl->getSurface() => Surface

其次使用 SurfaceComposerClient :: openTransaction()/ closeTransaction() 开往所有交易SurfaceFlinger表面,如:
表面::锁()/ unlockAndPost() SurfaceControl :: setLayer()/的setSize()

Secondly use SurfaceComposerClient::openTransaction()/closeTransaction() to bound all transactions to SurfaceFlinger surface, eg:
Surface::lock()/unlockAndPost() and SurfaceControl::setLayer()/setSize()

我这里还有样品codeS(希望这编译:P)

Here're some sample codes (hope this compiles :P)

sp<SurfaceComposerClient> client;
sp<SurfaceControl> control;
sp<Surface> surface;
SurfaceID sid = 0;
Surface::SurfaceInfo sinfo;
// set up the thread-pool, needed for Binder
sp<ProcessState> proc(ProcessState::self());
ProcessState::self()->startThreadPool();
client = new SurfaceComposerClient();
control = client->createSurface(getpid(), sid, 160, 240, PIXEL_FORMAT_RGB_565);
surface = control->getSurface();

// global transaction sometimes cannot trigger a redraw
//client->openGlobalTransaction();

printf("setLayer...\n");
client->openTransaction();
control->setLayer(100000);
client->closeTransaction();
printf("setLayer done\n");

printf("memset 0xF800...\n");
client->openTransaction();
surface->lock(&sinfo);
android_memset16((uint16_t*)sinfo.bits, 0xF800, sinfo.s*pfInfo.bytesPerPixel*sinfo.h);
surface->unlockAndPost();
client->closeTransaction();
printf("memset 0xF800 done\n");
sleep(2);

printf("setSize...\n");
client->openTransaction();
control->setSize(80, 120);
client->closeTransaction();
printf("setSize done\n");
sleep(2);

printf("memset 0x07E0...\n");
client->openTransaction();
surface->lock(&sinfo);
android_memset16((uint16_t*)sinfo.bits, 0x07E0, sinfo.s*pfInfo.bytesPerPixel*sinfo.h);
surface->unlockAndPost();
printf("memset 0x07E0 done\n");
client->closeTransaction();
sleep(2);

printf("setPosition...\n");
client->openTransaction();
control->setPosition(100, 100);
client->closeTransaction();
printf("setPosition done\n");
sleep(2);

// global transaction sometimes cannot trigger a redraw
//client->closeGlobalTransaction();

printf("bye\n");

这篇关于surfaceflinger测试程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆