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

Unified Diff: include/gpu/GrGpuResource.h

Issue 1187523005: Add support for creating texture backed images where Skia will delete the texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add default param to support Chrome's current callers Created 5 years, 6 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
« no previous file with comments | « include/core/SkImage.h ('k') | include/gpu/GrTextureProvider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrGpuResource.h
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index 5a35ab794ab12aa9209c07e85b1a3b7687b7cd61..6f9855f17cf603d45d189f385e3284a266ec9953 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -150,17 +150,24 @@ public:
* The cache may release them whenever there are no refs.
*/
kCached_LifeCycle,
+
/**
* The resource is uncached. As soon as there are no more refs to it, it is released. Under
* the hood the cache may opaquely recycle it as a cached resource.
*/
kUncached_LifeCycle,
+
/**
* Similar to uncached, but Skia does not manage the lifetime of the underlying backend
* 3D API object(s). The client is responsible for freeing those. Used to inject client-
* created GPU resources into Skia (e.g. to render to a client-created texture).
*/
- kWrapped_LifeCycle,
+ kBorrowed_LifeCycle,
+
+ /**
+ * An external resource with ownership transfered into Skia. Skia will free the resource.
+ */
+ kAdopted_LifeCycle,
};
/**
@@ -265,7 +272,12 @@ protected:
backend API calls should be made. */
virtual void onAbandon() { }
- bool isWrapped() const { return kWrapped_LifeCycle == fLifeCycle; }
+ bool shouldFreeResources() const { return fLifeCycle != kBorrowed_LifeCycle; }
+
+ bool isExternal() const {
+ return GrGpuResource::kAdopted_LifeCycle == fLifeCycle ||
+ GrGpuResource::kBorrowed_LifeCycle == fLifeCycle;
+ }
/**
* This entry point should be called whenever gpuMemorySize() should report a different size.
« no previous file with comments | « include/core/SkImage.h ('k') | include/gpu/GrTextureProvider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698