55#include " flutter/impeller/entity/entity_renderer.h"
66
77#include " flutter/fml/trace_event.h"
8- #include " impeller/renderer/tessellator.h"
9- #include " impeller/renderer/vertex_buffer_builder.h"
8+ #include " impeller/entity/content_renderer.h"
109
1110namespace impeller {
1211
@@ -21,8 +20,6 @@ EntityRenderer::EntityRenderer(std::shared_ptr<Context> context)
2120 return ;
2221 }
2322
24- solid_fill_pipeline_ = std::make_unique<SolidFillPipeline>(*context_);
25-
2623 is_valid_ = true ;
2724}
2825
@@ -40,70 +37,13 @@ bool EntityRenderer::RenderEntities(const Surface& surface,
4037 }
4138
4239 for (const auto & entity : entities) {
43- if (RenderEntity (surface, onscreen_pass, entity) ==
44- EntityRenderer::RenderResult:: kFailure ) {
40+ if (auto contents = entity. GetContents ();
41+ !contents-> Render (*content_renderer_, entity, surface, onscreen_pass) ) {
4542 return false ;
4643 }
4744 }
4845
4946 return true ;
5047}
5148
52- EntityRenderer::RenderResult EntityRenderer::RenderEntity (
53- const Surface& surface,
54- RenderPass& pass,
55- const Entity& entity) {
56- if (!entity.HasRenderableContents ()) {
57- return RenderResult::kSkipped ;
58- }
59-
60- if (entity.HasContents () && !entity.IsClip () && !entity.GetContents ()) {
61- using VS = SolidFillPipeline::VertexShader;
62-
63- Command cmd;
64- cmd.label = " SolidFill" ;
65- cmd.pipeline = solid_fill_pipeline_->WaitAndGet ();
66- if (cmd.pipeline == nullptr ) {
67- return RenderResult::kFailure ;
68- }
69-
70- VertexBufferBuilder<VS::PerVertexData> vtx_builder;
71- {
72- auto tesselation_result = Tessellator{}.Tessellate (
73- entity.GetPath ().CreatePolyline (), [&vtx_builder](auto point) {
74- VS::PerVertexData vtx;
75- vtx.vertices = point;
76- vtx_builder.AppendVertex (vtx);
77- });
78- if (!tesselation_result) {
79- return RenderResult::kFailure ;
80- }
81- }
82-
83- cmd.BindVertices (
84- vtx_builder.CreateVertexBuffer (*context_->GetPermanentsAllocator ()));
85-
86- VS::FrameInfo frame_info;
87- frame_info.mvp = Matrix::MakeOrthographic (surface.GetSize ()) *
88- entity.GetTransformation ();
89- frame_info.color = entity.GetBackgroundColor ();
90- VS::BindFrameInfo (cmd,
91- pass.GetTransientsBuffer ().EmplaceUniform (frame_info));
92-
93- cmd.primitive_type = PrimitiveType::kTriangle ;
94-
95- if (!pass.AddCommand (std::move (cmd))) {
96- return RenderResult::kFailure ;
97- }
98- } else if (entity.GetContents ()) {
99- auto result =
100- entity.GetContents ()->Render (*content_renderer_, entity, surface, pass);
101- if (!result) {
102- return RenderResult::kFailure ;
103- }
104- }
105-
106- return RenderResult::kSuccess ;
107- }
108-
10949} // namespace impeller
0 commit comments