Flutter Impeller
line_contents.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_ENTITY_CONTENTS_LINE_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_LINE_CONTENTS_H_
7 
8 #include <memory>
9 
12 #include "impeller/entity/line.vert.h"
13 
14 namespace impeller {
15 class LineContents : public Contents {
16  public:
17  static const Scalar kSampleRadius;
18  static std::vector<uint8_t> CreateCurveData(Scalar width,
19  Scalar radius,
20  Scalar scale);
21 
25  };
26 
27  /// Calculates the values needed for the vertex shader, per vertex.
28  /// Returns the effective line parameters that are used. These differ from the
29  /// ones provided by `geometry` when the line gets clamped for being too thin.
30  static fml::StatusOr<EffectiveLineParameters> CalculatePerVertex(
31  LineVertexShader::PerVertexData* per_vertex,
32  const LineGeometry* geometry,
33  const Matrix& entity_transform);
34 
35  static std::unique_ptr<LineContents> Make(
36  std::unique_ptr<LineGeometry> geometry,
37  Color color);
38 
39  bool Render(const ContentContext& renderer,
40  const Entity& entity,
41  RenderPass& pass) const override;
42 
43  std::optional<Rect> GetCoverage(const Entity& entity) const override;
44 
45  private:
46  explicit LineContents(std::unique_ptr<LineGeometry> geometry, Color color);
47 
48  std::unique_ptr<LineGeometry> geometry_;
49  Color color_;
50 };
51 } // namespace impeller
52 
53 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_LINE_CONTENTS_H_
static std::unique_ptr< LineContents > Make(std::unique_ptr< LineGeometry > geometry, Color color)
static std::vector< uint8_t > CreateCurveData(Scalar width, Scalar radius, Scalar scale)
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
static const Scalar kSampleRadius
Definition: line_contents.h:17
static fml::StatusOr< EffectiveLineParameters > CalculatePerVertex(LineVertexShader::PerVertexData *per_vertex, const LineGeometry *geometry, const Matrix &entity_transform)
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
float Scalar
Definition: scalar.h:19
A 4x4 matrix using column-major storage.
Definition: matrix.h:37