Algorithms used in android.graphics.Canvas

自古美人都是妖i 提交于 2019-12-12 03:15:48

问题


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.

Any idea?


回答1:


Summarizing the comments:

  • There are at least two implementations of the drawing functions, one purely in software (the Skia library), and one that uses the GPU when hardware acceleration is enabled.

  • 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.

  • 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.



来源:https://stackoverflow.com/questions/27871855/algorithms-used-in-android-graphics-canvas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!