Flutter Engine
The Flutter Engine
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
11namespace impeller {
12
14 : center_(center), radius_(radius), stroke_width_(-1.0f) {
15 FML_DCHECK(radius >= 0);
16}
17
19 Scalar radius,
21 : center_(center),
22 radius_(radius),
23 stroke_width_(std::max(stroke_width, 0.0f)) {
24 FML_DCHECK(radius >= 0);
26}
27
28GeometryResult 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
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
47std::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
62 const Rect& rect) const {
63 return false;
64}
65
67 return false;
68}
69
70} // namespace impeller
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...
bool IsAxisAlignedRect() const override
CircleGeometry(const Point &center, Scalar radius)
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition: entity.cc:46
static GeometryResult ComputePositionGeometry(const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Entity &entity, RenderPass &pass)
Definition: geometry.cc:24
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:33
static const char * begin(const StringSlice &s)
Definition: editor.cpp:252
#define FML_DCHECK(condition)
Definition: logging.h:103
static float max(float r, float g, float b)
Definition: hsl.cpp:49
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
float Scalar
Definition: scalar.h:18
TPoint< Scalar > Point
Definition: point.h:322
SK_API sk_sp< PrecompileColorFilter > Matrix()
Definition: ref_ptr.h:256
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47
const Scalar stroke_width
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
static constexpr std::optional< TRect > MakePointBounds(const U &value)
Definition: rect.h:151