OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #ifndef SkPictureRecord_DEFINED | 8 #ifndef SkPictureRecord_DEFINED |
9 #define SkPictureRecord_DEFINED | 9 #define SkPictureRecord_DEFINED |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 fRecordFlags = recordFlags; | 95 fRecordFlags = recordFlags; |
96 } | 96 } |
97 | 97 |
98 const SkWriter32& writeStream() const { | 98 const SkWriter32& writeStream() const { |
99 return fWriter; | 99 return fWriter; |
100 } | 100 } |
101 | 101 |
102 void beginRecording(); | 102 void beginRecording(); |
103 void endRecording(); | 103 void endRecording(); |
104 | 104 |
105 static bool canRecordBounds(DrawType op); | |
105 private: | 106 private: |
106 void recordRestoreOffsetPlaceholder(SkRegion::Op); | 107 void recordRestoreOffsetPlaceholder(SkRegion::Op); |
107 void fillRestoreOffsetPlaceholdersForCurrentStackLevel( | 108 void fillRestoreOffsetPlaceholdersForCurrentStackLevel( |
108 uint32_t restoreOffset); | 109 uint32_t restoreOffset); |
109 | 110 |
110 SkTDArray<int32_t> fRestoreOffsetStack; | 111 SkTDArray<int32_t> fRestoreOffsetStack; |
111 int fFirstSavedLayerIndex; | 112 int fFirstSavedLayerIndex; |
112 enum { | 113 enum { |
113 kNoSavedLayerIndex = -1 | 114 kNoSavedLayerIndex = -1, |
114 }; | 115 }; |
116 static const uint32_t kInvalidOffset = ~0; | |
115 | 117 |
116 /* | 118 /* |
robertphillips
2013/03/07 18:37:40
This comment needs enhancing
| |
117 * Write the 'drawType' operation and chunk size to the skp. 'size' | 119 * Write the 'drawType' operation and chunk size to the skp. 'size' |
118 * can potentially be increased if the chunk size needs its own storage | 120 * can potentially be increased if the chunk size needs its own storage |
119 * location (i.e., it overflows 24 bits). | 121 * location (i.e., it overflows 24 bits). |
120 * Returns the start offset of the chunk. This is the location at which | 122 * Returns the start offset of the chunk. This is the location at which |
121 * the opcode & size are stored. | 123 * the opcode & size are stored. |
122 * TODO: since we are handing the size into here we could call reserve | 124 * TODO: since we are handing the size into here we could call reserve |
123 * and then return a pointer to the memory storage. This could decrease | 125 * and then return a pointer to the memory storage. This could decrease |
124 * allocation overhead but could lead to more wasted space (the tail | 126 * allocation overhead but could lead to more wasted space (the tail |
125 * end of blocks could go unused). Possibly add a second addDraw that | 127 * end of blocks could go unused). Possibly add a second addDraw that |
126 * operates in this manner. | 128 * operates in this manner. |
127 */ | 129 */ |
128 uint32_t addDraw(DrawType drawType, uint32_t* size) { | 130 uint32_t addDraw(DrawType drawType, uint32_t* size, const SkPaint* paint = N ULL, |
129 uint32_t offset = fWriter.size(); | 131 const SkRect* localBounds = NULL); |
130 | 132 bool recordBounds() const { return fRecordFlags & SkPicture::kRecordBounds_R ecordingFlag; } |
131 this->predrawNotify(); | |
132 | |
133 #ifdef SK_DEBUG_TRACE | |
134 SkDebugf("add %s\n", DrawTypeToString(drawType)); | |
135 #endif | |
136 | |
137 SkASSERT(0 != *size); | |
138 SkASSERT(((uint8_t) drawType) == drawType); | |
139 | |
140 if (0 != (*size & ~MASK_24) || *size == MASK_24) { | |
141 fWriter.writeInt(PACK_8_24(drawType, MASK_24)); | |
142 *size += 1; | |
143 fWriter.writeInt(*size); | |
144 } else { | |
145 fWriter.writeInt(PACK_8_24(drawType, *size)); | |
146 } | |
147 | |
148 return offset; | |
149 } | |
150 | 133 |
151 void addInt(int value) { | 134 void addInt(int value) { |
152 fWriter.writeInt(value); | 135 fWriter.writeInt(value); |
153 } | 136 } |
154 void addScalar(SkScalar scalar) { | 137 void addScalar(SkScalar scalar) { |
155 fWriter.writeScalar(scalar); | 138 fWriter.writeScalar(scalar); |
156 } | 139 } |
157 | 140 |
158 void addBitmap(const SkBitmap& bitmap); | 141 void addBitmap(const SkBitmap& bitmap); |
159 void addMatrix(const SkMatrix& matrix); | 142 void addMatrix(const SkMatrix& matrix); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 uint32_t fRecordFlags; | 219 uint32_t fRecordFlags; |
237 int fInitialSaveCount; | 220 int fInitialSaveCount; |
238 | 221 |
239 friend class SkPicturePlayback; | 222 friend class SkPicturePlayback; |
240 friend class SkPictureTester; // for unit testing | 223 friend class SkPictureTester; // for unit testing |
241 | 224 |
242 typedef SkCanvas INHERITED; | 225 typedef SkCanvas INHERITED; |
243 }; | 226 }; |
244 | 227 |
245 #endif | 228 #endif |
OLD | NEW |