看看Canvas的repaint做了什么

Canvas
public final void repaint(int x, int y, int width, int height) {
        synchronized (Display.LCDUILock) {
            callRepaint(x + viewport[X], y + viewport[Y], width, height, null);
        }
    }
    public final void repaint() {
        synchronized (Display.LCDUILock) {
            callRepaint(viewport[X], viewport[Y],
                        viewport[WIDTH], viewport[HEIGHT], null);
        }
}
Displayable
final void callRepaint(int x, int y, int width, int height, Object target) {
        if (currentDisplay != null) {
            // Note: Display will not let anyone but the current
            // Displayable schedule repaints
            currentDisplay.repaintImpl(paintDelegate, x, y, width, height,
                                       target);
        }
    }
    final void callRepaint() {
        callRepaint(0, 0,
                    viewport[X] + viewport[WIDTH],
                    viewport[Y] + viewport[HEIGHT], null);
}
Display
void repaintImpl(Displayable d, int x, int y, int w, int h,
                     Object target) {
        synchronized (LCDUILock) {
            if (paintSuspended || !hasForeground || d != current) {
                return;
            }
        }
        eventHandler.scheduleRepaint(x, y, w, h, target);
    }

你可能感兴趣的:(canvas)