aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpuResource.cpp
diff options
context:
space:
mode:
authorGravatar ericrk <ericrk@chromium.org>2015-09-15 14:16:10 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-15 14:16:10 -0700
commit0a5fa484fd58d27088f8696bdc11c8cc8f2b4866 (patch)
tree3b4559d7da20b1de45b1a537378c8a36bca75511 /src/gpu/GrGpuResource.cpp
parenteb00eaba0cb0be4ba39a7c00b6be8347136ce4ae (diff)
Add onMemoryDump to GrContext
Adds an entry point to GrContext to allow enumeration and tracing of GPU resources via the newly added SkTraceMemoryDump. Plan is for Chrome to call this on each of its GrContexts. Dumps both the total size of GPU resources, as well as the total purgeable size. BUG=526261 Review URL: https://codereview.chromium.org/1313743002
Diffstat (limited to 'src/gpu/GrGpuResource.cpp')
-rw-r--r--src/gpu/GrGpuResource.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index df8301c506..f8cb529314 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);
@@ -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_");
+ 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);