| Flutter Impeller |

Public Member Functions | List of all members
impeller::VertexWriter Class Reference

An interface for generating a multi contour polyline as a triangle strip. More...

`#include <path_component.h>`

## Public Member Functions
| VertexWriter (std::vector< Point > &points, std::vector< uint16_t > &indices)
| ~VertexWriter ()=default
void | EndContour ()
void | Write (Point point)

## Detailed Description

An interface for generating a multi contour polyline as a triangle strip.

Definition at line 20 of file path_component.h.

## Constructor & Destructor Documentation

## ◆ VertexWriter()

impeller::VertexWriter::VertexWriter | ( | std::vector< Point > & | points,
|  | std::vector< uint16_t > & | indices
| ) |  |
| explicit

Definition at line 13 of file path_component.cc.

15 : points_(points), indices_(indices) {}

## ◆ ~VertexWriter()

impeller::VertexWriter::~VertexWriter | ( |  | ) |
| default

## Member Function Documentation

## ◆ EndContour()

void impeller::VertexWriter::EndContour | ( |  | ) |

Definition at line 17 of file path_component.cc.

17 {
18 if (points_.size() == 0u || contour_start_ == points_.size() - 1) {
19 // Empty or first contour.
20 return;
21 }
22
23 auto start = contour_start_;
24 auto end = points_.size() - 1;
25 // All filled paths are drawn as if they are closed, but if
26 // there is an explicit close then a lineTo to the origin
27 // is inserted. This point isn't strictly necesary to
28 // correctly render the shape and can be dropped.
29 if (points_[end] == points_[start]) {
30 end--;
31 }
32
33 // Triangle strip break for subsequent contours
34 if (contour_start_ != 0) {
35 auto back = indices_.back();
36 indices_.push_back(back);
37 indices_.push_back(start);
38 indices_.push_back(start);
39
40 // If the contour has an odd number of points, insert an extra point when
41 // bridging to the next contour to preserve the correct triangle winding
42 // order.
43 if (previous_contour_odd_points_) {
44 indices_.push_back(start);
45 }
46 } else {
47 indices_.push_back(start);
48 }
49
50 size_t a = start + 1;
51 size_t b = end;
52 while (a < b) {
53 indices_.push_back(a);
54 indices_.push_back(b);
55 a++;
56 b--;
57 }
58 if (a == b) {
59 indices_.push_back(a);
60 previous_contour_odd_points_ = false;
61 } else {
62 previous_contour_odd_points_ = true;
63 }
64 contour_start_ = points_.size();
65 }

References impeller::saturated::b.

Referenced by impeller::Path::WritePolyline().

## ◆ Write()

void impeller::VertexWriter::Write | ( | Point | point | ) |

Definition at line 67 of file path_component.cc.

67 {
68 points_.push_back(point);
69 }

Referenced by impeller::QuadraticPathComponent::ToLinearPathComponents(), impeller::CubicPathComponent::ToLinearPathComponents(), and impeller::Path::WritePolyline().

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

- impeller/geometry/path_component.h
- impeller/geometry/path_component.cc

impeller::saturated::b
SI b
Definition: saturated_math.h:87