问题
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
Paintfeatures 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