blob: caa7b743cd7e5f6dde83cc69ba2632e5060580cc [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 /**
67 * Draws the specified layer onto this canvas.
68 *
Romain Guy6c319ca2011-01-11 14:29:25 -080069 * @param layer The layer to composite on this canvas
Romain Guyada830f2011-01-13 12:13:20 -080070 * @param x The left coordinate of the layer
71 * @param y The top coordinate of the layer
Romain Guy6c319ca2011-01-11 14:29:25 -080072 * @param paint The paint used to draw the layer
73 */
Chet Haasedaf98e92011-01-10 14:10:36 -080074 abstract void drawHardwareLayer(HardwareLayer layer, float x, float y, Paint paint);
75
76 /**
77 * Calls the function specified with the drawGLFunction function pointer. This is
78 * functionality used by webkit for calling into their renderer from our display lists.
79 * This function may return true if an invalidation is needed after the call.
80 *
81 * @param drawGLFunction A native function pointer
82 * @return true if an invalidate is needed after the call, false otherwise
83 */
84 public boolean callDrawGLFunction(int drawGLFunction) {
85 // Noop - this is done in the display list recorder subclass
86 return false;
87 }
Romain Guyb051e892010-09-28 19:09:36 -070088}