Remove GrFragmentProcessor-derived class' GrTexture-based ctors
Split out into:
https://skia-review.googlesource.com/c/8881/ (Switch GrTextureStripAtlas over to GrTextureProxies)
https://skia-review.googlesource.com/c/8942/ (Wrap cached GrTextures in GrTextureProxies (e.g., blur profiles, nine-patch blurs, etc.))
https://skia-review.googlesource.com/c/8997/ (Clean up/remove unused GrFragmentProcessor-derived ctors)
https://skia-review.googlesource.com/c/9191/ (Switch SkImageGenerator over to generating GrTextureProxies)
https://skia-review.googlesource.com/c/9448/ (Switch GrYUVProvider over to GrTextureProxies)
https://skia-review.googlesource.com/c/9559/ (Preparatory Proxification)
https://skia-review.googlesource.com/c/9626/ (Consolidate Proxy caching code in GrResourceProvider)
https://skia-review.googlesource.com/c/9683/ (More pre-emptive proxification)
https://skia-review.googlesource.com/c/9917/ (Make experimental Perlin noise shader take texture proxies)
https://skia-review.googlesource.com/c/9961/ (rename makeCopyForTextureParams to isACopyNeededForTextureParams)
https://skia-review.googlesource.com/c/9945/ (Make SkImageCacherator be deferred)
https://skia-review.googlesource.com/c/10180/ (Add new proxy-based DetermineDomainMode w/ test)
Change-Id: Ia33389d92360e542a9d2bf395948deb04d017465
Reviewed-on: https://skia-review.googlesource.com/8823
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index ee4641b..4fb0c0d 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -11,10 +11,10 @@
#include "GrGpu.h"
#include "GrResourceProvider.h"
-GrTexture* GrTextureMaker::refTextureForParams(const GrSamplerParams& params,
- SkColorSpace* dstColorSpace,
- sk_sp<SkColorSpace>* texColorSpace,
- SkScalar scaleAdjust[2]) {
+sk_sp<GrTextureProxy> GrTextureMaker::refTextureProxyForParams(const GrSamplerParams& params,
+ SkColorSpace* dstColorSpace,
+ sk_sp<SkColorSpace>* texColorSpace,
+ SkScalar scaleAdjust[2]) {
CopyParams copyParams;
bool willBeMipped = params.filterMode() == GrSamplerParams::kMipMap_FilterMode;
@@ -28,30 +28,25 @@
if (!fContext->getGpu()->isACopyNeededForTextureParams(this->width(), this->height(), params,
©Params, scaleAdjust)) {
- sk_sp<GrTextureProxy>proxy = this->refOriginalTextureProxy(willBeMipped, dstColorSpace);
- if (!proxy) {
- return nullptr;
- }
-
- sk_sp<GrTexture> tex(SkSafeRef(proxy->instantiate(fContext->resourceProvider())));
- return tex.release();
+ return this->refOriginalTextureProxy(willBeMipped, dstColorSpace);
}
GrUniqueKey copyKey;
this->makeCopyKey(copyParams, ©Key, dstColorSpace);
if (copyKey.isValid()) {
- GrTexture* result = fContext->resourceProvider()->findAndRefTextureByUniqueKey(copyKey);
+ sk_sp<GrTextureProxy> result(fContext->resourceProvider()->findProxyByUniqueKey(copyKey));
if (result) {
return result;
}
}
- GrTexture* result = this->generateTextureForParams(copyParams, willBeMipped, dstColorSpace);
+ sk_sp<GrTextureProxy> result(this->generateTextureProxyForParams(copyParams, willBeMipped,
+ dstColorSpace));
if (!result) {
return nullptr;
}
if (copyKey.isValid()) {
- fContext->resourceProvider()->assignUniqueKeyToTexture(copyKey, result);
+ fContext->resourceProvider()->assignUniqueKeyToProxy(copyKey, result.get());
this->didCacheCopy(copyKey);
}
return result;
@@ -86,9 +81,10 @@
}
sk_sp<SkColorSpace> texColorSpace;
SkScalar scaleAdjust[2] = { 1.0f, 1.0f };
- sk_sp<GrTexture> texture(this->refTextureForParams(params, dstColorSpace, &texColorSpace,
- scaleAdjust));
- if (!texture) {
+ sk_sp<GrTextureProxy> proxy(this->refTextureProxyForParams(params, dstColorSpace,
+ &texColorSpace,
+ scaleAdjust));
+ if (!proxy) {
return nullptr;
}
SkMatrix adjustedMatrix = textureMatrix;
@@ -96,28 +92,24 @@
SkRect domain;
DomainMode domainMode =
DetermineDomainMode(constraintRect, filterConstraint, coordsLimitedToConstraintRect,
- texture->width(), texture->height(),
+ proxy.get(),
nullptr, fmForDetermineDomain, &domain);
SkASSERT(kTightCopy_DomainMode != domainMode);
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(texColorSpace.get(),
dstColorSpace);
- return CreateFragmentProcessorForDomainAndFilter(texture.get(), std::move(colorSpaceXform),
+ return CreateFragmentProcessorForDomainAndFilter(fContext->resourceProvider(), std::move(proxy),
+ std::move(colorSpaceXform),
adjustedMatrix, domainMode, domain,
filterOrNullForBicubic);
}
-GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams, bool willBeMipped,
- SkColorSpace* dstColorSpace) {
+sk_sp<GrTextureProxy> GrTextureMaker::generateTextureProxyForParams(const CopyParams& copyParams,
+ bool willBeMipped,
+ SkColorSpace* dstColorSpace) {
sk_sp<GrTextureProxy> original(this->refOriginalTextureProxy(willBeMipped, dstColorSpace));
if (!original) {
return nullptr;
}
- sk_sp<GrTextureProxy> copy = CopyOnGpu(fContext, std::move(original), nullptr, copyParams);
- if (!copy) {
- return nullptr;
- }
-
- sk_sp<GrTexture> tex(SkSafeRef(copy->instantiate(fContext->resourceProvider())));
- return tex.release();
+ return CopyOnGpu(fContext, std::move(original), nullptr, copyParams);
}