Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: src/core/SkLinearBitmapPipeline.cpp

Issue 1719333002: tile spans (Closed) Base URL: https://skia.googlesource.com/skia.git@code-organization-speed
Patch Set: Address comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLinearBitmapPipeline.cpp
diff --git a/src/core/SkLinearBitmapPipeline.cpp b/src/core/SkLinearBitmapPipeline.cpp
index 02a4bd39f3df869a5d6a75284da472bb636646e2..dda00c560d067ce461ec1a980fda4f2fc476a4b8 100644
--- a/src/core/SkLinearBitmapPipeline.cpp
+++ b/src/core/SkLinearBitmapPipeline.cpp
@@ -15,7 +15,7 @@
#include "SkSize.h"
// Tweak ABI of functions that pass Sk4f by value to pass them via registers.
-#if defined(_MSC_VER) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
+ #if defined(_MSC_VER) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
mtklein 2016/02/23 23:49:57 Seems like it's all the other lines that are wrong
herb_g 2016/02/24 18:16:06 Done.
#define VECTORCALL __vectorcall
#elif defined(SK_CPU_ARM32) && defined(SK_ARM_HAS_NEON)
#define VECTORCALL __attribute__((pcs("aapcs-vfp")))
@@ -26,8 +26,8 @@
class SkLinearBitmapPipeline::PointProcessorInterface {
public:
virtual ~PointProcessorInterface() { }
- virtual void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) = 0;
- virtual void VECTORCALL pointList4(Sk4f xs, Sk4f ys) = 0;
+ virtual void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) = 0;
+ virtual void VECTORCALL pointList4(Sk4s xs, Sk4s ys) = 0;
// The pointSpan method efficiently process horizontal spans of pixels.
// * start - the point where to start the span.
@@ -58,7 +58,7 @@ public:
// +--------+--------+
// These pixels coordinates are arranged in the following order in xs and ys:
// px00 px10 px01 px11
- virtual void VECTORCALL bilerpList(Sk4f xs, Sk4f ys) = 0;
+ virtual void VECTORCALL bilerpList(Sk4s xs, Sk4s ys) = 0;
};
class SkLinearBitmapPipeline::PixelPlacerInterface {
@@ -76,7 +76,7 @@ struct X {
explicit X(SkPoint pt) : fVal{pt.fX} { }
explicit X(SkSize s) : fVal{s.fWidth} { }
explicit X(SkISize s) : fVal(s.fWidth) { }
- operator float () const {return fVal;}
+ operator SkScalar () const {return fVal;}
private:
float fVal;
mtklein 2016/02/23 23:49:57 SkScalar
herb_g 2016/02/24 18:16:06 Done.
};
@@ -86,20 +86,20 @@ struct Y {
explicit Y(SkPoint pt) : fVal{pt.fY} { }
explicit Y(SkSize s) : fVal{s.fHeight} { }
explicit Y(SkISize s) : fVal(s.fHeight) { }
- operator float () const {return fVal;}
+ operator SkScalar () const {return fVal;}
private:
float fVal;
};
template <typename Stage>
void span_fallback(SkPoint start, SkScalar length, int count, Stage* stage) {
- // If count == 1 use PointListFew instead.
- SkASSERT(count > 1);
-
float dx = length / (count - 1);
mtklein 2016/02/23 23:49:57 Let's do a careful search for all 'float' in here.
herb_g 2016/02/24 18:16:06 Done.
- Sk4f Xs = Sk4f(X(start)) + Sk4f{0.0f, 1.0f, 2.0f, 3.0f} * Sk4f{dx};
- Sk4f Ys{Y(start)};
- Sk4f fourDx = {4.0f * dx};
+ // Xs must be calculated in the following manner instead of dx * {0.0, 1.0, 2.0, 3.0} because
mtklein 2016/02/23 23:49:57 Seems fine to branch on count too, if that makes t
herb_g 2016/02/24 18:16:06 Done.
+ // dx may be nan (in the case where length and count - 1 are zero). The following produces a
+ // 0.0f in lane 0 which is required for handling the length = 0 and count = 1 case.
+ Sk4s Xs = Sk4s(X(start)) + Sk4s{0.0f, dx, 2.0f * dx, 3.0f * dx};
+ Sk4s Ys{Y(start)};
+ Sk4s fourDx = {4.0f * dx};
while (count >= 4) {
stage->pointList4(Xs, Ys);
@@ -132,12 +132,12 @@ public:
: fNext{next}
, fStrategy{std::forward<Args>(args)...}{ }
- void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override {
+ void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override {
fStrategy.processPoints(&xs, &ys);
fNext->pointListFew(n, xs, ys);
}
- void VECTORCALL pointList4(Sk4f xs, Sk4f ys) override {
+ void VECTORCALL pointList4(Sk4s xs, Sk4s ys) override {
fStrategy.processPoints(&xs, &ys);
fNext->pointList4(xs, ys);
}
@@ -162,17 +162,17 @@ public:
: fNext{next}
, fStrategy{std::forward<Args>(args)...}{ }
- void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override {
+ void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override {
fStrategy.processPoints(&xs, &ys);
fNext->pointListFew(n, xs, ys);
}
- void VECTORCALL pointList4(Sk4f xs, Sk4f ys) override {
+ void VECTORCALL pointList4(Sk4s xs, Sk4s ys) override {
fStrategy.processPoints(&xs, &ys);
fNext->pointList4(xs, ys);
}
- void VECTORCALL bilerpList(Sk4f xs, Sk4f ys) override {
+ void VECTORCALL bilerpList(Sk4s xs, Sk4s ys) override {
fStrategy.processPoints(&xs, &ys);
fNext->bilerpList(xs, ys);
}
@@ -189,13 +189,13 @@ private:
};
class SkippedStage final : public SkLinearBitmapPipeline::BilerpProcessorInterface {
- void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override {
+ void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override {
SkFAIL("Skipped stage.");
}
- void VECTORCALL pointList4(Sk4f xs, Sk4f ys) override {
+ void VECTORCALL pointList4(Sk4s xs, Sk4s ys) override {
SkFAIL("Skipped stage.");
}
- void VECTORCALL bilerpList(Sk4f xs, Sk4f ys) override {
+ void VECTORCALL bilerpList(Sk4s xs, Sk4s ys) override {
SkFAIL("Skipped stage.");
}
void pointSpan(SkPoint start, SkScalar length, int count) override {
@@ -209,7 +209,7 @@ public:
: fXOffset{X(offset)}
, fYOffset{Y(offset)} { }
- void processPoints(Sk4f* xs, Sk4f* ys) {
+ void processPoints(Sk4s* xs, Sk4s* ys) {
*xs = *xs + fXOffset;
*ys = *ys + fYOffset;
}
@@ -221,7 +221,7 @@ public:
}
private:
- const Sk4f fXOffset, fYOffset;
+ const Sk4s fXOffset, fYOffset;
};
template <typename Next = SkLinearBitmapPipeline::PointProcessorInterface>
using TranslateMatrix = PointProcessor<TranslateMatrixStrategy, Next>;
@@ -231,7 +231,7 @@ public:
ScaleMatrixStrategy(SkVector offset, SkVector scale)
: fXOffset{X(offset)}, fYOffset{Y(offset)}
, fXScale{X(scale)}, fYScale{Y(scale)} { }
- void processPoints(Sk4f* xs, Sk4f* ys) {
+ void processPoints(Sk4s* xs, Sk4s* ys) {
*xs = *xs * fXScale + fXOffset;
*ys = *ys * fYScale + fYOffset;
}
@@ -246,8 +246,8 @@ public:
}
private:
- const Sk4f fXOffset, fYOffset;
- const Sk4f fXScale, fYScale;
+ const Sk4s fXOffset, fYOffset;
+ const Sk4s fXScale, fYScale;
};
template <typename Next = SkLinearBitmapPipeline::PointProcessorInterface>
using ScaleMatrix = PointProcessor<ScaleMatrixStrategy, Next>;
@@ -258,9 +258,9 @@ public:
: fXOffset{X(offset)}, fYOffset{Y(offset)}
, fXScale{X(scale)}, fYScale{Y(scale)}
, fXSkew{X(skew)}, fYSkew{Y(skew)} { }
- void processPoints(Sk4f* xs, Sk4f* ys) {
- Sk4f newXs = fXScale * *xs + fXSkew * *ys + fXOffset;
- Sk4f newYs = fYSkew * *xs + fYScale * *ys + fYOffset;
+ void processPoints(Sk4s* xs, Sk4s* ys) {
+ Sk4s newXs = fXScale * *xs + fXSkew * *ys + fXOffset;
+ Sk4s newYs = fYSkew * *xs + fYScale * *ys + fYOffset;
*xs = newXs;
*ys = newYs;
@@ -272,9 +272,9 @@ public:
}
private:
- const Sk4f fXOffset, fYOffset;
- const Sk4f fXScale, fYScale;
- const Sk4f fXSkew, fYSkew;
+ const Sk4s fXOffset, fYOffset;
+ const Sk4s fXScale, fYScale;
+ const Sk4s fXSkew, fYSkew;
};
template <typename Next = SkLinearBitmapPipeline::PointProcessorInterface>
using AffineMatrix = PointProcessor<AffineMatrixStrategy, Next>;
@@ -312,24 +312,24 @@ class ExpandBilerp final : public SkLinearBitmapPipeline::PointProcessorInterfac
public:
ExpandBilerp(Next* next) : fNext{next} { }
- void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override {
+ void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override {
SkASSERT(0 < n && n < 4);
// px00 px10 px01 px11
- const Sk4f kXOffsets{-0.5f, 0.5f, -0.5f, 0.5f},
+ const Sk4s kXOffsets{-0.5f, 0.5f, -0.5f, 0.5f},
kYOffsets{-0.5f, -0.5f, 0.5f, 0.5f};
- if (n >= 1) fNext->bilerpList(Sk4f{xs[0]} + kXOffsets, Sk4f{ys[0]} + kYOffsets);
- if (n >= 2) fNext->bilerpList(Sk4f{xs[1]} + kXOffsets, Sk4f{ys[1]} + kYOffsets);
- if (n >= 3) fNext->bilerpList(Sk4f{xs[2]} + kXOffsets, Sk4f{ys[2]} + kYOffsets);
+ if (n >= 1) fNext->bilerpList(Sk4s{xs[0]} + kXOffsets, Sk4s{ys[0]} + kYOffsets);
+ if (n >= 2) fNext->bilerpList(Sk4s{xs[1]} + kXOffsets, Sk4s{ys[1]} + kYOffsets);
+ if (n >= 3) fNext->bilerpList(Sk4s{xs[2]} + kXOffsets, Sk4s{ys[2]} + kYOffsets);
}
void VECTORCALL pointList4(Sk4f xs, Sk4f ys) override {
// px00 px10 px01 px11
const Sk4f kXOffsets{-0.5f, 0.5f, -0.5f, 0.5f},
kYOffsets{-0.5f, -0.5f, 0.5f, 0.5f};
- fNext->bilerpList(Sk4f{xs[0]} + kXOffsets, Sk4f{ys[0]} + kYOffsets);
- fNext->bilerpList(Sk4f{xs[1]} + kXOffsets, Sk4f{ys[1]} + kYOffsets);
- fNext->bilerpList(Sk4f{xs[2]} + kXOffsets, Sk4f{ys[2]} + kYOffsets);
- fNext->bilerpList(Sk4f{xs[3]} + kXOffsets, Sk4f{ys[3]} + kYOffsets);
+ fNext->bilerpList(Sk4s{xs[0]} + kXOffsets, Sk4s{ys[0]} + kYOffsets);
+ fNext->bilerpList(Sk4s{xs[1]} + kXOffsets, Sk4s{ys[1]} + kYOffsets);
+ fNext->bilerpList(Sk4s{xs[2]} + kXOffsets, Sk4s{ys[2]} + kYOffsets);
+ fNext->bilerpList(Sk4s{xs[3]} + kXOffsets, Sk4s{ys[3]} + kYOffsets);
}
void pointSpan(SkPoint start, SkScalar length, int count) override {
@@ -367,25 +367,105 @@ public:
, fXMax{X(max) - 1.0f}
, fYMax{Y(max) - 1.0f} { }
- void processPoints(Sk4f* xs, Sk4f* ys) {
- *xs = Sk4f::Min(Sk4f::Max(*xs, fXMin), fXMax);
- *ys = Sk4f::Min(Sk4f::Max(*ys, fYMin), fYMax);
+ void processPoints(Sk4s* xs, Sk4s* ys) {
+ *xs = Sk4s::Min(Sk4s::Max(*xs, fXMin), fXMax);
+ *ys = Sk4s::Min(Sk4s::Max(*ys, fYMin), fYMax);
}
template <typename Next>
bool maybeProcessSpan(SkPoint start, SkScalar length, int count, Next* next) {
- return false;
+ SkScalar xMin = fXMin[0];
+ SkScalar xMax = fXMax[0];
+ SkScalar yMin = fYMin[0];
+ SkScalar yMax = fYMax[0];
+ SkScalar x = X(start);
+ SkScalar y = std::min(std::max<float>(yMin, Y(start)), yMax);
+
+ bool under = x < xMin;
+
+ if (!under && x + length < xMax) {
+ next->pointSpan(start, length, count);
+ return true;
+ }
+
+ SkScalar dx = length / (count - 1);
+
+ // A B C
+ // +-------+-------+-------++-------+-------+-------+ +-------+-------++------
+ // | *---*|---*---|*---*--||-*---*-|---*---|*---...| |--*---*|---*---||*---*....
+ // | | | || | | | ... | | ||
+ // | | | || | | | | | ||
+ // +-------+-------+-------++-------+-------+-------+ +-------+-------++------
+ // ^ ^
+ // | xMin xMax-1 | xMax
+ //
+ // *---*---*---... - track of samples. * = sample
+ //
+ // +-+ ||
+ // | | - pixels in source space. || - tile border.
+ // +-+ ||
+ //
+ // The length from A to B is the length in source space or 4 * dx ((count - 1) * dx)
mtklein 2016/02/23 23:49:57 4 * dx ((count - 1) * dx) reads like one expressio
herb_g 2016/02/24 18:16:06 Done.
+ // where dx is the distance between samples. There are 5 pixels specified in the A, B
mtklein 2016/02/23 23:49:57 There are 5 destination pixels ... ? Or 5 samples
herb_g 2016/02/24 18:16:06 Add explanation.
+ // span. The distance from A to the next span starting at C is 5 * dx, so count * dx.
+ // Overall Strategy:
+ // * Under - for portions of the span < xMin, take the color at pixel {xMin, y} and use it
+ // to fill in the 5 pixel sampled from A to B.
+ // * Middle - for the portion of the span between xMin and xMax sample normally.
+ // * Over - for the portion of the span > xMax, take the color at pixel {xMax-1, y} and
+ // use it to fill in the rest of the destination pixels.
+ if (under) {
+ // It could be that the entire span is off the left edge of the tile.
+ SkScalar EdgeOrXEnd = std::min(xMin, x + length + 1.0f);
+ int underCount = SkScalarFloorToInt((EdgeOrXEnd - x) / dx) + 1;
+ if (underCount > 0) {
+ // Use the pixel on the edge of the bitmap as the color for the entire span.
+ // Using a length of 0 causes x not to move in the sampler resulting in the same
+ // pixel being used for the entire span.
+ next->pointSpan({xMin, y}, 0.0f, underCount);
+
+ // The length is not the distance to xMin, but to the next starting sample.
+ SkScalar lengthToNextStart = dx * underCount;
+ count -= underCount;
+ length -= lengthToNextStart;
+ x += lengthToNextStart;
+ }
+ }
+
+ // If there are more pixels needed, sample from the middle of the tile.
+ if (count > 0) {
+ // It could be that span continues off the edge of tile; use min for the limit.
+ SkScalar EdgeOrXEnd = std::min(xMax, x + length);
+ int middleCount = SkScalarFloorToInt((EdgeOrXEnd - x) / dx) + 1;
+ SkScalar middleLength = (middleCount - 1) * dx;
+ next->pointSpan({x, y}, middleLength, middleCount);
+ count -= middleCount;
+ }
+
+ if (count > 0) {
+ // Use the pixel on the edge of the bitmap as the color for the entire span.
+ // Using a length of 0 causes x not to move in the sampler resulting in the same
+ // pixel being used for the entire span.
+ next->pointSpan({xMax - 1.0f, y}, 0.0f, count);
+ }
+
+ return true;
}
private:
- const Sk4f fXMin{SK_FloatNegativeInfinity};
- const Sk4f fYMin{SK_FloatNegativeInfinity};
- const Sk4f fXMax{SK_FloatInfinity};
- const Sk4f fYMax{SK_FloatInfinity};
+ const Sk4s fXMin{SK_FloatNegativeInfinity};
+ const Sk4s fYMin{SK_FloatNegativeInfinity};
+ const Sk4s fXMax{SK_FloatInfinity};
+ const Sk4s fYMax{SK_FloatInfinity};
};
template <typename Next = SkLinearBitmapPipeline::BilerpProcessorInterface>
using Clamp = BilerpProcessor<ClampStrategy, Next>;
+// It would be nice to use fmod, but it uses trunc based rounding where floor rounding is needed.
+static SkScalar tile_mod(SkScalar x, SkScalar base) {
+ return x - std::floor(x / base) * base;
+}
+
class RepeatStrategy {
public:
RepeatStrategy(X max) : fXMax{max}, fXInvMax{1.0f/max} { }
@@ -396,25 +476,79 @@ public:
, fYMax{Y(max)}
, fYInvMax{1.0f / Y(max)} { }
- void processPoints(Sk4f* xs, Sk4f* ys) {
- Sk4f divX = (*xs * fXInvMax).floor();
- Sk4f divY = (*ys * fYInvMax).floor();
- Sk4f baseX = (divX * fXMax);
- Sk4f baseY = (divY * fYMax);
+ void processPoints(Sk4s* xs, Sk4s* ys) {
+ Sk4s divX = (*xs * fXInvMax).floor();
+ Sk4s divY = (*ys * fYInvMax).floor();
+ Sk4s baseX = (divX * fXMax);
+ Sk4s baseY = (divY * fYMax);
*xs = *xs - baseX;
*ys = *ys - baseY;
}
template <typename Next>
bool maybeProcessSpan(SkPoint start, SkScalar length, int count, Next* next) {
- return false;
+ // Make x and y in range on the tile.
+ SkScalar x = tile_mod(X(start), fXMax[0]);
+ SkScalar y = tile_mod(Y(start), fYMax[0]);
+ SkScalar xMax = fXMax[0];
+ SkScalar dx = length / (count - 1);
+
+ // A B C D Z
+ // +-------+-------+-------++-------+-------+-------++ +-------+-------++------
+ // | | *---|*---*--||-*---*-|---*---|*---*--|| |--*---*| ||
+ // | | | || | | || ... | | ||
+ // | | | || | | || | | ||
+ // +-------+-------+-------++-------+-------+-------++ +-------+-------++------
+ // ^^ ^^ ^^
+ // xMax || xMin xMax || xMin xMax || xMin
+ //
+ // *---*---*---... - track of samples. * = sample
+ //
+ // +-+ ||
+ // | | - pixels in source space. || - tile border.
+ // +-+ ||
+ //
+ //
+ // The given span starts at A and continues on through several tiles to sample point Z.
+ // The idea is to break this into several spans one on each tile the entire span
+ // intersects. The A to B span only covers a partial tile and has a count of 3 and the
+ // distance from A to B is (count - 1) * dx or 2 * dx. The distance from A to the start of
+ // the next span is count * dx or 3 * dx. Span C to D covers an entire tile has a count
+ // of 5 and a length of 4 * dx.
+ //
+ // Overall Strategy:
+ // While the span hangs over the edge of the tile. Draw the span covering the tile then
mtklein 2016/02/23 23:49:57 While the span hangs over the edge of the tile. ?
herb_g 2016/02/24 18:16:06 Fixed sentence fragment.
+ // slide the span over to the next tile.
+
+ // The guard could have been count > 0, but then a bunch of math would be done in the
+ // common case.
+ while (x + length > xMax) {
+ // The number of samples that intersect this tile.
+ int countForTile = SkScalarFloorToInt((xMax - x) / dx) + 1;
+ // The distance between the first and last sample.
+ SkScalar lengthForSpanOnTile = (countForTile - 1) * dx;
+ // Span the samples.
+ next->pointSpan({x, y}, lengthForSpanOnTile, countForTile);
+ // Add one more dx to get to the first sample on the next tile.
+ SkScalar lengthToNextStart = lengthForSpanOnTile + dx;
+ // slide over to the next tile.
+ length -= lengthToNextStart;
+ count -= countForTile;
+ x += lengthToNextStart - xMax;
+ }
+ // All on a single tile.
+ if (count > 0) {
+ next->pointSpan({x, y}, length, count);
+ }
+
+ return true;
}
private:
- const Sk4f fXMax{0.0f};
- const Sk4f fXInvMax{0.0f};
- const Sk4f fYMax{0.0f};
- const Sk4f fYInvMax{0.0f};
+ const Sk4s fXMax{0.0f};
+ const Sk4s fXInvMax{0.0f};
+ const Sk4s fYMax{0.0f};
+ const Sk4s fYInvMax{0.0f};
};
template <typename Next = SkLinearBitmapPipeline::BilerpProcessorInterface>
@@ -469,9 +603,9 @@ static SkLinearBitmapPipeline::BilerpProcessorInterface* choose_tiler(
class sRGBFast {
public:
- static Sk4f VECTORCALL sRGBToLinear(Sk4f pixel) {
- Sk4f l = pixel * pixel;
- return Sk4f{l[0], l[1], l[2], pixel[3]};
+ static Sk4s VECTORCALL sRGBToLinear(Sk4s pixel) {
+ Sk4s l = pixel * pixel;
+ return Sk4s{l[0], l[1], l[2], pixel[3]};
}
};
@@ -481,7 +615,7 @@ public:
Passthrough8888(int width, const uint32_t* src)
: fSrc{src}, fWidth{width}{ }
- void VECTORCALL getFewPixels(int n, Sk4f xs, Sk4f ys, Sk4f* px0, Sk4f* px1, Sk4f* px2) {
+ void VECTORCALL getFewPixels(int n, Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2) {
Sk4i XIs = SkNx_cast<int, float>(xs);
Sk4i YIs = SkNx_cast<int, float>(ys);
Sk4i bufferLoc = YIs * fWidth + XIs;
@@ -497,7 +631,7 @@ public:
}
}
- void VECTORCALL get4Pixels(Sk4f xs, Sk4f ys, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) {
+ void VECTORCALL get4Pixels(Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2, Sk4f* px3) {
Sk4i XIs = SkNx_cast<int, float>(xs);
Sk4i YIs = SkNx_cast<int, float>(ys);
Sk4i bufferLoc = YIs * fWidth + XIs;
@@ -543,12 +677,12 @@ private:
// * px01 -> (1 - x)y = y - xy
// * px11 -> xy
// So x * y is calculated first and then used to calculate all the other factors.
-static Sk4f VECTORCALL bilerp4(Sk4f xs, Sk4f ys, Sk4f px00, Sk4f px10,
+static Sk4s VECTORCALL bilerp4(Sk4s xs, Sk4s ys, Sk4f px00, Sk4f px10,
Sk4f px01, Sk4f px11) {
// Calculate fractional xs and ys.
- Sk4f fxs = xs - xs.floor();
- Sk4f fys = ys - ys.floor();
- Sk4f fxys{fxs * fys};
+ Sk4s fxs = xs - xs.floor();
+ Sk4s fys = ys - ys.floor();
+ Sk4s fxys{fxs * fys};
Sk4f sum = px11 * fxys;
sum = sum + px01 * (fys - fxys);
sum = sum + px10 * (fxs - fxys);
@@ -564,7 +698,7 @@ public:
: fNext{next}
, fStrategy{std::forward<Args>(args)...} { }
- void VECTORCALL pointListFew(int n, Sk4f xs, Sk4f ys) override {
+ void 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);
@@ -573,13 +707,13 @@ public:
if (n >= 3) fNext->placePixel(px2);
}
- void VECTORCALL pointList4(Sk4f xs, Sk4f ys) override {
+ void VECTORCALL pointList4(Sk4s xs, Sk4s ys) override {
Sk4f px0, px1, px2, px3;
fStrategy.get4Pixels(xs, ys, &px0, &px1, &px2, &px3);
fNext->place4Pixels(px0, px1, px2, px3);
}
- void VECTORCALL bilerpList(Sk4f xs, Sk4f ys) override {
+ void VECTORCALL bilerpList(Sk4s xs, Sk4s ys) override {
Sk4f px00, px10, px01, px11;
fStrategy.get4Pixels(xs, ys, &px00, &px10, &px01, &px11);
Sk4f pixel = bilerp4(xs, ys, px00, px10, px01, px11);
@@ -697,14 +831,9 @@ SkLinearBitmapPipeline::SkLinearBitmapPipeline(
void SkLinearBitmapPipeline::shadeSpan4f(int x, int y, SkPM4f* dst, int count) {
SkASSERT(count > 0);
fPixelStage->setDestination(dst);
- // Adjust points by 0.5, 0.5 to sample from the center of the pixels.
- if (count == 1) {
- fFirstStage->pointListFew(1, Sk4f{x + 0.5f}, Sk4f{y + 0.5f});
- } else {
- // The count and length arguments start out in a precise relation in order to keep the
- // math correct through the different stages. Count is the number of pixel to produce.
- // Since the code samples at pixel centers, length is the distance from the center of the
- // first pixel to the center of the last pixel. This implies that length is count-1.
- fFirstStage->pointSpan(SkPoint{x + 0.5f, y + 0.5f}, count - 1, count);
- }
+ // The count and length arguments start out in a precise relation in order to keep the
+ // math correct through the different stages. Count is the number of pixel to produce.
+ // Since the code samples at pixel centers, length is the distance from the center of the
+ // first pixel to the center of the last pixel. This implies that length is count-1.
+ fFirstStage->pointSpan(SkPoint{x + 0.5f, y + 0.5f}, count - 1, count);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698