| 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 A callback that returns the results of the tessellation.
48 ///
49 /// The index buffer may not be populated, in which case [indices] will
50 /// be nullptr and indices_count will be 0.
51 using BuilderCallback = std::function<bool(const float* vertices,
52 size_t vertices_count,
53 const uint16_t* indices,
54 size_t indices_count)>;
55
56 //----------------------------------------------------------------------------
57 /// @brief Generates filled triangles from the polyline. A callback is
58 /// invoked once for the entire tessellation.
59 ///
60 /// @param[in] fill_type The fill rule to use when filling.
61 /// @param[in] polyline The polyline
62 /// @param[in] callback The callback, return false to indicate failure.
63 ///
64 /// @return The result status of the tessellation.
65 ///
66 Tessellator::Result Tessellate(FillType fill_type,
67 const Path::Polyline& polyline,
68 const BuilderCallback& callback) const;
69
70 private:
71 CTessellator c_tessellator_;
72
73 FML_DISALLOW_COPY_AND_ASSIGN(Tessellator);
74 };
75
76 } // 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::DestroyTessellator
void DestroyTessellator(TESStesselator *tessellator)
Definition: tessellator.cc:162
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:54
impeller::CTessellator
std::unique_ptr< TESStesselator, decltype(&DestroyTessellator)> CTessellator
Definition: tessellator.h:22