diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/codec/SkCodec.cpp | 7 | ||||
-rw-r--r-- | src/codec/SkJpegCodec.cpp | 17 | ||||
-rw-r--r-- | src/codec/SkPngCodec.cpp | 9 | ||||
-rw-r--r-- | src/core/SkImageCacherator.h | 8 | ||||
-rw-r--r-- | src/gpu/GrBitmapTextureMaker.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrBitmapTextureMaker.h | 4 | ||||
-rw-r--r-- | src/gpu/GrImageTextureMaker.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrImageTextureMaker.h | 3 | ||||
-rw-r--r-- | src/gpu/GrTextureAdjuster.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrTextureAdjuster.h | 3 | ||||
-rw-r--r-- | src/gpu/GrTextureMaker.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrTextureProducer.h | 3 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 1 | ||||
-rw-r--r-- | src/image/SkImage_Lazy.cpp | 64 |
14 files changed, 38 insertions, 100 deletions
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp index d12646a44b..2c5c3df799 100644 --- a/src/codec/SkCodec.cpp +++ b/src/codec/SkCodec.cpp @@ -156,7 +156,6 @@ bool SkCodec::conversionSupported(const SkImageInfo& dst, SkColorType srcColor, case kRGB_565_SkColorType: return srcIsOpaque; case kGray_8_SkColorType: - SkASSERT(!needsColorXform); return kGray_8_SkColorType == srcColor && srcIsOpaque; case kAlpha_8_SkColorType: // conceptually we can convert anything into alpha_8, but we haven't actually coded @@ -610,6 +609,9 @@ static inline bool select_xform_format(SkColorType colorType, bool forColorTable case kRGBA_F16_SkColorType: *outFormat = skcms_PixelFormat_RGBA_hhhh; break; + case kGray_8_SkColorType: + *outFormat = skcms_PixelFormat_G_8; + break; default: return false; } @@ -625,9 +627,6 @@ bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Al if (kRGBA_F16_SkColorType == dstInfo.colorType() || !skcms_ApproximatelyEqualProfiles(fEncodedInfo.profile(), &fDstProfile) ) { needsColorXform = true; - if (kGray_8_SkColorType == dstInfo.colorType()) { - return false; - } } } diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index 7888b8a9fc..21570fddfe 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -302,8 +302,7 @@ std::unique_ptr<SkCodec> SkJpegCodec::MakeFromStream(std::unique_ptr<SkStream> s SkJpegCodec::SkJpegCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream> stream, JpegDecoderMgr* decoderMgr, SkEncodedOrigin origin) - : INHERITED(std::move(info), skcms_PixelFormat_RGBA_8888, std::move(stream), - origin) + : INHERITED(std::move(info), skcms_PixelFormat_RGBA_8888, std::move(stream), origin) , fDecoderMgr(decoderMgr) , fReadyState(decoderMgr->dinfo()->global_state) , fSwizzleSrcRow(nullptr) @@ -426,12 +425,15 @@ bool SkJpegCodec::conversionSupported(const SkImageInfo& dstInfo, SkColorType sr } break; case kGray_8_SkColorType: - SkASSERT(!needsColorXform); if (JCS_GRAYSCALE != encodedColorType) { return false; } - fDecoderMgr->dinfo()->out_color_space = JCS_GRAYSCALE; + if (needsColorXform) { + fDecoderMgr->dinfo()->out_color_space = JCS_EXT_RGBA; + } else { + fDecoderMgr->dinfo()->out_color_space = JCS_GRAYSCALE; + } break; case kRGBA_F16_SkColorType: SkASSERT(needsColorXform); @@ -505,7 +507,8 @@ int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes // We can never swizzle "in place" because the swizzler may perform sampling and/or // subsetting. // When fColorXformSrcRow is non-null, it means that we need to color xform and that - // we cannot color xform "in place" (many times we can, but not when the dst is F16). + // we cannot color xform "in place" (many times we can, but not when the src and dst + // are different sizes). // In this case, we will color xform from fColorXformSrcRow into the dst. JSAMPLE* decodeDst = (JSAMPLE*) dst; uint32_t* swizzleDst = (uint32_t*) dst; @@ -624,8 +627,8 @@ void SkJpegCodec::allocateStorage(const SkImageInfo& dstInfo) { } size_t xformBytes = 0; - if (this->colorXform() && (kRGBA_F16_SkColorType == dstInfo.colorType() || - kRGB_565_SkColorType == dstInfo.colorType())) { + + if (this->colorXform() && sizeof(uint32_t) != dstInfo.bytesPerPixel()) { xformBytes = dstWidth * sizeof(uint32_t); } diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp index 21046d4b5e..c3c6f6c277 100644 --- a/src/codec/SkPngCodec.cpp +++ b/src/codec/SkPngCodec.cpp @@ -456,6 +456,8 @@ static skcms_PixelFormat png_select_xform_format(const SkEncodedInfo& info) { } else if (SkEncodedInfo::kRGB_Color == info.color()) { return skcms_PixelFormat_RGB_161616; } + } else if (SkEncodedInfo::kGray_Color == info.color()) { + return skcms_PixelFormat_G_8; } return skcms_PixelFormat_RGBA_8888; @@ -1020,6 +1022,7 @@ SkCodec::Result SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const O // Fall through case SkEncodedInfo::kRGBA_Color: + case SkEncodedInfo::kGray_Color: skipFormatConversion = this->colorXform(); break; default: @@ -1059,7 +1062,11 @@ void SkPngCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& o Options swizzlerOptions = options; fXformMode = kSwizzleOnly_XformMode; if (this->colorXform() && this->xformOnDecode()) { - swizzlerInfo = swizzlerInfo.makeColorType(kXformSrcColorType); + if (SkEncodedInfo::kGray_Color == this->getEncodedInfo().color()) { + swizzlerInfo = swizzlerInfo.makeColorType(kGray_8_SkColorType); + } else { + swizzlerInfo = swizzlerInfo.makeColorType(kXformSrcColorType); + } if (kPremul_SkAlphaType == dstInfo.alphaType()) { swizzlerInfo = swizzlerInfo.makeAlphaType(kUnpremul_SkAlphaType); } diff --git a/src/core/SkImageCacherator.h b/src/core/SkImageCacherator.h index 9b554731af..b07fc6a270 100644 --- a/src/core/SkImageCacherator.h +++ b/src/core/SkImageCacherator.h @@ -29,8 +29,6 @@ class SkImageCacherator { public: virtual ~SkImageCacherator() {} - virtual SkImageInfo buildCacheInfo() const = 0; - #if SK_SUPPORT_GPU // Returns the texture proxy. If the cacherator is generating the texture and wants to cache it, // it should use the passed in key (if the key is valid). @@ -41,12 +39,6 @@ public: SkImage::CachingHint, bool willBeMipped, SkColorSpace* dstColorSpace, GrTextureMaker::AllowedTexGenType genType) = 0; - - // Returns the color space of the texture that would be returned if you called lockTexture. - // Separate code path to allow querying of the color space for textures that cached (even - // externally). - virtual sk_sp<SkColorSpace> getColorSpace(GrContext*, SkColorSpace* dstColorSpace) = 0; - virtual void makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, GrUniqueKey* cacheKey) = 0; #endif }; diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp index 55419d8a8a..9de4d2c282 100644 --- a/src/gpu/GrBitmapTextureMaker.cpp +++ b/src/gpu/GrBitmapTextureMaker.cpp @@ -107,8 +107,7 @@ sk_sp<GrTextureProxy> GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM return nullptr; } -void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey, - SkColorSpace* dstColorSpace) { +void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) { // Destination color space is irrelevant - we always upload the bitmap's contents as-is if (fOriginalKey.isValid()) { MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey); diff --git a/src/gpu/GrBitmapTextureMaker.h b/src/gpu/GrBitmapTextureMaker.h index 22d8ca37ed..867d1f22f7 100644 --- a/src/gpu/GrBitmapTextureMaker.h +++ b/src/gpu/GrBitmapTextureMaker.h @@ -23,9 +23,7 @@ protected: SkColorSpace* dstColorSpace, AllowedTexGenType onlyIfFast) override; - void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey, - SkColorSpace* dstColorSpace) override; - + void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) override; void didCacheCopy(const GrUniqueKey& copyKey, uint32_t contextUniqueID) override; SkAlphaType alphaType() const override; diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp index 308445c8a1..a42c146f65 100644 --- a/src/gpu/GrImageTextureMaker.cpp +++ b/src/gpu/GrImageTextureMaker.cpp @@ -32,12 +32,9 @@ sk_sp<GrTextureProxy> GrImageTextureMaker::refOriginalTextureProxy(bool willBeMi willBeMipped, dstColorSpace, onlyIfFast); } -void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey, - SkColorSpace* dstColorSpace) { +void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) { if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { - GrUniqueKey cacheKey; - fCacher->makeCacheKeyFromOrigKey(fOriginalKey, &cacheKey); - MakeCopyKeyFromOrigKey(cacheKey, stretch, paramsCopyKey); + MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey); } } @@ -45,5 +42,5 @@ SkAlphaType GrImageTextureMaker::alphaType() const { return fClient->alphaType(); } sk_sp<SkColorSpace> GrImageTextureMaker::getColorSpace(SkColorSpace* dstColorSpace) { - return fCacher->getColorSpace(this->context(), dstColorSpace); + return fClient->refColorSpace(); } diff --git a/src/gpu/GrImageTextureMaker.h b/src/gpu/GrImageTextureMaker.h index 04148cfc71..f1f647bac8 100644 --- a/src/gpu/GrImageTextureMaker.h +++ b/src/gpu/GrImageTextureMaker.h @@ -27,8 +27,7 @@ protected: SkColorSpace* dstColorSpace, AllowedTexGenType onlyIfFast) override; - void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey, - SkColorSpace* dstColorSpace) override; + void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) override; void didCacheCopy(const GrUniqueKey& copyKey, uint32_t contextUniqueID) override {} SkAlphaType alphaType() const override; diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp index 472797d5e0..c682e0b96a 100644 --- a/src/gpu/GrTextureAdjuster.cpp +++ b/src/gpu/GrTextureAdjuster.cpp @@ -24,8 +24,7 @@ GrTextureAdjuster::GrTextureAdjuster(GrContext* context, sk_sp<GrTextureProxy> o , fColorSpace(cs) , fUniqueID(uniqueID) {} -void GrTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey, - SkColorSpace* dstColorSpace) { +void GrTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) { // Destination color space is irrelevant - we already have a texture so we're just sub-setting GrUniqueKey baseKey; GrMakeKeyFromImageID(&baseKey, fUniqueID, SkIRect::MakeWH(this->width(), this->height())); @@ -41,7 +40,7 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c GrProxyProvider* proxyProvider = fContext->contextPriv().proxyProvider(); GrUniqueKey key; - this->makeCopyKey(copyParams, &key, nullptr); + this->makeCopyKey(copyParams, &key); sk_sp<GrTextureProxy> cachedCopy; if (key.isValid()) { cachedCopy = proxyProvider->findOrCreateProxyByUniqueKey(key, diff --git a/src/gpu/GrTextureAdjuster.h b/src/gpu/GrTextureAdjuster.h index ad02ae06c8..f9c9ca385d 100644 --- a/src/gpu/GrTextureAdjuster.h +++ b/src/gpu/GrTextureAdjuster.h @@ -35,8 +35,7 @@ public: protected: SkAlphaType alphaType() const override { return fAlphaType; } - void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey, - SkColorSpace* dstColorSpace) override; + void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override; void didCacheCopy(const GrUniqueKey& copyKey, uint32_t contextUniqueID) override; GrTextureProxy* originalProxy() const { return fOriginal.get(); } diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp index 16bcefa008..cb383d4d2e 100644 --- a/src/gpu/GrTextureMaker.cpp +++ b/src/gpu/GrTextureMaker.cpp @@ -58,7 +58,7 @@ sk_sp<GrTextureProxy> GrTextureMaker::onRefTextureProxyForParams(const GrSampler GrSurfaceOrigin origOrigin = original ? original->origin() : kTopLeft_GrSurfaceOrigin; GrUniqueKey copyKey; - this->makeCopyKey(copyParams, ©Key, dstColorSpace); + this->makeCopyKey(copyParams, ©Key); sk_sp<GrTextureProxy> cachedProxy; if (copyKey.isValid()) { cachedProxy = proxyProvider->findOrCreateProxyByUniqueKey(copyKey, origOrigin); diff --git a/src/gpu/GrTextureProducer.h b/src/gpu/GrTextureProducer.h index 66adb6fa4e..c41912d64f 100644 --- a/src/gpu/GrTextureProducer.h +++ b/src/gpu/GrTextureProducer.h @@ -152,8 +152,7 @@ protected: * depends on the destination color space, then that information should also be incorporated * in the key. */ - virtual void makeCopyKey(const CopyParams&, GrUniqueKey* copyKey, - SkColorSpace* dstColorSpace) = 0; + virtual void makeCopyKey(const CopyParams&, GrUniqueKey* copyKey) = 0; /** * If a stretched version of the texture is generated, it may be cached (assuming that diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 8619aba1bc..214abfb5b8 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -33,7 +33,6 @@ #include "SkBitmapCache.h" #include "SkCanvas.h" #include "SkGr.h" -#include "SkImageCacherator.h" #include "SkImageInfoPriv.h" #include "SkImage_Gpu.h" #include "SkMipMap.h" diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index 94eab59994..6b2fb4aca7 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp @@ -117,18 +117,8 @@ public: bool willBeMipped, SkColorSpace* dstColorSpace, GrTextureMaker::AllowedTexGenType genType) override; - - // Returns the color space of the texture that would be returned if you called lockTexture. - // Separate code path to allow querying of the color space for textures that cached (even - // externally). - sk_sp<SkColorSpace> getColorSpace(GrContext*, SkColorSpace* dstColorSpace) override; - - // TODO: Need to pass in dstColorSpace to fold into key here? - void makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, GrUniqueKey* cacheKey) override; #endif - SkImageInfo buildCacheInfo() const override; - private: class ScopedGenerator; @@ -233,16 +223,6 @@ SkImage_Lazy::SkImage_Lazy(Validator* validator) ////////////////////////////////////////////////////////////////////////////////////////////////// -SkImageInfo SkImage_Lazy::buildCacheInfo() const { - if (kGray_8_SkColorType == fInfo.colorType()) { - return fInfo.makeColorSpace(nullptr); - } else { - return fInfo; - } -} - -////////////////////////////////////////////////////////////////////////////////////////////////// - static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { SkASSERT(bitmap.getGenerationID() == expectedID); SkASSERT(bitmap.isImmutable()); @@ -384,8 +364,7 @@ sk_sp<SkData> SkImage_Lazy::onRefEncoded() const { bool SkImage_Lazy::getROPixels(SkBitmap* bitmap, SkColorSpace* dstColorSpace, CachingHint chint) const { - const SkImageInfo cacheInfo = this->buildCacheInfo(); - return this->lockAsBitmap(bitmap, chint, cacheInfo); + return this->lockAsBitmap(bitmap, chint, fInfo); } bool SkImage_Lazy::onIsValid(GrContext* context) const { @@ -452,15 +431,6 @@ sk_sp<SkImage> SkImage::MakeFromGenerator(std::unique_ptr<SkImageGenerator> gene #if SK_SUPPORT_GPU -void SkImage_Lazy::makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, GrUniqueKey* cacheKey) { - // TODO: Take dstColorSpace, include hash in key - SkASSERT(!cacheKey->isValid()); - if (origKey.isValid()) { - static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); - GrUniqueKey::Builder builder(cacheKey, origKey, kDomain, 0, "Image"); - } -} - class Generator_GrYUVProvider : public GrYUVProvider { SkImageGenerator* fGen; @@ -494,21 +464,6 @@ static void set_key_on_proxy(GrProxyProvider* proxyProvider, } } -sk_sp<SkColorSpace> SkImage_Lazy::getColorSpace(GrContext* ctx, SkColorSpace* dstColorSpace) { - // TODO: Is this ever needed? Is the output of this function going to be: - // return dstColorSpace ? fInfo.refColorSpace() : dstColorSpace; - // Yes, except for gray? - if (!dstColorSpace) { - // In legacy mode, we do no modification to the image's color space or encoding. - // Subsequent legacy drawing is likely to ignore the color space, but some clients - // may want to know what space the image data is in, so return it. - return fInfo.refColorSpace(); - } else { - SkImageInfo cacheInfo = this->buildCacheInfo(); - return cacheInfo.refColorSpace(); - } -} - /* * We have 4 ways to try to return a texture (in sorted order) * @@ -518,7 +473,7 @@ sk_sp<SkColorSpace> SkImage_Lazy::getColorSpace(GrContext* ctx, SkColorSpace* ds * 4. Ask the generator to return RGB(A) data, which the GPU can convert */ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, - const GrUniqueKey& origKey, + const GrUniqueKey& key, SkImage::CachingHint chint, bool willBeMipped, SkColorSpace* dstColorSpace, @@ -536,10 +491,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, enum { kLockTexturePathCount = kRGBA_LockTexturePath + 1 }; - // Build our texture key. - // TODO: This needs to include the dstColorSpace. - GrUniqueKey key; - this->makeCacheKeyFromOrigKey(origKey, &key); + // TODO: When implementing decode-to-dst, fold dstColorSpace hash into key GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider(); sk_sp<GrTextureProxy> proxy; @@ -556,10 +508,6 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, } } - // What format are we going to ask the generator to create? - // TODO: Based on the dstColorSpace? - const SkImageInfo cacheInfo = this->buildCacheInfo(); - // 2. Ask the generator to natively create one if (!proxy) { ScopedGenerator generator(fSharedGenerator); @@ -567,7 +515,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, SkImageGenerator::TexGenType::kCheap != generator->onCanGenerateTexture()) { return nullptr; } - if ((proxy = generator->generateTexture(ctx, cacheInfo, fOrigin, willBeMipped))) { + if ((proxy = generator->generateTexture(ctx, fInfo, fOrigin, willBeMipped))) { SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath, kLockTexturePathCount); set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key); @@ -582,7 +530,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, // 3. Ask the generator to return YUV planes, which the GPU can convert. If we will be mipping // the texture we fall through here and have the CPU generate the mip maps for us. if (!proxy && !willBeMipped && !ctx->contextPriv().disableGpuYUVConversion()) { - const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(cacheInfo); + const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo); ScopedGenerator generator(fSharedGenerator); Generator_GrYUVProvider provider(generator); @@ -611,7 +559,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, cacheInfo)) { + if (!proxy && this->lockAsBitmap(&bitmap, chint, fInfo)) { if (willBeMipped) { proxy = proxyProvider->createMipMapProxyFromBitmap(bitmap); } |