Flutter Engine
 
Loading...
Searching...
No Matches
tessellator_libtess.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#ifndef FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_LIBTESS_H_
6#define FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_LIBTESS_H_
7
8#include <functional>
9#include <memory>
10
12
13struct TESStesselator;
14
15namespace impeller {
16
17void DestroyTessellator(TESStesselator* tessellator);
18
20 std::unique_ptr<TESStesselator, decltype(&DestroyTessellator)>;
21
22//------------------------------------------------------------------------------
23/// @brief An extended tessellator that offers arbitrary/concave
24/// tessellation via the libtess2 library.
25///
26/// This object is not thread safe, and its methods must not be
27/// called from multiple threads.
28///
30 public:
32
34
35 enum class Result {
39 };
40
41 /// @brief A callback that returns the results of the tessellation.
42 ///
43 /// The index buffer may not be populated, in which case [indices] will
44 /// be nullptr and indices_count will be 0.
45 using BuilderCallback = std::function<bool(const float* vertices,
46 size_t vertices_count,
47 const uint16_t* indices,
48 size_t indices_count)>;
49
50 //----------------------------------------------------------------------------
51 /// @brief Generates filled triangles from the path. A callback is
52 /// invoked once for the entire tessellation.
53 ///
54 /// @param[in] source The path source to tessellate.
55 /// @param[in] tolerance The tolerance value for conversion of the path to
56 /// a polyline. This value is often derived from the
57 /// Matrix::GetMaxBasisLength of the CTM applied to the
58 /// path for rendering.
59 /// @param[in] callback The callback, return false to indicate failure.
60 ///
61 /// @return The result status of the tessellation.
62 ///
64 Scalar tolerance,
66
67 private:
68 CTessellator c_tessellator_;
69
71
72 TessellatorLibtess& operator=(const TessellatorLibtess&) = delete;
73};
74
75} // namespace impeller
76
77#endif // FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_LIBTESS_H_
An extended tessellator that offers arbitrary/concave tessellation via the libtess2 library.
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.
TessellatorLibtess::Result Tessellate(const PathSource &source, Scalar tolerance, const BuilderCallback &callback)
Generates filled triangles from the path. A callback is invoked once for the entire tessellation.
FlutterDesktopBinaryReply callback
float Scalar
Definition scalar.h:19
void DestroyTessellator(TESStesselator *tessellator)
std::unique_ptr< TESStesselator, decltype(&DestroyTessellator)> CTessellator