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
 
bool BackendSupportsFragmentProgram () 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
 
RuntimeStage::Map OpenAssetAsRuntimeStage (const char *asset_name) const
 
std::shared_ptr< ContextGetContext () const
 
Point GetContentScale () const
 
Scalar GetSecondsElapsed () const
 
ISize GetWindowSize () const
 
fml::Status SetCapabilities (const std::shared_ptr< Capabilities > &capabilities)
 
bool WillRenderSomething () const
 

Protected Member Functions

void SetWindowSize (ISize size)
 

Detailed Description

Definition at line 23 of file golden_playground_test.h.

Member Typedef Documentation

◆ AiksPlaygroundCallback

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

Definition at line 27 of file golden_playground_test.h.

Constructor & Destructor Documentation

◆ GoldenPlaygroundTest()

impeller::GoldenPlaygroundTest::GoldenPlaygroundTest ( )
default

Definition at line 96 of file golden_playground_test_mac.cc.

97  : typographer_context_(TypographerContextSkia::Make()),
98  pimpl_(new GoldenPlaygroundTest::GoldenPlaygroundTestImpl()) {}

◆ ~GoldenPlaygroundTest()

impeller::GoldenPlaygroundTest::~GoldenPlaygroundTest ( )
overridedefault

Member Function Documentation

◆ BackendSupportsFragmentProgram()

bool impeller::GoldenPlaygroundTest::BackendSupportsFragmentProgram ( ) const
inline

Definition at line 41 of file golden_playground_test.h.

41  {
43  }

References GetBackend(), and impeller::kVulkan.

◆ CreateTextureForFixture()

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

Definition at line 157 of file golden_playground_test_mac.cc.

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

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

◆ GetBackend()

PlaygroundBackend impeller::GoldenPlaygroundTest::GetBackend ( ) const

Definition at line 139 of file golden_playground_test_mac.cc.

139  {
140  return GetParam();
141 }

Referenced by BackendSupportsFragmentProgram(), and SetUp().

◆ GetContentScale()

Point impeller::GoldenPlaygroundTest::GetContentScale ( ) const

Definition at line 184 of file golden_playground_test_mac.cc.

184  {
185  return pimpl_->screenshotter->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_->screenshotter->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()

RuntimeStage::Map impeller::GoldenPlaygroundTest::OpenAssetAsRuntimeStage ( const char *  asset_name) const

Definition at line 170 of file golden_playground_test_mac.cc.

171  {
172  const std::shared_ptr<fml::Mapping> fixture =
173  flutter::testing::OpenFixtureAsMapping(asset_name);
174  if (!fixture || fixture->GetSize() == 0) {
175  return {};
176  }
177  return RuntimeStage::DecodeRuntimeStages(fixture);
178 }

References impeller::RuntimeStage::DecodeRuntimeStages().

◆ OpenPlaygroundHere() [1/2]

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

Definition at line 151 of file golden_playground_test_mac.cc.

153  { // NOLINT(performance-unnecessary-value-param)
154  return false;
155 }

◆ OpenPlaygroundHere() [2/2]

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

Definition at line 143 of file golden_playground_test_mac.cc.

143  {
144  AiksContext renderer(GetContext(), typographer_context_);
145 
146  auto screenshot = pimpl_->screenshotter->MakeScreenshot(renderer, picture,
147  pimpl_->window_size);
148  return SaveScreenshot(std::move(screenshot));
149 }

References GetContext().

◆ SetCapabilities()

fml::Status impeller::GoldenPlaygroundTest::SetCapabilities ( const std::shared_ptr< Capabilities > &  capabilities)

Definition at line 200 of file golden_playground_test_mac.cc.

201  {
202  return pimpl_->screenshotter->GetPlayground().SetCapabilities(capabilities);
203 }

◆ SetTypographerContext()

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

Definition at line 102 of file golden_playground_test_mac.cc.

103  {
104  typographer_context_ = std::move(typographer_context);
105 };

◆ SetUp()

void impeller::GoldenPlaygroundTest::SetUp ( )

Definition at line 111 of file golden_playground_test_mac.cc.

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

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

◆ SetWindowSize()

void impeller::GoldenPlaygroundTest::SetWindowSize ( ISize  size)
protected

Definition at line 66 of file golden_playground_test_stub.cc.

66 {}

◆ TearDown()

void impeller::GoldenPlaygroundTest::TearDown ( )

Definition at line 107 of file golden_playground_test_mac.cc.

107  {
108  ASSERT_FALSE(dlopen("/usr/local/lib/libMoltenVK.dylib", RTLD_NOLOAD));
109 }

◆ WillRenderSomething()

bool impeller::GoldenPlaygroundTest::WillRenderSomething ( ) const
inline

TODO(https://github.com/flutter/flutter/issues/139950): Remove this. Returns true if OpenPlaygroundHere will actually render anything.

Definition at line 71 of file golden_playground_test.h.

71 { return true; }

The documentation for this class was generated from the following files:
impeller::PlaygroundBackend::kVulkan
@ kVulkan
impeller::RuntimeStage::DecodeRuntimeStages
static Map DecodeRuntimeStages(const std::shared_ptr< fml::Mapping > &payload)
Definition: runtime_stage.cc:72
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:139
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