diff options
author | 2016-06-21 10:28:14 -0700 | |
---|---|---|
committer | 2016-06-21 10:28:14 -0700 | |
commit | dabe5d3780dee956882c0d65c979ccd09a99ea8f (patch) | |
tree | 21f750ea8c8972806287216490dcd25f603a2b96 /src/core | |
parent | db197a54b562d92a9da2f849e780aa327e1991ca (diff) |
update callers to not use SkColorProfileType
Requires https://codereview.chromium.org/2087833002/ to land first.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2086583002
Review-Url: https://codereview.chromium.org/2086583002
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBlitter_PM4f.cpp | 2 | ||||
-rw-r--r-- | src/core/SkBlitter_Sprite.cpp | 9 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 4 | ||||
-rw-r--r-- | src/core/SkColorShader.cpp | 2 | ||||
-rw-r--r-- | src/core/SkDraw.cpp | 3 | ||||
-rw-r--r-- | src/core/SkLinearBitmapPipeline.cpp | 19 | ||||
-rw-r--r-- | src/core/SkLinearBitmapPipeline.h | 5 | ||||
-rw-r--r-- | src/core/SkLinearBitmapPipeline_sample.h | 60 | ||||
-rw-r--r-- | src/core/SkMipMap.cpp | 10 | ||||
-rw-r--r-- | src/core/SkSpanProcs.cpp | 2 |
10 files changed, 57 insertions, 59 deletions
diff --git a/src/core/SkBlitter_PM4f.cpp b/src/core/SkBlitter_PM4f.cpp index bf332c5985..455a97b95d 100644 --- a/src/core/SkBlitter_PM4f.cpp +++ b/src/core/SkBlitter_PM4f.cpp @@ -354,7 +354,7 @@ struct State32 : State4f { if (is_opaque(paint, shaderContext)) { fFlags |= SkXfermode::kSrcIsOpaque_D32Flag; } - if (info.isSRGB()) { + if (info.gammaCloseToSRGB()) { fFlags |= SkXfermode::kDstIsSRGB_D32Flag; } fProc1 = SkXfermode::GetD32Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle_D32Flag); diff --git a/src/core/SkBlitter_Sprite.cpp b/src/core/SkBlitter_Sprite.cpp index 90e38f498a..950f18791f 100644 --- a/src/core/SkBlitter_Sprite.cpp +++ b/src/core/SkBlitter_Sprite.cpp @@ -59,7 +59,7 @@ public: if (dst.colorType() != src.colorType()) { return false; } - if (dst.info().profileType() != src.info().profileType()) { + if (dst.info().gammaCloseToSRGB() != src.info().gammaCloseToSRGB()) { return false; } if (paint.getMaskFilter() || paint.getColorFilter() || paint.getImageFilter()) { @@ -81,8 +81,7 @@ public: // At this point memcpy can't be used. The following check for using SrcOver. - if (dst.colorType() != kN32_SkColorType - || dst.info().profileType() != kSRGB_SkColorProfileType) { + if (dst.colorType() != kN32_SkColorType || !dst.info().gammaCloseToSRGB()) { return false; } @@ -109,7 +108,7 @@ public: void blitRect(int x, int y, int width, int height) override { SkASSERT(fDst.colorType() == fSource.colorType()); - SkASSERT(fDst.info().profileType() == fSource.info().profileType()); + SkASSERT(fDst.info().gammaCloseToSRGB() == fSource.info().gammaCloseToSRGB()); SkASSERT(width > 0 && height > 0); if (fUseMemcpy) { @@ -175,7 +174,7 @@ SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint, blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator); break; case kN32_SkColorType: - if (dst.info().isSRGB()) { + if (dst.info().gammaCloseToSRGB()) { blitter = SkSpriteBlitter::ChooseS32(source, paint, allocator); } else { blitter = SkSpriteBlitter::ChooseL32(source, paint, allocator); diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 1a5c4c4d11..0313ed1611 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -2283,7 +2283,7 @@ void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S drawAsSprite = false; } else{ // Until imagefilters are updated, they cannot handle any src type but N32... - if (bitmap.info().colorType() != kN32_SkColorType || bitmap.info().isSRGB()) { + if (bitmap.info().colorType() != kN32_SkColorType || bitmap.info().gammaCloseToSRGB()) { drawAsSprite = false; } } @@ -2368,7 +2368,7 @@ void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons *paint); if (drawAsSprite && paint->getImageFilter()) { // Until imagefilters are updated, they cannot handle any src type but N32... - if (bitmap.info().colorType() != kN32_SkColorType || bitmap.info().isSRGB()) { + if (bitmap.info().colorType() != kN32_SkColorType || bitmap.info().gammaCloseToSRGB()) { drawAsSprite = false; } } diff --git a/src/core/SkColorShader.cpp b/src/core/SkColorShader.cpp index 83fd239a92..250a367822 100644 --- a/src/core/SkColorShader.cpp +++ b/src/core/SkColorShader.cpp @@ -286,7 +286,7 @@ static bool choose_blitprocs(const SkPM4f* pm4, const SkImageInfo& info, } switch (info.colorType()) { case kN32_SkColorType: - if (info.isSRGB()) { + if (info.gammaCloseToSRGB()) { flags |= SkXfermode::kDstIsSRGB_D32Flag; } state->fStorage[0] = (void*)SkXfermode::GetD32Proc(state->fXfer, flags); diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 9a0509c488..e7bacab8ac 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1561,7 +1561,8 @@ private: uint32_t SkDraw::scalerContextFlags() const { uint32_t flags = SkPaint::kBoostContrast_ScalerContextFlag; - if (fDevice->imageInfo().isLinear()) { + // TODO: how should we handle non-srgb, non-linear gamma? + if (!fDevice->imageInfo().gammaCloseToSRGB()) { flags |= SkPaint::kFakeGamma_ScalerContextFlag; } return flags; diff --git a/src/core/SkLinearBitmapPipeline.cpp b/src/core/SkLinearBitmapPipeline.cpp index 4f6985b594..3a8606238d 100644 --- a/src/core/SkLinearBitmapPipeline.cpp +++ b/src/core/SkLinearBitmapPipeline.cpp @@ -567,22 +567,22 @@ private: using Blender = SkLinearBitmapPipeline::BlendProcessorInterface; -template <SkColorType colorType, template <SkColorType, SkColorProfileType, typename> class Sampler> +template <SkColorType colorType, template <SkColorType, SkGammaType, typename> class Sampler> static void choose_specific_sampler( Blender* next, const SkPixmap& srcPixmap, SkLinearBitmapPipeline::SampleStage* sampleStage) { - if (srcPixmap.info().profileType() == kSRGB_SkColorProfileType) { - using S = Sampler<colorType, kSRGB_SkColorProfileType, Blender>; + if (srcPixmap.info().gammaCloseToSRGB()) { + using S = Sampler<colorType, kSRGB_SkGammaType, Blender>; sampleStage->initStage<S>(next, srcPixmap); } else { - using S = Sampler<colorType, kLinear_SkColorProfileType, Blender>; + using S = Sampler<colorType, kLinear_SkGammaType, Blender>; sampleStage->initStage<S>(next, srcPixmap); } } -template<template <SkColorType, SkColorProfileType, typename> class Sampler> +template<template <SkColorType, SkGammaType, typename> class Sampler> static SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler_base( Blender* next, const SkPixmap& srcPixmap, @@ -592,7 +592,7 @@ static SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler_ba const SkImageInfo& imageInfo = srcPixmap.info(); switch (imageInfo.colorType()) { case kAlpha_8_SkColorType: { - using S = Sampler<kAlpha_8_SkColorType, kLinear_SkColorProfileType, Blender>; + using S = Sampler<kAlpha_8_SkColorType, kLinear_SkGammaType, Blender>; sampleStage->initStage<S>(next, srcPixmap, A8TintColor); } break; @@ -615,7 +615,7 @@ static SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler_ba choose_specific_sampler<kGray_8_SkColorType, Sampler>(next, srcPixmap, sampleStage); break; case kRGBA_F16_SkColorType: { - using S = Sampler<kRGBA_F16_SkColorType, kLinear_SkColorProfileType, Blender>; + using S = Sampler<kRGBA_F16_SkColorType, kLinear_SkGammaType, Blender>; sampleStage->initStage<S>(next, srcPixmap); } break; @@ -772,8 +772,9 @@ bool SkLinearBitmapPipeline::ClonePipelineForBlitting( if (srcPixmap.info().colorType() != kRGBA_8888_SkColorType || dstInfo.colorType() != kRGBA_8888_SkColorType) { return false; } - if (srcPixmap.info().profileType() != kSRGB_SkColorProfileType - || dstInfo.profileType() != kSRGB_SkColorProfileType) { return false; } + if (!srcPixmap.info().gammaCloseToSRGB() || !dstInfo.gammaCloseToSRGB()) { + return false; + } if (xferMode != SkXfermode::kSrc_Mode && xferMode != SkXfermode::kSrcOver_Mode) { return false; diff --git a/src/core/SkLinearBitmapPipeline.h b/src/core/SkLinearBitmapPipeline.h index dce537aa6e..452ab8ef4e 100644 --- a/src/core/SkLinearBitmapPipeline.h +++ b/src/core/SkLinearBitmapPipeline.h @@ -15,6 +15,11 @@ class SkEmbeddableLinearPipeline; +enum SkGammaType { + kLinear_SkGammaType, + kSRGB_SkGammaType, +}; + /////////////////////////////////////////////////////////////////////////////////////////////////// // SkLinearBitmapPipeline - encapsulates all the machinery for doing floating point pixel // processing in a linear color space. diff --git a/src/core/SkLinearBitmapPipeline_sample.h b/src/core/SkLinearBitmapPipeline_sample.h index 5184a41af6..56f43224ae 100644 --- a/src/core/SkLinearBitmapPipeline_sample.h +++ b/src/core/SkLinearBitmapPipeline_sample.h @@ -55,14 +55,14 @@ static Sk4s VECTORCALL bilerp4(Sk4s xs, Sk4s ys, Sk4f px00, Sk4f px10, //////////////////////////////////////////////////////////////////////////////////////////////////// // PixelGetter is the lowest level interface to the source data. There is a PixelGetter for each // of the different SkColorTypes. -template <SkColorType colorType, SkColorProfileType colorProfile> class PixelGetter; +template <SkColorType, SkGammaType> class PixelGetter; // Alpha handling: // The alpha from the paint (tintColor) is used in the blend part of the pipeline to modulate // the entire bitmap. So, the tint color is given an alpha of 1.0 so that the later alpha can // modulate this color later. template <> -class PixelGetter<kAlpha_8_SkColorType, kLinear_SkColorProfileType> { +class PixelGetter<kAlpha_8_SkColorType, kLinear_SkGammaType> { public: using Element = uint8_t; PixelGetter(const SkPixmap& srcPixmap, SkColor tintColor) @@ -76,63 +76,63 @@ private: const Sk4f fTintColor; }; -template <SkColorProfileType colorProfile> -class PixelGetter<kRGB_565_SkColorType, colorProfile> { +template <SkGammaType gammaType> +class PixelGetter<kRGB_565_SkColorType, gammaType> { public: using Element = uint16_t; PixelGetter(const SkPixmap& srcPixmap) { } Sk4f getPixelAt(const uint16_t* src) { SkPMColor pixel = SkPixel16ToPixel32(*src); - return colorProfile == kSRGB_SkColorProfileType + return gammaType == kSRGB_SkGammaType ? Sk4f_fromS32(pixel) : Sk4f_fromL32(pixel); } }; -template <SkColorProfileType colorProfile> -class PixelGetter<kARGB_4444_SkColorType, colorProfile> { +template <SkGammaType gammaType> +class PixelGetter<kARGB_4444_SkColorType, gammaType> { public: using Element = uint16_t; PixelGetter(const SkPixmap& srcPixmap) { } Sk4f getPixelAt(const uint16_t* src) { SkPMColor pixel = SkPixel4444ToPixel32(*src); - return colorProfile == kSRGB_SkColorProfileType + return gammaType == kSRGB_SkGammaType ? Sk4f_fromS32(pixel) : Sk4f_fromL32(pixel); } }; -template <SkColorProfileType colorProfile> -class PixelGetter<kRGBA_8888_SkColorType, colorProfile> { +template <SkGammaType gammaType> +class PixelGetter<kRGBA_8888_SkColorType, gammaType> { public: using Element = uint32_t; PixelGetter(const SkPixmap& srcPixmap) { } Sk4f getPixelAt(const uint32_t* src) { - return colorProfile == kSRGB_SkColorProfileType + return gammaType == kSRGB_SkGammaType ? Sk4f_fromS32(*src) : Sk4f_fromL32(*src); } }; -template <SkColorProfileType colorProfile> -class PixelGetter<kBGRA_8888_SkColorType, colorProfile> { +template <SkGammaType gammaType> +class PixelGetter<kBGRA_8888_SkColorType, gammaType> { public: using Element = uint32_t; PixelGetter(const SkPixmap& srcPixmap) { } Sk4f getPixelAt(const uint32_t* src) { - Sk4f pixel = colorProfile == kSRGB_SkColorProfileType + Sk4f pixel = gammaType == kSRGB_SkGammaType ? Sk4f_fromS32(*src) : Sk4f_fromL32(*src); return swizzle_rb(pixel); } }; -template <SkColorProfileType colorProfile> -class PixelGetter<kIndex_8_SkColorType, colorProfile> { +template <SkGammaType gammaType> +class PixelGetter<kIndex_8_SkColorType, gammaType> { public: using Element = uint8_t; PixelGetter(const SkPixmap& srcPixmap) { @@ -166,7 +166,7 @@ private: float invAlpha = 1.0f / alpha; Sk4f normalize = {invAlpha, invAlpha, invAlpha, 1.0f / 255.0f}; pixel = pixel * normalize; - if (colorProfile == kSRGB_SkColorProfileType) { + if (gammaType == kSRGB_SkGammaType) { pixel = linear_to_srgb(pixel); } return pixel; @@ -178,8 +178,8 @@ private: Sk4f* fColorTable; }; -template <SkColorProfileType colorProfile> -class PixelGetter<kGray_8_SkColorType, colorProfile> { +template <SkGammaType gammaType> +class PixelGetter<kGray_8_SkColorType, gammaType> { public: using Element = uint8_t; PixelGetter(const SkPixmap& srcPixmap) { } @@ -187,14 +187,14 @@ public: Sk4f getPixelAt(const uint8_t* src) { float gray = *src * (1.0f/255.0f); Sk4f pixel = Sk4f{gray, gray, gray, 1.0f}; - return colorProfile == kSRGB_SkColorProfileType + return gammaType == kSRGB_SkGammaType ? srgb_to_linear(pixel) : pixel; } }; template <> -class PixelGetter<kRGBA_F16_SkColorType, kLinear_SkColorProfileType> { +class PixelGetter<kRGBA_F16_SkColorType, kLinear_SkGammaType> { public: using Element = uint64_t; PixelGetter(const SkPixmap& srcPixmap) { } @@ -206,9 +206,9 @@ public: //////////////////////////////////////////////////////////////////////////////////////////////////// // PixelAccessor handles all the same plumbing for all the PixelGetters. -template <SkColorType colorType, SkColorProfileType colorProfile> +template <SkColorType colorType, SkGammaType gammaType> class PixelAccessor { - using Element = typename PixelGetter<colorType, colorProfile>::Element; + using Element = typename PixelGetter<colorType, gammaType>::Element; public: template <typename... Args> PixelAccessor(const SkPixmap& srcPixmap, Args&&... args) @@ -263,7 +263,7 @@ public: private: const Element* const fSrc; const Sk4i fWidth; - PixelGetter<colorType, colorProfile> fGetter; + PixelGetter<colorType, gammaType> fGetter; }; // We're moving through source space at a rate of 1 source pixel per 1 dst pixel. @@ -308,7 +308,7 @@ static void src_strategy_blend(Span span, Next* next, Strategy* strategy) { } // NearestNeighborSampler - use nearest neighbor filtering to create runs of destination pixels. -template<SkColorType colorType, SkColorProfileType colorProfile, typename Next> +template<SkColorType colorType, SkGammaType gammaType, typename Next> class NearestNeighborSampler : public SkLinearBitmapPipeline::SampleProcessorInterface { public: template<typename... Args> @@ -424,13 +424,13 @@ private: span_fallback(span, this); } - Next* const fNext; - PixelAccessor<colorType, colorProfile> fStrategy; + Next* const fNext; + PixelAccessor<colorType, gammaType> fStrategy; }; // -- BilerpSampler -------------------------------------------------------------------------------- // BilerpSampler - use a bilerp filter to create runs of destination pixels. -template<SkColorType colorType, SkColorProfileType colorProfile, typename Next> +template<SkColorType colorType, SkGammaType gammaType, typename Next> class BilerpSampler : public SkLinearBitmapPipeline::SampleProcessorInterface { public: template<typename... Args> @@ -801,8 +801,8 @@ private: } } - Next* const fNext; - PixelAccessor<colorType, colorProfile> fStrategy; + Next* const fNext; + PixelAccessor<colorType, gammaType> fStrategy; }; } // namespace diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp index b9302cdb68..f469762eba 100644 --- a/src/core/SkMipMap.cpp +++ b/src/core/SkMipMap.cpp @@ -304,14 +304,6 @@ size_t SkMipMap::AllocLevelsSize(int levelCount, size_t pixelSize) { return sk_64_asS32(size); } -static bool treat_like_srgb(const SkImageInfo& info) { - if (info.colorSpace()) { - return info.colorSpace()->gammaCloseToSRGB(); - } else { - return kSRGB_SkColorProfileType == info.profileType(); - } -} - SkMipMap* SkMipMap::Build(const SkPixmap& src, SkSourceGammaTreatment treatment, SkDiscardableFactoryProc fact) { typedef void FilterProc(void*, const void* srcPtr, size_t srcRB, int count); @@ -328,7 +320,7 @@ SkMipMap* SkMipMap::Build(const SkPixmap& src, SkSourceGammaTreatment treatment, const SkColorType ct = src.colorType(); const SkAlphaType at = src.alphaType(); const bool srgbGamma = (SkSourceGammaTreatment::kRespect == treatment) - && treat_like_srgb(src.info()); + && src.info().gammaCloseToSRGB(); switch (ct) { case kRGBA_8888_SkColorType: diff --git a/src/core/SkSpanProcs.cpp b/src/core/SkSpanProcs.cpp index 385bd6b70f..dddf7419e2 100644 --- a/src/core/SkSpanProcs.cpp +++ b/src/core/SkSpanProcs.cpp @@ -49,7 +49,7 @@ static void load_f16(const SkPixmap& src, int x, int y, SkPM4f span[], int count SkLoadSpanProc SkLoadSpanProc_Choose(const SkImageInfo& info) { switch (info.colorType()) { case kN32_SkColorType: - return info.isSRGB() ? load_s32 : load_l32; + return info.gammaCloseToSRGB() ? load_s32 : load_l32; case kRGBA_F16_SkColorType: return load_f16; default: |