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