gpt4 book ai didi

android surfaceview onDraw 与 thread.onDraw

转载 作者:行者123 更新时间:2023-11-29 02:12:51 26 4
gpt4 key购买 nike

安卓游戏用什么比较好:

  • 一个带有渲染线程的SurfaceView

  • 一个 SurfaceView,带有调用 SurfaceView 函数的线程 doDraw()

谢谢。

最佳答案

SurfaceView 中的绘图已经在单独的线程中处理。您不需要生成新的。

参见 API doc关于它:

One of the purposes of this class is to provide a surface in which a secondary thread can render into the screen. If you are going to use it this way, you need to be aware of some threading semantics:

  • All SurfaceView and SurfaceHolder.Callback methods will be called from the thread running the SurfaceView's window (typically the main thread of the application). They thus need to correctly synchronize with any state that is also touched by the drawing thread.
  • You must ensure that the drawing thread only touches the underlying Surface while it is valid -- between SurfaceHolder.Callback.surfaceCreated() and SurfaceHolder.Callback.surfaceDestroyed().

关于android surfaceview onDraw 与 thread.onDraw,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6253807/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com