| OLD | NEW |
| (Empty) |
| 1 #ifndef SkPicturePlayback_DEFINED | |
| 2 #define SkPicturePlayback_DEFINED | |
| 3 | |
| 4 #include "SkPicture.h" | |
| 5 #include "SkReader32.h" | |
| 6 | |
| 7 #include "SkBitmap.h" | |
| 8 #include "SkMatrix.h" | |
| 9 #include "SkPaint.h" | |
| 10 #include "SkPath.h" | |
| 11 #include "SkPathHeap.h" | |
| 12 #include "SkRegion.h" | |
| 13 #include "SkPictureFlat.h" | |
| 14 | |
| 15 class SkPictureRecord; | |
| 16 class SkStream; | |
| 17 class SkWStream; | |
| 18 | |
| 19 class SkPicturePlayback { | |
| 20 public: | |
| 21 SkPicturePlayback(); | |
| 22 SkPicturePlayback(const SkPicturePlayback& src); | |
| 23 explicit SkPicturePlayback(const SkPictureRecord& record); | |
| 24 explicit SkPicturePlayback(SkStream*); | |
| 25 | |
| 26 virtual ~SkPicturePlayback(); | |
| 27 | |
| 28 void draw(SkCanvas& canvas); | |
| 29 | |
| 30 void serialize(SkWStream*) const; | |
| 31 | |
| 32 void dumpSize() const; | |
| 33 | |
| 34 // Can be called in the middle of playback (the draw() call). WIll abort the | |
| 35 // drawing and return from draw() after the "current" op code is done | |
| 36 void abort(); | |
| 37 | |
| 38 private: | |
| 39 | |
| 40 class TextContainer { | |
| 41 public: | |
| 42 size_t length() { return fByteLength; } | |
| 43 const void* text() { return (const void*) fText; } | |
| 44 size_t fByteLength; | |
| 45 const char* fText; | |
| 46 }; | |
| 47 | |
| 48 const SkBitmap& getBitmap() { | |
| 49 int index = getInt(); | |
| 50 SkASSERT(index > 0); | |
| 51 return fBitmaps[index - 1]; | |
| 52 } | |
| 53 | |
| 54 int getIndex() { return fReader.readInt(); } | |
| 55 int getInt() { return fReader.readInt(); } | |
| 56 | |
| 57 const SkMatrix* getMatrix() { | |
| 58 int index = getInt(); | |
| 59 if (index == 0) { | |
| 60 return NULL; | |
| 61 } | |
| 62 SkASSERT(index > 0 && index <= fMatrixCount); | |
| 63 return &fMatrices[index - 1]; | |
| 64 } | |
| 65 | |
| 66 const SkPath& getPath() { | |
| 67 return (*fPathHeap)[getInt() - 1]; | |
| 68 } | |
| 69 | |
| 70 SkPicture& getPicture() { | |
| 71 int index = getInt(); | |
| 72 SkASSERT(index > 0 && index <= fPictureCount); | |
| 73 return *fPictureRefs[index - 1]; | |
| 74 } | |
| 75 | |
| 76 const SkPaint* getPaint() { | |
| 77 int index = getInt(); | |
| 78 if (index == 0) { | |
| 79 return NULL; | |
| 80 } | |
| 81 SkASSERT(index > 0 && index <= fPaintCount); | |
| 82 return &fPaints[index - 1]; | |
| 83 } | |
| 84 | |
| 85 const SkRect* getRectPtr() { | |
| 86 if (fReader.readBool()) { | |
| 87 return fReader.skipRect(); | |
| 88 } else { | |
| 89 return NULL; | |
| 90 } | |
| 91 } | |
| 92 | |
| 93 const SkIRect* getIRectPtr() { | |
| 94 if (fReader.readBool()) { | |
| 95 return (const SkIRect*)fReader.skip(sizeof(SkIRect)); | |
| 96 } else { | |
| 97 return NULL; | |
| 98 } | |
| 99 } | |
| 100 | |
| 101 const SkRegion& getRegion() { | |
| 102 int index = getInt(); | |
| 103 SkASSERT(index > 0); | |
| 104 return fRegions[index - 1]; | |
| 105 } | |
| 106 | |
| 107 SkScalar getScalar() { return fReader.readScalar(); } | |
| 108 | |
| 109 void getText(TextContainer* text) { | |
| 110 size_t length = text->fByteLength = getInt(); | |
| 111 text->fText = (const char*)fReader.skip(length); | |
| 112 } | |
| 113 | |
| 114 void init(); | |
| 115 | |
| 116 #ifdef SK_DEBUG_SIZE | |
| 117 public: | |
| 118 int size(size_t* sizePtr); | |
| 119 int bitmaps(size_t* size); | |
| 120 int paints(size_t* size); | |
| 121 int paths(size_t* size); | |
| 122 int regions(size_t* size); | |
| 123 #endif | |
| 124 | |
| 125 #ifdef SK_DEBUG_DUMP | |
| 126 private: | |
| 127 void dumpBitmap(const SkBitmap& bitmap) const; | |
| 128 void dumpMatrix(const SkMatrix& matrix) const; | |
| 129 void dumpPaint(const SkPaint& paint) const; | |
| 130 void dumpPath(const SkPath& path) const; | |
| 131 void dumpPicture(const SkPicture& picture) const; | |
| 132 void dumpRegion(const SkRegion& region) const; | |
| 133 int dumpDrawType(char* bufferPtr, char* buffer, DrawType drawType); | |
| 134 int dumpInt(char* bufferPtr, char* buffer, char* name); | |
| 135 int dumpRect(char* bufferPtr, char* buffer, char* name); | |
| 136 int dumpPoint(char* bufferPtr, char* buffer, char* name); | |
| 137 void dumpPointArray(char** bufferPtrPtr, char* buffer, int count); | |
| 138 int dumpPtr(char* bufferPtr, char* buffer, char* name, void* ptr); | |
| 139 int dumpRectPtr(char* bufferPtr, char* buffer, char* name); | |
| 140 int dumpScalar(char* bufferPtr, char* buffer, char* name); | |
| 141 void dumpText(char** bufferPtrPtr, char* buffer); | |
| 142 void dumpStream(); | |
| 143 | |
| 144 public: | |
| 145 void dump() const; | |
| 146 #endif | |
| 147 | |
| 148 private: | |
| 149 SkPathHeap* fPathHeap; // reference counted | |
| 150 SkBitmap* fBitmaps; | |
| 151 int fBitmapCount; | |
| 152 SkMatrix* fMatrices; | |
| 153 int fMatrixCount; | |
| 154 SkPaint* fPaints; | |
| 155 int fPaintCount; | |
| 156 SkRegion* fRegions; | |
| 157 int fRegionCount; | |
| 158 mutable SkFlattenableReadBuffer fReader; | |
| 159 | |
| 160 SkPicture** fPictureRefs; | |
| 161 int fPictureCount; | |
| 162 | |
| 163 SkRefCntPlayback fRCPlayback; | |
| 164 SkTypefacePlayback fTFPlayback; | |
| 165 SkFactoryPlayback* fFactoryPlayback; | |
| 166 }; | |
| 167 | |
| 168 #endif | |
| OLD | NEW |