aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ops
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-06-02 11:01:10 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-02 19:44:18 +0000
commite23bffd65b379aeeb6bb614de81369c130623e92 (patch)
tree7ed966359438344027ffd20d58b5afdb4bb5b3fe /src/gpu/ops
parent219b4e81db683d943da0261438bfdc6139d8f061 (diff)
Remove support in GPU backend for distance vector field.
Also, remvoes SkNormalBevelSource as this was the last use case for the distance vector field. Change-Id: Ib0176c78e500e6b5130310934253a75860245812 Reviewed-on: https://skia-review.googlesource.com/18482 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/ops')
-rw-r--r--src/gpu/ops/GrAnalyticRectOp.cpp31
-rw-r--r--src/gpu/ops/GrOvalOpFactory.cpp74
-rw-r--r--src/gpu/ops/GrOvalOpFactory.h1
-rw-r--r--src/gpu/ops/GrRectOpFactory.h6
4 files changed, 15 insertions, 97 deletions
diff --git a/src/gpu/ops/GrAnalyticRectOp.cpp b/src/gpu/ops/GrAnalyticRectOp.cpp
index 358b5622e3..f62f0c628e 100644
--- a/src/gpu/ops/GrAnalyticRectOp.cpp
+++ b/src/gpu/ops/GrAnalyticRectOp.cpp
@@ -60,8 +60,6 @@ public:
fInWidthHeight = &this->addVertexAttrib("inWidthHeight", kVec2f_GrVertexAttribType);
}
- bool implementsDistanceVector() const override { return true; }
-
const Attribute* inPosition() const { return fInPosition; }
const Attribute* inColor() const { return fInColor; }
const Attribute* inRectEdge() const { return fInRectEdge; }
@@ -141,46 +139,17 @@ public:
fragBuilder->codeAppendf("float perpDot = abs(offset.x * %s.w - offset.y * %s.z);",
rectEdgeVary.fsIn(), rectEdgeVary.fsIn());
- if (args.fDistanceVectorName) {
- fragBuilder->codeAppendf("float widthDistance = %s.x - perpDot;",
- widthHeightVary.fsIn());
- }
-
fragBuilder->codeAppendf(
"float coverage = scaleW*clamp((%s.x-perpDot)/spanW, 0.0, 1.0);",
widthHeightVary.fsIn());
// Compute the coverage for the rect's height and merge with the width
fragBuilder->codeAppendf("perpDot = abs(dot(offset, %s.zw));", rectEdgeVary.fsIn());
- if (args.fDistanceVectorName) {
- fragBuilder->codeAppendf("float heightDistance = %s.y - perpDot;",
- widthHeightVary.fsIn());
- }
-
fragBuilder->codeAppendf(
"coverage = coverage*scaleH*clamp((%s.y-perpDot)/spanH, 0.0, 1.0);",
widthHeightVary.fsIn());
fragBuilder->codeAppendf("%s = vec4(coverage);", args.fOutputCoverage);
-
- if (args.fDistanceVectorName) {
- fragBuilder->codeAppend("// Calculating distance vector\n");
- fragBuilder->codeAppend("vec2 dvAxis;");
- fragBuilder->codeAppend("float dvLength;");
-
- fragBuilder->codeAppend("if (heightDistance < widthDistance) {");
- fragBuilder->codeAppendf(" dvAxis = %s.zw;", rectEdgeVary.fsIn());
- fragBuilder->codeAppend(" dvLength = heightDistance;");
- fragBuilder->codeAppend("} else {");
- fragBuilder->codeAppendf(" dvAxis = vec2(-%s.w, %s.z);", rectEdgeVary.fsIn(),
- rectEdgeVary.fsIn());
- fragBuilder->codeAppend(" dvLength = widthDistance;");
- fragBuilder->codeAppend("}");
-
- fragBuilder->codeAppend("float dvSign = sign(dot(offset, dvAxis));");
- fragBuilder->codeAppendf("%s = vec4(dvSign * dvAxis, dvLength, 0.0);",
- args.fDistanceVectorName);
- }
}
static void GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 174dc4015e..2b9d1c8e56 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -57,12 +57,6 @@ static inline bool circle_stays_circle(const SkMatrix& m) { return m.isSimilarit
* p is the position in the normalized space.
* outerRad is the outerRadius in device space.
* innerRad is the innerRadius in normalized space (ignored if not stroking).
- * If fUsesDistanceVectorField is set in fragment processors in the same program, then
- * an additional vertex attribute is available via args.fFragBuilder->distanceVectorName():
- * vec4f : (v.xy, outerDistance, innerDistance)
- * v is a normalized vector pointing to the outer edge
- * outerDistance is the distance to the outer edge, < 0 if we are outside of the shape
- * if stroking, innerDistance is the distance to the inner edge, < 0 if outside
* Additional clip planes are supported for rendering circular arcs. The additional planes are
* either intersected or unioned together. Up to three planes are supported (an initial plane,
* a plane intersected with the initial plane, and a plane unioned with the first two). Only two
@@ -99,8 +93,6 @@ public:
fStroke = stroke;
}
- bool implementsDistanceVector() const override { return !fInClipPlane; }
-
~CircleGeometryProcessor() override {}
const char* name() const override { return "CircleEdge"; }
@@ -170,21 +162,6 @@ private:
fragBuilder->codeAppend("edgeAlpha *= innerAlpha;");
}
- if (args.fDistanceVectorName) {
- const char* innerEdgeDistance = cgp.fStroke ? "distanceToInnerEdge" : "0.0";
- fragBuilder->codeAppendf(
- "if (d == 0.0) {" // if on the center of the circle
- " %s = vec4(1.0, 0.0, distanceToOuterEdge, "
- " %s);", // no normalize
- args.fDistanceVectorName,
- innerEdgeDistance);
- fragBuilder->codeAppendf(
- "} else {"
- " %s = vec4(normalize(circleEdge.xy),"
- " distanceToOuterEdge, %s);"
- "}",
- args.fDistanceVectorName, innerEdgeDistance);
- }
if (cgp.fInClipPlane) {
fragBuilder->codeAppend(
"float clip = clamp(circleEdge.z * dot(circleEdge.xy, clipPlane.xy) + "
@@ -1689,7 +1666,6 @@ enum RRectType {
kFill_RRectType,
kStroke_RRectType,
kOverstroke_RRectType,
- kFillWithDist_RRectType
};
static int rrect_type_to_vert_count(RRectType type) {
@@ -1698,7 +1674,6 @@ static int rrect_type_to_vert_count(RRectType type) {
case kStroke_RRectType:
return kVertsPerStandardRRect;
case kOverstroke_RRectType:
- case kFillWithDist_RRectType:
return kVertsPerOverstrokeRRect;
}
SkFAIL("Invalid type");
@@ -1712,7 +1687,6 @@ static int rrect_type_to_index_count(RRectType type) {
case kStroke_RRectType:
return kIndicesPerStrokeRRect;
case kOverstroke_RRectType:
- case kFillWithDist_RRectType:
return kIndicesPerOverstrokeRRect;
}
SkFAIL("Invalid type");
@@ -1725,7 +1699,6 @@ static const uint16_t* rrect_type_to_indices(RRectType type) {
case kStroke_RRectType:
return gStandardRRectIndices;
case kOverstroke_RRectType:
- case kFillWithDist_RRectType:
return gOverstrokeRRectIndices;
}
SkFAIL("Invalid type");
@@ -1752,16 +1725,14 @@ public:
// A devStrokeWidth <= 0 indicates a fill only. If devStrokeWidth > 0 then strokeOnly indicates
// whether the rrect is only stroked or stroked and filled.
- static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, bool needsDistance,
- const SkMatrix& viewMatrix, const SkRect& devRect,
- float devRadius, float devStrokeWidth, bool strokeOnly) {
- return Helper::FactoryHelper<CircularRRectOp>(std::move(paint), needsDistance, viewMatrix,
- devRect, devRadius, devStrokeWidth,
- strokeOnly);
+ static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkMatrix& viewMatrix,
+ const SkRect& devRect, float devRadius,
+ float devStrokeWidth, bool strokeOnly) {
+ return Helper::FactoryHelper<CircularRRectOp>(std::move(paint), viewMatrix, devRect,
+ devRadius, devStrokeWidth, strokeOnly);
}
- CircularRRectOp(Helper::MakeArgs& helperArgs, GrColor color, bool needsDistance,
- const SkMatrix& viewMatrix, const SkRect& devRect, float devRadius,
- float devStrokeWidth, bool strokeOnly)
+ CircularRRectOp(Helper::MakeArgs& helperArgs, GrColor color, const SkMatrix& viewMatrix,
+ const SkRect& devRect, float devRadius, float devStrokeWidth, bool strokeOnly)
: INHERITED(ClassID())
, fViewMatrixIfUsingLocalCoords(viewMatrix)
, fHelper(helperArgs, GrAAType::kCoverage) {
@@ -1791,9 +1762,6 @@ public:
outerRadius += halfWidth;
bounds.outset(halfWidth, halfWidth);
}
- if (kFill_RRectType == type && needsDistance) {
- type = kFillWithDist_RRectType;
- }
// The radii are outset for two reasons. First, it allows the shader to simply perform
// simpler computation because the computed alpha is zero, rather than 50%, at the radius.
@@ -1958,10 +1926,9 @@ private:
SkScalar yOuterRadii[4] = {-1, 0, 0, 1};
// The inner radius in the vertex data must be specified in normalized space.
// For fills, specifying -1/outerRadius guarantees an alpha of 1.0 at the inner radius.
- SkScalar innerRadius =
- rrect.fType != kFill_RRectType && rrect.fType != kFillWithDist_RRectType
- ? rrect.fInnerRadius / rrect.fOuterRadius
- : -1.0f / rrect.fOuterRadius;
+ SkScalar innerRadius = rrect.fType != kFill_RRectType
+ ? rrect.fInnerRadius / rrect.fOuterRadius
+ : -1.0f / rrect.fOuterRadius;
for (int i = 0; i < 4; ++i) {
verts->fPos = SkPoint::Make(bounds.fLeft, yCoords[i]);
verts->fColor = color;
@@ -2011,15 +1978,6 @@ private:
overstrokeOuterRadius, 0.0f, rrect.fColor);
}
- if (kFillWithDist_RRectType == rrect.fType) {
- SkScalar halfMinDim = 0.5f * SkTMin(bounds.width(), bounds.height());
-
- SkScalar xOffset = 1.0f - outerRadius / halfMinDim;
-
- FillInOverstrokeVerts(&verts, bounds, outerRadius, halfMinDim, xOffset, halfMinDim,
- -1.0f, rrect.fColor);
- }
-
const uint16_t* primIndices = rrect_type_to_indices(rrect.fType);
const int primIndexCount = rrect_type_to_index_count(rrect.fType);
for (int i = 0; i < primIndexCount; ++i) {
@@ -2321,7 +2279,6 @@ private:
};
static std::unique_ptr<GrDrawOp> make_rrect_op(GrPaint&& paint,
- bool needsDistance,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
const SkStrokeRec& stroke) {
@@ -2382,8 +2339,8 @@ static std::unique_ptr<GrDrawOp> make_rrect_op(GrPaint&& paint,
// if the corners are circles, use the circle renderer
if (isCircular) {
- return CircularRRectOp::Make(std::move(paint), needsDistance, viewMatrix, bounds, xRadius,
- scaledStroke.fX, isStrokeOnly);
+ return CircularRRectOp::Make(std::move(paint), viewMatrix, bounds, xRadius, scaledStroke.fX,
+ isStrokeOnly);
// otherwise we use the ellipse renderer
} else {
return EllipticalRRectOp::Make(std::move(paint), viewMatrix, bounds, xRadius, yRadius,
@@ -2392,7 +2349,6 @@ static std::unique_ptr<GrDrawOp> make_rrect_op(GrPaint&& paint,
}
std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeRRectOp(GrPaint&& paint,
- bool needsDistance,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
const SkStrokeRec& stroke,
@@ -2405,7 +2361,7 @@ std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeRRectOp(GrPaint&& paint,
return nullptr;
}
- return make_rrect_op(std::move(paint), needsDistance, viewMatrix, rrect, stroke);
+ return make_rrect_op(std::move(paint), viewMatrix, rrect, stroke);
}
///////////////////////////////////////////////////////////////////////////////
@@ -2508,9 +2464,7 @@ GR_DRAW_OP_TEST_DEFINE(DIEllipseOp) {
GR_DRAW_OP_TEST_DEFINE(RRectOp) {
SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
const SkRRect& rrect = GrTest::TestRRectSimple(random);
- bool needsDistance = random->nextBool();
- return make_rrect_op(std::move(paint), needsDistance, viewMatrix, rrect,
- GrTest::TestStrokeRec(random));
+ return make_rrect_op(std::move(paint), viewMatrix, rrect, GrTest::TestStrokeRec(random));
}
#endif
diff --git a/src/gpu/ops/GrOvalOpFactory.h b/src/gpu/ops/GrOvalOpFactory.h
index 8a51c5301e..4c85ee84f5 100644
--- a/src/gpu/ops/GrOvalOpFactory.h
+++ b/src/gpu/ops/GrOvalOpFactory.h
@@ -33,7 +33,6 @@ public:
const GrShaderCaps*);
static std::unique_ptr<GrDrawOp> MakeRRectOp(GrPaint&&,
- bool needsDistance,
const SkMatrix&,
const SkRRect&,
const SkStrokeRec&,
diff --git a/src/gpu/ops/GrRectOpFactory.h b/src/gpu/ops/GrRectOpFactory.h
index f4b1b803fb..58927ef91b 100644
--- a/src/gpu/ops/GrRectOpFactory.h
+++ b/src/gpu/ops/GrRectOpFactory.h
@@ -31,11 +31,7 @@ inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFill(const GrPaint& paint,
const SkRect& rect,
const SkRect& croppedRect,
const SkRect& devRect) {
- if (!paint.usesDistanceVectorField()) {
- return GrAAFillRectOp::Make(paint.getColor(), viewMatrix, croppedRect, devRect);
- } else {
- return GrAnalyticRectOp::Make(paint.getColor(), viewMatrix, rect, croppedRect, devRect);
- }
+ return GrAAFillRectOp::Make(paint.getColor(), viewMatrix, croppedRect, devRect);
}
inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFill(GrColor color,