Fixup tidy checks in impeller/geometry.

This commit is contained in:
Chinmay Garde
2021-07-20 13:30:09 -07:00
committed by Dan Field
parent 3349f7c78c
commit a6f7f6bef7
6 changed files with 63 additions and 61 deletions

View File

@@ -363,27 +363,27 @@ uint64_t Matrix::Decomposition::GetComponentsMask() const {
Quaternion noRotation(0.0, 0.0, 0.0, 1.0);
if (rotation != noRotation) {
mask = mask | static_cast<uint64_t>(Component::Rotation);
mask = mask | static_cast<uint64_t>(Component::kRotation);
}
Vector4 defaultPerspective(0.0, 0.0, 0.0, 1.0);
if (perspective != defaultPerspective) {
mask = mask | static_cast<uint64_t>(Component::Perspective);
mask = mask | static_cast<uint64_t>(Component::kPerspective);
}
Shear noShear(0.0, 0.0, 0.0);
if (shear != noShear) {
mask = mask | static_cast<uint64_t>(Component::Shear);
mask = mask | static_cast<uint64_t>(Component::kShear);
}
Vector3 defaultScale(1.0, 1.0, 1.0);
if (scale != defaultScale) {
mask = mask | static_cast<uint64_t>(Component::Scale);
mask = mask | static_cast<uint64_t>(Component::kScale);
}
Vector3 defaultTranslation(0.0, 0.0, 0.0);
if (translation != defaultTranslation) {
mask = mask | static_cast<uint64_t>(Component::Translation);
mask = mask | static_cast<uint64_t>(Component::kTranslation);
}
return mask;

View File

@@ -43,11 +43,11 @@ struct Matrix {
Quaternion rotation;
enum class Component {
Translation = 1 << 0,
Scale = 1 << 1,
Shear = 1 << 2,
Perspective = 1 << 3,
Rotation = 1 << 4,
kTranslation = 1 << 0,
kScale = 1 << 1,
kShear = 1 << 2,
kPerspective = 1 << 3,
kRotation = 1 << 4,
};
uint64_t GetComponentsMask() const;

View File

@@ -16,19 +16,19 @@ size_t Path::GetComponentCount() const {
Path& Path::AddLinearComponent(Point p1, Point p2) {
linears_.emplace_back(p1, p2);
components_.emplace_back(ComponentType::Linear, linears_.size() - 1);
components_.emplace_back(ComponentType::kLinear, linears_.size() - 1);
return *this;
}
Path& Path::AddQuadraticComponent(Point p1, Point cp, Point p2) {
quads_.emplace_back(p1, cp, p2);
components_.emplace_back(ComponentType::Quadratic, quads_.size() - 1);
components_.emplace_back(ComponentType::kQuadratic, quads_.size() - 1);
return *this;
}
Path& Path::AddCubicComponent(Point p1, Point cp1, Point cp2, Point p2) {
cubics_.emplace_back(p1, cp1, cp2, p2);
components_.emplace_back(ComponentType::Cubic, cubics_.size() - 1);
components_.emplace_back(ComponentType::kCubic, cubics_.size() - 1);
return *this;
}
@@ -38,17 +38,17 @@ void Path::EnumerateComponents(Applier<LinearPathComponent> linearApplier,
size_t currentIndex = 0;
for (const auto& component : components_) {
switch (component.type) {
case ComponentType::Linear:
case ComponentType::kLinear:
if (linearApplier) {
linearApplier(currentIndex, linears_[component.index]);
}
break;
case ComponentType::Quadratic:
case ComponentType::kQuadratic:
if (quadApplier) {
quadApplier(currentIndex, quads_[component.index]);
}
break;
case ComponentType::Cubic:
case ComponentType::kCubic:
if (cubicApplier) {
cubicApplier(currentIndex, cubics_[component.index]);
}
@@ -64,7 +64,7 @@ bool Path::GetLinearComponentAtIndex(size_t index,
return false;
}
if (components_[index].type != ComponentType::Linear) {
if (components_[index].type != ComponentType::kLinear) {
return false;
}
@@ -79,7 +79,7 @@ bool Path::GetQuadraticComponentAtIndex(
return false;
}
if (components_[index].type != ComponentType::Quadratic) {
if (components_[index].type != ComponentType::kQuadratic) {
return false;
}
@@ -93,7 +93,7 @@ bool Path::GetCubicComponentAtIndex(size_t index,
return false;
}
if (components_[index].type != ComponentType::Cubic) {
if (components_[index].type != ComponentType::kCubic) {
return false;
}
@@ -107,7 +107,7 @@ bool Path::UpdateLinearComponentAtIndex(size_t index,
return false;
}
if (components_[index].type != ComponentType::Linear) {
if (components_[index].type != ComponentType::kLinear) {
return false;
}
@@ -122,7 +122,7 @@ bool Path::UpdateQuadraticComponentAtIndex(
return false;
}
if (components_[index].type != ComponentType::Quadratic) {
if (components_[index].type != ComponentType::kQuadratic) {
return false;
}
@@ -136,7 +136,7 @@ bool Path::UpdateCubicComponentAtIndex(size_t index,
return false;
}
if (components_[index].type != ComponentType::Cubic) {
if (components_[index].type != ComponentType::kCubic) {
return false;
}
@@ -153,17 +153,17 @@ void Path::EnumerateSmoothPoints(
for (const auto& component : components_) {
switch (component.type) {
case ComponentType::Linear: {
case ComponentType::kLinear: {
if (!enumerator(linears_[component.index].SmoothPoints())) {
return;
}
} break;
case ComponentType::Quadratic: {
case ComponentType::kQuadratic: {
if (!enumerator(quads_[component.index].SmoothPoints(approximation))) {
return;
}
} break;
case ComponentType::Cubic: {
case ComponentType::kCubic: {
if (!enumerator(cubics_[component.index].SmoothPoints(approximation))) {
return;
}
@@ -180,7 +180,7 @@ Rect Path::GetBoundingBox() const {
}
for (const auto& quad : quads_) {
box = box.WithPoints(quad.Sxtrema());
box = box.WithPoints(quad.Extrema());
}
for (const auto& cubic : cubics_) {

View File

@@ -13,10 +13,10 @@ namespace impeller {
class Path {
public:
enum class ComponentType : uint8_t {
Linear,
Quadratic,
Cubic,
enum class ComponentType {
kLinear,
kQuadratic,
kCubic,
};
Path();
@@ -61,7 +61,7 @@ class Path {
private:
struct ComponentIndexPair {
ComponentType type = ComponentType::Linear;
ComponentType type = ComponentType::kLinear;
size_t index = 0;
ComponentIndexPair() {}

View File

@@ -91,7 +91,7 @@ std::vector<Point> QuadraticPathComponent::SmoothPoints(
return elevated.SmoothPoints(approximation);
}
std::vector<Point> QuadraticPathComponent::Sxtrema() const {
std::vector<Point> QuadraticPathComponent::Extrema() const {
CubicPathComponent elevated(*this);
return elevated.Extrema();
}
@@ -193,12 +193,12 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx,
}
if (d2 > d3) {
if (d2 < approx.distanceToleranceSquare) {
if (d2 < approx.distance_tolerance_square) {
points.emplace_back(p2);
return;
}
} else {
if (d3 < approx.distanceToleranceSquare) {
if (d3 < approx.distance_tolerance_square) {
points.emplace_back(p3);
return;
}
@@ -208,8 +208,9 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx,
/*
* p1, p2, p4 are collinear, p3 is significant.
*/
if (d3 * d3 <= approx.distanceToleranceSquare * (d.x * d.x + d.y * d.y)) {
if (approx.angleTolerance < kCurveAngleToleranceEpsilon) {
if (d3 * d3 <=
approx.distance_tolerance_square * (d.x * d.x + d.y * d.y)) {
if (approx.angle_tolerance < kCurveAngleToleranceEpsilon) {
points.emplace_back(p23);
return;
}
@@ -224,14 +225,14 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx,
da1 = 2.0 * M_PI - da1;
}
if (da1 < approx.angleTolerance) {
if (da1 < approx.angle_tolerance) {
points.emplace_back(p2);
points.emplace_back(p3);
return;
}
if (approx.cuspLimit != 0.0) {
if (da1 > approx.cuspLimit) {
if (approx.cusp_limit != 0.0) {
if (da1 > approx.cusp_limit) {
points.emplace_back(p3);
return;
}
@@ -243,8 +244,9 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx,
/*
* p1,p3,p4 are collinear, p2 is significant.
*/
if (d2 * d2 <= approx.distanceToleranceSquare * (d.x * d.x + d.y * d.y)) {
if (approx.angleTolerance < kCurveAngleToleranceEpsilon) {
if (d2 * d2 <=
approx.distance_tolerance_square * (d.x * d.x + d.y * d.y)) {
if (approx.angle_tolerance < kCurveAngleToleranceEpsilon) {
points.emplace_back(p23);
return;
}
@@ -259,14 +261,14 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx,
da1 = 2.0 * M_PI - da1;
}
if (da1 < approx.angleTolerance) {
if (da1 < approx.angle_tolerance) {
points.emplace_back(p2);
points.emplace_back(p3);
return;
}
if (approx.cuspLimit != 0.0) {
if (da1 > approx.cuspLimit) {
if (approx.cusp_limit != 0.0) {
if (da1 > approx.cusp_limit) {
points.emplace_back(p2);
return;
}
@@ -279,12 +281,12 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx,
* Regular case.
*/
if ((d2 + d3) * (d2 + d3) <=
approx.distanceToleranceSquare * (d.x * d.x + d.y * d.y)) {
approx.distance_tolerance_square * (d.x * d.x + d.y * d.y)) {
/*
* If the curvature doesn't exceed the distance_tolerance value
* we tend to finish subdivisions.
*/
if (approx.angleTolerance < kCurveAngleToleranceEpsilon) {
if (approx.angle_tolerance < kCurveAngleToleranceEpsilon) {
points.emplace_back(p23);
return;
}
@@ -304,7 +306,7 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx,
da2 = 2.0 * M_PI - da2;
}
if (da1 + da2 < approx.angleTolerance) {
if (da1 + da2 < approx.angle_tolerance) {
/*
* Finally we can stop the recursion.
*/
@@ -312,13 +314,13 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx,
return;
}
if (approx.cuspLimit != 0.0) {
if (da1 > approx.cuspLimit) {
if (approx.cusp_limit != 0.0) {
if (da1 > approx.cusp_limit) {
points.emplace_back(p2);
return;
}
if (da2 > approx.cuspLimit) {
if (da2 > approx.cusp_limit) {
points.emplace_back(p3);
return;
}

View File

@@ -13,22 +13,22 @@ namespace impeller {
struct SmoothingApproximation {
const Scalar scale;
const Scalar angleTolerance;
const Scalar cuspLimit;
const Scalar distanceToleranceSquare;
const Scalar angle_tolerance;
const Scalar cusp_limit;
const Scalar distance_tolerance_square;
SmoothingApproximation(/* default */)
: SmoothingApproximation(1.0 /* scale */,
0.0 /* angle tolerance */,
0.0 /* cusp limit */) {}
SmoothingApproximation(Scalar pScale,
Scalar pAngleTolerance,
Scalar pCuspLimit)
: scale(pScale),
angleTolerance(pAngleTolerance),
cuspLimit(pCuspLimit),
distanceToleranceSquare(0.5 * pScale * 0.5 * pScale) {}
SmoothingApproximation(Scalar p_scale,
Scalar p_angle_tolerance,
Scalar p_cusp_limit)
: scale(p_scale),
angle_tolerance(p_angle_tolerance),
cusp_limit(p_cusp_limit),
distance_tolerance_square(0.5 * p_scale * 0.5 * p_scale) {}
};
struct LinearPathComponent {
@@ -67,7 +67,7 @@ struct QuadraticPathComponent {
std::vector<Point> SmoothPoints(
const SmoothingApproximation& approximation) const;
std::vector<Point> Sxtrema() const;
std::vector<Point> Extrema() const;
bool operator==(const QuadraticPathComponent& other) const {
return p1 == other.p1 && cp == other.cp && p2 == other.p2;