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

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

Issue 504313002: Make GrGpuResources register with GrResourceCache2 after fully constructed. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix insertion for GlyphPathRange. 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() {
31 get_resource_cache2(fGpu)->insertResource(this); 34 get_resource_cache2(fGpu)->insertResource(this);
32 } 35 }
33 36
34 GrGpuResource::~GrGpuResource() { 37 GrGpuResource::~GrGpuResource() {
35 SkASSERT(0 == fRefCnt); 38 SkASSERT(0 == fRefCnt);
36 // subclass should have released this. 39 // subclass should have released this.
37 SkASSERT(this->wasDestroyed()); 40 SkASSERT(this->wasDestroyed());
38 } 41 }
39 42
40 void GrGpuResource::release() { 43 void GrGpuResource::release() {
41 if (NULL != fGpu) { 44 if (NULL != fGpu) {
42 this->onRelease(); 45 this->onRelease();
43 get_resource_cache2(fGpu)->removeResource(this); 46 get_resource_cache2(fGpu)->removeResource(this);
44 fGpu = NULL; 47 fGpu = NULL;
45 } 48 }
46 } 49 }
47 50
48 void GrGpuResource::abandon() { 51 void GrGpuResource::abandon() {
49 if (NULL != fGpu) { 52 if (NULL != fGpu) {
50 this->onAbandon(); 53 this->onAbandon();
(...skipping 19 matching lines...) Expand all
70 } 73 }
71 74
72 uint32_t GrGpuResource::CreateUniqueID() { 75 uint32_t GrGpuResource::CreateUniqueID() {
73 static int32_t gUniqueID = SK_InvalidUniqueID; 76 static int32_t gUniqueID = SK_InvalidUniqueID;
74 uint32_t id; 77 uint32_t id;
75 do { 78 do {
76 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); 79 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
77 } while (id == SK_InvalidUniqueID); 80 } while (id == SK_InvalidUniqueID);
78 return id; 81 return id;
79 } 82 }
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