From df117ace53cd999d1b94b4d03900966058752d3a Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 21 Oct 2022 16:06:34 -0700 Subject: [PATCH 1/2] [Impeller] move some methods to VerticesGeometry --- impeller/entity/contents/vertices_contents.cc | 2 +- impeller/entity/contents/vertices_contents.h | 4 +- impeller/entity/geometry.cc | 59 +--------------- impeller/entity/geometry.h | 70 ++++--------------- 4 files changed, 18 insertions(+), 117 deletions(-) diff --git a/impeller/entity/contents/vertices_contents.cc b/impeller/entity/contents/vertices_contents.cc index f789228972be2..d34f48e109fd5 100644 --- a/impeller/entity/contents/vertices_contents.cc +++ b/impeller/entity/contents/vertices_contents.cc @@ -25,7 +25,7 @@ std::optional VerticesContents::GetCoverage(const Entity& entity) const { return geometry_->GetCoverage(entity.GetTransformation()); }; -void VerticesContents::SetGeometry(std::unique_ptr geometry) { +void VerticesContents::SetGeometry(std::unique_ptr geometry) { geometry_ = std::move(geometry); } diff --git a/impeller/entity/contents/vertices_contents.h b/impeller/entity/contents/vertices_contents.h index 191214168c935..b509b0a3b39fe 100644 --- a/impeller/entity/contents/vertices_contents.h +++ b/impeller/entity/contents/vertices_contents.h @@ -26,7 +26,7 @@ class VerticesContents final : public Contents { ~VerticesContents() override; - void SetGeometry(std::unique_ptr geometry); + void SetGeometry(std::unique_ptr geometry); void SetColor(Color color); @@ -42,7 +42,7 @@ class VerticesContents final : public Contents { public: Color color_; - std::unique_ptr geometry_; + std::unique_ptr geometry_; BlendMode blend_mode_ = BlendMode::kSource; FML_DISALLOW_COPY_AND_ASSIGN(VerticesContents); diff --git a/impeller/entity/geometry.cc b/impeller/entity/geometry.cc index aad8042d4c4f9..51d271c81a27f 100644 --- a/impeller/entity/geometry.cc +++ b/impeller/entity/geometry.cc @@ -17,7 +17,7 @@ Geometry::Geometry() = default; Geometry::~Geometry() = default; // static -std::unique_ptr Geometry::MakeVertices(Vertices vertices) { +std::unique_ptr Geometry::MakeVertices(Vertices vertices) { return std::make_unique(std::move(vertices)); } @@ -171,7 +171,8 @@ GeometryResult VerticesGeometry::GetPositionUVBuffer( const ContentContext& renderer, const Entity& entity, RenderPass& pass) { - // TODO(jonahwilliams): support texture coordinates in vertices. + // TODO(jonahwilliams): support texture coordinates in vertices + // https://github.com/flutter/flutter/issues/109956 return {}; } @@ -222,24 +223,6 @@ GeometryResult FillPathGeometry::GetPositionBuffer( }; } -GeometryResult FillPathGeometry::GetPositionColorBuffer( - const ContentContext& renderer, - const Entity& entity, - RenderPass& pass, - Color paint_color, - BlendMode blend_mode) { - // TODO(jonahwilliams): support per-color vertex in path geometry. - return {}; -} - -GeometryResult FillPathGeometry::GetPositionUVBuffer( - const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) { - // TODO(jonahwilliams): support texture coordinates in path geometry. - return {}; -} - GeometryVertexType FillPathGeometry::GetVertexType() const { return GeometryVertexType::kPosition; } @@ -593,24 +576,6 @@ GeometryResult StrokePathGeometry::GetPositionBuffer( }; } -GeometryResult StrokePathGeometry::GetPositionColorBuffer( - const ContentContext& renderer, - const Entity& entity, - RenderPass& pass, - Color paint_color, - BlendMode blend_mode) { - // TODO(jonahwilliams): support per-color vertex in path geometry. - return {}; -} - -GeometryResult StrokePathGeometry::GetPositionUVBuffer( - const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) { - // TODO(jonahwilliams): support texture coordinates in path geometry. - return {}; -} - GeometryVertexType StrokePathGeometry::GetVertexType() const { return GeometryVertexType::kPosition; } @@ -669,24 +634,6 @@ GeometryResult CoverGeometry::GetPositionBuffer(const ContentContext& renderer, }; } -GeometryResult CoverGeometry::GetPositionColorBuffer( - const ContentContext& renderer, - const Entity& entity, - RenderPass& pass, - Color paint_color, - BlendMode blend_mode) { - // TODO(jonahwilliams): support per-color vertex in cover geometry. - return {}; -} - -GeometryResult CoverGeometry::GetPositionUVBuffer( - const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) { - // TODO(jonahwilliams): support texture coordinates in cover geometry. - return {}; -} - GeometryVertexType CoverGeometry::GetVertexType() const { return GeometryVertexType::kPosition; } diff --git a/impeller/entity/geometry.h b/impeller/entity/geometry.h index e0b69042b9761..aa6313cae5490 100644 --- a/impeller/entity/geometry.h +++ b/impeller/entity/geometry.h @@ -42,13 +42,15 @@ enum class Join { kBevel, }; +class VerticesGeometry; + class Geometry { public: Geometry(); virtual ~Geometry(); - static std::unique_ptr MakeVertices(Vertices vertices); + static std::unique_ptr MakeVertices(Vertices vertices); static std::unique_ptr MakeFillPath(Path path); @@ -65,16 +67,6 @@ class Geometry { const Entity& entity, RenderPass& pass) = 0; - virtual GeometryResult GetPositionColorBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass, - Color paint_color, - BlendMode blend_mode) = 0; - - virtual GeometryResult GetPositionUVBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) = 0; - virtual GeometryVertexType GetVertexType() const = 0; virtual std::optional GetCoverage(const Matrix& transform) const = 0; @@ -87,30 +79,28 @@ class VerticesGeometry : public Geometry { ~VerticesGeometry(); - private: - // |Geometry| - GeometryResult GetPositionBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) override; - - // |Geometry| GeometryResult GetPositionColorBuffer(const ContentContext& renderer, const Entity& entity, RenderPass& pass, Color paint_color, - BlendMode blend_mode) override; + BlendMode blend_mode); - // |Geometry| GeometryResult GetPositionUVBuffer(const ContentContext& renderer, const Entity& entity, - RenderPass& pass) override; + RenderPass& pass); // |Geometry| - GeometryVertexType GetVertexType() const override; + GeometryResult GetPositionBuffer(const ContentContext& renderer, + const Entity& entity, + RenderPass& pass) override; // |Geometry| std::optional GetCoverage(const Matrix& transform) const override; + // |Geometry| + GeometryVertexType GetVertexType() const override; + + private: Vertices vertices_; FML_DISALLOW_COPY_AND_ASSIGN(VerticesGeometry); @@ -129,18 +119,6 @@ class FillPathGeometry : public Geometry { const Entity& entity, RenderPass& pass) override; - // |Geometry| - GeometryResult GetPositionColorBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass, - Color paint_color, - BlendMode blend_mode) override; - - // |Geometry| - GeometryResult GetPositionUVBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) override; - // |Geometry| GeometryVertexType GetVertexType() const override; @@ -192,18 +170,6 @@ class StrokePathGeometry : public Geometry { const Entity& entity, RenderPass& pass) override; - // |Geometry| - GeometryResult GetPositionColorBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass, - Color paint_color, - BlendMode blend_mode) override; - - // |Geometry| - GeometryResult GetPositionUVBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) override; - // |Geometry| GeometryVertexType GetVertexType() const override; @@ -251,18 +217,6 @@ class CoverGeometry : public Geometry { const Entity& entity, RenderPass& pass) override; - // |Geometry| - GeometryResult GetPositionColorBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass, - Color paint_color, - BlendMode blend_mode) override; - - // |Geometry| - GeometryResult GetPositionUVBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) override; - // |Geometry| GeometryVertexType GetVertexType() const override; From a012496dd6b9e0f775efbd9acfad4daa3aaeb52c Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 21 Oct 2022 18:13:46 -0700 Subject: [PATCH 2/2] ++ --- impeller/entity/geometry.cc | 17 ----------------- impeller/entity/geometry.h | 12 ------------ 2 files changed, 29 deletions(-) diff --git a/impeller/entity/geometry.cc b/impeller/entity/geometry.cc index c845f366d9e8e..aed7ce69e632d 100644 --- a/impeller/entity/geometry.cc +++ b/impeller/entity/geometry.cc @@ -671,23 +671,6 @@ GeometryResult RectGeometry::GetPositionBuffer(const ContentContext& renderer, }; } -GeometryResult RectGeometry::GetPositionColorBuffer( - const ContentContext& renderer, - const Entity& entity, - RenderPass& pass, - Color paint_color, - BlendMode blend_mode) { - // TODO(jonahwilliams): support per-color vertex in rect geometry. - return {}; -} - -GeometryResult RectGeometry::GetPositionUVBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) { - // TODO(jonahwilliams): support texture coordinates in rect geometry. - return {}; -} - GeometryVertexType RectGeometry::GetVertexType() const { return GeometryVertexType::kPosition; } diff --git a/impeller/entity/geometry.h b/impeller/entity/geometry.h index 86dcbd6a3c260..799a77c7de74f 100644 --- a/impeller/entity/geometry.h +++ b/impeller/entity/geometry.h @@ -240,18 +240,6 @@ class RectGeometry : public Geometry { const Entity& entity, RenderPass& pass) override; - // |Geometry| - GeometryResult GetPositionColorBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass, - Color paint_color, - BlendMode blend_mode) override; - - // |Geometry| - GeometryResult GetPositionUVBuffer(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) override; - // |Geometry| GeometryVertexType GetVertexType() const override;