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

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

Issue 14314008: Add FontMgr to DirectWrite. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Add matcher, fix GrGLCaps. Created 7 years, 7 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/utils/win/SkTScopedComPtr.h » ('j') | src/gpu/gl/GrGLCaps.cpp » ('J')
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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 const T& operator[](int index) const { 288 const T& operator[](int index) const {
289 return fPtr[index]; 289 return fPtr[index];
290 } 290 }
291 291
292 private: 292 private:
293 T* fPtr; 293 T* fPtr;
294 }; 294 };
295 295
296 template <size_t N, typename T> class SK_API SkAutoSTMalloc : SkNoncopyable { 296 template <size_t N, typename T> class SK_API SkAutoSTMalloc : SkNoncopyable {
297 public: 297 public:
298 SkAutoSTMalloc() {
299 fPtr = NULL;
300 }
301
298 SkAutoSTMalloc(size_t count) { 302 SkAutoSTMalloc(size_t count) {
299 if (count <= N) { 303 if (count > N) {
304 fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_M ALLOC_TEMP);
305 } else if (count) {
300 fPtr = fTStorage; 306 fPtr = fTStorage;
301 } else { 307 } else {
302 fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_M ALLOC_TEMP); 308 fPtr = NULL;
303 } 309 }
304 } 310 }
305 311
306 ~SkAutoSTMalloc() { 312 ~SkAutoSTMalloc() {
307 if (fPtr != fTStorage) { 313 if (fPtr != fTStorage) {
308 sk_free(fPtr); 314 sk_free(fPtr);
309 } 315 }
310 } 316 }
311 317
312 // doesn't preserve contents 318 // doesn't preserve contents
313 void reset(size_t count) { 319 void reset(size_t count) {
314 if (fPtr != fTStorage) { 320 if (fPtr != fTStorage) {
315 sk_free(fPtr); 321 sk_free(fPtr);
316 } 322 }
317 if (count <= N) { 323 if (count > N) {
324 fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_M ALLOC_TEMP);
325 } else if (count) {
318 fPtr = fTStorage; 326 fPtr = fTStorage;
319 } else { 327 } else {
320 fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_M ALLOC_TEMP); 328 fPtr = NULL;
321 } 329 }
322 } 330 }
323 331
324 T* get() const { return fPtr; } 332 T* get() const { return fPtr; }
325 333
326 operator T*() { 334 operator T*() {
327 return fPtr; 335 return fPtr;
328 } 336 }
329 337
330 operator const T*() const { 338 operator const T*() const {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 /** 381 /**
374 * Returns void* because this object does not initialize the 382 * Returns void* because this object does not initialize the
375 * memory. Use placement new for types that require a cons. 383 * memory. Use placement new for types that require a cons.
376 */ 384 */
377 void* get() { return fStorage.get(); } 385 void* get() { return fStorage.get(); }
378 private: 386 private:
379 SkAlignedSStorage<sizeof(T)*N> fStorage; 387 SkAlignedSStorage<sizeof(T)*N> fStorage;
380 }; 388 };
381 389
382 #endif 390 #endif
OLDNEW
« no previous file with comments | « no previous file | include/utils/win/SkTScopedComPtr.h » ('j') | src/gpu/gl/GrGLCaps.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698