Remove stringification in impeller/geometry.

This commit is contained in:
Chinmay Garde 2021-06-15 13:29:07 -07:00 committed by Dan Field
parent 2ed5f9fec6
commit da597d0321
11 changed files with 6 additions and 125 deletions

View File

@ -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

View File

@ -4,9 +4,6 @@
#pragma once
#include <stdint.h>
#include <string>
#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));

View File

@ -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 <climits>
#include <sstream>
@ -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

View File

@ -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,

View File

@ -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

View File

@ -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));

View File

@ -38,22 +38,4 @@ Rect Rect::WithPoints(const std::vector<Point>& 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

View File

@ -66,10 +66,6 @@ struct Rect {
Rect WithPoint(const Point& p) const;
Rect WithPoints(const std::vector<Point>& points) const;
std::string ToString() const;
void FromString(const std::string& str);
};
static_assert(sizeof(Rect) == 4 * sizeof(Scalar));

View File

@ -4,6 +4,8 @@
#pragma once
#include <cfloat>
namespace impeller {
using Scalar = float;

View File

@ -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

View File

@ -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));