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

Side by Side Diff: src/gpu/vk/GrVkResource.h

Issue 2167453003: Add GrVkRecycledResource subclass (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove extra unref Created 4 years, 5 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 | « src/gpu/vk/GrVkCommandBuffer.cpp ('k') | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 GrVkResource_DEFINED 8 #ifndef GrVkResource_DEFINED
9 #define GrVkResource_DEFINED 9 #define GrVkResource_DEFINED
10 10
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 184 }
185 185
186 mutable int32_t fRefCnt; 186 mutable int32_t fRefCnt;
187 #ifdef SK_TRACE_VK_RESOURCES 187 #ifdef SK_TRACE_VK_RESOURCES
188 uint32_t fKey; 188 uint32_t fKey;
189 #endif 189 #endif
190 190
191 typedef SkNoncopyable INHERITED; 191 typedef SkNoncopyable INHERITED;
192 }; 192 };
193 193
194 // This subclass allows for recycling
195 class GrVkRecycledResource : public GrVkResource {
196 public:
197 // When recycle is called and there is only one ref left on the resource, we will signal that
198 // the resource can be recycled for reuse. This function will always unref t he object. Thus
199 // if the object is recycled it should be ref'd inside the onRecycle call.
200 void recycle(GrVkGpu* gpu) const {
201 if (this->unique()) {
202 this->onRecycle(gpu);
203 }
204 this->unref(gpu);
205 }
206
207 private:
208 virtual void onRecycle(GrVkGpu* gpu) const = 0;
209 };
194 210
195 #endif 211 #endif
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkCommandBuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698