SurfaceFlinger测试程序

发布于 2024-09-05 23:29:46 字数 96 浏览 9 评论 0原文

我想在Android中编写一个本机应用程序进行测试 表面抛掷者。有没有任何简单的程序可以显示如何创建 Surfaceflinger 上的 Surface、寄存器缓冲区和后缓冲区。

I want to write a native application in Android for testing
surfaceflinger. Is there any simple program that shows how to create
surface, register buffers and post buffers on Surfaceflinger.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

夜夜流光相皎洁 2024-09-12 23:29:46

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");

frameworks/base/libs/surfaceflinger/tests/resize/resize.cpp is a good place to start.
But my version (Eclair from vendor) of the test app is out-dated, some Surface API has been moved to SurfaceControl and you have to:
SurfaceComposerClient::createSurface() => SurfaceControl
SurfaceControl->getSurface() => Surface

Secondly use SurfaceComposerClient::openTransaction()/closeTransaction()
to bound all transactions to SurfaceFlinger surface, eg:
Surface::lock()/unlockAndPost() and SurfaceControl::setLayer()/setSize()

Here're some sample codes (hope this compiles :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");
凉城凉梦凉人心 2024-09-12 23:29:46

对于姜饼,代码位于
/frameworks/base/services/surfaceflinger

查看此网站以获取有关 Surfaceflinger 的一些信息
http://kcchao.wikidot.com/surfaceflinger

For gingerbread the code is in
/frameworks/base/services/surfaceflinger

Checkout this site for some info on Surfaceflinger
http://kcchao.wikidot.com/surfaceflinger

为你鎻心 2024-09-12 23:29:46

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

谢谢,
维布杰尔

I am also looking for some similar application in Jelly bean but I am no able to get a standalone application which I can build and run and can see some output on the screen. There are some applications but they are not building in Jellybean as few of the APIs would have got modified at lower level. Please provide some pointers. I want to use this app to understand the surface flinger and the display sub system of Android.

Thanks,
Vibgyor

千里故人稀 2024-09-12 23:29:46

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

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

[platform/frameworks/base.git]/opengl/tests/gralloc/gralloc.cpp

它基本上按照您所描述的进行操作,但要意识到,这些是低级本机 API,并且在 Android 中不断发展。

Look in the source code for SurfaceFlinger(of the platform you're interested in).

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

[platform/frameworks/base.git]/opengl/tests/gralloc/gralloc.cpp

It basically does what you describe, realize though, that these are low level native APIs and are constantly evolving in Android.

想你只要分分秒秒 2024-09-12 23:29:46

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

If you are looking for how to interact directly with the SurfaceFlinger, the best start is to look into the SurfaceComposerClient code in /frameworks/base/libs/gui.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文