From cf05dcd64b47dcf5e6ff02132d2b57d3b40d0bf1 Mon Sep 17 00:00:00 2001 From: herb Date: Wed, 11 May 2016 11:53:36 -0700 Subject: Use common code from SkPM4fPriv BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1967793003 Review-Url: https://codereview.chromium.org/1967793003 --- src/core/SkLinearBitmapPipeline_sample.h | 45 ++++++++++---------------------- 1 file changed, 14 insertions(+), 31 deletions(-) (limited to 'src/core') diff --git a/src/core/SkLinearBitmapPipeline_sample.h b/src/core/SkLinearBitmapPipeline_sample.h index 0e31c647df..8171b855a4 100644 --- a/src/core/SkLinearBitmapPipeline_sample.h +++ b/src/core/SkLinearBitmapPipeline_sample.h @@ -8,11 +8,12 @@ #ifndef SkLinearBitmapPipeline_sampler_DEFINED #define SkLinearBitmapPipeline_sampler_DEFINED +#include + #include "SkFixed.h" #include "SkHalf.h" #include "SkLinearBitmapPipeline_core.h" -#include -#include +#include "SkPM4fPriv.h" namespace { // Explaination of the math: @@ -48,7 +49,6 @@ static Sk4s VECTORCALL bilerp4(Sk4s xs, Sk4s ys, Sk4f px00, Sk4f px10, return sum; } -// The GeneralSampler class template class GeneralSampler { public: @@ -560,14 +560,6 @@ private: SourceStrategy fStrategy; }; -class sRGBFast { -public: - static Sk4s VECTORCALL sRGBToLinear(Sk4s pixel) { - Sk4s l = pixel * pixel; - return Sk4s{l[0], l[1], l[2], pixel[3]}; - } -}; - template class PixelAccessor { public: @@ -630,13 +622,9 @@ public: Sk4f getPixelFromRow(const void* row, int index) { const uint32_t* src = static_cast(row); - Sk4b bytePixel = Sk4b::Load((uint8_t *)(&src[index])); - Sk4f pixel = SkNx_cast(bytePixel); - pixel = pixel * (1.0f/255.0f); - if (colorProfile == kSRGB_SkColorProfileType) { - pixel = sRGBFast::sRGBToLinear(pixel); - } - return pixel; + return colorProfile == kSRGB_SkColorProfileType + ? Sk4f_fromS32(*src) + : Sk4f_fromL32(*src); } Sk4f getPixelAt(int index) { @@ -662,14 +650,10 @@ public: Sk4f getPixelFromRow(const void* row, int index) { const uint32_t* src = static_cast(row); - Sk4b bytePixel = Sk4b::Load((uint8_t *)(&src[index])); - Sk4f pixel = SkNx_cast(bytePixel); - pixel = SkNx_shuffle<2, 1, 0, 3>(pixel); - pixel = pixel * (1.0f/255.0f); - if (colorProfile == kSRGB_SkColorProfileType) { - pixel = sRGBFast::sRGBToLinear(pixel); - } - return pixel; + Sk4f pixel = colorProfile == kSRGB_SkColorProfileType + ? Sk4f_fromS32(*src) + : Sk4f_fromL32(*src); + return SkNx_shuffle<2, 1, 0, 3>(pixel); } Sk4f getPixelAt(int index) { @@ -725,15 +709,14 @@ public: private: static const size_t kColorTableSize = sizeof(Sk4f[256]) + 12; Sk4f convertPixel(SkPMColor pmColor) { - Sk4b bPixel = Sk4b::Load(&pmColor); - Sk4f pixel = SkNx_cast(bPixel); - float alpha = pixel[3]; + Sk4f pixel = to_4f(pmColor); + float alpha = get_alpha(pixel); if (alpha != 0.0f) { - float invAlpha = 1.0f / pixel[3]; + float invAlpha = 1.0f / alpha; Sk4f normalize = {invAlpha, invAlpha, invAlpha, 1.0f / 255.0f}; pixel = pixel * normalize; if (colorProfile == kSRGB_SkColorProfileType) { - pixel = sRGBFast::sRGBToLinear(pixel); + pixel = linear_to_srgb(pixel); } return pixel; } else { -- cgit v1.2.3