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

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

Issue 414013005: Merge GrGpuObject and GrCacheable. (Closed) Base URL: https://skia.googlesource.com/skia.git@uniqueid
Patch Set: Address comments Created 6 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/GrGpu.h ('k') | src/gpu/GrResourceCache.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 "GrGpuObject.h" 10 #include "GrGpuObject.h"
11 #include "GrGpu.h" 11 #include "GrGpu.h"
12 12
13 GrGpuObject::GrGpuObject(GrGpu* gpu, bool isWrapped) { 13 GrGpuObject::GrGpuObject(GrGpu* gpu, bool isWrapped)
14 : fRefCnt(1)
15 , fCacheEntry(NULL)
16 , fUniqueID(CreateUniqueID()) {
14 fGpu = gpu; 17 fGpu = gpu;
15 if (isWrapped) { 18 if (isWrapped) {
16 fFlags = kWrapped_FlagBit; 19 fFlags = kWrapped_FlagBit;
17 } else { 20 } else {
18 fFlags = 0; 21 fFlags = 0;
19 } 22 }
20 fGpu->insertObject(this); 23 fGpu->insertObject(this);
21 } 24 }
22 25
23 GrGpuObject::~GrGpuObject() { 26 GrGpuObject::~GrGpuObject() {
27 SkASSERT(0 == fRefCnt);
24 // subclass should have released this. 28 // subclass should have released this.
25 SkASSERT(this->wasDestroyed()); 29 SkASSERT(this->wasDestroyed());
26 } 30 }
27 31
28 void GrGpuObject::release() { 32 void GrGpuObject::release() {
29 if (NULL != fGpu) { 33 if (NULL != fGpu) {
30 this->onRelease(); 34 this->onRelease();
31 fGpu->removeObject(this); 35 fGpu->removeObject(this);
32 fGpu = NULL; 36 fGpu = NULL;
33 } 37 }
(...skipping 15 matching lines...) Expand all
49 } 53 }
50 } 54 }
51 55
52 GrContext* GrGpuObject::getContext() { 56 GrContext* GrGpuObject::getContext() {
53 if (NULL != fGpu) { 57 if (NULL != fGpu) {
54 return fGpu->getContext(); 58 return fGpu->getContext();
55 } else { 59 } else {
56 return NULL; 60 return NULL;
57 } 61 }
58 } 62 }
63
64 uint32_t GrGpuObject::CreateUniqueID() {
65 static int32_t gUniqueID = SK_InvalidUniqueID;
66 uint32_t id;
67 do {
68 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
69 } while (id == SK_InvalidUniqueID);
70 return id;
71 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698