Android绘图缓存在后台做什么?

Android绘图缓存在后台做什么?,android,caching,path,draw,Android,Caching,Path,Draw,我有一个应用程序,需要我绘制画布的路径。随着路径数量的增加,累积绘图操作需要更长的时间,因此我认为使用绘图缓存可以提高速度 为此,我有一个onDraw方法,看起来有点像这样: @Override protected void onDraw(Canvas canvas) { Path path; Paint paint; synchronized(mPaths) { buildDrawingCache(); Bitmap bmp = getD

我有一个应用程序,需要我绘制画布的路径。随着路径数量的增加,累积绘图操作需要更长的时间,因此我认为使用绘图缓存可以提高速度

为此,我有一个
onDraw
方法,看起来有点像这样:

@Override
protected void onDraw(Canvas canvas) {
    Path path;
    Paint paint;
    synchronized(mPaths) {
        buildDrawingCache();
        Bitmap bmp = getDrawingCache();
        if(bmp!=null) canvas.drawBitmap(bmp,
                new Rect(0, 0, bmp.getWidth(), bmp.getHeight()),
                new Rect(getLeft(), getTop(), getRight(), getBottom()),
                null);
        for(int i=mLastCount; i<mPaths.size(); ++i) {
            path = mPaths.get(i);
            paint = mPaints.get(i);
            canvas.drawPath(path, paint);
        }
        mLastCount = 0;
        mDrawn = true;
        destroyDrawingCache();
    }
}
@覆盖
受保护的void onDraw(画布){
路径;
油漆;
已同步(兆帕){
buildDrawingCache();
位图bmp=getDrawingCache();
如果(bmp!=null)canvas.drawBitmap(bmp,
新的Rect(0,0,bmp.getWidth(),bmp.getHeight()),
新的Rect(getLeft(),getTop(),getRight(),getBottom()),
无效);
对于(int i=mLastCount;i