android.graphics.Canvas中使用的算法 [英] Algorithms used in android.graphics.Canvas
问题描述
我正在尝试找出什么绘制算法 android.graphics.Canvas 正在使用,尤其是drawLine
和drawCircle
.我设法找到了 Canvas_Delegate. Java ,但我无法理解每种情况下使用哪种算法.
I am trying to find out what drawing algorithms android.graphics.Canvas is using, and especialy for drawLine
and drawCircle
. I have managed to find Canvas_Delegate.java, but I cannot understand which algorithm is used in each occasion.
有什么主意吗?
推荐答案
总结评论:
-
绘图功能至少有两种实现,一种纯粹是在软件中实现( Skia库),并且在 Skia实现是用C ++而不是Java编写的.由于必须考虑
Paint
功能(例如笔划宽度),因此代码可能不会像The Skia implementation is written in C++, not Java. Because it has to take into account
Paint
features like stroke width, the code may not appear as straightforward as the classic implementation you found.使用C ++编写的给定算法的实现通常比使用Java编程语言编写的算法要快得多.这是一个宗教问题,定期发布各种基准以消除"Java缓慢"的概念.我认为C ++更具表现力,可以让您更准确地告诉编译器您想要执行的操作,尤其是在Android上,NDK C ++编译器明显优于Dalvik或Art编译器.
The implementation of a given algorithm is often much faster when written in C++ than it is when written in the Java programming language. This is something of a religious issue, with various benchmarks periodically thrown around to dispel the "Java is slow" notion. I think C++ is a bit more expressive, allowing you to tell the compiler more exactly what you want it to do, and on Android in particular the NDK C++ compiler is significantly better than the Dalvik or Art compilers.
这篇关于android.graphics.Canvas中使用的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!