| 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" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 SkASSERT(fGpu); | 62 SkASSERT(fGpu); |
| 63 this->onAbandon(); | 63 this->onAbandon(); |
| 64 get_resource_cache(fGpu)->resourceAccess().removeResource(this); | 64 get_resource_cache(fGpu)->resourceAccess().removeResource(this); |
| 65 fGpu = nullptr; | 65 fGpu = nullptr; |
| 66 fGpuMemorySize = 0; | 66 fGpuMemorySize = 0; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void GrGpuResource::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) con
st { | 69 void GrGpuResource::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) con
st { |
| 70 // Dump resource as "skia/gpu_resources/resource_#". | 70 // Dump resource as "skia/gpu_resources/resource_#". |
| 71 SkString dumpName("skia/gpu_resources/resource_"); | 71 SkString dumpName("skia/gpu_resources/resource_"); |
| 72 dumpName.appendS32(this->getUniqueID()); | 72 dumpName.appendS32(this->uniqueID()); |
| 73 | 73 |
| 74 traceMemoryDump->dumpNumericValue(dumpName.c_str(), "size", "bytes", this->g
puMemorySize()); | 74 traceMemoryDump->dumpNumericValue(dumpName.c_str(), "size", "bytes", this->g
puMemorySize()); |
| 75 | 75 |
| 76 if (this->isPurgeable()) { | 76 if (this->isPurgeable()) { |
| 77 traceMemoryDump->dumpNumericValue(dumpName.c_str(), "purgeable_size", "b
ytes", | 77 traceMemoryDump->dumpNumericValue(dumpName.c_str(), "purgeable_size", "b
ytes", |
| 78 this->gpuMemorySize()); | 78 this->gpuMemorySize()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Call setMemoryBacking to allow sub-classes with implementation specific b
ackings (such as GL | 81 // Call setMemoryBacking to allow sub-classes with implementation specific b
ackings (such as GL |
| 82 // objects) to provide additional information. | 82 // objects) to provide additional information. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 194 } |
| 195 | 195 |
| 196 uint32_t GrGpuResource::CreateUniqueID() { | 196 uint32_t GrGpuResource::CreateUniqueID() { |
| 197 static int32_t gUniqueID = SK_InvalidUniqueID; | 197 static int32_t gUniqueID = SK_InvalidUniqueID; |
| 198 uint32_t id; | 198 uint32_t id; |
| 199 do { | 199 do { |
| 200 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 200 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
| 201 } while (id == SK_InvalidUniqueID); | 201 } while (id == SK_InvalidUniqueID); |
| 202 return id; | 202 return id; |
| 203 } | 203 } |
| OLD | NEW |