Flutter Impeller
impeller::EntityPlayground Class Reference

#include <entity_playground.h>

Inheritance diagram for impeller::EntityPlayground:
impeller::PlaygroundTest impeller::Playground

Public Types

using EntityPlaygroundCallback = std::function< bool(ContentContext &context, RenderPass &pass)>
 
- Public Types inherited from impeller::Playground
using SinglePassCallback = std::function< bool(RenderPass &pass)>
 

Public Member Functions

 EntityPlayground ()
 
 ~EntityPlayground ()
 
void SetTypographerContext (std::shared_ptr< TypographerContext > typographer_context)
 
bool OpenPlaygroundHere (Entity entity)
 
bool OpenPlaygroundHere (EntityPass &entity_pass)
 
bool OpenPlaygroundHere (EntityPlaygroundCallback callback)
 
- Public Member Functions inherited from impeller::PlaygroundTest
 PlaygroundTest ()
 
virtual ~PlaygroundTest ()
 
void SetUp () override
 
void TearDown () override
 
PlaygroundBackend GetBackend () const
 
std::unique_ptr< fml::Mapping > OpenAssetAsMapping (std::string asset_name) const override
 
std::shared_ptr< RuntimeStageOpenAssetAsRuntimeStage (const char *asset_name) const
 
std::string GetWindowTitle () const override
 
- Public Member Functions inherited from impeller::Playground
 Playground (PlaygroundSwitches switches)
 
virtual ~Playground ()
 
void SetupContext (PlaygroundBackend backend)
 
void SetupWindow ()
 
void TeardownWindow ()
 
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
 
bool OpenPlaygroundHere (const Renderer::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
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::Playground
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 Attributes inherited from impeller::Playground
const PlaygroundSwitches switches_
 

Detailed Description

Definition at line 17 of file entity_playground.h.

Member Typedef Documentation

◆ EntityPlaygroundCallback

Definition at line 20 of file entity_playground.h.

Constructor & Destructor Documentation

◆ EntityPlayground()

impeller::EntityPlayground::EntityPlayground ( )

Definition at line 13 of file entity_playground.cc.

14  : typographer_context_(TypographerContextSkia::Make()) {}

◆ ~EntityPlayground()

impeller::EntityPlayground::~EntityPlayground ( )
default

Member Function Documentation

◆ OpenPlaygroundHere() [1/3]

bool impeller::EntityPlayground::OpenPlaygroundHere ( Entity  entity)

Definition at line 39 of file entity_playground.cc.

39  {
41  return true;
42  }
43 
44  ContentContext content_context(GetContext(), typographer_context_);
45  if (!content_context.IsValid()) {
46  return false;
47  }
48  SinglePassCallback callback = [&](RenderPass& pass) -> bool {
49  return entity.Render(content_context, pass);
50  };
51  return Playground::OpenPlaygroundHere(callback);
52 }

References impeller::PlaygroundSwitches::enable_playground, impeller::Playground::GetContext(), impeller::ContentContext::IsValid(), impeller::Playground::OpenPlaygroundHere(), impeller::Entity::Render(), and impeller::Playground::switches_.

◆ OpenPlaygroundHere() [2/3]

bool impeller::EntityPlayground::OpenPlaygroundHere ( EntityPass entity_pass)

Definition at line 23 of file entity_playground.cc.

23  {
25  return true;
26  }
27 
28  ContentContext content_context(GetContext(), typographer_context_);
29  if (!content_context.IsValid()) {
30  return false;
31  }
32 
33  auto callback = [&](RenderTarget& render_target) -> bool {
34  return entity_pass.Render(content_context, render_target);
35  };
36  return Playground::OpenPlaygroundHere(callback);
37 }

References impeller::PlaygroundSwitches::enable_playground, impeller::Playground::GetContext(), impeller::ContentContext::IsValid(), impeller::Playground::OpenPlaygroundHere(), impeller::EntityPass::Render(), and impeller::Playground::switches_.

◆ OpenPlaygroundHere() [3/3]

bool impeller::EntityPlayground::OpenPlaygroundHere ( EntityPlaygroundCallback  callback)

Definition at line 54 of file entity_playground.cc.

54  {
56  return true;
57  }
58 
59  ContentContext content_context(GetContext(), typographer_context_);
60  if (!content_context.IsValid()) {
61  return false;
62  }
63  SinglePassCallback pass_callback = [&](RenderPass& pass) -> bool {
64  static bool wireframe = false;
65  if (ImGui::IsKeyPressed(ImGuiKey_Z)) {
66  wireframe = !wireframe;
67  content_context.SetWireframe(wireframe);
68  }
69  return callback(content_context, pass);
70  };
71  return Playground::OpenPlaygroundHere(pass_callback);
72 }

References impeller::PlaygroundSwitches::enable_playground, impeller::Playground::GetContext(), impeller::ContentContext::IsValid(), impeller::Playground::OpenPlaygroundHere(), impeller::ContentContext::SetWireframe(), and impeller::Playground::switches_.

◆ SetTypographerContext()

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

Definition at line 18 of file entity_playground.cc.

19  {
20  typographer_context_ = std::move(typographer_context);
21 }

The documentation for this class was generated from the following files:
impeller::Playground::switches_
const PlaygroundSwitches switches_
Definition: playground.h:91
impeller::Playground::SinglePassCallback
std::function< bool(RenderPass &pass)> SinglePassCallback
Definition: playground.h:35
impeller::Playground::OpenPlaygroundHere
bool OpenPlaygroundHere(const Renderer::RenderCallback &render_callback)
Definition: playground.cc:189
impeller::Playground::GetContext
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:86
impeller::PlaygroundSwitches::enable_playground
bool enable_playground
Definition: switches.h:16
impeller::TypographerContextSkia::Make
static std::shared_ptr< TypographerContext > Make()
Definition: typographer_context_skia.cc:30