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>
This commit is contained in:
parent
bc096bffcb
commit
4785897c96
@ -35,16 +35,19 @@ public:
|
||||
uint32_t uniqueID() const { return fUniqueID; }
|
||||
|
||||
/**
|
||||
* Return a ref to the encoded (i.e. compressed) representation,
|
||||
* of this data. If the GrContext is non-null, then the caller is only interested in
|
||||
* gpu-specific formats, so the impl may return null even if they have encoded data,
|
||||
* assuming they know it is not suitable for the gpu.
|
||||
* Return a ref to the encoded (i.e. compressed) representation
|
||||
* of this data.
|
||||
*
|
||||
* If non-NULL is returned, the caller is responsible for calling
|
||||
* unref() on the data when it is finished.
|
||||
*/
|
||||
SkData* refEncodedData(GrContext* ctx = nullptr) {
|
||||
SkData* refEncodedData() {
|
||||
#ifdef SK_SUPPORT_GPU_REF_ENCODED_DATA
|
||||
GrContext* ctx = nullptr;
|
||||
return this->onRefEncodedData(ctx);
|
||||
#else
|
||||
return this->onRefEncodedData();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,7 +166,11 @@ protected:
|
||||
|
||||
SkImageGenerator(const SkImageInfo& info, uint32_t uniqueId = kNeedNewImageUniqueID);
|
||||
|
||||
virtual SkData* onRefEncodedData(GrContext* ctx);
|
||||
virtual SkData* onRefEncodedData(
|
||||
#ifdef SK_SUPPORT_GPU_REF_ENCODED_DATA
|
||||
GrContext* ctx
|
||||
#endif
|
||||
);
|
||||
|
||||
virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
|
||||
SkPMColor ctable[], int* ctableCount);
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user