| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "GrGpuResource.h" | 8 #include "GrGpuResource.h" |
| 9 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 #include "GrResourceCache.h" | 10 #include "GrResourceCache.h" |
| 11 #include "GrGpu.h" | 11 #include "GrGpu.h" |
| 12 #include "GrGpuResourcePriv.h" | 12 #include "GrGpuResourcePriv.h" |
| 13 #include "SkTraceMemoryDump.h" | 13 #include "SkTraceMemoryDump.h" |
| 14 | 14 |
| 15 static inline GrResourceCache* get_resource_cache(GrGpu* gpu) { | 15 static inline GrResourceCache* get_resource_cache(GrGpu* gpu) { |
| 16 SkASSERT(gpu); | 16 SkASSERT(gpu); |
| 17 SkASSERT(gpu->getContext()); | 17 SkASSERT(gpu->getContext()); |
| 18 SkASSERT(gpu->getContext()->getResourceCache()); | 18 SkASSERT(gpu->getContext()->getResourceCache()); |
| 19 return gpu->getContext()->getResourceCache(); | 19 return gpu->getContext()->getResourceCache(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 GrGpuResource::GrGpuResource(GrGpu* gpu) | 22 GrGpuResource::GrGpuResource(GrGpu* gpu) |
| 23 : fGpu(gpu) | 23 : fExternalFlushCntWhenBecamePurgeable(0) |
| 24 , fGpu(gpu) |
| 24 , fGpuMemorySize(kInvalidGpuMemorySize) | 25 , fGpuMemorySize(kInvalidGpuMemorySize) |
| 25 , fBudgeted(SkBudgeted::kNo) | 26 , fBudgeted(SkBudgeted::kNo) |
| 26 , fRefsWrappedObjects(false) | 27 , fRefsWrappedObjects(false) |
| 27 , fUniqueID(CreateUniqueID()) { | 28 , fUniqueID(CreateUniqueID()) { |
| 28 SkDEBUGCODE(fCacheArrayIndex = -1); | 29 SkDEBUGCODE(fCacheArrayIndex = -1); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void GrGpuResource::registerWithCache(SkBudgeted budgeted) { | 32 void GrGpuResource::registerWithCache(SkBudgeted budgeted) { |
| 32 SkASSERT(fBudgeted == SkBudgeted::kNo); | 33 SkASSERT(fBudgeted == SkBudgeted::kNo); |
| 33 fBudgeted = budgeted; | 34 fBudgeted = budgeted; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 195 } |
| 195 | 196 |
| 196 uint32_t GrGpuResource::CreateUniqueID() { | 197 uint32_t GrGpuResource::CreateUniqueID() { |
| 197 static int32_t gUniqueID = SK_InvalidUniqueID; | 198 static int32_t gUniqueID = SK_InvalidUniqueID; |
| 198 uint32_t id; | 199 uint32_t id; |
| 199 do { | 200 do { |
| 200 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 201 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
| 201 } while (id == SK_InvalidUniqueID); | 202 } while (id == SK_InvalidUniqueID); |
| 202 return id; | 203 return id; |
| 203 } | 204 } |
| OLD | NEW |