OLD | NEW |
---|---|
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" |
11 #include "GrResourceCache2.h" | 11 #include "GrResourceCache2.h" |
12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
13 | 13 |
14 static inline GrResourceCache2* get_resource_cache2(GrGpu* gpu) { | 14 static inline GrResourceCache2* get_resource_cache2(GrGpu* gpu) { |
15 SkASSERT(NULL != gpu); | 15 SkASSERT(NULL != gpu); |
16 SkASSERT(NULL != gpu->getContext()); | 16 SkASSERT(NULL != gpu->getContext()); |
17 SkASSERT(NULL != gpu->getContext()->getResourceCache2()); | 17 SkASSERT(NULL != gpu->getContext()->getResourceCache2()); |
18 return gpu->getContext()->getResourceCache2(); | 18 return gpu->getContext()->getResourceCache2(); |
19 } | 19 } |
20 | 20 |
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 , fScratchKey(GrResourceKey::NullScratchKey()) { | |
26 if (isWrapped) { | 27 if (isWrapped) { |
27 fFlags = kWrapped_FlagBit; | 28 fFlags = kWrapped_FlagBit; |
28 } else { | 29 } else { |
29 fFlags = 0; | 30 fFlags = 0; |
30 } | 31 } |
31 } | 32 } |
32 | 33 |
33 void GrGpuResource::registerWithCache() { | 34 void GrGpuResource::registerWithCache() { |
34 get_resource_cache2(fGpu)->insertResource(this); | 35 get_resource_cache2(fGpu)->insertResource(this); |
35 } | 36 } |
(...skipping 29 matching lines...) Expand all Loading... | |
65 } | 66 } |
66 | 67 |
67 GrContext* GrGpuResource::getContext() { | 68 GrContext* GrGpuResource::getContext() { |
68 if (NULL != fGpu) { | 69 if (NULL != fGpu) { |
69 return fGpu->getContext(); | 70 return fGpu->getContext(); |
70 } else { | 71 } else { |
71 return NULL; | 72 return NULL; |
72 } | 73 } |
73 } | 74 } |
74 | 75 |
76 void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) { | |
77 SkASSERT(fScratchKey.isNullScratch()); | |
robertphillips
2014/08/27 19:11:30
Do we want to assert that scratchKey is not null ?
bsalomon
2014/08/27 20:37:40
Done.
| |
78 SkASSERT(scratchKey.isScratch()); | |
79 fScratchKey = scratchKey; | |
80 } | |
81 | |
75 uint32_t GrGpuResource::CreateUniqueID() { | 82 uint32_t GrGpuResource::CreateUniqueID() { |
76 static int32_t gUniqueID = SK_InvalidUniqueID; | 83 static int32_t gUniqueID = SK_InvalidUniqueID; |
77 uint32_t id; | 84 uint32_t id; |
78 do { | 85 do { |
79 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 86 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
80 } while (id == SK_InvalidUniqueID); | 87 } while (id == SK_InvalidUniqueID); |
81 return id; | 88 return id; |
82 } | 89 } |
OLD | NEW |