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

Unified Diff: include/gpu/GrGpuResource.h

Issue 1862043002: Refactor to separate backend object lifecycle and GpuResource budget decision (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix unrelated GrBuffer::onGpuMemorySize() lack of override keyword compile error Created 4 years, 8 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/gpu/GrBuffer.h ('k') | include/gpu/GrRenderTarget.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 8103959984b14ccf5a7fde91783b5a8120eda178..37a87d364da857d84c2a9502286811881736df43 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -140,34 +140,6 @@ private:
class SK_API GrGpuResource : public GrIORef<GrGpuResource> {
public:
-
- enum LifeCycle {
- /**
- * The resource is cached and owned by Skia. Resources with this status may be kept alive
- * by the cache as either scratch or unique resources even when there are no refs to them.
- * 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).
- */
- kBorrowed_LifeCycle,
-
- /**
- * An external resource with ownership transfered into Skia. Skia will free the resource.
- */
- kAdopted_LifeCycle,
- };
-
/**
* Tests whether a object has been abandoned or released. All objects will
* be in this state after their creating GrContext is destroyed or has
@@ -261,11 +233,16 @@ public:
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).
- void registerWithCache();
+ // This must be called by every non-wrapped GrGpuObject. It should be called once the object is
+ // fully initialized (i.e. only from the constructors of the final class).
+ void registerWithCache(SkBudgeted);
+
+ // This must be called by every GrGpuObject that references any wrapped backend objects. It
+ // should be called once the object is fully initialized (i.e. only from the constructors of the
+ // final class).
+ void registerWithCacheWrapped();
- GrGpuResource(GrGpu*, LifeCycle);
+ GrGpuResource(GrGpu*);
virtual ~GrGpuResource();
GrGpu* getGpu() const { return fGpu; }
@@ -277,13 +254,6 @@ protected:
backend API calls should be made. */
virtual void onAbandon() { }
- 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.
* The cache will call gpuMemorySize() to update the current size of the resource.
@@ -291,12 +261,6 @@ protected:
void didChangeGpuMemorySize() const;
/**
- * Optionally called by the GrGpuResource subclass if the resource can be used as scratch.
- * By default resources are not usable as scratch. This should only be called once.
- **/
- 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.
**/
@@ -304,6 +268,14 @@ protected:
private:
/**
+ * Called by the registerWithCache if the resource is available to be used as scratch.
+ * Resource subclasses should override this if the instances should be recycled as scratch
+ * resources and populate the scratchKey with the key.
+ * By default resources are not recycled as scratch.
+ **/
+ virtual void computeScratchKey(GrScratchKey*) const { };
+
+ /**
* Frees the object in the underlying 3D API. Called by CacheAccess.
*/
void release();
@@ -341,7 +313,8 @@ private:
GrGpu* fGpu;
mutable size_t fGpuMemorySize;
- LifeCycle fLifeCycle;
+ SkBudgeted fBudgeted;
+ bool fRefsWrappedObjects;
const uint32_t fUniqueID;
SkAutoTUnref<const SkData> fData;
« no previous file with comments | « include/gpu/GrBuffer.h ('k') | include/gpu/GrRenderTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698