blob: 23b3abcc3cd6f38e97be20eea8307bb44558a495 [file] [log] [blame]
Romain Guyb051e892010-09-28 19:09:36 -07001/*
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
19import android.graphics.Bitmap;
20import android.graphics.Canvas;
Romain Guy6c319ca2011-01-11 14:29:25 -080021import android.graphics.Paint;
Romain Guy7d7b5492011-01-24 16:33:45 -080022import android.graphics.Rect;
Romain Guyb051e892010-09-28 19:09:36 -070023
24/**
Chet Haasedaf98e92011-01-10 14:10:36 -080025 * Hardware accelerated canvas.
26 *
27 * @hide
Romain Guyb051e892010-09-28 19:09:36 -070028 */
Chet Haasedaf98e92011-01-10 14:10:36 -080029public abstract class HardwareCanvas extends Canvas {
Romain Guyb051e892010-09-28 19:09:36 -070030 @Override
31 public boolean isHardwareAccelerated() {
32 return true;
33 }
34
35 @Override
36 public void setBitmap(Bitmap bitmap) {
37 throw new UnsupportedOperationException();
38 }
39
40 /**
Romain Guyb051e892010-09-28 19:09:36 -070041 * Invoked before any drawing operation is performed in this canvas.
Romain Guy7d7b5492011-01-24 16:33:45 -080042 *
43 * @param dirty The dirty rectangle to update, can be null.
Romain Guyb051e892010-09-28 19:09:36 -070044 */
Romain Guy7d7b5492011-01-24 16:33:45 -080045 abstract void onPreDraw(Rect dirty);
Romain Guyb051e892010-09-28 19:09:36 -070046
47 /**
48 * Invoked after all drawing operation have been performed.
49 */
50 abstract void onPostDraw();
51
52 /**
53 * Draws the specified display list onto this canvas.
54 *
55 * @param displayList The display list to replay.
Romain Guy7b5b6ab2011-03-14 18:05:08 -070056 * @param width The width of the display list.
57 * @param height The height of the display list.
Romain Guycabfcc12011-03-07 18:06:46 -080058 * @param dirty The dirty region to redraw in the next pass, matters only
59 * if this method returns true, can be null.
60 *
61 * @return True if the content of the display list requires another
62 * drawing pass (invalidate()), false otherwise
Romain Guyb051e892010-09-28 19:09:36 -070063 */
Romain Guy7b5b6ab2011-03-14 18:05:08 -070064 abstract boolean drawDisplayList(DisplayList displayList, int width, int height, Rect dirty);
Romain Guy6c319ca2011-01-11 14:29:25 -080065
66 /**
Chet Haaseed30fd82011-04-22 16:18:45 -070067 * Outputs the specified display list to the log. This method exists for use by
68 * tools to output display lists for selected nodes to the log.
69 *
70 * @param displayList The display list to be logged.
71 */
72 abstract void outputDisplayList(DisplayList displayList);
73
74 /**
Romain Guy6c319ca2011-01-11 14:29:25 -080075 * Draws the specified layer onto this canvas.
76 *
Romain Guy6c319ca2011-01-11 14:29:25 -080077 * @param layer The layer to composite on this canvas
Romain Guyada830f2011-01-13 12:13:20 -080078 * @param x The left coordinate of the layer
79 * @param y The top coordinate of the layer
Romain Guy6c319ca2011-01-11 14:29:25 -080080 * @param paint The paint used to draw the layer
81 */
Chet Haasedaf98e92011-01-10 14:10:36 -080082 abstract void drawHardwareLayer(HardwareLayer layer, float x, float y, Paint paint);
83
84 /**
85 * Calls the function specified with the drawGLFunction function pointer. This is
86 * functionality used by webkit for calling into their renderer from our display lists.
87 * This function may return true if an invalidation is needed after the call.
88 *
89 * @param drawGLFunction A native function pointer
90 * @return true if an invalidate is needed after the call, false otherwise
91 */
92 public boolean callDrawGLFunction(int drawGLFunction) {
93 // Noop - this is done in the display list recorder subclass
94 return false;
95 }
Romain Guyb051e892010-09-28 19:09:36 -070096}