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

Side by Side Diff: include/core/SkTemplates.h

Issue 27192003: Start cleaning up 64bit Win warnings (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: revertedGrBytesPerPixel to returning a size_t Created 7 years, 2 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 | « no previous file | include/core/SkWriter32.h » ('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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
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 8
9 9
10 #ifndef SkTemplates_DEFINED 10 #ifndef SkTemplates_DEFINED
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 template <size_t N, typename T> class SkAutoSTArray : SkNoncopyable { 234 template <size_t N, typename T> class SkAutoSTArray : SkNoncopyable {
235 public: 235 public:
236 /** Initialize with no objects */ 236 /** Initialize with no objects */
237 SkAutoSTArray() { 237 SkAutoSTArray() {
238 fArray = NULL; 238 fArray = NULL;
239 fCount = 0; 239 fCount = 0;
240 } 240 }
241 241
242 /** Allocate count number of T elements 242 /** Allocate count number of T elements
243 */ 243 */
244 SkAutoSTArray(size_t count) { 244 SkAutoSTArray(int count) {
245 fArray = NULL; 245 fArray = NULL;
246 fCount = 0; 246 fCount = 0;
247 this->reset(count); 247 this->reset(count);
248 } 248 }
249 249
250 ~SkAutoSTArray() { 250 ~SkAutoSTArray() {
251 this->reset(0); 251 this->reset(0);
252 } 252 }
253 253
254 /** Destroys previous objects in the array and default constructs count numb er of objects */ 254 /** Destroys previous objects in the array and default constructs count numb er of objects */
255 void reset(size_t count) { 255 void reset(int count) {
256 T* start = fArray; 256 T* start = fArray;
257 T* iter = start + fCount; 257 T* iter = start + fCount;
258 while (iter > start) { 258 while (iter > start) {
259 (--iter)->~T(); 259 (--iter)->~T();
260 } 260 }
261 261
262 if (fCount != count) { 262 if (fCount != count) {
263 if (fCount > N) { 263 if (fCount > N) {
264 // 'fArray' was allocated last time so free it now 264 // 'fArray' was allocated last time so free it now
265 SkASSERT((T*) fStorage != fArray); 265 SkASSERT((T*) fStorage != fArray);
(...skipping 13 matching lines...) Expand all
279 279
280 iter = fArray; 280 iter = fArray;
281 T* stop = fArray + count; 281 T* stop = fArray + count;
282 while (iter < stop) { 282 while (iter < stop) {
283 SkNEW_PLACEMENT(iter++, T); 283 SkNEW_PLACEMENT(iter++, T);
284 } 284 }
285 } 285 }
286 286
287 /** Return the number of T elements in the array 287 /** Return the number of T elements in the array
288 */ 288 */
289 size_t count() const { return fCount; } 289 int count() const { return fCount; }
290 290
291 /** Return the array of T elements. Will be NULL if count == 0 291 /** Return the array of T elements. Will be NULL if count == 0
292 */ 292 */
293 T* get() const { return fArray; } 293 T* get() const { return fArray; }
294 294
295 /** Return the nth element in the array 295 /** Return the nth element in the array
296 */ 296 */
297 T& operator[](int index) const { 297 T& operator[](int index) const {
298 SkASSERT((unsigned)index < fCount); 298 SkASSERT(index < fCount);
299 return fArray[index]; 299 return fArray[index];
300 } 300 }
301 301
302 private: 302 private:
303 size_t fCount; 303 int fCount;
304 T* fArray; 304 T* fArray;
305 // since we come right after fArray, fStorage should be properly aligned 305 // since we come right after fArray, fStorage should be properly aligned
306 char fStorage[N * sizeof(T)]; 306 char fStorage[N * sizeof(T)];
307 }; 307 };
308 308
309 /** Manages an array of T elements, freeing the array in the destructor. 309 /** Manages an array of T elements, freeing the array in the destructor.
310 * Does NOT call any constructors/destructors on T (T must be POD). 310 * Does NOT call any constructors/destructors on T (T must be POD).
311 */ 311 */
312 template <typename T> class SkAutoTMalloc : SkNoncopyable { 312 template <typename T> class SkAutoTMalloc : SkNoncopyable {
313 public: 313 public:
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 /** 458 /**
459 * Returns void* because this object does not initialize the 459 * Returns void* because this object does not initialize the
460 * memory. Use placement new for types that require a cons. 460 * memory. Use placement new for types that require a cons.
461 */ 461 */
462 void* get() { return fStorage.get(); } 462 void* get() { return fStorage.get(); }
463 private: 463 private:
464 SkAlignedSStorage<sizeof(T)*N> fStorage; 464 SkAlignedSStorage<sizeof(T)*N> fStorage;
465 }; 465 };
466 466
467 #endif 467 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkWriter32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698