Flutter Engine
The Flutter Engine
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)>
 
using AiksDlPlaygroundCallback = std::function< sk_sp< flutter::DisplayList >()>
 

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)
 
bool OpenPlaygroundHere (const AiksDlPlaygroundCallback &callback)
 
bool OpenPlaygroundHere (const sk_sp< flutter::DisplayList > &list)
 
std::shared_ptr< TextureCreateTextureForFixture (const char *fixture_name, bool enable_mipmapping=false) const
 
sk_sp< flutter::DlImageCreateDlImageForFixture (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 25 of file golden_playground_test.h.

Member Typedef Documentation

◆ AiksDlPlaygroundCallback

Definition at line 31 of file golden_playground_test.h.

◆ AiksPlaygroundCallback

Definition at line 28 of file golden_playground_test.h.

Constructor & Destructor Documentation

◆ GoldenPlaygroundTest()

impeller::GoldenPlaygroundTest::GoldenPlaygroundTest ( )
default

Definition at line 119 of file golden_playground_test_mac.cc.

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

◆ ~GoldenPlaygroundTest()

impeller::GoldenPlaygroundTest::~GoldenPlaygroundTest ( )
overridedefault

Member Function Documentation

◆ CreateDlImageForFixture()

sk_sp< flutter::DlImage > impeller::GoldenPlaygroundTest::CreateDlImageForFixture ( const char *  fixture_name,
bool  enable_mipmapping = false 
) const

Definition at line 278 of file golden_playground_test_mac.cc.

280 {
281 std::shared_ptr<Texture> texture =
282 CreateTextureForFixture(fixture_name, enable_mipmapping);
284}
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
std::shared_ptr< Texture > CreateTextureForFixture(const char *fixture_name, bool enable_mipmapping=false) const
FlTexture * texture

◆ CreateTextureForFixture()

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

Definition at line 265 of file golden_playground_test_mac.cc.

267 {
268 std::shared_ptr<fml::Mapping> mapping =
271 enable_mipmapping);
272 if (result) {
273 result->SetLabel(fixture_name);
274 }
275 return result;
276}
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)
Definition: playground.cc:441
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 201 of file golden_playground_test_mac.cc.

201 {
202 return GetParam();
203}

◆ GetContentScale()

Point impeller::GoldenPlaygroundTest::GetContentScale ( ) const

Definition at line 319 of file golden_playground_test_mac.cc.

319 {
320 return pimpl_->screenshotter->GetPlayground().GetContentScale();
321}

◆ GetContext()

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

Definition at line 296 of file golden_playground_test_mac.cc.

296 {
297 return pimpl_->screenshotter->GetPlayground().GetContext();
298}

◆ GetSecondsElapsed()

Scalar impeller::GoldenPlaygroundTest::GetSecondsElapsed ( ) const

Definition at line 323 of file golden_playground_test_mac.cc.

323 {
324 return 0.0f;
325}

◆ GetWindowSize()

ISize impeller::GoldenPlaygroundTest::GetWindowSize ( ) const

Definition at line 327 of file golden_playground_test_mac.cc.

327 {
328 return pimpl_->window_size;
329}

◆ ImGuiBegin()

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

Definition at line 259 of file golden_playground_test_mac.cc.

261 {
262 return false;
263}

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

300 {
301 if (GetParam() == PlaygroundBackend::kMetal) {
302 /// On Metal we create a context for each test.
303 return GetContext();
304 } else if (GetParam() == PlaygroundBackend::kVulkan) {
305 bool enable_vulkan_validations = true;
306 FML_CHECK(!pimpl_->test_vulkan_playground)
307 << "We don't support creating multiple contexts for one test";
308 pimpl_->test_vulkan_playground =
309 MakeVulkanPlayground(enable_vulkan_validations);
310 pimpl_->screenshotter = std::make_unique<testing::VulkanScreenshotter>(
311 pimpl_->test_vulkan_playground);
312 return pimpl_->test_vulkan_playground->GetContext();
313 } else {
314 /// On OpenGL we create a context for each test.
315 return GetContext();
316 }
317}
#define FML_CHECK(condition)
Definition: logging.h:85

◆ OpenAssetAsRuntimeStage()

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

Definition at line 286 of file golden_playground_test_mac.cc.

287 {
288 const std::shared_ptr<fml::Mapping> fixture =
290 if (!fixture || fixture->GetSize() == 0) {
291 return {};
292 }
293 return RuntimeStage::DecodeRuntimeStages(fixture);
294}
static Map DecodeRuntimeStages(const std::shared_ptr< fml::Mapping > &payload)

◆ OpenPlaygroundHere() [1/4]

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

Definition at line 232 of file golden_playground_test_mac.cc.

234 { // NOLINT(performance-unnecessary-value-param)
235 AiksContext renderer(GetContext(), typographer_context_);
236
237 std::optional<Picture> picture;
238 std::unique_ptr<testing::Screenshot> screenshot;
239 for (int i = 0; i < 2; ++i) {
241 if (!picture.has_value()) {
242 return false;
243 }
244 screenshot = pimpl_->screenshotter->MakeScreenshot(
245 renderer, picture.value(), pimpl_->window_size);
246 }
247
248 return SaveScreenshot(std::move(screenshot));
249}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299

◆ OpenPlaygroundHere() [2/4]

bool impeller::GoldenPlaygroundTest::OpenPlaygroundHere ( const AiksDlPlaygroundCallback callback)

Definition at line 213 of file golden_playground_test_mac.cc.

214 {
215 AiksContext renderer(GetContext(), typographer_context_);
216
217 std::optional<Picture> picture;
218 std::unique_ptr<testing::Screenshot> screenshot;
219 for (int i = 0; i < 2; ++i) {
220 auto display_list = callback();
221 DlDispatcher dispatcher;
222 display_list->Dispatch(dispatcher);
223 Picture picture = dispatcher.EndRecordingAsPicture();
224
225 screenshot = pimpl_->screenshotter->MakeScreenshot(renderer, picture,
226 pimpl_->window_size);
227 }
228
229 return SaveScreenshot(std::move(screenshot));
230}
SK_API sk_sp< PrecompileShader > Picture()

◆ OpenPlaygroundHere() [3/4]

bool impeller::GoldenPlaygroundTest::OpenPlaygroundHere ( const sk_sp< flutter::DisplayList > &  list)

Definition at line 251 of file golden_playground_test_mac.cc.

252 {
253 DlDispatcher dispatcher;
254 list->Dispatch(dispatcher);
255 Picture picture = dispatcher.EndRecordingAsPicture();
256 return OpenPlaygroundHere(std::move(picture));
257}
void Dispatch(DlOpReceiver &ctx) const

◆ OpenPlaygroundHere() [4/4]

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

Definition at line 205 of file golden_playground_test_mac.cc.

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

◆ SetCapabilities()

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

Definition at line 335 of file golden_playground_test_mac.cc.

336 {
337 return pimpl_->screenshotter->GetPlayground().SetCapabilities(capabilities);
338}

◆ SetTypographerContext()

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

Definition at line 125 of file golden_playground_test_mac.cc.

126 {
127 typographer_context_ = std::move(typographer_context);
128};

◆ SetUp()

void impeller::GoldenPlaygroundTest::SetUp ( )

Definition at line 144 of file golden_playground_test_mac.cc.

144 {
145 std::filesystem::path testing_assets_path =
147 std::filesystem::path target_path = testing_assets_path.parent_path()
148 .parent_path()
149 .parent_path()
150 .parent_path();
151 std::filesystem::path icd_path = target_path / "vk_swiftshader_icd.json";
152 setenv("VK_ICD_FILENAMES", icd_path.c_str(), 1);
153
154 std::string test_name = GetTestName();
155 bool enable_wide_gamut = test_name.find("WideGamut_") != std::string::npos;
156 switch (GetParam()) {
158 if (!DoesSupportWideGamutTests()) {
159 GTEST_SKIP_(
160 "This metal device doesn't support wide gamut golden tests.");
161 }
162 pimpl_->screenshotter =
163 std::make_unique<testing::MetalScreenshotter>(enable_wide_gamut);
164 break;
166 if (enable_wide_gamut) {
167 GTEST_SKIP_("Vulkan doesn't support wide gamut golden tests.");
168 }
169 const std::unique_ptr<PlaygroundImpl>& playground =
170 GetSharedVulkanPlayground(/*enable_validations=*/true);
171 pimpl_->screenshotter =
172 std::make_unique<testing::VulkanScreenshotter>(playground);
173 break;
174 }
176 if (enable_wide_gamut) {
177 GTEST_SKIP_("OpenGLES doesn't support wide gamut golden tests.");
178 }
179 FML_CHECK(::glfwInit() == GLFW_TRUE);
180 PlaygroundSwitches playground_switches;
181 playground_switches.use_angle = true;
182 pimpl_->test_opengl_playground = PlaygroundImpl::Create(
183 PlaygroundBackend::kOpenGLES, playground_switches);
184 pimpl_->screenshotter = std::make_unique<testing::VulkanScreenshotter>(
185 pimpl_->test_opengl_playground);
186 break;
187 }
188 }
189
190 if (std::find(kSkipTests.begin(), kSkipTests.end(), test_name) !=
191 kSkipTests.end()) {
192 GTEST_SKIP_(
193 "GoldenPlaygroundTest doesn't support interactive playground tests "
194 "yet.");
195 }
196
198 "gpu_string", GetContext()->DescribeGpuModel());
199}
int find(T *array, int N, T item)
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
Definition: flutter_glfw.cc:33
const char * GetTestingAssetsPath()
Returns the directory containing assets shared across all tests.
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
static const std::vector< std::string > kSkipTests

◆ SetWindowSize()

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

Definition at line 83 of file golden_playground_test_stub.cc.

83{}

◆ TearDown()

void impeller::GoldenPlaygroundTest::TearDown ( )

Definition at line 130 of file golden_playground_test_mac.cc.

130 {
131 ASSERT_FALSE(dlopen("/usr/local/lib/libMoltenVK.dylib", RTLD_NOLOAD));
132}

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

83{ return true; }

The documentation for this class was generated from the following files: