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

Unified Diff: src/gpu/batches/GrAAStrokeRectBatch.cpp

Issue 1356223003: Revert of Fix for degenerate stroke rect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 | « src/gpu/batches/GrAAStrokeRectBatch.h ('k') | src/gpu/batches/GrRectBatchFactory.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrAAStrokeRectBatch.cpp
diff --git a/src/gpu/batches/GrAAStrokeRectBatch.cpp b/src/gpu/batches/GrAAStrokeRectBatch.cpp
index baea72f5ec43ad287fb11e8ff7f589f49ca6d163..0a9601f3102f87f27bdd10eb4057e47f2e0cf055 100644
--- a/src/gpu/batches/GrAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrAAStrokeRectBatch.cpp
@@ -53,7 +53,6 @@
SkRect fDevOutsideAssist;
SkRect fDevInside;
GrColor fColor;
- bool fDegenerate;
};
static AAStrokeRectBatch* Create(const SkMatrix& viewMatrix, bool miterStroke) {
@@ -78,19 +77,17 @@
}
void append(GrColor color, const SkRect& devOutside, const SkRect& devOutsideAssist,
- const SkRect& devInside, bool degenerate) {
+ const SkRect& devInside) {
Geometry& geometry = fGeoData.push_back();
geometry.fColor = color;
geometry.fDevOutside = devOutside;
geometry.fDevOutsideAssist = devOutsideAssist;
geometry.fDevInside = devInside;
- geometry.fDegenerate = degenerate;
}
void appendAndUpdateBounds(GrColor color, const SkRect& devOutside,
- const SkRect& devOutsideAssist, const SkRect& devInside,
- bool degenerate) {
- this->append(color, devOutside, devOutsideAssist, devInside, degenerate);
+ const SkRect& devOutsideAssist, const SkRect& devInside) {
+ this->append(color, devOutside, devOutsideAssist, devInside);
SkRect bounds;
this->updateBounds(&bounds, fGeoData.back());
@@ -148,7 +145,6 @@
const SkRect& devOutsideAssist,
const SkRect& devInside,
bool miterStroke,
- bool degenerate,
bool tweakAlphaForCoverage) const;
struct BatchTracker {
@@ -230,7 +226,6 @@
args.fDevOutsideAssist,
args.fDevInside,
fMiterStroke,
- args.fDegenerate,
canTweakAlphaForCoverage);
}
helper.recordDraw(target);
@@ -361,15 +356,6 @@
return true;
}
-static void setup_scale(int* scale, SkScalar inset) {
- if (inset < SK_ScalarHalf) {
- *scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf));
- SkASSERT(*scale >= 0 && *scale <= 255);
- } else {
- *scale = 0xff;
- }
-}
-
void AAStrokeRectBatch::generateAAStrokeRectGeometry(void* vertices,
size_t offset,
size_t vertexStride,
@@ -380,7 +366,6 @@
const SkRect& devOutsideAssist,
const SkRect& devInside,
bool miterStroke,
- bool degenerate,
bool tweakAlphaForCoverage) const {
intptr_t verts = reinterpret_cast<intptr_t>(vertices) + offset;
@@ -397,34 +382,18 @@
#ifndef SK_IGNORE_THIN_STROKED_RECT_FIX
// TODO: this only really works if the X & Y margins are the same all around
// the rect (or if they are all >= 1.0).
- SkScalar inset;
- if (!degenerate) {
- inset = SkMinScalar(SK_Scalar1, devOutside.fRight - devInside.fRight);
- inset = SkMinScalar(inset, devInside.fLeft - devOutside.fLeft);
- inset = SkMinScalar(inset, devInside.fTop - devOutside.fTop);
- if (miterStroke) {
- inset = SK_ScalarHalf * SkMinScalar(inset, devOutside.fBottom - devInside.fBottom);
- } else {
- inset = SK_ScalarHalf * SkMinScalar(inset, devOutsideAssist.fBottom -
- devInside.fBottom);
- }
- SkASSERT(inset >= 0);
+ SkScalar inset = SkMinScalar(SK_Scalar1, devOutside.fRight - devInside.fRight);
+ inset = SkMinScalar(inset, devInside.fLeft - devOutside.fLeft);
+ inset = SkMinScalar(inset, devInside.fTop - devOutside.fTop);
+ if (miterStroke) {
+ inset = SK_ScalarHalf * SkMinScalar(inset, devOutside.fBottom - devInside.fBottom);
} else {
- // TODO use real devRect here
- inset = SkMinScalar(devOutside.width(), SK_Scalar1);
- inset = SK_ScalarHalf * SkMinScalar(inset, SkTMax(devOutside.height(),
- devOutsideAssist.height()));
- }
+ inset = SK_ScalarHalf * SkMinScalar(inset, devOutsideAssist.fBottom -
+ devInside.fBottom);
+ }
+ SkASSERT(inset >= 0);
#else
- SkScalar inset;
- if (!degenerate) {
- inset = SK_ScalarHalf;
- } else {
- // TODO use real devRect here
- inset = SkMinScalar(devOutside.width(), SK_Scalar1);
- inset = SK_ScalarHalf * SkMinScalar(inset, SkTMax(devOutside.height(),
- devOutsideAssist.height()));
- }
+ SkScalar inset = SK_ScalarHalf;
#endif
if (miterStroke) {
@@ -432,19 +401,9 @@
set_inset_fan(fan0Pos, vertexStride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
// inner two
set_inset_fan(fan1Pos, vertexStride, devOutside, inset, inset);
- if (!degenerate) {
- set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset);
- // innermost
- set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf);
- } else {
- // When the interior rect has become degenerate we smoosh to a single point
- SkASSERT(devInside.fLeft == devInside.fRight &&
- devInside.fTop == devInside.fBottom);
- fan2Pos->setRectFan(devInside.fLeft, devInside.fTop,
- devInside.fRight, devInside.fBottom, vertexStride);
- fan3Pos->setRectFan(devInside.fLeft, devInside.fTop,
- devInside.fRight, devInside.fBottom, vertexStride);
- }
+ set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset);
+ // innermost
+ set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf);
} else {
SkPoint* fan0AssistPos = reinterpret_cast<SkPoint*>(verts + 4 * vertexStride);
SkPoint* fan1AssistPos = reinterpret_cast<SkPoint*>(verts +
@@ -457,20 +416,10 @@
// outer one of the inner two
set_inset_fan(fan1Pos, vertexStride, devOutside, inset, inset);
set_inset_fan(fan1AssistPos, vertexStride, devOutsideAssist, inset, inset);
- if (!degenerate) {
- // inner one of the inner two
- set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset);
- // innermost
- set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf);
- } else {
- // When the interior rect has become degenerate we smoosh to a single point
- SkASSERT(devInside.fLeft == devInside.fRight &&
- devInside.fTop == devInside.fBottom);
- fan2Pos->setRectFan(devInside.fLeft, devInside.fTop,
- devInside.fRight, devInside.fBottom, vertexStride);
- fan3Pos->setRectFan(devInside.fLeft, devInside.fTop,
- devInside.fRight, devInside.fBottom, vertexStride);
- }
+ // inner one of the inner two
+ set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset);
+ // innermost
+ set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf);
}
// Make verts point to vertex color and then set all the color and coverage vertex attrs
@@ -487,7 +436,12 @@
// scale is the coverage for the the inner two rects.
int scale;
- setup_scale(&scale, inset);
+ if (inset < SK_ScalarHalf) {
+ scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf));
+ SkASSERT(scale >= 0 && scale <= 255);
+ } else {
+ scale = 0xff;
+ }
float innerCoverage = GrNormalizeByteToFloat(scale);
GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale);
@@ -498,24 +452,19 @@
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor;
} else {
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
- *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) = innerCoverage;
+ *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) =
+ innerCoverage;
}
}
- // The innermost rect has 0 coverage, unless we are degenerate, in which case we must apply the
- // scaled coverage
+ // The innermost rect has 0 coverage
verts += (outerVertexNum + innerVertexNum) * vertexStride;
- if (!degenerate) {
- innerCoverage = 0;
- scaledColor = 0;
- }
-
for (int i = 0; i < innerVertexNum; ++i) {
if (tweakAlphaForCoverage) {
- *reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor;
+ *reinterpret_cast<GrColor*>(verts + i * vertexStride) = 0;
} else {
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
- *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) = innerCoverage;
+ *reinterpret_cast<GrColor*>(verts + i * vertexStride + sizeof(GrColor)) = 0;
}
}
}
@@ -527,10 +476,9 @@
const SkRect& devOutside,
const SkRect& devOutsideAssist,
const SkRect& devInside,
- bool miterStroke,
- bool degenerate) {
+ bool miterStroke) {
AAStrokeRectBatch* batch = AAStrokeRectBatch::Create(viewMatrix, miterStroke);
- batch->append(color, devOutside, devOutsideAssist, devInside, degenerate);
+ batch->append(color, devOutside, devOutsideAssist, devInside);
batch->init();
return batch;
}
@@ -541,8 +489,7 @@
const SkRect& devOutside,
const SkRect& devOutsideAssist,
const SkRect& devInside,
- bool miterStroke,
- bool degenerate) {
+ bool miterStroke) {
AAStrokeRectBatch* batch = origBatch->cast<AAStrokeRectBatch>();
// we can't batch across vm changes
@@ -550,7 +497,7 @@
return false;
}
- batch->appendAndUpdateBounds(color, devOutside, devOutsideAssist, devInside, degenerate);
+ batch->appendAndUpdateBounds(color, devOutside, devOutsideAssist, devInside);
return true;
}
@@ -564,7 +511,6 @@
DRAW_BATCH_TEST_DEFINE(AAStrokeRectBatch) {
bool miterStroke = random->nextBool();
- bool degenerate = random->nextBool();
// Create mock stroke rect
SkRect outside = GrTest::TestRect(random);
@@ -578,7 +524,7 @@
GrColor color = GrRandomColor(random);
return GrAAStrokeRectBatch::Create(color, GrTest::TestMatrix(random), outside, outsideAssist,
- inside, degenerate, miterStroke);
+ inside, miterStroke);
}
#endif
« no previous file with comments | « src/gpu/batches/GrAAStrokeRectBatch.h ('k') | src/gpu/batches/GrRectBatchFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698