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

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

Issue 244273002: fix size_t/int warnings in pictures (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | src/core/SkPictureRecord.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 void beginRecording(); 94 void beginRecording();
95 void endRecording(); 95 void endRecording();
96 96
97 void internalOnly_EnableOpts(bool optsEnabled) { 97 void internalOnly_EnableOpts(bool optsEnabled) {
98 fOptsEnabled = optsEnabled; 98 fOptsEnabled = optsEnabled;
99 } 99 }
100 100
101 private: 101 private:
102 void handleOptimization(int opt); 102 void handleOptimization(int opt);
103 int recordRestoreOffsetPlaceholder(SkRegion::Op); 103 size_t recordRestoreOffsetPlaceholder(SkRegion::Op);
104 void fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffse t); 104 void fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffse t);
105 105
106 #ifndef SK_COLLAPSE_MATRIX_CLIP_STATE 106 #ifndef SK_COLLAPSE_MATRIX_CLIP_STATE
107 SkTDArray<int32_t> fRestoreOffsetStack; 107 SkTDArray<int32_t> fRestoreOffsetStack;
108 int fFirstSavedLayerIndex; 108 int fFirstSavedLayerIndex;
109 enum { 109 enum {
110 kNoSavedLayerIndex = -1 110 kNoSavedLayerIndex = -1
111 }; 111 };
112 #endif 112 #endif
113 113
114 SkTDArray<uint32_t> fCullOffsetStack; 114 SkTDArray<uint32_t> fCullOffsetStack;
115 115
116 /* 116 /*
117 * Write the 'drawType' operation and chunk size to the skp. 'size' 117 * Write the 'drawType' operation and chunk size to the skp. 'size'
118 * can potentially be increased if the chunk size needs its own storage 118 * can potentially be increased if the chunk size needs its own storage
119 * location (i.e., it overflows 24 bits). 119 * location (i.e., it overflows 24 bits).
120 * Returns the start offset of the chunk. This is the location at which 120 * Returns the start offset of the chunk. This is the location at which
121 * the opcode & size are stored. 121 * the opcode & size are stored.
122 * TODO: since we are handing the size into here we could call reserve 122 * 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 123 * and then return a pointer to the memory storage. This could decrease
124 * allocation overhead but could lead to more wasted space (the tail 124 * allocation overhead but could lead to more wasted space (the tail
125 * end of blocks could go unused). Possibly add a second addDraw that 125 * end of blocks could go unused). Possibly add a second addDraw that
126 * operates in this manner. 126 * operates in this manner.
127 */ 127 */
128 size_t addDraw(DrawType drawType, uint32_t* size) { 128 size_t addDraw(DrawType drawType, size_t* size) {
129 size_t offset = fWriter.bytesWritten(); 129 size_t offset = fWriter.bytesWritten();
130 130
131 this->predrawNotify(); 131 this->predrawNotify();
132 132
133 #ifdef SK_DEBUG_TRACE 133 #ifdef SK_DEBUG_TRACE
134 SkDebugf("add %s\n", DrawTypeToString(drawType)); 134 SkDebugf("add %s\n", DrawTypeToString(drawType));
135 #endif 135 #endif
136 136
137 SkASSERT(0 != *size); 137 SkASSERT(0 != *size);
138 SkASSERT(((uint8_t) drawType) == drawType); 138 SkASSERT(((uint8_t) drawType) == drawType);
139 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(SkToU32(*size));
144 } else { 144 } else {
145 fWriter.writeInt(PACK_8_24(drawType, *size)); 145 fWriter.writeInt(PACK_8_24(drawType, SkToU32(*size)));
146 } 146 }
147 147
148 return offset; 148 return offset;
149 } 149 }
150 150
151 void addInt(int value) { 151 void addInt(int value) {
152 fWriter.writeInt(value); 152 fWriter.writeInt(value);
153 } 153 }
154 void addScalar(SkScalar scalar) { 154 void addScalar(SkScalar scalar) {
155 fWriter.writeScalar(scalar); 155 fWriter.writeScalar(scalar);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 public: 199 public:
200 void validate(size_t initialOffset, uint32_t size) const; 200 void validate(size_t initialOffset, uint32_t size) const;
201 private: 201 private:
202 void validateBitmaps() const; 202 void validateBitmaps() const;
203 void validateMatrices() const; 203 void validateMatrices() const;
204 void validatePaints() const; 204 void validatePaints() const;
205 void validatePaths() const; 205 void validatePaths() const;
206 void validateRegions() const; 206 void validateRegions() const;
207 #else 207 #else
208 public: 208 public:
209 void validate(size_t initialOffset, uint32_t size) const { 209 void validate(size_t initialOffset, size_t size) const {
210 SkASSERT(fWriter.bytesWritten() == initialOffset + size); 210 SkASSERT(fWriter.bytesWritten() == initialOffset + size);
211 } 211 }
212 #endif 212 #endif
213 213
214 protected: 214 protected:
215 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE; 215 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE;
216 const void* onPeekPixels(SkImageInfo*, size_t*) SK_OVERRIDE { 216 const void* onPeekPixels(SkImageInfo*, size_t*) SK_OVERRIDE {
217 return NULL; 217 return NULL;
218 } 218 }
219 219
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 const SkPaint& paint, const SkFlatData* flatPaintData) ; 255 const SkPaint& paint, const SkFlatData* flatPaintData) ;
256 256
257 int addPathToHeap(const SkPath& path); // does not write to ops stream 257 int addPathToHeap(const SkPath& path); // does not write to ops stream
258 258
259 // These entry points allow the writing of matrices, clips, saves & 259 // These entry points allow the writing of matrices, clips, saves &
260 // restores to be deferred (e.g., if the MC state is being collapsed and 260 // restores to be deferred (e.g., if the MC state is being collapsed and
261 // only written out as needed). 261 // only written out as needed).
262 void recordConcat(const SkMatrix& matrix); 262 void recordConcat(const SkMatrix& matrix);
263 void recordTranslate(const SkMatrix& matrix); 263 void recordTranslate(const SkMatrix& matrix);
264 void recordScale(const SkMatrix& matrix); 264 void recordScale(const SkMatrix& matrix);
265 int recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA); 265 size_t recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
266 int recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA); 266 size_t recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA);
267 int recordClipPath(int pathID, SkRegion::Op op, bool doAA); 267 size_t recordClipPath(int pathID, SkRegion::Op op, bool doAA);
268 int recordClipRegion(const SkRegion& region, SkRegion::Op op); 268 size_t recordClipRegion(const SkRegion& region, SkRegion::Op op);
269 void recordSave(SaveFlags flags); 269 void recordSave(SaveFlags flags);
270 void recordSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags f lags); 270 void recordSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags f lags);
271 void recordRestore(bool fillInSkips = true); 271 void recordRestore(bool fillInSkips = true);
272 272
273 // These are set to NULL in our constructor, but may be changed by 273 // These are set to NULL in our constructor, but may be changed by
274 // subclasses, in which case they will be SkSafeUnref'd in our destructor. 274 // subclasses, in which case they will be SkSafeUnref'd in our destructor.
275 SkBBoxHierarchy* fBoundingHierarchy; 275 SkBBoxHierarchy* fBoundingHierarchy;
276 SkPictureStateTree* fStateTree; 276 SkPictureStateTree* fStateTree;
277 277
278 // Allocated in the constructor and managed by this class. 278 // Allocated in the constructor and managed by this class.
(...skipping 21 matching lines...) Expand all
300 friend class SkPictureTester; // for unit testing 300 friend class SkPictureTester; // for unit testing
301 301
302 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 302 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
303 SkMatrixClipStateMgr fMCMgr; 303 SkMatrixClipStateMgr fMCMgr;
304 #endif 304 #endif
305 305
306 typedef SkCanvas INHERITED; 306 typedef SkCanvas INHERITED;
307 }; 307 };
308 308
309 #endif 309 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | src/core/SkPictureRecord.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698