Skip to content

Commit

Permalink
Move entity shaders to their own directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaygarde authored and dnfield committed Apr 27, 2022
1 parent 28af36b commit 08f00cd
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 24 deletions.
8 changes: 4 additions & 4 deletions impeller/entity/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 13 additions & 12 deletions impeller/geometry/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,26 @@ Path& Path::AddCubicComponent(Point p1, Point cp1, Point cp2, Point p2) {
return *this;
}

void Path::EnumerateComponents(Applier<LinearPathComponent> linearApplier,
Applier<QuadraticPathComponent> quadApplier,
Applier<CubicPathComponent> cubicApplier) const {
void Path::EnumerateComponents(
Applier<LinearPathComponent> linear_applier,
Applier<QuadraticPathComponent> quad_applier,
Applier<CubicPathComponent> 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;
}
Expand Down Expand Up @@ -155,15 +156,15 @@ std::vector<Point> 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;
}
}
Expand Down
12 changes: 11 additions & 1 deletion impeller/geometry/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
#include <functional>
#include <vector>

#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 {
Expand Down
8 changes: 4 additions & 4 deletions impeller/geometry/path_component.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Point LinearPathComponent::Solve(Scalar time) const {
};
}

std::vector<Point> LinearPathComponent::SubdivideAdaptively() const {
std::vector<Point> LinearPathComponent::CreatePolyline() const {
return {p1, p2};
}

Expand All @@ -85,10 +85,10 @@ Point QuadraticPathComponent::SolveDerivative(Scalar time) const {
};
}

std::vector<Point> QuadraticPathComponent::SubdivideAdaptively(
std::vector<Point> QuadraticPathComponent::CreatePolyline(
const SmoothingApproximation& approximation) const {
CubicPathComponent elevated(*this);
return elevated.SubdivideAdaptively(approximation);
return elevated.CreatePolyline(approximation);
}

std::vector<Point> QuadraticPathComponent::Extrema() const {
Expand Down Expand Up @@ -336,7 +336,7 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx,
CubicPathSmoothenRecursive(approx, points, p1234, p234, p34, p4, level + 1);
}

std::vector<Point> CubicPathComponent::SubdivideAdaptively(
std::vector<Point> CubicPathComponent::CreatePolyline(
const SmoothingApproximation& approximation) const {
std::vector<Point> points;
points.emplace_back(p1);
Expand Down
6 changes: 3 additions & 3 deletions impeller/geometry/path_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct LinearPathComponent {

Point Solve(Scalar time) const;

std::vector<Point> SubdivideAdaptively() const;
std::vector<Point> CreatePolyline() const;

std::vector<Point> Extrema() const;

Expand All @@ -64,7 +64,7 @@ struct QuadraticPathComponent {

Point SolveDerivative(Scalar time) const;

std::vector<Point> SubdivideAdaptively(
std::vector<Point> CreatePolyline(
const SmoothingApproximation& approximation) const;

std::vector<Point> Extrema() const;
Expand Down Expand Up @@ -95,7 +95,7 @@ struct CubicPathComponent {

Point SolveDerivative(Scalar time) const;

std::vector<Point> SubdivideAdaptively(
std::vector<Point> CreatePolyline(
const SmoothingApproximation& approximation) const;

std::vector<Point> Extrema() const;
Expand Down

0 comments on commit 08f00cd

Please sign in to comment.