Merge entity renderer impl into the entity renderer.

This commit is contained in:
Chinmay Garde
2021-11-03 15:33:00 -07:00
committed by Dan Field
parent e8a632c8e5
commit 6572fa9350
11 changed files with 54 additions and 120 deletions

View File

@@ -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 = [

View File

@@ -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",

View File

@@ -7,8 +7,8 @@
#include <memory>
#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 {

View File

@@ -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> context)
EntityRenderer::EntityRenderer(std::shared_ptr<Context> context)
: context_(std::move(context)) {
if (!context_ || !context_->IsValid()) {
return;
@@ -26,13 +26,30 @@ EntityRendererImpl::EntityRendererImpl(std::shared_ptr<Context> context)
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<Entity>& 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) {

View File

@@ -7,15 +7,18 @@
#include <memory>
#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> context);
@@ -26,10 +29,25 @@ class EntityRenderer {
[[nodiscard]] bool RenderEntities(const Surface& surface,
RenderPass& onscreen_pass,
const std::vector<Entity>& entities) const;
const std::vector<Entity>& entities);
enum class RenderResult {
kSkipped,
kSuccess,
kFailure,
};
[[nodiscard]] RenderResult RenderEntity(const Surface& surface,
RenderPass& onscreen_pass,
const Entity& entities);
private:
std::unique_ptr<EntityRendererImpl> renderer_;
using SolidFillPipeline =
PipelineT<SolidFillVertexShader, SolidFillFragmentShader>;
std::shared_ptr<Context> context_;
std::unique_ptr<SolidFillPipeline> solid_fill_pipeline_;
std::unique_ptr<ContentRenderer> content_renderer_;
bool is_valid_ = false;
FML_DISALLOW_COPY_AND_ASSIGN(EntityRenderer);

View File

@@ -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> context)
: renderer_(std::make_unique<EntityRendererImpl>(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<Entity>& 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

View File

@@ -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 <memory>
#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> 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<SolidFillVertexShader, SolidFillFragmentShader>;
std::shared_ptr<Context> context_;
std::unique_ptr<SolidFillPipeline> solid_fill_pipeline_;
std::unique_ptr<ContentRenderer> content_renderer_;
bool is_valid_ = false;
FML_DISALLOW_COPY_AND_ASSIGN(EntityRendererImpl);
};
} // namespace impeller