2010-06-19 34 views
2

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

回答

1

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

../frameworks/base/libs/surfaceflinger/tests/resize/resize.cpp

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

它基本上做你所描述的,但是,这些都是低级本地API,并且在Android中不断发展。

+0

是否有可能建立和Android的控制台独立运行这个程序,得到一种什么感觉? – Midson 2010-12-31 04:24:31

+0

是的,虽然可能不是你想要做的事情,但它是可能的。请记住,这些是低级别的本地API,因此可能无法跨发行版移植。我能想到的一种方式是使用Android的NDK来满足所有的依赖(包括,库等)。 NDK确实带有可简单替换的示例代码。正确的/预期的方式是从源代码构建Android,然后从源代码树中修改/构建。 – csanta 2011-01-02 20:12:08

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

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

2

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

感谢, VIBGYOR