Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: src/core/SkPictureRecord.h

Issue 12545009: Adding option in SkPicture to record device-space bounds of draw commands. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 /*
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) {
129 uint32_t offset = fWriter.size(); 131 uint32_t offset = fWriter.size();
130 132
131 this->predrawNotify(); 133 this->predrawNotify();
132 134
133 #ifdef SK_DEBUG_TRACE 135 #ifdef SK_DEBUG_TRACE
134 SkDebugf("add %s\n", DrawTypeToString(drawType)); 136 SkDebugf("add %s\n", DrawTypeToString(drawType));
135 #endif 137 #endif
136
137 SkASSERT(0 != *size); 138 SkASSERT(0 != *size);
138 SkASSERT(((uint8_t) drawType) == drawType); 139 SkASSERT(((uint8_t) drawType) == drawType);
139
140 if (0 != (*size & ~MASK_24) || *size == MASK_24) { 140 if (0 != (*size & ~MASK_24) || *size == MASK_24) {
141 fWriter.writeInt(PACK_8_24(drawType, MASK_24)); 141 fWriter.writeInt(PACK_8_24(drawType, MASK_24));
142 *size += 1; 142 *size += 1;
143 fWriter.writeInt(*size); 143 fWriter.writeInt(*size);
144 } else { 144 } else {
145 fWriter.writeInt(PACK_8_24(drawType, *size)); 145 fWriter.writeInt(PACK_8_24(drawType, *size));
146 } 146 }
147 147 fLastDrawRejected = false;
148 return offset; 148 return offset;
149 } 149 }
150 150
151 uint32_t addDrawWithBounds(DrawType drawType, uint32_t* size, const SkPaint* paint,
152 const SkRect* localBounds);
153 bool recordBounds() const { return fRecordFlags & SkPicture::kRecordBounds_R ecordingFlag; }
154
151 void addInt(int value) { 155 void addInt(int value) {
152 fWriter.writeInt(value); 156 fWriter.writeInt(value);
153 } 157 }
154 void addScalar(SkScalar scalar) { 158 void addScalar(SkScalar scalar) {
155 fWriter.writeScalar(scalar); 159 fWriter.writeScalar(scalar);
156 } 160 }
157 161
158 void addBitmap(const SkBitmap& bitmap); 162 void addBitmap(const SkBitmap& bitmap);
159 void addMatrix(const SkMatrix& matrix); 163 void addMatrix(const SkMatrix& matrix);
160 void addMatrixPtr(const SkMatrix* matrix); 164 void addMatrixPtr(const SkMatrix* matrix);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 216
213 protected: 217 protected:
214 218
215 // These are set to NULL in our constructor, but may be changed by 219 // These are set to NULL in our constructor, but may be changed by
216 // subclasses, in which case they will be SkSafeUnref'd in our destructor. 220 // subclasses, in which case they will be SkSafeUnref'd in our destructor.
217 SkBBoxHierarchy* fBoundingHierarchy; 221 SkBBoxHierarchy* fBoundingHierarchy;
218 SkPictureStateTree* fStateTree; 222 SkPictureStateTree* fStateTree;
219 223
220 // Allocated in the constructor and managed by this class. 224 // Allocated in the constructor and managed by this class.
221 SkBitmapHeap* fBitmapHeap; 225 SkBitmapHeap* fBitmapHeap;
226 bool fLastDrawRejected;
222 227
223 private: 228 private:
224 SkChunkFlatController fFlattenableHeap; 229 SkChunkFlatController fFlattenableHeap;
225 230
226 SkMatrixDictionary fMatrices; 231 SkMatrixDictionary fMatrices;
227 SkPaintDictionary fPaints; 232 SkPaintDictionary fPaints;
228 SkRegionDictionary fRegions; 233 SkRegionDictionary fRegions;
229 234
230 SkPathHeap* fPathHeap; // reference counted 235 SkPathHeap* fPathHeap; // reference counted
231 SkWriter32 fWriter; 236 SkWriter32 fWriter;
232 237
233 // we ref each item in these arrays 238 // we ref each item in these arrays
234 SkTDArray<SkPicture*> fPictureRefs; 239 SkTDArray<SkPicture*> fPictureRefs;
235 240
236 uint32_t fRecordFlags; 241 uint32_t fRecordFlags;
237 int fInitialSaveCount; 242 int fInitialSaveCount;
238 243
239 friend class SkPicturePlayback; 244 friend class SkPicturePlayback;
240 friend class SkPictureTester; // for unit testing 245 friend class SkPictureTester; // for unit testing
241 246
242 typedef SkCanvas INHERITED; 247 typedef SkCanvas INHERITED;
243 }; 248 };
244 249
245 #endif 250 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698