DisplayList.java revision b35ab7b72967adcfd01cec483a705dafe8b951d1
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.view;
18
19/**
20 * A display lists records a series of graphics related operation and can replay
21 * them later. Display lists are usually built by recording operations on a
22 * {@link android.graphics.Canvas}. Replaying the operations from a display list
23 * avoids executing views drawing code on every frame, and is thus much more
24 * efficient.
25 *
26 * @hide
27 */
28public abstract class DisplayList {
29    /**
30     * Starts recording the display list. All operations performed on the
31     * returned canvas are recorded and stored in this display list.
32     *
33     * @return A canvas to record drawing operations.
34     */
35    public abstract HardwareCanvas start();
36
37    /**
38     * Ends the recording for this display list. A display list cannot be
39     * replayed if recording is not finished.
40     */
41    public abstract void end();
42
43    /**
44     * Invalidates the display list, indicating that it should be repopulated
45     * with new drawing commands prior to being used again. Calling this method
46     * causes calls to {@link #isValid()} to return <code>false</code>.
47     */
48    public abstract void invalidate();
49
50    /**
51     * Returns whether the display list is currently usable. If this returns false,
52     * the display list should be re-recorded prior to replaying it.
53     *
54     * @return boolean true if the display list is able to be replayed, false otherwise.
55     */
56    public abstract boolean isValid();
57
58    /**
59     * Return the amount of memory used by this display list.
60     *
61     * @return The size of this display list in bytes
62     */
63    public abstract int getSize();
64}
65