Use Analytic AA in SkAAClip.
This will fix some Chrome ref tests.
The main issue here is that the SkAAClip requires: (1) we blit in order, and (2) we must forceRLE.
Note that this still depends on the global gSkUseAnalyticAA to turn on the Analytic AA.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2430343003
Review-Url: https://chromiumcodereview.appspot.com/2430343003
diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp
index 088ee55..c7e1ead 100644
--- a/src/core/SkAAClip.cpp
+++ b/src/core/SkAAClip.cpp
@@ -1037,8 +1037,10 @@
void addAntiRectRun(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha) {
- SkASSERT(fBounds.contains(x + width - 1 +
- (leftAlpha > 0 ? 1 : 0) + (rightAlpha > 0 ? 1 : 0),
+ // According to SkBlitter.cpp, no matter whether leftAlpha is 0 or positive,
+ // we should always consider [x, x+1] as the left-most column and [x+1, x+1+width]
+ // as the rect with full alpha.
+ SkASSERT(fBounds.contains(x + width + (rightAlpha > 0 ? 1 : 0),
y + height - 1));
SkASSERT(width >= 0);
@@ -1048,6 +1050,9 @@
width++;
} else if (leftAlpha > 0) {
this->addRun(x++, y, leftAlpha, 1);
+ } else {
+ // leftAlpha is 0, ignore the left column
+ x++;
}
if (rightAlpha == 0xFF) {
width++;
@@ -1274,9 +1279,17 @@
any failure cases that misses may have minor artifacts.
*/
void blitV(int x, int y, int height, SkAlpha alpha) override {
- this->recordMinY(y);
- fBuilder->addColumn(x, y, alpha, height);
- fLastY = y + height - 1;
+ if (height == 1) {
+ // We're still in scan-line order if height is 1
+ // This is useful for Analytic AA
+ const SkAlpha alphas[2] = {alpha, 0};
+ const int16_t runs[2] = {1, 0};
+ this->blitAntiH(x, y, alphas, runs);
+ } else {
+ this->recordMinY(y);
+ fBuilder->addColumn(x, y, alpha, height);
+ fLastY = y + height - 1;
+ }
}
void blitRect(int x, int y, int width, int height) override {
@@ -1398,7 +1411,11 @@
BuilderBlitter blitter(&builder);
if (doAA) {
- SkScan::AntiFillPath(path, *clip, &blitter, true);
+ if (gSkUseAnalyticAA.load()) {
+ SkScan::AAAFillPath(path, *clip, &blitter, true);
+ } else {
+ SkScan::AntiFillPath(path, *clip, &blitter, true);
+ }
} else {
SkScan::FillPath(path, *clip, &blitter);
}