12 : p0_(p0), p1_(p1), width_(stroke.width), cap_(stroke.cap) {
13 FML_DCHECK(width_ >= 0);
26 return std::max(width, min_size) * 0.5f;
30 bool allow_zero_length,
42 if (!allow_zero_length) {
46 return {stroke_half_width, 0};
48 return along * stroke_half_width / length;
54 bool extend_endpoints,
63 auto across =
Vector2(along.y, -along.x);
64 corners[0] = p0 - across;
65 corners[1] = p1 - across;
66 corners[2] = p0 + across;
67 corners[3] = p1 + across;
68 if (extend_endpoints) {
91 GeometryResult LineGeometry::GetPositionBuffer(
const ContentContext& renderer,
93 RenderPass& pass)
const {
94 using VT = SolidFillVertexShader::PerVertexData;
103 if (width_ == 0.f &&
transform.IsTranslationScaleOnly()) {
108 p0.x = RoundToHalf(p0.x);
111 p0.y = RoundToHalf(p0.y);
116 Entity fixed_transform = entity.Clone();
121 renderer.GetTessellator().RoundCapLine(
transform, p0, p1, radius);
131 auto& host_buffer = renderer.GetTransientsBuffer();
134 BufferView vertex_buffer = host_buffer.Emplace(
135 count *
sizeof(VT),
alignof(VT), [&corners](uint8_t* buffer) {
136 auto vertices =
reinterpret_cast<VT*
>(buffer);
137 for (
auto& corner : corners) {
144 return GeometryResult{
148 .vertex_buffer = vertex_buffer,
149 .vertex_count = count,
152 .transform = fixed_transform.GetShaderTransform(pass),
164 for (
int i = 0; i < 4; i++) {
175 return coverage.has_value() ? coverage->Contains(rect) :
false;
179 return cap_ !=
Cap::kRound && (p0_.x == p1_.x || p0_.y == p1_.y);
static Scalar ComputeStrokeAlphaCoverage(const Matrix &entity, Scalar stroke_width)
Compute an alpha value to simulate lower coverage of fractional pixel strokes.
static GeometryResult ComputePositionGeometry(const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Entity &entity, RenderPass &pass)
static Vector2 ComputeAlongVector(const Matrix &transform, bool allow_zero_length, Point p0, Point p1, Scalar width)
static Scalar ComputePixelHalfWidth(const Matrix &transform, Scalar width)
LineGeometry(Point p0, Point p1, const StrokeParameters &stroke)
bool IsAxisAlignedRect() const override
Scalar ComputeAlphaCoverage(const Matrix &transform) const override
static bool ComputeCorners(Point corners[4], const Matrix &transform, bool extend_endpoints, Point p0, Point p1, Scalar width)
std::optional< Rect > GetCoverage(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...
@ kNone
Does not use the index buffer.
constexpr float kEhCloseEnough
static const GeometryResult kEmptyResult
static constexpr Scalar kMinStrokeSize
A 4x4 matrix using column-major storage.
A structure to store all of the parameters related to stroking a path or basic geometry object.
constexpr Type GetLength() const
constexpr static std::optional< TRect > MakePointBounds(const U &value)