PUSH_BUFFERS 类型的 SurfaceView

发布于 2024-09-30 06:10:08 字数 519 浏览 1 评论 0原文

我对 SurfaceView 有一些经验。为了防止不必要的重绘,我总是使用倒计时变量来告诉线程应该绘制视图的频率。

countdown > 0 : draw ? doNothing

然而我正在考虑改变它以使用“推动表面”。因此,只需将缓冲区推到表面并显示即可,而不是在项目中的任何地方设置倒计时变量。

我的问题是我找不到描述用法的好教程/资源。目前我有这样的事情:

// panel is the SurfaceView
c = panel.getHolder().lockCanvas(null);
synchronized (panel.getHolder()) {
    panel.updatePhysics();
    panel.onDraw(c);
}
panel.getHolder().unlockCanvasAndPost(c);

当我无法使用文档中提到的 lockCanvas() 时,我不知道如何让画布进行绘制。

I have some experience with the SurfaceView. To prevent unneeded redrawing, I always use a countdown variable which tells the thread how often the view should be drawn.

countdown > 0 : draw ? doNothing

However I was thinking about changing that to use a "push surface". So just push a buffer to the surface and show that instead of setting a countdown variable everywhere in my project.

My problem is that I can't find a good tutorial/resource where the usage is described. Currently I have something like this:

// panel is the SurfaceView
c = panel.getHolder().lockCanvas(null);
synchronized (panel.getHolder()) {
    panel.updatePhysics();
    panel.onDraw(c);
}
panel.getHolder().unlockCanvasAndPost(c);

I have no idea on how to get the canvas to draw on when I can't use lockCanvas() as mentioned in the documentation.

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

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

发布评论

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

评论(1

榆西 2024-10-07 06:10:08

在弃用表面类型后,这个问题就已经过时了。所以就不再用了...

This question is obsolete after making the surface types deprecated. So it isn't used anymore...

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