| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkRecords_DEFINED | 8 #ifndef SkRecords_DEFINED |
| 9 #define SkRecords_DEFINED | 9 #define SkRecords_DEFINED |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 // Defines SkRecords::Type, an enum of all record types. | 80 // Defines SkRecords::Type, an enum of all record types. |
| 81 #define ENUM(T) T##_Type, | 81 #define ENUM(T) T##_Type, |
| 82 enum Type { SK_RECORD_TYPES(ENUM) }; | 82 enum Type { SK_RECORD_TYPES(ENUM) }; |
| 83 #undef ENUM | 83 #undef ENUM |
| 84 | 84 |
| 85 #define ACT_AS_PTR(ptr) \ | 85 #define ACT_AS_PTR(ptr) \ |
| 86 operator T*() const { return ptr; } \ | 86 operator T*() const { return ptr; } \ |
| 87 T* operator->() const { return ptr; } | 87 T* operator->() const { return ptr; } |
| 88 | 88 |
| 89 template <typename T> | |
| 90 class RefBox : SkNoncopyable { | |
| 91 public: | |
| 92 RefBox() {} | |
| 93 RefBox(T* obj) : fObj(SkSafeRef(obj)) {} | |
| 94 RefBox(RefBox&& o) : fObj(o.fObj) { | |
| 95 o.fObj = nullptr; | |
| 96 } | |
| 97 ~RefBox() { SkSafeUnref(fObj); } | |
| 98 | |
| 99 ACT_AS_PTR(fObj); | |
| 100 | |
| 101 private: | |
| 102 T* fObj; | |
| 103 }; | |
| 104 | |
| 105 // An Optional doesn't own the pointer's memory, but may need to destroy non-POD
data. | 89 // An Optional doesn't own the pointer's memory, but may need to destroy non-POD
data. |
| 106 template <typename T> | 90 template <typename T> |
| 107 class Optional : SkNoncopyable { | 91 class Optional : SkNoncopyable { |
| 108 public: | 92 public: |
| 109 Optional() : fPtr(nullptr) {} | 93 Optional() : fPtr(nullptr) {} |
| 110 Optional(T* ptr) : fPtr(ptr) {} | 94 Optional(T* ptr) : fPtr(ptr) {} |
| 111 Optional(Optional&& o) : fPtr(o.fPtr) { | 95 Optional(Optional&& o) : fPtr(o.fPtr) { |
| 112 o.fPtr = nullptr; | 96 o.fPtr = nullptr; |
| 113 } | 97 } |
| 114 ~Optional() { if (fPtr) fPtr->~T(); } | 98 ~Optional() { if (fPtr) fPtr->~T(); } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 165 |
| 182 RECORD(NoOp, 0); | 166 RECORD(NoOp, 0); |
| 183 RECORD(Restore, 0, | 167 RECORD(Restore, 0, |
| 184 SkIRect devBounds; | 168 SkIRect devBounds; |
| 185 TypedMatrix matrix); | 169 TypedMatrix matrix); |
| 186 RECORD(Save, 0); | 170 RECORD(Save, 0); |
| 187 | 171 |
| 188 RECORD(SaveLayer, 0, | 172 RECORD(SaveLayer, 0, |
| 189 Optional<SkRect> bounds; | 173 Optional<SkRect> bounds; |
| 190 Optional<SkPaint> paint; | 174 Optional<SkPaint> paint; |
| 191 RefBox<const SkImageFilter> backdrop; | 175 sk_sp<const SkImageFilter> backdrop; |
| 192 SkCanvas::SaveLayerFlags saveLayerFlags); | 176 SkCanvas::SaveLayerFlags saveLayerFlags); |
| 193 | 177 |
| 194 RECORD(SetMatrix, 0, | 178 RECORD(SetMatrix, 0, |
| 195 TypedMatrix matrix); | 179 TypedMatrix matrix); |
| 196 RECORD(Concat, 0, | 180 RECORD(Concat, 0, |
| 197 TypedMatrix matrix); | 181 TypedMatrix matrix); |
| 198 | 182 |
| 199 RECORD(TranslateZ, 0, SkScalar z); | 183 RECORD(TranslateZ, 0, SkScalar z); |
| 200 | 184 |
| 201 struct RegionOpAndAA { | 185 struct RegionOpAndAA { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 227 RECORD(DrawDRRect, kDraw_Tag, | 211 RECORD(DrawDRRect, kDraw_Tag, |
| 228 SkPaint paint; | 212 SkPaint paint; |
| 229 SkRRect outer; | 213 SkRRect outer; |
| 230 SkRRect inner); | 214 SkRRect inner); |
| 231 RECORD(DrawDrawable, kDraw_Tag, | 215 RECORD(DrawDrawable, kDraw_Tag, |
| 232 Optional<SkMatrix> matrix; | 216 Optional<SkMatrix> matrix; |
| 233 SkRect worstCaseBounds; | 217 SkRect worstCaseBounds; |
| 234 int32_t index); | 218 int32_t index); |
| 235 RECORD(DrawImage, kDraw_Tag|kHasImage_Tag, | 219 RECORD(DrawImage, kDraw_Tag|kHasImage_Tag, |
| 236 Optional<SkPaint> paint; | 220 Optional<SkPaint> paint; |
| 237 RefBox<const SkImage> image; | 221 sk_sp<const SkImage> image; |
| 238 SkScalar left; | 222 SkScalar left; |
| 239 SkScalar top); | 223 SkScalar top); |
| 240 RECORD(DrawImageRect, kDraw_Tag|kHasImage_Tag, | 224 RECORD(DrawImageRect, kDraw_Tag|kHasImage_Tag, |
| 241 Optional<SkPaint> paint; | 225 Optional<SkPaint> paint; |
| 242 RefBox<const SkImage> image; | 226 sk_sp<const SkImage> image; |
| 243 Optional<SkRect> src; | 227 Optional<SkRect> src; |
| 244 SkRect dst; | 228 SkRect dst; |
| 245 SkCanvas::SrcRectConstraint constraint); | 229 SkCanvas::SrcRectConstraint constraint); |
| 246 RECORD(DrawImageNine, kDraw_Tag|kHasImage_Tag, | 230 RECORD(DrawImageNine, kDraw_Tag|kHasImage_Tag, |
| 247 Optional<SkPaint> paint; | 231 Optional<SkPaint> paint; |
| 248 RefBox<const SkImage> image; | 232 sk_sp<const SkImage> image; |
| 249 SkIRect center; | 233 SkIRect center; |
| 250 SkRect dst); | 234 SkRect dst); |
| 251 RECORD(DrawOval, kDraw_Tag, | 235 RECORD(DrawOval, kDraw_Tag, |
| 252 SkPaint paint; | 236 SkPaint paint; |
| 253 SkRect oval); | 237 SkRect oval); |
| 254 RECORD(DrawPaint, kDraw_Tag, | 238 RECORD(DrawPaint, kDraw_Tag, |
| 255 SkPaint paint); | 239 SkPaint paint); |
| 256 RECORD(DrawPath, kDraw_Tag, | 240 RECORD(DrawPath, kDraw_Tag, |
| 257 SkPaint paint; | 241 SkPaint paint; |
| 258 PreCachedPath path); | 242 PreCachedPath path); |
| 259 RECORD(DrawPicture, kDraw_Tag, | 243 RECORD(DrawPicture, kDraw_Tag, |
| 260 Optional<SkPaint> paint; | 244 Optional<SkPaint> paint; |
| 261 RefBox<const SkPicture> picture; | 245 sk_sp<const SkPicture> picture; |
| 262 TypedMatrix matrix); | 246 TypedMatrix matrix); |
| 263 RECORD(DrawShadowedPicture, kDraw_Tag, | 247 RECORD(DrawShadowedPicture, kDraw_Tag, |
| 264 Optional<SkPaint> paint; | 248 Optional<SkPaint> paint; |
| 265 RefBox<const SkPicture> picture; | 249 sk_sp<const SkPicture> picture; |
| 266 TypedMatrix matrix); | 250 TypedMatrix matrix); |
| 267 RECORD(DrawPoints, kDraw_Tag, | 251 RECORD(DrawPoints, kDraw_Tag, |
| 268 SkPaint paint; | 252 SkPaint paint; |
| 269 SkCanvas::PointMode mode; | 253 SkCanvas::PointMode mode; |
| 270 unsigned count; | 254 unsigned count; |
| 271 SkPoint* pts); | 255 SkPoint* pts); |
| 272 RECORD(DrawPosText, kDraw_Tag|kHasText_Tag, | 256 RECORD(DrawPosText, kDraw_Tag|kHasText_Tag, |
| 273 SkPaint paint; | 257 SkPaint paint; |
| 274 PODArray<char> text; | 258 PODArray<char> text; |
| 275 size_t byteLength; | 259 size_t byteLength; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 287 SkPaint paint; | 271 SkPaint paint; |
| 288 SkRect rect); | 272 SkRect rect); |
| 289 RECORD(DrawText, kDraw_Tag|kHasText_Tag, | 273 RECORD(DrawText, kDraw_Tag|kHasText_Tag, |
| 290 SkPaint paint; | 274 SkPaint paint; |
| 291 PODArray<char> text; | 275 PODArray<char> text; |
| 292 size_t byteLength; | 276 size_t byteLength; |
| 293 SkScalar x; | 277 SkScalar x; |
| 294 SkScalar y); | 278 SkScalar y); |
| 295 RECORD(DrawTextBlob, kDraw_Tag|kHasText_Tag, | 279 RECORD(DrawTextBlob, kDraw_Tag|kHasText_Tag, |
| 296 SkPaint paint; | 280 SkPaint paint; |
| 297 RefBox<const SkTextBlob> blob; | 281 sk_sp<const SkTextBlob> blob; |
| 298 SkScalar x; | 282 SkScalar x; |
| 299 SkScalar y); | 283 SkScalar y); |
| 300 RECORD(DrawTextOnPath, kDraw_Tag|kHasText_Tag, | 284 RECORD(DrawTextOnPath, kDraw_Tag|kHasText_Tag, |
| 301 SkPaint paint; | 285 SkPaint paint; |
| 302 PODArray<char> text; | 286 PODArray<char> text; |
| 303 size_t byteLength; | 287 size_t byteLength; |
| 304 PreCachedPath path; | 288 PreCachedPath path; |
| 305 TypedMatrix matrix); | 289 TypedMatrix matrix); |
| 306 RECORD(DrawTextRSXform, kDraw_Tag|kHasText_Tag, | 290 RECORD(DrawTextRSXform, kDraw_Tag|kHasText_Tag, |
| 307 SkPaint paint; | 291 SkPaint paint; |
| 308 PODArray<char> text; | 292 PODArray<char> text; |
| 309 size_t byteLength; | 293 size_t byteLength; |
| 310 PODArray<SkRSXform> xforms; | 294 PODArray<SkRSXform> xforms; |
| 311 Optional<SkRect> cull); | 295 Optional<SkRect> cull); |
| 312 RECORD(DrawPatch, kDraw_Tag, | 296 RECORD(DrawPatch, kDraw_Tag, |
| 313 SkPaint paint; | 297 SkPaint paint; |
| 314 PODArray<SkPoint> cubics; | 298 PODArray<SkPoint> cubics; |
| 315 PODArray<SkColor> colors; | 299 PODArray<SkColor> colors; |
| 316 PODArray<SkPoint> texCoords; | 300 PODArray<SkPoint> texCoords; |
| 317 RefBox<SkXfermode> xmode); | 301 sk_sp<SkXfermode> xmode); |
| 318 RECORD(DrawAtlas, kDraw_Tag|kHasImage_Tag, | 302 RECORD(DrawAtlas, kDraw_Tag|kHasImage_Tag, |
| 319 Optional<SkPaint> paint; | 303 Optional<SkPaint> paint; |
| 320 RefBox<const SkImage> atlas; | 304 sk_sp<const SkImage> atlas; |
| 321 PODArray<SkRSXform> xforms; | 305 PODArray<SkRSXform> xforms; |
| 322 PODArray<SkRect> texs; | 306 PODArray<SkRect> texs; |
| 323 PODArray<SkColor> colors; | 307 PODArray<SkColor> colors; |
| 324 int count; | 308 int count; |
| 325 SkXfermode::Mode mode; | 309 SkXfermode::Mode mode; |
| 326 Optional<SkRect> cull); | 310 Optional<SkRect> cull); |
| 327 RECORD(DrawVertices, kDraw_Tag, | 311 RECORD(DrawVertices, kDraw_Tag, |
| 328 SkPaint paint; | 312 SkPaint paint; |
| 329 SkCanvas::VertexMode vmode; | 313 SkCanvas::VertexMode vmode; |
| 330 int vertexCount; | 314 int vertexCount; |
| 331 PODArray<SkPoint> vertices; | 315 PODArray<SkPoint> vertices; |
| 332 PODArray<SkPoint> texs; | 316 PODArray<SkPoint> texs; |
| 333 PODArray<SkColor> colors; | 317 PODArray<SkColor> colors; |
| 334 RefBox<SkXfermode> xmode; | 318 sk_sp<SkXfermode> xmode; |
| 335 PODArray<uint16_t> indices; | 319 PODArray<uint16_t> indices; |
| 336 int indexCount); | 320 int indexCount); |
| 337 RECORD(DrawAnnotation, 0, | 321 RECORD(DrawAnnotation, 0, |
| 338 SkRect rect; | 322 SkRect rect; |
| 339 SkString key; | 323 SkString key; |
| 340 RefBox<SkData> value); | 324 sk_sp<SkData> value); |
| 341 #undef RECORD | 325 #undef RECORD |
| 342 | 326 |
| 343 } // namespace SkRecords | 327 } // namespace SkRecords |
| 344 | 328 |
| 345 #endif//SkRecords_DEFINED | 329 #endif//SkRecords_DEFINED |
| OLD | NEW |