问题描述
在许多情况下,渲染需要大量的计算能力。因此,可能会发生由于UI需要等待渲染完成而跳过帧的情况。
Rendering takes a lot of computational power in many cases. Thus, it can happen that frames are being skipped as the UI needs to wait for the rendering to finish.
我想知道如何实现渲染或绘画异步,即孤立。
I was wondering how I could implement rendering or painting asynchronously, i.e. isolated.
类似于 compute
不是一个选择,因为仅适用于原始类型,绘画需要或。
Functions like compute
are not an option because SendPort
only works with primitive types and painting will require a PaintingContext
or Canvas
.
有些Flutter插件需要大量渲染。因此,我认为我可以在插件,但它使用,即不在Dart中渲染 。
There are Flutter plugins that require heavy rendering. Hence, I thought that I could find answers in the video_player
plugin, but it uses Texture
, i.e. does not render in Dart.
我想知道是否有任何成语或示例
I am wondering if there are any idioms or example implementations regarding this.
我想知道如何实现渲染,可以看看。原来他们像我一样处理绘画。现在我想知道为什么我遇到瓶颈而Flare却没有。有优化绘画的指南吗?
I you are wondering how I implement rendering, you can take a look at FlareActor
. It turns out that they handle painting exactly like I do. Now I am wondering why I am running into bottlenecks and Flare is not. Are there any guides on optimizing painting?
推荐答案
我通过将所有需要的像素写入来解决了问题BMP
文件格式,然后使用 Canvas.drawImage
代替,因为Flutter画布无法处理许多 Canvas
操作:
I solved it by writing all my required pixels to the BMP
file format and then using Canvas.drawImage
instead as the Flutter canvas cannot handle many Canvas
operations: https://stackoverflow.com/a/55855735/6509751
这篇关于如何执行昂贵的渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!