Flutter Impeller
impeller::GLESVertexWriter Class Reference

A vertex writer that has no hardware requirements. More...

#include <path_component.h>

Inheritance diagram for impeller::GLESVertexWriter:
impeller::VertexWriter

Public Member Functions

 GLESVertexWriter (std::vector< Point > &points, std::vector< uint16_t > &indices)
 
 ~GLESVertexWriter ()=default
 
void EndContour () override
 
void Write (Point point) override
 

Detailed Description

A vertex writer that has no hardware requirements.

Definition at line 92 of file path_component.h.

Constructor & Destructor Documentation

◆ GLESVertexWriter()

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

Definition at line 106 of file path_component.cc.

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

◆ ~GLESVertexWriter()

impeller::GLESVertexWriter::~GLESVertexWriter ( )
default

Member Function Documentation

◆ EndContour()

void impeller::GLESVertexWriter::EndContour ( )
overridevirtual

Implements impeller::VertexWriter.

Definition at line 110 of file path_component.cc.

110  {
111  if (points_.size() == 0u || contour_start_ == points_.size() - 1) {
112  // Empty or first contour.
113  return;
114  }
115 
116  auto start = contour_start_;
117  auto end = points_.size() - 1;
118  // All filled paths are drawn as if they are closed, but if
119  // there is an explicit close then a lineTo to the origin
120  // is inserted. This point isn't strictly necesary to
121  // correctly render the shape and can be dropped.
122  if (points_[end] == points_[start]) {
123  end--;
124  }
125 
126  // Triangle strip break for subsequent contours
127  if (contour_start_ != 0) {
128  auto back = indices_.back();
129  indices_.push_back(back);
130  indices_.push_back(start);
131  indices_.push_back(start);
132 
133  // If the contour has an odd number of points, insert an extra point when
134  // bridging to the next contour to preserve the correct triangle winding
135  // order.
136  if (previous_contour_odd_points_) {
137  indices_.push_back(start);
138  }
139  } else {
140  indices_.push_back(start);
141  }
142 
143  size_t a = start + 1;
144  size_t b = end;
145  while (a < b) {
146  indices_.push_back(a);
147  indices_.push_back(b);
148  a++;
149  b--;
150  }
151  if (a == b) {
152  indices_.push_back(a);
153  previous_contour_odd_points_ = false;
154  } else {
155  previous_contour_odd_points_ = true;
156  }
157  contour_start_ = points_.size();
158 }

References impeller::saturated::b.

◆ Write()

void impeller::GLESVertexWriter::Write ( Point  point)
overridevirtual

Implements impeller::VertexWriter.

Definition at line 160 of file path_component.cc.

160  {
161  points_.push_back(point);
162 }

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