2010-06-19 51 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