Chromium Code Reviews| Index: src/core/SkLinearBitmapPipeline_sample.h |
| diff --git a/src/core/SkLinearBitmapPipeline_sample.h b/src/core/SkLinearBitmapPipeline_sample.h |
| index 0e31c647df82eb43618cbb76201c4b1a2a553665..bf16c14216f495c9d348e3c0d01d59bd7953fda2 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 <tuple> |
| + |
| #include "SkFixed.h" |
| #include "SkHalf.h" |
| #include "SkLinearBitmapPipeline_core.h" |
| -#include <array> |
| -#include <tuple> |
| +#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<typename SourceStrategy, typename Next> |
| 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 <typename PixelGetter> |
| class PixelAccessor { |
| public: |
| @@ -630,11 +622,10 @@ public: |
| Sk4f getPixelFromRow(const void* row, int index) { |
| const uint32_t* src = static_cast<const uint32_t*>(row); |
| - Sk4b bytePixel = Sk4b::Load((uint8_t *)(&src[index])); |
| - Sk4f pixel = SkNx_cast<float, uint8_t>(bytePixel); |
| + Sk4f pixel = to_4f(*src); |
| pixel = pixel * (1.0f/255.0f); |
|
f(malita)
2016/05/11 16:54:03
Nit: these two lines are equivalent to Sk4f_fromL3
herb_g
2016/05/11 18:15:17
Done.
|
| if (colorProfile == kSRGB_SkColorProfileType) { |
| - pixel = sRGBFast::sRGBToLinear(pixel); |
| + pixel = srgb_to_linear(pixel); |
| } |
| return pixel; |
| } |
| @@ -662,12 +653,11 @@ public: |
| Sk4f getPixelFromRow(const void* row, int index) { |
| const uint32_t* src = static_cast<const uint32_t*>(row); |
| - Sk4b bytePixel = Sk4b::Load((uint8_t *)(&src[index])); |
| - Sk4f pixel = SkNx_cast<float, uint8_t>(bytePixel); |
| + Sk4f pixel = to_4f(*src); |
| pixel = SkNx_shuffle<2, 1, 0, 3>(pixel); |
| pixel = pixel * (1.0f/255.0f); |
| if (colorProfile == kSRGB_SkColorProfileType) { |
| - pixel = sRGBFast::sRGBToLinear(pixel); |
| + pixel = srgb_to_linear(pixel); |
| } |
|
f(malita)
2016/05/11 16:54:03
Nit: maybe also rewrite as
Sk4f pixel = colorPr
herb_g
2016/05/11 18:15:17
Done.
|
| return pixel; |
| } |
| @@ -725,15 +715,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<float, uint8_t>(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 { |