diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/codec/SkCodecImageGenerator.cpp | 6 | ||||
-rw-r--r-- | src/core/SkImageCacherator.h | 6 | ||||
-rw-r--r-- | src/core/SkImageGenerator.cpp | 4 | ||||
-rw-r--r-- | src/core/SkPictureImageGenerator.cpp | 10 | ||||
-rw-r--r-- | src/core/SkPictureImageGenerator.h | 1 | ||||
-rw-r--r-- | src/gpu/GrAHardwareBufferImageGenerator.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrAHardwareBufferImageGenerator.h | 1 | ||||
-rw-r--r-- | src/gpu/GrBackendTextureImageGenerator.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrBackendTextureImageGenerator.h | 1 | ||||
-rw-r--r-- | src/gpu/GrImageTextureMaker.cpp | 3 | ||||
-rw-r--r-- | src/image/SkImage_Lazy.cpp | 242 |
11 files changed, 28 insertions, 252 deletions
diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp index 286320c9cd..6727dcf076 100644 --- a/src/codec/SkCodecImageGenerator.cpp +++ b/src/codec/SkCodecImageGenerator.cpp @@ -40,12 +40,12 @@ sk_sp<SkData> SkCodecImageGenerator::onRefEncodedData() { } bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& requestInfo, void* requestPixels, - size_t requestRowBytes, const Options& opts) { + size_t requestRowBytes, const Options&) { SkPixmap dst(requestInfo, requestPixels, requestRowBytes); - auto decode = [this, &opts](const SkPixmap& pm) { + auto decode = [this](const SkPixmap& pm) { SkCodec::Options codecOpts; - codecOpts.fPremulBehavior = opts.fBehavior; + codecOpts.fPremulBehavior = SkTransferFunctionBehavior::kIgnore; SkCodec::Result result = fCodec->getPixels(pm, &codecOpts); switch (result) { case SkCodec::kSuccess: diff --git a/src/core/SkImageCacherator.h b/src/core/SkImageCacherator.h index e5ed250294..101a5faf9a 100644 --- a/src/core/SkImageCacherator.h +++ b/src/core/SkImageCacherator.h @@ -31,15 +31,9 @@ public: enum CachedFormat { kLegacy_CachedFormat, // The format from the generator, with any color space stripped out - kLinearF16_CachedFormat, // Half float RGBA with linear gamma - kSRGB8888_CachedFormat, // sRGB bytes - kSBGR8888_CachedFormat, // sRGB bytes, in BGR order - kNumCachedFormats, }; - virtual CachedFormat chooseCacheFormat(SkColorSpace* dstColorSpace, - const GrCaps* = nullptr) const = 0; virtual SkImageInfo buildCacheInfo(CachedFormat) const = 0; #if SK_SUPPORT_GPU diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp index 865a718e44..1aa8873723 100644 --- a/src/core/SkImageGenerator.cpp +++ b/src/core/SkImageGenerator.cpp @@ -66,18 +66,16 @@ bool SkImageGenerator::getYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes sk_sp<GrTextureProxy> SkImageGenerator::generateTexture(GrContext* ctx, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior behavior, bool willNeedMipMaps) { SkIRect srcRect = SkIRect::MakeXYWH(origin.x(), origin.y(), info.width(), info.height()); if (!SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(srcRect)) { return nullptr; } - return this->onGenerateTexture(ctx, info, origin, behavior, willNeedMipMaps); + return this->onGenerateTexture(ctx, info, origin, willNeedMipMaps); } sk_sp<GrTextureProxy> SkImageGenerator::onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, - SkTransferFunctionBehavior, bool willNeedMipMaps) { return nullptr; } diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp index f17ff647ae..0f52dc1d7c 100644 --- a/src/core/SkPictureImageGenerator.cpp +++ b/src/core/SkPictureImageGenerator.cpp @@ -56,8 +56,8 @@ SkPictureImageGenerator::SkPictureImageGenerator(const SkImageInfo& info, sk_sp< bool SkPictureImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options& opts) { - bool useXformCanvas = - SkTransferFunctionBehavior::kIgnore == opts.fBehavior && info.colorSpace(); + // TODO: Stop using xform canvas and simplify this code once rasterization works the same way + bool useXformCanvas = /* kIgnore == behavior && */ info.colorSpace(); SkSurfaceProps props(0, kUnknown_SkPixelGeometry); SkImageInfo canvasInfo = useXformCanvas ? info.makeColorSpace(nullptr) : info; @@ -99,10 +99,10 @@ SkImageGenerator::MakeFromPicture(const SkISize& size, sk_sp<SkPicture> picture, #if SK_SUPPORT_GPU sk_sp<GrTextureProxy> SkPictureImageGenerator::onGenerateTexture( - GrContext* ctx, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior behavior, bool willNeedMipMaps) { + GrContext* ctx, const SkImageInfo& info, const SkIPoint& origin, bool willNeedMipMaps) { SkASSERT(ctx); - bool useXformCanvas = SkTransferFunctionBehavior::kIgnore == behavior && info.colorSpace(); + // TODO: Stop using xform canvas and simplify this code once rasterization works the same way + bool useXformCanvas = /* behavior == kIgnore && */ info.colorSpace(); // // TODO: respect the usage, by possibly creating a different (pow2) surface diff --git a/src/core/SkPictureImageGenerator.h b/src/core/SkPictureImageGenerator.h index 4c5f8e3a75..8f16c19318 100644 --- a/src/core/SkPictureImageGenerator.h +++ b/src/core/SkPictureImageGenerator.h @@ -23,7 +23,6 @@ protected: #if SK_SUPPORT_GPU TexGenType onCanGenerateTexture() const override { return TexGenType::kExpensive; } sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, - SkTransferFunctionBehavior, bool willNeedMipMaps) override; #endif diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp index 40be392230..b00661fc2f 100644 --- a/src/gpu/GrAHardwareBufferImageGenerator.cpp +++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp @@ -96,8 +96,7 @@ void GrAHardwareBufferImageGenerator::deleteImageTexture(void* context) { /////////////////////////////////////////////////////////////////////////////////////////////////// sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::onGenerateTexture( - GrContext* context, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior, bool willNeedMipMaps) { + GrContext* context, const SkImageInfo& info, const SkIPoint& origin, bool willNeedMipMaps) { auto proxy = this->makeProxy(context); if (!proxy) { return nullptr; diff --git a/src/gpu/GrAHardwareBufferImageGenerator.h b/src/gpu/GrAHardwareBufferImageGenerator.h index b7d13d2c02..13f2e1409f 100644 --- a/src/gpu/GrAHardwareBufferImageGenerator.h +++ b/src/gpu/GrAHardwareBufferImageGenerator.h @@ -37,7 +37,6 @@ protected: TexGenType onCanGenerateTexture() const override { return TexGenType::kCheap; } sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, - SkTransferFunctionBehavior, bool willNeedMipMaps) override; private: diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp index 4147abd2a4..466a842f23 100644 --- a/src/gpu/GrBackendTextureImageGenerator.cpp +++ b/src/gpu/GrBackendTextureImageGenerator.cpp @@ -85,8 +85,7 @@ void GrBackendTextureImageGenerator::ReleaseRefHelper_TextureReleaseProc(void* c } sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture( - GrContext* context, const SkImageInfo& info, const SkIPoint& origin, - SkTransferFunctionBehavior, bool willNeedMipMaps) { + GrContext* context, const SkImageInfo& info, const SkIPoint& origin, bool willNeedMipMaps) { SkASSERT(context); if (context->contextPriv().getBackend() != fBackendTexture.backend()) { diff --git a/src/gpu/GrBackendTextureImageGenerator.h b/src/gpu/GrBackendTextureImageGenerator.h index fffb7da0d2..9d76e02dae 100644 --- a/src/gpu/GrBackendTextureImageGenerator.h +++ b/src/gpu/GrBackendTextureImageGenerator.h @@ -41,7 +41,6 @@ protected: TexGenType onCanGenerateTexture() const override { return TexGenType::kCheap; } sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, - SkTransferFunctionBehavior, bool willNeedMipMaps) override; private: diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp index 920415f55c..732811615f 100644 --- a/src/gpu/GrImageTextureMaker.cpp +++ b/src/gpu/GrImageTextureMaker.cpp @@ -35,8 +35,7 @@ sk_sp<GrTextureProxy> GrImageTextureMaker::refOriginalTextureProxy(bool willBeMi void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey, SkColorSpace* dstColorSpace) { if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { - SkImageCacherator::CachedFormat cacheFormat = - fCacher->chooseCacheFormat(dstColorSpace, this->context()->contextPriv().caps()); + SkImageCacherator::CachedFormat cacheFormat = SkImageCacherator::kLegacy_CachedFormat; GrUniqueKey cacheKey; fCacher->makeCacheKeyFromOrigKey(fOriginalKey, cacheFormat, &cacheKey); MakeCopyKeyFromOrigKey(cacheKey, stretch, paramsCopyKey); diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index 5d978e7951..8d8e95219d 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp @@ -107,7 +107,7 @@ public: bool lockAsBitmapOnlyIfAlreadyCached(SkBitmap*, CachedFormat) const; // Call the underlying generator directly bool directGeneratePixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB, - int srcX, int srcY, SkTransferFunctionBehavior behavior) const; + int srcX, int srcY) const; // SkImageCacherator interface #if SK_SUPPORT_GPU @@ -128,8 +128,6 @@ public: GrUniqueKey* cacheKey) override; #endif - CachedFormat chooseCacheFormat(SkColorSpace* dstColorSpace, - const GrCaps* = nullptr) const override; SkImageInfo buildCacheInfo(CachedFormat) const override; private: @@ -139,18 +137,7 @@ private: * On success (true), bitmap will point to the pixels for this generator. If this returns * false, the bitmap will be reset to empty. */ - bool lockAsBitmap(SkBitmap*, SkImage::CachingHint, CachedFormat, const SkImageInfo&, - SkTransferFunctionBehavior) const; - - /** - * Populates parameters to pass to the generator for reading pixels or generating a texture. - * For image generators, legacy versus true color blending is indicated using a - * SkTransferFunctionBehavior, and the target color space is specified on the SkImageInfo. - * If generatorImageInfo has no color space set, set its color space to this SkImage's color - * space, and return "ignore" behavior, indicating legacy mode. If generatorImageInfo has a - * color space set, return "respect" behavior, indicating linear blending mode. - */ - SkTransferFunctionBehavior getGeneratorBehaviorAndInfo(SkImageInfo* generatorImageInfo) const; + bool lockAsBitmap(SkBitmap*, SkImage::CachingHint, CachedFormat, const SkImageInfo&) const; sk_sp<SharedGenerator> fSharedGenerator; // Note that fInfo is not necessarily the info from the generator. It may be cropped by @@ -264,174 +251,12 @@ uint32_t SkImage_Lazy::getUniqueID(CachedFormat format) const { ////////////////////////////////////////////////////////////////////////////////////////////////// -// Abstraction of GrCaps that handles the cases where we don't have a caps pointer (because -// we're in raster mode), or where GPU support is entirely missing. In theory, we only need the -// chosen format to be texturable, but that lets us choose F16 on GLES implemenations where we -// won't be able to read the texture back. We'd like to ensure that SkImake::makeNonTextureImage -// works, so we require that the formats we choose are renderable (as a proxy for being readable). -struct CacheCaps { - CacheCaps(const GrCaps* caps) : fCaps(caps) {} - -#if SK_SUPPORT_GPU - bool supportsHalfFloat() const { - return !fCaps || (fCaps->isConfigTexturable(kRGBA_half_GrPixelConfig) && - fCaps->isConfigRenderable(kRGBA_half_GrPixelConfig)); - } - - bool supportsSRGB() const { - return !fCaps || - (fCaps->srgbSupport() && fCaps->isConfigTexturable(kSRGBA_8888_GrPixelConfig)); - } - - bool supportsSBGR() const { - return !fCaps || fCaps->srgbSupport(); - } -#else - bool supportsHalfFloat() const { return true; } - bool supportsSRGB() const { return true; } - bool supportsSBGR() const { return true; } -#endif - - const GrCaps* fCaps; -}; - -SkImageCacherator::CachedFormat SkImage_Lazy::chooseCacheFormat(SkColorSpace* dstColorSpace, - const GrCaps* grCaps) const { -#ifdef SK_SUPPORT_LEGACY_LAZY_IMAGE_DECODE_BEHAVIOR - SkColorSpace* cs = fInfo.colorSpace(); - if (!cs || !dstColorSpace) { - return kLegacy_CachedFormat; - } - - CacheCaps caps(grCaps); - switch (fInfo.colorType()) { - case kUnknown_SkColorType: - case kAlpha_8_SkColorType: - case kRGB_565_SkColorType: - case kARGB_4444_SkColorType: - case kRGB_888x_SkColorType: - case kRGBA_1010102_SkColorType: - case kRGB_101010x_SkColorType: - // We don't support color space on these formats, so always decode in legacy mode: - // TODO: Ask the codec to decode these to something else (at least sRGB 8888)? - return kLegacy_CachedFormat; - - case kGray_8_SkColorType: - // TODO: What do we do with grayscale sources that have strange color spaces attached? - // The codecs and color space xform don't handle this correctly (yet), so drop it on - // the floor. (Also, inflating by a factor of 8 is going to be unfortunate). - // As it is, we don't directly support sRGB grayscale, so ask the codec to convert - // it for us. This bypasses some really sketchy code GrUploadPixmapToTexture. - if (cs->gammaCloseToSRGB() && caps.supportsSRGB()) { - return kSRGB8888_CachedFormat; - } else { - return kLegacy_CachedFormat; - } - - case kRGBA_8888_SkColorType: - if (cs->gammaCloseToSRGB()) { - if (caps.supportsSRGB()) { - return kSRGB8888_CachedFormat; - } else if (caps.supportsHalfFloat()) { - return kLinearF16_CachedFormat; - } else { - return kLegacy_CachedFormat; - } - } else { - if (caps.supportsHalfFloat()) { - return kLinearF16_CachedFormat; - } else if (caps.supportsSRGB()) { - return kSRGB8888_CachedFormat; - } else { - return kLegacy_CachedFormat; - } - } - - case kBGRA_8888_SkColorType: - // Odd case. sBGRA isn't a real thing, so we may not have this texturable. - if (caps.supportsSBGR()) { - if (cs->gammaCloseToSRGB()) { - return kSBGR8888_CachedFormat; - } else if (caps.supportsHalfFloat()) { - return kLinearF16_CachedFormat; - } else if (caps.supportsSRGB()) { - return kSRGB8888_CachedFormat; - } else { - // sBGRA support without sRGBA is highly unlikely (impossible?) Nevertheless. - return kLegacy_CachedFormat; - } - } else { - if (cs->gammaCloseToSRGB()) { - if (caps.supportsSRGB()) { - return kSRGB8888_CachedFormat; - } else if (caps.supportsHalfFloat()) { - return kLinearF16_CachedFormat; - } else { - return kLegacy_CachedFormat; - } - } else { - if (caps.supportsHalfFloat()) { - return kLinearF16_CachedFormat; - } else if (caps.supportsSRGB()) { - return kSRGB8888_CachedFormat; - } else { - return kLegacy_CachedFormat; - } - } - } - - case kRGBA_F16_SkColorType: - case kRGBA_F32_SkColorType: - if (caps.supportsHalfFloat()) { - return kLinearF16_CachedFormat; - } else if (caps.supportsSRGB()) { - return kSRGB8888_CachedFormat; - } else { - return kLegacy_CachedFormat; - } - } - SkDEBUGFAIL("Unreachable"); -#endif - return kLegacy_CachedFormat; -} - SkImageInfo SkImage_Lazy::buildCacheInfo(CachedFormat format) const { -#ifdef SK_SUPPORT_LEGACY_LAZY_IMAGE_DECODE_BEHAVIOR - switch (format) { - case kLegacy_CachedFormat: - return fInfo.makeColorSpace(nullptr); - case kLinearF16_CachedFormat: - return fInfo.makeColorType(kRGBA_F16_SkColorType) - .makeColorSpace(fInfo.colorSpace()->makeLinearGamma()); - case kSRGB8888_CachedFormat: - // If the transfer function is nearly (but not exactly) sRGB, we don't want the codec - // to bother trans-coding. It would be slow, and do more harm than good visually, - // so we make sure to leave the colorspace as-is. - if (fInfo.colorSpace()->gammaCloseToSRGB()) { - return fInfo.makeColorType(kRGBA_8888_SkColorType); - } else { - return fInfo.makeColorType(kRGBA_8888_SkColorType) - .makeColorSpace(fInfo.colorSpace()->makeSRGBGamma()); - } - case kSBGR8888_CachedFormat: - // See note above about not-quite-sRGB transfer functions. - if (fInfo.colorSpace()->gammaCloseToSRGB()) { - return fInfo.makeColorType(kBGRA_8888_SkColorType); - } else { - return fInfo.makeColorType(kBGRA_8888_SkColorType) - .makeColorSpace(fInfo.colorSpace()->makeSRGBGamma()); - } - default: - SkDEBUGFAIL("Invalid cached format"); - return fInfo; - } -#else if (kGray_8_SkColorType == fInfo.colorType()) { return fInfo.makeColorSpace(nullptr); } else { return fInfo; } -#endif } ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -444,8 +269,7 @@ static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { } bool SkImage_Lazy::directGeneratePixels(const SkImageInfo& info, void* pixels, size_t rb, - int srcX, int srcY, - SkTransferFunctionBehavior behavior) const { + int srcX, int srcY) const { ScopedGenerator generator(fSharedGenerator); const SkImageInfo& genInfo = generator->getInfo(); // Currently generators do not natively handle subsets, so check that first. @@ -453,10 +277,7 @@ bool SkImage_Lazy::directGeneratePixels(const SkImageInfo& info, void* pixels, s return false; } - SkImageGenerator::Options opts; - // TODO: This should respect the behavior argument. - opts.fBehavior = SkTransferFunctionBehavior::kIgnore; - return generator->getPixels(info, pixels, rb, &opts); + return generator->getPixels(info, pixels, rb); } ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -468,8 +289,7 @@ bool SkImage_Lazy::lockAsBitmapOnlyIfAlreadyCached(SkBitmap* bitmap, CachedForma check_output_bitmap(*bitmap, uniqueID); } -static bool generate_pixels(SkImageGenerator* gen, const SkPixmap& pmap, int originX, int originY, - SkTransferFunctionBehavior behavior) { +static bool generate_pixels(SkImageGenerator* gen, const SkPixmap& pmap, int originX, int originY) { const int genW = gen->getInfo().width(); const int genH = gen->getInfo().height(); const SkIRect srcR = SkIRect::MakeWH(genW, genH); @@ -493,9 +313,7 @@ static bool generate_pixels(SkImageGenerator* gen, const SkPixmap& pmap, int ori dstPM = &fullPM; } - SkImageGenerator::Options opts; - opts.fBehavior = behavior; - if (!gen->getPixels(dstPM->info(), dstPM->writable_addr(), dstPM->rowBytes(), &opts)) { + if (!gen->getPixels(dstPM->info(), dstPM->writable_addr(), dstPM->rowBytes())) { return false; } @@ -508,8 +326,7 @@ static bool generate_pixels(SkImageGenerator* gen, const SkPixmap& pmap, int ori } bool SkImage_Lazy::lockAsBitmap(SkBitmap* bitmap, SkImage::CachingHint chint, CachedFormat format, - const SkImageInfo& info, - SkTransferFunctionBehavior behavior) const { + const SkImageInfo& info) const { if (this->lockAsBitmapOnlyIfAlreadyCached(bitmap, format)) { return true; } @@ -535,7 +352,7 @@ bool SkImage_Lazy::lockAsBitmap(SkBitmap* bitmap, SkImage::CachingHint chint, Ca } ScopedGenerator generator(fSharedGenerator); - if (!generate_pixels(generator, pmap, fOrigin.x(), fOrigin.y(), behavior)) { + if (!generate_pixels(generator, pmap, fOrigin.x(), fOrigin.y())) { return false; } @@ -561,16 +378,14 @@ bool SkImage_Lazy::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, siz SkColorSpace* dstColorSpace = dstInfo.colorSpace(); SkBitmap bm; if (kDisallow_CachingHint == chint) { - CachedFormat cacheFormat = this->chooseCacheFormat(dstColorSpace); - SkImageInfo genPixelsInfo = dstInfo; - SkTransferFunctionBehavior behavior = getGeneratorBehaviorAndInfo(&genPixelsInfo); + CachedFormat cacheFormat = kLegacy_CachedFormat; if (this->lockAsBitmapOnlyIfAlreadyCached(&bm, cacheFormat)) { return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY); } else { // Try passing the caller's buffer directly down to the generator. If this fails we // may still succeed in the general case, as the generator may prefer some other // config, which we could then convert via SkBitmap::readPixels. - if (this->directGeneratePixels(genPixelsInfo, dstPixels, dstRB, srcX, srcY, behavior)) { + if (this->directGeneratePixels(dstInfo, dstPixels, dstRB, srcX, srcY)) { return true; } // else fall through @@ -590,11 +405,9 @@ sk_sp<SkData> SkImage_Lazy::onRefEncoded() const { bool SkImage_Lazy::getROPixels(SkBitmap* bitmap, SkColorSpace* dstColorSpace, CachingHint chint) const { - CachedFormat cacheFormat = this->chooseCacheFormat(dstColorSpace); + CachedFormat cacheFormat = kLegacy_CachedFormat; const SkImageInfo cacheInfo = this->buildCacheInfo(cacheFormat); - SkImageInfo genPixelsInfo = cacheInfo; - SkTransferFunctionBehavior behavior = getGeneratorBehaviorAndInfo(&genPixelsInfo); - return this->lockAsBitmap(bitmap, chint, cacheFormat, genPixelsInfo, behavior); + return this->lockAsBitmap(bitmap, chint, cacheFormat, cacheInfo); } bool SkImage_Lazy::onIsValid(GrContext* context) const { @@ -611,26 +424,6 @@ bool SkImage_Lazy::onCanLazyGenerateOnGPU() const { #endif } -SkTransferFunctionBehavior SkImage_Lazy::getGeneratorBehaviorAndInfo(SkImageInfo* generatorImageInfo) const { -#ifdef SK_SUPPORT_LEGACY_LAZY_IMAGE_DECODE_BEHAVIOR - if (generatorImageInfo->colorSpace()) { - return SkTransferFunctionBehavior::kRespect; - } - // Only specify an output color space if color conversion can be done on the color type. - switch (generatorImageInfo->colorType()) { - case kRGBA_8888_SkColorType: - case kBGRA_8888_SkColorType: - case kRGBA_F16_SkColorType: - case kRGB_565_SkColorType: - *generatorImageInfo = generatorImageInfo->makeColorSpace(fInfo.refColorSpace()); - break; - default: - break; - } -#endif - return SkTransferFunctionBehavior::kIgnore; -} - /////////////////////////////////////////////////////////////////////////////////////////////////// #if SK_SUPPORT_GPU @@ -741,7 +534,7 @@ sk_sp<SkColorSpace> SkImage_Lazy::getColorSpace(GrContext* ctx, SkColorSpace* ds // may want to know what space the image data is in, so return it. return fInfo.refColorSpace(); } else { - CachedFormat format = this->chooseCacheFormat(dstColorSpace, ctx->contextPriv().caps()); + CachedFormat format = kLegacy_CachedFormat; SkImageInfo cacheInfo = this->buildCacheInfo(format); return cacheInfo.refColorSpace(); } @@ -776,7 +569,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, // Determine which cached format we're going to use (which may involve decoding to a different // info than the generator provides). - CachedFormat format = this->chooseCacheFormat(dstColorSpace, ctx->contextPriv().caps()); + CachedFormat format = kLegacy_CachedFormat; // Fold the cache format into our texture key GrUniqueKey key; @@ -801,8 +594,6 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, // decoded variant of the encoded data, and also a recipe for how to transform the original // info to get the one that we're going to decode to. const SkImageInfo cacheInfo = this->buildCacheInfo(format); - SkImageInfo genPixelsInfo = cacheInfo; - SkTransferFunctionBehavior behavior = getGeneratorBehaviorAndInfo(&genPixelsInfo); // 2. Ask the generator to natively create one if (!proxy) { @@ -811,8 +602,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, SkImageGenerator::TexGenType::kCheap != generator->onCanGenerateTexture()) { return nullptr; } - if ((proxy = generator->generateTexture(ctx, genPixelsInfo, fOrigin, behavior, - willBeMipped))) { + if ((proxy = generator->generateTexture(ctx, cacheInfo, fOrigin, willBeMipped))) { SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath, kLockTexturePathCount); set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key); @@ -852,7 +642,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, // 4. Ask the generator to return RGB(A) data, which the GPU can convert SkBitmap bitmap; - if (!proxy && this->lockAsBitmap(&bitmap, chint, format, genPixelsInfo, behavior)) { + if (!proxy && this->lockAsBitmap(&bitmap, chint, format, cacheInfo)) { if (willBeMipped) { proxy = proxyProvider->createMipMapProxyFromBitmap(bitmap); } |