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

Unified Diff: src/core/SkAAClip.cpp

Issue 2430343003: Use Analytic AA in SkAAClip (Closed)
Patch Set: Nit fixes Created 4 years, 2 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 | src/core/SkAnalyticEdge.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkAAClip.cpp
diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp
index 088ee55844473aab14fecb4fb4286f457f5ed331..c7e1ead9098f2df92d43a751947544e2ea128019 100644
--- a/src/core/SkAAClip.cpp
+++ b/src/core/SkAAClip.cpp
@@ -1037,8 +1037,10 @@ public:
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 @@ public:
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 @@ public:
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 @@ bool SkAAClip::setPath(const SkPath& path, const SkRegion* clip, bool doAA) {
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);
}
« no previous file with comments | « no previous file | src/core/SkAnalyticEdge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698