Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
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
 
RuntimeStage::Map OpenAssetAsRuntimeStage (const char *asset_name) const
 
std::shared_ptr< ContextGetContext () const
 
std::shared_ptr< ContextMakeContext () const
 
Point GetContentScale () const
 
Scalar GetSecondsElapsed () const
 
ISize GetWindowSize () const
 
fml::Status SetCapabilities (const std::shared_ptr< Capabilities > &capabilities)
 
bool WillRenderSomething () const
 

Static Public Member Functions

static bool ImGuiBegin (const char *name, bool *p_open, ImGuiWindowFlags flags)
 

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 26 of file golden_playground_test.h.

Constructor & Destructor Documentation

◆ GoldenPlaygroundTest()

impeller::GoldenPlaygroundTest::GoldenPlaygroundTest ( )
default

Definition at line 116 of file golden_playground_test_mac.cc.

117 : typographer_context_(TypographerContextSkia::Make()),
118 pimpl_(new GoldenPlaygroundTest::GoldenPlaygroundTestImpl()) {}
static std::shared_ptr< TypographerContext > Make()

◆ ~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 235 of file golden_playground_test_mac.cc.

237 {
238 std::shared_ptr<fml::Mapping> mapping =
241 enable_mipmapping);
242 if (result) {
243 result->SetLabel(fixture_name);
244 }
245 return result;
246}
std::shared_ptr< Context > GetContext() const
static std::shared_ptr< Texture > CreateTextureForMapping(const std::shared_ptr< Context > &context, std::shared_ptr< fml::Mapping > mapping, bool enable_mipmapping=false)
GAsyncResult * result
std::unique_ptr< fml::Mapping > OpenFixtureAsMapping(const std::string &fixture_name)
Opens a fixture of the given file name and returns a mapping to its contents.
Definition testing.cc:59

◆ GetBackend()

PlaygroundBackend impeller::GoldenPlaygroundTest::GetBackend ( ) const

Definition at line 198 of file golden_playground_test_mac.cc.

198 {
199 return GetParam();
200}

◆ GetContentScale()

Point impeller::GoldenPlaygroundTest::GetContentScale ( ) const

Definition at line 281 of file golden_playground_test_mac.cc.

281 {
282 return pimpl_->screenshotter->GetPlayground().GetContentScale();
283}

◆ GetContext()

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

Definition at line 258 of file golden_playground_test_mac.cc.

258 {
259 return pimpl_->screenshotter->GetPlayground().GetContext();
260}

◆ GetSecondsElapsed()

Scalar impeller::GoldenPlaygroundTest::GetSecondsElapsed ( ) const

Definition at line 285 of file golden_playground_test_mac.cc.

285 {
286 return 0.0f;
287}

◆ GetWindowSize()

ISize impeller::GoldenPlaygroundTest::GetWindowSize ( ) const

Definition at line 289 of file golden_playground_test_mac.cc.

289 {
290 return pimpl_->window_size;
291}

◆ ImGuiBegin()

bool impeller::GoldenPlaygroundTest::ImGuiBegin ( const char *  name,
bool *  p_open,
ImGuiWindowFlags  flags 
)
static

Definition at line 229 of file golden_playground_test_mac.cc.

231 {
232 return false;
233}

◆ MakeContext()

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

On Metal we create a context for each test.

On OpenGL we create a context for each test.

Definition at line 262 of file golden_playground_test_mac.cc.

262 {
263 if (GetParam() == PlaygroundBackend::kMetal) {
264 /// On Metal we create a context for each test.
265 return GetContext();
266 } else if (GetParam() == PlaygroundBackend::kVulkan) {
267 bool enable_vulkan_validations = true;
268 FML_CHECK(!pimpl_->test_vulkan_playground)
269 << "We don't support creating multiple contexts for one test";
270 pimpl_->test_vulkan_playground =
271 MakeVulkanPlayground(enable_vulkan_validations);
272 pimpl_->screenshotter = std::make_unique<testing::VulkanScreenshotter>(
273 pimpl_->test_vulkan_playground);
274 return pimpl_->test_vulkan_playground->GetContext();
275 } else {
276 /// On OpenGL we create a context for each test.
277 return GetContext();
278 }
279}
#define FML_CHECK(condition)
Definition logging.h:85

◆ OpenAssetAsRuntimeStage()

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

Definition at line 248 of file golden_playground_test_mac.cc.

249 {
250 const std::shared_ptr<fml::Mapping> fixture =
252 if (!fixture || fixture->GetSize() == 0) {
253 return {};
254 }
255 return RuntimeStage::DecodeRuntimeStages(fixture);
256}
static Map DecodeRuntimeStages(const std::shared_ptr< fml::Mapping > &payload)

◆ OpenPlaygroundHere() [1/2]

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

Definition at line 210 of file golden_playground_test_mac.cc.

212 { // NOLINT(performance-unnecessary-value-param)
213 AiksContext renderer(GetContext(), typographer_context_);
214
215 std::optional<Picture> picture;
216 std::unique_ptr<testing::Screenshot> screenshot;
217 for (int i = 0; i < 2; ++i) {
218 picture = callback(renderer);
219 if (!picture.has_value()) {
220 return false;
221 }
222 screenshot = pimpl_->screenshotter->MakeScreenshot(
223 renderer, picture.value(), pimpl_->window_size);
224 }
225
226 return SaveScreenshot(std::move(screenshot));
227}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
sk_sp< const SkPicture > picture
Definition SkRecords.h:299

◆ OpenPlaygroundHere() [2/2]

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

Definition at line 202 of file golden_playground_test_mac.cc.

202 {
203 AiksContext renderer(GetContext(), typographer_context_);
204
205 auto screenshot = pimpl_->screenshotter->MakeScreenshot(renderer, picture,
206 pimpl_->window_size);
207 return SaveScreenshot(std::move(screenshot));
208}

◆ SetCapabilities()

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

Definition at line 297 of file golden_playground_test_mac.cc.

298 {
299 return pimpl_->screenshotter->GetPlayground().SetCapabilities(capabilities);
300}

◆ SetTypographerContext()

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

Definition at line 122 of file golden_playground_test_mac.cc.

123 {
124 typographer_context_ = std::move(typographer_context);
125};

◆ SetUp()

void impeller::GoldenPlaygroundTest::SetUp ( )

Definition at line 141 of file golden_playground_test_mac.cc.

141 {
142 std::filesystem::path testing_assets_path =
144 std::filesystem::path target_path = testing_assets_path.parent_path()
145 .parent_path()
146 .parent_path()
147 .parent_path();
148 std::filesystem::path icd_path = target_path / "vk_swiftshader_icd.json";
149 setenv("VK_ICD_FILENAMES", icd_path.c_str(), 1);
150
151 std::string test_name = GetTestName();
152 bool enable_wide_gamut = test_name.find("WideGamut_") != std::string::npos;
153 switch (GetParam()) {
155 if (!DoesSupportWideGamutTests()) {
156 GTEST_SKIP_(
157 "This metal device doesn't support wide gamut golden tests.");
158 }
159 pimpl_->screenshotter =
160 std::make_unique<testing::MetalScreenshotter>(enable_wide_gamut);
161 break;
163 if (enable_wide_gamut) {
164 GTEST_SKIP_("Vulkan doesn't support wide gamut golden tests.");
165 }
166 const std::unique_ptr<PlaygroundImpl>& playground =
167 GetSharedVulkanPlayground(/*enable_validations=*/true);
168 pimpl_->screenshotter =
169 std::make_unique<testing::VulkanScreenshotter>(playground);
170 break;
171 }
173 if (enable_wide_gamut) {
174 GTEST_SKIP_("OpenGLES doesn't support wide gamut golden tests.");
175 }
176 FML_CHECK(::glfwInit() == GLFW_TRUE);
177 PlaygroundSwitches playground_switches;
178 playground_switches.use_angle = true;
179 pimpl_->test_opengl_playground = PlaygroundImpl::Create(
180 PlaygroundBackend::kOpenGLES, playground_switches);
181 pimpl_->screenshotter = std::make_unique<testing::VulkanScreenshotter>(
182 pimpl_->test_opengl_playground);
183 break;
184 }
185 }
186
187 if (std::find(kSkipTests.begin(), kSkipTests.end(), test_name) !=
188 kSkipTests.end()) {
189 GTEST_SKIP_(
190 "GoldenPlaygroundTest doesn't support interactive playground tests "
191 "yet.");
192 }
193
195 "gpu_string", GetContext()->DescribeGpuModel());
196}
static std::unique_ptr< PlaygroundImpl > Create(PlaygroundBackend backend, PlaygroundSwitches switches)
static GoldenDigest * Instance()
void AddDimension(const std::string &name, const std::string &value)
#define GLFW_TRUE
const char * GetTestingAssetsPath()
Returns the directory containing assets shared across all tests.
static const std::vector< std::string > kSkipTests

◆ 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 127 of file golden_playground_test_mac.cc.

127 {
128 ASSERT_FALSE(dlopen("/usr/local/lib/libMoltenVK.dylib", RTLD_NOLOAD));
129}

◆ 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: