Flutter Impeller
impeller::Playground Class Referenceabstract

#include <playground.h>

Inheritance diagram for impeller::Playground:
impeller::ComputePlaygroundTest impeller::PlaygroundTest impeller::AiksPlayground impeller::DlPlayground impeller::EntityPlayground impeller::RuntimeStagePlayground impeller::interop::testing::PlaygroundTest impeller::testing::RendererDartTest impeller::testing::BlendFilterContentsTest impeller::testing::GaussianBlurFilterContentsTest impeller::testing::MatrixFilterContentsTest

Public Types

using SinglePassCallback = std::function< bool(RenderPass &pass)>
 
using RenderCallback = std::function< bool(RenderTarget &render_target)>
 
using GLProcAddressResolver = std::function< void *(const char *proc_name)>
 
using VKProcAddressResolver = std::function< void *(void *instance, const char *proc_name)>
 

Public Member Functions

 Playground (PlaygroundSwitches switches)
 
virtual ~Playground ()
 
void SetupContext (PlaygroundBackend backend, const PlaygroundSwitches &switches)
 
void SetupWindow ()
 
void TeardownWindow ()
 
bool IsPlaygroundEnabled () const
 
Point GetCursorPosition () const
 
ISize GetWindowSize () const
 
Point GetContentScale () const
 
Scalar GetSecondsElapsed () const
 Get the amount of time elapsed from the start of the playground's execution. More...
 
std::shared_ptr< ContextGetContext () const
 
std::shared_ptr< ContextMakeContext () const
 
bool OpenPlaygroundHere (const RenderCallback &render_callback)
 
bool OpenPlaygroundHere (SinglePassCallback pass_callback)
 
std::shared_ptr< TextureCreateTextureForFixture (const char *fixture_name, bool enable_mipmapping=false) const
 
std::shared_ptr< TextureCreateTextureCubeForFixture (std::array< const char *, 6 > fixture_names) const
 
virtual std::unique_ptr< fml::Mapping > OpenAssetAsMapping (std::string asset_name) const =0
 
virtual std::string GetWindowTitle () const =0
 
fml::Status SetCapabilities (const std::shared_ptr< Capabilities > &capabilities)
 
bool WillRenderSomething () const
 Returns true if OpenPlaygroundHere will actually render anything. More...
 
GLProcAddressResolver CreateGLProcAddressResolver () const
 
VKProcAddressResolver CreateVKProcAddressResolver () const
 
void SetGPUDisabled (bool disabled) const
 Mark the GPU as unavilable. More...
 
RuntimeStageBackend GetRuntimeStageBackend () const
 

Static Public Member Functions

static bool ShouldOpenNewPlaygrounds ()
 
static std::shared_ptr< CompressedImageLoadFixtureImageCompressed (std::shared_ptr< fml::Mapping > mapping)
 
static std::optional< DecompressedImageDecodeImageRGBA (const std::shared_ptr< CompressedImage > &compressed)
 
static std::shared_ptr< TextureCreateTextureForMapping (const std::shared_ptr< Context > &context, std::shared_ptr< fml::Mapping > mapping, bool enable_mipmapping=false)
 
static bool SupportsBackend (PlaygroundBackend backend)
 

Protected Member Functions

virtual bool ShouldKeepRendering () const
 
void SetWindowSize (ISize size)
 

Protected Attributes

const PlaygroundSwitches switches_
 

Detailed Description

Definition at line 35 of file playground.h.

Member Typedef Documentation

◆ GLProcAddressResolver

using impeller::Playground::GLProcAddressResolver = std::function<void*(const char* proc_name)>

Definition at line 105 of file playground.h.

◆ RenderCallback

using impeller::Playground::RenderCallback = std::function<bool(RenderTarget& render_target)>

Definition at line 68 of file playground.h.

◆ SinglePassCallback

using impeller::Playground::SinglePassCallback = std::function<bool(RenderPass& pass)>

Definition at line 37 of file playground.h.

◆ VKProcAddressResolver

using impeller::Playground::VKProcAddressResolver = std::function<void*(void* instance, const char* proc_name)>

Definition at line 108 of file playground.h.

Constructor & Destructor Documentation

◆ Playground()

impeller::Playground::Playground ( PlaygroundSwitches  switches)
explicit

Definition at line 87 of file playground.cc.

87  : switches_(switches) {
89  flutter::testing::SetupSwiftshaderOnce(switches_.use_swiftshader);
90 }
const PlaygroundSwitches switches_
Definition: playground.h:120
static void InitializeGLFWOnce()
Definition: playground.cc:61

References impeller::InitializeGLFWOnce(), switches_, and impeller::PlaygroundSwitches::use_swiftshader.

◆ ~Playground()

impeller::Playground::~Playground ( )
virtualdefault

Member Function Documentation

◆ CreateGLProcAddressResolver()

Playground::GLProcAddressResolver impeller::Playground::CreateGLProcAddressResolver ( ) const

Definition at line 524 of file playground.cc.

525  {
526  return impl_->CreateGLProcAddressResolver();
527 }

Referenced by impeller::interop::testing::PlaygroundTest::CreateContext().

◆ CreateTextureCubeForFixture()

std::shared_ptr< Texture > impeller::Playground::CreateTextureCubeForFixture ( std::array< const char *, 6 >  fixture_names) const

Definition at line 462 of file playground.cc.

463  {
464  std::array<DecompressedImage, 6> images;
465  for (size_t i = 0; i < fixture_names.size(); i++) {
466  auto image = DecodeImageRGBA(
468  if (!image.has_value()) {
469  return nullptr;
470  }
471  images[i] = image.value();
472  }
473 
474  TextureDescriptor texture_descriptor;
475  texture_descriptor.storage_mode = StorageMode::kDevicePrivate;
476  texture_descriptor.type = TextureType::kTextureCube;
477  texture_descriptor.format = PixelFormat::kR8G8B8A8UNormInt;
478  texture_descriptor.size = images[0].GetSize();
479  texture_descriptor.mip_count = 1u;
480 
481  auto texture =
482  context_->GetResourceAllocator()->CreateTexture(texture_descriptor);
483  if (!texture) {
484  VALIDATION_LOG << "Could not allocate texture cube.";
485  return nullptr;
486  }
487  texture->SetLabel("Texture cube");
488 
489  auto cmd_buffer = context_->CreateCommandBuffer();
490  auto blit_pass = cmd_buffer->CreateBlitPass();
491  for (size_t i = 0; i < fixture_names.size(); i++) {
492  auto device_buffer = context_->GetResourceAllocator()->CreateBufferWithCopy(
493  *images[i].GetAllocation());
494  blit_pass->AddCopy(DeviceBuffer::AsBufferView(device_buffer), texture, {},
495  "", /*mip_level=*/0, /*slice=*/i);
496  }
497 
498  if (!blit_pass->EncodeCommands() ||
499  !context_->GetCommandQueue()->Submit({std::move(cmd_buffer)}).ok()) {
500  VALIDATION_LOG << "Could not upload texture to device memory.";
501  return nullptr;
502  }
503 
504  return texture;
505 }
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
static std::shared_ptr< CompressedImage > LoadFixtureImageCompressed(std::shared_ptr< fml::Mapping > mapping)
Definition: playground.cc:365
virtual std::unique_ptr< fml::Mapping > OpenAssetAsMapping(std::string asset_name) const =0
static std::optional< DecompressedImage > DecodeImageRGBA(const std::shared_ptr< CompressedImage > &compressed)
Definition: playground.cc:376
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::DeviceBuffer::AsBufferView(), DecodeImageRGBA(), impeller::TextureDescriptor::format, impeller::kDevicePrivate, impeller::kR8G8B8A8UNormInt, impeller::kTextureCube, LoadFixtureImageCompressed(), impeller::TextureDescriptor::mip_count, OpenAssetAsMapping(), impeller::TextureDescriptor::size, impeller::TextureDescriptor::storage_mode, impeller::TextureDescriptor::type, and VALIDATION_LOG.

◆ CreateTextureForFixture()

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

Definition at line 450 of file playground.cc.

452  {
453  auto texture = CreateTextureForMapping(
454  context_, OpenAssetAsMapping(fixture_name), enable_mipmapping);
455  if (texture == nullptr) {
456  return nullptr;
457  }
458  texture->SetLabel(fixture_name);
459  return texture;
460 }
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:437

References CreateTextureForMapping(), and OpenAssetAsMapping().

◆ CreateTextureForMapping()

std::shared_ptr< Texture > impeller::Playground::CreateTextureForMapping ( const std::shared_ptr< Context > &  context,
std::shared_ptr< fml::Mapping >  mapping,
bool  enable_mipmapping = false 
)
static

Definition at line 437 of file playground.cc.

440  {
441  auto image = Playground::DecodeImageRGBA(
442  Playground::LoadFixtureImageCompressed(std::move(mapping)));
443  if (!image.has_value()) {
444  return nullptr;
445  }
446  return CreateTextureForDecompressedImage(context, image.value(),
447  enable_mipmapping);
448 }
static std::shared_ptr< Texture > CreateTextureForDecompressedImage(const std::shared_ptr< Context > &context, DecompressedImage &decompressed_image, bool enable_mipmapping)
Definition: playground.cc:395

References impeller::CreateTextureForDecompressedImage(), DecodeImageRGBA(), and LoadFixtureImageCompressed().

Referenced by impeller::DlPlayground::CreateDlImageForFixture(), impeller::GoldenPlaygroundTest::CreateTextureForFixture(), and CreateTextureForFixture().

◆ CreateVKProcAddressResolver()

Playground::VKProcAddressResolver impeller::Playground::CreateVKProcAddressResolver ( ) const

Definition at line 529 of file playground.cc.

530  {
531  return impl_->CreateVKProcAddressResolver();
532 }

Referenced by impeller::interop::testing::PlaygroundTest::CreateContext().

◆ DecodeImageRGBA()

std::optional< DecompressedImage > impeller::Playground::DecodeImageRGBA ( const std::shared_ptr< CompressedImage > &  compressed)
static

Definition at line 376 of file playground.cc.

377  {
378  if (compressed == nullptr) {
379  return std::nullopt;
380  }
381  // The decoded image is immediately converted into RGBA as that format is
382  // known to be supported everywhere. For image sources that don't need 32
383  // bit pixel strides, this is overkill. Since this is a test fixture we
384  // aren't necessarily trying to eke out memory savings here and instead
385  // favor simplicity.
386  auto image = compressed->Decode().ConvertToRGBA();
387  if (!image.IsValid()) {
388  VALIDATION_LOG << "Could not decode image.";
389  return std::nullopt;
390  }
391 
392  return image;
393 }

References VALIDATION_LOG.

Referenced by CreateTextureCubeForFixture(), CreateTextureForMapping(), and impeller::interop::testing::PlaygroundTest::OpenAssetAsHPPTexture().

◆ GetContentScale()

Point impeller::Playground::GetContentScale ( ) const

◆ GetContext()

◆ GetCursorPosition()

Point impeller::Playground::GetCursorPosition ( ) const

Definition at line 185 of file playground.cc.

185  {
186  return cursor_position_;
187 }

◆ GetRuntimeStageBackend()

RuntimeStageBackend impeller::Playground::GetRuntimeStageBackend ( ) const

Definition at line 538 of file playground.cc.

538  {
539  return impl_->GetRuntimeStageBackend();
540 }

◆ GetSecondsElapsed()

Scalar impeller::Playground::GetSecondsElapsed ( ) const

Get the amount of time elapsed from the start of the playground's execution.

Definition at line 197 of file playground.cc.

197  {
198  return (fml::TimePoint::Now().ToEpochDelta() - start_time_).ToSecondsF();
199 }

◆ GetWindowSize()

ISize impeller::Playground::GetWindowSize ( ) const

◆ GetWindowTitle()

virtual std::string impeller::Playground::GetWindowTitle ( ) const
pure virtual

◆ IsPlaygroundEnabled()

bool impeller::Playground::IsPlaygroundEnabled ( ) const

◆ LoadFixtureImageCompressed()

std::shared_ptr< CompressedImage > impeller::Playground::LoadFixtureImageCompressed ( std::shared_ptr< fml::Mapping >  mapping)
static

Definition at line 365 of file playground.cc.

366  {
367  auto compressed_image = CompressedImageSkia::Create(std::move(mapping));
368  if (!compressed_image) {
369  VALIDATION_LOG << "Could not create compressed image.";
370  return nullptr;
371  }
372 
373  return compressed_image;
374 }
static std::shared_ptr< CompressedImage > Create(std::shared_ptr< const fml::Mapping > allocation)

References impeller::CompressedImageSkia::Create(), and VALIDATION_LOG.

Referenced by CreateTextureCubeForFixture(), CreateTextureForMapping(), and impeller::interop::testing::PlaygroundTest::OpenAssetAsHPPTexture().

◆ MakeContext()

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

Definition at line 98 of file playground.cc.

98  {
99  // Playgrounds are already making a context for each test, so we can just
100  // return the `context_`.
101  return context_;
102 }

◆ OpenAssetAsMapping()

virtual std::unique_ptr<fml::Mapping> impeller::Playground::OpenAssetAsMapping ( std::string  asset_name) const
pure virtual

◆ OpenPlaygroundHere() [1/2]

bool impeller::Playground::OpenPlaygroundHere ( const RenderCallback render_callback)

Definition at line 205 of file playground.cc.

206  {
208  return true;
209  }
210 
211  if (!render_callback) {
212  return true;
213  }
214 
215  IMGUI_CHECKVERSION();
217  fml::ScopedCleanupClosure destroy_imgui_context(
218  []() { ImGui::DestroyContext(); });
219  ImGui::StyleColorsDark();
220 
221  auto& io = ImGui::GetIO();
222  io.IniFilename = nullptr;
223  io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
224  io.ConfigWindowsResizeFromEdges = true;
225 
226  auto window = reinterpret_cast<GLFWwindow*>(impl_->GetWindowHandle());
227  if (!window) {
228  return false;
229  }
230  ::glfwSetWindowTitle(window, GetWindowTitle().c_str());
231  ::glfwSetWindowUserPointer(window, this);
232  ::glfwSetWindowSizeCallback(
233  window, [](GLFWwindow* window, int width, int height) -> void {
234  auto playground =
235  reinterpret_cast<Playground*>(::glfwGetWindowUserPointer(window));
236  if (!playground) {
237  return;
238  }
239  playground->SetWindowSize(ISize{width, height}.Max({}));
240  });
241  ::glfwSetKeyCallback(window, &PlaygroundKeyCallback);
242  ::glfwSetCursorPosCallback(window, [](GLFWwindow* window, double x,
243  double y) {
244  reinterpret_cast<Playground*>(::glfwGetWindowUserPointer(window))
245  ->SetCursorPosition({static_cast<Scalar>(x), static_cast<Scalar>(y)});
246  });
247 
248  ImGui_ImplGlfw_InitForOther(window, true);
249  fml::ScopedCleanupClosure shutdown_imgui([]() { ImGui_ImplGlfw_Shutdown(); });
250 
251  ImGui_ImplImpeller_Init(context_);
252  fml::ScopedCleanupClosure shutdown_imgui_impeller(
253  []() { ImGui_ImplImpeller_Shutdown(); });
254 
255  ImGui::SetNextWindowPos({10, 10});
256 
257  ::glfwSetWindowSize(window, GetWindowSize().width, GetWindowSize().height);
258  ::glfwSetWindowPos(window, 200, 100);
259  ::glfwShowWindow(window);
260 
261  while (true) {
262 #if FML_OS_MACOSX
263  fml::ScopedNSAutoreleasePool pool;
264 #endif
265  ::glfwPollEvents();
266 
267  if (::glfwWindowShouldClose(window)) {
268  return true;
269  }
270 
271  ImGui_ImplGlfw_NewFrame();
272 
273  auto surface = impl_->AcquireSurfaceFrame(context_);
274  RenderTarget render_target = surface->GetRenderTarget();
275 
276  ImGui::NewFrame();
277  ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport(),
278  ImGuiDockNodeFlags_PassthruCentralNode);
279  bool result = render_callback(render_target);
280  ImGui::Render();
281 
282  // Render ImGui overlay.
283  {
284  auto buffer = context_->CreateCommandBuffer();
285  if (!buffer) {
286  VALIDATION_LOG << "Could not create command buffer.";
287  return false;
288  }
289  buffer->SetLabel("ImGui Command Buffer");
290 
291  auto color0 = render_target.GetColorAttachment(0);
292  color0.load_action = LoadAction::kLoad;
293  if (color0.resolve_texture) {
294  color0.texture = color0.resolve_texture;
295  color0.resolve_texture = nullptr;
296  color0.store_action = StoreAction::kStore;
297  }
298  render_target.SetColorAttachment(color0, 0);
299  render_target.SetStencilAttachment(std::nullopt);
300  render_target.SetDepthAttachment(std::nullopt);
301 
302  auto pass = buffer->CreateRenderPass(render_target);
303  if (!pass) {
304  VALIDATION_LOG << "Could not create render pass.";
305  return false;
306  }
307  pass->SetLabel("ImGui Render Pass");
308  if (!host_buffer_) {
309  host_buffer_ = HostBuffer::Create(
310  context_->GetResourceAllocator(), context_->GetIdleWaiter(),
311  context_->GetCapabilities()->GetMinimumUniformAlignment());
312  }
313 
314  ImGui_ImplImpeller_RenderDrawData(ImGui::GetDrawData(), *pass,
315  *host_buffer_);
316 
317  pass->EncodeCommands();
318 
319  if (!context_->GetCommandQueue()->Submit({buffer}).ok()) {
320  return false;
321  }
322  }
323 
324  if (!result || !surface->Present()) {
325  return false;
326  }
327 
328  if (!ShouldKeepRendering()) {
329  break;
330  }
331  }
332 
333  ::glfwHideWindow(window);
334 
335  return true;
336 }
static std::shared_ptr< HostBuffer > Create(const std::shared_ptr< Allocator > &allocator, const std::shared_ptr< const IdleWaiter > &idle_waiter, size_t minimum_uniform_alignment)
Definition: host_buffer.cc:21
Playground(PlaygroundSwitches switches)
Definition: playground.cc:87
virtual bool ShouldKeepRendering() const
Definition: playground.cc:511
ISize GetWindowSize() const
Definition: playground.cc:189
virtual std::string GetWindowTitle() const =0
int32_t x
void ImGui_ImplImpeller_RenderDrawData(ImDrawData *draw_data, impeller::RenderPass &render_pass, impeller::HostBuffer &host_buffer)
bool ImGui_ImplImpeller_Init(const std::shared_ptr< impeller::Context > &context)
void ImGui_ImplImpeller_Shutdown()
std::shared_ptr< ContextVK > CreateContext()
float Scalar
Definition: scalar.h:19
static void PlaygroundKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
Definition: playground.cc:172
ISize64 ISize
Definition: size.h:162
constexpr TSize Max(const TSize &o) const
Definition: size.h:97

References impeller::HostBuffer::Create(), impeller::android::testing::CreateContext(), impeller::PlaygroundSwitches::enable_playground, impeller::RenderTarget::GetColorAttachment(), GetWindowSize(), GetWindowTitle(), ImGui_ImplImpeller_Init(), ImGui_ImplImpeller_RenderDrawData(), ImGui_ImplImpeller_Shutdown(), impeller::kLoad, impeller::kStore, impeller::Attachment::load_action, impeller::TSize< T >::Max(), impeller::PlaygroundKeyCallback(), impeller::RenderTarget::SetColorAttachment(), impeller::RenderTarget::SetDepthAttachment(), impeller::RenderTarget::SetStencilAttachment(), SetWindowSize(), ShouldKeepRendering(), switches_, VALIDATION_LOG, and x.

Referenced by impeller::AiksPlayground::OpenPlaygroundHere(), impeller::DlPlayground::OpenPlaygroundHere(), impeller::EntityPlayground::OpenPlaygroundHere(), impeller::interop::testing::PlaygroundTest::OpenPlaygroundHere(), OpenPlaygroundHere(), impeller::testing::RendererDartTest::RenderDartToPlayground(), and impeller::testing::TEST_P().

◆ OpenPlaygroundHere() [2/2]

bool impeller::Playground::OpenPlaygroundHere ( SinglePassCallback  pass_callback)

Definition at line 338 of file playground.cc.

338  {
339  return OpenPlaygroundHere(
340  [context = GetContext(), &pass_callback](RenderTarget& render_target) {
341  auto buffer = context->CreateCommandBuffer();
342  if (!buffer) {
343  return false;
344  }
345  buffer->SetLabel("Playground Command Buffer");
346 
347  auto pass = buffer->CreateRenderPass(render_target);
348  if (!pass) {
349  return false;
350  }
351  pass->SetLabel("Playground Render Pass");
352 
353  if (!pass_callback(*pass)) {
354  return false;
355  }
356 
357  pass->EncodeCommands();
358  if (!context->GetCommandQueue()->Submit({buffer}).ok()) {
359  return false;
360  }
361  return true;
362  });
363 }
bool OpenPlaygroundHere(const RenderCallback &render_callback)
Definition: playground.cc:205
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:94

References GetContext(), and OpenPlaygroundHere().

◆ SetCapabilities()

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

Definition at line 515 of file playground.cc.

516  {
517  return impl_->SetCapabilities(capabilities);
518 }

◆ SetGPUDisabled()

void impeller::Playground::SetGPUDisabled ( bool  disabled) const

Mark the GPU as unavilable.

Only supported on the Metal backend.

Definition at line 534 of file playground.cc.

534  {
535  impl_->SetGPUDisabled(value);
536 }
int32_t value

References value.

◆ SetupContext()

void impeller::Playground::SetupContext ( PlaygroundBackend  backend,
const PlaygroundSwitches switches 
)

Definition at line 129 of file playground.cc.

130  {
131  FML_CHECK(SupportsBackend(backend));
132 
133  impl_ = PlaygroundImpl::Create(backend, switches);
134  if (!impl_) {
135  FML_LOG(WARNING) << "PlaygroundImpl::Create failed.";
136  return;
137  }
138 
139  context_ = impl_->GetContext();
140 }
static bool SupportsBackend(PlaygroundBackend backend)
Definition: playground.cc:104
static std::unique_ptr< PlaygroundImpl > Create(PlaygroundBackend backend, PlaygroundSwitches switches)

References impeller::PlaygroundImpl::Create(), and SupportsBackend().

Referenced by impeller::ComputePlaygroundTest::SetUp(), and impeller::PlaygroundTest::SetUp().

◆ SetupWindow()

void impeller::Playground::SetupWindow ( )

Definition at line 142 of file playground.cc.

142  {
143  if (!context_) {
144  FML_LOG(WARNING) << "Asked to set up a window with no context (call "
145  "SetupContext first).";
146  return;
147  }
148  start_time_ = fml::TimePoint::Now().ToEpochDelta();
149 }

Referenced by impeller::ComputePlaygroundTest::SetUp(), and impeller::PlaygroundTest::SetUp().

◆ SetWindowSize()

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

Definition at line 507 of file playground.cc.

507  {
508  window_size_ = size;
509 }

Referenced by OpenPlaygroundHere().

◆ ShouldKeepRendering()

bool impeller::Playground::ShouldKeepRendering ( ) const
protectedvirtual

Definition at line 511 of file playground.cc.

511  {
512  return true;
513 }

Referenced by OpenPlaygroundHere().

◆ ShouldOpenNewPlaygrounds()

bool impeller::Playground::ShouldOpenNewPlaygrounds ( )
static

Definition at line 168 of file playground.cc.

168  {
170 }
static std::atomic_bool gShouldOpenNewPlaygrounds
Definition: playground.cc:166

References impeller::gShouldOpenNewPlaygrounds.

Referenced by impeller::ComputePlaygroundTest::SetUp(), and impeller::PlaygroundTest::SetUp().

◆ SupportsBackend()

bool impeller::Playground::SupportsBackend ( PlaygroundBackend  backend)
static

Definition at line 104 of file playground.cc.

104  {
105  switch (backend) {
108 #if IMPELLER_ENABLE_METAL
109  return true;
110 #else // IMPELLER_ENABLE_METAL
111  return false;
112 #endif // IMPELLER_ENABLE_METAL
114 #if IMPELLER_ENABLE_OPENGLES
115  return true;
116 #else // IMPELLER_ENABLE_OPENGLES
117  return false;
118 #endif // IMPELLER_ENABLE_OPENGLES
120 #if IMPELLER_ENABLE_VULKAN
122 #else // IMPELLER_ENABLE_VULKAN
123  return false;
124 #endif // IMPELLER_ENABLE_VULKAN
125  }
126  FML_UNREACHABLE();
127 }

References impeller::PlaygroundImplVK::IsVulkanDriverPresent(), impeller::kMetal, impeller::kMetalSDF, impeller::kOpenGLES, and impeller::kVulkan.

Referenced by impeller::ComputePlaygroundTest::SetUp(), impeller::PlaygroundTest::SetUp(), and SetupContext().

◆ TeardownWindow()

void impeller::Playground::TeardownWindow ( )

Definition at line 155 of file playground.cc.

155  {
156  if (host_buffer_) {
157  host_buffer_.reset();
158  }
159  if (context_) {
160  context_->Shutdown();
161  }
162  context_.reset();
163  impl_.reset();
164 }

Referenced by impeller::ComputePlaygroundTest::TearDown(), and impeller::PlaygroundTest::TearDown().

◆ WillRenderSomething()

bool impeller::Playground::WillRenderSomething ( ) const

Returns true if OpenPlaygroundHere will actually render anything.

Definition at line 520 of file playground.cc.

520  {
522 }

References impeller::PlaygroundSwitches::enable_playground, and switches_.

Member Data Documentation

◆ switches_


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