Fix the sum of alpha = 254 instead of 255 by rounding
This patch is a subpatch from https://codereview.chromium.org/2471133002/ I created this CL mainly for Florin to land before he rebaseline the Chrome layout tests. (Landing the whole patch of 2471133002 would be nice but most people already left for the weekend so I'd rather not take the risk to break the Skia during the weekend.) BUG=skia: TBR=reed@google.com, mtklein@google.com, fmalita@chromium.org GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2483523002 Review-Url: https://codereview.chromium.org/2483523002
This commit is contained in:
parent
2478c73bb8
commit
525e13c1d3
@ -21,6 +21,11 @@ public:
|
||||
int16_t* fRuns;
|
||||
uint8_t* fAlpha;
|
||||
|
||||
// Return 0-255 given 0-256
|
||||
static inline SkAlpha CatchOverflow(int alpha) {
|
||||
return alpha - (alpha >> 8);
|
||||
}
|
||||
|
||||
/// Returns true if the scanline contains only a single run,
|
||||
/// of alpha value 0.
|
||||
bool empty() const {
|
||||
@ -79,7 +84,7 @@ public:
|
||||
runs += x;
|
||||
x = 0;
|
||||
do {
|
||||
alpha[0] = SkToU8(alpha[0] + maxValue);
|
||||
alpha[0] = SkToU8(CatchOverflow(alpha[0] + maxValue));
|
||||
int n = runs[0];
|
||||
SkASSERT(n <= middleCount);
|
||||
alpha += n;
|
||||
|
@ -83,9 +83,9 @@ number of scan lines in our algorithm is only about 3 + H while the
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void addAlpha(SkAlpha& alpha, SkAlpha delta) {
|
||||
SkASSERT(alpha + (int)delta <= 0xFF);
|
||||
alpha += delta;
|
||||
static inline void addAlpha(SkAlpha& alpha, SkAlpha delta) {
|
||||
SkASSERT(alpha + (int)delta <= 256);
|
||||
alpha = SkAlphaRuns::CatchOverflow(alpha + (int)delta);
|
||||
}
|
||||
|
||||
class AdditiveBlitter : public SkBlitter {
|
||||
@ -481,7 +481,7 @@ static inline SkAlpha partialTriangleToAlpha(SkFixed a, SkFixed b) {
|
||||
}
|
||||
|
||||
static inline SkAlpha getPartialAlpha(SkAlpha alpha, SkFixed partialHeight) {
|
||||
return (alpha * partialHeight) >> 16;
|
||||
return (alpha * partialHeight + SK_FixedHalf) >> 16;
|
||||
}
|
||||
|
||||
static inline SkAlpha getPartialAlpha(SkAlpha alpha, SkAlpha fullAlpha) {
|
||||
|
Loading…
Reference in New Issue
Block a user