Flutter Impeller
circle_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
5
#include <algorithm>
6
7
#include "
flutter/impeller/entity/geometry/circle_geometry.h
"
8
9
#include "
flutter/impeller/entity/geometry/line_geometry.h
"
10
11
namespace
impeller
{
12
13
CircleGeometry::CircleGeometry
(
const
Point
& center,
Scalar
radius)
14
: center_(center), radius_(radius), stroke_width_(-1.0f) {
15
FML_DCHECK(radius >= 0);
16
}
17
18
CircleGeometry::CircleGeometry
(
const
Point
& center,
19
Scalar
radius,
20
Scalar
stroke_width
)
21
: center_(center),
22
radius_(radius),
23
stroke_width_(
std
::max(
stroke_width
, 0.0f)) {
24
FML_DCHECK(radius >= 0);
25
FML_DCHECK(
stroke_width
>= 0);
26
}
27
28
GeometryResult
CircleGeometry::GetPositionBuffer(
const
ContentContext
& renderer,
29
const
Entity
& entity,
30
RenderPass
& pass)
const
{
31
auto
&
transform
= entity.
GetTransform
();
32
33
Scalar
half_width = stroke_width_ < 0 ? 0.0
34
:
LineGeometry::ComputePixelHalfWidth
(
35
transform
, stroke_width_);
36
37
std::shared_ptr<Tessellator> tessellator = renderer.
GetTessellator
();
38
39
// We call the StrokedCircle method which will simplify to a
40
// FilledCircleGenerator if the inner_radius is <= 0.
41
auto
generator =
42
tessellator->StrokedCircle(
transform
, center_, radius_, half_width);
43
44
return
ComputePositionGeometry
(renderer, generator, entity, pass);
45
}
46
47
std::optional<Rect> CircleGeometry::GetCoverage(
const
Matrix&
transform
)
const
{
48
Point
corners[4]{
49
{center_.
x
, center_.
y
- radius_},
50
{center_.
x
+ radius_, center_.
y
},
51
{center_.
x
, center_.
y
+ radius_},
52
{center_.
x
- radius_, center_.
y
},
53
};
54
55
for
(
int
i = 0; i < 4; i++) {
56
corners[i] =
transform
* corners[i];
57
}
58
return
Rect::MakePointBounds
(std::begin(corners), std::end(corners));
59
}
60
61
bool
CircleGeometry::CoversArea
(
const
Matrix
&
transform
,
62
const
Rect
& rect)
const
{
63
return
false
;
64
}
65
66
bool
CircleGeometry::IsAxisAlignedRect
()
const
{
67
return
false
;
68
}
69
70
}
// namespace impeller
impeller::TPoint::y
Type y
Definition:
point.h:31
impeller::Scalar
float Scalar
Definition:
scalar.h:18
impeller::CircleGeometry::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:
circle_geometry.cc:61
impeller::Entity::GetTransform
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition:
entity.cc:46
stroke_width
const Scalar stroke_width
Definition:
stroke_path_geometry.cc:304
impeller::TRect< Scalar >::MakePointBounds
constexpr static std::optional< TRect > MakePointBounds(const U &value)
Definition:
rect.h:151
impeller::Geometry::ComputePositionGeometry
static GeometryResult ComputePositionGeometry(const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Entity &entity, RenderPass &pass)
Definition:
geometry.cc:24
impeller::Entity
Definition:
entity.h:20
impeller::Point
TPoint< Scalar > Point
Definition:
point.h:322
transform
Matrix transform
Definition:
gaussian_blur_filter_contents.cc:231
impeller::GeometryResult
Definition:
geometry.h:19
impeller::CircleGeometry::IsAxisAlignedRect
bool IsAxisAlignedRect() const override
Definition:
circle_geometry.cc:66
impeller::ContentContext::GetTessellator
std::shared_ptr< Tessellator > GetTessellator() const
Definition:
content_context.cc:549
impeller::LineGeometry::ComputePixelHalfWidth
static Scalar ComputePixelHalfWidth(const Matrix &transform, Scalar width)
Definition:
line_geometry.cc:14
impeller::TPoint::x
Type x
Definition:
point.h:30
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition:
render_pass.h:33
std
Definition:
comparable.h:95
impeller::TPoint< Scalar >
line_geometry.h
impeller::CircleGeometry::CircleGeometry
CircleGeometry(const Point ¢er, Scalar radius)
Definition:
circle_geometry.cc:13
circle_geometry.h
impeller
Definition:
aiks_blend_unittests.cc:18
impeller::ContentContext
Definition:
content_context.h:366
impeller::TRect< Scalar >
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition:
matrix.h:37
impeller
entity
geometry
circle_geometry.cc
Generated by
1.8.17