From 37aa63cf06113af973374386ffc2287798f32bfa Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Wed, 18 Aug 2021 01:02:21 -0700 Subject: [PATCH] Setup render command for solid fill. --- .../flutter/impeller/aiks/picture_renderer.h | 2 +- .../flutter/impeller/aiks/picture_renderer.mm | 2 +- .../flutter/impeller/compositor/pipeline.h | 2 +- engine/src/flutter/impeller/entity/entity.cc | 6 +++++- engine/src/flutter/impeller/entity/entity.h | 2 ++ .../flutter/impeller/entity/entity_renderer.h | 2 +- .../impeller/entity/entity_renderer.mm | 2 +- .../impeller/entity/entity_renderer_impl.h | 2 +- .../impeller/entity/entity_renderer_impl.mm | 21 +++++++++++++++++-- 9 files changed, 32 insertions(+), 9 deletions(-) diff --git a/engine/src/flutter/impeller/aiks/picture_renderer.h b/engine/src/flutter/impeller/aiks/picture_renderer.h index 83ffcc04bd8..3e3ab2939ca 100644 --- a/engine/src/flutter/impeller/aiks/picture_renderer.h +++ b/engine/src/flutter/impeller/aiks/picture_renderer.h @@ -23,7 +23,7 @@ class PictureRenderer { bool IsValid() const; [[nodiscard]] bool Render(const Surface& surface, - const RenderPass& onscreen_pass, + RenderPass& onscreen_pass, const Picture& picture); private: diff --git a/engine/src/flutter/impeller/aiks/picture_renderer.mm b/engine/src/flutter/impeller/aiks/picture_renderer.mm index 826da4cd74c..ad613a0ccd7 100644 --- a/engine/src/flutter/impeller/aiks/picture_renderer.mm +++ b/engine/src/flutter/impeller/aiks/picture_renderer.mm @@ -23,7 +23,7 @@ bool PictureRenderer::IsValid() const { } bool PictureRenderer::Render(const Surface& surface, - const RenderPass& onscreen_pass, + RenderPass& onscreen_pass, const Picture& picture) { if (!IsValid()) { return false; diff --git a/engine/src/flutter/impeller/compositor/pipeline.h b/engine/src/flutter/impeller/compositor/pipeline.h index 59c4ddbd92f..35f1351af76 100644 --- a/engine/src/flutter/impeller/compositor/pipeline.h +++ b/engine/src/flutter/impeller/compositor/pipeline.h @@ -63,7 +63,7 @@ class PipelineT { context, Builder::MakeDefaultPipelineDescriptor(context))) {} - const Pipeline* WaitAndGet() { return pipeline_future_.get().get(); } + std::shared_ptr WaitAndGet() { return pipeline_future_.get(); } private: PipelineFuture pipeline_future_; diff --git a/engine/src/flutter/impeller/entity/entity.cc b/engine/src/flutter/impeller/entity/entity.cc index f6adb865111..51acf97e5a0 100644 --- a/engine/src/flutter/impeller/entity/entity.cc +++ b/engine/src/flutter/impeller/entity/entity.cc @@ -62,6 +62,10 @@ bool Entity::HasStroke() const { return stroke_size_ > 0.0 && !stroke_color_.IsTransparent(); } +bool Entity::HasContents() const { + return !background_color_.IsTransparent(); +} + bool Entity::HasRenderableContents() const { const bool has_empty_path = path_.GetBoundingBox().IsZero(); @@ -77,7 +81,7 @@ bool Entity::HasRenderableContents() const { return true; } - if (!background_color_.IsTransparent()) { + if (HasContents()) { return true; } diff --git a/engine/src/flutter/impeller/entity/entity.h b/engine/src/flutter/impeller/entity/entity.h index 5b3fedee761..43dd3f3fdc4 100644 --- a/engine/src/flutter/impeller/entity/entity.h +++ b/engine/src/flutter/impeller/entity/entity.h @@ -44,6 +44,8 @@ class Entity { bool HasStroke() const; + bool HasContents() const; + bool HasRenderableContents() const; private: diff --git a/engine/src/flutter/impeller/entity/entity_renderer.h b/engine/src/flutter/impeller/entity/entity_renderer.h index 4da3477011a..ed6629b5ec1 100644 --- a/engine/src/flutter/impeller/entity/entity_renderer.h +++ b/engine/src/flutter/impeller/entity/entity_renderer.h @@ -25,7 +25,7 @@ class EntityRenderer { bool IsValid() const; [[nodiscard]] bool RenderEntities(const Surface& surface, - const RenderPass& onscreen_pass, + RenderPass& onscreen_pass, const std::vector& entities) const; private: diff --git a/engine/src/flutter/impeller/entity/entity_renderer.mm b/engine/src/flutter/impeller/entity/entity_renderer.mm index c2a5cc7c2bf..87df107395a 100644 --- a/engine/src/flutter/impeller/entity/entity_renderer.mm +++ b/engine/src/flutter/impeller/entity/entity_renderer.mm @@ -24,7 +24,7 @@ bool EntityRenderer::IsValid() const { } bool EntityRenderer::RenderEntities(const Surface& surface, - const RenderPass& onscreen_pass, + RenderPass& onscreen_pass, const std::vector& entities) const { if (!IsValid()) { return false; diff --git a/engine/src/flutter/impeller/entity/entity_renderer_impl.h b/engine/src/flutter/impeller/entity/entity_renderer_impl.h index 1f2ffa77818..c63d063e021 100644 --- a/engine/src/flutter/impeller/entity/entity_renderer_impl.h +++ b/engine/src/flutter/impeller/entity/entity_renderer_impl.h @@ -30,7 +30,7 @@ class EntityRendererImpl { bool IsValid() const; [[nodiscard]] bool RenderEntity(const Surface& surface, - const RenderPass& onscreen_pass, + RenderPass& onscreen_pass, const Entity& entities); private: diff --git a/engine/src/flutter/impeller/entity/entity_renderer_impl.mm b/engine/src/flutter/impeller/entity/entity_renderer_impl.mm index e148d4024dd..bbd4cd42cbc 100644 --- a/engine/src/flutter/impeller/entity/entity_renderer_impl.mm +++ b/engine/src/flutter/impeller/entity/entity_renderer_impl.mm @@ -12,7 +12,7 @@ EntityRendererImpl::EntityRendererImpl(std::shared_ptr context) return; } - solid_fill_pipeline_ = std::make_unique(*context); + solid_fill_pipeline_ = std::make_unique(*context_); is_valid_ = true; } @@ -24,12 +24,29 @@ bool EntityRendererImpl::IsValid() const { } bool EntityRendererImpl::RenderEntity(const Surface& surface, - const RenderPass& onscreen_pass, + RenderPass& pass, const Entity& entity) { if (!entity.HasRenderableContents()) { return true; } + if (entity.HasContents()) { + using CurrentPipeline = decltype(solid_fill_pipeline_)::element_type; + using VS = CurrentPipeline::VertexShader; + + Command cmd; + cmd.pipeline = solid_fill_pipeline_->WaitAndGet(); + if (cmd.pipeline == nullptr) { + return false; + } + + VS::FrameInfo frame_info; + frame_info.mvp = Matrix::MakeOrthographic(surface.GetSize()) * + entity.GetTransformation(); + VS::BindFrameInfo(cmd, + pass.GetTransientsBuffer().EmplaceUniform(frame_info)); + } + return true; }