| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 SkPictureRecord_DEFINED | 8 #ifndef SkPictureRecord_DEFINED |
| 9 #define SkPictureRecord_DEFINED | 9 #define SkPictureRecord_DEFINED |
| 10 | 10 |
| 11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 12 #include "SkFlattenable.h" | 12 #include "SkFlattenable.h" |
| 13 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 13 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
| 14 #include "SkMatrixClipStateMgr.h" | 14 #include "SkMatrixClipStateMgr.h" |
| 15 #endif | 15 #endif |
| 16 #include "SkPathHeap.h" | 16 #include "SkPathHeap.h" |
| 17 #include "SkPicture.h" | 17 #include "SkPicture.h" |
| 18 #include "SkPicturePlayback.h" |
| 18 #include "SkPictureFlat.h" | 19 #include "SkPictureFlat.h" |
| 19 #include "SkTemplates.h" | 20 #include "SkTemplates.h" |
| 20 #include "SkWriter32.h" | 21 #include "SkWriter32.h" |
| 21 | 22 |
| 22 class SkBBoxHierarchy; | 23 class SkBBoxHierarchy; |
| 23 class SkPictureStateTree; | 24 class SkPictureStateTree; |
| 24 | 25 |
| 25 // These macros help with packing and unpacking a single byte value and | 26 // These macros help with packing and unpacking a single byte value and |
| 26 // a 3 byte value into/out of a uint32_t | 27 // a 3 byte value into/out of a uint32_t |
| 27 #define MASK_24 0x00FFFFFF | 28 #define MASK_24 0x00FFFFFF |
| 28 #define UNPACK_8_24(combined, small, large) \ | 29 #define UNPACK_8_24(combined, small, large) \ |
| 29 small = (combined >> 24) & 0xFF; \ | 30 small = (combined >> 24) & 0xFF; \ |
| 30 large = combined & MASK_24; | 31 large = combined & MASK_24; |
| 31 #define PACK_8_24(small, large) ((small << 24) | large) | 32 #define PACK_8_24(small, large) ((small << 24) | large) |
| 32 | 33 |
| 33 | 34 |
| 34 class SkPictureRecord : public SkCanvas { | 35 class SkPictureRecord : public SkCanvas { |
| 35 public: | 36 public: |
| 36 SkPictureRecord(SkPicture* picture, const SkISize& dimensions, uint32_t reco
rdFlags); | 37 SkPictureRecord(const SkISize& dimensions, uint32_t recordFlags); |
| 37 virtual ~SkPictureRecord(); | 38 virtual ~SkPictureRecord(); |
| 38 | 39 |
| 39 virtual void clear(SkColor) SK_OVERRIDE; | 40 virtual void clear(SkColor) SK_OVERRIDE; |
| 40 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; | 41 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; |
| 41 virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], | 42 virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], |
| 42 const SkPaint&) SK_OVERRIDE; | 43 const SkPaint&) SK_OVERRIDE; |
| 43 virtual void drawOval(const SkRect&, const SkPaint&) SK_OVERRIDE; | 44 virtual void drawOval(const SkRect&, const SkPaint&) SK_OVERRIDE; |
| 44 virtual void drawRect(const SkRect&, const SkPaint&) SK_OVERRIDE; | 45 virtual void drawRect(const SkRect&, const SkPaint&) SK_OVERRIDE; |
| 45 virtual void drawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE; | 46 virtual void drawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE; |
| 46 virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE; | 47 virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 66 virtual void endCommentGroup() SK_OVERRIDE; | 67 virtual void endCommentGroup() SK_OVERRIDE; |
| 67 virtual bool isDrawingToLayer() const SK_OVERRIDE; | 68 virtual bool isDrawingToLayer() const SK_OVERRIDE; |
| 68 | 69 |
| 69 void addFontMetricsTopBottom(const SkPaint& paint, const SkFlatData&, | 70 void addFontMetricsTopBottom(const SkPaint& paint, const SkFlatData&, |
| 70 SkScalar minY, SkScalar maxY); | 71 SkScalar minY, SkScalar maxY); |
| 71 | 72 |
| 72 const SkTDArray<const SkPicture* >& getPictureRefs() const { | 73 const SkTDArray<const SkPicture* >& getPictureRefs() const { |
| 73 return fPictureRefs; | 74 return fPictureRefs; |
| 74 } | 75 } |
| 75 | 76 |
| 77 SkData* opData(bool deepCopy) const { |
| 78 this->validate(fWriter.bytesWritten(), 0); |
| 79 |
| 80 if (fWriter.bytesWritten() == 0) { |
| 81 return SkData::NewEmpty(); |
| 82 } |
| 83 |
| 84 if (deepCopy) { |
| 85 return SkData::NewWithCopy(fWriter.contiguousArray(), fWriter.bytesW
ritten()); |
| 86 } |
| 87 |
| 88 return fWriter.snapshotAsData(); |
| 89 } |
| 90 |
| 91 SkPathHeap* pathHeap() { |
| 92 return fPathHeap; |
| 93 } |
| 94 |
| 95 const SkPictureContentInfo& contentInfo() const { |
| 96 return fContentInfo; |
| 97 } |
| 98 |
| 76 void setFlags(uint32_t recordFlags) { | 99 void setFlags(uint32_t recordFlags) { |
| 77 fRecordFlags = recordFlags; | 100 fRecordFlags = recordFlags; |
| 78 } | 101 } |
| 79 | 102 |
| 80 const SkWriter32& writeStream() const { | 103 const SkWriter32& writeStream() const { |
| 81 return fWriter; | 104 return fWriter; |
| 82 } | 105 } |
| 83 | 106 |
| 84 void beginRecording(); | 107 void beginRecording(); |
| 85 void endRecording(); | 108 void endRecording(); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 299 |
| 277 // These are set to NULL in our constructor, but may be changed by | 300 // These are set to NULL in our constructor, but may be changed by |
| 278 // subclasses, in which case they will be SkSafeUnref'd in our destructor. | 301 // subclasses, in which case they will be SkSafeUnref'd in our destructor. |
| 279 SkBBoxHierarchy* fBoundingHierarchy; | 302 SkBBoxHierarchy* fBoundingHierarchy; |
| 280 SkPictureStateTree* fStateTree; | 303 SkPictureStateTree* fStateTree; |
| 281 | 304 |
| 282 // Allocated in the constructor and managed by this class. | 305 // Allocated in the constructor and managed by this class. |
| 283 SkBitmapHeap* fBitmapHeap; | 306 SkBitmapHeap* fBitmapHeap; |
| 284 | 307 |
| 285 private: | 308 private: |
| 286 // The owning SkPicture | |
| 287 SkPicture* fPicture; | |
| 288 | |
| 289 friend class MatrixClipState; // for access to *Impl methods | 309 friend class MatrixClipState; // for access to *Impl methods |
| 290 friend class SkMatrixClipStateMgr; // for access to *Impl methods | 310 friend class SkMatrixClipStateMgr; // for access to *Impl methods |
| 291 | 311 |
| 312 SkPictureContentInfo fContentInfo; |
| 313 SkAutoTUnref<SkPathHeap> fPathHeap; |
| 314 |
| 292 SkChunkFlatController fFlattenableHeap; | 315 SkChunkFlatController fFlattenableHeap; |
| 293 | 316 |
| 294 SkPaintDictionary fPaints; | 317 SkPaintDictionary fPaints; |
| 295 | 318 |
| 296 SkWriter32 fWriter; | 319 SkWriter32 fWriter; |
| 297 | 320 |
| 298 // we ref each item in these arrays | 321 // we ref each item in these arrays |
| 299 SkTDArray<const SkPicture*> fPictureRefs; | 322 SkTDArray<const SkPicture*> fPictureRefs; |
| 300 | 323 |
| 301 uint32_t fRecordFlags; | 324 uint32_t fRecordFlags; |
| 302 bool fOptsEnabled; | 325 bool fOptsEnabled; |
| 303 int fInitialSaveCount; | 326 int fInitialSaveCount; |
| 304 | 327 |
| 305 friend class SkPicturePlayback; | 328 friend class SkPicturePlayback; |
| 306 friend class SkPictureTester; // for unit testing | 329 friend class SkPictureTester; // for unit testing |
| 307 | 330 |
| 308 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 331 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
| 309 SkMatrixClipStateMgr fMCMgr; | 332 SkMatrixClipStateMgr fMCMgr; |
| 310 #endif | 333 #endif |
| 311 | 334 |
| 312 typedef SkCanvas INHERITED; | 335 typedef SkCanvas INHERITED; |
| 313 }; | 336 }; |
| 314 | 337 |
| 315 #endif | 338 #endif |
| OLD | NEW |