diff options
author | Brian Osman <brianosman@google.com> | 2017-04-25 10:02:12 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-25 17:59:54 +0000 |
commit | 4785897c962c02dd6f92b37850dec527f34387f8 (patch) | |
tree | ebbb1153baa94114cc93343c7b788e85197a34f0 /src | |
parent | bc096bffcbc9b640c09010247994cd64e064384a (diff) |
Remove compressed texture support from cacherator
All variants of (on)?[rR]efEncoded(Data)? no longer need a GrContext
parameter.
Bug: skia:5485 skia:4971
Change-Id: If4f5e785718d5522eb3df8588318ccb8a02a5749
Reviewed-on: https://skia-review.googlesource.com/14269
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/codec/SkCodecImageGenerator.cpp | 6 | ||||
-rw-r--r-- | src/codec/SkCodecImageGenerator.h | 6 | ||||
-rw-r--r-- | src/core/SkImageCacherator.cpp | 47 | ||||
-rw-r--r-- | src/core/SkImageCacherator.h | 5 | ||||
-rw-r--r-- | src/core/SkImageGenerator.cpp | 6 | ||||
-rw-r--r-- | src/image/SkImage.cpp | 3 | ||||
-rw-r--r-- | src/image/SkImage_Base.h | 3 | ||||
-rw-r--r-- | src/image/SkImage_Lazy.cpp | 6 | ||||
-rw-r--r-- | src/ports/SkImageGeneratorCG.cpp | 6 | ||||
-rw-r--r-- | src/ports/SkImageGeneratorCG.h | 6 | ||||
-rw-r--r-- | src/ports/SkImageGeneratorWIC.cpp | 6 | ||||
-rw-r--r-- | src/ports/SkImageGeneratorWIC.h | 6 |
12 files changed, 50 insertions, 56 deletions
diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp index 6467033371..d1bb43f2fd 100644 --- a/src/codec/SkCodecImageGenerator.cpp +++ b/src/codec/SkCodecImageGenerator.cpp @@ -31,7 +31,11 @@ SkCodecImageGenerator::SkCodecImageGenerator(SkCodec* codec, sk_sp<SkData> data) , fData(std::move(data)) {} -SkData* SkCodecImageGenerator::onRefEncodedData(GrContext* ctx) { +SkData* SkCodecImageGenerator::onRefEncodedData( +#ifdef SK_SUPPORT_GPU_REF_ENCODED_DATA + GrContext* ctx +#endif + ) { return SkRef(fData.get()); } diff --git a/src/codec/SkCodecImageGenerator.h b/src/codec/SkCodecImageGenerator.h index a435205fa9..2332164f08 100644 --- a/src/codec/SkCodecImageGenerator.h +++ b/src/codec/SkCodecImageGenerator.h @@ -21,7 +21,11 @@ public: static std::unique_ptr<SkImageGenerator> MakeFromEncodedCodec(sk_sp<SkData>); protected: - SkData* onRefEncodedData(GrContext* ctx) override; + SkData* onRefEncodedData( +#ifdef SK_SUPPORT_GPU_REF_ENCODED_DATA + GrContext* ctx +#endif + ) override; bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[], int* ctableCount) override; diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index 808fdd4554..9ef9f79a33 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -127,9 +127,9 @@ uint32_t SkImageCacherator::getUniqueID(CachedFormat format) const { return rec->fUniqueID; } -SkData* SkImageCacherator::refEncoded(GrContext* ctx) { +SkData* SkImageCacherator::refEncoded() { ScopedGenerator generator(fSharedGenerator); - return generator->refEncodedData(ctx); + return generator->refEncodedData(); } static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { @@ -425,20 +425,6 @@ void SkImageCacherator::makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, Cach } } -#ifdef SK_SUPPORT_COMPRESSED_TEXTURES_IN_CACHERATOR -static GrTexture* load_compressed_into_texture(GrContext* ctx, SkData* data, GrSurfaceDesc desc) { - const void* rawStart; - GrPixelConfig config = GrIsCompressedTextureDataSupported(ctx, data, desc.fWidth, desc.fHeight, - &rawStart); - if (kUnknown_GrPixelConfig == config) { - return nullptr; - } - - desc.fConfig = config; - return ctx->resourceProvider()->createTexture(desc, SkBudgeted::kYes, rawStart, 0); -} -#endif - class Generator_GrYUVProvider : public GrYUVProvider { SkImageGenerator* fGen; @@ -471,13 +457,12 @@ sk_sp<SkColorSpace> SkImageCacherator::getColorSpace(GrContext* ctx, SkColorSpac } /* - * We have a 5 ways to try to return a texture (in sorted order) + * We have 4 ways to try to return a texture (in sorted order) * * 1. Check the cache for a pre-existing one * 2. Ask the generator to natively create one - * 3. Ask the generator to return a compressed form that the GPU might support - * 4. Ask the generator to return YUV planes, which the GPU can convert - * 5. Ask the generator to return RGB(A) data, 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 */ sk_sp<GrTextureProxy> SkImageCacherator::lockTextureProxy(GrContext* ctx, const GrUniqueKey& origKey, @@ -491,7 +476,7 @@ sk_sp<GrTextureProxy> SkImageCacherator::lockTextureProxy(GrContext* ctx, kFailure_LockTexturePath, kPreExisting_LockTexturePath, kNative_LockTexturePath, - kCompressed_LockTexturePath, + kCompressed_LockTexturePath, // Deprecated kYUV_LockTexturePath, kRGBA_LockTexturePath, }; @@ -531,23 +516,9 @@ sk_sp<GrTextureProxy> SkImageCacherator::lockTextureProxy(GrContext* ctx, } } - const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(cacheInfo, *ctx->caps()); - -#ifdef SK_SUPPORT_COMPRESSED_TEXTURES_IN_CACHERATOR - // 3. Ask the generator to return a compressed form that the GPU might support - sk_sp<SkData> data(this->refEncoded(ctx)); - if (data) { - GrTexture* tex = load_compressed_into_texture(ctx, data, desc); - if (tex) { - SK_HISTOGRAM_ENUMERATION("LockTexturePath", kCompressed_LockTexturePath, - kLockTexturePathCount); - return set_key_and_return(tex, key); - } - } -#endif - - // 4. 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 if (!ctx->contextPriv().disableGpuYUVConversion()) { + const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(cacheInfo, *ctx->caps()); ScopedGenerator generator(fSharedGenerator); Generator_GrYUVProvider provider(generator); if (sk_sp<GrTextureProxy> proxy = provider.refAsTextureProxy(ctx, desc, true)) { @@ -558,7 +529,7 @@ sk_sp<GrTextureProxy> SkImageCacherator::lockTextureProxy(GrContext* ctx, } } - // 5. 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 SkBitmap bitmap; if (this->lockAsBitmap(&bitmap, client, chint, format, cacheInfo)) { sk_sp<GrTextureProxy> proxy; diff --git a/src/core/SkImageCacherator.h b/src/core/SkImageCacherator.h index c3b0bcc20d..fb07b7646a 100644 --- a/src/core/SkImageCacherator.h +++ b/src/core/SkImageCacherator.h @@ -68,11 +68,8 @@ public: /** * If the underlying src naturally is represented by an encoded blob (in SkData), this returns * a ref to that data. If not, it returns null. - * - * If a GrContext is specified, then the caller is only interested in gpu-specific encoded - * formats, so others (e.g. PNG) can just return nullptr. */ - SkData* refEncoded(GrContext*); + SkData* refEncoded(); // Only return true if the generate has already been cached. bool lockAsBitmapOnlyIfAlreadyCached(SkBitmap*, CachedFormat); diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp index f47bb1d160..59619a9af1 100644 --- a/src/core/SkImageGenerator.cpp +++ b/src/core/SkImageGenerator.cpp @@ -106,7 +106,11 @@ sk_sp<GrTextureProxy> SkImageGenerator::onGenerateTexture(GrContext*, const SkIm ///////////////////////////////////////////////////////////////////////////////////////////// -SkData* SkImageGenerator::onRefEncodedData(GrContext* ctx) { +SkData* SkImageGenerator::onRefEncodedData( +#ifdef SK_SUPPORT_GPU_REF_ENCODED_DATA + GrContext* ctx +#endif + ) { return nullptr; } diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index 9866acf3f9..6e4d32e8df 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -130,8 +130,7 @@ SkData* SkImage::encode(SkPixelSerializer* serializer) const { } SkData* SkImage::refEncoded() const { - GrContext* ctx = nullptr; // should we allow the caller to pass in a ctx? - return as_IB(this)->onRefEncoded(ctx); + return as_IB(this)->onRefEncoded(); } sk_sp<SkImage> SkImage::MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset) { diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index 062d785679..96fd6e6dca 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -73,8 +73,7 @@ public: virtual sk_sp<SkImage> onMakeSubset(const SkIRect&) const = 0; - // If a ctx is specified, then only gpu-specific formats are requested. - virtual SkData* onRefEncoded(GrContext*) const { return nullptr; } + virtual SkData* onRefEncoded() const { return nullptr; } virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index 5fd0f61a53..99995d17aa 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp @@ -34,7 +34,7 @@ public: SkScalar scaleAdjust[2]) const override; #endif SkImageCacherator* peekCacherator() const override { return &fCache; } - SkData* onRefEncoded(GrContext*) const override; + SkData* onRefEncoded() const override; sk_sp<SkImage> onMakeSubset(const SkIRect&) const override; bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override; bool onIsLazyGenerated() const override { return true; } @@ -74,8 +74,8 @@ bool SkImage_Lazy::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, siz return false; } -SkData* SkImage_Lazy::onRefEncoded(GrContext* ctx) const { - return fCache.refEncoded(ctx); +SkData* SkImage_Lazy::onRefEncoded() const { + return fCache.refEncoded(); } bool SkImage_Lazy::getROPixels(SkBitmap* bitmap, SkColorSpace* dstColorSpace, diff --git a/src/ports/SkImageGeneratorCG.cpp b/src/ports/SkImageGeneratorCG.cpp index d2e6436916..7d1c44de0e 100644 --- a/src/ports/SkImageGeneratorCG.cpp +++ b/src/ports/SkImageGeneratorCG.cpp @@ -75,7 +75,11 @@ SkImageGeneratorCG::SkImageGeneratorCG(const SkImageInfo& info, const void* imag , fData(SkRef(data)) {} -SkData* SkImageGeneratorCG::onRefEncodedData(GrContext* ctx) { +SkData* SkImageGeneratorCG::onRefEncodedData( +#ifdef SK_SUPPORT_GPU_REF_ENCODED_DATA + GrContext* ctx +#endif + ) { return SkRef(fData.get()); } diff --git a/src/ports/SkImageGeneratorCG.h b/src/ports/SkImageGeneratorCG.h index 9ecfe1b1fe..c675e85404 100644 --- a/src/ports/SkImageGeneratorCG.h +++ b/src/ports/SkImageGeneratorCG.h @@ -22,7 +22,11 @@ public: static SkImageGenerator* NewFromEncodedCG(SkData* data); protected: - SkData* onRefEncodedData(GrContext* ctx) override; + SkData* onRefEncodedData( +#ifdef SK_SUPPORT_GPU_REF_ENCODED_DATA + GrContext* ctx +#endif + ) override; bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[], int* ctableCount) override; diff --git a/src/ports/SkImageGeneratorWIC.cpp b/src/ports/SkImageGeneratorWIC.cpp index 7a367851ae..41958864de 100644 --- a/src/ports/SkImageGeneratorWIC.cpp +++ b/src/ports/SkImageGeneratorWIC.cpp @@ -132,7 +132,11 @@ SkImageGeneratorWIC::SkImageGeneratorWIC(const SkImageInfo& info, , fData(SkRef(data)) {} -SkData* SkImageGeneratorWIC::onRefEncodedData(GrContext* ctx) { +SkData* SkImageGeneratorWIC::onRefEncodedData( +#ifdef SK_SUPPORT_GPU_REF_ENCODED_DATA + GrContext* ctx +#endif + ) { return SkRef(fData.get()); } diff --git a/src/ports/SkImageGeneratorWIC.h b/src/ports/SkImageGeneratorWIC.h index eb65e0b678..d20d493f73 100644 --- a/src/ports/SkImageGeneratorWIC.h +++ b/src/ports/SkImageGeneratorWIC.h @@ -39,7 +39,11 @@ public: static SkImageGenerator* NewFromEncodedWIC(SkData* data); protected: - SkData* onRefEncodedData(GrContext* ctx) override; + SkData* onRefEncodedData( +#ifdef SK_SUPPORT_GPU_REF_ENCODED_DATA + GrContext* ctx +#endif + ) override; bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[], int* ctableCount) override; |