Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
impeller
geometry
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
5
#include "
impeller/geometry/wangs_formula.h
"
6
7
namespace
impeller
{
8
9
namespace
{
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.
14
constexpr
static
Scalar
kPrecision = 4;
15
16
constexpr
Scalar
length
(
Point
n) {
17
Point
nn = n * n;
18
return
std::sqrt(nn.x + nn.y);
19
}
20
21
}
// namespace
22
23
Scalar
ComputeCubicSubdivisions
(
Scalar
scale_factor,
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
34
Scalar
ComputeQuadradicSubdivisions
(
Scalar
scale_factor,
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
42
Scalar
ComputeQuadradicSubdivisions
(
Scalar
scale_factor,
43
const
QuadraticPathComponent
& quad) {
44
return
ComputeQuadradicSubdivisions
(scale_factor, quad.
p1
, quad.
cp
, quad.
p2
);
45
}
46
47
Scalar
ComputeCubicSubdivisions
(
float
scale_factor,
48
const
CubicPathComponent
& cub) {
49
return
ComputeCubicSubdivisions
(scale_factor, cub.
p1
, cub.
cp1
, cub.
cp2
,
50
cub.
p2
);
51
}
52
53
}
// namespace impeller
b
static bool b
Definition
ffi_native_test_module.c:74
a
struct MyStruct a[10]
length
size_t length
Definition
key_event_handler.cc:41
impeller
Definition
texture.h:18
impeller::Scalar
float Scalar
Definition
scalar.h:18
impeller::Point
TPoint< Scalar > Point
Definition
point.h:316
impeller::ComputeQuadradicSubdivisions
Scalar ComputeQuadradicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2)
Definition
wangs_formula.cc:34
impeller::ComputeCubicSubdivisions
Scalar ComputeCubicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2, Point p3)
Definition
wangs_formula.cc:23
impeller::CubicPathComponent
Definition
path_component.h:79
impeller::CubicPathComponent::p1
Point p1
Definition
path_component.h:81
impeller::CubicPathComponent::cp1
Point cp1
Definition
path_component.h:83
impeller::CubicPathComponent::cp2
Point cp2
Definition
path_component.h:85
impeller::CubicPathComponent::p2
Point p2
Definition
path_component.h:87
impeller::QuadraticPathComponent
Definition
path_component.h:43
impeller::QuadraticPathComponent::p2
Point p2
Definition
path_component.h:49
impeller::QuadraticPathComponent::cp
Point cp
Definition
path_component.h:47
impeller::QuadraticPathComponent::p1
Point p1
Definition
path_component.h:45
impeller::TPoint< Scalar >
wangs_formula.h
Generated on Fri Apr 26 2024 06:14:11 for Flutter Engine by
1.9.8