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