OLD | NEW |
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 GrGpuObject_DEFINED | 8 #ifndef GrGpuObject_DEFINED |
9 #define GrGpuObject_DEFINED | 9 #define GrGpuObject_DEFINED |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 virtual ~GrGpuObject(); | 66 virtual ~GrGpuObject(); |
67 | 67 |
68 GrGpu* getGpu() const { return fGpu; } | 68 GrGpu* getGpu() const { return fGpu; } |
69 | 69 |
70 // Derived classes should always call their parent class' onRelease | 70 // Derived classes should always call their parent class' onRelease |
71 // and onAbandon methods in their overrides. | 71 // and onAbandon methods in their overrides. |
72 virtual void onRelease() {}; | 72 virtual void onRelease() {}; |
73 virtual void onAbandon() {}; | 73 virtual void onAbandon() {}; |
74 | 74 |
75 bool isWrapped() const { return kWrapped_FlagBit & fFlags; } | 75 bool isWrapped() const { return kWrapped_FlagBit & fFlags; } |
76 bool needsDeferredUnref() const { return SkToBool(kDeferredUnref_FlagBit & f
Flags); } | |
77 | 76 |
78 private: | 77 private: |
79 #ifdef SK_DEBUG | 78 #ifdef SK_DEBUG |
80 friend class GrGpu; // for assert in GrGpu to access getGpu | 79 friend class GrGpu; // for assert in GrGpu to access getGpu |
81 #endif | 80 #endif |
82 | 81 |
83 // We're in an internal doubly linked list | 82 // We're in an internal doubly linked list |
84 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrGpuObject); | 83 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrGpuObject); |
85 | 84 |
86 GrGpu* fGpu; // not reffed. The GrGpu can be dele
ted while there | 85 GrGpu* fGpu; // not reffed. The GrGpu can be dele
ted while there |
87 // are still live GrGpuObjects. It w
ill call | 86 // are still live GrGpuObjects. It w
ill call |
88 // release() on all such objects in
its destructor. | 87 // release() on all such objects in
its destructor. |
89 mutable int fDeferredRefCount; // How many references in deferred d
rawing buffers. | |
90 | |
91 enum Flags { | 88 enum Flags { |
92 /** | 89 /** |
93 * This object wraps a GPU object given to us by the user. | 90 * This object wraps a GPU object given to us by the user. |
94 * Lifetime management is left up to the user (i.e., we will not | 91 * Lifetime management is left up to the user (i.e., we will not |
95 * free it). | 92 * free it). |
96 */ | 93 */ |
97 kWrapped_FlagBit = 0x1, | 94 kWrapped_FlagBit = 0x1, |
98 | |
99 /** | |
100 * This texture should be de-refed when the deferred ref count goes | |
101 * to zero. An object gets into this state when the resource cache | |
102 * is holding a ref-of-obligation (i.e., someone needs to own it but | |
103 * no one else wants to) but doesn't really want to keep it around. | |
104 */ | |
105 kDeferredUnref_FlagBit = 0x2, | |
106 }; | 95 }; |
107 uint32_t fFlags; | 96 uint32_t fFlags; |
108 | 97 |
109 typedef GrCacheable INHERITED; | 98 typedef GrCacheable INHERITED; |
110 }; | 99 }; |
111 | 100 |
112 #endif | 101 #endif |
OLD | NEW |