我想用Android写一个原生的应用程序来测试surfaceflinger。有没有简单的程序来展示如何在Surfaceflinger上创建表面,寄存器缓冲区和post缓冲区。
发布于 2011-05-23 13:23:38
frameworks/base/libs/surfaceflinger/tests/resize/resize.cpp是一个很好的起点。但是我的测试应用程序版本(供应商提供的Eclair)已经过时了,一些Surface应用程序接口已经移到了SurfaceControl上,你必须:
SurfaceComposerClient::createSurface() => SurfaceControl
SurfaceControl->getSurface() => Surface
其次,使用SurfaceComposerClient::openTransaction()/closeTransaction()将所有事务绑定到SurfaceFlinger表面,例如:
Surface::lock()/unlockAndPost()和SurfaceControl::setLayer()/setSize()
下面是一些示例代码(希望这段代码可以编译: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");发布于 2011-05-06 15:36:47
对于姜饼,代码在/framework/base/services/surfaceflinger中
有关Surfaceflinger http://kcchao.wikidot.com/surfaceflinger的一些信息,请查看此站点
发布于 2013-05-17 14:59:55
我也在寻找一些类似的应用程序在Jelly bean,但我不能得到一个独立的应用程序,我可以构建和运行,并可以在屏幕上看到一些输出。有一些应用程序,但它们不是在Jellybean中构建的,因为很少有API会在较低的级别进行修改。请提供一些提示。我想使用这个应用程序来了解表面的flinger和Android的显示子系统。
谢谢,Vibgyor
https://stackoverflow.com/questions/3076529
复制相似问题