11 std::optional<Rect> inner_rect)
12 : path_(path), inner_rect_(inner_rect) {}
29 points.data(), points.size() *
sizeof(
Point),
alignof(
Point));
31 indices.data(), indices.size() *
sizeof(uint16_t),
alignof(uint16_t));
37 .vertex_buffer = vertex_buffer,
40 .prevent_overdraw =
false,
47 [&vertex_buffer, &host_buffer](
48 const float* vertices,
size_t vertices_count,
const uint16_t* indices,
49 size_t indices_count) {
50 vertex_buffer.vertex_buffer = host_buffer.Emplace(
51 vertices, vertices_count * sizeof(float) * 2, alignof(float));
52 if (indices != nullptr) {
53 vertex_buffer.index_buffer = host_buffer.Emplace(
54 indices, indices_count * sizeof(uint16_t), alignof(uint16_t));
55 vertex_buffer.vertex_count = indices_count;
56 vertex_buffer.index_type = IndexType::k16bit;
58 vertex_buffer.index_buffer = {};
64 if (tesselation_result != Tessellator::Result::kSuccess) {
67 return GeometryResult{
68 .type = PrimitiveType::kTriangle,
69 .vertex_buffer = vertex_buffer,
72 .prevent_overdraw =
false,
77 GeometryResult FillPathGeometry::GetPositionUVBuffer(
78 Rect texture_coverage,
79 Matrix effect_transform,
80 const ContentContext& renderer,
83 using VS = TextureFillVertexShader;
85 if (path_.GetFillType() == FillType::kNonZero &&
88 path_.CreatePolyline(entity.GetTransformation().GetMaxBasisLength()));
90 VertexBufferBuilder<VS::PerVertexData> vertex_builder;
91 vertex_builder.Reserve(points.size());
92 vertex_builder.ReserveIndices(indices.size());
93 for (
auto i = 0u; i < points.size(); i++) {
94 VS::PerVertexData data;
95 data.position = points[i];
96 data.texture_coords = effect_transform *
97 (points[i] - texture_coverage.origin) /
98 texture_coverage.size;
99 vertex_builder.AppendVertex(data);
101 for (
auto i = 0u; i < indices.size(); i++) {
102 vertex_builder.AppendIndex(indices[i]);
105 return GeometryResult{
106 .type = PrimitiveType::kTriangle,
108 vertex_builder.CreateVertexBuffer(pass.GetTransientsBuffer()),
109 .transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
110 entity.GetTransformation(),
111 .prevent_overdraw =
false,
115 VertexBufferBuilder<VS::PerVertexData> vertex_builder;
116 auto tesselation_result = renderer.GetTessellator()->Tessellate(
118 path_.CreatePolyline(entity.GetTransformation().GetMaxBasisLength()),
119 [&vertex_builder, &texture_coverage, &effect_transform](
120 const float* vertices,
size_t vertices_count,
const uint16_t* indices,
121 size_t indices_count) {
122 for (
auto i = 0u; i < vertices_count * 2; i += 2) {
123 VS::PerVertexData data;
124 Point vtx = {vertices[i], vertices[i + 1]};
126 data.texture_coords = effect_transform *
127 (vtx - texture_coverage.origin) /
128 texture_coverage.size;
129 vertex_builder.AppendVertex(data);
131 FML_DCHECK(vertex_builder.GetVertexCount() == vertices_count);
132 if (indices !=
nullptr) {
133 for (
auto i = 0u; i < indices_count; i++) {
134 vertex_builder.AppendIndex(indices[i]);
139 if (tesselation_result != Tessellator::Result::kSuccess) {
142 return GeometryResult{
143 .type = PrimitiveType::kTriangle,
145 vertex_builder.CreateVertexBuffer(pass.GetTransientsBuffer()),
146 .transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
147 entity.GetTransformation(),
148 .prevent_overdraw =
false,
156 std::optional<Rect> FillPathGeometry::GetCoverage(
157 const Matrix& transform)
const {
158 return path_.GetTransformedBoundingBox(transform);
161 bool FillPathGeometry::CoversArea(
const Matrix& transform,
162 const Rect& rect)
const {
163 if (!inner_rect_.has_value()) {