Use GrVertexWriter::writeQuad in ellipse ops
More concise and (hopefully), makes the underlying logic easier to spot. Bug: skia: Change-Id: I8dbdcee7c761259dc586311b8c703e87555634cc Reviewed-on: https://skia-review.googlesource.com/c/172502 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
b336c39e07
commit
2b6e3901eb
@ -46,6 +46,11 @@ static inline GrPrimitiveProcessor::Attribute color_attribute(bool wideColor) {
|
||||
kHalf4_GrSLType };
|
||||
}
|
||||
|
||||
// Produces TriStrip vertex data for an origin-centered rectangle from [-x, -y] to [x, y]
|
||||
static inline GrVertexWriter::TriStrip<float> origin_centered_tri_strip(float x, float y) {
|
||||
return GrVertexWriter::TriStrip<float>{ -x, -y, x, y };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -1786,7 +1791,6 @@ private:
|
||||
GrVertexColor color(ellipse.fColor, fWideColor);
|
||||
SkScalar xRadius = ellipse.fXRadius;
|
||||
SkScalar yRadius = ellipse.fYRadius;
|
||||
const SkRect& bounds = ellipse.fDevBounds;
|
||||
|
||||
// Compute the reciprocals of the radii here to save time in the shader
|
||||
struct { float xOuter, yOuter, xInner, yInner; } invRadii = {
|
||||
@ -1806,25 +1810,10 @@ private:
|
||||
}
|
||||
|
||||
// The inner radius in the vertex data must be specified in normalized space.
|
||||
verts.write(SkPoint::Make(bounds.fLeft, bounds.fTop),
|
||||
color,
|
||||
SkPoint::Make(-xMaxOffset, -yMaxOffset),
|
||||
invRadii);
|
||||
|
||||
verts.write(SkPoint::Make(bounds.fLeft, bounds.fBottom),
|
||||
color,
|
||||
SkPoint::Make(-xMaxOffset, yMaxOffset),
|
||||
invRadii);
|
||||
|
||||
verts.write(SkPoint::Make(bounds.fRight, bounds.fTop),
|
||||
color,
|
||||
SkPoint::Make(xMaxOffset, -yMaxOffset),
|
||||
invRadii);
|
||||
|
||||
verts.write(SkPoint::Make(bounds.fRight, bounds.fBottom),
|
||||
color,
|
||||
SkPoint::Make(xMaxOffset, yMaxOffset),
|
||||
invRadii);
|
||||
verts.writeQuad(GrVertexWriter::TriStripFromRect(ellipse.fDevBounds),
|
||||
color,
|
||||
origin_centered_tri_strip(xMaxOffset, yMaxOffset),
|
||||
invRadii);
|
||||
}
|
||||
auto pipe = fHelper.makePipeline(target);
|
||||
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
|
||||
@ -2020,8 +2009,6 @@ private:
|
||||
SkScalar xRadius = ellipse.fXRadius;
|
||||
SkScalar yRadius = ellipse.fYRadius;
|
||||
|
||||
const SkRect& bounds = ellipse.fBounds;
|
||||
|
||||
// This adjusts the "radius" to include the half-pixel border
|
||||
SkScalar offsetDx = ellipse.fGeoDx / xRadius;
|
||||
SkScalar offsetDy = ellipse.fGeoDy / yRadius;
|
||||
@ -2036,29 +2023,11 @@ private:
|
||||
innerRatioY = yRadius / ellipse.fInnerYRadius;
|
||||
}
|
||||
|
||||
verts.write(SkPoint::Make(bounds.fLeft, bounds.fTop),
|
||||
color,
|
||||
SkPoint::Make(-1.0f - offsetDx, -1.0f - offsetDy),
|
||||
SkPoint::Make(-innerRatioX - offsetDx,
|
||||
-innerRatioY - offsetDy));
|
||||
|
||||
verts.write(SkPoint::Make(bounds.fLeft, bounds.fBottom),
|
||||
color,
|
||||
SkPoint::Make(-1.0f - offsetDx, 1.0f + offsetDy),
|
||||
SkPoint::Make(-innerRatioX - offsetDx,
|
||||
innerRatioY + offsetDy));
|
||||
|
||||
verts.write(SkPoint::Make(bounds.fRight, bounds.fTop),
|
||||
color,
|
||||
SkPoint::Make(1.0f + offsetDx, -1.0f - offsetDy),
|
||||
SkPoint::Make( innerRatioX + offsetDx,
|
||||
-innerRatioY - offsetDy));
|
||||
|
||||
verts.write(SkPoint::Make(bounds.fRight, bounds.fBottom),
|
||||
color,
|
||||
SkPoint::Make(1.0f + offsetDx, 1.0f + offsetDy),
|
||||
SkPoint::Make(innerRatioX + offsetDx,
|
||||
innerRatioY + offsetDy));
|
||||
verts.writeQuad(GrVertexWriter::TriStripFromRect(ellipse.fBounds),
|
||||
color,
|
||||
origin_centered_tri_strip(1.0f + offsetDx, 1.0f + offsetDy),
|
||||
origin_centered_tri_strip(innerRatioX + offsetDx,
|
||||
innerRatioY + offsetDy));
|
||||
}
|
||||
auto pipe = fHelper.makePipeline(target);
|
||||
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
|
||||
|
Loading…
Reference in New Issue
Block a user