| Flutter Impeller |

line_geometry.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_GEOMETRY_LINE_GEOMETRY_H_
6 #define FLUTTER_IMPELLER_ENTITY_GEOMETRY_LINE_GEOMETRY_H_
7
8 #include "impeller/entity/geometry/geometry.h"
9
10 namespace impeller {
11
12 class LineGeometry final : public Geometry {
13 public:
14 explicit LineGeometry(Point p0, Point p1, Scalar width, Cap cap);
15
16 ~LineGeometry() override;
17
18 static Scalar ComputePixelHalfWidth(const Matrix& transform, Scalar width);
19
20 // |Geometry|
21 bool CoversArea(const Matrix& transform, const Rect& rect) const override;
22
23 // |Geometry|
24 bool IsAxisAlignedRect() const override;
25
26 Scalar ComputeAlphaCoverage(const Matrix& transform) const override;
27
28 private:
29 // Computes the 4 corners of a rectangle that defines the line and
30 // possibly extended endpoints which will be rendered under the given
31 // transform, and returns true if such a rectangle is defined.
32 //
33 // The coordinates will be generated in the original coordinate system
34 // of the line end points and the transform will only be used to determine
35 // the minimum line width.
36 //
37 // For kButt and kSquare end caps the ends should always be exteded as
38 // per that decoration, but for kRound caps the ends might be extended
39 // if the goal is to get a conservative bounds and might not be extended
40 // if the calling code is planning to draw the round caps on the ends.
41 //
42 // @return true if the transform and width were not degenerate
43 bool ComputeCorners(Point corners[4],
44 const Matrix& transform,
45 bool extend_endpoints) const;
46
47 Vector2 ComputeAlongVector(const Matrix& transform,
48 bool allow_zero_length) const;
49
50 // |Geometry|
51 GeometryResult GetPositionBuffer(const ContentContext& renderer,
52 const Entity& entity,
53 RenderPass& pass) const override;
54
55 // |Geometry|
56 std::optional<Rect> GetCoverage(const Matrix& transform) const override;
57
58 Point p0_;
59 Point p1_;
60 Scalar width_;
61 Cap cap_;
62
63 LineGeometry(const LineGeometry&) = delete;
64
65 LineGeometry& operator=(const LineGeometry&) = delete;
66 };
67
68 } // namespace impeller
69
70 #endif // FLUTTER_IMPELLER_ENTITY_GEOMETRY_LINE_GEOMETRY_H_
impeller::Scalar
float Scalar
Definition: scalar.h:18
geometry.h
impeller::LineGeometry::ComputeAlphaCoverage
Scalar ComputeAlphaCoverage(const Matrix &transform) const override
Definition: line_geometry.cc:70
impeller::LineGeometry::LineGeometry
LineGeometry(Point p0, Point p1, Scalar width, Cap cap)
Definition: line_geometry.cc:10
impeller::Entity
Definition: entity.h:20
impeller::LineGeometry::CoversArea
bool CoversArea(const Matrix &transform, const Rect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all surface ar...
Definition: line_geometry.cc:131
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:214
impeller::LineGeometry
Definition: line_geometry.h:12
impeller::GeometryResult
Definition: geometry.h:21
impeller::LineGeometry::IsAxisAlignedRect
bool IsAxisAlignedRect() const override
Definition: line_geometry.cc:139
impeller::LineGeometry::ComputePixelHalfWidth
static Scalar ComputePixelHalfWidth(const Matrix &transform, Scalar width)
Definition: line_geometry.cc:17
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
impeller::Geometry
Definition: geometry.h:50
impeller::TPoint< Scalar >
impeller
Definition: allocation.cc:12
impeller::ContentContext
Definition: content_context.h:371
impeller::TRect< Scalar >
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::Cap
Cap
Definition: path.h:19
impeller::LineGeometry::~LineGeometry
~LineGeometry() override