Surfaceflinger测试程序

时间:2010-06-19 17:29:39

标签: android android-ndk native platform surfaceflinger

我想在Android中编写一个本机应用程序进行测试 SurfaceFlinger的。是否有任何简单的程序显示如何创建 Surfaceflinger上的表面,寄存器缓冲区和后缓冲区。

5 个答案:

答案 0 :(得分:3)

frameworks/base/libs/surfaceflinger/tests/resize/resize.cpp是个好地方。 但我的测试应用版本(来自供应商的Eclair)已过时,某些Surface API已移至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");

答案 1 :(得分:2)

对于姜饼,代码在 /框架/碱/服务/ SurfaceFlinger的

查看此网站,了解有关Surfaceflinger的一些信息 http://kcchao.wikidot.com/surfaceflinger

答案 2 :(得分:2)

我也在Jelly bean中寻找一些类似的应用程序,但我无法获得一个可以构建和运行的独立应用程序,并且可以在屏幕上看到一些输出。有一些应用程序,但它们不是在Jellybean中构建的,因为很少有API会在较低级别进行修改。请提供一些指示。我想使用这个应用程序来了解Android的表面抛弃物和显示子系统。

谢谢, VIBGYOR

答案 3 :(得分:1)

查看SurfaceFlinger的源代码(您感兴趣的平台)。

../框架/碱/库/ SurfaceFlinger的/测试/调整/ resize.cpp

[平台/框架/ base.git] /opengl/tests/gralloc/gralloc.cpp

它基本上完成了您所描述的内容,但实现了这些是低级本机API并且在Android中不断发展。

答案 4 :(得分:1)

如果您正在寻找如何直接与SurfaceFlinger交互,最好的方法是查看/ frameworks / base / libs / gui中的SurfaceComposerClient代码。