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 kExpensive, //onGenerateTexture is implemented and it is relatively slow
}; };
virtual TexGenType onCanGenerateTexture() const { return TexGenType::kNone; }
virtual GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&, virtual GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
const SkIPoint&, const SkIPoint&,
bool willNeedMipMaps); // returns nullptr bool willNeedMipMaps); // returns nullptr

View File

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

View File

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

View File

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

View File

@ -23,8 +23,7 @@ public:
bool useDecal = false); bool useDecal = false);
private: private:
GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped, GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
AllowedTexGenType onlyIfFast) override;
void makeMipMappedKey(GrUniqueKey* mipMappedKey) override; void makeMipMappedKey(GrUniqueKey* mipMappedKey) override;
void didCacheMipMappedCopy(const GrUniqueKey& mipMappedKey, uint32_t contextUniqueID) 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())); GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), SkIRect::MakeSize(this->dimensions()));
} }
GrSurfaceProxyView GrImageTextureMaker::refOriginalTextureProxyView(bool willBeMipped, GrSurfaceProxyView GrImageTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
AllowedTexGenType onlyIfFast) { return fImage->lockTextureProxyView(this->context(), fOriginalKey, fCachingHint, willBeMipped);
return fImage->lockTextureProxyView(this->context(), fOriginalKey, fCachingHint, willBeMipped,
onlyIfFast);
} }
void GrImageTextureMaker::makeMipMappedKey(GrUniqueKey* mipMappedKey) { void GrImageTextureMaker::makeMipMappedKey(GrUniqueKey* mipMappedKey) {
@ -57,12 +55,7 @@ GrYUVAImageTextureMaker::GrYUVAImageTextureMaker(GrContext* context, const SkIma
GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), SkIRect::MakeSize(this->dimensions())); GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), SkIRect::MakeSize(this->dimensions()));
} }
GrSurfaceProxyView GrYUVAImageTextureMaker::refOriginalTextureProxyView( GrSurfaceProxyView GrYUVAImageTextureMaker::refOriginalTextureProxyView(bool willBeMipped) {
bool willBeMipped, AllowedTexGenType onlyIfFast) {
if (AllowedTexGenType::kCheap == onlyIfFast) {
return {};
}
if (willBeMipped) { if (willBeMipped) {
return fImage->refMippedView(this->context()); return fImage->refMippedView(this->context());
} else { } else {

View File

@ -22,8 +22,7 @@ public:
SkImage::CachingHint chint, bool useDecal = false); SkImage::CachingHint chint, bool useDecal = false);
private: private:
GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped, GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
AllowedTexGenType onlyIfFast) override;
void makeMipMappedKey(GrUniqueKey* mipMappedKey) override; void makeMipMappedKey(GrUniqueKey* mipMappedKey) override;
void didCacheMipMappedCopy(const GrUniqueKey& mipMappedKey, uint32_t contextUniqueID) 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 // 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) // able to efficiently produce a "stretched" texture natively (e.g. picture-backed)
// GrTexture* generateTextureForParams(const CopyParams&) override; // GrTexture* generateTextureForParams(const CopyParams&) override;
GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped, GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override;
AllowedTexGenType onlyIfFast) override;
void makeMipMappedKey(GrUniqueKey* mipMappedKey) override; void makeMipMappedKey(GrUniqueKey* mipMappedKey) override;
void didCacheMipMappedCopy(const GrUniqueKey& mipMappedKey, uint32_t contextUniqueID) override { void didCacheMipMappedCopy(const GrUniqueKey& mipMappedKey, uint32_t contextUniqueID) override {

View File

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

View File

@ -16,8 +16,6 @@
*/ */
class GrTextureMaker : public GrTextureProducer { class GrTextureMaker : public GrTextureProducer {
public: public:
enum class AllowedTexGenType : bool { kCheap, kAny };
std::unique_ptr<GrFragmentProcessor> createFragmentProcessor( std::unique_ptr<GrFragmentProcessor> createFragmentProcessor(
const SkMatrix& textureMatrix, const SkMatrix& textureMatrix,
const SkRect& constraintRect, const SkRect& constraintRect,
@ -36,8 +34,7 @@ protected:
* construct then refOriginalTextureProxy should return nullptr (for example if texture is made * construct then refOriginalTextureProxy should return nullptr (for example if texture is made
* by drawing into a render target). * by drawing into a render target).
*/ */
virtual GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped, virtual GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) = 0;
AllowedTexGenType genType) = 0;
private: private:
GrSurfaceProxyView onRefTextureProxyViewForParams(GrSamplerState, bool willBeMipped) override; 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 * 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 * 4. Ask the generator to return RGB(A) data, which the GPU can convert
*/ */
GrSurfaceProxyView SkImage_Lazy::lockTextureProxyView( GrSurfaceProxyView SkImage_Lazy::lockTextureProxyView(GrRecordingContext* ctx,
GrRecordingContext* ctx, const GrUniqueKey& origKey,
const GrUniqueKey& origKey, SkImage::CachingHint chint,
SkImage::CachingHint chint, bool willBeMipped) const {
bool willBeMipped,
GrTextureMaker::AllowedTexGenType genType) const {
// Values representing the various texture lock paths we can take. Used for logging the path // Values representing the various texture lock paths we can take. Used for logging the path
// taken to a histogram. // taken to a histogram.
enum LockTexturePath { enum LockTexturePath {
@ -469,10 +467,6 @@ GrSurfaceProxyView SkImage_Lazy::lockTextureProxyView(
// 2. Ask the generator to natively create one // 2. Ask the generator to natively create one
if (!view.proxy()) { if (!view.proxy()) {
ScopedGenerator generator(fSharedGenerator); ScopedGenerator generator(fSharedGenerator);
if (GrTextureMaker::AllowedTexGenType::kCheap == genType &&
SkImageGenerator::TexGenType::kCheap != generator->onCanGenerateTexture()) {
return {};
}
view = generator->generateTexture(ctx, this->imageInfo(), fOrigin, willBeMipped); view = generator->generateTexture(ctx, this->imageInfo(), fOrigin, willBeMipped);
if (view.proxy()) { if (view.proxy()) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath, SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath,

View File

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