dashing asPoints could draw excessively long first dash
https://codereview.appspot.com/7098054/ Will require rebaselining of dashing gm. git-svn-id: http://skia.googlecode.com/svn/trunk@7177 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
fb830981f2
commit
5c4d5582c9
@ -316,6 +316,7 @@ DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count,
|
||||
this->fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar(count),
|
||||
"Points: "));
|
||||
this->fInfo.push(SkObjectParser::PointModeToString(mode));
|
||||
this->fInfo.push(SkObjectParser::PaintToString(paint));
|
||||
}
|
||||
|
||||
void DrawPoints::execute(SkCanvas* canvas) {
|
||||
|
@ -248,6 +248,12 @@ protected:
|
||||
this->drawDashedLines(canvas, 99.5f, SK_ScalarHalf, SK_Scalar1, 1, false);
|
||||
canvas->restore();
|
||||
|
||||
// 255on/255off 1x1 squares with phase of 0 - rects fast path
|
||||
canvas->save();
|
||||
canvas->translate(446, 0);
|
||||
this->drawDashedLines(canvas, 100, 0, SkIntToScalar(255), 1, false);
|
||||
canvas->restore();
|
||||
|
||||
// 1on/1off 3x3 squares with phase of 0 - points fast path
|
||||
canvas->save();
|
||||
canvas->translate(2, 110);
|
||||
|
@ -320,6 +320,7 @@ bool SkDashPathEffect::asPoints(PointData* results,
|
||||
|
||||
if (NULL != results) {
|
||||
results->fFlags = 0;
|
||||
SkScalar clampedInitialDashLength = SkMinScalar(length, fInitialDashLength);
|
||||
|
||||
if (SkPaint::kRound_Cap == rec.getCap()) {
|
||||
results->fFlags |= PointData::kCircles_PointFlag;
|
||||
@ -328,22 +329,22 @@ bool SkDashPathEffect::asPoints(PointData* results,
|
||||
results->fNumPoints = 0;
|
||||
SkScalar len2 = length;
|
||||
bool partialFirst = false;
|
||||
if (fInitialDashLength > 0 || 0 == fInitialDashIndex) {
|
||||
SkASSERT(len2 >= fInitialDashLength);
|
||||
if (clampedInitialDashLength > 0 || 0 == fInitialDashIndex) {
|
||||
SkASSERT(len2 >= clampedInitialDashLength);
|
||||
if (0 == fInitialDashIndex) {
|
||||
if (fInitialDashLength > 0) {
|
||||
if (clampedInitialDashLength > 0) {
|
||||
partialFirst = true;
|
||||
if (fInitialDashLength >= fIntervals[0]) {
|
||||
if (clampedInitialDashLength >= fIntervals[0]) {
|
||||
++results->fNumPoints; // partial first dash
|
||||
}
|
||||
len2 -= fInitialDashLength;
|
||||
len2 -= clampedInitialDashLength;
|
||||
}
|
||||
len2 -= fIntervals[1]; // also skip first space
|
||||
if (len2 < 0) {
|
||||
len2 = 0;
|
||||
}
|
||||
} else {
|
||||
len2 -= fInitialDashLength; // skip initial partial empty
|
||||
len2 -= clampedInitialDashLength; // skip initial partial empty
|
||||
}
|
||||
}
|
||||
int numMidPoints = SkScalarFloorToInt(SkScalarDiv(len2, fIntervalLength));
|
||||
@ -364,24 +365,24 @@ bool SkDashPathEffect::asPoints(PointData* results,
|
||||
SkScalar distance = 0;
|
||||
int curPt = 0;
|
||||
|
||||
if (fInitialDashLength > 0 || 0 == fInitialDashIndex) {
|
||||
SkASSERT(fInitialDashLength <= length);
|
||||
if (clampedInitialDashLength > 0 || 0 == fInitialDashIndex) {
|
||||
SkASSERT(clampedInitialDashLength <= length);
|
||||
|
||||
if (0 == fInitialDashIndex) {
|
||||
if (fInitialDashLength > 0) {
|
||||
if (clampedInitialDashLength > 0) {
|
||||
// partial first block
|
||||
SkASSERT(SkPaint::kRound_Cap != rec.getCap()); // can't handle partial circles
|
||||
SkScalar x = pts[0].fX + SkScalarMul(tangent.fX, SkScalarHalf(fInitialDashLength));
|
||||
SkScalar y = pts[0].fY + SkScalarMul(tangent.fY, SkScalarHalf(fInitialDashLength));
|
||||
SkScalar x = pts[0].fX + SkScalarMul(tangent.fX, SkScalarHalf(clampedInitialDashLength));
|
||||
SkScalar y = pts[0].fY + SkScalarMul(tangent.fY, SkScalarHalf(clampedInitialDashLength));
|
||||
SkScalar halfWidth, halfHeight;
|
||||
if (isXAxis) {
|
||||
halfWidth = SkScalarHalf(fInitialDashLength);
|
||||
halfWidth = SkScalarHalf(clampedInitialDashLength);
|
||||
halfHeight = SkScalarHalf(rec.getWidth());
|
||||
} else {
|
||||
halfWidth = SkScalarHalf(rec.getWidth());
|
||||
halfHeight = SkScalarHalf(fInitialDashLength);
|
||||
halfHeight = SkScalarHalf(clampedInitialDashLength);
|
||||
}
|
||||
if (fInitialDashLength < fIntervals[0]) {
|
||||
if (clampedInitialDashLength < fIntervals[0]) {
|
||||
// This one will not be like the others
|
||||
results->fFirst.addRect(x - halfWidth, y - halfHeight,
|
||||
x + halfWidth, y + halfHeight);
|
||||
@ -391,12 +392,12 @@ bool SkDashPathEffect::asPoints(PointData* results,
|
||||
++curPt;
|
||||
}
|
||||
|
||||
distance += fInitialDashLength;
|
||||
distance += clampedInitialDashLength;
|
||||
}
|
||||
|
||||
distance += fIntervals[1]; // skip over the next blank block too
|
||||
} else {
|
||||
distance += fInitialDashLength;
|
||||
distance += clampedInitialDashLength;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user