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

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

Issue 2075913002: Revert of Support pixel antialising in DirectWrite. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | src/ports/SkFontMgr_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 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 SkTScopedComPtr_DEFINED 8 #ifndef SkTScopedComPtr_DEFINED
9 #define SkTScopedComPtr_DEFINED 9 #define SkTScopedComPtr_DEFINED
10 10
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 return ptr; 31 return ptr;
32 } 32 }
33 33
34 template<typename T> 34 template<typename T>
35 class SkTScopedComPtr : SkNoncopyable { 35 class SkTScopedComPtr : SkNoncopyable {
36 private: 36 private:
37 T *fPtr; 37 T *fPtr;
38 38
39 public: 39 public:
40 explicit SkTScopedComPtr(T *ptr = nullptr) : fPtr(ptr) { } 40 explicit SkTScopedComPtr(T *ptr = NULL) : fPtr(ptr) { }
41 ~SkTScopedComPtr() { 41 ~SkTScopedComPtr() {
42 this->reset(); 42 this->reset();
43 } 43 }
44 T &operator*() const { SkASSERT(fPtr != nullptr); return *fPtr; } 44 T &operator*() const { SkASSERT(fPtr != NULL); return *fPtr; }
45 SkBlockComRef<T> *operator->() const { 45 SkBlockComRef<T> *operator->() const {
46 return static_cast<SkBlockComRef<T>*>(fPtr); 46 return static_cast<SkBlockComRef<T>*>(fPtr);
47 } 47 }
48 /** 48 /**
49 * Returns the address of the underlying pointer. 49 * Returns the address of the underlying pointer.
50 * This is dangerous -- it breaks encapsulation and the reference escapes. 50 * This is dangerous -- it breaks encapsulation and the reference escapes.
51 * Must only be used on instances currently pointing to NULL, 51 * Must only be used on instances currently pointing to NULL,
52 * and only to initialize the instance. 52 * and only to initialize the instance.
53 */ 53 */
54 T **operator&() { SkASSERT(fPtr == nullptr); return &fPtr; } 54 T **operator&() { SkASSERT(fPtr == NULL); return &fPtr; }
55 explicit operator bool() const { return fPtr != nullptr; }
56 T *get() const { return fPtr; } 55 T *get() const { return fPtr; }
57 void reset() { 56 void reset() {
58 if (this->fPtr) { 57 if (this->fPtr) {
59 this->fPtr->Release(); 58 this->fPtr->Release();
60 this->fPtr = nullptr; 59 this->fPtr = NULL;
61 } 60 }
62 } 61 }
63 62
64 void swap(SkTScopedComPtr<T>& that) { 63 void swap(SkTScopedComPtr<T>& that) {
65 T* temp = this->fPtr; 64 T* temp = this->fPtr;
66 this->fPtr = that.fPtr; 65 this->fPtr = that.fPtr;
67 that.fPtr = temp; 66 that.fPtr = temp;
68 } 67 }
69 68
70 T* release() { 69 T* release() {
71 T* temp = this->fPtr; 70 T* temp = this->fPtr;
72 this->fPtr = nullptr; 71 this->fPtr = NULL;
73 return temp; 72 return temp;
74 } 73 }
75 }; 74 };
76 75
77 #endif // SK_BUILD_FOR_WIN 76 #endif // SK_BUILD_FOR_WIN
78 #endif // SkTScopedComPtr_DEFINED 77 #endif // SkTScopedComPtr_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/ports/SkFontMgr_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698