surfaceflinger测试程序

我想在Android中编写一个本机应用程序进行测试 SurfaceFlinger的。是否有任何简单的程序显示如何创建 Surfaceflinger上的表面,寄存器缓冲区和后缓冲区。     
已邀请:
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 donen");

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 donen");
sleep(2);

printf("setSize...n");
client->openTransaction();
control->setSize(80, 120);
client->closeTransaction();
printf("setSize donen");
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 donen");
client->closeTransaction();
sleep(2);

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

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

printf("byen");
    
对于姜饼代码是在 /框架/基/服务/ SurfaceFlinger的 在这个网站上查看有关Surfaceflinger的一些信息 http://kcchao.wikidot.com/surfaceflinger     
我也在Jelly bean中寻找一些类似的应用程序,但是我无法获得一个可以构建和运行的独立应用程序,并且可以在屏幕上看到一些输出。有一些应用程序,但它们不是在Jellybean中构建的,因为很少有API会在较低级别进行修改。请提供一些指示。我想使用这个应用程序来了解Android的表面抛弃物和显示子系统。 谢谢, VIBGYOR     
查看SurfaceFlinger的源代码(您感兴趣的平台)。 ../frameworks/base/libs/surfaceflinger/tests/resize/resize.cpp [平台/框架/ base.git] /opengl/tests/gralloc/gralloc.cpp 它基本上完成了您所描述的内容,但实现了这些是低级本机API并且在Android中不断发展。     
如果您正在寻找如何直接与SurfaceFlinger交互,最好的方法是查看/ frameworks / base / libs / gui中的SurfaceComposerClient代码。     

要回复问题请先登录注册