From 4204ad3779f8d81db5f38d32cc50239fbb945d00 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Wed, 3 Nov 2021 15:49:54 -0700 Subject: [PATCH] Move entity shaders to their own directory. --- engine/src/flutter/impeller/entity/BUILD.gn | 8 +++--- .../entity/{ => shaders}/gradient_fill.frag | 0 .../entity/{ => shaders}/gradient_fill.vert | 0 .../entity/{ => shaders}/solid_fill.frag | 0 .../entity/{ => shaders}/solid_fill.vert | 0 engine/src/flutter/impeller/geometry/path.cc | 25 ++++++++++--------- engine/src/flutter/impeller/geometry/path.h | 12 ++++++++- .../impeller/geometry/path_component.cc | 8 +++--- .../impeller/geometry/path_component.h | 6 ++--- 9 files changed, 35 insertions(+), 24 deletions(-) rename engine/src/flutter/impeller/entity/{ => shaders}/gradient_fill.frag (100%) rename engine/src/flutter/impeller/entity/{ => shaders}/gradient_fill.vert (100%) rename engine/src/flutter/impeller/entity/{ => shaders}/solid_fill.frag (100%) rename engine/src/flutter/impeller/entity/{ => shaders}/solid_fill.vert (100%) diff --git a/engine/src/flutter/impeller/entity/BUILD.gn b/engine/src/flutter/impeller/entity/BUILD.gn index 1e7b138eb3..e4d368cc1a 100644 --- a/engine/src/flutter/impeller/entity/BUILD.gn +++ b/engine/src/flutter/impeller/entity/BUILD.gn @@ -8,10 +8,10 @@ impeller_shaders("entity_shaders") { name = "entity" shaders = [ - "gradient_fill.frag", - "gradient_fill.vert", - "solid_fill.frag", - "solid_fill.vert", + "shaders/gradient_fill.frag", + "shaders/gradient_fill.vert", + "shaders/solid_fill.frag", + "shaders/solid_fill.vert", ] } diff --git a/engine/src/flutter/impeller/entity/gradient_fill.frag b/engine/src/flutter/impeller/entity/shaders/gradient_fill.frag similarity index 100% rename from engine/src/flutter/impeller/entity/gradient_fill.frag rename to engine/src/flutter/impeller/entity/shaders/gradient_fill.frag diff --git a/engine/src/flutter/impeller/entity/gradient_fill.vert b/engine/src/flutter/impeller/entity/shaders/gradient_fill.vert similarity index 100% rename from engine/src/flutter/impeller/entity/gradient_fill.vert rename to engine/src/flutter/impeller/entity/shaders/gradient_fill.vert diff --git a/engine/src/flutter/impeller/entity/solid_fill.frag b/engine/src/flutter/impeller/entity/shaders/solid_fill.frag similarity index 100% rename from engine/src/flutter/impeller/entity/solid_fill.frag rename to engine/src/flutter/impeller/entity/shaders/solid_fill.frag diff --git a/engine/src/flutter/impeller/entity/solid_fill.vert b/engine/src/flutter/impeller/entity/shaders/solid_fill.vert similarity index 100% rename from engine/src/flutter/impeller/entity/solid_fill.vert rename to engine/src/flutter/impeller/entity/shaders/solid_fill.vert diff --git a/engine/src/flutter/impeller/geometry/path.cc b/engine/src/flutter/impeller/geometry/path.cc index 61a8d4c99d..2eb79b1a0b 100644 --- a/engine/src/flutter/impeller/geometry/path.cc +++ b/engine/src/flutter/impeller/geometry/path.cc @@ -32,25 +32,26 @@ Path& Path::AddCubicComponent(Point p1, Point cp1, Point cp2, Point p2) { return *this; } -void Path::EnumerateComponents(Applier linearApplier, - Applier quadApplier, - Applier cubicApplier) const { +void Path::EnumerateComponents( + Applier linear_applier, + Applier quad_applier, + Applier cubic_applier) const { size_t currentIndex = 0; for (const auto& component : components_) { switch (component.type) { case ComponentType::kLinear: - if (linearApplier) { - linearApplier(currentIndex, linears_[component.index]); + if (linear_applier) { + linear_applier(currentIndex, linears_[component.index]); } break; case ComponentType::kQuadratic: - if (quadApplier) { - quadApplier(currentIndex, quads_[component.index]); + if (quad_applier) { + quad_applier(currentIndex, quads_[component.index]); } break; case ComponentType::kCubic: - if (cubicApplier) { - cubicApplier(currentIndex, cubics_[component.index]); + if (cubic_applier) { + cubic_applier(currentIndex, cubics_[component.index]); } break; } @@ -155,15 +156,15 @@ std::vector Path::CreatePolyline( for (const auto& component : components_) { switch (component.type) { case ComponentType::kLinear: - AddPoints(points, linears_[component.index].SubdivideAdaptively()); + AddPoints(points, linears_[component.index].CreatePolyline()); break; case ComponentType::kQuadratic: AddPoints(points, - quads_[component.index].SubdivideAdaptively(approximation)); + quads_[component.index].CreatePolyline(approximation)); break; case ComponentType::kCubic: AddPoints(points, - cubics_[component.index].SubdivideAdaptively(approximation)); + cubics_[component.index].CreatePolyline(approximation)); break; } } diff --git a/engine/src/flutter/impeller/geometry/path.h b/engine/src/flutter/impeller/geometry/path.h index 8ae91753ff..1eda541179 100644 --- a/engine/src/flutter/impeller/geometry/path.h +++ b/engine/src/flutter/impeller/geometry/path.h @@ -7,10 +7,20 @@ #include #include -#include "path_component.h" +#include "impeller/geometry/path_component.h" namespace impeller { +//------------------------------------------------------------------------------ +/// @brief Paths are lightweight objects that describe a collection of +/// linear, quadratic, or cubic segments. +/// +/// All shapes supported by Impeller are paths either directly or +/// via approximation (in the case of circles). +/// +/// Creating paths that describe complex shapes is usually done by a +/// path builder. +/// class Path { public: enum class ComponentType { diff --git a/engine/src/flutter/impeller/geometry/path_component.cc b/engine/src/flutter/impeller/geometry/path_component.cc index 02c7242803..a4b4737d88 100644 --- a/engine/src/flutter/impeller/geometry/path_component.cc +++ b/engine/src/flutter/impeller/geometry/path_component.cc @@ -63,7 +63,7 @@ Point LinearPathComponent::Solve(Scalar time) const { }; } -std::vector LinearPathComponent::SubdivideAdaptively() const { +std::vector LinearPathComponent::CreatePolyline() const { return {p1, p2}; } @@ -85,10 +85,10 @@ Point QuadraticPathComponent::SolveDerivative(Scalar time) const { }; } -std::vector QuadraticPathComponent::SubdivideAdaptively( +std::vector QuadraticPathComponent::CreatePolyline( const SmoothingApproximation& approximation) const { CubicPathComponent elevated(*this); - return elevated.SubdivideAdaptively(approximation); + return elevated.CreatePolyline(approximation); } std::vector QuadraticPathComponent::Extrema() const { @@ -336,7 +336,7 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx, CubicPathSmoothenRecursive(approx, points, p1234, p234, p34, p4, level + 1); } -std::vector CubicPathComponent::SubdivideAdaptively( +std::vector CubicPathComponent::CreatePolyline( const SmoothingApproximation& approximation) const { std::vector points; points.emplace_back(p1); diff --git a/engine/src/flutter/impeller/geometry/path_component.h b/engine/src/flutter/impeller/geometry/path_component.h index cda5258eaa..289b72793e 100644 --- a/engine/src/flutter/impeller/geometry/path_component.h +++ b/engine/src/flutter/impeller/geometry/path_component.h @@ -41,7 +41,7 @@ struct LinearPathComponent { Point Solve(Scalar time) const; - std::vector SubdivideAdaptively() const; + std::vector CreatePolyline() const; std::vector Extrema() const; @@ -64,7 +64,7 @@ struct QuadraticPathComponent { Point SolveDerivative(Scalar time) const; - std::vector SubdivideAdaptively( + std::vector CreatePolyline( const SmoothingApproximation& approximation) const; std::vector Extrema() const; @@ -95,7 +95,7 @@ struct CubicPathComponent { Point SolveDerivative(Scalar time) const; - std::vector SubdivideAdaptively( + std::vector CreatePolyline( const SmoothingApproximation& approximation) const; std::vector Extrema() const;