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

Unified Diff: src/gpu/GrGpuResource.cpp

Issue 1313743002: Add onMemoryDump to GrContext (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Review feedback Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrGpuResource.cpp
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index 49212df416d8d639b143e7580fd9f507d33e2395..520a1c21c59052c265b617876d4610baad2c7265 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -11,6 +11,7 @@
#include "GrResourceCache.h"
#include "GrGpu.h"
#include "GrGpuResourcePriv.h"
+#include "SkTraceMemoryDump.h"
static inline GrResourceCache* get_resource_cache(GrGpu* gpu) {
SkASSERT(gpu);
@@ -36,7 +37,7 @@ GrGpuResource::~GrGpuResource() {
SkASSERT(this->wasDestroyed());
}
-void GrGpuResource::release() {
+void GrGpuResource::release() {
SkASSERT(fGpu);
this->onRelease();
get_resource_cache(fGpu)->resourceAccess().removeResource(this);
@@ -52,6 +53,23 @@ void GrGpuResource::abandon() {
fGpuMemorySize = 0;
}
+void GrGpuResource::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
+ // Dump resource as "skia/gpu_resources/resource_#".
+ SkString dumpName("skia/gpu_resources/resource_");
ssid 2015/08/26 17:10:03 Is the plan to dump all the gpu resources in separ
ericrk 2015/08/26 19:40:21 Pretty sure we want to dump this under skia/, simi
+ dumpName.appendS32(this->getUniqueID());
+
+ traceMemoryDump->dumpNumericValue(dumpName.c_str(), "size", "bytes", this->gpuMemorySize());
+
+ if (this->isPurgeable()) {
+ traceMemoryDump->dumpNumericValue(dumpName.c_str(), "purgeable_size", "bytes",
+ this->gpuMemorySize());
+ }
+
+ // Call setMemoryBacking to allow sub-classes with implementation specific backings (such as GL
+ // objects) to provide additional information.
+ this->setMemoryBacking(traceMemoryDump, dumpName);
+}
+
const SkData* GrGpuResource::setCustomData(const SkData* data) {
SkSafeRef(data);
fData.reset(data);
« src/gpu/GrContext.cpp ('K') | « src/gpu/GrContext.cpp ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698