aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private/GrSurfaceProxy.h
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-02-08 15:05:44 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-08 20:33:40 +0000
commit457469c7a0c879b9d8ff8ed9fabe3f3dcab06097 (patch)
tree92ef5dcb793bbe9406730b1576c51bcc6042b86c /include/private/GrSurfaceProxy.h
parent5635631c8887db678e6123c191ae68456b60d2a7 (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/private/GrSurfaceProxy.h')
-rw-r--r--include/private/GrSurfaceProxy.h19
1 files changed, 16 insertions, 3 deletions
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);