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

Side by Side Diff: src/core/SkAAClip.cpp

Issue 2430343003: Use Analytic AA in SkAAClip (Closed)
Patch Set: Nit 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkAnalyticEdge.h » ('j') | src/core/SkAnalyticEdge.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkAAClip.h" 8 #include "SkAAClip.h"
9 #include "SkAtomics.h" 9 #include "SkAtomics.h"
10 #include "SkBlitter.h" 10 #include "SkBlitter.h"
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 // so we ensure our row goes all the way to our right 1030 // so we ensure our row goes all the way to our right
1031 this->flushRowH(fCurrRow); 1031 this->flushRowH(fCurrRow);
1032 1032
1033 y -= fBounds.fTop; 1033 y -= fBounds.fTop;
1034 SkASSERT(y == fCurrRow->fY); 1034 SkASSERT(y == fCurrRow->fY);
1035 fCurrRow->fY = y + height - 1; 1035 fCurrRow->fY = y + height - 1;
1036 } 1036 }
1037 1037
1038 void addAntiRectRun(int x, int y, int width, int height, 1038 void addAntiRectRun(int x, int y, int width, int height,
1039 SkAlpha leftAlpha, SkAlpha rightAlpha) { 1039 SkAlpha leftAlpha, SkAlpha rightAlpha) {
1040 // According to SkBlitter.cpp, no matter whether leftAlpha is 0 or posit ive,
1041 // we should always consider [x, x+1] as the left-most column and [x+1, x+1+width]
1042 // as the rect with full alpha.
1040 SkASSERT(fBounds.contains(x + width - 1 + 1043 SkASSERT(fBounds.contains(x + width - 1 +
1041 (leftAlpha > 0 ? 1 : 0) + (rightAlpha > 0 ? 1 : 0), 1044 1 + (rightAlpha > 0 ? 1 : 0),
caryclark 2016/10/20 16:58:14 could this be SkASSERT(fBounds.contains(x + width
liyuqian 2016/10/20 17:19:50 Sure, done. I was just preserving the old format f
1042 y + height - 1)); 1045 y + height - 1));
1043 SkASSERT(width >= 0); 1046 SkASSERT(width >= 0);
1044 1047
1045 // Conceptually we're always adding 3 runs, but we should 1048 // Conceptually we're always adding 3 runs, but we should
1046 // merge or omit them if possible. 1049 // merge or omit them if possible.
1047 if (leftAlpha == 0xFF) { 1050 if (leftAlpha == 0xFF) {
1048 width++; 1051 width++;
1049 } else if (leftAlpha > 0) { 1052 } else if (leftAlpha > 0) {
1050 this->addRun(x++, y, leftAlpha, 1); 1053 this->addRun(x++, y, leftAlpha, 1);
1054 } else {
1055 // leftAlpha is 0, ignore the left column
1056 x++;
1051 } 1057 }
1052 if (rightAlpha == 0xFF) { 1058 if (rightAlpha == 0xFF) {
1053 width++; 1059 width++;
1054 } 1060 }
1055 if (width > 0) { 1061 if (width > 0) {
1056 this->addRun(x, y, 0xFF, width); 1062 this->addRun(x, y, 0xFF, width);
1057 } 1063 }
1058 if (rightAlpha > 0 && rightAlpha < 255) { 1064 if (rightAlpha > 0 && rightAlpha < 255) {
1059 this->addRun(x + width, y, rightAlpha, 1); 1065 this->addRun(x + width, y, rightAlpha, 1);
1060 } 1066 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 } 1273 }
1268 1274
1269 /** 1275 /**
1270 Must evaluate clips in scan-line order, so don't want to allow blitV(), 1276 Must evaluate clips in scan-line order, so don't want to allow blitV(),
1271 but an AAClip can be clipped down to a single pixel wide, so we 1277 but an AAClip can be clipped down to a single pixel wide, so we
1272 must support it (given AntiRect semantics: minimum width is 2). 1278 must support it (given AntiRect semantics: minimum width is 2).
1273 Instead we'll rely on the runtime asserts to guarantee Y monotonicity; 1279 Instead we'll rely on the runtime asserts to guarantee Y monotonicity;
1274 any failure cases that misses may have minor artifacts. 1280 any failure cases that misses may have minor artifacts.
1275 */ 1281 */
1276 void blitV(int x, int y, int height, SkAlpha alpha) override { 1282 void blitV(int x, int y, int height, SkAlpha alpha) override {
1277 this->recordMinY(y); 1283 if (height == 1) {
1278 fBuilder->addColumn(x, y, alpha, height); 1284 // We're still in scan-line order if height is 1
1279 fLastY = y + height - 1; 1285 // This is useful for Analytic AA
1286 const SkAlpha alphas[2] = {alpha, 0};
1287 const int16_t runs[2] = {1, 0};
1288 this->blitAntiH(x, y, alphas, runs);
1289 } else {
1290 this->recordMinY(y);
1291 fBuilder->addColumn(x, y, alpha, height);
1292 fLastY = y + height - 1;
1293 }
1280 } 1294 }
1281 1295
1282 void blitRect(int x, int y, int width, int height) override { 1296 void blitRect(int x, int y, int width, int height) override {
1283 this->recordMinY(y); 1297 this->recordMinY(y);
1284 this->checkForYGap(y); 1298 this->checkForYGap(y);
1285 fBuilder->addRectRun(x, y, width, height); 1299 fBuilder->addRectRun(x, y, width, height);
1286 fLastY = y + height - 1; 1300 fLastY = y + height - 1;
1287 } 1301 }
1288 1302
1289 virtual void blitAntiRect(int x, int y, int width, int height, 1303 virtual void blitAntiRect(int x, int y, int width, int height,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 } else { 1405 } else {
1392 if (ibounds.isEmpty() || !ibounds.intersect(clip->getBounds())) { 1406 if (ibounds.isEmpty() || !ibounds.intersect(clip->getBounds())) {
1393 return this->setEmpty(); 1407 return this->setEmpty();
1394 } 1408 }
1395 } 1409 }
1396 1410
1397 Builder builder(ibounds); 1411 Builder builder(ibounds);
1398 BuilderBlitter blitter(&builder); 1412 BuilderBlitter blitter(&builder);
1399 1413
1400 if (doAA) { 1414 if (doAA) {
1401 SkScan::AntiFillPath(path, *clip, &blitter, true); 1415 if (gSkUseAnalyticAA.load()) {
1416 SkScan::AAAFillPath(path, *clip, &blitter, true);
1417 } else {
1418 SkScan::AntiFillPath(path, *clip, &blitter, true);
1419 }
1402 } else { 1420 } else {
1403 SkScan::FillPath(path, *clip, &blitter); 1421 SkScan::FillPath(path, *clip, &blitter);
1404 } 1422 }
1405 1423
1406 blitter.finish(); 1424 blitter.finish();
1407 return builder.finish(this); 1425 return builder.finish(this);
1408 } 1426 }
1409 1427
1410 /////////////////////////////////////////////////////////////////////////////// 1428 ///////////////////////////////////////////////////////////////////////////////
1411 1429
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 rowMask.fBounds.fBottom = y + 1; 2229 rowMask.fBounds.fBottom = y + 1;
2212 fBlitter->blitMask(rowMask, rowMask.fBounds); 2230 fBlitter->blitMask(rowMask, rowMask.fBounds);
2213 src = (const void*)((const char*)src + srcRB); 2231 src = (const void*)((const char*)src + srcRB);
2214 } while (++y < localStopY); 2232 } while (++y < localStopY);
2215 } while (y < stopY); 2233 } while (y < stopY);
2216 } 2234 }
2217 2235
2218 const SkPixmap* SkAAClipBlitter::justAnOpaqueColor(uint32_t* value) { 2236 const SkPixmap* SkAAClipBlitter::justAnOpaqueColor(uint32_t* value) {
2219 return nullptr; 2237 return nullptr;
2220 } 2238 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkAnalyticEdge.h » ('j') | src/core/SkAnalyticEdge.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698