Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
compute_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#ifndef FLUTTER_IMPELLER_RENDERER_COMPUTE_TESSELLATOR_H_
6#define FLUTTER_IMPELLER_RENDERER_COMPUTE_TESSELLATOR_H_
7
8#include "flutter/fml/macros.h"
13
14namespace impeller {
15
16//------------------------------------------------------------------------------
17/// @brief A utility that generates triangles of the specified fill type
18/// given a path.
19///
21 public:
23
25
26 static constexpr size_t kMaxCubicCount = 512;
27 static constexpr size_t kMaxQuadCount = 2048;
28 static constexpr size_t kMaxLineCount = 4096;
29 static constexpr size_t kMaxComponentCount =
31
32 enum class Status {
35 kOk,
36 };
37
38 enum class Style {
39 kStroke,
40 // TODO(dnfield): Implement kFill.
41 };
42
50
51 //----------------------------------------------------------------------------
52 /// @brief Generates triangles from the path.
53 /// If the data needs to be synchronized back to the CPU, e.g.
54 /// because one of the buffer views are host visible and will be
55 /// used without creating a blit pass to copy them back, the
56 /// callback is used to determine when the GPU calculation is
57 /// complete and its status.
58 /// On Metal, no additional synchronization is needed as long as
59 /// the buffers are not heap allocated, so no additional
60 /// synchronization mechanism is provided.
61 ///
62 /// @return A |Status| value indicating success or failure of the submission.
63 ///
64 // TODO(dnfield): Provide additional synchronization methods here for Vulkan
65 // and heap allocated buffers on Metal.
67 const Path& path,
68 HostBuffer& host_buffer,
69 const std::shared_ptr<Context>& context,
70 BufferView vertex_buffer,
71 BufferView vertex_buffer_count,
72 const CommandBuffer::CompletionCallback& callback = nullptr) const;
73
74 private:
75 Style style_ = Style::kStroke;
76 Scalar stroke_width_ = 1.0f;
77 Cap stroke_cap_ = Cap::kButt;
78 Join stroke_join_ = Join::kMiter;
79 Scalar miter_limit_ = 4.0f;
80 Scalar cubic_accuracy_ = .1f;
81 Scalar quad_tolerance_ = .1f;
82
84
85 ComputeTessellator& operator=(const ComputeTessellator&) = delete;
86};
87
88} // namespace impeller
89
90#endif // FLUTTER_IMPELLER_RENDERER_COMPUTE_TESSELLATOR_H_
std::function< void(Status)> CompletionCallback
A utility that generates triangles of the specified fill type given a path.
static constexpr size_t kMaxCubicCount
static constexpr size_t kMaxComponentCount
ComputeTessellator & SetStrokeJoin(Join value)
ComputeTessellator & SetStrokeCap(Cap value)
static constexpr size_t kMaxQuadCount
ComputeTessellator & SetMiterLimit(Scalar value)
static constexpr size_t kMaxLineCount
ComputeTessellator & SetStrokeWidth(Scalar value)
ComputeTessellator & SetStyle(Style value)
ComputeTessellator & SetQuadraticTolerance(Scalar value)
ComputeTessellator & SetCubicAccuracy(Scalar value)
Status Tessellate(const Path &path, HostBuffer &host_buffer, const std::shared_ptr< Context > &context, BufferView vertex_buffer, BufferView vertex_buffer_count, const CommandBuffer::CompletionCallback &callback=nullptr) const
Generates triangles from the path. If the data needs to be synchronized back to the CPU,...
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
Definition path.h:51
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
float Scalar
Definition scalar.h:18