| Index: src/core/SkLinearBitmapPipeline_sample.h
|
| diff --git a/src/core/SkLinearBitmapPipeline_sample.h b/src/core/SkLinearBitmapPipeline_sample.h
|
| index 5d1f26fc8fe6637429da01b40f9791b1b597a103..39400f67500bc95986135123d5ffe3970098e54e 100644
|
| --- a/src/core/SkLinearBitmapPipeline_sample.h
|
| +++ b/src/core/SkLinearBitmapPipeline_sample.h
|
| @@ -53,23 +53,23 @@ static Sk4s SK_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
|
| +// PixelGetter is the lowest level interface to the source data. There is a PixelConverter for each
|
| // of the different SkColorTypes.
|
| -template <SkColorType, SkGammaType> class PixelGetter;
|
| +template <SkColorType, SkGammaType> class PixelConverter;
|
|
|
| // 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_SkGammaType> {
|
| +class PixelConverter<kAlpha_8_SkColorType, kLinear_SkGammaType> {
|
| public:
|
| using Element = uint8_t;
|
| - PixelGetter(const SkPixmap& srcPixmap, SkColor tintColor)
|
| + PixelConverter(const SkPixmap& srcPixmap, SkColor tintColor)
|
| : fTintColor{set_alpha(Sk4f_from_SkColor(tintColor), 1.0f)} { }
|
|
|
| - Sk4f getPixelAt(const uint8_t* src) {
|
| - return fTintColor * (*src * (1.0f/255.0f));
|
| + Sk4f toSk4f(const Element pixel) const {
|
| + return fTintColor * (pixel * (1.0f/255.0f));
|
| }
|
|
|
| private:
|
| @@ -77,65 +77,63 @@ private:
|
| };
|
|
|
| template <SkGammaType gammaType>
|
| -class PixelGetter<kRGB_565_SkColorType, gammaType> {
|
| +class PixelConverter<kRGB_565_SkColorType, gammaType> {
|
| public:
|
| using Element = uint16_t;
|
| - PixelGetter(const SkPixmap& srcPixmap) { }
|
| + PixelConverter(const SkPixmap& srcPixmap) { }
|
|
|
| - Sk4f getPixelAt(const uint16_t* src) {
|
| - SkPMColor pixel = SkPixel16ToPixel32(*src);
|
| + Sk4f toSk4f(Element pixel) const {
|
| + SkPMColor pixel32 = SkPixel16ToPixel32(pixel);
|
| return gammaType == kSRGB_SkGammaType
|
| - ? Sk4f_fromS32(pixel)
|
| - : Sk4f_fromL32(pixel);
|
| + ? Sk4f_fromS32(pixel32)
|
| + : Sk4f_fromL32(pixel32);
|
| }
|
| };
|
|
|
| template <SkGammaType gammaType>
|
| -class PixelGetter<kARGB_4444_SkColorType, gammaType> {
|
| +class PixelConverter<kARGB_4444_SkColorType, gammaType> {
|
| public:
|
| using Element = uint16_t;
|
| - PixelGetter(const SkPixmap& srcPixmap) { }
|
| + PixelConverter(const SkPixmap& srcPixmap) { }
|
|
|
| - Sk4f getPixelAt(const uint16_t* src) {
|
| - SkPMColor pixel = SkPixel4444ToPixel32(*src);
|
| + Sk4f toSk4f(Element pixel) const {
|
| + SkPMColor pixel32 = SkPixel4444ToPixel32(pixel);
|
| return gammaType == kSRGB_SkGammaType
|
| - ? Sk4f_fromS32(pixel)
|
| - : Sk4f_fromL32(pixel);
|
| + ? Sk4f_fromS32(pixel32)
|
| + : Sk4f_fromL32(pixel32);
|
| }
|
| };
|
|
|
| template <SkGammaType gammaType>
|
| -class PixelGetter<kRGBA_8888_SkColorType, gammaType> {
|
| +class PixelConverter<kRGBA_8888_SkColorType, gammaType> {
|
| public:
|
| using Element = uint32_t;
|
| - PixelGetter(const SkPixmap& srcPixmap) { }
|
| + PixelConverter(const SkPixmap& srcPixmap) { }
|
|
|
| - Sk4f getPixelAt(const uint32_t* src) {
|
| + Sk4f toSk4f(Element pixel) const {
|
| return gammaType == kSRGB_SkGammaType
|
| - ? Sk4f_fromS32(*src)
|
| - : Sk4f_fromL32(*src);
|
| + ? Sk4f_fromS32(pixel)
|
| + : Sk4f_fromL32(pixel);
|
| }
|
| };
|
|
|
| template <SkGammaType gammaType>
|
| -class PixelGetter<kBGRA_8888_SkColorType, gammaType> {
|
| +class PixelConverter<kBGRA_8888_SkColorType, gammaType> {
|
| public:
|
| using Element = uint32_t;
|
| - PixelGetter(const SkPixmap& srcPixmap) { }
|
| + PixelConverter(const SkPixmap& srcPixmap) { }
|
|
|
| - Sk4f getPixelAt(const uint32_t* src) {
|
| - Sk4f pixel = gammaType == kSRGB_SkGammaType
|
| - ? Sk4f_fromS32(*src)
|
| - : Sk4f_fromL32(*src);
|
| - return swizzle_rb(pixel);
|
| + Sk4f toSk4f(Element pixel) const {
|
| + return swizzle_rb(
|
| + gammaType == kSRGB_SkGammaType ? Sk4f_fromS32(pixel) : Sk4f_fromL32(pixel));
|
| }
|
| };
|
|
|
| template <SkGammaType gammaType>
|
| -class PixelGetter<kIndex_8_SkColorType, gammaType> {
|
| +class PixelConverter<kIndex_8_SkColorType, gammaType> {
|
| public:
|
| using Element = uint8_t;
|
| - PixelGetter(const SkPixmap& srcPixmap) {
|
| + PixelConverter(const SkPixmap& srcPixmap) {
|
| SkColorTable* skColorTable = srcPixmap.ctable();
|
| SkASSERT(skColorTable != nullptr);
|
|
|
| @@ -145,7 +143,7 @@ public:
|
| }
|
| }
|
|
|
| - PixelGetter(const PixelGetter& strategy) {
|
| + PixelConverter(const PixelConverter& strategy) {
|
| fColorTable = (Sk4f*)SkAlign16((intptr_t)fColorTableStorage.get());
|
| // TODO: figure out the count.
|
| for (int i = 0; i < 256; i++) {
|
| @@ -153,8 +151,8 @@ public:
|
| }
|
| }
|
|
|
| - Sk4f getPixelAt(const uint8_t* src) {
|
| - return fColorTable[*src];
|
| + Sk4f toSk4f(Element index) const {
|
| + return fColorTable[index];
|
| }
|
|
|
| private:
|
| @@ -179,44 +177,81 @@ private:
|
| };
|
|
|
| template <SkGammaType gammaType>
|
| -class PixelGetter<kGray_8_SkColorType, gammaType> {
|
| +class PixelConverter<kGray_8_SkColorType, gammaType> {
|
| public:
|
| using Element = uint8_t;
|
| - PixelGetter(const SkPixmap& srcPixmap) { }
|
| + PixelConverter(const SkPixmap& srcPixmap) { }
|
|
|
| - Sk4f getPixelAt(const uint8_t* src) {
|
| - float gray = *src * (1.0f/255.0f);
|
| - Sk4f pixel = Sk4f{gray, gray, gray, 1.0f};
|
| + Sk4f toSk4f(Element pixel) const {
|
| + float gray = pixel * (1.0f/255.0f);
|
| + Sk4f result = Sk4f{gray, gray, gray, 1.0f};
|
| return gammaType == kSRGB_SkGammaType
|
| - ? srgb_to_linear(pixel)
|
| - : pixel;
|
| + ? srgb_to_linear(result)
|
| + : result;
|
| }
|
| };
|
|
|
| template <>
|
| -class PixelGetter<kRGBA_F16_SkColorType, kLinear_SkGammaType> {
|
| +class PixelConverter<kRGBA_F16_SkColorType, kLinear_SkGammaType> {
|
| public:
|
| using Element = uint64_t;
|
| - PixelGetter(const SkPixmap& srcPixmap) { }
|
| + PixelConverter(const SkPixmap& srcPixmap) { }
|
| +
|
| + Sk4f toSk4f(const Element pixel) const {
|
| + return SkHalfToFloat_01(pixel);
|
| + }
|
| +};
|
| +
|
| +class PixelAccessorShim {
|
| +public:
|
| + explicit PixelAccessorShim(SkLinearBitmapPipeline::PixelAccessorInterface* accessor)
|
| + : fPixelAccessor(accessor) { }
|
|
|
| - Sk4f getPixelAt(const uint64_t* src) {
|
| - return SkHalfToFloat_01(*src);
|
| + void SK_VECTORCALL getFewPixels(
|
| + int n, Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2) const {
|
| + fPixelAccessor->getFewPixels(n, xs, ys, px0, px1, px2);
|
| }
|
| +
|
| + void SK_VECTORCALL get4Pixels(
|
| + Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) const {
|
| + fPixelAccessor->get4Pixels(xs, ys, px0, px1, px2, px3);
|
| + }
|
| +
|
| + void get4Pixels(
|
| + const void* src, int index, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) const {
|
| + fPixelAccessor->get4Pixels(src, index, px0, px1, px2, px3);
|
| + };
|
| +
|
| + Sk4f getPixelFromRow(const void* row, int index) const {
|
| + return fPixelAccessor->getPixelFromRow(row, index);
|
| + }
|
| +
|
| + Sk4f getPixelAt(int index) const {
|
| + return fPixelAccessor->getPixelAt(index);
|
| + }
|
| +
|
| + const void* row(int y) const {
|
| + return fPixelAccessor->row(y);
|
| + }
|
| +
|
| +private:
|
| + SkLinearBitmapPipeline::PixelAccessorInterface* const fPixelAccessor;
|
| };
|
|
|
| ////////////////////////////////////////////////////////////////////////////////////////////////////
|
| // PixelAccessor handles all the same plumbing for all the PixelGetters.
|
| template <SkColorType colorType, SkGammaType gammaType>
|
| -class PixelAccessor {
|
| - using Element = typename PixelGetter<colorType, gammaType>::Element;
|
| +class PixelAccessor final : public SkLinearBitmapPipeline::PixelAccessorInterface {
|
| + using Element = typename PixelConverter<colorType, gammaType>::Element;
|
| public:
|
| template <typename... Args>
|
| PixelAccessor(const SkPixmap& srcPixmap, Args&&... args)
|
| : fSrc{static_cast<const Element*>(srcPixmap.addr())}
|
| , fWidth{srcPixmap.rowBytesAsPixels()}
|
| - , fGetter{srcPixmap, std::move<Args>(args)...} { }
|
| + , fConverter{srcPixmap, std::move<Args>(args)...} { }
|
|
|
| - void SK_VECTORCALL getFewPixels(int n, Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2) {
|
| + void SK_VECTORCALL getFewPixels (
|
| + int n, Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2) const override {
|
| Sk4i XIs = SkNx_cast<int, SkScalar>(xs);
|
| Sk4i YIs = SkNx_cast<int, SkScalar>(ys);
|
| Sk4i bufferLoc = YIs * fWidth + XIs;
|
| @@ -232,7 +267,8 @@ public:
|
| }
|
| }
|
|
|
| - void SK_VECTORCALL get4Pixels(Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) {
|
| + void SK_VECTORCALL get4Pixels(
|
| + Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) const override {
|
| Sk4i XIs = SkNx_cast<int, SkScalar>(xs);
|
| Sk4i YIs = SkNx_cast<int, SkScalar>(ys);
|
| Sk4i bufferLoc = YIs * fWidth + XIs;
|
| @@ -242,28 +278,29 @@ public:
|
| *px3 = this->getPixelAt(bufferLoc[3]);
|
| }
|
|
|
| - void get4Pixels(const void* src, int index, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) {
|
| + void get4Pixels(
|
| + const void* src, int index, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) const override {
|
| *px0 = this->getPixelFromRow(src, index + 0);
|
| *px1 = this->getPixelFromRow(src, index + 1);
|
| *px2 = this->getPixelFromRow(src, index + 2);
|
| *px3 = this->getPixelFromRow(src, index + 3);
|
| }
|
|
|
| - Sk4f getPixelFromRow(const void* row, int index) {
|
| + Sk4f getPixelFromRow(const void* row, int index) const override {
|
| const Element* src = static_cast<const Element*>(row);
|
| - return fGetter.getPixelAt(src + index);
|
| + return fConverter.toSk4f(src[index]);
|
| }
|
|
|
| - Sk4f getPixelAt(int index) {
|
| + Sk4f getPixelAt(int index) const override {
|
| return this->getPixelFromRow(fSrc, index);
|
| }
|
|
|
| - const void* row(int y) const { return fSrc + y * fWidth[0]; }
|
| + const void* row(int y) const override { return fSrc + y * fWidth; }
|
|
|
| private:
|
| const Element* const fSrc;
|
| - const Sk4i fWidth;
|
| - PixelGetter<colorType, gammaType> fGetter;
|
| + const int fWidth;
|
| + PixelConverter<colorType, gammaType> fConverter;
|
| };
|
|
|
| // We're moving through source space at a rate of 1 source pixel per 1 dst pixel.
|
| @@ -308,21 +345,21 @@ 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, SkGammaType gammaType, typename Next>
|
| +template<typename Accessor, typename Next>
|
| class NearestNeighborSampler : public SkLinearBitmapPipeline::SampleProcessorInterface {
|
| public:
|
| template<typename... Args>
|
| NearestNeighborSampler(SkLinearBitmapPipeline::BlendProcessorInterface* next, Args&& ... args)
|
| - : fNext{next}, fStrategy{std::forward<Args>(args)...} { }
|
| + : fNext{next}, fAccessor{std::forward<Args>(args)...} { }
|
|
|
| NearestNeighborSampler(SkLinearBitmapPipeline::BlendProcessorInterface* next,
|
| const NearestNeighborSampler& sampler)
|
| - : fNext{next}, fStrategy{sampler.fStrategy} { }
|
| + : fNext{next}, fAccessor{sampler.fAccessor} { }
|
|
|
| void SK_VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override {
|
| SkASSERT(0 < n && n < 4);
|
| Sk4f px0, px1, px2;
|
| - fStrategy.getFewPixels(n, xs, ys, &px0, &px1, &px2);
|
| + fAccessor.getFewPixels(n, xs, ys, &px0, &px1, &px2);
|
| if (n >= 1) fNext->blendPixel(px0);
|
| if (n >= 2) fNext->blendPixel(px1);
|
| if (n >= 3) fNext->blendPixel(px2);
|
| @@ -330,7 +367,7 @@ public:
|
|
|
| void SK_VECTORCALL pointList4(Sk4s xs, Sk4s ys) override {
|
| Sk4f px0, px1, px2, px3;
|
| - fStrategy.get4Pixels(xs, ys, &px0, &px1, &px2, &px3);
|
| + fAccessor.get4Pixels(xs, ys, &px0, &px1, &px2, &px3);
|
| fNext->blend4Pixels(px0, px1, px2, px3);
|
| }
|
|
|
| @@ -344,7 +381,7 @@ public:
|
| if (absLength < (count - 1)) {
|
| this->spanSlowRate(span);
|
| } else if (absLength == (count - 1)) {
|
| - src_strategy_blend(span, fNext, &fStrategy);
|
| + src_strategy_blend(span, fNext, &fAccessor);
|
| } else {
|
| this->spanFastRate(span);
|
| }
|
| @@ -378,19 +415,19 @@ private:
|
| SkScalar dx = length / (count - 1);
|
| SkFixed fdx = SkScalarToFixed(dx);
|
|
|
| - const void* row = fStrategy.row((int)std::floor(Y(start)));
|
| + const void* row = fAccessor.row((int)std::floor(Y(start)));
|
| Next* next = fNext;
|
|
|
| int ix = SkFixedFloorToInt(fx);
|
| int prevIX = ix;
|
| - Sk4f fpixel = fStrategy.getPixelFromRow(row, ix);
|
| + Sk4f fpixel = fAccessor.getPixelFromRow(row, ix);
|
|
|
| // When dx is less than one, each pixel is used more than once. Using the fixed point fx
|
| // allows the code to quickly check that the same pixel is being used. The code uses this
|
| // same pixel check to do the sRGB and normalization only once.
|
| auto getNextPixel = [&]() {
|
| if (ix != prevIX) {
|
| - fpixel = fStrategy.getPixelFromRow(row, ix);
|
| + fpixel = fAccessor.getPixelFromRow(row, ix);
|
| prevIX = ix;
|
| }
|
| fx += fdx;
|
| @@ -415,7 +452,7 @@ private:
|
| // We're moving through source space at a rate of 1 source pixel per 1 dst pixel.
|
| // We'll never re-use pixels, but we can at least load contiguous pixels.
|
| void spanUnitRate(Span span) {
|
| - src_strategy_blend(span, fNext, &fStrategy);
|
| + src_strategy_blend(span, fNext, &fAccessor);
|
| }
|
|
|
| // We're moving through source space faster than dst (zoomed out),
|
| @@ -424,22 +461,22 @@ private:
|
| span_fallback(span, this);
|
| }
|
|
|
| - Next* const fNext;
|
| - PixelAccessor<colorType, gammaType> fStrategy;
|
| + Next* const fNext;
|
| + Accessor fAccessor;
|
| };
|
|
|
| // -- BilerpSampler --------------------------------------------------------------------------------
|
| // BilerpSampler - use a bilerp filter to create runs of destination pixels.
|
| -template<SkColorType colorType, SkGammaType gammaType, typename Next>
|
| +template<typename Accessor, typename Next>
|
| class BilerpSampler : public SkLinearBitmapPipeline::SampleProcessorInterface {
|
| public:
|
| template<typename... Args>
|
| BilerpSampler(SkLinearBitmapPipeline::BlendProcessorInterface* next, Args&& ... args)
|
| - : fNext{next}, fStrategy{std::forward<Args>(args)...} { }
|
| + : fNext{next}, fAccessor{std::forward<Args>(args)...} { }
|
|
|
| BilerpSampler(SkLinearBitmapPipeline::BlendProcessorInterface* next,
|
| const BilerpSampler& sampler)
|
| - : fNext{next}, fStrategy{sampler.fStrategy} { }
|
| + : fNext{next}, fAccessor{sampler.fAccessor} { }
|
|
|
| Sk4f bilerpNonEdgePixel(SkScalar x, SkScalar y) {
|
| Sk4f px00, px10, px01, px11;
|
| @@ -449,7 +486,7 @@ public:
|
| Sk4f ys = Sk4f{y} - 0.5f;
|
| Sk4f sampleXs = xs + Sk4f{0.0f, 1.0f, 0.0f, 1.0f};
|
| Sk4f sampleYs = ys + Sk4f{0.0f, 0.0f, 1.0f, 1.0f};
|
| - fStrategy.get4Pixels(sampleXs, sampleYs, &px00, &px10, &px01, &px11);
|
| + fAccessor.get4Pixels(sampleXs, sampleYs, &px00, &px10, &px01, &px11);
|
| return bilerp4(xs, ys, px00, px10, px01, px11);
|
| }
|
|
|
| @@ -486,7 +523,7 @@ public:
|
| Sk4f px00, px10, px01, px11;
|
| Sk4f xs = Sk4f{sampleXs[0]};
|
| Sk4f ys = Sk4f{sampleYs[0]};
|
| - fStrategy.get4Pixels(sampleXs, sampleYs, &px00, &px10, &px01, &px11);
|
| + fAccessor.get4Pixels(sampleXs, sampleYs, &px00, &px10, &px01, &px11);
|
| Sk4f pixel = bilerp4(xs, ys, px00, px10, px01, px11);
|
| fNext->blendPixel(pixel);
|
| }
|
| @@ -505,7 +542,7 @@ public:
|
| } else if (absLength == (count - 1)) {
|
| if (std::fmod(span.startX() - 0.5f, 1.0f) == 0.0f) {
|
| if (std::fmod(span.startY() - 0.5f, 1.0f) == 0.0f) {
|
| - src_strategy_blend(span, fNext, &fStrategy);
|
| + src_strategy_blend(span, fNext, &fAccessor);
|
| } else {
|
| this->spanUnitRateAlignedX(span, y);
|
| }
|
| @@ -526,8 +563,8 @@ private:
|
| SkScalar filterY0 = 1.0f - filterY1;
|
| int iy1 = SkScalarFloorToInt(y1);
|
| int ix = SkScalarFloorToInt(span.startX());
|
| - Sk4f pixelY0 = fStrategy.getPixelFromRow(fStrategy.row(iy0), ix);
|
| - Sk4f pixelY1 = fStrategy.getPixelFromRow(fStrategy.row(iy1), ix);
|
| + Sk4f pixelY0 = fAccessor.getPixelFromRow(fAccessor.row(iy0), ix);
|
| + Sk4f pixelY1 = fAccessor.getPixelFromRow(fAccessor.row(iy1), ix);
|
| Sk4f filterPixel = pixelY0 * filterY0 + pixelY1 * filterY1;
|
| int count = span.count();
|
| while (count >= 4) {
|
| @@ -566,18 +603,18 @@ private:
|
| SkScalar yFloor = std::floor(ry0);
|
| Sk4f y1 = Sk4f{ry0 - yFloor};
|
| Sk4f y0 = Sk4f{1.0f} - y1;
|
| - const void* const row0 = fStrategy.row(SkScalarFloorToInt(ry0));
|
| - const void* const row1 = fStrategy.row(SkScalarFloorToInt(ry1));
|
| - Sk4f fpixel00 = y0 * fStrategy.getPixelFromRow(row0, ix);
|
| - Sk4f fpixel01 = y1 * fStrategy.getPixelFromRow(row1, ix);
|
| - Sk4f fpixel10 = y0 * fStrategy.getPixelFromRow(row0, ix + 1);
|
| - Sk4f fpixel11 = y1 * fStrategy.getPixelFromRow(row1, ix + 1);
|
| + const void* const row0 = fAccessor.row(SkScalarFloorToInt(ry0));
|
| + const void* const row1 = fAccessor.row(SkScalarFloorToInt(ry1));
|
| + Sk4f fpixel00 = y0 * fAccessor.getPixelFromRow(row0, ix);
|
| + Sk4f fpixel01 = y1 * fAccessor.getPixelFromRow(row1, ix);
|
| + Sk4f fpixel10 = y0 * fAccessor.getPixelFromRow(row0, ix + 1);
|
| + Sk4f fpixel11 = y1 * fAccessor.getPixelFromRow(row1, ix + 1);
|
| auto getNextPixel = [&]() {
|
| if (ix != ioldx) {
|
| fpixel00 = fpixel10;
|
| fpixel01 = fpixel11;
|
| - fpixel10 = y0 * fStrategy.getPixelFromRow(row0, ix + 1);
|
| - fpixel11 = y1 * fStrategy.getPixelFromRow(row1, ix + 1);
|
| + fpixel10 = y0 * fAccessor.getPixelFromRow(row0, ix + 1);
|
| + fpixel11 = y1 * fAccessor.getPixelFromRow(row1, ix + 1);
|
| ioldx = ix;
|
| x = x + xAdjust;
|
| }
|
| @@ -618,25 +655,25 @@ private:
|
| SkScalar filterY1 = y0 - iy0;
|
| SkScalar filterY0 = 1.0f - filterY1;
|
| int iy1 = SkScalarFloorToInt(y1);
|
| - const void* rowY0 = fStrategy.row(iy0);
|
| - const void* rowY1 = fStrategy.row(iy1);
|
| + const void* rowY0 = fAccessor.row(iy0);
|
| + const void* rowY1 = fAccessor.row(iy1);
|
| SkScalar x0 = span.startX() - 0.5f;
|
| int ix0 = SkScalarFloorToInt(x0);
|
| SkScalar filterX1 = x0 - ix0;
|
| SkScalar filterX0 = 1.0f - filterX1;
|
|
|
| auto getPixelY0 = [&]() {
|
| - Sk4f px = fStrategy.getPixelFromRow(rowY0, ix0);
|
| + Sk4f px = fAccessor.getPixelFromRow(rowY0, ix0);
|
| return px * filterY0;
|
| };
|
|
|
| auto getPixelY1 = [&]() {
|
| - Sk4f px = fStrategy.getPixelFromRow(rowY1, ix0);
|
| + Sk4f px = fAccessor.getPixelFromRow(rowY1, ix0);
|
| return px * filterY1;
|
| };
|
|
|
| auto get4PixelsY0 = [&](int ix, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) {
|
| - fStrategy.get4Pixels(rowY0, ix, px0, px1, px2, px3);
|
| + fAccessor.get4Pixels(rowY0, ix, px0, px1, px2, px3);
|
| *px0 = *px0 * filterY0;
|
| *px1 = *px1 * filterY0;
|
| *px2 = *px2 * filterY0;
|
| @@ -644,7 +681,7 @@ private:
|
| };
|
|
|
| auto get4PixelsY1 = [&](int ix, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) {
|
| - fStrategy.get4Pixels(rowY1, ix, px0, px1, px2, px3);
|
| + fAccessor.get4Pixels(rowY1, ix, px0, px1, px2, px3);
|
| *px0 = *px0 * filterY1;
|
| *px1 = *px1 * filterY1;
|
| *px2 = *px2 * filterY1;
|
| @@ -678,8 +715,8 @@ private:
|
| count -= 4;
|
| }
|
| while (count > 0) {
|
| - Sk4f pixelY0 = fStrategy.getPixelFromRow(rowY0, ix0);
|
| - Sk4f pixelY1 = fStrategy.getPixelFromRow(rowY1, ix0);
|
| + Sk4f pixelY0 = fAccessor.getPixelFromRow(rowY0, ix0);
|
| + Sk4f pixelY1 = fAccessor.getPixelFromRow(rowY1, ix0);
|
|
|
| fNext->blendPixel(lerp(pixelY0, pixelY1));
|
| ix0 += 1;
|
| @@ -706,8 +743,8 @@ private:
|
| count -= 4;
|
| }
|
| while (count > 0) {
|
| - Sk4f pixelY0 = fStrategy.getPixelFromRow(rowY0, ix0);
|
| - Sk4f pixelY1 = fStrategy.getPixelFromRow(rowY1, ix0);
|
| + Sk4f pixelY0 = fAccessor.getPixelFromRow(rowY0, ix0);
|
| + Sk4f pixelY1 = fAccessor.getPixelFromRow(rowY1, ix0);
|
|
|
| fNext->blendPixel(lerp(pixelY0, pixelY1));
|
| ix0 -= 1;
|
| @@ -724,8 +761,8 @@ private:
|
| SkScalar filterY0 = 1.0f - filterY1;
|
| int iy1 = SkScalarFloorToInt(y1);
|
| int ix = SkScalarFloorToInt(span.startX());
|
| - const void* rowY0 = fStrategy.row(iy0);
|
| - const void* rowY1 = fStrategy.row(iy1);
|
| + const void* rowY0 = fAccessor.row(iy0);
|
| + const void* rowY1 = fAccessor.row(iy1);
|
| auto lerp = [&](Sk4f* pixelY0, Sk4f* pixelY1) {
|
| return *pixelY0 * filterY0 + *pixelY1 * filterY1;
|
| };
|
| @@ -734,17 +771,17 @@ private:
|
| int count = span.count();
|
| while (count >= 4) {
|
| Sk4f px00, px10, px20, px30;
|
| - fStrategy.get4Pixels(rowY0, ix, &px00, &px10, &px20, &px30);
|
| + fAccessor.get4Pixels(rowY0, ix, &px00, &px10, &px20, &px30);
|
| Sk4f px01, px11, px21, px31;
|
| - fStrategy.get4Pixels(rowY1, ix, &px01, &px11, &px21, &px31);
|
| + fAccessor.get4Pixels(rowY1, ix, &px01, &px11, &px21, &px31);
|
| fNext->blend4Pixels(
|
| lerp(&px00, &px01), lerp(&px10, &px11), lerp(&px20, &px21), lerp(&px30, &px31));
|
| ix += 4;
|
| count -= 4;
|
| }
|
| while (count > 0) {
|
| - Sk4f pixelY0 = fStrategy.getPixelFromRow(rowY0, ix);
|
| - Sk4f pixelY1 = fStrategy.getPixelFromRow(rowY1, ix);
|
| + Sk4f pixelY0 = fAccessor.getPixelFromRow(rowY0, ix);
|
| + Sk4f pixelY1 = fAccessor.getPixelFromRow(rowY1, ix);
|
|
|
| fNext->blendPixel(lerp(&pixelY0, &pixelY1));
|
| ix += 1;
|
| @@ -754,17 +791,17 @@ private:
|
| int count = span.count();
|
| while (count >= 4) {
|
| Sk4f px00, px10, px20, px30;
|
| - fStrategy.get4Pixels(rowY0, ix - 3, &px30, &px20, &px10, &px00);
|
| + fAccessor.get4Pixels(rowY0, ix - 3, &px30, &px20, &px10, &px00);
|
| Sk4f px01, px11, px21, px31;
|
| - fStrategy.get4Pixels(rowY1, ix - 3, &px31, &px21, &px11, &px01);
|
| + fAccessor.get4Pixels(rowY1, ix - 3, &px31, &px21, &px11, &px01);
|
| fNext->blend4Pixels(
|
| lerp(&px00, &px01), lerp(&px10, &px11), lerp(&px20, &px21), lerp(&px30, &px31));
|
| ix -= 4;
|
| count -= 4;
|
| }
|
| while (count > 0) {
|
| - Sk4f pixelY0 = fStrategy.getPixelFromRow(rowY0, ix);
|
| - Sk4f pixelY1 = fStrategy.getPixelFromRow(rowY1, ix);
|
| + Sk4f pixelY0 = fAccessor.getPixelFromRow(rowY0, ix);
|
| + Sk4f pixelY1 = fAccessor.getPixelFromRow(rowY1, ix);
|
|
|
| fNext->blendPixel(lerp(&pixelY0, &pixelY1));
|
| ix -= 1;
|
| @@ -801,8 +838,8 @@ private:
|
| }
|
| }
|
|
|
| - Next* const fNext;
|
| - PixelAccessor<colorType, gammaType> fStrategy;
|
| + Next* const fNext;
|
| + Accessor fAccessor;
|
| };
|
|
|
| } // namespace
|
|
|