16 : points_(
std::move(points)), radius_(radius), round_(round) {}
27 if (determinant == 0) {
31 Scalar min_size = 1.0f / sqrt(std::abs(determinant));
32 Scalar radius = std::max(radius_, min_size);
35 VertexBufferBuilder<SolidFillVertexShader::PerVertexData> vtx_builder;
43 std::vector<Point> circle_vertices;
44 circle_vertices.reserve(generator.GetVertexCount());
45 generator.GenerateVertices([&circle_vertices](
const Point& p) {
46 circle_vertices.push_back(p);
48 FML_DCHECK(circle_vertices.size() == generator.GetVertexCount());
50 vtx_builder.Reserve((circle_vertices.size() + 2) * points_.size() - 2);
51 for (
auto& center : points_) {
52 if (vtx_builder.HasVertices()) {
53 vtx_builder.AppendVertex(vtx_builder.Last());
54 vtx_builder.AppendVertex({center + circle_vertices[0]});
57 for (
auto& vertex : circle_vertices) {
58 vtx_builder.AppendVertex({center + vertex});
62 vtx_builder.Reserve(6 * points_.size() - 2);
63 for (
auto& point : points_) {
64 auto first =
Point(point.x - radius, point.y - radius);
66 if (vtx_builder.HasVertices()) {
67 vtx_builder.AppendVertex(vtx_builder.Last());
68 vtx_builder.AppendVertex({first});
72 vtx_builder.AppendVertex({first});
73 vtx_builder.AppendVertex({{point.x + radius, point.y - radius}});
74 vtx_builder.AppendVertex({{point.x - radius, point.y + radius}});
75 vtx_builder.AppendVertex({{point.x + radius, point.y + radius}});
79 return GeometryResult{
81 .vertex_buffer = vtx_builder.CreateVertexBuffer(host_buffer),
87 std::optional<Rect> PointFieldGeometry::GetCoverage(
89 if (points_.size() > 0) {
92 auto first = points_.begin();
93 auto last = points_.end();
96 auto right = first->x;
97 auto bottom = first->y;
98 for (
auto it = first + 1; it < last; ++it) {
99 left = std::min(left, it->x);
100 top = std::min(top, it->y);
101 right = std::max(right, it->x);
102 bottom = std::max(bottom, it->y);
105 right + radius_, bottom + radius_);
106 return coverage.TransformBounds(
transform);