5 #include "display_list/dl_color.h"
6 #include "display_list/dl_tile_mode.h"
7 #include "gtest/gtest.h"
11 #include "display_list/dl_builder.h"
12 #include "display_list/dl_paint.h"
13 #include "display_list/effects/dl_color_source.h"
14 #include "flutter/fml/platform/darwin/scoped_nsautorelease_pool.h"
26 std::string GetTestName() {
27 std::string suite_name =
28 ::testing::UnitTest::GetInstance()->current_test_suite()->name();
29 std::string test_name =
30 ::testing::UnitTest::GetInstance()->current_test_info()->name();
32 ss <<
"impeller_" << suite_name <<
"_" << test_name;
36 std::string GetGoldenFilename() {
37 return GetTestName() +
".png";
40 bool SaveScreenshot(std::unique_ptr<Screenshot> screenshot) {
41 if (!screenshot || !screenshot->GetBytes()) {
44 std::string test_name = GetTestName();
45 std::string filename = GetGoldenFilename();
47 test_name, filename, screenshot->GetWidth(), screenshot->GetHeight());
48 return screenshot->WriteToPNG(
52 PlaygroundSwitches GetPlaygroundSwitches() {
53 PlaygroundSwitches switches;
54 switches.enable_wide_gamut =
false;
69 Screenshotter().GetPlayground().GetContext()->DescribeGpuModel());
75 fml::ScopedNSAutoreleasePool autorelease_pool_;
77 std::unique_ptr<MetalScreenshotter> screenshotter_;
81 flutter::DisplayListBuilder builder;
82 flutter::DlPaint paint;
83 paint.setDrawStyle(flutter::DlDrawStyle::kFill);
85 flutter::DlColor colors[2] = {flutter::DlColor::RGBA(1, 0, 0, 1),
86 flutter::DlColor::RGBA(0, 0, 1, 1)};
89 paint.setColorSource(flutter::DlColorSource::MakeConical(
96 flutter::DlTileMode::kClamp
99 builder.DrawRect(DlRect::MakeXYWH(10, 10, 250, 250), paint);
106 ASSERT_TRUE(SaveScreenshot(std::move(screenshot)));
static GoldenDigest * Instance()
void AddDimension(const std::string &name, const std::string &value)
void AddImage(const std::string &test_name, const std::string &filename, int32_t width, int32_t height)
MetalScreenshotter & Screenshotter()
virtual std::unique_ptr< Screenshot > MakeScreenshot(AiksContext &aiks_context, const std::shared_ptr< Texture > texture)=0
static WorkingDirectory * Instance()
TEST_F(GoldenTests, ConicalGradient)
std::shared_ptr< Texture > DisplayListToTexture(const sk_sp< flutter::DisplayList > &display_list, ISize size, AiksContext &context, bool reset_host_buffer, bool generate_mips)
Render the provided display list to a texture with the given size.