OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrTemplates_DEFINED | 8 #ifndef GrTemplates_DEFINED |
9 #define GrTemplates_DEFINED | 9 #define GrTemplates_DEFINED |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 * e.g.: | 28 * e.g.: |
29 * { | 29 * { |
30 * GrAutoTRestore<int*> autoCountRestore; | 30 * GrAutoTRestore<int*> autoCountRestore; |
31 * if (useExtra) { | 31 * if (useExtra) { |
32 * autoCountRestore.reset(&fCount); | 32 * autoCountRestore.reset(&fCount); |
33 * fCount += fExtraCount; | 33 * fCount += fExtraCount; |
34 * } | 34 * } |
35 * ... | 35 * ... |
36 * } // fCount is restored | 36 * } // fCount is restored |
37 */ | 37 */ |
38 template <typename T> class GrAutoTRestore : public SkNoncopyable { | 38 template <typename T> class GrAutoTRestore : SkNoncopyable { |
39 public: | 39 public: |
40 GrAutoTRestore() : fPtr(NULL), fVal() {} | 40 GrAutoTRestore() : fPtr(NULL), fVal() {} |
41 | 41 |
42 GrAutoTRestore(T* ptr) { | 42 GrAutoTRestore(T* ptr) { |
43 fPtr = ptr; | 43 fPtr = ptr; |
44 if (NULL != ptr) { | 44 if (NULL != ptr) { |
45 fVal = *ptr; | 45 fVal = *ptr; |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
(...skipping 10 matching lines...) Expand all Loading... |
59 } | 59 } |
60 fPtr = ptr; | 60 fPtr = ptr; |
61 fVal = *ptr; | 61 fVal = *ptr; |
62 } | 62 } |
63 private: | 63 private: |
64 T* fPtr; | 64 T* fPtr; |
65 T fVal; | 65 T fVal; |
66 }; | 66 }; |
67 | 67 |
68 #endif | 68 #endif |
OLD | NEW |