Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -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 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_HWUI_DISPLAY_LIST_RENDERER_H |
| 18 | #define ANDROID_HWUI_DISPLAY_LIST_RENDERER_H |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 19 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 20 | #include <SkMatrix.h> |
| 21 | #include <SkPaint.h> |
| 22 | #include <SkPath.h> |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 23 | #include <cutils/compiler.h> |
| 24 | |
Chet Haase | 9c1e23b | 2011-03-24 10:51:31 -0700 | [diff] [blame] | 25 | #include "DisplayListLogBuffer.h" |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 26 | #include "OpenGLRenderer.h" |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 27 | #include "RenderNode.h" |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 28 | |
| 29 | namespace android { |
| 30 | namespace uirenderer { |
| 31 | |
| 32 | /////////////////////////////////////////////////////////////////////////////// |
| 33 | // Defines |
| 34 | /////////////////////////////////////////////////////////////////////////////// |
| 35 | |
Romain Guy | ffac7fc | 2011-01-13 17:21:49 -0800 | [diff] [blame] | 36 | // Debug |
| 37 | #if DEBUG_DISPLAY_LIST |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 38 | #define DISPLAY_LIST_LOGD(...) ALOGD(__VA_ARGS__) |
Romain Guy | ffac7fc | 2011-01-13 17:21:49 -0800 | [diff] [blame] | 39 | #else |
| 40 | #define DISPLAY_LIST_LOGD(...) |
| 41 | #endif |
| 42 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 43 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 44 | // Display list |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 45 | /////////////////////////////////////////////////////////////////////////////// |
| 46 | |
Chris Craik | c3566d0 | 2013-02-04 16:16:33 -0800 | [diff] [blame] | 47 | class DeferredDisplayList; |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 48 | class DisplayListRenderer; |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 49 | class DisplayListOp; |
| 50 | class DrawOp; |
| 51 | class StateOp; |
| 52 | |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 53 | /** |
Chris Craik | d6b65f6 | 2014-01-01 14:45:21 -0800 | [diff] [blame] | 54 | * Records drawing commands in a display list for later playback into an OpenGLRenderer. |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 55 | */ |
| 56 | class DisplayListRenderer: public OpenGLRenderer { |
| 57 | public: |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 58 | ANDROID_API DisplayListRenderer(); |
| 59 | virtual ~DisplayListRenderer(); |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 60 | |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 61 | ANDROID_API DisplayListData* finishRecording(); |
Chet Haase | 5977baa | 2011-01-05 18:01:22 -0800 | [diff] [blame] | 62 | |
Chris Craik | 406af02 | 2014-01-02 14:56:40 -0800 | [diff] [blame] | 63 | virtual bool isRecording() const { return true; } |
Romain Guy | 49c5fc0 | 2012-05-15 11:10:01 -0700 | [diff] [blame] | 64 | |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 65 | // ---------------------------------------------------------------------------- |
| 66 | // Frame state operations |
| 67 | // ---------------------------------------------------------------------------- |
Romain Guy | 7c25aab | 2012-10-18 15:05:02 -0700 | [diff] [blame] | 68 | virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque); |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 69 | virtual void finish(); |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 70 | virtual void interrupt(); |
| 71 | virtual void resume(); |
Chet Haase | daf98e9 | 2011-01-10 14:10:36 -0800 | [diff] [blame] | 72 | |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 73 | // ---------------------------------------------------------------------------- |
| 74 | // Canvas state operations |
| 75 | // ---------------------------------------------------------------------------- |
| 76 | // Save (layer) |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 77 | virtual int save(int flags); |
| 78 | virtual void restore(); |
| 79 | virtual void restoreToCount(int saveCount); |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 80 | virtual int saveLayer(float left, float top, float right, float bottom, |
Derek Sollenberger | d44fbe5 | 2014-02-05 16:47:00 -0500 | [diff] [blame] | 81 | const SkPaint* paint, int flags); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 82 | |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 83 | // Matrix |
Chris Craik | b458942 | 2013-12-26 15:13:13 -0800 | [diff] [blame] | 84 | virtual void translate(float dx, float dy, float dz); |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 85 | virtual void rotate(float degrees); |
| 86 | virtual void scale(float sx, float sy); |
| 87 | virtual void skew(float sx, float sy); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 88 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 89 | virtual void setMatrix(const SkMatrix* matrix); |
| 90 | virtual void concatMatrix(const SkMatrix* matrix); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 91 | |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 92 | // Clip |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 93 | virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op); |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 94 | virtual bool clipPath(const SkPath* path, SkRegion::Op op); |
| 95 | virtual bool clipRegion(const SkRegion* region, SkRegion::Op op); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 96 | |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 97 | // Misc - should be implemented with SkPaint inspection |
Romain Guy | 5ff9df6 | 2012-01-23 17:09:05 -0800 | [diff] [blame] | 98 | virtual void resetPaintFilter(); |
| 99 | virtual void setupPaintFilter(int clearBits, int setBits); |
| 100 | |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 101 | // ---------------------------------------------------------------------------- |
| 102 | // Canvas draw operations |
| 103 | // ---------------------------------------------------------------------------- |
| 104 | virtual status_t drawColor(int color, SkXfermode::Mode mode); |
| 105 | |
| 106 | // Bitmap-based |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 107 | virtual status_t drawBitmap(const SkBitmap* bitmap, float left, float top, |
| 108 | const SkPaint* paint); |
| 109 | virtual status_t drawBitmap(const SkBitmap* bitmap, const SkMatrix* matrix, |
| 110 | const SkPaint* paint); |
| 111 | virtual status_t drawBitmap(const SkBitmap* bitmap, float srcLeft, float srcTop, |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 112 | float srcRight, float srcBottom, float dstLeft, float dstTop, |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 113 | float dstRight, float dstBottom, const SkPaint* paint); |
| 114 | virtual status_t drawBitmapData(const SkBitmap* bitmap, float left, float top, |
| 115 | const SkPaint* paint); |
| 116 | virtual status_t drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight, |
| 117 | const float* vertices, const int* colors, const SkPaint* paint); |
| 118 | virtual status_t drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch, |
| 119 | float left, float top, float right, float bottom, const SkPaint* paint); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 120 | |
| 121 | // Shapes |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 122 | virtual status_t drawRect(float left, float top, float right, float bottom, |
| 123 | const SkPaint* paint); |
| 124 | virtual status_t drawRects(const float* rects, int count, const SkPaint* paint); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 125 | virtual status_t drawRoundRect(float left, float top, float right, float bottom, |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 126 | float rx, float ry, const SkPaint* paint); |
| 127 | virtual status_t drawCircle(float x, float y, float radius, const SkPaint* paint); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 128 | virtual status_t drawCircle(CanvasPropertyPrimitive* x, CanvasPropertyPrimitive* y, |
| 129 | CanvasPropertyPrimitive* radius, CanvasPropertyPaint* paint); |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 130 | virtual status_t drawOval(float left, float top, float right, float bottom, |
| 131 | const SkPaint* paint); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 132 | virtual status_t drawArc(float left, float top, float right, float bottom, |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 133 | float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint); |
| 134 | virtual status_t drawPath(const SkPath* path, const SkPaint* paint); |
| 135 | virtual status_t drawLines(const float* points, int count, const SkPaint* paint); |
| 136 | virtual status_t drawPoints(const float* points, int count, const SkPaint* paint); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 137 | |
| 138 | // Text |
| 139 | virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y, |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 140 | const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds, |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 141 | DrawOpMode drawOpMode = kDrawOpMode_Immediate); |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 142 | virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path, |
| 143 | float hOffset, float vOffset, const SkPaint* paint); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 144 | virtual status_t drawPosText(const char* text, int bytesCount, int count, |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 145 | const float* positions, const SkPaint* paint); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 146 | |
| 147 | // ---------------------------------------------------------------------------- |
| 148 | // Canvas draw operations - special |
| 149 | // ---------------------------------------------------------------------------- |
| 150 | virtual status_t drawLayer(Layer* layer, float x, float y); |
John Reck | e18264b | 2014-03-12 13:56:30 -0700 | [diff] [blame] | 151 | virtual status_t drawDisplayList(RenderNode* displayList, Rect& dirty, |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 152 | int32_t replayFlags); |
| 153 | |
| 154 | // TODO: rename for consistency |
| 155 | virtual status_t callDrawGLFunction(Functor* functor, Rect& dirty); |
| 156 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 157 | private: |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 158 | void insertRestoreToCount(); |
| 159 | void insertTranslate(); |
Romain Guy | 27454a4 | 2011-01-23 12:01:41 -0800 | [diff] [blame] | 160 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 161 | LinearAllocator& alloc() { return mDisplayListData->allocator; } |
| 162 | void addStateOp(StateOp* op); |
Romain Guy | 0f66753 | 2013-03-01 14:31:04 -0800 | [diff] [blame] | 163 | void addDrawOp(DrawOp* op); |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 164 | void addOpInternal(DisplayListOp* op) { |
Romain Guy | 27454a4 | 2011-01-23 12:01:41 -0800 | [diff] [blame] | 165 | insertRestoreToCount(); |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 166 | insertTranslate(); |
| 167 | mDisplayListData->displayListOps.add(op); |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 170 | template<class T> |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 171 | inline const T* refBuffer(const T* srcBuffer, int32_t count) { |
| 172 | if (!srcBuffer) return NULL; |
| 173 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 174 | T* dstBuffer = (T*) mDisplayListData->allocator.alloc(count * sizeof(T)); |
| 175 | memcpy(dstBuffer, srcBuffer, count * sizeof(T)); |
| 176 | return dstBuffer; |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 177 | } |
| 178 | |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 179 | inline char* refText(const char* text, size_t byteLength) { |
| 180 | return (char*) refBuffer<uint8_t>((uint8_t*)text, byteLength); |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 181 | } |
| 182 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 183 | inline const SkPath* refPath(const SkPath* path) { |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 184 | if (!path) return NULL; |
Romain Guy | 2fc941e | 2011-02-03 15:06:05 -0800 | [diff] [blame] | 185 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 186 | const SkPath* pathCopy = mPathMap.valueFor(path); |
Romain Guy | 2fc941e | 2011-02-03 15:06:05 -0800 | [diff] [blame] | 187 | if (pathCopy == NULL || pathCopy->getGenerationID() != path->getGenerationID()) { |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 188 | SkPath* newPathCopy = new SkPath(*path); |
| 189 | newPathCopy->setSourcePath(path); |
| 190 | |
| 191 | pathCopy = newPathCopy; |
Romain Guy | 96ebc6b | 2012-02-21 18:32:32 -0800 | [diff] [blame] | 192 | // replaceValueFor() performs an add if the entry doesn't exist |
| 193 | mPathMap.replaceValueFor(path, pathCopy); |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 194 | mDisplayListData->paths.add(pathCopy); |
Romain Guy | 2fc941e | 2011-02-03 15:06:05 -0800 | [diff] [blame] | 195 | } |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 196 | if (mDisplayListData->sourcePaths.indexOf(path) < 0) { |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 197 | mCaches.resourceCache.incrementRefcount(path); |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 198 | mDisplayListData->sourcePaths.add(path); |
Chet Haase | d34dd71 | 2012-05-02 18:50:34 -0700 | [diff] [blame] | 199 | } |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 200 | return pathCopy; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 203 | inline const SkPaint* refPaint(const SkPaint* paint) { |
Romain Guy | 24c0021 | 2011-01-14 15:31:00 -0800 | [diff] [blame] | 204 | if (!paint) { |
Chet Haase | e816bae | 2012-08-09 13:39:02 -0700 | [diff] [blame] | 205 | return paint; |
Chet Haase | d98aa2d | 2010-10-25 15:47:32 -0700 | [diff] [blame] | 206 | } |
Romain Guy | 0fe478e | 2010-11-08 12:08:41 -0800 | [diff] [blame] | 207 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 208 | const SkPaint* paintCopy = mPaintMap.valueFor(paint); |
Chet Haase | d98aa2d | 2010-10-25 15:47:32 -0700 | [diff] [blame] | 209 | if (paintCopy == NULL || paintCopy->getGenerationID() != paint->getGenerationID()) { |
| 210 | paintCopy = new SkPaint(*paint); |
Romain Guy | 96ebc6b | 2012-02-21 18:32:32 -0800 | [diff] [blame] | 211 | // replaceValueFor() performs an add if the entry doesn't exist |
| 212 | mPaintMap.replaceValueFor(paint, paintCopy); |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 213 | mDisplayListData->paints.add(paintCopy); |
Chet Haase | d98aa2d | 2010-10-25 15:47:32 -0700 | [diff] [blame] | 214 | } |
Romain Guy | 0fe478e | 2010-11-08 12:08:41 -0800 | [diff] [blame] | 215 | |
Chet Haase | e816bae | 2012-08-09 13:39:02 -0700 | [diff] [blame] | 216 | return paintCopy; |
Romain Guy | 0fe478e | 2010-11-08 12:08:41 -0800 | [diff] [blame] | 217 | } |
| 218 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 219 | inline const SkRegion* refRegion(const SkRegion* region) { |
Romain Guy | 735738c | 2012-12-03 12:34:51 -0800 | [diff] [blame] | 220 | if (!region) { |
Romain Guy | 735738c | 2012-12-03 12:34:51 -0800 | [diff] [blame] | 221 | return region; |
| 222 | } |
| 223 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 224 | const SkRegion* regionCopy = mRegionMap.valueFor(region); |
Romain Guy | 735738c | 2012-12-03 12:34:51 -0800 | [diff] [blame] | 225 | // TODO: Add generation ID to SkRegion |
| 226 | if (regionCopy == NULL) { |
| 227 | regionCopy = new SkRegion(*region); |
| 228 | // replaceValueFor() performs an add if the entry doesn't exist |
| 229 | mRegionMap.replaceValueFor(region, regionCopy); |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 230 | mDisplayListData->regions.add(regionCopy); |
Romain Guy | 735738c | 2012-12-03 12:34:51 -0800 | [diff] [blame] | 231 | } |
| 232 | |
Romain Guy | 735738c | 2012-12-03 12:34:51 -0800 | [diff] [blame] | 233 | return regionCopy; |
| 234 | } |
| 235 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 236 | inline const SkMatrix* refMatrix(const SkMatrix* matrix) { |
Romain Guy | 4e7b772 | 2013-07-16 13:47:01 -0700 | [diff] [blame] | 237 | if (matrix) { |
| 238 | // Copying the matrix is cheap and prevents against the user changing |
| 239 | // the original matrix before the operation that uses it |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 240 | const SkMatrix* copy = new SkMatrix(*matrix); |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 241 | mDisplayListData->matrices.add(copy); |
Romain Guy | 4e7b772 | 2013-07-16 13:47:01 -0700 | [diff] [blame] | 242 | return copy; |
| 243 | } |
| 244 | return matrix; |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 245 | } |
| 246 | |
Romain Guy | ce4a7df | 2013-03-28 11:32:33 -0700 | [diff] [blame] | 247 | inline Layer* refLayer(Layer* layer) { |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 248 | mDisplayListData->layers.add(layer); |
Romain Guy | ce4a7df | 2013-03-28 11:32:33 -0700 | [diff] [blame] | 249 | mCaches.resourceCache.incrementRefcount(layer); |
| 250 | return layer; |
| 251 | } |
| 252 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 253 | inline const SkBitmap* refBitmap(const SkBitmap* bitmap) { |
Chet Haase | d98aa2d | 2010-10-25 15:47:32 -0700 | [diff] [blame] | 254 | // Note that this assumes the bitmap is immutable. There are cases this won't handle |
| 255 | // correctly, such as creating the bitmap from scratch, drawing with it, changing its |
| 256 | // contents, and drawing again. The only fix would be to always copy it the first time, |
| 257 | // which doesn't seem worth the extra cycles for this unlikely case. |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 258 | mDisplayListData->bitmapResources.add(bitmap); |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 259 | mCaches.resourceCache.incrementRefcount(bitmap); |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 260 | return bitmap; |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 261 | } |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 262 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 263 | inline const SkBitmap* refBitmapData(const SkBitmap* bitmap) { |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 264 | mDisplayListData->ownedBitmapResources.add(bitmap); |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 265 | mCaches.resourceCache.incrementRefcount(bitmap); |
Chris Craik | 2af4635 | 2012-11-26 18:30:17 -0800 | [diff] [blame] | 266 | return bitmap; |
Romain Guy | 49c5fc0 | 2012-05-15 11:10:01 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 269 | inline const Res_png_9patch* refPatch(const Res_png_9patch* patch) { |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 270 | mDisplayListData->patchResources.add(patch); |
Romain Guy | e3b0a01 | 2013-06-26 15:45:41 -0700 | [diff] [blame] | 271 | mCaches.resourceCache.incrementRefcount(patch); |
| 272 | return patch; |
| 273 | } |
| 274 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 275 | DefaultKeyedVector<const SkPaint*, const SkPaint*> mPaintMap; |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 276 | DefaultKeyedVector<const SkPath*, const SkPath*> mPathMap; |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame] | 277 | DefaultKeyedVector<const SkRegion*, const SkRegion*> mRegionMap; |
Romain Guy | 24c0021 | 2011-01-14 15:31:00 -0800 | [diff] [blame] | 278 | |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 279 | Caches& mCaches; |
John Reck | 44fd8d2 | 2014-02-26 11:00:11 -0800 | [diff] [blame] | 280 | DisplayListData* mDisplayListData; |
Romain Guy | 58ecc20 | 2012-09-07 11:58:36 -0700 | [diff] [blame] | 281 | |
Romain Guy | 33f6beb | 2012-02-16 19:24:51 -0800 | [diff] [blame] | 282 | float mTranslateX; |
| 283 | float mTranslateY; |
| 284 | bool mHasTranslate; |
Romain Guy | 54c1a64 | 2012-09-27 17:55:46 -0700 | [diff] [blame] | 285 | |
Chris Craik | eea6ef9 | 2014-03-05 16:37:35 -0800 | [diff] [blame] | 286 | int mRestoreSaveCount; |
| 287 | |
John Reck | e18264b | 2014-03-12 13:56:30 -0700 | [diff] [blame] | 288 | friend class RenderNode; |
Romain Guy | b051e89 | 2010-09-28 19:09:36 -0700 | [diff] [blame] | 289 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 290 | }; // class DisplayListRenderer |
| 291 | |
| 292 | }; // namespace uirenderer |
| 293 | }; // namespace android |
| 294 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 295 | #endif // ANDROID_HWUI_DISPLAY_LIST_RENDERER_H |