8 #include "gtest/gtest.h"
12 #include "impeller/entity/contents/test/contents_test_helpers.h"
13 #include "impeller/entity/contents/test/recording_render_pass.h"
17 #include "impeller/entity/vertices.frag.h"
27 const std::vector<Point>& vertices,
28 const std::vector<Color>& colors) {
30 std::vector<uint16_t> indices = {};
31 indices.reserve(vertices.size());
32 for (
auto i = 0u; i < vertices.size(); i++) {
33 indices.emplace_back(i);
35 std::vector<Point> texture_coordinates = {};
37 return std::make_shared<VerticesGeometry>(
38 vertices, indices, texture_coordinates, colors,
47 auto contents = std::make_shared<VerticesContents>();
49 {{0, 0}, {100, 0}, {0, 100}, {100, 0}, {0, 100}, {100, 100}},
56 contents->SetGeometry(vertices);
57 contents->SetAlpha(0.5);
59 contents->SetSourceContents(std::move(src_contents));
61 auto content_context = GetContentContext();
62 auto buffer = content_context->GetContext()->CreateCommandBuffer();
64 GetContentContext()->GetRenderTargetCache()->CreateOffscreenMSAA(
65 *content_context->GetContext(), {100, 100},
67 auto render_pass = buffer->CreateRenderPass(render_target);
68 auto recording_pass = std::make_shared<RecordingRenderPass>(
69 render_pass, GetContext(), render_target);
72 ASSERT_TRUE(recording_pass->GetCommands().empty());
73 ASSERT_TRUE(contents->Render(*content_context, entity, *recording_pass));
75 ASSERT_TRUE(recording_pass->GetCommands().size() > 0);
76 const auto& cmd = recording_pass->GetCommands()[0];
77 auto* frag_uniforms = GetFragInfo<FS>(cmd);
79 ASSERT_TRUE(frag_uniforms);
80 ASSERT_EQ(frag_uniforms->alpha, 0.5);
83 recording_pass->EncodeCommands();