| Flutter Impeller |

tessellator.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #pragma once
6
7 #include <functional>
8 #include <memory>
9 #include <vector>
10
11 #include "flutter/fml/macros.h"
12 #include "impeller/geometry/path.h"
13 #include "impeller/geometry/point.h"
14
15 struct TESStesselator;
16
17 namespace impeller {
18
19 void DestroyTessellator(TESStesselator* tessellator);
20
21 using CTessellator =
22 std::unique_ptr<TESStesselator, decltype(&DestroyTessellator)>;
23
24 enum class WindingOrder {
25 kClockwise,
26 kCounterClockwise,
27 };
28
29 //------------------------------------------------------------------------------
30 /// @brief A utility that generates triangles of the specified fill type
31 /// given a polyline. This happens on the CPU.
32 ///
33 /// @bug This should just be called a triangulator.
34 ///
35 class Tessellator {
36 public:
37 enum class Result {
38 kSuccess,
39 kInputError,
40 kTessellationError,
41 };
42
43 Tessellator();
44
45 ~Tessellator();
46
47 /// @brief An arbitrary value to determine when a multi-contour non-zero fill
48 /// path should be split into multiple tessellations.
49 static constexpr size_t kMultiContourThreshold = 30u;
50
51 /// @brief A callback that returns the results of the tessellation.
52 ///
53 /// The index buffer may not be populated, in which case [indices] will
54 /// be nullptr and indices_count will be 0.
55 using BuilderCallback = std::function<bool(const float* vertices,
56 size_t vertices_count,
57 const uint16_t* indices,
58 size_t indices_count)>;
59
60 //----------------------------------------------------------------------------
61 /// @brief Generates filled triangles from the polyline. A callback is
62 /// invoked once for the entire tessellation.
63 ///
64 /// @param[in] fill_type The fill rule to use when filling.
65 /// @param[in] polyline The polyline
66 /// @param[in] callback The callback, return false to indicate failure.
67 ///
68 /// @return The result status of the tessellation.
69 ///
70 Tessellator::Result Tessellate(FillType fill_type,
71 const Path::Polyline& polyline,
72 const BuilderCallback& callback) const;
73
74 private:
75 CTessellator c_tessellator_;
76
77 FML_DISALLOW_COPY_AND_ASSIGN(Tessellator);
78 };
79
80 } // namespace impeller
path.h
impeller::Tessellator::~Tessellator
~Tessellator()
point.h
impeller::Tessellator
A utility that generates triangles of the specified fill type given a polyline. This happens on the C...
Definition: tessellator.h:35
impeller::Tessellator::Result::kInputError
@ kInputError
impeller::WindingOrder::kClockwise
@ kClockwise
impeller::WindingOrder
WindingOrder
Definition: tessellator.h:24
impeller::Path::Polyline
Definition: path.h:78
impeller::Tessellator::Result::kTessellationError
@ kTessellationError
impeller::Tessellator::kMultiContourThreshold
static constexpr size_t kMultiContourThreshold
An arbitrary value to determine when a multi-contour non-zero fill path should be split into multiple...
Definition: tessellator.h:49
impeller::DestroyTessellator
void DestroyTessellator(TESStesselator *tessellator)
Definition: tessellator.cc:221
impeller::WindingOrder::kCounterClockwise
@ kCounterClockwise
impeller::Tessellator::Result::kSuccess
@ kSuccess
impeller::FillType
FillType
Definition: path.h:29
impeller::Tessellator::Tessellate
Tessellator::Result Tessellate(FillType fill_type, const Path::Polyline &polyline, const BuilderCallback &callback) const
Generates filled triangles from the polyline. A callback is invoked once for the entire tessellation.
Definition: tessellator.cc:61
impeller::Tessellator::Tessellator
Tessellator()
Definition: tessellator.cc:34
impeller::Tessellator::Result
Result
Definition: tessellator.h:37
impeller
Definition: aiks_context.cc:10
impeller::Tessellator::BuilderCallback
std::function< bool(const float *vertices, size_t vertices_count, const uint16_t *indices, size_t indices_count)> BuilderCallback
A callback that returns the results of the tessellation.
Definition: tessellator.h:58
impeller::CTessellator
std::unique_ptr< TESStesselator, decltype(&DestroyTessellator)> CTessellator
Definition: tessellator.h:22