aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
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 /include
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 'include')
-rw-r--r--include/gpu/GrContext.h4
-rw-r--r--include/gpu/GrGpuResource.h16
2 files changed, 19 insertions, 1 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 64f4f6ce30..1775166419 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -43,6 +43,7 @@ class GrTextureParams;
class GrVertexBuffer;
class GrStrokeInfo;
class GrSoftwarePathRenderer;
+class SkTraceMemoryDump;
class SK_API GrContext : public SkRefCnt {
public:
@@ -358,6 +359,9 @@ public:
to an array of 3 entries */
void setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* configs);
+ /** Enumerates all cached GPU resources and dumps their memory to traceMemoryDump. */
+ void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
+
private:
GrGpu* fGpu;
const GrCaps* fCaps;
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index d726115a72..8103959984 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -15,6 +15,7 @@
class GrContext;
class GrGpu;
class GrResourceCache;
+class SkTraceMemoryDump;
/**
* Base class for GrGpuResource. Handles the various types of refs we need. Separated out as a base
@@ -138,7 +139,7 @@ private:
*/
class SK_API GrGpuResource : public GrIORef<GrGpuResource> {
public:
-
+
enum LifeCycle {
/**
@@ -252,6 +253,13 @@ public:
*/
void abandon();
+ /**
+ * Dumps memory usage information for this GrGpuResource to traceMemoryDump.
+ * Typically, subclasses should not need to override this, and should only
+ * need to override setMemoryBacking.
+ **/
+ virtual void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
+
protected:
// This must be called by every GrGpuObject. It should be called once the object is fully
// initialized (i.e. not in a base class constructor).
@@ -288,6 +296,12 @@ protected:
**/
void setScratchKey(const GrScratchKey& scratchKey);
+ /**
+ * Allows subclasses to add additional backing information to the SkTraceMemoryDump. Called by
+ * onMemoryDump. The default implementation adds no backing information.
+ **/
+ virtual void setMemoryBacking(SkTraceMemoryDump*, const SkString&) const {}
+
private:
/**
* Frees the object in the underlying 3D API. Called by CacheAccess.