OLD | NEW |
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 Loading... |
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 SkASSERT(fBounds.contains(x + width - 1 + | 1040 // According to SkBlitter.cpp, no matter whether leftAlpha is 0 or posit
ive, |
1041 (leftAlpha > 0 ? 1 : 0) + (rightAlpha > 0 ? 1 : 0), | 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. |
| 1043 SkASSERT(fBounds.contains(x + width + (rightAlpha > 0 ? 1 : 0), |
1042 y + height - 1)); | 1044 y + height - 1)); |
1043 SkASSERT(width >= 0); | 1045 SkASSERT(width >= 0); |
1044 | 1046 |
1045 // Conceptually we're always adding 3 runs, but we should | 1047 // Conceptually we're always adding 3 runs, but we should |
1046 // merge or omit them if possible. | 1048 // merge or omit them if possible. |
1047 if (leftAlpha == 0xFF) { | 1049 if (leftAlpha == 0xFF) { |
1048 width++; | 1050 width++; |
1049 } else if (leftAlpha > 0) { | 1051 } else if (leftAlpha > 0) { |
1050 this->addRun(x++, y, leftAlpha, 1); | 1052 this->addRun(x++, y, leftAlpha, 1); |
| 1053 } else { |
| 1054 // leftAlpha is 0, ignore the left column |
| 1055 x++; |
1051 } | 1056 } |
1052 if (rightAlpha == 0xFF) { | 1057 if (rightAlpha == 0xFF) { |
1053 width++; | 1058 width++; |
1054 } | 1059 } |
1055 if (width > 0) { | 1060 if (width > 0) { |
1056 this->addRun(x, y, 0xFF, width); | 1061 this->addRun(x, y, 0xFF, width); |
1057 } | 1062 } |
1058 if (rightAlpha > 0 && rightAlpha < 255) { | 1063 if (rightAlpha > 0 && rightAlpha < 255) { |
1059 this->addRun(x + width, y, rightAlpha, 1); | 1064 this->addRun(x + width, y, rightAlpha, 1); |
1060 } | 1065 } |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 } | 1272 } |
1268 | 1273 |
1269 /** | 1274 /** |
1270 Must evaluate clips in scan-line order, so don't want to allow blitV(), | 1275 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 | 1276 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). | 1277 must support it (given AntiRect semantics: minimum width is 2). |
1273 Instead we'll rely on the runtime asserts to guarantee Y monotonicity; | 1278 Instead we'll rely on the runtime asserts to guarantee Y monotonicity; |
1274 any failure cases that misses may have minor artifacts. | 1279 any failure cases that misses may have minor artifacts. |
1275 */ | 1280 */ |
1276 void blitV(int x, int y, int height, SkAlpha alpha) override { | 1281 void blitV(int x, int y, int height, SkAlpha alpha) override { |
1277 this->recordMinY(y); | 1282 if (height == 1) { |
1278 fBuilder->addColumn(x, y, alpha, height); | 1283 // We're still in scan-line order if height is 1 |
1279 fLastY = y + height - 1; | 1284 // This is useful for Analytic AA |
| 1285 const SkAlpha alphas[2] = {alpha, 0}; |
| 1286 const int16_t runs[2] = {1, 0}; |
| 1287 this->blitAntiH(x, y, alphas, runs); |
| 1288 } else { |
| 1289 this->recordMinY(y); |
| 1290 fBuilder->addColumn(x, y, alpha, height); |
| 1291 fLastY = y + height - 1; |
| 1292 } |
1280 } | 1293 } |
1281 | 1294 |
1282 void blitRect(int x, int y, int width, int height) override { | 1295 void blitRect(int x, int y, int width, int height) override { |
1283 this->recordMinY(y); | 1296 this->recordMinY(y); |
1284 this->checkForYGap(y); | 1297 this->checkForYGap(y); |
1285 fBuilder->addRectRun(x, y, width, height); | 1298 fBuilder->addRectRun(x, y, width, height); |
1286 fLastY = y + height - 1; | 1299 fLastY = y + height - 1; |
1287 } | 1300 } |
1288 | 1301 |
1289 virtual void blitAntiRect(int x, int y, int width, int height, | 1302 virtual void blitAntiRect(int x, int y, int width, int height, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 } else { | 1404 } else { |
1392 if (ibounds.isEmpty() || !ibounds.intersect(clip->getBounds())) { | 1405 if (ibounds.isEmpty() || !ibounds.intersect(clip->getBounds())) { |
1393 return this->setEmpty(); | 1406 return this->setEmpty(); |
1394 } | 1407 } |
1395 } | 1408 } |
1396 | 1409 |
1397 Builder builder(ibounds); | 1410 Builder builder(ibounds); |
1398 BuilderBlitter blitter(&builder); | 1411 BuilderBlitter blitter(&builder); |
1399 | 1412 |
1400 if (doAA) { | 1413 if (doAA) { |
1401 SkScan::AntiFillPath(path, *clip, &blitter, true); | 1414 if (gSkUseAnalyticAA.load()) { |
| 1415 SkScan::AAAFillPath(path, *clip, &blitter, true); |
| 1416 } else { |
| 1417 SkScan::AntiFillPath(path, *clip, &blitter, true); |
| 1418 } |
1402 } else { | 1419 } else { |
1403 SkScan::FillPath(path, *clip, &blitter); | 1420 SkScan::FillPath(path, *clip, &blitter); |
1404 } | 1421 } |
1405 | 1422 |
1406 blitter.finish(); | 1423 blitter.finish(); |
1407 return builder.finish(this); | 1424 return builder.finish(this); |
1408 } | 1425 } |
1409 | 1426 |
1410 /////////////////////////////////////////////////////////////////////////////// | 1427 /////////////////////////////////////////////////////////////////////////////// |
1411 | 1428 |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2211 rowMask.fBounds.fBottom = y + 1; | 2228 rowMask.fBounds.fBottom = y + 1; |
2212 fBlitter->blitMask(rowMask, rowMask.fBounds); | 2229 fBlitter->blitMask(rowMask, rowMask.fBounds); |
2213 src = (const void*)((const char*)src + srcRB); | 2230 src = (const void*)((const char*)src + srcRB); |
2214 } while (++y < localStopY); | 2231 } while (++y < localStopY); |
2215 } while (y < stopY); | 2232 } while (y < stopY); |
2216 } | 2233 } |
2217 | 2234 |
2218 const SkPixmap* SkAAClipBlitter::justAnOpaqueColor(uint32_t* value) { | 2235 const SkPixmap* SkAAClipBlitter::justAnOpaqueColor(uint32_t* value) { |
2219 return nullptr; | 2236 return nullptr; |
2220 } | 2237 } |
OLD | NEW |