aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-03-02 10:23:52 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-02 16:12:35 +0000
commitf7cf81aefd28e5bfe74d40b4fc037df72f157f33 (patch)
treebb04e18bdd24f8af585f3c0a4fae6741e86a13cd
parentbfafcba05a54e1bc9c3074353a155d61119d095c (diff)
Use GrTextureProvider's uniqueKey setting method rather than directly setting it
Clients will not be able to directly set the uniqueKey on GrTextureProxies. This CL sets up the choke point for the switch over to having uniqueKeys be managed by a third party (the textureProvider). Change-Id: I5061a970faf77ea0c4a320e021ff7c3ef90a0900 Reviewed-on: https://skia-review.googlesource.com/9140 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r--include/gpu/GrTextureProvider.h1
-rw-r--r--src/core/SkImageCacherator.cpp11
-rw-r--r--src/gpu/GrBitmapTextureMaker.cpp2
-rw-r--r--src/gpu/GrClipStackClip.cpp4
-rw-r--r--src/gpu/GrResourceProvider.cpp2
-rw-r--r--src/gpu/GrSoftwarePathRenderer.cpp4
-rw-r--r--src/gpu/GrTextureAdjuster.cpp2
-rw-r--r--src/gpu/SkGr.cpp2
8 files changed, 15 insertions, 13 deletions
diff --git a/include/gpu/GrTextureProvider.h b/include/gpu/GrTextureProvider.h
index b8d185648d..dd139cc0e7 100644
--- a/include/gpu/GrTextureProvider.h
+++ b/include/gpu/GrTextureProvider.h
@@ -51,6 +51,7 @@ public:
/** Assigns a unique key to the texture. The texture will be findable via this key using
findTextureByUniqueKey(). If an existing texture has this key, it's key will be removed. */
void assignUniqueKeyToTexture(const GrUniqueKey& key, GrTexture* texture) {
+ SkASSERT(key.isValid());
this->assignUniqueKeyToResource(key, texture);
}
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp
index e971883f7c..f36af3f259 100644
--- a/src/core/SkImageCacherator.cpp
+++ b/src/core/SkImageCacherator.cpp
@@ -474,9 +474,10 @@ public:
}
};
-static GrTexture* set_key_and_return(GrTexture* tex, const GrUniqueKey& key) {
+static GrTexture* set_key_and_return(GrTextureProvider* texProvider,
+ GrTexture* tex, const GrUniqueKey& key) {
if (key.isValid()) {
- tex->resourcePriv().setUniqueKey(key);
+ texProvider->assignUniqueKeyToTexture(key, tex);
}
return tex;
}
@@ -543,7 +544,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori
if (GrTexture* tex = generator->generateTexture(ctx, cacheInfo, fOrigin)) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath,
kLockTexturePathCount);
- return set_key_and_return(tex, key);
+ return set_key_and_return(ctx->textureProvider(), tex, key);
}
}
@@ -570,7 +571,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori
if (tex) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
kLockTexturePathCount);
- return set_key_and_return(tex.release(), key);
+ return set_key_and_return(ctx->textureProvider(), tex.release(), key);
}
}
@@ -587,7 +588,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori
if (tex) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath,
kLockTexturePathCount);
- return set_key_and_return(tex, key);
+ return set_key_and_return(ctx->textureProvider(), tex, key);
}
}
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath,
diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp
index e4ea772cc5..9d577cdcd1 100644
--- a/src/gpu/GrBitmapTextureMaker.cpp
+++ b/src/gpu/GrBitmapTextureMaker.cpp
@@ -43,7 +43,7 @@ GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped,
tex = GrUploadBitmapToTexture(this->context(), fBitmap);
}
if (tex && fOriginalKey.isValid()) {
- tex->resourcePriv().setUniqueKey(fOriginalKey);
+ this->context()->textureProvider()->assignUniqueKeyToTexture(fOriginalKey, tex);
GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef());
}
return tex;
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 0b3089bd2e..c69f79e402 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -446,7 +446,7 @@ sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrContext* context,
return nullptr;
}
- tex->resourcePriv().setUniqueKey(key);
+ context->textureProvider()->assignUniqueKeyToTexture(key, tex);
add_invalidate_on_pop_message(*fStack, reducedClip.elementsGenID(), key);
return result;
@@ -522,7 +522,7 @@ sk_sp<GrTextureProxy> GrClipStackClip::createSoftwareClipMask(
return nullptr;
}
- tex->resourcePriv().setUniqueKey(key);
+ context->textureProvider()->assignUniqueKeyToTexture(key, tex);
add_invalidate_on_pop_message(*fStack, reducedClip.elementsGenID(), key);
return result;
}
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index deb400c371..272c6a6ee7 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -161,7 +161,7 @@ GrStencilAttachment* GrResourceProvider::attachStencilAttachment(GrRenderTarget*
// Need to try and create a new stencil
stencil = this->gpu()->createStencilAttachmentForRenderTarget(rt, width, height);
if (stencil) {
- stencil->resourcePriv().setUniqueKey(sbKey);
+ this->assignUniqueKeyToResource(sbKey, stencil);
newStencil = true;
}
}
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 5ed9f42446..b51ce630d0 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -206,7 +206,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
sk_sp<GrTexture> texture;
if (useCache) {
- texture.reset(args.fContext->textureProvider()->findAndRefTextureByUniqueKey(maskKey));
+ texture.reset(fTexProvider->findAndRefTextureByUniqueKey(maskKey));
}
if (!texture) {
SkBackingFit fit = useCache ? SkBackingFit::kExact : SkBackingFit::kApprox;
@@ -219,7 +219,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
return false;
}
if (useCache) {
- texture->resourcePriv().setUniqueKey(maskKey);
+ fTexProvider->assignUniqueKeyToTexture(maskKey, texture.get());
}
}
if (inverseFilled) {
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index 2fa5241060..0c9c23ed07 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -56,7 +56,7 @@ GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) {
GrTexture* copy = CopyOnGpu(texture, contentArea, copyParams);
if (copy) {
if (key.isValid()) {
- copy->resourcePriv().setUniqueKey(key);
+ context->textureProvider()->assignUniqueKeyToTexture(key, copy);
this->didCacheCopy(key);
}
}
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index fe7e98c8d9..b685723970 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -288,7 +288,7 @@ sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrContext* context, const SkBitmap
if (!tex) {
tex.reset(GrUploadBitmapToTexture(context, bitmap));
if (tex && originalKey.isValid()) {
- tex->resourcePriv().setUniqueKey(originalKey);
+ context->textureProvider()->assignUniqueKeyToTexture(originalKey, tex.get());
GrInstallBitmapUniqueKeyInvalidator(originalKey, bitmap.pixelRef());
}
}