Flutter Impeller
impeller::GoldenPlaygroundTest Class Reference

#include <golden_playground_test.h>

Inheritance diagram for impeller::GoldenPlaygroundTest:

Classes

struct  GoldenPlaygroundTestImpl
 

Public Types

using AiksPlaygroundCallback = std::function< std::optional< Picture >(AiksContext &renderer)>
 

Public Member Functions

 GoldenPlaygroundTest ()
 
 ~GoldenPlaygroundTest () override
 
void SetUp ()
 
void TearDown ()
 
PlaygroundBackend GetBackend () const
 
void SetTypographerContext (std::shared_ptr< TypographerContext > typographer_context)
 
bool OpenPlaygroundHere (Picture picture)
 
bool OpenPlaygroundHere (AiksPlaygroundCallback callback)
 
std::shared_ptr< TextureCreateTextureForFixture (const char *fixture_name, bool enable_mipmapping=false) const
 
std::shared_ptr< RuntimeStageOpenAssetAsRuntimeStage (const char *asset_name) const
 
std::shared_ptr< ContextGetContext () const
 
Point GetContentScale () const
 
Scalar GetSecondsElapsed () const
 
ISize GetWindowSize () const
 

Detailed Description

Definition at line 22 of file golden_playground_test.h.

Member Typedef Documentation

◆ AiksPlaygroundCallback

using impeller::GoldenPlaygroundTest::AiksPlaygroundCallback = std::function<std::optional<Picture>(AiksContext& renderer)>

Definition at line 26 of file golden_playground_test.h.

Constructor & Destructor Documentation

◆ GoldenPlaygroundTest()

impeller::GoldenPlaygroundTest::GoldenPlaygroundTest ( )
default

Definition at line 93 of file golden_playground_test_mac.cc.

94  : typographer_context_(TypographerContextSkia::Make()),
95  pimpl_(new GoldenPlaygroundTest::GoldenPlaygroundTestImpl()) {}

◆ ~GoldenPlaygroundTest()

impeller::GoldenPlaygroundTest::~GoldenPlaygroundTest ( )
overridedefault

Member Function Documentation

◆ CreateTextureForFixture()

std::shared_ptr< Texture > impeller::GoldenPlaygroundTest::CreateTextureForFixture ( const char *  fixture_name,
bool  enable_mipmapping = false 
) const

Definition at line 154 of file golden_playground_test_mac.cc.

156  {
157  std::shared_ptr<fml::Mapping> mapping =
158  flutter::testing::OpenFixtureAsMapping(fixture_name);
159  auto result = Playground::CreateTextureForMapping(GetContext(), mapping,
160  enable_mipmapping);
161  if (result) {
162  result->SetLabel(fixture_name);
163  }
164  return result;
165 }

References impeller::Playground::CreateTextureForMapping(), and GetContext().

◆ GetBackend()

PlaygroundBackend impeller::GoldenPlaygroundTest::GetBackend ( ) const

Definition at line 136 of file golden_playground_test_mac.cc.

136  {
137  return GetParam();
138 }

Referenced by SetUp().

◆ GetContentScale()

Point impeller::GoldenPlaygroundTest::GetContentScale ( ) const

Definition at line 184 of file golden_playground_test_mac.cc.

184  {
185  return pimpl_->screenshoter->GetPlayground().GetContentScale();
186 }

◆ GetContext()

std::shared_ptr< Context > impeller::GoldenPlaygroundTest::GetContext ( ) const

Definition at line 180 of file golden_playground_test_mac.cc.

180  {
181  return pimpl_->screenshoter->GetPlayground().GetContext();
182 }

Referenced by CreateTextureForFixture(), OpenPlaygroundHere(), and SetUp().

◆ GetSecondsElapsed()

Scalar impeller::GoldenPlaygroundTest::GetSecondsElapsed ( ) const

Definition at line 188 of file golden_playground_test_mac.cc.

188  {
189  return 0.0f;
190 }

◆ GetWindowSize()

ISize impeller::GoldenPlaygroundTest::GetWindowSize ( ) const

Definition at line 192 of file golden_playground_test_mac.cc.

192  {
193  return pimpl_->window_size;
194 }

◆ OpenAssetAsRuntimeStage()

std::shared_ptr< RuntimeStage > impeller::GoldenPlaygroundTest::OpenAssetAsRuntimeStage ( const char *  asset_name) const

Definition at line 167 of file golden_playground_test_mac.cc.

168  {
169  auto fixture = flutter::testing::OpenFixtureAsMapping(asset_name);
170  if (!fixture || fixture->GetSize() == 0) {
171  return nullptr;
172  }
173  auto stage = std::make_unique<RuntimeStage>(std::move(fixture));
174  if (!stage->IsValid()) {
175  return nullptr;
176  }
177  return stage;
178 }

◆ OpenPlaygroundHere() [1/2]

bool impeller::GoldenPlaygroundTest::OpenPlaygroundHere ( AiksPlaygroundCallback  callback)

Definition at line 148 of file golden_playground_test_mac.cc.

150  { // NOLINT(performance-unnecessary-value-param)
151  return false;
152 }

◆ OpenPlaygroundHere() [2/2]

bool impeller::GoldenPlaygroundTest::OpenPlaygroundHere ( Picture  picture)

Definition at line 140 of file golden_playground_test_mac.cc.

140  {
141  AiksContext renderer(GetContext(), typographer_context_);
142 
143  auto screenshot = pimpl_->screenshoter->MakeScreenshot(renderer, picture,
144  pimpl_->window_size);
145  return SaveScreenshot(std::move(screenshot));
146 }

References GetContext().

◆ SetTypographerContext()

void impeller::GoldenPlaygroundTest::SetTypographerContext ( std::shared_ptr< TypographerContext typographer_context)

Definition at line 99 of file golden_playground_test_mac.cc.

100  {
101  typographer_context_ = std::move(typographer_context);
102 };

◆ SetUp()

void impeller::GoldenPlaygroundTest::SetUp ( )

Definition at line 108 of file golden_playground_test_mac.cc.

108  {
109  std::filesystem::path testing_assets_path =
110  flutter::testing::GetTestingAssetsPath();
111  std::filesystem::path target_path = testing_assets_path.parent_path()
112  .parent_path()
113  .parent_path()
114  .parent_path();
115  std::filesystem::path icd_path = target_path / "vk_swiftshader_icd.json";
116  setenv("VK_ICD_FILENAMES", icd_path.c_str(), 1);
117 
120  GTEST_SKIP_("GoldenPlaygroundTest doesn't support this backend type.");
121  return;
122  }
123 
124  std::string test_name = GetTestName();
125  if (std::find(kSkipTests.begin(), kSkipTests.end(), test_name) !=
126  kSkipTests.end()) {
127  GTEST_SKIP_(
128  "GoldenPlaygroundTest doesn't support interactive playground tests "
129  "yet.");
130  }
131 
133  "gpu_string", GetContext()->DescribeGpuModel());
134 }

References impeller::testing::GoldenDigest::AddDimension(), GetBackend(), GetContext(), impeller::testing::GoldenDigest::Instance(), impeller::kMetal, impeller::kSkipTests, and impeller::kVulkan.

◆ TearDown()

void impeller::GoldenPlaygroundTest::TearDown ( )

Definition at line 104 of file golden_playground_test_mac.cc.

104  {
105  ASSERT_FALSE(dlopen("/usr/local/lib/libMoltenVK.dylib", RTLD_NOLOAD));
106 }

The documentation for this class was generated from the following files:
impeller::PlaygroundBackend::kVulkan
@ kVulkan
impeller::PlaygroundBackend::kMetal
@ kMetal
impeller::GoldenPlaygroundTest::GetContext
std::shared_ptr< Context > GetContext() const
Definition: golden_playground_test_mac.cc:180
impeller::GoldenPlaygroundTest::GetBackend
PlaygroundBackend GetBackend() const
Definition: golden_playground_test_mac.cc:136
impeller::kSkipTests
static const std::vector< std::string > kSkipTests
Definition: golden_playground_test_mac.cc:21
impeller::Playground::CreateTextureForMapping
static std::shared_ptr< Texture > CreateTextureForMapping(const std::shared_ptr< Context > &context, std::shared_ptr< fml::Mapping > mapping, bool enable_mipmapping=false)
Definition: playground.cc:461
impeller::testing::GoldenDigest::Instance
static GoldenDigest * Instance()
Definition: golden_digest.cc:18
impeller::testing::GoldenDigest::AddDimension
void AddDimension(const std::string &name, const std::string &value)
Definition: golden_digest.cc:27
impeller::TypographerContextSkia::Make
static std::shared_ptr< TypographerContext > Make()
Definition: typographer_context_skia.cc:30