10 #include "third_party/googletest/googletest/include/gtest/gtest.h"
17 return std::clamp(
x, 0.f, 1.f);
21 float CalculateLine(
const LineVertexShader::PerVertexData& per_vertex,
23 Vector3 pos = Vector3(position.x, position.y, 1.0);
24 Scalar d[4] = {pos.Dot(per_vertex.e0), pos.Dot(per_vertex.e1),
25 pos.Dot(per_vertex.e2), pos.Dot(per_vertex.e3)};
27 for (
int i = 0; i < 4; ++i) {
33 return lookup(std::min(d[0], d[2])) * lookup(std::min(d[1], d[3]));
40 auto geometry = std::make_unique<LineGeometry>(
45 std::unique_ptr<LineContents> contents =
47 EXPECT_TRUE(contents);
49 std::optional<Rect> coverage = contents->
GetCoverage(entity);
50 EXPECT_TRUE(coverage.has_value());
51 if (coverage.has_value()) {
52 Scalar lip = sqrt((width * width) / 2.f);
59 LineVertexShader::PerVertexData per_vertex[4];
60 auto geometry = std::make_unique<LineGeometry>(
67 fml::StatusOr<LineContents::EffectiveLineParameters> status =
71 ASSERT_TRUE(status.ok());
72 EXPECT_EQ(status.value().width, 5.f);
83 for (
int i = 1; i < 4; ++i) {
90 EXPECT_EQ(CalculateLine(per_vertex[0],
Point(0, 0)), 0.f);
91 EXPECT_NEAR(CalculateLine(per_vertex[0],
Point(150, 100 +
offset)), 0.f,
93 EXPECT_NEAR(CalculateLine(per_vertex[0],
Point(150, 100 +
offset * 0.5)),
95 EXPECT_NEAR(CalculateLine(per_vertex[0],
Point(150, 100)), 1.f,
103 EXPECT_EQ(
data.size(), 32u);
105 EXPECT_NEAR(
data[1] / 255.f, 0.5f, 0.02);
114 EXPECT_EQ(
data.size(), 32u);
116 EXPECT_NEAR(
data[1] / 255.f, 0.5f, 0.02);
123 LineVertexShader::PerVertexData per_vertex[4];
125 auto geometry = std::make_unique<LineGeometry>(
134 fml::StatusOr<LineContents::EffectiveLineParameters> status =
141 ASSERT_TRUE(status.ok());
154 EXPECT_NEAR(CalculateLine(per_vertex[0],
Point(150, 100)), 1.f,
std::optional< Rect > GetCoverage() const
static std::unique_ptr< LineContents > Make(std::unique_ptr< LineGeometry > geometry, Color color)
static std::vector< uint8_t > CreateCurveData(Scalar width, Scalar radius, Scalar scale)
static const Scalar kSampleRadius
static fml::StatusOr< EffectiveLineParameters > CalculatePerVertex(LineVertexShader::PerVertexData *per_vertex, const LineGeometry *geometry, const Matrix &entity_transform)
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
#define EXPECT_VECTOR3_NEAR(a, b)
#define EXPECT_POINT_NEAR(a, b)
ScopedObject< Object > Create(CtorArgs &&... args)
TEST(AllocationSizeTest, CanCreateTypedAllocations)
constexpr float kEhCloseEnough
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static constexpr Matrix MakeScale(const Vector3 &s)
constexpr static TRect MakeXYWH(Type x, Type y, Type width, Type height)
std::shared_ptr< const fml::Mapping > data