| Flutter Impeller |

Public Member Functions | List of all members
impeller::ConvexTessellatorImpl< IndexT > Class Template Reference

Inherits impeller::Tessellator::ConvexTessellator.

## Public Member Functions
| ConvexTessellatorImpl ()
VertexBuffer | TessellateConvex (const PathSource &path, HostBuffer &data_host_buffer, HostBuffer &indexes_host_buffer, Scalar tolerance, bool supports_primitive_restart, bool supports_triangle_fan) override

## Detailed Description

### template<typename IndexT>
class impeller::ConvexTessellatorImpl< IndexT >

Definition at line 324 of file tessellator.cc.

## Constructor & Destructor Documentation

## ◆ ConvexTessellatorImpl()

template<typename IndexT >

impeller::ConvexTessellatorImpl< IndexT >::ConvexTessellatorImpl | ( |  | ) |
| inline

Definition at line 326 of file tessellator.cc.

326 {
327 point_buffer_.reserve(2048);
328 index_buffer_.reserve(2048);
329 }

## Member Function Documentation

## ◆ TessellateConvex()

template<typename IndexT >

VertexBuffer impeller::ConvexTessellatorImpl< IndexT >::TessellateConvex | ( | const PathSource & | path,
|  | HostBuffer & | data_host_buffer,
|  | HostBuffer & | indexes_host_buffer,
|  | Scalar | tolerance,
|  | bool | supports_primitive_restart,
|  | bool | supports_triangle_fan
| ) |  |
| inline override

Definition at line 331 of file tessellator.cc.

336 {
337 if (supports_primitive_restart) {
338 // Primitive Restart.
339 const auto [point_count, contour_count] =
340 PathTessellator::CountFillStorage(path, tolerance);
341 BufferView point_buffer = data_host_buffer.Emplace(
342 nullptr, sizeof(Point) * point_count, alignof(Point));
343 BufferView index_buffer = indexes_host_buffer.Emplace(
344 nullptr, sizeof(IndexT) * (point_count + contour_count),
345 alignof(IndexT));
346
347 auto* points_ptr =
348 reinterpret_cast<Point*>(point_buffer.GetBuffer()->OnGetContents() +
349 point_buffer.GetRange().offset);
350 auto* indices_ptr =
351 reinterpret_cast<IndexT*>(index_buffer.GetBuffer()->OnGetContents() +
352 index_buffer.GetRange().offset);
353
354 auto tessellate_path = [&](auto& writer) {
355 PathTessellator::PathToFilledVertices(path, writer, tolerance);
356 FML_DCHECK(writer.GetPointCount() <= point_count);
357 FML_DCHECK(writer.GetIndexCount() <= (point_count + contour_count));
358 point_buffer.GetBuffer()->Flush(point_buffer.GetRange());
359 index_buffer.GetBuffer()->Flush(index_buffer.GetRange());
360
361 return VertexBuffer{
362 .vertex_buffer = std::move(point_buffer),
363 .index_buffer = std::move(index_buffer),
364 .vertex_count = writer.GetIndexCount(),
365 .index_type = IndexTypeFor<IndexT>(),
366 };
367 };
368
369 if (supports_triangle_fan) {
370 FanPathVertexWriter writer(points_ptr, indices_ptr);
371 return tessellate_path(writer);
372 } else {
373 StripPathVertexWriter writer(points_ptr, indices_ptr);
374 return tessellate_path(writer);
375 }
376 }
377
378 DoTessellateConvexInternal(path, point_buffer_, index_buffer_, tolerance);
379
380 if (point_buffer_.empty()) {
381 return VertexBuffer{
382 .vertex_buffer = {},
383 .index_buffer = {},
384 .vertex_count = 0u,
385 .index_type = IndexTypeFor<IndexT>(),
386 };
387 }
388
389 BufferView vertex_buffer = data_host_buffer.Emplace(
390 point_buffer_.data(), sizeof(Point) * point_buffer_.size(),
391 alignof(Point));
392
393 BufferView index_buffer = indexes_host_buffer.Emplace(
394 index_buffer_.data(), sizeof(IndexT) * index_buffer_.size(),
395 alignof(IndexT));
396
397 return VertexBuffer{
398 .vertex_buffer = std::move(vertex_buffer),
399 .index_buffer = std::move(index_buffer),
400 .vertex_count = index_buffer_.size(),
401 .index_type = IndexTypeFor<IndexT>(),
402 };
403 }
impeller::PathTessellator::PathToFilledVertices
static void PathToFilledVertices(const PathSource &source, VertexWriter &writer, Scalar scale)
Definition: path_tessellator.cc:308
impeller::PathTessellator::CountFillStorage
static std::pair< size_t, size_t > CountFillStorage(const PathSource &source, Scalar scale)
Definition: path_tessellator.cc:298
impeller::Point
TPoint< Scalar > Point
Definition: point.h:425

References impeller::PathTessellator::CountFillStorage(), impeller::HostBuffer::Emplace(), impeller::DeviceBuffer::Flush(), impeller::BufferView::GetBuffer(), impeller::BufferView::GetRange(), impeller::Range::offset, impeller::DeviceBuffer::OnGetContents(), impeller::PathTessellator::PathToFilledVertices(), and impeller::VertexBuffer::vertex_buffer.

The documentation for this class was generated from the following file:

- impeller/tessellator/tessellator.cc