| OLD | NEW |
| 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 | 8 |
| 9 #ifndef SkSkTScopedPtr_DEFINED | 9 #ifndef SkSkTScopedPtr_DEFINED |
| 10 #define SkSkTScopedPtr_DEFINED | 10 #define SkSkTScopedPtr_DEFINED |
| 11 | 11 |
| 12 #include "SkTypes.h" | 12 #include "SkTypes.h" |
| 13 #include "SkTemplates.h" | 13 #include "SkTemplates.h" |
| 14 | 14 |
| 15 template<typename T> | 15 template<typename T> |
| 16 class SkBlockComRef : public T { | 16 class SkBlockComRef : public T { |
| 17 private: | 17 private: |
| 18 virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0; | 18 virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0; |
| 19 virtual ULONG STDMETHODCALLTYPE Release(void) = 0; | 19 virtual ULONG STDMETHODCALLTYPE Release(void) = 0; |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 template<typename T> T* SkRefComPtr(T* ptr) { |
| 23 ptr->AddRef(); |
| 24 return ptr; |
| 25 } |
| 26 |
| 22 template<typename T> | 27 template<typename T> |
| 23 class SkTScopedComPtr : SkNoncopyable { | 28 class SkTScopedComPtr : SkNoncopyable { |
| 24 private: | 29 private: |
| 25 T *fPtr; | 30 T *fPtr; |
| 26 | 31 |
| 27 public: | 32 public: |
| 28 explicit SkTScopedComPtr(T *ptr = NULL) : fPtr(ptr) { } | 33 explicit SkTScopedComPtr(T *ptr = NULL) : fPtr(ptr) { } |
| 29 ~SkTScopedComPtr() { | 34 ~SkTScopedComPtr() { |
| 30 this->reset(); | 35 this->reset(); |
| 31 } | 36 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 55 } | 60 } |
| 56 | 61 |
| 57 T* release() { | 62 T* release() { |
| 58 T* temp = this->fPtr; | 63 T* temp = this->fPtr; |
| 59 this->fPtr = NULL; | 64 this->fPtr = NULL; |
| 60 return temp; | 65 return temp; |
| 61 } | 66 } |
| 62 }; | 67 }; |
| 63 | 68 |
| 64 #endif | 69 #endif |
| OLD | NEW |