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

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

Issue 2482193004: Tighten SkAAClip Bounds by Path Bounds (Closed)
Patch Set: Send in the true SkRegion 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The Android Open Source Project 2 * Copyright 2016 The Android Open Source Project
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 "SkAntiRun.h" 8 #include "SkAntiRun.h"
9 #include "SkBlitter.h" 9 #include "SkBlitter.h"
10 #include "SkEdge.h" 10 #include "SkEdge.h"
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 SkFixed local_bot_fixed = SkMin32(leftE->fLowerY, riteE->fLowerY); 954 SkFixed local_bot_fixed = SkMin32(leftE->fLowerY, riteE->fLowerY);
955 // Skip the fractional y if edges are changing smoothly. 955 // Skip the fractional y if edges are changing smoothly.
956 // If forceRLE is true, we won't skip the fractional y because it 956 // If forceRLE is true, we won't skip the fractional y because it
957 // implies that SkAAClip is calling us and there are strict 957 // implies that SkAAClip is calling us and there are strict
958 // assertions inside SkAAClip. 958 // assertions inside SkAAClip.
959 if (isSmoothEnough(leftE, riteE, currE, stop_y) && !forceRLE) { 959 if (isSmoothEnough(leftE, riteE, currE, stop_y) && !forceRLE) {
960 local_bot_fixed = SkFixedCeilToFixed(local_bot_fixed); 960 local_bot_fixed = SkFixedCeilToFixed(local_bot_fixed);
961 } 961 }
962 local_bot_fixed = SkMin32(local_bot_fixed, SkIntToFixed(stop_y)); 962 local_bot_fixed = SkMin32(local_bot_fixed, SkIntToFixed(stop_y));
963 963
964 SkFixed left = leftE->fX; 964 SkFixed left = SkTMax(leftBound, leftE->fX);
965 SkFixed dLeft = leftE->fDX; 965 SkFixed dLeft = leftE->fDX;
966 SkFixed rite = riteE->fX; 966 SkFixed rite = SkTMin(riteBound, riteE->fX);
967 SkFixed dRite = riteE->fDX; 967 SkFixed dRite = riteE->fDX;
968 if (0 == (dLeft | dRite)) { 968 if (0 == (dLeft | dRite)) {
969 int fullLeft = SkFixedCeilToInt(left); 969 int fullLeft = SkFixedCeilToInt(left);
970 int fullRite = SkFixedFloorToInt(rite); 970 int fullRite = SkFixedFloorToInt(rite);
971 SkFixed partialLeft = SkIntToFixed(fullLeft) - left; 971 SkFixed partialLeft = SkIntToFixed(fullLeft) - left;
972 SkFixed partialRite = rite - SkIntToFixed(fullRite); 972 SkFixed partialRite = rite - SkIntToFixed(fullRite);
973 int fullTop = SkFixedCeilToInt(y); 973 int fullTop = SkFixedCeilToInt(y);
974 int fullBot = SkFixedFloorToInt(local_bot_fixed); 974 int fullBot = SkFixedFloorToInt(local_bot_fixed);
975 SkFixed partialTop = SkIntToFixed(fullTop) - y; 975 SkFixed partialTop = SkIntToFixed(fullTop) - y;
976 SkFixed partialBot = local_bot_fixed - SkIntToFixed(fullBot); 976 SkFixed partialBot = local_bot_fixed - SkIntToFixed(fullBot);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 // and full-row trapezoid_row together, we use the following 3-stage flow to 1066 // and full-row trapezoid_row together, we use the following 3-stage flow to
1067 // handle partial-row blit and full-row blit separately. It will sav e us much time 1067 // handle partial-row blit and full-row blit separately. It will sav e us much time
1068 // on changing y, left, and rite. 1068 // on changing y, left, and rite.
1069 if (count > 1) { 1069 if (count > 1) {
1070 if ((int)(y & 0xFFFF0000) != y) { // There's a partial-row on th e top 1070 if ((int)(y & 0xFFFF0000) != y) { // There's a partial-row on th e top
1071 count--; 1071 count--;
1072 SkFixed nextY = SkFixedCeilToFixed(y + 1); 1072 SkFixed nextY = SkFixedCeilToFixed(y + 1);
1073 SkFixed dY = nextY - y; 1073 SkFixed dY = nextY - y;
1074 SkFixed nextLeft = left + SkFixedMul_lowprec(dLeft, dY); 1074 SkFixed nextLeft = left + SkFixedMul_lowprec(dLeft, dY);
1075 SkFixed nextRite = rite + SkFixedMul_lowprec(dRite, dY); 1075 SkFixed nextRite = rite + SkFixedMul_lowprec(dRite, dY);
1076 SkASSERT((left & kSnapMask) >= leftBound && (rite & kSnapMas k) <= riteBound &&
1077 (nextLeft & kSnapMask) >= leftBound && (nextRite & k SnapMask) <= riteBound);
1076 blit_trapezoid_row(blitter, y >> 16, left & kSnapMask, rite & kSnapMask, 1078 blit_trapezoid_row(blitter, y >> 16, left & kSnapMask, rite & kSnapMask,
1077 nextLeft & kSnapMask, nextRite & kSnapMask, leftE->f DY, riteE->fDY, 1079 nextLeft & kSnapMask, nextRite & kSnapMask, leftE->f DY, riteE->fDY,
1078 getPartialAlpha(0xFF, dY), maskRow, isUsingMask); 1080 getPartialAlpha(0xFF, dY), maskRow, isUsingMask);
1079 if (forceRLE) { 1081 if (forceRLE) {
1080 ((RunBasedAdditiveBlitter*)blitter)->flush_if_y_changed( y, nextY); 1082 ((RunBasedAdditiveBlitter*)blitter)->flush_if_y_changed( y, nextY);
1081 } 1083 }
1082 left = nextLeft; rite = nextRite; y = nextY; 1084 left = nextLeft; rite = nextRite; y = nextY;
1083 } 1085 }
1084 1086
1085 while (count > 1) { // Full rows in the middle 1087 while (count > 1) { // Full rows in the middle
1086 count--; 1088 count--;
1087 if (isUsingMask) { 1089 if (isUsingMask) {
1088 maskRow = static_cast<MaskAdditiveBlitter*>(blitter)->ge tRow(y >> 16); 1090 maskRow = static_cast<MaskAdditiveBlitter*>(blitter)->ge tRow(y >> 16);
1089 } 1091 }
1090 SkFixed nextY = y + SK_Fixed1, nextLeft = left + dLeft, next Rite = rite + dRite; 1092 SkFixed nextY = y + SK_Fixed1, nextLeft = left + dLeft, next Rite = rite + dRite;
1093 SkASSERT((left & kSnapMask) >= leftBound && (rite & kSnapMas k) <= riteBound &&
1094 (nextLeft & kSnapMask) >= leftBound && (nextRite & k SnapMask) <= riteBound);
1091 blit_trapezoid_row(blitter, y >> 16, left & kSnapMask, rite & kSnapMask, 1095 blit_trapezoid_row(blitter, y >> 16, left & kSnapMask, rite & kSnapMask,
1092 nextLeft & kSnapMask, nextRite & kSnapMask, 1096 nextLeft & kSnapMask, nextRite & kSnapMask,
1093 leftE->fDY, riteE->fDY, 0xFF, maskRow, isUsingMask); 1097 leftE->fDY, riteE->fDY, 0xFF, maskRow, isUsingMask);
1094 if (forceRLE) { 1098 if (forceRLE) {
1095 ((RunBasedAdditiveBlitter*)blitter)->flush_if_y_changed( y, nextY); 1099 ((RunBasedAdditiveBlitter*)blitter)->flush_if_y_changed( y, nextY);
1096 } 1100 }
1097 left = nextLeft; rite = nextRite; y = nextY; 1101 left = nextLeft; rite = nextRite; y = nextY;
1098 } 1102 }
1099 } 1103 }
1100 1104
1101 if (isUsingMask) { 1105 if (isUsingMask) {
1102 maskRow = static_cast<MaskAdditiveBlitter*>(blitter)->getRow(y > > 16); 1106 maskRow = static_cast<MaskAdditiveBlitter*>(blitter)->getRow(y > > 16);
1103 } 1107 }
1104 1108
1105 SkFixed dY = local_bot_fixed - y; // partial-row on the bottom 1109 SkFixed dY = local_bot_fixed - y; // partial-row on the bottom
1106 SkASSERT(dY <= SK_Fixed1); 1110 SkASSERT(dY <= SK_Fixed1);
1107 // Smooth jumping to integer y may make the last nextLeft/nextRite o ut of bound. 1111 // Smooth jumping to integer y may make the last nextLeft/nextRite o ut of bound.
1108 // Take them back into the bound here. 1112 // Take them back into the bound here.
1109 // Note that we substract kSnapHalf later so we have to add them to leftBound/riteBound 1113 // Note that we substract kSnapHalf later so we have to add them to leftBound/riteBound
1110 SkFixed nextLeft = SkTMax(left + SkFixedMul_lowprec(dLeft, dY), left Bound + kSnapHalf); 1114 SkFixed nextLeft = SkTMax(left + SkFixedMul_lowprec(dLeft, dY), left Bound + kSnapHalf);
1111 SkFixed nextRite = SkTMin(rite + SkFixedMul_lowprec(dRite, dY), rite Bound + kSnapHalf); 1115 SkFixed nextRite = SkTMin(rite + SkFixedMul_lowprec(dRite, dY), rite Bound + kSnapHalf);
1116 SkASSERT((left & kSnapMask) >= leftBound && (rite & kSnapMask) <= ri teBound &&
1117 (nextLeft & kSnapMask) >= leftBound && (nextRite & kSnapMask ) <= riteBound);
1112 blit_trapezoid_row(blitter, y >> 16, left & kSnapMask, rite & kSnapM ask, 1118 blit_trapezoid_row(blitter, y >> 16, left & kSnapMask, rite & kSnapM ask,
1113 nextLeft & kSnapMask, nextRite & kSnapMask, leftE->fDY, rite E->fDY, 1119 nextLeft & kSnapMask, nextRite & kSnapMask, leftE->fDY, rite E->fDY,
1114 getPartialAlpha(0xFF, dY), maskRow, isUsingMask); 1120 getPartialAlpha(0xFF, dY), maskRow, isUsingMask);
1115 if (forceRLE) { 1121 if (forceRLE) {
1116 ((RunBasedAdditiveBlitter*)blitter)->flush_if_y_changed(y, local _bot_fixed); 1122 ((RunBasedAdditiveBlitter*)blitter)->flush_if_y_changed(y, local _bot_fixed);
1117 } 1123 }
1118 left = nextLeft; rite = nextRite; y = local_bot_fixed; 1124 left = nextLeft; rite = nextRite; y = local_bot_fixed;
1119 left -= kSnapHalf; rite -= kSnapHalf; 1125 left -= kSnapHalf; rite -= kSnapHalf;
1120 } 1126 }
1121 1127
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 AAAFillPath(path, clip.bwRgn(), blitter); 1350 AAAFillPath(path, clip.bwRgn(), blitter);
1345 } else { 1351 } else {
1346 SkRegion tmp; 1352 SkRegion tmp;
1347 SkAAClipBlitter aaBlitter; 1353 SkAAClipBlitter aaBlitter;
1348 1354
1349 tmp.setRect(clip.getBounds()); 1355 tmp.setRect(clip.getBounds());
1350 aaBlitter.init(blitter, &clip.aaRgn()); 1356 aaBlitter.init(blitter, &clip.aaRgn());
1351 AAAFillPath(path, tmp, &aaBlitter, true); 1357 AAAFillPath(path, tmp, &aaBlitter, true);
1352 } 1358 }
1353 } 1359 }
OLDNEW
« src/core/SkAAClip.cpp ('K') | « src/core/SkAAClip.cpp ('k') | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698