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

Unified Diff: src/core/SkAntiRun.h

Issue 2483523002: Fix the issue of alpha = 254 instead of 255 (Closed)
Patch Set: Rounding Created 4 years, 1 month 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 | src/core/SkScan_AAAPath.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkAntiRun.h
diff --git a/src/core/SkAntiRun.h b/src/core/SkAntiRun.h
index 8214e28d5b7ee8d8575c082d31b77e9f49388d5a..5ac0e62a6ce99129f356c43709b14c45c5fb2712 100644
--- a/src/core/SkAntiRun.h
+++ b/src/core/SkAntiRun.h
@@ -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;
« no previous file with comments | « no previous file | src/core/SkScan_AAAPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698