diff options
author | bsalomon <bsalomon@google.com> | 2015-01-14 10:42:08 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-14 10:42:08 -0800 |
commit | 5236cf480daf82b2f36e42795abdbbc915533a59 (patch) | |
tree | b3e76998aabf4849c60d7bc0c701de47b2aaf4e9 /include/gpu/GrGpuResource.h | |
parent | 028b98a08072bd1764936e47c54fa2da5cf92744 (diff) |
Make uncached textures uncached from the get go.
This avoids the problem of a newly created uncached texture causing a purge of cached resources.
BUG=chromium:445885
Review URL: https://codereview.chromium.org/846303002
Diffstat (limited to 'include/gpu/GrGpuResource.h')
-rw-r--r-- | include/gpu/GrGpuResource.h | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h index 4340f710b3..44c4ba0082 100644 --- a/include/gpu/GrGpuResource.h +++ b/include/gpu/GrGpuResource.h @@ -125,6 +125,26 @@ class SK_API GrGpuResource : public GrIORef<GrGpuResource> { public: SK_DECLARE_INST_COUNT(GrGpuResource) + 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 content 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). + */ + kWrapped_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 @@ -204,7 +224,7 @@ protected: // initialized (i.e. not in a base class constructor). void registerWithCache(); - GrGpuResource(GrGpu*, bool isWrapped); + GrGpuResource(GrGpu*, LifeCycle); virtual ~GrGpuResource(); GrGpu* getGpu() const { return fGpu; } @@ -216,7 +236,7 @@ protected: backend API calls should be made. */ virtual void onAbandon() { } - bool isWrapped() const { return SkToBool(kWrapped_Flag & fFlags); } + bool isWrapped() const { return kWrapped_LifeCycle == fLifeCycle; } /** * This entry point should be called whenever gpuMemorySize() should report a different size. @@ -240,7 +260,6 @@ private: // See comments in CacheAccess. bool setContentKey(const GrResourceKey& contentKey); - void setBudgeted(bool countsAgainstBudget); void notifyIsPurgable() const; void removeScratchKey(); @@ -257,21 +276,9 @@ private: static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0); enum Flags { /** - * The resource counts against the resource cache's budget. - */ - kBudgeted_Flag = 0x1, - - /** - * This object wraps a GPU object given to us by Skia's client. Skia will not free the - * underlying backend API GPU resources when the GrGpuResource is destroyed. This also - * implies that kBudgeted_Flag is not set. - */ - kWrapped_Flag = 0x2, - - /** * If set then fContentKey is valid and the resource is cached based on its content. */ - kContentKeySet_Flag = 0x4, + kContentKeySet_Flag = 0x1, }; GrScratchKey fScratchKey; @@ -284,6 +291,7 @@ private: mutable size_t fGpuMemorySize; uint32_t fFlags; + LifeCycle fLifeCycle; const uint32_t fUniqueID; SkAutoTUnref<const SkData> fData; |