diff options
author | Robert Phillips <robertphillips@google.com> | 2017-03-14 09:17:43 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-14 14:09:12 +0000 |
commit | d3749485db2de966a80e39669a49192fc7c0bd9d (patch) | |
tree | 2a86aa3d24a394dd569f25f94eae08cd58674efe /src/gpu/GrResourceProvider.cpp | |
parent | 4a01ac9e410e7b78fb04c8632e0676082b9408aa (diff) |
Consolidate Proxy caching code in GrResourceProvider
This doesn't implement the GrSurfaceProxy-based caching but just carves out a space for it.
Split out of: https://skia-review.googlesource.com/c/8823/ (Remove GrFragmentProcessor-derived class' GrTexture-based ctors)
Change-Id: Iec87b45e3264b349d7804f63e361e970b925e335
Reviewed-on: https://skia-review.googlesource.com/9626
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrResourceProvider.cpp')
-rw-r--r-- | src/gpu/GrResourceProvider.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp index 2083c7c72b..43e82975c7 100644 --- a/src/gpu/GrResourceProvider.cpp +++ b/src/gpu/GrResourceProvider.cpp @@ -212,6 +212,34 @@ GrTexture* GrResourceProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& k return NULL; } +// MDB TODO (caching): this side-steps the issue of texture proxies with unique IDs +void GrResourceProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy* proxy) { + ASSERT_SINGLE_OWNER + SkASSERT(key.isValid()); + if (this->isAbandoned() || !proxy) { + return; + } + + GrTexture* texture = proxy->instantiate(this); + if (!texture) { + return; + } + + this->assignUniqueKeyToResource(key, texture); +} + +// MDB TODO (caching): this side-steps the issue of texture proxies with unique IDs +sk_sp<GrTextureProxy> GrResourceProvider::findProxyByUniqueKey(const GrUniqueKey& key) { + ASSERT_SINGLE_OWNER + + sk_sp<GrTexture> texture(this->findAndRefTextureByUniqueKey(key)); + if (!texture) { + return nullptr; + } + + return GrSurfaceProxy::MakeWrapped(std::move(texture)); +} + const GrBuffer* GrResourceProvider::createInstancedIndexBuffer(const uint16_t* pattern, int patternSize, int reps, |