From 6ceb957d0717eb7a51deb6ba15ef2b39e8e5f5e4 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Wed, 5 May 2021 15:38:26 -0700 Subject: [PATCH] Apply clang-tidy guidelines. --- .../impeller/impeller/entity/Entity.cc | 10 +- .../impeller/impeller/geometry/Matrix.cc | 89 +++++----- .../impeller/impeller/geometry/Matrix.h | 105 ++++++------ .../impeller/impeller/geometry/Path.cc | 12 +- .../impeller/impeller/geometry/PathBuilder.cc | 156 +++++++++--------- .../impeller/impeller/geometry/PathBuilder.h | 40 ++--- .../impeller/geometry/PathComponent.cc | 44 ++--- .../impeller/geometry/PathComponent.h | 22 +-- .../impeller/impeller/geometry/Point.cc | 10 +- .../impeller/impeller/geometry/Point.h | 14 +- .../impeller/impeller/geometry/Quaternion.cc | 8 +- .../impeller/impeller/geometry/Quaternion.h | 22 +-- .../impeller/impeller/geometry/Rect.cc | 10 +- .../flutter/impeller/impeller/geometry/Rect.h | 16 +- .../impeller/impeller/geometry/Shear.cc | 2 +- .../impeller/impeller/geometry/Shear.h | 2 +- .../impeller/impeller/geometry/Size.cc | 4 +- .../flutter/impeller/impeller/geometry/Size.h | 10 +- .../impeller/impeller/geometry/Vector.cc | 4 +- .../impeller/impeller/geometry/Vector.h | 44 ++--- .../flutter/impeller/impeller/image/Image.cc | 14 +- .../flutter/impeller/impeller/image/Image.h | 6 +- .../impeller/impeller/image/ImageResult.cc | 24 +-- .../impeller/impeller/image/ImageResult.h | 16 +- 24 files changed, 345 insertions(+), 339 deletions(-) diff --git a/engine/src/flutter/impeller/impeller/entity/Entity.cc b/engine/src/flutter/impeller/impeller/entity/Entity.cc index db360cf41d..bebb915787 100644 --- a/engine/src/flutter/impeller/impeller/entity/Entity.cc +++ b/engine/src/flutter/impeller/impeller/entity/Entity.cc @@ -62,7 +62,7 @@ geom::Matrix Entity::GetModelMatrix() const { * The translation accounts for the offset in the origin of the bounds * of the entity and its position about its anchor point. */ - auto translation = geom::Matrix::Translation( + auto translation = geom::Matrix::MakeTranslation( {-bounds_.origin.x + position_.x - (bounds_.size.width * anchor_point_.x), -bounds_.origin.y + position_.y - (bounds_.size.height * anchor_point_.y)}); @@ -73,15 +73,15 @@ geom::Matrix Entity::GetModelMatrix() const { * matrix adjustment and also the two matrix multiplications. */ - if (transformation_.isIdentity()) { + if (transformation_.IsIdentity()) { return translation; } auto anchorAdjustment = - geom::Matrix::Translation({-anchor_point_.x * bounds_.size.width, - -anchor_point_.y * bounds_.size.height}); + geom::Matrix::MakeTranslation({-anchor_point_.x * bounds_.size.width, + -anchor_point_.y * bounds_.size.height}); - return translation * anchorAdjustment.invert() * transformation_ * + return translation * anchorAdjustment.Invert() * transformation_ * anchorAdjustment; } diff --git a/engine/src/flutter/impeller/impeller/geometry/Matrix.cc b/engine/src/flutter/impeller/impeller/geometry/Matrix.cc index 9fe2161373..95294b77f6 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Matrix.cc +++ b/engine/src/flutter/impeller/impeller/geometry/Matrix.cc @@ -85,12 +85,12 @@ Matrix::Matrix(const Decomposition& d) : Matrix() { } } -Matrix Matrix::Orthographic(double left, - double right, - double bottom, - double top, - double nearZ, - double farZ) { +Matrix Matrix::MakeOrthographic(double left, + double right, + double bottom, + double top, + double nearZ, + double farZ) { double ral = right + left; double rsl = right - left; double tab = top + bottom; @@ -106,14 +106,15 @@ Matrix Matrix::Orthographic(double left, // clang-format on } -Matrix Matrix::Orthographic(const Size& size) { - return Matrix::Orthographic(0, size.width, size.height, 0, -INT_MAX, INT_MAX); +Matrix Matrix::MakeOrthographic(const Size& size) { + return Matrix::MakeOrthographic(0, size.width, size.height, 0, -INT_MAX, + INT_MAX); } -Matrix Matrix::Perspective(double fov, - double aspect, - double nearZ, - double farZ) { +Matrix Matrix::MakePerspective(double fov, + double aspect, + double nearZ, + double farZ) { double cotan = 1.0 / tan(fov / 2.0); return Matrix(cotan / aspect, 0.0, 0.0, 0.0, // @@ -123,16 +124,16 @@ Matrix Matrix::Perspective(double fov, ); } -Matrix Matrix::LookAt(const Vector3& eye, - const Vector3& center, - const Vector3& up) { - auto n = (eye - center).normalize(); - auto u = (up.cross(n)).normalize(); - auto v = n.cross(u); +Matrix Matrix::MakeLookAt(const Vector3& eye, + const Vector3& center, + const Vector3& up) { + auto n = (eye - center).Normalize(); + auto u = (up.Cross(n)).Normalize(); + auto v = n.Cross(u); return {u.x, v.x, n.x, 0.0, // u.y, v.y, n.y, 0.0, // u.z, v.z, n.z, 0.0, // - (-u).dot(eye), (-v).dot(eye), (-n).dot(eye), 1.0}; + (-u).Dot(eye), (-v).Dot(eye), (-n).Dot(eye), 1.0}; } Matrix Matrix::operator+(const Matrix& o) const { @@ -144,7 +145,7 @@ Matrix Matrix::operator+(const Matrix& o) const { ); } -std::string Matrix::toString() const { +std::string Matrix::ToString() const { std::stringstream stream; for (int i = 0, limit = 16; i < limit; i++) { stream << m[i]; @@ -155,7 +156,7 @@ std::string Matrix::toString() const { return stream.str(); } -void Matrix::fromString(const std::string& str) { +void Matrix::FromString(const std::string& str) { std::stringstream stream(str); for (int i = 0; i < 16; i++) { stream >> m[i]; @@ -163,7 +164,7 @@ void Matrix::fromString(const std::string& str) { } } -Matrix Matrix::invert() const { +Matrix Matrix::Invert() const { Matrix tmp{ m[5] * m[10] * m[15] - m[5] * m[11] * m[14] - m[9] * m[6] * m[15] + m[9] * m[7] * m[14] + m[13] * m[6] * m[11] - m[13] * m[7] * m[10], @@ -228,7 +229,7 @@ Matrix Matrix::invert() const { tmp.m[12] * det, tmp.m[13] * det, tmp.m[14] * det, tmp.m[15] * det}; } -Matrix Matrix::transpose() const { +Matrix Matrix::Transpose() const { return { m[0], m[4], m[8], m[12], // m[1], m[5], m[9], m[13], // @@ -237,7 +238,7 @@ Matrix Matrix::transpose() const { }; } -double Matrix::determinant() const { +double Matrix::GetDeterminant() const { auto a00 = e[0][0]; auto a01 = e[0][1]; auto a02 = e[0][2]; @@ -275,7 +276,7 @@ double Matrix::determinant() const { * Adapted for Radar from Graphics Gems: * http://www.realtimerendering.com/resources/GraphicsGems/gemsii/unmatrix.c */ -Matrix::DecompositionResult Matrix::decompose() const { +Matrix::DecompositionResult Matrix::Decompose() const { /* * Normalize the matrix. */ @@ -302,7 +303,7 @@ Matrix::DecompositionResult Matrix::decompose() const { perpectiveMatrix.e[3][3] = 1; - if (perpectiveMatrix.determinant() == 0.0) { + if (perpectiveMatrix.GetDeterminant() == 0.0) { return {false, {}}; } @@ -327,7 +328,7 @@ Matrix::DecompositionResult Matrix::decompose() const { * prhs by the inverse. */ - result.perspective = rightHandSide * perpectiveMatrix.invert().transpose(); + result.perspective = rightHandSide * perpectiveMatrix.Invert().Transpose(); /* * Clear the perspective partition. @@ -359,35 +360,35 @@ Matrix::DecompositionResult Matrix::decompose() const { /* * Compute X scale factor and normalize first row. */ - result.scale.x = row[0].length(); - row[0] = row[0].normalize(); + result.scale.x = row[0].Length(); + row[0] = row[0].Normalize(); /* * Compute XY shear factor and make 2nd row orthogonal to 1st. */ - result.shear.xy = row[0].dot(row[1]); + result.shear.xy = row[0].Dot(row[1]); row[1] = Vector3::Combine(row[1], 1.0, row[0], -result.shear.xy); /* * Compute Y scale and normalize 2nd row. */ - result.scale.y = row[1].length(); - row[1] = row[1].normalize(); + result.scale.y = row[1].Length(); + row[1] = row[1].Normalize(); result.shear.xy /= result.scale.y; /* * Compute XZ and YZ shears, orthogonalize 3rd row. */ - result.shear.xz = row[0].dot(row[2]); + result.shear.xz = row[0].Dot(row[2]); row[2] = Vector3::Combine(row[2], 1.0, row[0], -result.shear.xz); - result.shear.yz = row[1].dot(row[2]); + result.shear.yz = row[1].Dot(row[2]); row[2] = Vector3::Combine(row[2], 1.0, row[1], -result.shear.yz); /* * Next, get Z scale and normalize 3rd row. */ - result.scale.z = row[2].length(); - row[2] = row[2].normalize(); + result.scale.z = row[2].Length(); + row[2] = row[2].Normalize(); result.shear.xz /= result.scale.z; result.shear.yz /= result.scale.z; @@ -397,7 +398,7 @@ Matrix::DecompositionResult Matrix::decompose() const { * Check for a coordinate system flip. If the determinant * is -1, then negate the matrix and the scaling factors. */ - if (row[0].dot(row[1].cross(row[2])) < 0) { + if (row[0].Dot(row[1].Cross(row[2])) < 0) { result.scale.x *= -1; result.scale.y *= -1; result.scale.z *= -1; @@ -436,7 +437,7 @@ Matrix::DecompositionResult Matrix::decompose() const { return DecompositionResult(true, result); } -uint64_t Matrix::Decomposition::componentsMask() const { +uint64_t Matrix::Decomposition::GetComponentsMask() const { uint64_t mask = 0; Quaternion noRotation(0.0, 0.0, 0.0, 1.0); @@ -467,14 +468,14 @@ uint64_t Matrix::Decomposition::componentsMask() const { return mask; } -std::string Matrix::Decomposition::toString() const { +std::string Matrix::Decomposition::ToString() const { std::stringstream stream; - stream << "Translation: " << translation.toString() << std::endl; - stream << "Scale: " << scale.toString() << std::endl; - stream << "Shear: " << shear.toString() << std::endl; - stream << "Perspective: " << perspective.toString() << std::endl; - stream << "Rotation: " << rotation.toString() << std::endl; + stream << "Translation: " << translation.ToString() << std::endl; + stream << "Scale: " << scale.ToString() << std::endl; + stream << "Shear: " << shear.ToString() << std::endl; + stream << "Perspective: " << perspective.ToString() << std::endl; + stream << "Rotation: " << rotation.ToString() << std::endl; return stream.str(); } diff --git a/engine/src/flutter/impeller/impeller/geometry/Matrix.h b/engine/src/flutter/impeller/impeller/geometry/Matrix.h index 721ed839d1..8fb236373b 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Matrix.h +++ b/engine/src/flutter/impeller/impeller/geometry/Matrix.h @@ -6,6 +6,7 @@ #include #include + #include "Point.h" #include "Quaternion.h" #include "Shear.h" @@ -37,9 +38,9 @@ struct Matrix { Rotation = 1 << 4, }; - uint64_t componentsMask() const; + uint64_t GetComponentsMask() const; - std::string toString() const; + std::string ToString() const; }; using DecompositionResult = @@ -66,7 +67,7 @@ struct Matrix { Matrix(const Decomposition& decomposition); - static Matrix Translation(const Vector3& t) { + static Matrix MakeTranslation(const Vector3& t) { // clang-format off return Matrix(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, @@ -75,7 +76,7 @@ struct Matrix { // clang-format on } - static Matrix Scale(const Vector3& s) { + static Matrix MakeScale(const Vector3& s) { // clang-format off return Matrix(s.x, 0.0, 0.0, 0.0, 0.0, s.y, 0.0, 0.0, @@ -84,8 +85,8 @@ struct Matrix { // clang-format on } - static Matrix Rotation(double radians, const Vector4& r) { - const Vector4 v = r.normalize(); + static Matrix MakeRotation(double radians, const Vector4& r) { + const Vector4 v = r.Normalize(); const double cosine = cos(radians); const double cosp = 1.0f - cosine; @@ -115,7 +116,7 @@ struct Matrix { // clang-format on } - static Matrix RotationX(double radians) { + static Matrix MakeRotationX(double radians) { double cosine = cos(radians); double sine = sin(radians); // clang-format off @@ -128,7 +129,7 @@ struct Matrix { // clang-format on } - static Matrix RotationY(double radians) { + static Matrix MakeRotationY(double radians) { double cosine = cos(radians); double sine = sin(radians); @@ -142,7 +143,7 @@ struct Matrix { // clang-format on } - static Matrix RotationZ(double radians) { + static Matrix MakeRotationZ(double radians) { double cosine = cos(radians); double sine = sin(radians); @@ -156,7 +157,35 @@ struct Matrix { // clang-format on } - Matrix translate(const Vector3& t) const { + static Matrix MakeOrthographic(double left, + double right, + double bottom, + double top, + double nearZ, + double farZ); + + static Matrix MakeOrthographic(const Size& size); + + /** + * Specify a viewing frustum in the worlds coordinate system. + * + * @param fov angle of the field of view (in radians). + * @param aspect aspect ratio. + * @param nearZ near clipping plane. + * @param farZ far clipping plane. + * + * @return the perspective projection matrix. + */ + static Matrix MakePerspective(double fov, + double aspect, + double nearZ, + double farZ); + + static Matrix MakeLookAt(const Vector3& eye, + const Vector3& center, + const Vector3& up); + + Matrix Translate(const Vector3& t) const { // clang-format off return Matrix(m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], @@ -168,7 +197,7 @@ struct Matrix { // clang-format on } - Matrix scale(const Vector3& s) const { + Matrix Scale(const Vector3& s) const { // clang-format off return Matrix(m[0] * s.x, m[1] * s.x, m[2] * s.x , m[3] * s.x, m[4] * s.y, m[5] * s.y, m[6] * s.y , m[7] * s.y, @@ -177,7 +206,7 @@ struct Matrix { // clang-format on } - Matrix multiply(const Matrix& o) const { + Matrix Multiply(const Matrix& o) const { // clang-format off return Matrix( m[0] * o.m[0] + m[4] * o.m[1] + m[8] * o.m[2] + m[12] * o.m[3], @@ -199,18 +228,18 @@ struct Matrix { // clang-format on } - Matrix transpose() const; + Matrix Transpose() const; - Matrix invert() const; + Matrix Invert() const; - double determinant() const; + double GetDeterminant() const; - bool isAffine() const { + bool IsAffine() const { return (m[2] == 0 && m[3] == 0 && m[6] == 0 && m[7] == 0 && m[8] == 0 && m[9] == 0 && m[10] == 1 && m[11] == 0 && m[14] == 0 && m[15] == 1); } - bool isIdentity() const { + bool IsIdentity() const { return ( // clang-format off m[0] == 1.0 && m[1] == 0.0 && m[2] == 0.0 && m[3] == 0.0 && @@ -221,7 +250,7 @@ struct Matrix { ); } - DecompositionResult decompose() const; + DecompositionResult Decompose() const; bool operator==(const Matrix& m) const { // clang-format off @@ -241,47 +270,19 @@ struct Matrix { // clang-format on } - Matrix operator+(const Vector3& t) const { return translate(t); } + Matrix operator+(const Vector3& t) const { return Translate(t); } - Matrix operator-(const Vector3& t) const { return translate(-t); } + Matrix operator-(const Vector3& t) const { return Translate(-t); } - Matrix operator*(const Vector3& s) const { return scale(s); } + Matrix operator*(const Vector3& s) const { return Scale(s); } - Matrix operator*(const Matrix& m) const { return multiply(m); } + Matrix operator*(const Matrix& m) const { return Multiply(m); } Matrix operator+(const Matrix& m) const; - static Matrix Orthographic(double left, - double right, - double bottom, - double top, - double nearZ, - double farZ); + std::string ToString() const; - static Matrix Orthographic(const Size& size); - - /** - * Specify a viewing frustum in the worlds coordinate system. - * - * @param fov angle of the field of view (in radians). - * @param aspect aspect ratio. - * @param nearZ near clipping plane. - * @param farZ far clipping plane. - * - * @return the perspective projection matrix. - */ - static Matrix Perspective(double fov, - double aspect, - double nearZ, - double farZ); - - static Matrix LookAt(const Vector3& eye, - const Vector3& center, - const Vector3& up); - - std::string toString() const; - - void fromString(const std::string& str); + void FromString(const std::string& str); }; static_assert(sizeof(struct Matrix) == sizeof(double) * 16, diff --git a/engine/src/flutter/impeller/impeller/geometry/Path.cc b/engine/src/flutter/impeller/impeller/geometry/Path.cc index b8c9ec6e5e..2b6dee74da 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Path.cc +++ b/engine/src/flutter/impeller/impeller/geometry/Path.cc @@ -153,17 +153,17 @@ void Path::smoothPoints(SmoothPointsEnumerator enumerator, for (const auto& component : _components) { switch (component.type) { case ComponentType::Linear: { - if (!enumerator(_linears[component.index].smoothPoints())) { + if (!enumerator(_linears[component.index].SmoothPoints())) { return; } } break; case ComponentType::Quadratic: { - if (!enumerator(_quads[component.index].smoothPoints(approximation))) { + if (!enumerator(_quads[component.index].SmoothPoints(approximation))) { return; } } break; case ComponentType::Cubic: { - if (!enumerator(_cubics[component.index].smoothPoints(approximation))) { + if (!enumerator(_cubics[component.index].SmoothPoints(approximation))) { return; } } break; @@ -175,15 +175,15 @@ Rect Path::boundingBox() const { Rect box; for (const auto& linear : _linears) { - box = box.withPoints(linear.extrema()); + box = box.WithPoints(linear.Extrema()); } for (const auto& quad : _quads) { - box = box.withPoints(quad.extrema()); + box = box.WithPoints(quad.Sxtrema()); } for (const auto& cubic : _cubics) { - box = box.withPoints(cubic.extrema()); + box = box.WithPoints(cubic.Extrema()); } return box; diff --git a/engine/src/flutter/impeller/impeller/geometry/PathBuilder.cc b/engine/src/flutter/impeller/impeller/geometry/PathBuilder.cc index 5bfe23dbeb..3f85ef9dce 100644 --- a/engine/src/flutter/impeller/impeller/geometry/PathBuilder.cc +++ b/engine/src/flutter/impeller/impeller/geometry/PathBuilder.cc @@ -13,129 +13,129 @@ PathBuilder::PathBuilder() = default; PathBuilder::~PathBuilder() = default; -Path PathBuilder::path() const { - return _prototype; +Path PathBuilder::CreatePath() const { + return prototype_; } -PathBuilder& PathBuilder::moveTo(Point point, bool relative) { - _current = relative ? _current + point : point; - _subpathStart = _current; +PathBuilder& PathBuilder::MoveTo(Point point, bool relative) { + current_ = relative ? current_ + point : point; + subpath_start_ = current_; return *this; } -PathBuilder& PathBuilder::close() { - lineTo(_subpathStart); +PathBuilder& PathBuilder::Close() { + LineTo(subpath_start_); return *this; } -PathBuilder& PathBuilder::lineTo(Point point, bool relative) { - point = relative ? _current + point : point; - _prototype.addLinearComponent(_current, point); - _current = point; +PathBuilder& PathBuilder::LineTo(Point point, bool relative) { + point = relative ? current_ + point : point; + prototype_.addLinearComponent(current_, point); + current_ = point; return *this; } -PathBuilder& PathBuilder::horizontalLineTo(double x, bool relative) { +PathBuilder& PathBuilder::HorizontalLineTo(double x, bool relative) { Point endpoint = - relative ? Point{_current.x + x, _current.y} : Point{x, _current.y}; - _prototype.addLinearComponent(_current, endpoint); - _current = endpoint; + relative ? Point{current_.x + x, current_.y} : Point{x, current_.y}; + prototype_.addLinearComponent(current_, endpoint); + current_ = endpoint; return *this; } -PathBuilder& PathBuilder::verticalLineTo(double y, bool relative) { +PathBuilder& PathBuilder::VerticalLineTo(double y, bool relative) { Point endpoint = - relative ? Point{_current.x, _current.y + y} : Point{_current.x, y}; - _prototype.addLinearComponent(_current, endpoint); - _current = endpoint; + relative ? Point{current_.x, current_.y + y} : Point{current_.x, y}; + prototype_.addLinearComponent(current_, endpoint); + current_ = endpoint; return *this; } -PathBuilder& PathBuilder::quadraticCurveTo(Point point, +PathBuilder& PathBuilder::QuadraticCurveTo(Point point, Point controlPoint, bool relative) { - point = relative ? _current + point : point; - controlPoint = relative ? _current + controlPoint : controlPoint; - _prototype.addQuadraticComponent(_current, controlPoint, point); - _current = point; + point = relative ? current_ + point : point; + controlPoint = relative ? current_ + controlPoint : controlPoint; + prototype_.addQuadraticComponent(current_, controlPoint, point); + current_ = point; return *this; } -Point PathBuilder::reflectedQuadraticControlPoint1() const { +Point PathBuilder::ReflectedQuadraticControlPoint1() const { /* * If there is no previous command or if the previous command was not a * quadratic, assume the control point is coincident with the current point. */ - if (_prototype.componentCount() == 0) { - return _current; + if (prototype_.componentCount() == 0) { + return current_; } QuadraticPathComponent quad; - if (!_prototype.quadraticComponentAtIndex(_prototype.componentCount() - 1, + if (!prototype_.quadraticComponentAtIndex(prototype_.componentCount() - 1, quad)) { - return _current; + return current_; } /* * The control point is assumed to be the reflection of the control point on * the previous command relative to the current point. */ - return (_current * 2.0) - quad.cp; + return (current_ * 2.0) - quad.cp; } -PathBuilder& PathBuilder::smoothQuadraticCurveTo(Point point, bool relative) { - point = relative ? _current + point : point; +PathBuilder& PathBuilder::SmoothQuadraticCurveTo(Point point, bool relative) { + point = relative ? current_ + point : point; /* * The reflected control point is absolute and we made the endpoint absolute * too. So there the last argument is always false (i.e, not relative). */ - quadraticCurveTo(point, reflectedQuadraticControlPoint1(), false); + QuadraticCurveTo(point, ReflectedQuadraticControlPoint1(), false); return *this; } -PathBuilder& PathBuilder::cubicCurveTo(Point point, +PathBuilder& PathBuilder::CubicCurveTo(Point point, Point controlPoint1, Point controlPoint2, bool relative) { - controlPoint1 = relative ? _current + controlPoint1 : controlPoint1; - controlPoint2 = relative ? _current + controlPoint2 : controlPoint2; - point = relative ? _current + point : point; - _prototype.addCubicComponent(_current, controlPoint1, controlPoint2, point); - _current = point; + controlPoint1 = relative ? current_ + controlPoint1 : controlPoint1; + controlPoint2 = relative ? current_ + controlPoint2 : controlPoint2; + point = relative ? current_ + point : point; + prototype_.addCubicComponent(current_, controlPoint1, controlPoint2, point); + current_ = point; return *this; } -Point PathBuilder::reflectedCubicControlPoint1() const { +Point PathBuilder::ReflectedCubicControlPoint1() const { /* * If there is no previous command or if the previous command was not a * cubic, assume the first control point is coincident with the current * point. */ - if (_prototype.componentCount() == 0) { - return _current; + if (prototype_.componentCount() == 0) { + return current_; } CubicPathComponent cubic; - if (!_prototype.cubicComponentAtIndex(_prototype.componentCount() - 1, + if (!prototype_.cubicComponentAtIndex(prototype_.componentCount() - 1, cubic)) { - return _current; + return current_; } /* * The first control point is assumed to be the reflection of the second * control point on the previous command relative to the current point. */ - return (_current * 2.0) - cubic.cp2; + return (current_ * 2.0) - cubic.cp2; } -PathBuilder& PathBuilder::smoothCubicCurveTo(Point point, +PathBuilder& PathBuilder::SmoothCubicCurveTo(Point point, Point controlPoint2, bool relative) { - auto controlPoint1 = reflectedCubicControlPoint1(); - controlPoint2 = relative ? _current + controlPoint2 : controlPoint2; - auto endpoint = relative ? _current + point : point; + auto controlPoint1 = ReflectedCubicControlPoint1(); + controlPoint2 = relative ? current_ + controlPoint2 : controlPoint2; + auto endpoint = relative ? current_ + point : point; - cubicCurveTo(endpoint, // endpoint + CubicCurveTo(endpoint, // endpoint controlPoint1, // control point 1 controlPoint2, // control point 2 false // relative since all points are already absolute @@ -143,15 +143,15 @@ PathBuilder& PathBuilder::smoothCubicCurveTo(Point point, return *this; } -PathBuilder& PathBuilder::addRect(Rect rect) { - _current = rect.origin; +PathBuilder& PathBuilder::AddRect(Rect rect) { + current_ = rect.origin; auto topLeft = rect.origin; auto bottomLeft = rect.origin + Point{0.0, rect.size.height}; auto bottomRight = rect.origin + Point{rect.size.width, rect.size.height}; auto topRight = rect.origin + Point{rect.size.width, 0.0}; - _prototype.addLinearComponent(topLeft, bottomLeft) + prototype_.addLinearComponent(topLeft, bottomLeft) .addLinearComponent(bottomLeft, bottomRight) .addLinearComponent(bottomRight, topRight) .addLinearComponent(topRight, topLeft); @@ -159,34 +159,34 @@ PathBuilder& PathBuilder::addRect(Rect rect) { return *this; } -PathBuilder& PathBuilder::addCircle(const Point& center, double radius) { - _current = center + Point{0.0, radius}; +PathBuilder& PathBuilder::AddCircle(const Point& center, double radius) { + current_ = center + Point{0.0, radius}; const double diameter = radius * 2.0; const double magic = kArcApproximationMagic * radius; - _prototype.addCubicComponent( + prototype_.addCubicComponent( {center.x + radius, center.y}, // {center.x + radius + magic, center.y}, // {center.x + diameter, center.y + radius - magic}, // {center.x + diameter, center.y + radius} // ); - _prototype.addCubicComponent( + prototype_.addCubicComponent( {center.x + diameter, center.y + radius}, // {center.x + diameter, center.y + radius + magic}, // {center.x + radius + magic, center.y + diameter}, // {center.x + radius, center.y + diameter} // ); - _prototype.addCubicComponent( + prototype_.addCubicComponent( {center.x + radius, center.y + diameter}, // {center.x + radius - magic, center.y + diameter}, // {center.x, center.y + radius + magic}, // {center.x, center.y + radius} // ); - _prototype.addCubicComponent({center.x, center.y + radius}, // + prototype_.addCubicComponent({center.x, center.y + radius}, // {center.x, center.y + radius - magic}, // {center.x + radius - magic, center.y}, // {center.x + radius, center.y} // @@ -195,13 +195,13 @@ PathBuilder& PathBuilder::addCircle(const Point& center, double radius) { return *this; } -PathBuilder& PathBuilder::addRoundedRect(Rect rect, double radius) { - return radius == 0.0 ? addRect(rect) - : addRoundedRect(rect, {radius, radius, radius, radius}); +PathBuilder& PathBuilder::AddRoundedRect(Rect rect, double radius) { + return radius == 0.0 ? AddRect(rect) + : AddRoundedRect(rect, {radius, radius, radius, radius}); } -PathBuilder& PathBuilder::addRoundedRect(Rect rect, RoundingRadii radii) { - _current = rect.origin + Point{radii.topLeft, 0.0}; +PathBuilder& PathBuilder::AddRoundedRect(Rect rect, RoundingRadii radii) { + current_ = rect.origin + Point{radii.topLeft, 0.0}; const double magicTopRight = kArcApproximationMagic * radii.topRight; const double magicBottomRight = kArcApproximationMagic * radii.bottomRight; @@ -211,14 +211,14 @@ PathBuilder& PathBuilder::addRoundedRect(Rect rect, RoundingRadii radii) { /* * Top line. */ - _prototype.addLinearComponent( + prototype_.addLinearComponent( {rect.origin.x + radii.topLeft, rect.origin.y}, {rect.origin.x + rect.size.width - radii.topRight, rect.origin.y}); /* * Top right arc. */ - _prototype.addCubicComponent( + prototype_.addCubicComponent( {rect.origin.x + rect.size.width - radii.topRight, rect.origin.y}, {rect.origin.x + rect.size.width - radii.topRight + magicTopRight, rect.origin.y}, @@ -229,7 +229,7 @@ PathBuilder& PathBuilder::addRoundedRect(Rect rect, RoundingRadii radii) { /* * Right line. */ - _prototype.addLinearComponent( + prototype_.addLinearComponent( {rect.origin.x + rect.size.width, rect.origin.y + radii.topRight}, {rect.origin.x + rect.size.width, rect.origin.y + rect.size.height - radii.bottomRight}); @@ -237,7 +237,7 @@ PathBuilder& PathBuilder::addRoundedRect(Rect rect, RoundingRadii radii) { /* * Bottom right arc. */ - _prototype.addCubicComponent( + prototype_.addCubicComponent( {rect.origin.x + rect.size.width, rect.origin.y + rect.size.height - radii.bottomRight}, {rect.origin.x + rect.size.width, @@ -250,7 +250,7 @@ PathBuilder& PathBuilder::addRoundedRect(Rect rect, RoundingRadii radii) { /* * Bottom line. */ - _prototype.addLinearComponent( + prototype_.addLinearComponent( {rect.origin.x + rect.size.width - radii.bottomRight, rect.origin.y + rect.size.height}, {rect.origin.x + radii.bottomLeft, rect.origin.y + rect.size.height}); @@ -258,7 +258,7 @@ PathBuilder& PathBuilder::addRoundedRect(Rect rect, RoundingRadii radii) { /* * Bottom left arc. */ - _prototype.addCubicComponent( + prototype_.addCubicComponent( {rect.origin.x + radii.bottomLeft, rect.origin.y + rect.size.height}, {rect.origin.x + radii.bottomLeft - magicBottomLeft, rect.origin.y + rect.size.height}, @@ -269,14 +269,14 @@ PathBuilder& PathBuilder::addRoundedRect(Rect rect, RoundingRadii radii) { /* * Left line. */ - _prototype.addLinearComponent( + prototype_.addLinearComponent( {rect.origin.x, rect.origin.y + rect.size.height - radii.bottomLeft}, {rect.origin.x, rect.origin.y + radii.topLeft}); /* * Top left arc. */ - _prototype.addCubicComponent( + prototype_.addCubicComponent( {rect.origin.x, rect.origin.y + radii.topLeft}, {rect.origin.x, rect.origin.y + radii.topLeft - magicTopLeft}, {rect.origin.x + radii.topLeft - magicTopLeft, rect.origin.y}, @@ -285,35 +285,35 @@ PathBuilder& PathBuilder::addRoundedRect(Rect rect, RoundingRadii radii) { return *this; } -PathBuilder& PathBuilder::addEllipse(const Point& center, const Size& radius) { - _current = center + Point{0.0, radius.height}; +PathBuilder& PathBuilder::AddEllipse(const Point& center, const Size& radius) { + current_ = center + Point{0.0, radius.height}; const Size diameter = {radius.width * 2.0, radius.height * 2.0}; const Size magic = {kArcApproximationMagic * radius.width, kArcApproximationMagic * radius.height}; - _prototype.addCubicComponent( + prototype_.addCubicComponent( {center.x + radius.width, center.y}, // {center.x + radius.width + magic.width, center.y}, // {center.x + diameter.width, center.y + radius.height - magic.height}, // {center.x + diameter.width, center.y + radius.height} // ); - _prototype.addCubicComponent( + prototype_.addCubicComponent( {center.x + diameter.width, center.y + radius.height}, // {center.x + diameter.width, center.y + radius.height + magic.height}, // {center.x + radius.width + magic.width, center.y + diameter.height}, // {center.x + radius.width, center.y + diameter.height} // ); - _prototype.addCubicComponent( + prototype_.addCubicComponent( {center.x + radius.width, center.y + diameter.height}, // {center.x + radius.width - magic.width, center.y + diameter.height}, // {center.x, center.y + radius.height + magic.height}, // {center.x, center.y + radius.height} // ); - _prototype.addCubicComponent( + prototype_.addCubicComponent( {center.x, center.y + radius.height}, // {center.x, center.y + radius.height - magic.height}, // {center.x + radius.width - magic.width, center.y}, // diff --git a/engine/src/flutter/impeller/impeller/geometry/PathBuilder.h b/engine/src/flutter/impeller/impeller/geometry/PathBuilder.h index 161aabc5ff..504a6d5275 100644 --- a/engine/src/flutter/impeller/impeller/geometry/PathBuilder.h +++ b/engine/src/flutter/impeller/impeller/geometry/PathBuilder.h @@ -17,40 +17,40 @@ class PathBuilder { ~PathBuilder(); - Path path() const; + Path CreatePath() const; - PathBuilder& moveTo(Point point, bool relative = false); + PathBuilder& MoveTo(Point point, bool relative = false); - PathBuilder& close(); + PathBuilder& Close(); - PathBuilder& lineTo(Point point, bool relative = false); + PathBuilder& LineTo(Point point, bool relative = false); - PathBuilder& horizontalLineTo(double x, bool relative = false); + PathBuilder& HorizontalLineTo(double x, bool relative = false); - PathBuilder& verticalLineTo(double y, bool relative = false); + PathBuilder& VerticalLineTo(double y, bool relative = false); - PathBuilder& quadraticCurveTo(Point point, + PathBuilder& QuadraticCurveTo(Point point, Point controlPoint, bool relative = false); - PathBuilder& smoothQuadraticCurveTo(Point point, bool relative = false); + PathBuilder& SmoothQuadraticCurveTo(Point point, bool relative = false); - PathBuilder& cubicCurveTo(Point point, + PathBuilder& CubicCurveTo(Point point, Point controlPoint1, Point controlPoint2, bool relative = false); - PathBuilder& smoothCubicCurveTo(Point point, + PathBuilder& SmoothCubicCurveTo(Point point, Point controlPoint2, bool relative = false); - PathBuilder& addRect(Rect rect); + PathBuilder& AddRect(Rect rect); - PathBuilder& addRoundedRect(Rect rect, double radius); + PathBuilder& AddRoundedRect(Rect rect, double radius); - PathBuilder& addCircle(const Point& center, double radius); + PathBuilder& AddCircle(const Point& center, double radius); - PathBuilder& addEllipse(const Point& center, const Size& size); + PathBuilder& AddEllipse(const Point& center, const Size& size); struct RoundingRadii { double topLeft; @@ -71,16 +71,16 @@ class PathBuilder { bottomRight(pBottomRight) {} }; - PathBuilder& addRoundedRect(Rect rect, RoundingRadii radii); + PathBuilder& AddRoundedRect(Rect rect, RoundingRadii radii); private: - Point _subpathStart; - Point _current; - Path _prototype; + Point subpath_start_; + Point current_; + Path prototype_; - Point reflectedQuadraticControlPoint1() const; + Point ReflectedQuadraticControlPoint1() const; - Point reflectedCubicControlPoint1() const; + Point ReflectedCubicControlPoint1() const; FML_DISALLOW_COPY_AND_ASSIGN(PathBuilder); }; diff --git a/engine/src/flutter/impeller/impeller/geometry/PathComponent.cc b/engine/src/flutter/impeller/impeller/geometry/PathComponent.cc index 2540e3082b..990f8c73b9 100644 --- a/engine/src/flutter/impeller/impeller/geometry/PathComponent.cc +++ b/engine/src/flutter/impeller/impeller/geometry/PathComponent.cc @@ -56,54 +56,54 @@ static inline double CubicSolveDerivative(double t, 3 * p3 * t * t; } -Point LinearPathComponent::solve(double time) const { +Point LinearPathComponent::Solve(double time) const { return { LinearSolve(time, p1.x, p2.x), // x LinearSolve(time, p1.y, p2.y), // y }; } -std::vector LinearPathComponent::smoothPoints() const { +std::vector LinearPathComponent::SmoothPoints() const { return {p1, p2}; } -std::vector LinearPathComponent::extrema() const { +std::vector LinearPathComponent::Extrema() const { return {p1, p2}; } -Point QuadraticPathComponent::solve(double time) const { +Point QuadraticPathComponent::Solve(double time) const { return { QuadraticSolve(time, p1.x, cp.x, p2.x), // x QuadraticSolve(time, p1.y, cp.y, p2.y), // y }; } -Point QuadraticPathComponent::solveDerivative(double time) const { +Point QuadraticPathComponent::SolveDerivative(double time) const { return { QuadraticSolveDerivative(time, p1.x, cp.x, p2.x), // x QuadraticSolveDerivative(time, p1.y, cp.y, p2.y), // y }; } -std::vector QuadraticPathComponent::smoothPoints( +std::vector QuadraticPathComponent::SmoothPoints( const SmoothingApproximation& approximation) const { CubicPathComponent elevated(*this); - return elevated.smoothPoints(approximation); + return elevated.SmoothPoints(approximation); } -std::vector QuadraticPathComponent::extrema() const { +std::vector QuadraticPathComponent::Sxtrema() const { CubicPathComponent elevated(*this); - return elevated.extrema(); + return elevated.Extrema(); } -Point CubicPathComponent::solve(double time) const { +Point CubicPathComponent::Solve(double time) const { return { CubicSolve(time, p1.x, cp1.x, cp2.x, p2.x), // x CubicSolve(time, p1.y, cp1.y, cp2.y, p2.y), // y }; } -Point CubicPathComponent::solveDerivative(double time) const { +Point CubicPathComponent::SolveDerivative(double time) const { return { CubicSolveDerivative(time, p1.x, cp1.x, cp2.x, p2.x), // x CubicSolveDerivative(time, p1.y, cp1.y, cp2.y, p2.y), // y @@ -157,8 +157,8 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx, */ k = d.x * d.x + d.y * d.y; if (k == 0) { - d2 = p1.distanceSquared(p2); - d3 = p4.distanceSquared(p3); + d2 = p1.GetDistanceSquared(p2); + d3 = p4.GetDistanceSquared(p3); } else { k = 1.0 / k; da1 = p2.x - p1.x; @@ -176,19 +176,19 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx, } if (d2 <= 0) { - d2 = p2.distanceSquared(p1); + d2 = p2.GetDistanceSquared(p1); } else if (d2 >= 1) { - d2 = p2.distanceSquared(p4); + d2 = p2.GetDistanceSquared(p4); } else { - d2 = p2.distanceSquared({p1.x + d2 * d.x, p1.y + d2 * d.y}); + d2 = p2.GetDistanceSquared({p1.x + d2 * d.x, p1.y + d2 * d.y}); } if (d3 <= 0) { - d3 = p3.distanceSquared(p1); + d3 = p3.GetDistanceSquared(p1); } else if (d3 >= 1) { - d3 = p3.distanceSquared(p4); + d3 = p3.GetDistanceSquared(p4); } else { - d3 = p3.distanceSquared({p1.x + d3 * d.x, p1.y + d3 * d.y}); + d3 = p3.GetDistanceSquared({p1.x + d3 * d.x, p1.y + d3 * d.y}); } } @@ -334,7 +334,7 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx, CubicPathSmoothenRecursive(approx, points, p1234, p234, p34, p4, level + 1); } -std::vector CubicPathComponent::smoothPoints( +std::vector CubicPathComponent::SmoothPoints( const SmoothingApproximation& approximation) const { std::vector points; points.emplace_back(p1); @@ -398,7 +398,7 @@ static void CubicPathBoundingPopulateValues(std::vector& values, } } -std::vector CubicPathComponent::extrema() const { +std::vector CubicPathComponent::Extrema() const { /* * As described in: https://pomax.github.io/bezierinfo/#extremities */ @@ -410,7 +410,7 @@ std::vector CubicPathComponent::extrema() const { std::vector points; for (const auto& value : values) { - points.emplace_back(solve(value)); + points.emplace_back(Solve(value)); } return points; diff --git a/engine/src/flutter/impeller/impeller/geometry/PathComponent.h b/engine/src/flutter/impeller/impeller/geometry/PathComponent.h index b1746b22ab..139adf0ea5 100644 --- a/engine/src/flutter/impeller/impeller/geometry/PathComponent.h +++ b/engine/src/flutter/impeller/impeller/geometry/PathComponent.h @@ -39,11 +39,11 @@ struct LinearPathComponent { LinearPathComponent(Point ap1, Point ap2) : p1(ap1), p2(ap2) {} - Point solve(double time) const; + Point Solve(double time) const; - std::vector smoothPoints() const; + std::vector SmoothPoints() const; - std::vector extrema() const; + std::vector Extrema() const; bool operator==(const LinearPathComponent& other) const { return p1 == other.p1 && p2 == other.p2; @@ -60,14 +60,14 @@ struct QuadraticPathComponent { QuadraticPathComponent(Point ap1, Point acp, Point ap2) : p1(ap1), cp(acp), p2(ap2) {} - Point solve(double time) const; + Point Solve(double time) const; - Point solveDerivative(double time) const; + Point SolveDerivative(double time) const; - std::vector smoothPoints( + std::vector SmoothPoints( const SmoothingApproximation& approximation) const; - std::vector extrema() const; + std::vector Sxtrema() const; bool operator==(const QuadraticPathComponent& other) const { return p1 == other.p1 && cp == other.cp && p2 == other.p2; @@ -91,14 +91,14 @@ struct CubicPathComponent { CubicPathComponent(Point ap1, Point acp1, Point acp2, Point ap2) : p1(ap1), cp1(acp1), cp2(acp2), p2(ap2) {} - Point solve(double time) const; + Point Solve(double time) const; - Point solveDerivative(double time) const; + Point SolveDerivative(double time) const; - std::vector smoothPoints( + std::vector SmoothPoints( const SmoothingApproximation& approximation) const; - std::vector extrema() const; + std::vector Extrema() const; bool operator==(const CubicPathComponent& other) const { return p1 == other.p1 && cp1 == other.cp1 && cp2 == other.cp2 && diff --git a/engine/src/flutter/impeller/impeller/geometry/Point.cc b/engine/src/flutter/impeller/impeller/geometry/Point.cc index 9b8d6976f2..72a0b9db45 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Point.cc +++ b/engine/src/flutter/impeller/impeller/geometry/Point.cc @@ -8,27 +8,27 @@ namespace rl { namespace geom { -std::string Point::toString() const { +std::string Point::ToString() const { std::stringstream stream; stream << x << "," << y; return stream.str(); } -void Point::fromString(const std::string& str) { +void Point::FromString(const std::string& str) { std::stringstream stream(str); stream >> x; stream.ignore(); stream >> y; } -double Point::distanceSquared(const Point& p) const { +double Point::GetDistanceSquared(const Point& p) const { double dx = p.x - x; double dy = p.y - y; return dx * dx + dy * dy; } -double Point::distance(const Point& p) const { - return sqrt(distanceSquared(p)); +double Point::GetDistance(const Point& p) const { + return sqrt(GetDistanceSquared(p)); } } // namespace geom diff --git a/engine/src/flutter/impeller/impeller/geometry/Point.h b/engine/src/flutter/impeller/impeller/geometry/Point.h index 988d2fd16e..a099d373aa 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Point.h +++ b/engine/src/flutter/impeller/impeller/geometry/Point.h @@ -12,10 +12,10 @@ namespace rl { namespace geom { struct Point { - double x; - double y; + double x = 0.0; + double y = 0.0; - constexpr Point() : x(0.0), y(0.0) {} + constexpr Point() = default; constexpr Point(double x, double y) : x(x), y(y) {} @@ -48,13 +48,13 @@ struct Point { Point operator/(const Size& s) const { return {x / s.width, y / s.height}; } - double distanceSquared(const Point& p) const; + double GetDistanceSquared(const Point& p) const; - double distance(const Point& p) const; + double GetDistance(const Point& p) const; - std::string toString() const; + std::string ToString() const; - void fromString(const std::string& str); + void FromString(const std::string& str); }; } // namespace geom diff --git a/engine/src/flutter/impeller/impeller/geometry/Quaternion.cc b/engine/src/flutter/impeller/impeller/geometry/Quaternion.cc index 58ef20c051..3430339605 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Quaternion.cc +++ b/engine/src/flutter/impeller/impeller/geometry/Quaternion.cc @@ -8,8 +8,8 @@ namespace rl { namespace geom { -Quaternion Quaternion::slerp(const Quaternion& to, double time) const { - double cosine = dot(to); +Quaternion Quaternion::Slerp(const Quaternion& to, double time) const { + double cosine = Dot(to); if (fabs(cosine) < 1.0 - 1e-3 /* epsilon */) { /* * Spherical Interpolation. @@ -24,11 +24,11 @@ Quaternion Quaternion::slerp(const Quaternion& to, double time) const { /* * Linear Interpolation. */ - return (*this * (1.0 - time) + to * time).normalize(); + return (*this * (1.0 - time) + to * time).Normalize(); } } -std::string Quaternion::toString() const { +std::string Quaternion::ToString() const { std::stringstream stream; stream << "{" << x << ", " << ", " << y << ", " << z << ", " << w << "}"; diff --git a/engine/src/flutter/impeller/impeller/geometry/Quaternion.h b/engine/src/flutter/impeller/impeller/geometry/Quaternion.h index ec5e6eb608..07507b8eb3 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Quaternion.h +++ b/engine/src/flutter/impeller/impeller/geometry/Quaternion.h @@ -12,15 +12,15 @@ namespace geom { struct Quaternion { union { struct { - double x; - double y; - double z; - double w; + double x = 0.0; + double y = 0.0; + double z = 0.0; + double w = 1.0; }; double e[4]; }; - Quaternion() : x(0.0), y(0.0), z(0.0), w(1.0) {} + Quaternion() {} Quaternion(double px, double py, double pz, double pw) : x(px), y(py), z(pz), w(pw) {} @@ -33,18 +33,18 @@ struct Quaternion { w = cos(angle * 0.5); } - double dot(const Quaternion& q) const { + double Dot(const Quaternion& q) const { return x * q.x + y * q.y + z * q.z + w * q.w; } - double length() const { return sqrt(x * x + y * y + z * z + w * w); } + double Length() const { return sqrt(x * x + y * y + z * z + w * w); } - Quaternion normalize() const { - auto m = 1.0 / length(); + Quaternion Normalize() const { + auto m = 1.0 / Length(); return {x * m, y * m, z * m, w * m}; } - Quaternion slerp(const Quaternion& to, double time) const; + Quaternion Slerp(const Quaternion& to, double time) const; Quaternion operator*(const Quaternion& o) const { return { @@ -75,7 +75,7 @@ struct Quaternion { return x != o.x || y != o.y || z != o.z || w != o.w; } - std::string toString() const; + std::string ToString() const; }; } // namespace geom diff --git a/engine/src/flutter/impeller/impeller/geometry/Rect.cc b/engine/src/flutter/impeller/impeller/geometry/Rect.cc index a718e746fc..cfcc4d9296 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Rect.cc +++ b/engine/src/flutter/impeller/impeller/geometry/Rect.cc @@ -8,7 +8,7 @@ namespace rl { namespace geom { -Rect Rect::withPoint(const Point& p) const { +Rect Rect::WithPoint(const Point& p) const { Rect copy = *this; if (p.x < origin.x) { copy.origin.x = p.x; @@ -31,22 +31,22 @@ Rect Rect::withPoint(const Point& p) const { return copy; } -Rect Rect::withPoints(const std::vector& points) const { +Rect Rect::WithPoints(const std::vector& points) const { Rect box = *this; for (const auto& point : points) { - box = box.withPoint(point); + box = box.WithPoint(point); } return box; } -std::string Rect::toString() const { +std::string Rect::ToString() const { std::stringstream stream; stream << origin.x << "," << origin.y << "," << size.width << "," << size.height; return stream.str(); } -void Rect::fromString(const std::string& str) { +void Rect::FromString(const std::string& str) { std::stringstream stream(str); stream >> origin.x; stream.ignore(); diff --git a/engine/src/flutter/impeller/impeller/geometry/Rect.h b/engine/src/flutter/impeller/impeller/geometry/Rect.h index 1cc5e39f1c..04223c47a0 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Rect.h +++ b/engine/src/flutter/impeller/impeller/geometry/Rect.h @@ -16,11 +16,15 @@ struct Rect { Size size; Rect() : origin({0.0, 0.0}), size({0.0, 0.0}) {} + Rect(Size size) : origin({0.0, 0.0}), size(size) {} + Rect(Point origin, Size size) : origin(origin), size(size) {} + Rect(const double components[4]) : origin(components[0], components[1]), size(components[2], components[3]) {} + Rect(double x, double y, double width, double height) : origin(x, y), size(width, height) {} @@ -51,20 +55,20 @@ struct Rect { return origin == r.origin && size == r.size; } - bool contains(const Point& p) const { + bool Contains(const Point& p) const { return p.x >= origin.x && p.x <= size.width && p.y >= origin.y && p.y <= size.height; } - bool isZero() const { return size.isZero(); } + bool IsZero() const { return size.IsZero(); } - Rect withPoint(const Point& p) const; + Rect WithPoint(const Point& p) const; - Rect withPoints(const std::vector& points) const; + Rect WithPoints(const std::vector& points) const; - std::string toString() const; + std::string ToString() const; - void fromString(const std::string& str); + void FromString(const std::string& str); }; } // namespace geom diff --git a/engine/src/flutter/impeller/impeller/geometry/Shear.cc b/engine/src/flutter/impeller/impeller/geometry/Shear.cc index fc0cae787a..ed77e6f841 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Shear.cc +++ b/engine/src/flutter/impeller/impeller/geometry/Shear.cc @@ -8,7 +8,7 @@ namespace rl { namespace geom { -std::string Shear::toString() const { +std::string Shear::ToString() const { std::stringstream stream; stream << "{" << xy << ", " << xz << ", " << yz << "}"; return stream.str(); diff --git a/engine/src/flutter/impeller/impeller/geometry/Shear.h b/engine/src/flutter/impeller/impeller/geometry/Shear.h index dd5d402bc9..a3ba44ea65 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Shear.h +++ b/engine/src/flutter/impeller/impeller/geometry/Shear.h @@ -29,7 +29,7 @@ struct Shear { bool operator!=(const Shear& o) const { return !(*this == o); } - std::string toString() const; + std::string ToString() const; }; } // namespace geom diff --git a/engine/src/flutter/impeller/impeller/geometry/Size.cc b/engine/src/flutter/impeller/impeller/geometry/Size.cc index d6f7f9da19..91ea783ed5 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Size.cc +++ b/engine/src/flutter/impeller/impeller/geometry/Size.cc @@ -8,13 +8,13 @@ namespace rl { namespace geom { -std::string Size::toString() const { +std::string Size::ToString() const { std::stringstream stream; stream << width << "," << height; return stream.str(); } -void Size::fromString(const std::string& str) { +void Size::FromString(const std::string& str) { std::stringstream stream(str); stream >> width; stream.ignore(); diff --git a/engine/src/flutter/impeller/impeller/geometry/Size.h b/engine/src/flutter/impeller/impeller/geometry/Size.h index bc064fb9b2..62fa7074cf 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Size.h +++ b/engine/src/flutter/impeller/impeller/geometry/Size.h @@ -38,20 +38,20 @@ struct Size { return {width - s.width, height - s.height}; } - Size unionWith(const Size& o) const { + Size Union(const Size& o) const { return { std::max(width, o.width), std::max(height, o.height), }; } - bool isZero() const { return width * height == 0.0; } + bool IsZero() const { return width * height == 0.0; } - bool isPositive() const { return width > 0.0 && height > 0.0; } + bool IsPositive() const { return width > 0.0 && height > 0.0; } - std::string toString() const; + std::string ToString() const; - void fromString(const std::string& str); + void FromString(const std::string& str); }; } // namespace geom diff --git a/engine/src/flutter/impeller/impeller/geometry/Vector.cc b/engine/src/flutter/impeller/impeller/geometry/Vector.cc index 2d33a39bdf..4e113b2474 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Vector.cc +++ b/engine/src/flutter/impeller/impeller/geometry/Vector.cc @@ -8,13 +8,13 @@ namespace rl { namespace geom { -std::string Vector3::toString() const { +std::string Vector3::ToString() const { std::stringstream stream; stream << "{" << x << ", " << y << ", " << z << "}"; return stream.str(); } -std::string Vector4::toString() const { +std::string Vector4::ToString() const { std::stringstream stream; stream << "{" << x << ", " << y << ", " << z << ", " << w << "}"; return stream.str(); diff --git a/engine/src/flutter/impeller/impeller/geometry/Vector.h b/engine/src/flutter/impeller/impeller/geometry/Vector.h index 69c4324622..4abbd7088e 100644 --- a/engine/src/flutter/impeller/impeller/geometry/Vector.h +++ b/engine/src/flutter/impeller/impeller/geometry/Vector.h @@ -15,20 +15,20 @@ namespace geom { struct Vector3 { union { struct { - double x; - double y; - double z; + double x = 0.0; + double y = 0.0; + double z = 0.0; }; double e[3]; }; - Vector3() : x(0.0), y(0.0), z(0.0) {} + Vector3() {} - Vector3(const Point& p) : x(p.x), y(p.y), z(0.0) {} + Vector3(const Point& p) : x(p.x), y(p.y) {} - Vector3(const Size& s) : x(s.width), y(s.height), z(0.0) {} + Vector3(const Size& s) : x(s.width), y(s.height) {} - Vector3(double x, double y) : x(x), y(y), z(0.0) {} + Vector3(double x, double y) : x(x), y(y) {} Vector3(double x, double y, double z) : x(x), y(y), z(z) {} @@ -37,18 +37,18 @@ struct Vector3 { * * @return the calculated length. */ - double length() const { return sqrt(x * x + y * y + z * z); } + double Length() const { return sqrt(x * x + y * y + z * z); } - Vector3 normalize() const { - const auto len = length(); + Vector3 Normalize() const { + const auto len = Length(); return {x / len, y / len, z / len}; } - double dot(const Vector3& other) const { + double Dot(const Vector3& other) const { return ((x * other.x) + (y * other.y) + (z * other.z)); } - Vector3 cross(const Vector3& other) const { + Vector3 Cross(const Vector3& other) const { return { (y * other.z) - (z * other.y), // (z * other.x) - (x * other.z), // @@ -95,29 +95,29 @@ struct Vector3 { }; } - std::string toString() const; + std::string ToString() const; }; struct Vector4 { union { struct { - double x; - double y; - double z; - double w; + double x = 0.0; + double y = 0.0; + double z = 0.0; + double w = 1.0; }; double e[4]; }; - Vector4() : x(0.0), y(0.0), z(0.0), w(1.0) {} + Vector4() {} Vector4(double x, double y, double z, double w) : x(x), y(y), z(z), w(w) {} - Vector4(const Vector3& v) : x(v.x), y(v.y), z(v.z), w(1.0) {} + Vector4(const Vector3& v) : x(v.x), y(v.y), z(v.z) {} - Vector4(const Point& p) : x(p.x), y(p.y), z(0.0), w(1.0) {} + Vector4(const Point& p) : x(p.x), y(p.y) {} - Vector4 normalize() const { + Vector4 Normalize() const { const double inverse = 1.0 / sqrt(x * x + y * y + z * z + w * w); return Vector4(x * inverse, y * inverse, z * inverse, w * inverse); } @@ -138,7 +138,7 @@ struct Vector4 { return Vector4(x - v.x, y - v.y, z - v.z, w - v.w); } - std::string toString() const; + std::string ToString() const; }; } // namespace geom diff --git a/engine/src/flutter/impeller/impeller/image/Image.cc b/engine/src/flutter/impeller/impeller/image/Image.cc index 79b0c19f69..c9fa5d80a3 100644 --- a/engine/src/flutter/impeller/impeller/image/Image.cc +++ b/engine/src/flutter/impeller/impeller/image/Image.cc @@ -9,12 +9,12 @@ namespace rl { namespace image { Image::Image(std::shared_ptr sourceAllocation) - : _source(std::move(sourceAllocation)) {} + : source_(std::move(sourceAllocation)) {} Image::~Image() = default; -ImageResult Image::decode() const { - if (!_source) { +ImageResult Image::Decode() const { + if (!source_) { return {}; } @@ -23,8 +23,8 @@ ImageResult Image::decode() const { int comps = 0; stbi_uc* decoded = - stbi_load_from_memory(_source->GetMapping(), // Source Data - _source->GetSize(), // Source Data Size + stbi_load_from_memory(source_->GetMapping(), // Source Data + source_->GetSize(), // Source Data Size &width, // Out: Width &height, // Out: Height &comps, // Out: Components @@ -79,8 +79,8 @@ ImageResult Image::decode() const { }; } -bool Image::isValid() const { - return static_cast(_source); +bool Image::IsValid() const { + return static_cast(source_); } } // namespace image diff --git a/engine/src/flutter/impeller/impeller/image/Image.h b/engine/src/flutter/impeller/impeller/image/Image.h index cf4641b5b6..b51ad8dae6 100644 --- a/engine/src/flutter/impeller/impeller/image/Image.h +++ b/engine/src/flutter/impeller/impeller/image/Image.h @@ -20,12 +20,12 @@ class Image { ~Image(); - ImageResult decode() const; + ImageResult Decode() const; - bool isValid() const; + bool IsValid() const; private: - std::shared_ptr _source; + std::shared_ptr source_; }; } // namespace image diff --git a/engine/src/flutter/impeller/impeller/image/ImageResult.cc b/engine/src/flutter/impeller/impeller/image/ImageResult.cc index 66783483ed..f68e2107dd 100644 --- a/engine/src/flutter/impeller/impeller/image/ImageResult.cc +++ b/engine/src/flutter/impeller/impeller/image/ImageResult.cc @@ -12,27 +12,27 @@ ImageResult::ImageResult() = default; ImageResult::ImageResult(geom::Size size, Components components, std::shared_ptr allocation) - : _success(true), - _size(size), - _components(components), - _allocation(std::move(allocation)) {} + : success_(true), + size_(size), + components_(components), + allocation_(std::move(allocation)) {} ImageResult::~ImageResult() = default; -bool ImageResult::wasSuccessful() const { - return _success; +bool ImageResult::WasSuccessful() const { + return success_; } -const geom::Size& ImageResult::size() const { - return _size; +const geom::Size& ImageResult::GetSize() const { + return size_; } -ImageResult::Components ImageResult::components() const { - return _components; +ImageResult::Components ImageResult::GetComponents() const { + return components_; } -const std::shared_ptr& ImageResult::allocation() const { - return _allocation; +const std::shared_ptr& ImageResult::Allocation() const { + return allocation_; } } // namespace image diff --git a/engine/src/flutter/impeller/impeller/image/ImageResult.h b/engine/src/flutter/impeller/impeller/image/ImageResult.h index 28dfc18f32..624f67507e 100644 --- a/engine/src/flutter/impeller/impeller/image/ImageResult.h +++ b/engine/src/flutter/impeller/impeller/image/ImageResult.h @@ -31,19 +31,19 @@ class ImageResult { ~ImageResult(); - const geom::Size& size() const; + const geom::Size& GetSize() const; - bool wasSuccessful() const; + bool WasSuccessful() const; - Components components() const; + Components GetComponents() const; - const std::shared_ptr& allocation() const; + const std::shared_ptr& Allocation() const; private: - bool _success = false; - geom::Size _size; - Components _components = Components::Invalid; - std::shared_ptr _allocation; + bool success_ = false; + geom::Size size_; + Components components_ = Components::Invalid; + std::shared_ptr allocation_; FML_DISALLOW_COPY_AND_ASSIGN(ImageResult); };