Remove cheap/any texture distinction from SkImageGenerator.

With the removal of rescaling of NPOT textures this no longer matters.

Change-Id: I313e895407c3a2c616e6113a5bde75dc6a167e7c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273519
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2020-02-26 15:34:27 -05:00 committed by Skia Commit-Bot
parent 66adad7d37
commit 6066b754fe
12 changed files with 19 additions and 61 deletions

View File

@ -182,7 +182,6 @@ protected:
kExpensive, //onGenerateTexture is implemented and it is relatively slow
};
virtual TexGenType onCanGenerateTexture() const { return TexGenType::kNone; }
virtual GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
const SkIPoint&,
bool willNeedMipMaps); // returns nullptr

View File

@ -24,7 +24,6 @@ protected:
override;
#if SK_SUPPORT_GPU
TexGenType onCanGenerateTexture() const override { return TexGenType::kExpensive; }
GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
const SkIPoint&, bool willNeedMipMaps) override;
#endif

View File

@ -42,7 +42,6 @@ protected:
bool onIsValid(GrContext*) const override;
TexGenType onCanGenerateTexture() const override { return TexGenType::kCheap; }
GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
const SkIPoint&, bool willNeedMipMaps) override;

View File

@ -39,7 +39,6 @@ protected:
// do that safely (we might be on another thread). So assume everything is fine.
bool onIsValid(GrContext*) const override { return true; }
TexGenType onCanGenerateTexture() const override { return TexGenType::kCheap; }
GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
const SkIPoint&, bool willNeedMipMaps) override;
bool onTexturesAreCacheable() const override { return false; }

View File

@ -39,12 +39,7 @@ GrBitmapTextureMaker::GrBitmapTextureMaker(GrRecordingContext* context, const Sk
}
}
GrSurfaceProxyView GrBitmapTextureMaker::refOriginalTextureProxyView(bool willBeMipped,
AllowedTexGenType onlyIfFast) {
if (AllowedTexGenType::kCheap == onlyIfFast) {
return {};
}
GrSurfaceProxyView GrBitmapTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
GrProxyProvider* proxyProvider = this->context()->priv().proxyProvider();
sk_sp<GrTextureProxy> proxy;
GrSwizzle swizzle;

View File

@ -23,8 +23,7 @@ public:
bool useDecal = false);
private:
GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped,
AllowedTexGenType onlyIfFast) override;
GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
void makeMipMappedKey(GrUniqueKey* mipMappedKey) override;
void didCacheMipMappedCopy(const GrUniqueKey& mipMappedKey, uint32_t contextUniqueID) override;

View File

@ -33,10 +33,8 @@ GrImageTextureMaker::GrImageTextureMaker(GrRecordingContext* context, const SkIm
GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), SkIRect::MakeSize(this->dimensions()));
}
GrSurfaceProxyView GrImageTextureMaker::refOriginalTextureProxyView(bool willBeMipped,
AllowedTexGenType onlyIfFast) {
return fImage->lockTextureProxyView(this->context(), fOriginalKey, fCachingHint, willBeMipped,
onlyIfFast);
GrSurfaceProxyView GrImageTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
return fImage->lockTextureProxyView(this->context(), fOriginalKey, fCachingHint, willBeMipped);
}
void GrImageTextureMaker::makeMipMappedKey(GrUniqueKey* mipMappedKey) {
@ -57,12 +55,7 @@ GrYUVAImageTextureMaker::GrYUVAImageTextureMaker(GrContext* context, const SkIma
GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), SkIRect::MakeSize(this->dimensions()));
}
GrSurfaceProxyView GrYUVAImageTextureMaker::refOriginalTextureProxyView(
bool willBeMipped, AllowedTexGenType onlyIfFast) {
if (AllowedTexGenType::kCheap == onlyIfFast) {
return {};
}
GrSurfaceProxyView GrYUVAImageTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
if (willBeMipped) {
return fImage->refMippedView(this->context());
} else {

View File

@ -22,8 +22,7 @@ public:
SkImage::CachingHint chint, bool useDecal = false);
private:
GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped,
AllowedTexGenType onlyIfFast) override;
GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
void makeMipMappedKey(GrUniqueKey* mipMappedKey) override;
void didCacheMipMappedCopy(const GrUniqueKey& mipMappedKey, uint32_t contextUniqueID) override {
@ -48,8 +47,7 @@ protected:
// TODO: consider overriding this, for the case where the underlying generator might be
// able to efficiently produce a "stretched" texture natively (e.g. picture-backed)
// GrTexture* generateTextureForParams(const CopyParams&) override;
GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped,
AllowedTexGenType onlyIfFast) override;
GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
void makeMipMappedKey(GrUniqueKey* mipMappedKey) override;
void didCacheMipMappedCopy(const GrUniqueKey& mipMappedKey, uint32_t contextUniqueID) override {

View File

@ -21,11 +21,11 @@ GrSurfaceProxyView GrTextureMaker::onRefTextureProxyViewForParams(GrSamplerState
return {};
}
GrSurfaceProxyView original = this->refOriginalTextureProxyView(willBeMipped,
AllowedTexGenType::kCheap);
GrSurfaceProxyView original = this->refOriginalTextureProxyView(willBeMipped);
if (!original) {
return this->refOriginalTextureProxyView(willBeMipped, AllowedTexGenType::kAny);
return {};
}
SkASSERT(original.asTextureProxy());
GrTextureProxy* texProxy = original.asTextureProxy();
if (!GrGpu::IsACopyNeededForMips(this->context()->priv().caps(), texProxy, params.filter())) {
@ -46,26 +46,13 @@ GrSurfaceProxyView GrTextureMaker::onRefTextureProxyViewForParams(GrSamplerState
}
}
GrSurfaceProxyView source;
if (original) {
source = std::move(original);
} else {
// Since we will be copying this texture there is no reason to make it mipped
source = this->refOriginalTextureProxyView(false, AllowedTexGenType::kAny);
if (!source) {
return {};
}
}
SkASSERT(source.asTextureProxy());
GrSurfaceProxyView result = GrCopyBaseMipMapToTextureProxy(this->context(), source.proxy(),
source.origin(), this->colorType());
GrSurfaceProxyView result = GrCopyBaseMipMapToTextureProxy(
this->context(), original.proxy(), original.origin(), this->colorType());
if (!result) {
// If we were unable to make a copy and we only needed a copy for mips, then we will return
// the source texture here and require that the GPU backend is able to fall back to using
// bilerp if mips are required.
return source;
return original;
}
if (mipMappedKey.isValid()) {

View File

@ -16,8 +16,6 @@
*/
class GrTextureMaker : public GrTextureProducer {
public:
enum class AllowedTexGenType : bool { kCheap, kAny };
std::unique_ptr<GrFragmentProcessor> createFragmentProcessor(
const SkMatrix& textureMatrix,
const SkRect& constraintRect,
@ -36,8 +34,7 @@ protected:
* construct then refOriginalTextureProxy should return nullptr (for example if texture is made
* by drawing into a render target).
*/
virtual GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped,
AllowedTexGenType genType) = 0;
virtual GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) = 0;
private:
GrSurfaceProxyView onRefTextureProxyViewForParams(GrSamplerState, bool willBeMipped) override;

View File

@ -419,12 +419,10 @@ sk_sp<SkCachedData> SkImage_Lazy::getPlanes(SkYUVASizeInfo* yuvaSizeInfo,
* 3. Ask the generator to return YUV planes, which the GPU can convert
* 4. Ask the generator to return RGB(A) data, which the GPU can convert
*/
GrSurfaceProxyView SkImage_Lazy::lockTextureProxyView(
GrRecordingContext* ctx,
const GrUniqueKey& origKey,
SkImage::CachingHint chint,
bool willBeMipped,
GrTextureMaker::AllowedTexGenType genType) const {
GrSurfaceProxyView SkImage_Lazy::lockTextureProxyView(GrRecordingContext* ctx,
const GrUniqueKey& origKey,
SkImage::CachingHint chint,
bool willBeMipped) const {
// Values representing the various texture lock paths we can take. Used for logging the path
// taken to a histogram.
enum LockTexturePath {
@ -469,10 +467,6 @@ GrSurfaceProxyView SkImage_Lazy::lockTextureProxyView(
// 2. Ask the generator to natively create one
if (!view.proxy()) {
ScopedGenerator generator(fSharedGenerator);
if (GrTextureMaker::AllowedTexGenType::kCheap == genType &&
SkImageGenerator::TexGenType::kCheap != generator->onCanGenerateTexture()) {
return {};
}
view = generator->generateTexture(ctx, this->imageInfo(), fOrigin, willBeMipped);
if (view.proxy()) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath,

View File

@ -63,8 +63,7 @@ public:
GrSurfaceProxyView lockTextureProxyView(GrRecordingContext*,
const GrUniqueKey& key,
SkImage::CachingHint,
bool willBeMipped,
GrTextureMaker::AllowedTexGenType genType) const;
bool willBeMipped) const;
// Returns the GrColorType to use with the GrTextureProxy returned from lockTextureProxy. This
// may be different from the color type on the image in the case where we need up upload CPU