11 : p0_(p0), p1_(p1), width_(width), cap_(cap) {
12 FML_DCHECK(width >= 0);
26 return std::max(width, min_size) * 0.5f;
30 bool allow_zero_length,
37 auto along = p1_ - p0_;
38 Scalar length = along.GetLength();
40 if (!allow_zero_length) {
44 return {stroke_half_width, 0};
46 return along * stroke_half_width / length;
50 bool LineGeometry::ComputeCorners(
Point corners[4],
52 bool extend_endpoints,
54 auto along = ComputeAlongVector(
transform, extend_endpoints, msaa);
59 auto across =
Vector2(along.y, -along.x);
60 corners[0] = p0_ - across;
61 corners[1] = p1_ - across;
62 corners[2] = p0_ + across;
63 corners[3] = p1_ + across;
64 if (extend_endpoints) {
80 using VT = SolidFillVertexShader::PerVertexData;
87 std::shared_ptr<Tessellator> tessellator = renderer.
GetTessellator();
88 auto generator = tessellator->RoundCapLine(
transform, p0_, p1_, radius);
101 BufferView vertex_buffer = host_buffer.
Emplace(
102 count *
sizeof(VT),
alignof(VT), [&corners](uint8_t* buffer) {
103 auto vertices =
reinterpret_cast<VT*
>(buffer);
104 for (
auto& corner : corners) {
111 return GeometryResult{
115 .vertex_buffer = vertex_buffer,
116 .vertex_count = count,
123 std::optional<Rect> LineGeometry::GetCoverage(
const Matrix&
transform)
const {
130 for (
int i = 0; i < 4; i++) {
141 return coverage.has_value() ? coverage->Contains(rect) :
false;
145 return cap_ !=
Cap::kRound && (p0_.x == p1_.
x || p0_.y == p1_.
y);