aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTextureProxy.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-09-20 15:58:44 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-20 20:21:50 +0000
commitd4f100dad90ed5beb1b614464d8c4fcb22c0a993 (patch)
tree4194bbcbe1884a5454143a7579f656113cf8f00f /src/gpu/GrTextureProxy.cpp
parent8d4a5c75f07a70f71320a426f392783dbcf180ba (diff)
Add native caching of uniquely keyed GrTextureProxies
Change-Id: I303fe025b7856b8d681a2d35b416c015bd468e1d Reviewed-on: https://skia-review.googlesource.com/48300 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrTextureProxy.cpp')
-rw-r--r--src/gpu/GrTextureProxy.cpp44
1 files changed, 41 insertions, 3 deletions
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index 3cb87b3faf..8a68e03bac 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -7,25 +7,43 @@
#include "GrTextureProxy.h"
+#include "GrContext.h"
+#include "GrResourceCache.h"
+
#include "GrTexturePriv.h"
GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, SkBudgeted budgeted,
const void* srcData, size_t /*rowBytes*/, uint32_t flags)
: INHERITED(srcDesc, fit, budgeted, flags)
, fIsMipMapped(srcDesc.fIsMipMapped)
- , fMipColorMode(SkDestinationSurfaceColorMode::kLegacy) {
+ , fMipColorMode(SkDestinationSurfaceColorMode::kLegacy)
+ , fCache(nullptr) {
SkASSERT(!srcData); // currently handled in Make()
}
GrTextureProxy::GrTextureProxy(sk_sp<GrSurface> surf, GrSurfaceOrigin origin)
: INHERITED(std::move(surf), origin, SkBackingFit::kExact)
, fIsMipMapped(fTarget->asTexture()->texturePriv().hasMipMaps())
- , fMipColorMode(fTarget->asTexture()->texturePriv().mipColorMode()) {
+ , fMipColorMode(fTarget->asTexture()->texturePriv().mipColorMode())
+ , fCache(nullptr) {
+ if (fTarget->getUniqueKey().isValid()) {
+ fUniqueKey = fTarget->getUniqueKey();
+ fCache = fTarget->asTexture()->getContext()->getResourceCache();
+ }
+}
+
+GrTextureProxy::~GrTextureProxy() {
+ if (fUniqueKey.isValid()) {
+ fCache->processInvalidProxyUniqueKey(fUniqueKey);
+ } else {
+ SkASSERT(!fCache);
+ }
}
bool GrTextureProxy::instantiate(GrResourceProvider* resourceProvider) {
if (!this->instantiateImpl(resourceProvider, 0, /* needsStencil = */ false,
- kNone_GrSurfaceFlags, fIsMipMapped, fMipColorMode)) {
+ kNone_GrSurfaceFlags, fIsMipMapped, fMipColorMode,
+ fUniqueKey.isValid() ? &fUniqueKey : nullptr)) {
return false;
}
@@ -80,3 +98,23 @@ size_t GrTextureProxy::onUninstantiatedGpuMemorySize() const {
return GrSurface::ComputeSize(fConfig, fWidth, fHeight, 1, kHasMipMaps,
SkBackingFit::kApprox == fFit);
}
+
+void GrTextureProxy::setUniqueKey(GrResourceCache* cache, const GrUniqueKey& key) {
+ SkASSERT(key.isValid());
+ SkASSERT(!fUniqueKey.isValid()); // proxies can only ever get one uniqueKey
+
+ if (fTarget) {
+ SkASSERT(!fTarget->getUniqueKey().isValid());
+ fTarget->resourcePriv().setUniqueKey(key);
+ SkASSERT(fTarget->getUniqueKey() == key);
+ }
+
+ fUniqueKey = key;
+ fCache = cache;
+}
+
+void GrTextureProxy::clearUniqueKey() {
+ fUniqueKey.reset();
+ fCache = nullptr;
+}
+