Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 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 | |
| 17 | package android.view; |
| 18 | |
| 19 | import android.graphics.Bitmap; |
| 20 | import android.graphics.Canvas; |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 21 | import android.graphics.Paint; |
Romain Guy | 7d7b549 | 2011-01-24 16:33:45 -0800 | [diff] [blame] | 22 | import android.graphics.Rect; |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 25 | * Hardware accelerated canvas. |
| 26 | * |
| 27 | * @hide |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 28 | */ |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 29 | public abstract class HardwareCanvas extends Canvas { |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 30 | @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 Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 41 | * Invoked before any drawing operation is performed in this canvas. |
Romain Guy | 7d7b549 | 2011-01-24 16:33:45 -0800 | [diff] [blame] | 42 | * |
| 43 | * @param dirty The dirty rectangle to update, can be null. |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 44 | */ |
Romain Guy | 7d7b549 | 2011-01-24 16:33:45 -0800 | [diff] [blame] | 45 | abstract void onPreDraw(Rect dirty); |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 46 | |
| 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 Guy | 7b5b6ab | 2011-03-14 18:05:08 -0700 | [diff] [blame] | 56 | * @param width The width of the display list. |
| 57 | * @param height The height of the display list. |
Romain Guy | cabfcc1 | 2011-03-07 18:06:46 -0800 | [diff] [blame] | 58 | * @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 Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 63 | */ |
Romain Guy | 7b5b6ab | 2011-03-14 18:05:08 -0700 | [diff] [blame] | 64 | abstract boolean drawDisplayList(DisplayList displayList, int width, int height, Rect dirty); |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 65 | |
| 66 | /** |
Chet Haase | ed30fd8 | 2011-04-22 16:18:45 -0700 | [diff] [blame] | 67 | * 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 Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 75 | * Draws the specified layer onto this canvas. |
| 76 | * |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 77 | * @param layer The layer to composite on this canvas |
Romain Guy | ada830f | 2011-01-13 12:13:20 -0800 | [diff] [blame] | 78 | * @param x The left coordinate of the layer |
| 79 | * @param y The top coordinate of the layer |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 80 | * @param paint The paint used to draw the layer |
| 81 | */ |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 82 | 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 Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 96 | } |