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

Side by Side Diff: include/utils/win/SkTScopedComPtr.h

Issue 14600009: TTC support for DirectWrite. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Add some missing error checks. 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 | src/ports/SkFontHost_win_dw.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 /* 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) { 22 template<typename T> T* SkRefComPtr(T* ptr) {
23 ptr->AddRef(); 23 ptr->AddRef();
24 return ptr; 24 return ptr;
25 } 25 }
26 26
27 template<typename T> T* SkSafeRefComPtr(T* ptr) {
28 if (ptr) {
29 ptr->AddRef();
30 }
31 return ptr;
32 }
33
27 template<typename T> 34 template<typename T>
28 class SkTScopedComPtr : SkNoncopyable { 35 class SkTScopedComPtr : SkNoncopyable {
29 private: 36 private:
30 T *fPtr; 37 T *fPtr;
31 38
32 public: 39 public:
33 explicit SkTScopedComPtr(T *ptr = NULL) : fPtr(ptr) { } 40 explicit SkTScopedComPtr(T *ptr = NULL) : fPtr(ptr) { }
34 ~SkTScopedComPtr() { 41 ~SkTScopedComPtr() {
35 this->reset(); 42 this->reset();
36 } 43 }
(...skipping 23 matching lines...) Expand all
60 } 67 }
61 68
62 T* release() { 69 T* release() {
63 T* temp = this->fPtr; 70 T* temp = this->fPtr;
64 this->fPtr = NULL; 71 this->fPtr = NULL;
65 return temp; 72 return temp;
66 } 73 }
67 }; 74 };
68 75
69 #endif 76 #endif
OLDNEW
« no previous file with comments | « no previous file | src/ports/SkFontHost_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698