Chromium Code Reviews| Index: include/gpu/GrGpuResource.h |
| diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h |
| index 8103959984b14ccf5a7fde91783b5a8120eda178..06507f9d392685edb4a2b86783c3f19c91686cf9 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,10 +261,12 @@ 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. |
| + * 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. |
| **/ |
| - void setScratchKey(const GrScratchKey& scratchKey); |
| + virtual void computeScratchKey(GrScratchKey* scratchKey) const { }; |
|
bsalomon
2016/04/19 14:37:46
Can this be private? Seems like only registerWithC
Kimmo Kinnunen
2016/04/20 12:04:55
Done.
|
| /** |
| * Allows subclasses to add additional backing information to the SkTraceMemoryDump. Called by |
| @@ -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; |