5
5
#include " flutter/impeller/entity/entity_renderer.h"
6
6
7
7
#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"
10
9
11
10
namespace impeller {
12
11
@@ -21,8 +20,6 @@ EntityRenderer::EntityRenderer(std::shared_ptr<Context> context)
21
20
return ;
22
21
}
23
22
24
- solid_fill_pipeline_ = std::make_unique<SolidFillPipeline>(*context_);
25
-
26
23
is_valid_ = true ;
27
24
}
28
25
@@ -40,70 +37,13 @@ bool EntityRenderer::RenderEntities(const Surface& surface,
40
37
}
41
38
42
39
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) ) {
45
42
return false ;
46
43
}
47
44
}
48
45
49
46
return true ;
50
47
}
51
48
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
-
109
49
} // namespace impeller
0 commit comments