| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 |  | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 2 | /* | 
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 |  * Copyright 2011 Google Inc. | 
 | 4 |  * | 
 | 5 |  * Use of this source code is governed by a BSD-style license that can be | 
 | 6 |  * found in the LICENSE file. | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 7 |  */ | 
 | 8 |  | 
 | 9 |  | 
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 |  | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 11 | #ifndef SkGPipePriv_DEFINED | 
 | 12 | #define SkGPipePriv_DEFINED | 
 | 13 |  | 
 | 14 | #include "SkTypes.h" | 
 | 15 |  | 
 | 16 | #define UNIMPLEMENTED | 
 | 17 |  | 
| reed@google.com | b55d118 | 2011-05-11 00:42:04 +0000 | [diff] [blame] | 18 | // these must be contiguous, 0...N-1 | 
 | 19 | enum PaintFlats { | 
 | 20 |     kColorFilter_PaintFlat, | 
| reed@google.com | 0faac1e | 2011-05-11 05:58:58 +0000 | [diff] [blame] | 21 |     kDrawLooper_PaintFlat, | 
| reed@google.com | b55d118 | 2011-05-11 00:42:04 +0000 | [diff] [blame] | 22 |     kMaskFilter_PaintFlat, | 
 | 23 |     kPathEffect_PaintFlat, | 
 | 24 |     kRasterizer_PaintFlat, | 
 | 25 |     kShader_PaintFlat, | 
| scroggo@google.com | 16d1d0b | 2012-05-02 19:09:40 +0000 | [diff] [blame] | 26 |     kImageFilter_PaintFlat, | 
| reed@google.com | b55d118 | 2011-05-11 00:42:04 +0000 | [diff] [blame] | 27 |     kXfermode_PaintFlat, | 
 | 28 |  | 
| reed@google.com | 0cd2ac6 | 2013-10-14 20:02:44 +0000 | [diff] [blame^] | 29 |     kLast_PaintFlat = kXfermode_PaintFlat | 
| reed@google.com | b55d118 | 2011-05-11 00:42:04 +0000 | [diff] [blame] | 30 | }; | 
 | 31 | #define kCount_PaintFlats   (kLast_PaintFlat + 1) | 
 | 32 |  | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 33 | enum DrawOps { | 
| reed@google.com | acd471f | 2011-05-03 21:26:46 +0000 | [diff] [blame] | 34 |     kSkip_DrawOp,   // skip an addition N bytes (N == data) | 
 | 35 |  | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 36 |     // these match Canvas apis | 
 | 37 |     kClipPath_DrawOp, | 
 | 38 |     kClipRegion_DrawOp, | 
 | 39 |     kClipRect_DrawOp, | 
| reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 40 |     kClipRRect_DrawOp, | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 41 |     kConcat_DrawOp, | 
 | 42 |     kDrawBitmap_DrawOp, | 
 | 43 |     kDrawBitmapMatrix_DrawOp, | 
| scroggo@google.com | 16d1d0b | 2012-05-02 19:09:40 +0000 | [diff] [blame] | 44 |     kDrawBitmapNine_DrawOp, | 
| reed@google.com | 7112173 | 2012-09-18 15:14:33 +0000 | [diff] [blame] | 45 |     kDrawBitmapRectToRect_DrawOp, | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 46 |     kDrawClear_DrawOp, | 
 | 47 |     kDrawData_DrawOp, | 
| reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 48 |     kDrawOval_DrawOp, | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 49 |     kDrawPaint_DrawOp, | 
 | 50 |     kDrawPath_DrawOp, | 
 | 51 |     kDrawPicture_DrawOp, | 
 | 52 |     kDrawPoints_DrawOp, | 
 | 53 |     kDrawPosText_DrawOp, | 
 | 54 |     kDrawPosTextH_DrawOp, | 
 | 55 |     kDrawRect_DrawOp, | 
| reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 56 |     kDrawRRect_DrawOp, | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 57 |     kDrawSprite_DrawOp, | 
 | 58 |     kDrawText_DrawOp, | 
 | 59 |     kDrawTextOnPath_DrawOp, | 
 | 60 |     kDrawVertices_DrawOp, | 
 | 61 |     kRestore_DrawOp, | 
 | 62 |     kRotate_DrawOp, | 
 | 63 |     kSave_DrawOp, | 
 | 64 |     kSaveLayer_DrawOp, | 
 | 65 |     kScale_DrawOp, | 
 | 66 |     kSetMatrix_DrawOp, | 
 | 67 |     kSkew_DrawOp, | 
 | 68 |     kTranslate_DrawOp, | 
 | 69 |  | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 70 |     kPaintOp_DrawOp, | 
| scroggo@google.com | 3cb969f | 2012-07-27 20:39:19 +0000 | [diff] [blame] | 71 |     kSetTypeface_DrawOp, | 
| reed@google.com | 0cd2ac6 | 2013-10-14 20:02:44 +0000 | [diff] [blame^] | 72 |     kSetAnnotation_DrawOp, | 
| reed@google.com | bb6793b | 2011-05-05 15:18:15 +0000 | [diff] [blame] | 73 |  | 
| reed@google.com | bb6793b | 2011-05-05 15:18:15 +0000 | [diff] [blame] | 74 |     kDef_Typeface_DrawOp, | 
| reed@google.com | 0faac1e | 2011-05-11 05:58:58 +0000 | [diff] [blame] | 75 |     kDef_Flattenable_DrawOp, | 
| scroggo@google.com | 16d1d0b | 2012-05-02 19:09:40 +0000 | [diff] [blame] | 76 |     kDef_Bitmap_DrawOp, | 
| scroggo@google.com | 0c3e5fe | 2012-08-01 19:34:20 +0000 | [diff] [blame] | 77 |     kDef_Factory_DrawOp, | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 78 |  | 
 | 79 |     // these are signals to playback, not drawing verbs | 
| scroggo@google.com | 565254b | 2012-06-28 15:41:32 +0000 | [diff] [blame] | 80 |     kReportFlags_DrawOp, | 
| scroggo@google.com | d9d2967 | 2012-08-14 17:21:34 +0000 | [diff] [blame] | 81 |     kShareBitmapHeap_DrawOp, | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 82 |     kDone_DrawOp, | 
 | 83 | }; | 
 | 84 |  | 
 | 85 | /** | 
 | 86 |  *  DrawOp packs into a 32bit int as follows | 
 | 87 |  * | 
 | 88 |  *  DrawOp:8 - Flags:4 - Data:20 | 
 | 89 |  * | 
 | 90 |  *  Flags and Data are called out separately, so we can reuse Data between | 
 | 91 |  *  different Ops that might have different Flags. e.g. Data might be a Paint | 
 | 92 |  *  index for both drawRect (no flags) and saveLayer (does have flags). | 
 | 93 |  * | 
 | 94 |  *  All Ops that take a SkPaint use their Data field to store the index to | 
 | 95 |  *  the paint (previously defined with kPaintOp_DrawOp). | 
 | 96 |  */ | 
 | 97 |  | 
 | 98 | #define DRAWOPS_OP_BITS     8 | 
 | 99 | #define DRAWOPS_FLAG_BITS   4 | 
 | 100 | #define DRAWOPS_DATA_BITS   20 | 
 | 101 |  | 
 | 102 | #define DRAWOPS_OP_MASK     ((1 << DRAWOPS_OP_BITS) - 1) | 
 | 103 | #define DRAWOPS_FLAG_MASK   ((1 << DRAWOPS_FLAG_BITS) - 1) | 
 | 104 | #define DRAWOPS_DATA_MASK   ((1 << DRAWOPS_DATA_BITS) - 1) | 
 | 105 |  | 
| caryclark@google.com | 920901d | 2012-06-06 12:04:11 +0000 | [diff] [blame] | 106 | static inline unsigned DrawOp_unpackOp(uint32_t op32) { | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 107 |     return (op32 >> (DRAWOPS_FLAG_BITS + DRAWOPS_DATA_BITS)); | 
 | 108 | } | 
 | 109 |  | 
| caryclark@google.com | 920901d | 2012-06-06 12:04:11 +0000 | [diff] [blame] | 110 | static inline unsigned DrawOp_unpackFlags(uint32_t op32) { | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 111 |     return (op32 >> DRAWOPS_DATA_BITS) & DRAWOPS_FLAG_MASK; | 
 | 112 | } | 
 | 113 |  | 
| caryclark@google.com | 920901d | 2012-06-06 12:04:11 +0000 | [diff] [blame] | 114 | static inline unsigned DrawOp_unpackData(uint32_t op32) { | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 115 |     return op32 & DRAWOPS_DATA_MASK; | 
 | 116 | } | 
 | 117 |  | 
| caryclark@google.com | 920901d | 2012-06-06 12:04:11 +0000 | [diff] [blame] | 118 | static inline uint32_t DrawOp_packOpFlagData(DrawOps op, unsigned flags, unsigned data) { | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 119 |     SkASSERT(0 == (op & ~DRAWOPS_OP_MASK)); | 
 | 120 |     SkASSERT(0 == (flags & ~DRAWOPS_FLAG_MASK)); | 
 | 121 |     SkASSERT(0 == (data & ~DRAWOPS_DATA_MASK)); | 
 | 122 |  | 
| reed@google.com | 67908f2 | 2011-06-27 14:47:50 +0000 | [diff] [blame] | 123 |     return (op << (DRAWOPS_FLAG_BITS + DRAWOPS_DATA_BITS)) | | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 124 |            (flags << DRAWOPS_DATA_BITS) | | 
 | 125 |             data; | 
 | 126 | } | 
 | 127 |  | 
 | 128 | /** DrawOp specific flag bits | 
 | 129 |  */ | 
 | 130 |  | 
 | 131 | enum { | 
 | 132 |     kSaveLayer_HasBounds_DrawOpFlag = 1 << 0, | 
 | 133 |     kSaveLayer_HasPaint_DrawOpFlag = 1 << 1, | 
 | 134 | }; | 
 | 135 | enum { | 
 | 136 |     kClear_HasColor_DrawOpFlag  = 1 << 0 | 
 | 137 | }; | 
 | 138 | enum { | 
 | 139 |     kDrawTextOnPath_HasMatrix_DrawOpFlag = 1 << 0 | 
 | 140 | }; | 
 | 141 | enum { | 
 | 142 |     kDrawVertices_HasTexs_DrawOpFlag     = 1 << 0, | 
 | 143 |     kDrawVertices_HasColors_DrawOpFlag   = 1 << 1, | 
 | 144 |     kDrawVertices_HasIndices_DrawOpFlag  = 1 << 2, | 
 | 145 | }; | 
| scroggo@google.com | 58be682 | 2012-07-30 14:40:01 +0000 | [diff] [blame] | 146 | enum { | 
| scroggo@google.com | 460a23e | 2012-08-16 17:56:49 +0000 | [diff] [blame] | 147 |     kDrawBitmap_HasPaint_DrawOpFlag   = 1 << 0, | 
| scroggo@google.com | 58be682 | 2012-07-30 14:40:01 +0000 | [diff] [blame] | 148 |     // Specific to drawBitmapRect, but needs to be different from HasPaint, | 
 | 149 |     // which is used for all drawBitmap calls, so include it here. | 
| scroggo@google.com | 460a23e | 2012-08-16 17:56:49 +0000 | [diff] [blame] | 150 |     kDrawBitmap_HasSrcRect_DrawOpFlag = 1 << 1, | 
| skia.committer@gmail.com | 7475811 | 2013-08-17 07:01:54 +0000 | [diff] [blame] | 151 |     // SkCanvas::DrawBitmapRectFlags::kBleed_DrawBitmapRectFlag is | 
| commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 152 |     // converted into and out of this flag to save space | 
 | 153 |     kDrawBitmap_Bleed_DrawOpFlag      = 1 << 2, | 
| scroggo@google.com | 58be682 | 2012-07-30 14:40:01 +0000 | [diff] [blame] | 154 | }; | 
| scroggo@google.com | 460a23e | 2012-08-16 17:56:49 +0000 | [diff] [blame] | 155 | enum { | 
 | 156 |     kClip_HasAntiAlias_DrawOpFlag = 1 << 0, | 
 | 157 | }; | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 158 | /////////////////////////////////////////////////////////////////////////////// | 
 | 159 |  | 
| scroggo@google.com | 284bf50 | 2012-07-17 16:10:34 +0000 | [diff] [blame] | 160 | class BitmapInfo : SkNoncopyable { | 
 | 161 | public: | 
 | 162 |     BitmapInfo(SkBitmap* bitmap, uint32_t genID, int toBeDrawnCount) | 
 | 163 |         : fBitmap(bitmap) | 
 | 164 |         , fGenID(genID) | 
| scroggo@google.com | 15011ee | 2012-07-26 20:03:32 +0000 | [diff] [blame] | 165 |         , fBytesAllocated(0) | 
| scroggo@google.com | 284bf50 | 2012-07-17 16:10:34 +0000 | [diff] [blame] | 166 |         , fMoreRecentlyUsed(NULL) | 
 | 167 |         , fLessRecentlyUsed(NULL) | 
 | 168 |         , fToBeDrawnCount(toBeDrawnCount) | 
 | 169 |     {} | 
 | 170 |  | 
 | 171 |     ~BitmapInfo() { | 
 | 172 |         SkASSERT(0 == fToBeDrawnCount); | 
 | 173 |         SkDELETE(fBitmap); | 
 | 174 |     } | 
 | 175 |  | 
 | 176 |     void addDraws(int drawsToAdd) { | 
 | 177 |         if (0 == fToBeDrawnCount) { | 
 | 178 |             // The readers will only ever decrement the count, so once the | 
 | 179 |             // count is zero, the writer will be the only one modifying it, | 
 | 180 |             // so it does not need to be an atomic operation. | 
 | 181 |             fToBeDrawnCount = drawsToAdd; | 
 | 182 |         } else { | 
 | 183 |             sk_atomic_add(&fToBeDrawnCount, drawsToAdd); | 
 | 184 |         } | 
 | 185 |     } | 
 | 186 |  | 
 | 187 |     void decDraws() { | 
 | 188 |         sk_atomic_dec(&fToBeDrawnCount); | 
 | 189 |     } | 
 | 190 |  | 
 | 191 |     int drawCount() const { | 
 | 192 |         return fToBeDrawnCount; | 
 | 193 |     } | 
 | 194 |  | 
 | 195 |     SkBitmap* fBitmap; | 
 | 196 |     // Store the generation ID of the original bitmap, since copying does | 
 | 197 |     // not copy this field, so fBitmap's generation ID will not be useful | 
 | 198 |     // for comparing. | 
| scroggo@google.com | 15011ee | 2012-07-26 20:03:32 +0000 | [diff] [blame] | 199 |     // FIXME: Is it reasonable to make copying a bitmap/pixelref copy the | 
 | 200 |     // generation ID? | 
| scroggo@google.com | 284bf50 | 2012-07-17 16:10:34 +0000 | [diff] [blame] | 201 |     uint32_t fGenID; | 
| scroggo@google.com | 15011ee | 2012-07-26 20:03:32 +0000 | [diff] [blame] | 202 |     // Keep track of the bytes allocated for this bitmap. When replacing the | 
 | 203 |     // bitmap or removing this BitmapInfo we know how much memory has been | 
 | 204 |     // reclaimed. | 
 | 205 |     size_t fBytesAllocated; | 
| scroggo@google.com | 284bf50 | 2012-07-17 16:10:34 +0000 | [diff] [blame] | 206 |     // TODO: Generalize the LRU caching mechanism | 
 | 207 |     BitmapInfo* fMoreRecentlyUsed; | 
 | 208 |     BitmapInfo* fLessRecentlyUsed; | 
 | 209 | private: | 
 | 210 |     int      fToBeDrawnCount; | 
 | 211 | }; | 
 | 212 |  | 
| scroggo@google.com | 565254b | 2012-06-28 15:41:32 +0000 | [diff] [blame] | 213 | static inline bool shouldFlattenBitmaps(uint32_t flags) { | 
| scroggo@google.com | 3cb969f | 2012-07-27 20:39:19 +0000 | [diff] [blame] | 214 |     return SkToBool(flags & SkGPipeWriter::kCrossProcess_Flag | 
 | 215 |             && !(flags & SkGPipeWriter::kSharedAddressSpace_Flag)); | 
| scroggo@google.com | 565254b | 2012-06-28 15:41:32 +0000 | [diff] [blame] | 216 | } | 
 | 217 |  | 
 | 218 | /////////////////////////////////////////////////////////////////////////////// | 
 | 219 |  | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 220 | enum PaintOps { | 
 | 221 |     kReset_PaintOp,     // no arg | 
| rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 222 |  | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 223 |     kFlags_PaintOp,     // arg inline | 
 | 224 |     kColor_PaintOp,     // arg 32 | 
 | 225 |     kStyle_PaintOp,     // arg inline | 
 | 226 |     kJoin_PaintOp,      // arg inline | 
 | 227 |     kCap_PaintOp,       // arg inline | 
 | 228 |     kWidth_PaintOp,     // arg scalar | 
| reed@google.com | 0cd2ac6 | 2013-10-14 20:02:44 +0000 | [diff] [blame^] | 229 |     kMiter_PaintOp,     // arg scalar | 
| rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 230 |  | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 231 |     kEncoding_PaintOp,  // arg inline - text | 
 | 232 |     kHinting_PaintOp,   // arg inline - text | 
 | 233 |     kAlign_PaintOp,     // arg inline - text | 
 | 234 |     kTextSize_PaintOp,  // arg scalar - text | 
 | 235 |     kTextScaleX_PaintOp,// arg scalar - text | 
 | 236 |     kTextSkewX_PaintOp, // arg scalar - text | 
| reed@google.com | f5842f7 | 2011-05-04 18:30:04 +0000 | [diff] [blame] | 237 |     kTypeface_PaintOp,  // arg inline (index) - text | 
 | 238 |  | 
| reed@google.com | 0cd2ac6 | 2013-10-14 20:02:44 +0000 | [diff] [blame^] | 239 |     kAnnotation_PaintOp,// arg SkAnnotation_flat, data=bool-has-size | 
 | 240 |  | 
| reed@google.com | b55d118 | 2011-05-11 00:42:04 +0000 | [diff] [blame] | 241 |     kFlatIndex_PaintOp, // flags=paintflat, data=index | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 242 | }; | 
 | 243 |  | 
 | 244 | #define PAINTOPS_OP_BITS     8 | 
 | 245 | #define PAINTOPS_FLAG_BITS   4 | 
 | 246 | #define PAINTOPS_DATA_BITS   20 | 
 | 247 |  | 
 | 248 | #define PAINTOPS_OP_MASK     ((1 << PAINTOPS_OP_BITS) - 1) | 
 | 249 | #define PAINTOPS_FLAG_MASK   ((1 << PAINTOPS_FLAG_BITS) - 1) | 
 | 250 | #define PAINTOPS_DATA_MASK   ((1 << PAINTOPS_DATA_BITS) - 1) | 
 | 251 |  | 
| caryclark@google.com | 920901d | 2012-06-06 12:04:11 +0000 | [diff] [blame] | 252 | static inline unsigned PaintOp_unpackOp(uint32_t op32) { | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 253 |     return (op32 >> (PAINTOPS_FLAG_BITS + PAINTOPS_DATA_BITS)); | 
 | 254 | } | 
 | 255 |  | 
| caryclark@google.com | 920901d | 2012-06-06 12:04:11 +0000 | [diff] [blame] | 256 | static inline unsigned PaintOp_unpackFlags(uint32_t op32) { | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 257 |     return (op32 >> PAINTOPS_DATA_BITS) & PAINTOPS_FLAG_MASK; | 
 | 258 | } | 
 | 259 |  | 
| caryclark@google.com | 920901d | 2012-06-06 12:04:11 +0000 | [diff] [blame] | 260 | static inline unsigned PaintOp_unpackData(uint32_t op32) { | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 261 |     return op32 & PAINTOPS_DATA_MASK; | 
 | 262 | } | 
 | 263 |  | 
| caryclark@google.com | 920901d | 2012-06-06 12:04:11 +0000 | [diff] [blame] | 264 | static inline uint32_t PaintOp_packOp(PaintOps op) { | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 265 |     SkASSERT(0 == (op & ~PAINTOPS_OP_MASK)); | 
| rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 266 |  | 
| reed@google.com | 67908f2 | 2011-06-27 14:47:50 +0000 | [diff] [blame] | 267 |     return op << (PAINTOPS_FLAG_BITS + PAINTOPS_DATA_BITS); | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 268 | } | 
 | 269 |  | 
| caryclark@google.com | 920901d | 2012-06-06 12:04:11 +0000 | [diff] [blame] | 270 | static inline uint32_t PaintOp_packOpData(PaintOps op, unsigned data) { | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 271 |     SkASSERT(0 == (op & ~PAINTOPS_OP_MASK)); | 
 | 272 |     SkASSERT(0 == (data & ~PAINTOPS_DATA_MASK)); | 
| rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 273 |  | 
| reed@google.com | 67908f2 | 2011-06-27 14:47:50 +0000 | [diff] [blame] | 274 |     return (op << (PAINTOPS_FLAG_BITS + PAINTOPS_DATA_BITS)) | data; | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 275 | } | 
 | 276 |  | 
| caryclark@google.com | 920901d | 2012-06-06 12:04:11 +0000 | [diff] [blame] | 277 | static inline uint32_t PaintOp_packOpFlagData(PaintOps op, unsigned flags, unsigned data) { | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 278 |     SkASSERT(0 == (op & ~PAINTOPS_OP_MASK)); | 
 | 279 |     SkASSERT(0 == (flags & ~PAINTOPS_FLAG_MASK)); | 
 | 280 |     SkASSERT(0 == (data & ~PAINTOPS_DATA_MASK)); | 
| rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 281 |  | 
| reed@google.com | 67908f2 | 2011-06-27 14:47:50 +0000 | [diff] [blame] | 282 |     return (op << (PAINTOPS_FLAG_BITS + PAINTOPS_DATA_BITS)) | | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 283 |     (flags << PAINTOPS_DATA_BITS) | | 
 | 284 |     data; | 
 | 285 | } | 
 | 286 |  | 
| reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame] | 287 | #endif |