From da597d03219249bd4769ef63c4f941f011ea1c5c Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Tue, 15 Jun 2021 13:29:07 -0700 Subject: [PATCH] Remove stringification in impeller/geometry. --- engine/src/flutter/impeller/geometry/color.cc | 24 ------------- engine/src/flutter/impeller/geometry/color.h | 9 ----- .../src/flutter/impeller/geometry/matrix.cc | 34 ++----------------- engine/src/flutter/impeller/geometry/matrix.h | 6 ---- engine/src/flutter/impeller/geometry/point.cc | 13 +------ engine/src/flutter/impeller/geometry/point.h | 4 --- engine/src/flutter/impeller/geometry/rect.cc | 18 ---------- engine/src/flutter/impeller/geometry/rect.h | 4 --- engine/src/flutter/impeller/geometry/scalar.h | 2 ++ engine/src/flutter/impeller/geometry/size.cc | 13 +------ engine/src/flutter/impeller/geometry/size.h | 4 --- 11 files changed, 6 insertions(+), 125 deletions(-) diff --git a/engine/src/flutter/impeller/geometry/color.cc b/engine/src/flutter/impeller/geometry/color.cc index 3680f2b5f31..fb052a80f58 100644 --- a/engine/src/flutter/impeller/geometry/color.cc +++ b/engine/src/flutter/impeller/geometry/color.cc @@ -85,30 +85,6 @@ Color ColorHSB::ToRGBA() const { return Color(0, 0, 0, alpha); } -std::string ColorHSB::ToString() const { - std::stringstream stream; - stream << "{" << hue << ", " << saturation << ", " << brightness << ", " - << alpha << "}"; - return stream.str(); -} - Color::Color(const ColorHSB& hsbColor) : Color(hsbColor.ToRGBA()) {} -std::string Color::ToString() const { - std::stringstream stream; - stream << red << "," << green << "," << blue << "," << alpha; - return stream.str(); -} - -void Color::FromString(const std::string& str) { - std::stringstream stream(str); - stream >> red; - stream.ignore(); - stream >> green; - stream.ignore(); - stream >> blue; - stream.ignore(); - stream >> alpha; -} - } // namespace impeller diff --git a/engine/src/flutter/impeller/geometry/color.h b/engine/src/flutter/impeller/geometry/color.h index 3e0104dd61d..ede6432835b 100644 --- a/engine/src/flutter/impeller/geometry/color.h +++ b/engine/src/flutter/impeller/geometry/color.h @@ -4,9 +4,6 @@ #pragma once -#include -#include - #include "impeller/geometry/scalar.h" namespace impeller { @@ -49,10 +46,6 @@ struct Color { alpha == c.alpha; } - std::string ToString() const; - - void FromString(const std::string& str); - static constexpr Color White() { return {1.0, 1.0, 1.0, 1.0}; } static constexpr Color Black() { return {0.0, 0.0, 0.0, 1.0}; } @@ -666,8 +659,6 @@ struct ColorHSB { static ColorHSB FromRGB(Color rgb); Color ToRGBA() const; - - std::string ToString() const; }; static_assert(sizeof(Color) == 4 * sizeof(Scalar)); diff --git a/engine/src/flutter/impeller/geometry/matrix.cc b/engine/src/flutter/impeller/geometry/matrix.cc index 3d8a457ef96..b783df7955c 100644 --- a/engine/src/flutter/impeller/geometry/matrix.cc +++ b/engine/src/flutter/impeller/geometry/matrix.cc @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "matrix.h" +#include "impeller/geometry/matrix.h" + #include #include @@ -144,25 +145,6 @@ Matrix Matrix::operator+(const Matrix& o) const { ); } -std::string Matrix::ToString() const { - std::stringstream stream; - for (int i = 0, limit = 16; i < limit; i++) { - stream << m[i]; - if (i != limit - 1) { - stream << ","; - } - } - return stream.str(); -} - -void Matrix::FromString(const std::string& str) { - std::stringstream stream(str); - for (int i = 0; i < 16; i++) { - stream >> m[i]; - stream.ignore(); - } -} - Matrix Matrix::Invert() const { Matrix tmp{ m[5] * m[10] * m[15] - m[5] * m[11] * m[14] - m[9] * m[6] * m[15] + @@ -467,16 +449,4 @@ uint64_t Matrix::Decomposition::GetComponentsMask() const { return mask; } -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; - - return stream.str(); -} - } // namespace impeller diff --git a/engine/src/flutter/impeller/geometry/matrix.h b/engine/src/flutter/impeller/geometry/matrix.h index f33f1755bab..9156b211a6a 100644 --- a/engine/src/flutter/impeller/geometry/matrix.h +++ b/engine/src/flutter/impeller/geometry/matrix.h @@ -39,8 +39,6 @@ struct Matrix { }; uint64_t GetComponentsMask() const; - - std::string ToString() const; }; using DecompositionResult = @@ -279,10 +277,6 @@ struct Matrix { Matrix operator*(const Matrix& m) const { return Multiply(m); } Matrix operator+(const Matrix& m) const; - - std::string ToString() const; - - void FromString(const std::string& str); }; static_assert(sizeof(struct Matrix) == sizeof(Scalar) * 16, diff --git a/engine/src/flutter/impeller/geometry/point.cc b/engine/src/flutter/impeller/geometry/point.cc index ca72d765501..a00f1bf57cf 100644 --- a/engine/src/flutter/impeller/geometry/point.cc +++ b/engine/src/flutter/impeller/geometry/point.cc @@ -7,17 +7,6 @@ namespace impeller { -std::string Point::ToString() const { - std::stringstream stream; - stream << x << "," << y; - return stream.str(); -} - -void Point::FromString(const std::string& str) { - std::stringstream stream(str); - stream >> x; - stream.ignore(); - stream >> y; -} +// } // namespace impeller diff --git a/engine/src/flutter/impeller/geometry/point.h b/engine/src/flutter/impeller/geometry/point.h index ba46e8283cc..10c25d996ee 100644 --- a/engine/src/flutter/impeller/geometry/point.h +++ b/engine/src/flutter/impeller/geometry/point.h @@ -69,10 +69,6 @@ struct Point { constexpr Scalar GetDistance(const Point& p) const { return sqrt(GetDistanceSquared(p)); } - - std::string ToString() const; - - void FromString(const std::string& str); }; static_assert(sizeof(Point) == 2 * sizeof(Scalar)); diff --git a/engine/src/flutter/impeller/geometry/rect.cc b/engine/src/flutter/impeller/geometry/rect.cc index 72d82d48a40..9d7e28fbcca 100644 --- a/engine/src/flutter/impeller/geometry/rect.cc +++ b/engine/src/flutter/impeller/geometry/rect.cc @@ -38,22 +38,4 @@ Rect Rect::WithPoints(const std::vector& points) const { return box; } -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) { - std::stringstream stream(str); - stream >> origin.x; - stream.ignore(); - stream >> origin.y; - stream.ignore(); - stream >> size.width; - stream.ignore(); - stream >> size.height; -} - } // namespace impeller diff --git a/engine/src/flutter/impeller/geometry/rect.h b/engine/src/flutter/impeller/geometry/rect.h index 21b5a905f1a..52ad8a54ee7 100644 --- a/engine/src/flutter/impeller/geometry/rect.h +++ b/engine/src/flutter/impeller/geometry/rect.h @@ -66,10 +66,6 @@ struct Rect { Rect WithPoint(const Point& p) const; Rect WithPoints(const std::vector& points) const; - - std::string ToString() const; - - void FromString(const std::string& str); }; static_assert(sizeof(Rect) == 4 * sizeof(Scalar)); diff --git a/engine/src/flutter/impeller/geometry/scalar.h b/engine/src/flutter/impeller/geometry/scalar.h index bf494586e7c..b7fe63c63f3 100644 --- a/engine/src/flutter/impeller/geometry/scalar.h +++ b/engine/src/flutter/impeller/geometry/scalar.h @@ -4,6 +4,8 @@ #pragma once +#include + namespace impeller { using Scalar = float; diff --git a/engine/src/flutter/impeller/geometry/size.cc b/engine/src/flutter/impeller/geometry/size.cc index da888d7a134..13bd3aebce2 100644 --- a/engine/src/flutter/impeller/geometry/size.cc +++ b/engine/src/flutter/impeller/geometry/size.cc @@ -7,17 +7,6 @@ namespace impeller { -std::string Size::ToString() const { - std::stringstream stream; - stream << width << "," << height; - return stream.str(); -} - -void Size::FromString(const std::string& str) { - std::stringstream stream(str); - stream >> width; - stream.ignore(); - stream >> height; -} +// } // namespace impeller diff --git a/engine/src/flutter/impeller/geometry/size.h b/engine/src/flutter/impeller/geometry/size.h index 04bce608a57..40fd2c673b2 100644 --- a/engine/src/flutter/impeller/geometry/size.h +++ b/engine/src/flutter/impeller/geometry/size.h @@ -63,10 +63,6 @@ struct Size { constexpr bool IsPositive() const { return width * height > 0.0; } constexpr bool IsEmpty() { return !IsPositive(); } - - std::string ToString() const; - - void FromString(const std::string& str); }; static_assert(sizeof(Size) == 2 * sizeof(Scalar));