| Index: include/gpu/GrGpuResource.h
|
| diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
|
| index 8103959984b14ccf5a7fde91783b5a8120eda178..25bed0ce6ab9c4f2b243841b32d5fb8822b20c30 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* scratchKey) 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;
|
|
|