| 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
10 #include "flutter/impeller/entity/contents/contents.h"
11 #include "flutter/impeller/entity/geometry/line_geometry.h"
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
22 struct EffectiveLineParameters {
23 Scalar width;
24 Scalar radius;
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_
impeller::ContentContext
Definition: content_context.h:138
impeller::Contents
Definition: contents.h:31
impeller::Entity
Definition: entity.h:20
impeller::LineContents
Definition: line_contents.h:15
impeller::LineContents::Make
static std::unique_ptr< LineContents > Make(std::unique_ptr< LineGeometry > geometry, Color color)
Definition: line_contents.cc:137
impeller::LineContents::CreateCurveData
static std::vector< uint8_t > CreateCurveData(Scalar width, Scalar radius, Scalar scale)
Definition: line_contents.cc:198
impeller::LineContents::GetCoverage
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.
Definition: line_contents.cc:194
impeller::LineContents::kSampleRadius
static const Scalar kSampleRadius
Definition: line_contents.h:17
impeller::LineContents::CalculatePerVertex
static fml::StatusOr< EffectiveLineParameters > CalculatePerVertex(LineVertexShader::PerVertexData *per_vertex, const LineGeometry *geometry, const Matrix &entity_transform)
Definition: line_contents.cc:227
impeller::LineContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: line_contents.cc:147
impeller::LineGeometry
Definition: line_geometry.h:12
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
contents.h
line_geometry.h
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:18
scale
const Scalar scale
Definition: stroke_path_geometry.cc:319
impeller::Color
Definition: color.h:124
impeller::LineContents::EffectiveLineParameters
Definition: line_contents.h:22
impeller::LineContents::EffectiveLineParameters::radius
Scalar radius
Definition: line_contents.h:24
impeller::LineContents::EffectiveLineParameters::width
Scalar width
Definition: line_contents.h:23
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37