Patch namespace.

This commit is contained in:
Chinmay Garde 2021-05-05 21:31:20 -07:00 committed by Dan Field
parent 864cc59f52
commit 5afc2d547b
28 changed files with 115 additions and 173 deletions

View File

@ -7,8 +7,7 @@
#include <cmath>
#include <sstream>
namespace rl {
namespace entity {
namespace impeller {
ColorHSB ColorHSB::FromRGB(Color rgb) {
double R = rgb.red;
@ -37,7 +36,7 @@ ColorHSB ColorHSB::FromRGB(Color rgb) {
return ColorHSB(((i - f / (v - x)) / 6.0), (v - x) / v, v, rgb.alpha);
}
Color ColorHSB::toRGBA() const {
Color ColorHSB::ToRGBA() const {
double h = hue * 6.0;
double s = saturation;
double v = brightness;
@ -85,14 +84,14 @@ Color ColorHSB::toRGBA() const {
return Color(0, 0, 0, alpha);
}
std::string ColorHSB::toString() const {
std::string ColorHSB::ToString() const {
std::stringstream stream;
stream << "{" << hue << ", " << saturation << ", " << brightness << ", "
<< alpha << "}";
return stream.str();
}
Color::Color(const ColorHSB& hsbColor) : Color(hsbColor.toRGBA()) {}
Color::Color(const ColorHSB& hsbColor) : Color(hsbColor.ToRGBA()) {}
std::string Color::ToString() const {
std::stringstream stream;
@ -111,5 +110,4 @@ void Color::FromString(const std::string& str) {
stream >> alpha;
}
} // namespace entity
} // namespace rl
} // namespace impeller

View File

@ -7,8 +7,7 @@
#include <stdint.h>
#include <string>
namespace rl {
namespace entity {
namespace impeller {
struct ColorHSB;
@ -662,10 +661,9 @@ struct ColorHSB {
static ColorHSB FromRGB(Color rgb);
Color toRGBA() const;
Color ToRGBA() const;
std::string toString() const;
std::string ToString() const;
};
} // namespace entity
} // namespace rl
} // namespace impeller

View File

@ -4,65 +4,63 @@
#include "Entity.h"
namespace rl {
namespace entity {
namespace impeller {
Entity::Entity() = default;
Entity::~Entity() = default;
geom::Rect Entity::GetFrame() const {
geom::Point origin(position_.x - (bounds_.size.width * anchor_point_.x),
position_.y - (bounds_.size.height * anchor_point_.y));
Rect Entity::GetFrame() const {
Point origin(position_.x - (bounds_.size.width * anchor_point_.x),
position_.y - (bounds_.size.height * anchor_point_.y));
return geom::Rect(origin, bounds_.size);
return Rect(origin, bounds_.size);
}
void Entity::SetFrame(const geom::Rect& frame) {
SetBounds(geom::Rect(bounds_.origin, frame.size));
SetPosition(
geom::Point(frame.origin.x + (anchor_point_.x * frame.size.width),
frame.origin.y + (anchor_point_.y * frame.size.height)));
void Entity::SetFrame(const Rect& frame) {
SetBounds(Rect(bounds_.origin, frame.size));
SetPosition(Point(frame.origin.x + (anchor_point_.x * frame.size.width),
frame.origin.y + (anchor_point_.y * frame.size.height)));
}
const geom::Rect& Entity::GetBounds() const {
const Rect& Entity::GetBounds() const {
return bounds_;
}
void Entity::SetBounds(const geom::Rect& bounds) {
void Entity::SetBounds(const Rect& bounds) {
bounds_ = bounds;
}
const geom::Point& Entity::GetPosition() const {
const Point& Entity::GetPosition() const {
return position_;
}
void Entity::SetPosition(const geom::Point& position) {
void Entity::SetPosition(const Point& position) {
position_ = position;
}
const geom::Point& Entity::GetAnchorPoint() const {
const Point& Entity::GetAnchorPoint() const {
return anchor_point_;
}
void Entity::SetAnchorPoint(const geom::Point& anchorPoint) {
void Entity::SetAnchorPoint(const Point& anchorPoint) {
anchor_point_ = anchorPoint;
}
const geom::Matrix& Entity::GetTransformation() const {
const Matrix& Entity::GetTransformation() const {
return transformation_;
}
void Entity::SetTransformation(const geom::Matrix& transformation) {
void Entity::SetTransformation(const Matrix& transformation) {
transformation_ = transformation;
}
geom::Matrix Entity::GetModelMatrix() const {
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::MakeTranslation(
auto translation = Matrix::MakeTranslation(
{-bounds_.origin.x + position_.x - (bounds_.size.width * anchor_point_.x),
-bounds_.origin.y + position_.y -
(bounds_.size.height * anchor_point_.y)});
@ -78,8 +76,8 @@ geom::Matrix Entity::GetModelMatrix() const {
}
auto anchorAdjustment =
geom::Matrix::MakeTranslation({-anchor_point_.x * bounds_.size.width,
-anchor_point_.y * bounds_.size.height});
Matrix::MakeTranslation({-anchor_point_.x * bounds_.size.width,
-anchor_point_.y * bounds_.size.height});
return translation * anchorAdjustment.Invert() * transformation_ *
anchorAdjustment;
@ -117,13 +115,12 @@ void Entity::SetStrokeSize(double strokeSize) {
stroke_size_ = strokeSize;
}
const geom::Path& Entity::GetPath() const {
const Path& Entity::GetPath() const {
return path_;
}
void Entity::SetPath(geom::Path path) {
void Entity::SetPath(Path path) {
path_ = std::move(path);
}
} // namespace entity
} // namespace rl
} // namespace impeller

View File

@ -10,8 +10,7 @@
#include "Path.h"
#include "Rect.h"
namespace rl {
namespace entity {
namespace impeller {
class Entity {
public:
@ -26,14 +25,14 @@ class Entity {
*
* @return the frame of the entity
*/
geom::Rect GetFrame() const;
Rect GetFrame() const;
/**
* Set the frame of the entity
*
* @param frame the new frame
*/
void SetFrame(const geom::Rect& frame);
void SetFrame(const Rect& frame);
/**
* The bounds specifies the origin and size of the entity in its own
@ -41,14 +40,14 @@ class Entity {
*
* @return the bounds of the entity
*/
const geom::Rect& GetBounds() const;
const Rect& GetBounds() const;
/**
* Set the bounds of the entity
*
* @param bounds the new bounds
*/
void SetBounds(const geom::Rect& bounds);
void SetBounds(const Rect& bounds);
/**
* The position specifies the coordinates of the anchor position of the
@ -56,49 +55,49 @@ class Entity {
*
* @return the position of the entity
*/
const geom::Point& GetPosition() const;
const Point& GetPosition() const;
/**
* Sets the position of the entity
*
* @param point the new position
*/
void SetPosition(const geom::Point& point);
void SetPosition(const Point& point);
/**
* The position of the anchor point within this node in unit space
*
* @return the anchor point
*/
const geom::Point& GetAnchorPoint() const;
const Point& GetAnchorPoint() const;
/**
* Sets the new anchor point of this node
*
* @param anchorPoint the new anchor point
*/
void SetAnchorPoint(const geom::Point& anchorPoint);
void SetAnchorPoint(const Point& anchorPoint);
/**
* The transformation that is applied to the entity about its anchor point
*
* @return the transformation applied to the node
*/
const geom::Matrix& GetTransformation() const;
const Matrix& GetTransformation() const;
/**
* Sets the transformation of the entity
*
* @param transformation the new transformation
*/
void SetTransformation(const geom::Matrix& transformation);
void SetTransformation(const Matrix& transformation);
/**
* The model matrix of the entity
*
* @return the view matrix
*/
geom::Matrix GetModelMatrix() const;
Matrix GetModelMatrix() const;
/**
* The background color of the entity
@ -137,18 +136,18 @@ class Entity {
void SetStrokeSize(double strokeSize);
const geom::Path& GetPath() const;
const Path& GetPath() const;
void SetPath(geom::Path path);
void SetPath(Path path);
private:
geom::Rect bounds_;
geom::Point position_;
geom::Point anchor_point_ = {0.5, 0.5};
geom::Matrix transformation_;
Rect bounds_;
Point position_;
Point anchor_point_ = {0.5, 0.5};
Matrix transformation_;
Color background_color_;
geom::Path path_;
Path path_;
double opacity_ = 1.0;
Color stroke_color_ = Color::Black();
double stroke_size_ = 1.0;
@ -156,5 +155,4 @@ class Entity {
FML_DISALLOW_COPY_AND_ASSIGN(Entity);
};
} // namespace entity
} // namespace rl
} // namespace impeller

View File

@ -6,8 +6,7 @@
#include <climits>
#include <sstream>
namespace rl {
namespace geom {
namespace impeller {
Matrix::Matrix(const Decomposition& d) : Matrix() {
/*
@ -480,5 +479,4 @@ std::string Matrix::Decomposition::ToString() const {
return stream.str();
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -13,8 +13,7 @@
#include "Size.h"
#include "Vector.h"
namespace rl {
namespace geom {
namespace impeller {
struct Matrix {
union {
@ -295,5 +294,4 @@ inline Vector4 operator*(const Vector4& v, const Matrix& m) {
v.x * m.m[3] + v.y * m.m[7] + v.z * m.m[11] + v.w * m.m[15]);
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -4,8 +4,7 @@
#include "Path.h"
namespace rl {
namespace geom {
namespace impeller {
Path::Path() = default;
@ -191,5 +190,4 @@ Rect Path::GetBoundingBox() const {
return box;
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -6,10 +6,10 @@
#include <functional>
#include <vector>
#include "PathComponent.h"
namespace rl {
namespace geom {
namespace impeller {
class Path {
public:
@ -76,5 +76,4 @@ class Path {
std::vector<CubicPathComponent> cubics_;
};
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -4,8 +4,7 @@
#include "PathBuilder.h"
namespace rl {
namespace geom {
namespace impeller {
static const double kArcApproximationMagic = 0.551915024494;
@ -323,5 +322,4 @@ PathBuilder& PathBuilder::AddEllipse(const Point& center, const Size& radius) {
return *this;
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -8,8 +8,7 @@
#include "Rect.h"
#include "flutter/fml/macros.h"
namespace rl {
namespace geom {
namespace impeller {
class PathBuilder {
public:
@ -53,13 +52,12 @@ class PathBuilder {
PathBuilder& AddEllipse(const Point& center, const Size& size);
struct RoundingRadii {
double topLeft;
double bottomLeft;
double topRight;
double bottomRight;
double topLeft = 0.0;
double bottomLeft = 0.0;
double topRight = 0.0;
double bottomRight = 0.0;
RoundingRadii()
: topLeft(0.0), bottomLeft(0.0), topRight(0.0), bottomRight(0.0) {}
RoundingRadii() {}
RoundingRadii(double pTopLeft,
double pBottomLeft,
@ -85,5 +83,4 @@ class PathBuilder {
FML_DISALLOW_COPY_AND_ASSIGN(PathBuilder);
};
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -5,8 +5,7 @@
#include "PathComponent.h"
#include <cmath>
namespace rl {
namespace geom {
namespace impeller {
static const size_t kRecursionLimit = 32;
static const double kCurveCollinearityEpsilon = 1e-30;
@ -416,5 +415,4 @@ std::vector<Point> CubicPathComponent::Extrema() const {
return points;
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -8,8 +8,7 @@
#include "Rect.h"
namespace rl {
namespace geom {
namespace impeller {
struct SmoothingApproximation {
const double scale;
@ -106,5 +105,4 @@ struct CubicPathComponent {
}
};
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -5,8 +5,7 @@
#include "Point.h"
#include <sstream>
namespace rl {
namespace geom {
namespace impeller {
std::string Point::ToString() const {
std::stringstream stream;
@ -31,5 +30,4 @@ double Point::GetDistance(const Point& p) const {
return sqrt(GetDistanceSquared(p));
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -8,8 +8,7 @@
#include <string>
#include "Size.h"
namespace rl {
namespace geom {
namespace impeller {
struct Point {
double x = 0.0;
@ -57,5 +56,4 @@ struct Point {
void FromString(const std::string& str);
};
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -5,8 +5,7 @@
#include "Quaternion.h"
#include <sstream>
namespace rl {
namespace geom {
namespace impeller {
Quaternion Quaternion::Slerp(const Quaternion& to, double time) const {
double cosine = Dot(to);
@ -35,5 +34,4 @@ std::string Quaternion::ToString() const {
return stream.str();
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -6,8 +6,7 @@
#include "Vector.h"
namespace rl {
namespace geom {
namespace impeller {
struct Quaternion {
union {
@ -78,5 +77,4 @@ struct Quaternion {
std::string ToString() const;
};
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -5,8 +5,7 @@
#include "Rect.h"
#include <sstream>
namespace rl {
namespace geom {
namespace impeller {
Rect Rect::WithPoint(const Point& p) const {
Rect copy = *this;
@ -57,5 +56,4 @@ void Rect::FromString(const std::string& str) {
stream >> size.height;
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -8,8 +8,7 @@
#include "Point.h"
#include "Size.h"
namespace rl {
namespace geom {
namespace impeller {
struct Rect {
Point origin;
@ -71,5 +70,4 @@ struct Rect {
void FromString(const std::string& str);
};
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -5,8 +5,7 @@
#include "Shear.h"
#include <sstream>
namespace rl {
namespace geom {
namespace impeller {
std::string Shear::ToString() const {
std::stringstream stream;
@ -14,5 +13,4 @@ std::string Shear::ToString() const {
return stream.str();
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -6,8 +6,7 @@
#include <string>
namespace rl {
namespace geom {
namespace impeller {
struct Shear {
union {
@ -32,5 +31,4 @@ struct Shear {
std::string ToString() const;
};
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -5,8 +5,7 @@
#include "Size.h"
#include <sstream>
namespace rl {
namespace geom {
namespace impeller {
std::string Size::ToString() const {
std::stringstream stream;
@ -21,5 +20,4 @@ void Size::FromString(const std::string& str) {
stream >> height;
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -6,8 +6,7 @@
#include <string>
namespace rl {
namespace geom {
namespace impeller {
struct Size {
double width = 0.0;
@ -54,5 +53,4 @@ struct Size {
void FromString(const std::string& str);
};
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -5,8 +5,7 @@
#include "Vector.h"
#include <sstream>
namespace rl {
namespace geom {
namespace impeller {
std::string Vector3::ToString() const {
std::stringstream stream;
@ -20,5 +19,4 @@ std::string Vector4::ToString() const {
return stream.str();
}
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -9,8 +9,7 @@
#include "Point.h"
#include "Size.h"
namespace rl {
namespace geom {
namespace impeller {
struct Vector3 {
union {
@ -141,5 +140,4 @@ struct Vector4 {
std::string ToString() const;
};
} // namespace geom
} // namespace rl
} // namespace impeller

View File

@ -5,8 +5,7 @@
#include "Image.h"
#include <stb_image.h>
namespace rl {
namespace image {
namespace impeller {
Image::Image(std::shared_ptr<const fml::Mapping> sourceAllocation)
: source_(std::move(sourceAllocation)) {}
@ -72,10 +71,9 @@ ImageResult Image::Decode() const {
}
return ImageResult{
geom::Size{static_cast<double>(width),
static_cast<double>(height)}, // size
components, // components
std::move(destinationAllocation) // allocation
Size{static_cast<double>(width), static_cast<double>(height)}, // size
components, // components
std::move(destinationAllocation) // allocation
};
}
@ -83,5 +81,4 @@ bool Image::IsValid() const {
return static_cast<bool>(source_);
}
} // namespace image
} // namespace rl
} // namespace impeller

View File

@ -9,8 +9,7 @@
#include "flutter/fml/macros.h"
#include "flutter/fml/mapping.h"
namespace rl {
namespace image {
namespace impeller {
class ImageSource;
@ -28,5 +27,4 @@ class Image {
std::shared_ptr<const fml::Mapping> source_;
};
} // namespace image
} // namespace rl
} // namespace impeller

View File

@ -4,12 +4,11 @@
#include "ImageResult.h"
namespace rl {
namespace image {
namespace impeller {
ImageResult::ImageResult() = default;
ImageResult::ImageResult(geom::Size size,
ImageResult::ImageResult(Size size,
Components components,
std::shared_ptr<const fml::Mapping> allocation)
: success_(true),
@ -23,7 +22,7 @@ bool ImageResult::WasSuccessful() const {
return success_;
}
const geom::Size& ImageResult::GetSize() const {
const Size& ImageResult::GetSize() const {
return size_;
}
@ -35,5 +34,4 @@ const std::shared_ptr<const fml::Mapping>& ImageResult::Allocation() const {
return allocation_;
}
} // namespace image
} // namespace rl
} // namespace impeller

View File

@ -10,8 +10,7 @@
#include "flutter/fml/macros.h"
#include "flutter/fml/mapping.h"
namespace rl {
namespace image {
namespace impeller {
class ImageResult {
public:
@ -25,13 +24,13 @@ class ImageResult {
ImageResult();
ImageResult(geom::Size size,
ImageResult(Size size,
Components components,
std::shared_ptr<const fml::Mapping> allocation);
~ImageResult();
const geom::Size& GetSize() const;
const Size& GetSize() const;
bool WasSuccessful() const;
@ -41,12 +40,11 @@ class ImageResult {
private:
bool success_ = false;
geom::Size size_;
Size size_;
Components components_ = Components::Invalid;
std::shared_ptr<const fml::Mapping> allocation_;
FML_DISALLOW_COPY_AND_ASSIGN(ImageResult);
};
} // namespace image
} // namespace rl
} // namespace impeller