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 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 * allocation overhead but could lead to more wasted space (the tail | 136 * allocation overhead but could lead to more wasted space (the tail |
137 * end of blocks could go unused). Possibly add a second addDraw that | 137 * end of blocks could go unused). Possibly add a second addDraw that |
138 * operates in this manner. | 138 * operates in this manner. |
139 */ | 139 */ |
140 size_t addDraw(DrawType drawType, size_t* size) { | 140 size_t addDraw(DrawType drawType, size_t* size) { |
141 size_t offset = fWriter.bytesWritten(); | 141 size_t offset = fWriter.bytesWritten(); |
142 | 142 |
143 this->predrawNotify(); | 143 this->predrawNotify(); |
144 fContentInfo.addOperation(); | 144 fContentInfo.addOperation(); |
145 | 145 |
146 #ifdef SK_DEBUG_TRACE | |
147 SkDebugf("add %s\n", DrawTypeToString(drawType)); | |
148 #endif | |
149 | |
150 SkASSERT(0 != *size); | 146 SkASSERT(0 != *size); |
151 SkASSERT(((uint8_t) drawType) == drawType); | 147 SkASSERT(((uint8_t) drawType) == drawType); |
152 | 148 |
153 if (0 != (*size & ~MASK_24) || *size == MASK_24) { | 149 if (0 != (*size & ~MASK_24) || *size == MASK_24) { |
154 fWriter.writeInt(PACK_8_24(drawType, MASK_24)); | 150 fWriter.writeInt(PACK_8_24(drawType, MASK_24)); |
155 *size += 1; | 151 *size += 1; |
156 fWriter.writeInt(SkToU32(*size)); | 152 fWriter.writeInt(SkToU32(*size)); |
157 } else { | 153 } else { |
158 fWriter.writeInt(PACK_8_24(drawType, SkToU32(*size))); | 154 fWriter.writeInt(PACK_8_24(drawType, SkToU32(*size))); |
159 } | 155 } |
(...skipping 22 matching lines...) Expand all Loading... |
182 void addRect(const SkRect& rect); | 178 void addRect(const SkRect& rect); |
183 void addRectPtr(const SkRect* rect); | 179 void addRectPtr(const SkRect* rect); |
184 void addIRect(const SkIRect& rect); | 180 void addIRect(const SkIRect& rect); |
185 void addIRectPtr(const SkIRect* rect); | 181 void addIRectPtr(const SkIRect* rect); |
186 void addRRect(const SkRRect&); | 182 void addRRect(const SkRRect&); |
187 void addRegion(const SkRegion& region); | 183 void addRegion(const SkRegion& region); |
188 void addText(const void* text, size_t byteLength); | 184 void addText(const void* text, size_t byteLength); |
189 | 185 |
190 int find(const SkBitmap& bitmap); | 186 int find(const SkBitmap& bitmap); |
191 | 187 |
192 #ifdef SK_DEBUG_DUMP | 188 protected: |
193 public: | |
194 void dumpMatrices(); | |
195 void dumpPaints(); | |
196 #endif | |
197 | |
198 #ifdef SK_DEBUG_SIZE | |
199 public: | |
200 size_t size() const; | |
201 int bitmaps(size_t* size) const; | |
202 int matrices(size_t* size) const; | |
203 int paints(size_t* size) const; | |
204 int paths(size_t* size) const; | |
205 int regions(size_t* size) const; | |
206 size_t streamlen() const; | |
207 | |
208 size_t fPointBytes, fRectBytes, fTextBytes; | |
209 int fPointWrites, fRectWrites, fTextWrites; | |
210 #endif | |
211 | |
212 #ifdef SK_DEBUG_VALIDATE | |
213 public: | |
214 void validate(size_t initialOffset, uint32_t size) const; | |
215 private: | |
216 void validateBitmaps() const; | |
217 void validateMatrices() const; | |
218 void validatePaints() const; | |
219 void validatePaths() const; | |
220 void validateRegions() const; | |
221 #else | |
222 public: | |
223 void validate(size_t initialOffset, size_t size) const { | 189 void validate(size_t initialOffset, size_t size) const { |
224 SkASSERT(fWriter.bytesWritten() == initialOffset + size); | 190 SkASSERT(fWriter.bytesWritten() == initialOffset + size); |
225 } | 191 } |
226 #endif | |
227 | 192 |
228 protected: | |
229 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE; | 193 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE; |
230 const void* onPeekPixels(SkImageInfo*, size_t*) SK_OVERRIDE { | 194 const void* onPeekPixels(SkImageInfo*, size_t*) SK_OVERRIDE { |
231 return NULL; | 195 return NULL; |
232 } | 196 } |
233 | 197 |
234 virtual void willSave() SK_OVERRIDE; | 198 virtual void willSave() SK_OVERRIDE; |
235 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) SK_OVERRIDE; | 199 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) SK_OVERRIDE; |
236 virtual void willRestore() SK_OVERRIDE; | 200 virtual void willRestore() SK_OVERRIDE; |
237 | 201 |
238 virtual void didConcat(const SkMatrix&) SK_OVERRIDE; | 202 virtual void didConcat(const SkMatrix&) SK_OVERRIDE; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 261 |
298 // These are set to NULL in our constructor, but may be changed by | 262 // These are set to NULL in our constructor, but may be changed by |
299 // subclasses, in which case they will be SkSafeUnref'd in our destructor. | 263 // subclasses, in which case they will be SkSafeUnref'd in our destructor. |
300 SkBBoxHierarchy* fBoundingHierarchy; | 264 SkBBoxHierarchy* fBoundingHierarchy; |
301 SkPictureStateTree* fStateTree; | 265 SkPictureStateTree* fStateTree; |
302 | 266 |
303 // Allocated in the constructor and managed by this class. | 267 // Allocated in the constructor and managed by this class. |
304 SkBitmapHeap* fBitmapHeap; | 268 SkBitmapHeap* fBitmapHeap; |
305 | 269 |
306 private: | 270 private: |
307 friend class MatrixClipState; // for access to *Impl methods | |
308 | |
309 SkPictureContentInfo fContentInfo; | 271 SkPictureContentInfo fContentInfo; |
310 SkAutoTUnref<SkPathHeap> fPathHeap; | 272 SkAutoTUnref<SkPathHeap> fPathHeap; |
311 | 273 |
312 SkChunkFlatController fFlattenableHeap; | 274 SkChunkFlatController fFlattenableHeap; |
313 | 275 |
314 SkPaintDictionary fPaints; | 276 SkPaintDictionary fPaints; |
315 | 277 |
316 SkWriter32 fWriter; | 278 SkWriter32 fWriter; |
317 | 279 |
318 // we ref each item in these arrays | 280 // we ref each item in these arrays |
319 SkTDArray<const SkPicture*> fPictureRefs; | 281 SkTDArray<const SkPicture*> fPictureRefs; |
320 | 282 |
321 uint32_t fRecordFlags; | 283 uint32_t fRecordFlags; |
322 bool fOptsEnabled; | 284 bool fOptsEnabled; |
323 int fInitialSaveCount; | 285 int fInitialSaveCount; |
324 | 286 |
325 friend class SkPictureData; // for SkPictureData's SkPictureRecord-based c
onstructor | 287 friend class SkPictureData; // for SkPictureData's SkPictureRecord-based c
onstructor |
326 friend class SkPictureTester; // for unit testing | 288 friend class SkPictureTester; // for unit testing |
327 | 289 |
328 typedef SkCanvas INHERITED; | 290 typedef SkCanvas INHERITED; |
329 }; | 291 }; |
330 | 292 |
331 #endif | 293 #endif |
OLD | NEW |