diff options
author | Greg Daniel <egdaniel@google.com> | 2018-02-08 15:05:44 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-08 20:33:40 +0000 |
commit | 457469c7a0c879b9d8ff8ed9fabe3f3dcab06097 (patch) | |
tree | 92ef5dcb793bbe9406730b1576c51bcc6042b86c /include | |
parent | 5635631c8887db678e6123c191ae68456b60d2a7 (diff) |
Make non-ddl lazy proxys clean-up and delete their callbacks immediately after instanstation.
This makes sure resources are released and free'd as soon as possible if we
no longer need them.
Bug: skia:
Change-Id: Ic216987649c54183f8cbbff90a633860a97754b3
Reviewed-on: https://skia-review.googlesource.com/105721
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/private/GrRenderTargetProxy.h | 4 | ||||
-rw-r--r-- | include/private/GrSurfaceProxy.h | 19 | ||||
-rw-r--r-- | include/private/GrTextureProxy.h | 4 |
3 files changed, 20 insertions, 7 deletions
diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h index b0018a7ad8..1672fd9357 100644 --- a/include/private/GrRenderTargetProxy.h +++ b/include/private/GrRenderTargetProxy.h @@ -77,8 +77,8 @@ protected: // // The minimal knowledge version is used for CCPR where we are generating an atlas but we do not // know the final size until flush time. - GrRenderTargetProxy(LazyInstantiateCallback&&, const GrSurfaceDesc&, SkBackingFit, SkBudgeted, - uint32_t flags); + GrRenderTargetProxy(LazyInstantiateCallback&&, LazyInstantiationType lazyType, + const GrSurfaceDesc&, SkBackingFit, SkBudgeted, uint32_t flags); // Wrapped version GrRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin); diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index 84353eee12..6bfb700a0f 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -182,6 +182,11 @@ private: class GrSurfaceProxy : public GrIORefProxy { public: + enum class LazyInstantiationType { + kSingleUse, // Instantiation callback is allowed to be called only once + kMultipleUse, // Instantiation callback can be called multiple times. + }; + enum class LazyState { kNot, // The proxy is instantiated or does not have a lazy callback kPartially, // The proxy has a lazy callback but knows basic information about itself. @@ -351,7 +356,8 @@ public: protected: // Deferred version GrSurfaceProxy(const GrSurfaceDesc& desc, SkBackingFit fit, SkBudgeted budgeted, uint32_t flags) - : GrSurfaceProxy(nullptr, desc, fit, budgeted, flags) { + : GrSurfaceProxy(nullptr, LazyInstantiationType::kSingleUse, + desc, fit, budgeted, flags) { // Note: this ctor pulls a new uniqueID from the same pool at the GrGpuResources } @@ -359,8 +365,9 @@ protected: GrSurfaceOrigin* outOrigin)>; // Lazy-callback version - GrSurfaceProxy(LazyInstantiateCallback&& callback, const GrSurfaceDesc& desc, - SkBackingFit fit, SkBudgeted budgeted, uint32_t flags); + GrSurfaceProxy(LazyInstantiateCallback&& callback, LazyInstantiationType lazyType, + const GrSurfaceDesc& desc, SkBackingFit fit, SkBudgeted budgeted, + uint32_t flags); // Wrapped version GrSurfaceProxy(sk_sp<GrSurface> surface, GrSurfaceOrigin origin, SkBackingFit fit); @@ -408,6 +415,12 @@ private: const UniqueID fUniqueID; // set from the backing resource for wrapped resources LazyInstantiateCallback fLazyInstantiateCallback; + // If this is set to kSingleuse, then after one call to fLazyInstantiateCallback we will cleanup + // the lazy callback and then delete it. This will allow for any refs and resources being held + // by the standard function to be released. This is specifically useful in non-dll cases where + // we make lazy proxies and instantiate them immediately. + // Note: This is ignored if fLazyInstantiateCallback is null. + LazyInstantiationType fLazyInstantiationType; SkDEBUGCODE(virtual void validateLazySurface(const GrSurface*) = 0;) static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0); diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h index 3aee3de361..3adfa58b74 100644 --- a/include/private/GrTextureProxy.h +++ b/include/private/GrTextureProxy.h @@ -80,8 +80,8 @@ protected: // // The minimal knowledge version is used for CCPR where we are generating an atlas but we do not // know the final size until flush time. - GrTextureProxy(LazyInstantiateCallback&&, const GrSurfaceDesc& desc, GrMipMapped, - SkBackingFit fit, SkBudgeted budgeted, uint32_t flags); + GrTextureProxy(LazyInstantiateCallback&&, LazyInstantiationType, const GrSurfaceDesc& desc, + GrMipMapped, SkBackingFit fit, SkBudgeted budgeted, uint32_t flags); // Wrapped version GrTextureProxy(sk_sp<GrSurface>, GrSurfaceOrigin); |