diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files index 1551a8af648cf..e2f7aedbf9f3f 100644 --- a/ci/licenses_golden/excluded_files +++ b/ci/licenses_golden/excluded_files @@ -134,6 +134,7 @@ ../../../flutter/impeller/display_list/dl_unittests.cc ../../../flutter/impeller/display_list/skia_conversions_unittests.cc ../../../flutter/impeller/docs +../../../flutter/impeller/entity/contents/checkerboard_contents_unittests.cc ../../../flutter/impeller/entity/contents/filters/inputs/filter_input_unittests.cc ../../../flutter/impeller/entity/entity_unittests.cc ../../../flutter/impeller/entity/geometry/geometry_unittests.cc diff --git a/impeller/entity/BUILD.gn b/impeller/entity/BUILD.gn index 4e1ce88280d4a..18d1e0035e0d5 100644 --- a/impeller/entity/BUILD.gn +++ b/impeller/entity/BUILD.gn @@ -240,6 +240,7 @@ impeller_component("entity_unittests") { testonly = true sources = [ + "contents/checkerboard_contents_unittests.cc", "contents/filters/inputs/filter_input_unittests.cc", "entity_playground.cc", "entity_playground.h", diff --git a/impeller/entity/contents/checkerboard_contents.h b/impeller/entity/contents/checkerboard_contents.h index 2629822a8d322..1c8682a28764b 100644 --- a/impeller/entity/contents/checkerboard_contents.h +++ b/impeller/entity/contents/checkerboard_contents.h @@ -4,7 +4,6 @@ #pragma once -#include "flutter/fml/macros.h" #include "impeller/entity/contents/contents.h" namespace impeller { diff --git a/impeller/entity/contents/checkerboard_contents_unittests.cc b/impeller/entity/contents/checkerboard_contents_unittests.cc new file mode 100644 index 0000000000000..b69ab65992745 --- /dev/null +++ b/impeller/entity/contents/checkerboard_contents_unittests.cc @@ -0,0 +1,50 @@ +// 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 +#include + +#include "gtest/gtest.h" + +#include "impeller/entity/contents/checkerboard_contents.h" +#include "impeller/entity/contents/contents.h" +#include "impeller/entity/entity.h" +#include "impeller/entity/entity_playground.h" +#include "impeller/renderer/render_target.h" + +namespace impeller { +namespace testing { + +using EntityTest = EntityPlayground; +INSTANTIATE_PLAYGROUND_SUITE(EntityTest); + +#ifdef IMPELLER_DEBUG +TEST(EntityTest, HasNulloptCoverage) { + auto contents = std::make_shared(); + + Entity entity; + ASSERT_EQ(contents->GetCoverage(entity), std::nullopt); +} + +TEST_P(EntityTest, RendersWithoutError) { + auto contents = std::make_shared(); + contents->SetColor(Color::Aqua()); + contents->SetSquareSize(10); + + auto content_context = GetContentContext(); + auto buffer = content_context->GetContext()->CreateCommandBuffer(); + auto render_target = RenderTarget::CreateOffscreenMSAA( + *content_context->GetContext(), + *GetContentContext()->GetRenderTargetCache(), {100, 100}); + auto render_pass = buffer->CreateRenderPass(render_target); + Entity entity; + + ASSERT_TRUE(render_pass->GetCommands().empty()); + ASSERT_TRUE(contents->Render(*content_context, entity, *render_pass)); + ASSERT_FALSE(render_pass->GetCommands().empty()); +} +#endif // IMPELLER_DEBUG + +} // namespace testing +} // namespace impeller diff --git a/impeller/entity/entity_playground.cc b/impeller/entity/entity_playground.cc index 0f9eebe3ab0d0..bd13db3c18c14 100644 --- a/impeller/entity/entity_playground.cc +++ b/impeller/entity/entity_playground.cc @@ -36,17 +36,21 @@ bool EntityPlayground::OpenPlaygroundHere(EntityPass& entity_pass) { return Playground::OpenPlaygroundHere(callback); } +std::shared_ptr EntityPlayground::GetContentContext() const { + return std::make_shared(GetContext(), typographer_context_); +} + bool EntityPlayground::OpenPlaygroundHere(Entity entity) { if (!switches_.enable_playground) { return true; } - ContentContext content_context(GetContext(), typographer_context_); - if (!content_context.IsValid()) { + auto content_context = GetContentContext(); + if (!content_context->IsValid()) { return false; } SinglePassCallback callback = [&](RenderPass& pass) -> bool { - return entity.Render(content_context, pass); + return entity.Render(*content_context, pass); }; return Playground::OpenPlaygroundHere(callback); } diff --git a/impeller/entity/entity_playground.h b/impeller/entity/entity_playground.h index 62ed08f8954e1..10604f607237c 100644 --- a/impeller/entity/entity_playground.h +++ b/impeller/entity/entity_playground.h @@ -32,6 +32,8 @@ class EntityPlayground : public PlaygroundTest { bool OpenPlaygroundHere(EntityPlaygroundCallback callback); + std::shared_ptr GetContentContext() const; + private: std::shared_ptr typographer_context_; diff --git a/impeller/entity/entity_unittests.cc b/impeller/entity/entity_unittests.cc index 1eb9cf149ad77..ea564dfa8e029 100644 --- a/impeller/entity/entity_unittests.cc +++ b/impeller/entity/entity_unittests.cc @@ -2,24 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include #include #include #include -#include #include #include -#include "flutter/testing/testing.h" #include "fml/logging.h" -#include "fml/time/time_point.h" #include "gtest/gtest.h" #include "impeller/core/texture_descriptor.h" #include "impeller/entity/contents/atlas_contents.h" #include "impeller/entity/contents/clip_contents.h" #include "impeller/entity/contents/conical_gradient_contents.h" #include "impeller/entity/contents/contents.h" -#include "impeller/entity/contents/filters/blend_filter_contents.h" #include "impeller/entity/contents/filters/color_filter_contents.h" #include "impeller/entity/contents/filters/filter_contents.h" #include "impeller/entity/contents/filters/inputs/filter_input.h" @@ -28,11 +23,9 @@ #include "impeller/entity/contents/runtime_effect_contents.h" #include "impeller/entity/contents/solid_color_contents.h" #include "impeller/entity/contents/solid_rrect_blur_contents.h" -#include "impeller/entity/contents/sweep_gradient_contents.h" #include "impeller/entity/contents/text_contents.h" #include "impeller/entity/contents/texture_contents.h" #include "impeller/entity/contents/tiled_texture_contents.h" -#include "impeller/entity/contents/vertices_contents.h" #include "impeller/entity/entity.h" #include "impeller/entity/entity_pass.h" #include "impeller/entity/entity_pass_delegate.h" @@ -50,11 +43,8 @@ #include "impeller/renderer/command.h" #include "impeller/renderer/render_pass.h" #include "impeller/renderer/vertex_buffer_builder.h" -#include "impeller/runtime_stage/runtime_stage.h" -#include "impeller/tessellator/tessellator.h" #include "impeller/typographer/backends/skia/text_frame_skia.h" #include "impeller/typographer/backends/skia/typographer_context_skia.h" -#include "include/core/SkBlendMode.h" #include "third_party/imgui/imgui.h" #include "third_party/skia/include/core/SkTextBlob.h"