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

Side by Side Diff: src/gpu/GrGpuResource.cpp

Issue 488463004: Revert of Make GrGpuResources register with GrResourceCache2 after fully constructed. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 | « include/gpu/GrGpuResource.h ('k') | src/gpu/GrPathRange.h » ('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 9
10 #include "GrGpuResource.h" 10 #include "GrGpuResource.h"
(...skipping 10 matching lines...) Expand all
21 GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped) 21 GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped)
22 : fGpu(gpu) 22 : fGpu(gpu)
23 , fRefCnt(1) 23 , fRefCnt(1)
24 , fCacheEntry(NULL) 24 , fCacheEntry(NULL)
25 , fUniqueID(CreateUniqueID()) { 25 , fUniqueID(CreateUniqueID()) {
26 if (isWrapped) { 26 if (isWrapped) {
27 fFlags = kWrapped_FlagBit; 27 fFlags = kWrapped_FlagBit;
28 } else { 28 } else {
29 fFlags = 0; 29 fFlags = 0;
30 } 30 }
31 }
32
33 void GrGpuResource::registerWithCache() {
34 get_resource_cache2(fGpu)->insertResource(this); 31 get_resource_cache2(fGpu)->insertResource(this);
35 } 32 }
36 33
37 GrGpuResource::~GrGpuResource() { 34 GrGpuResource::~GrGpuResource() {
38 SkASSERT(0 == fRefCnt); 35 SkASSERT(0 == fRefCnt);
39 // subclass should have released this. 36 // subclass should have released this.
40 SkASSERT(this->wasDestroyed()); 37 SkASSERT(this->wasDestroyed());
41 } 38 }
42 39
43 void GrGpuResource::release() { 40 void GrGpuResource::release() {
44 if (NULL != fGpu) { 41 if (NULL != fGpu) {
45 this->onRelease(); 42 this->onRelease();
46 get_resource_cache2(fGpu)->removeResource(this); 43 get_resource_cache2(fGpu)->removeResource(this);
47 fGpu = NULL; 44 fGpu = NULL;
48 } 45 }
49 } 46 }
50 47
51 void GrGpuResource::abandon() { 48 void GrGpuResource::abandon() {
52 if (NULL != fGpu) { 49 if (NULL != fGpu) {
53 this->onAbandon(); 50 this->onAbandon();
(...skipping 19 matching lines...) Expand all
73 } 70 }
74 71
75 uint32_t GrGpuResource::CreateUniqueID() { 72 uint32_t GrGpuResource::CreateUniqueID() {
76 static int32_t gUniqueID = SK_InvalidUniqueID; 73 static int32_t gUniqueID = SK_InvalidUniqueID;
77 uint32_t id; 74 uint32_t id;
78 do { 75 do {
79 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); 76 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
80 } while (id == SK_InvalidUniqueID); 77 } while (id == SK_InvalidUniqueID);
81 return id; 78 return id;
82 } 79 }
OLDNEW
« no previous file with comments | « include/gpu/GrGpuResource.h ('k') | src/gpu/GrPathRange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698