Flutter Engine
The Flutter Engine
wangs_formula.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
7namespace impeller {
8
9namespace {
10
11// Don't allow linearized segments to be off by more than 1/4th of a pixel from
12// the true curve. This value should be scaled by the max basis of the
13// X and Y directions.
14constexpr static Scalar kPrecision = 4;
15
16constexpr Scalar length(Point n) {
17 Point nn = n * n;
18 return std::sqrt(nn.x + nn.y);
19}
20
21} // namespace
22
24 Point p0,
25 Point p1,
26 Point p2,
27 Point p3) {
28 Scalar k = scale_factor * .75f * kPrecision;
29 Point a = (p0 - p1 * 2 + p2).Abs();
30 Point b = (p1 - p2 * 2 + p3).Abs();
31 return std::sqrt(k * length(a.Max(b)));
32}
33
35 Point p0,
36 Point p1,
37 Point p2) {
38 Scalar k = scale_factor * .25f * kPrecision;
39 return std::sqrt(k * length(p0 - p1 * 2 + p2));
40}
41
43 const QuadraticPathComponent& quad) {
44 return ComputeQuadradicSubdivisions(scale_factor, quad.p1, quad.cp, quad.p2);
45}
46
48 const CubicPathComponent& cub) {
49 return ComputeCubicSubdivisions(scale_factor, cub.p1, cub.cp1, cub.cp2,
50 cub.p2);
51}
52
53} // namespace impeller
static bool b
struct MyStruct a[10]
size_t length
float Scalar
Definition: scalar.h:18
TPoint< Scalar > Point
Definition: point.h:322
Scalar ComputeQuadradicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2)
Scalar ComputeCubicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2, Point p3)
static constexpr float kPrecision
Definition: Tessellation.h:29
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition: SkVx.h:706