PUSH_BUFFERS 类型的 SurfaceView
我对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在弃用表面类型后,这个问题就已经过时了。所以就不再用了...
This question is obsolete after making the surface types deprecated. So it isn't used anymore...