Flutter Engine
 
Loading...
Searching...
No Matches
arc_geometry.cc
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
6
8
9namespace impeller {
10
12 : arc_(arc), stroke_width_(-1.0f), cap_(Cap::kButt) {}
13
15 : arc_(arc), stroke_width_(stroke.width), cap_(stroke.cap) {
18}
19
21
22// |Geometry|
24 if (stroke_width_ < 0) {
25 return 1;
26 }
28}
29
30GeometryResult ArcGeometry::GetPositionBuffer(const ContentContext& renderer,
31 const Entity& entity,
32 RenderPass& pass) const {
33 auto& transform = entity.GetTransform();
34
35 if (stroke_width_ < 0) {
36 auto generator = renderer.GetTessellator().FilledArc(
37 transform, arc_,
39
40 return ComputePositionGeometry(renderer, generator, entity, pass);
41 } else {
44 Scalar half_width =
46
47 auto generator =
48 renderer.GetTessellator().StrokedArc(transform, arc_, cap_, half_width);
49
50 return ComputePositionGeometry(renderer, generator, entity, pass);
51 }
52}
53
54std::optional<Rect> ArcGeometry::GetCoverage(const Matrix& transform) const {
55 Scalar padding = //
56 stroke_width_ < 0
57 ? 0.0
59
60 if (arc_.IsFullCircle()) {
61 // Simpler calculation than below and we don't pad by the extra distance
62 // that square caps take up because we aren't going to use caps.
64 transform);
65 }
66
67 if (cap_ == Cap::kSquare) {
69 }
70
72 transform);
73}
74
75bool ArcGeometry::CoversArea(const Matrix& transform, const Rect& rect) const {
76 return false;
77}
78
80 return false;
81}
82
83} // namespace impeller
bool IsAxisAlignedRect() const override
Scalar ComputeAlphaCoverage(const Matrix &transform) const override
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...
ArcGeometry(const Arc &arc)
virtual bool SupportsTriangleFan() const =0
Whether the primitive type TriangleFan is supported by the backend.
const Capabilities & GetDeviceCapabilities() const
Tessellator & GetTessellator() const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition entity.cc:44
static Scalar ComputeStrokeAlphaCoverage(const Matrix &entity, Scalar stroke_width)
Compute an alpha value to simulate lower coverage of fractional pixel strokes.
Definition geometry.cc:149
static GeometryResult ComputePositionGeometry(const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Entity &entity, RenderPass &pass)
Definition geometry.cc:26
static Scalar ComputePixelHalfWidth(const Matrix &transform, Scalar width)
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:30
ArcVertexGenerator StrokedArc(const Matrix &view_transform, const Arc &arc, Cap cap, Scalar half_width)
Create a |VertexGenerator| that can produce vertices for a stroked arc inscribed within the given ova...
ArcVertexGenerator FilledArc(const Matrix &view_transform, const Arc &arc, bool supports_triangle_fans)
Create a |VertexGenerator| that can produce vertices for a stroked arc inscribed within the given ova...
#define FML_DCHECK(condition)
Definition logging.h:122
Vector2 padding
The halo padding in source space.
float Scalar
Definition scalar.h:19
Cap
An enum that describes ways to decorate the end of a path contour.
constexpr float kSqrt2
Definition constants.h:47
int32_t width
Rect GetTightArcBounds() const
Definition arc.cc:59
constexpr bool IncludeCenter() const
Definition arc.h:110
constexpr bool IsFullCircle() const
Definition arc.h:114
constexpr bool IsPerfectCircle() const
Definition arc.h:112
const Rect & GetOvalBounds() const
Return the bounds of the oval in which this arc is inscribed.
Definition arc.h:94
A 4x4 matrix using column-major storage.
Definition matrix.h:37
A structure to store all of the parameters related to stroking a path or basic geometry object.
constexpr TRect TransformAndClipBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle, clipped against the near clippin...
Definition rect.h:438
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
Definition rect.h:618