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

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

Issue 1313743002: Add onMemoryDump to GrContext (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Small build fix Created 5 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 | « src/gpu/GrContext.cpp ('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 #include "GrGpuResource.h" 9 #include "GrGpuResource.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
11 #include "GrResourceCache.h" 11 #include "GrResourceCache.h"
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 #include "GrGpuResourcePriv.h" 13 #include "GrGpuResourcePriv.h"
14 #include "SkTraceMemoryDump.h"
14 15
15 static inline GrResourceCache* get_resource_cache(GrGpu* gpu) { 16 static inline GrResourceCache* get_resource_cache(GrGpu* gpu) {
16 SkASSERT(gpu); 17 SkASSERT(gpu);
17 SkASSERT(gpu->getContext()); 18 SkASSERT(gpu->getContext());
18 SkASSERT(gpu->getContext()->getResourceCache()); 19 SkASSERT(gpu->getContext()->getResourceCache());
19 return gpu->getContext()->getResourceCache(); 20 return gpu->getContext()->getResourceCache();
20 } 21 }
21 22
22 GrGpuResource::GrGpuResource(GrGpu* gpu, LifeCycle lifeCycle) 23 GrGpuResource::GrGpuResource(GrGpu* gpu, LifeCycle lifeCycle)
23 : fGpu(gpu) 24 : fGpu(gpu)
(...skipping 21 matching lines...) Expand all
45 } 46 }
46 47
47 void GrGpuResource::abandon() { 48 void GrGpuResource::abandon() {
48 SkASSERT(fGpu); 49 SkASSERT(fGpu);
49 this->onAbandon(); 50 this->onAbandon();
50 get_resource_cache(fGpu)->resourceAccess().removeResource(this); 51 get_resource_cache(fGpu)->resourceAccess().removeResource(this);
51 fGpu = nullptr; 52 fGpu = nullptr;
52 fGpuMemorySize = 0; 53 fGpuMemorySize = 0;
53 } 54 }
54 55
56 void GrGpuResource::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) con st {
57 // Dump resource as "skia/gpu_resources/resource_#".
58 SkString dumpName("skia/gpu_resources/resource_");
59 dumpName.appendS32(this->getUniqueID());
60
61 traceMemoryDump->dumpNumericValue(dumpName.c_str(), "size", "bytes", this->g puMemorySize());
62
63 if (this->isPurgeable()) {
64 traceMemoryDump->dumpNumericValue(dumpName.c_str(), "purgeable_size", "b ytes",
65 this->gpuMemorySize());
66 }
67
68 // Call setMemoryBacking to allow sub-classes with implementation specific b ackings (such as GL
69 // objects) to provide additional information.
70 this->setMemoryBacking(traceMemoryDump, dumpName);
71 }
72
55 const SkData* GrGpuResource::setCustomData(const SkData* data) { 73 const SkData* GrGpuResource::setCustomData(const SkData* data) {
56 SkSafeRef(data); 74 SkSafeRef(data);
57 fData.reset(data); 75 fData.reset(data);
58 return data; 76 return data;
59 } 77 }
60 78
61 const GrContext* GrGpuResource::getContext() const { 79 const GrContext* GrGpuResource::getContext() const {
62 if (fGpu) { 80 if (fGpu) {
63 return fGpu->getContext(); 81 return fGpu->getContext();
64 } else { 82 } else {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 191 }
174 192
175 uint32_t GrGpuResource::CreateUniqueID() { 193 uint32_t GrGpuResource::CreateUniqueID() {
176 static int32_t gUniqueID = SK_InvalidUniqueID; 194 static int32_t gUniqueID = SK_InvalidUniqueID;
177 uint32_t id; 195 uint32_t id;
178 do { 196 do {
179 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); 197 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
180 } while (id == SK_InvalidUniqueID); 198 } while (id == SK_InvalidUniqueID);
181 return id; 199 return id;
182 } 200 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698