diff --git a/impeller/aiks/BUILD.gn b/impeller/aiks/BUILD.gn index 5d3d66f7dfab8..39ad62609f5e7 100644 --- a/impeller/aiks/BUILD.gn +++ b/impeller/aiks/BUILD.gn @@ -16,8 +16,8 @@ impeller_component("aiks") { "picture.h", "picture_recorder.cc", "picture_recorder.h", + "picture_renderer.cc", "picture_renderer.h", - "picture_renderer.mm", ] public_deps = [ diff --git a/impeller/aiks/picture_renderer.mm b/impeller/aiks/picture_renderer.cc similarity index 100% rename from impeller/aiks/picture_renderer.mm rename to impeller/aiks/picture_renderer.cc diff --git a/impeller/entity/BUILD.gn b/impeller/entity/BUILD.gn index e67246e55fd1b..1e7b138eb3eb2 100644 --- a/impeller/entity/BUILD.gn +++ b/impeller/entity/BUILD.gn @@ -17,16 +17,14 @@ impeller_shaders("entity_shaders") { impeller_component("entity") { sources = [ + "content_renderer.cc", "content_renderer.h", - "content_renderer.mm", + "contents.cc", "contents.h", - "contents.mm", "entity.cc", "entity.h", + "entity_renderer.cc", "entity_renderer.h", - "entity_renderer.mm", - "entity_renderer_impl.h", - "entity_renderer_impl.mm", ] deps = [ ":entity_shaders" ] @@ -40,7 +38,7 @@ impeller_component("entity") { impeller_component("entity_unittests") { testonly = true - sources = [ "entity_unittests.mm" ] + sources = [ "entity_unittests.cc" ] deps = [ ":entity", diff --git a/impeller/entity/content_renderer.mm b/impeller/entity/content_renderer.cc similarity index 100% rename from impeller/entity/content_renderer.mm rename to impeller/entity/content_renderer.cc diff --git a/impeller/entity/content_renderer.h b/impeller/entity/content_renderer.h index d803ef45f2243..671504a298099 100644 --- a/impeller/entity/content_renderer.h +++ b/impeller/entity/content_renderer.h @@ -7,8 +7,8 @@ #include #include "flutter/fml/macros.h" -#include "impeller/entity/gradient_fill.frag.h" -#include "impeller/entity/gradient_fill.vert.h" +#include "flutter/impeller/entity/gradient_fill.frag.h" +#include "flutter/impeller/entity/gradient_fill.vert.h" #include "impeller/renderer/pipeline.h" namespace impeller { diff --git a/impeller/entity/contents.mm b/impeller/entity/contents.cc similarity index 100% rename from impeller/entity/contents.mm rename to impeller/entity/contents.cc diff --git a/impeller/entity/entity_renderer_impl.mm b/impeller/entity/entity_renderer.cc similarity index 77% rename from impeller/entity/entity_renderer_impl.mm rename to impeller/entity/entity_renderer.cc index 9ff3410a893e0..a15846b7bba00 100644 --- a/impeller/entity/entity_renderer_impl.mm +++ b/impeller/entity/entity_renderer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "impeller/entity/entity_renderer_impl.h" +#include "flutter/impeller/entity/entity_renderer.h" #include "flutter/fml/trace_event.h" #include "impeller/renderer/tessellator.h" @@ -10,7 +10,7 @@ namespace impeller { -EntityRendererImpl::EntityRendererImpl(std::shared_ptr context) +EntityRenderer::EntityRenderer(std::shared_ptr context) : context_(std::move(context)) { if (!context_ || !context_->IsValid()) { return; @@ -26,13 +26,30 @@ is_valid_ = true; } -EntityRendererImpl::~EntityRendererImpl() = default; +EntityRenderer::~EntityRenderer() = default; -bool EntityRendererImpl::IsValid() const { +bool EntityRenderer::IsValid() const { return is_valid_; } -EntityRendererImpl::RenderResult EntityRendererImpl::RenderEntity( +bool EntityRenderer::RenderEntities(const Surface& surface, + RenderPass& onscreen_pass, + const std::vector& entities) { + if (!IsValid()) { + return false; + } + + for (const auto& entity : entities) { + if (RenderEntity(surface, onscreen_pass, entity) == + EntityRenderer::RenderResult::kFailure) { + return false; + } + } + + return true; +} + +EntityRenderer::RenderResult EntityRenderer::RenderEntity( const Surface& surface, RenderPass& pass, const Entity& entity) { diff --git a/impeller/entity/entity_renderer.h b/impeller/entity/entity_renderer.h index ed6629b5ec19d..caa670dc9c4fd 100644 --- a/impeller/entity/entity_renderer.h +++ b/impeller/entity/entity_renderer.h @@ -7,15 +7,18 @@ #include #include "flutter/fml/macros.h" +#include "flutter/impeller/entity/solid_fill.frag.h" +#include "flutter/impeller/entity/solid_fill.vert.h" +#include "impeller/entity/content_renderer.h" #include "impeller/entity/entity.h" +#include "impeller/renderer/context.h" +#include "impeller/renderer/pipeline.h" +#include "impeller/renderer/pipeline_builder.h" +#include "impeller/renderer/render_pass.h" +#include "impeller/renderer/surface.h" namespace impeller { -class Surface; -class RenderPass; -class Context; -class EntityRendererImpl; - class EntityRenderer { public: EntityRenderer(std::shared_ptr context); @@ -26,10 +29,25 @@ class EntityRenderer { [[nodiscard]] bool RenderEntities(const Surface& surface, RenderPass& onscreen_pass, - const std::vector& entities) const; + const std::vector& entities); + + enum class RenderResult { + kSkipped, + kSuccess, + kFailure, + }; + + [[nodiscard]] RenderResult RenderEntity(const Surface& surface, + RenderPass& onscreen_pass, + const Entity& entities); private: - std::unique_ptr renderer_; + using SolidFillPipeline = + PipelineT; + + std::shared_ptr context_; + std::unique_ptr solid_fill_pipeline_; + std::unique_ptr content_renderer_; bool is_valid_ = false; FML_DISALLOW_COPY_AND_ASSIGN(EntityRenderer); diff --git a/impeller/entity/entity_renderer.mm b/impeller/entity/entity_renderer.mm deleted file mode 100644 index a352ce4f4efb3..0000000000000 --- a/impeller/entity/entity_renderer.mm +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/impeller/entity/entity_renderer.h" - -#include "flutter/fml/trace_event.h" -#include "flutter/impeller/entity/entity_renderer_impl.h" - -namespace impeller { - -EntityRenderer::EntityRenderer(std::shared_ptr context) - : renderer_(std::make_unique(std::move(context))) { - if (!renderer_->IsValid()) { - return; - } - is_valid_ = true; -} - -EntityRenderer::~EntityRenderer() = default; - -bool EntityRenderer::IsValid() const { - return is_valid_; -} - -bool EntityRenderer::RenderEntities(const Surface& surface, - RenderPass& onscreen_pass, - const std::vector& entities) const { - if (!IsValid()) { - return false; - } - - for (const auto& entity : entities) { - if (renderer_->RenderEntity(surface, onscreen_pass, entity) == - EntityRendererImpl::RenderResult::kFailure) { - return false; - } - } - - return true; -} - -} // namespace impeller diff --git a/impeller/entity/entity_renderer_impl.h b/impeller/entity/entity_renderer_impl.h deleted file mode 100644 index dcea72aded521..0000000000000 --- a/impeller/entity/entity_renderer_impl.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#pragma once - -#include - -#include "flutter/fml/macros.h" -#include "impeller/entity/content_renderer.h" -#include "impeller/entity/entity.h" -#include "impeller/entity/solid_fill.frag.h" -#include "impeller/entity/solid_fill.vert.h" -#include "impeller/renderer/context.h" -#include "impeller/renderer/pipeline.h" -#include "impeller/renderer/pipeline_builder.h" -#include "impeller/renderer/render_pass.h" -#include "impeller/renderer/surface.h" - -namespace impeller { - -// TODO(csg): Only present to hide Objective-C++ interface in the headers. Once -// the backend is separated into its own TU, this can be merged with -// EntityRenderer. -class EntityRendererImpl { - public: - EntityRendererImpl(std::shared_ptr context); - - ~EntityRendererImpl(); - - bool IsValid() const; - - enum class RenderResult { - kSkipped, - kSuccess, - kFailure, - }; - - [[nodiscard]] RenderResult RenderEntity(const Surface& surface, - RenderPass& onscreen_pass, - const Entity& entities); - - private: - using SolidFillPipeline = - PipelineT; - - std::shared_ptr context_; - std::unique_ptr solid_fill_pipeline_; - std::unique_ptr content_renderer_; - - bool is_valid_ = false; - - FML_DISALLOW_COPY_AND_ASSIGN(EntityRendererImpl); -}; - -} // namespace impeller diff --git a/impeller/entity/entity_unittests.mm b/impeller/entity/entity_unittests.cc similarity index 100% rename from impeller/entity/entity_unittests.mm rename to impeller/entity/entity_unittests.cc