DisplayList.java revision 33f6beb10f98e8ba96250e284876d607055d278d
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 * Flag used when calling 31 * {@link HardwareCanvas#drawDisplayList(DisplayList, int, int, android.graphics.Rect, int)}. 32 * When this flag is set, draw operations lying outside of the bounds of the 33 * display list will be culled early. It is recommeneded to always set this 34 * flag. 35 */ 36 public static final int FLAG_CLIP_CHILDREN = 0x1; 37 38 /** 39 * Starts recording the display list. All operations performed on the 40 * returned canvas are recorded and stored in this display list. 41 * 42 * @return A canvas to record drawing operations. 43 */ 44 public abstract HardwareCanvas start(); 45 46 /** 47 * Ends the recording for this display list. A display list cannot be 48 * replayed if recording is not finished. 49 */ 50 public abstract void end(); 51 52 /** 53 * Invalidates the display list, indicating that it should be repopulated 54 * with new drawing commands prior to being used again. Calling this method 55 * causes calls to {@link #isValid()} to return <code>false</code>. 56 */ 57 public abstract void invalidate(); 58 59 /** 60 * Returns whether the display list is currently usable. If this returns false, 61 * the display list should be re-recorded prior to replaying it. 62 * 63 * @return boolean true if the display list is able to be replayed, false otherwise. 64 */ 65 public abstract boolean isValid(); 66 67 /** 68 * Return the amount of memory used by this display list. 69 * 70 * @return The size of this display list in bytes 71 */ 72 public abstract int getSize(); 73} 74