Flutter Impeller
impeller::EntityPlayground Class Reference

#include <entity_playground.h>

Inheritance diagram for impeller::EntityPlayground:
impeller::PlaygroundTest impeller::Playground impeller::testing::BlendFilterContentsTest impeller::testing::GaussianBlurFilterContentsTest impeller::testing::MatrixFilterContentsTest

Public Types

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

 EntityPlayground ()
 
 ~EntityPlayground ()
 
void SetTypographerContext (std::shared_ptr< TypographerContext > typographer_context)
 
std::shared_ptr< TypographerContextGetTypographerContext () const
 
bool OpenPlaygroundHere (Entity entity)
 
bool OpenPlaygroundHere (EntityPlaygroundCallback callback)
 
std::shared_ptr< ContentContextGetContentContext () const
 
- 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
 
RuntimeStage::Map OpenAssetAsRuntimeStage (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, 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
 
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...
 

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 Member Functions inherited from impeller::Playground
void SetWindowSize (ISize size)
 
- Protected Attributes inherited from impeller::Playground
const PlaygroundSwitches switches_
 

Detailed Description

Definition at line 16 of file entity_playground.h.

Member Typedef Documentation

◆ EntityPlaygroundCallback

Definition at line 18 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()) {}
static std::shared_ptr< TypographerContext > Make()

◆ ~EntityPlayground()

impeller::EntityPlayground::~EntityPlayground ( )
default

Member Function Documentation

◆ GetContentContext()

std::shared_ptr< ContentContext > impeller::EntityPlayground::GetContentContext ( ) const

Definition at line 28 of file entity_playground.cc.

28  {
29  return std::make_shared<ContentContext>(GetContext(), typographer_context_);
30 }
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:91

References impeller::Playground::GetContext().

Referenced by impeller::testing::BlendFilterContentsTest::MakeTexture(), impeller::testing::GaussianBlurFilterContentsTest::MakeTexture(), impeller::testing::MatrixFilterContentsTest::MakeTexture(), and OpenPlaygroundHere().

◆ GetTypographerContext()

std::shared_ptr< TypographerContext > impeller::EntityPlayground::GetTypographerContext ( ) const

Definition at line 23 of file entity_playground.cc.

24  {
25  return typographer_context_;
26 }

◆ OpenPlaygroundHere() [1/2]

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

Definition at line 32 of file entity_playground.cc.

32  {
34  return true;
35  }
36 
37  auto content_context = GetContentContext();
38  if (!content_context->IsValid()) {
39  return false;
40  }
41  SinglePassCallback callback = [&](RenderPass& pass) -> bool {
42  content_context->GetRenderTargetCache()->Start();
43  bool result = entity.Render(*content_context, pass);
44  content_context->GetRenderTargetCache()->End();
45  content_context->GetTransientsBuffer().Reset();
46  return result;
47  };
48  return Playground::OpenPlaygroundHere(callback);
49 }
std::shared_ptr< ContentContext > GetContentContext() const
bool OpenPlaygroundHere(const RenderCallback &render_callback)
Definition: playground.cc:201
std::function< bool(RenderPass &pass)> SinglePassCallback
Definition: playground.h:50
const PlaygroundSwitches switches_
Definition: playground.h:131

References impeller::PlaygroundSwitches::enable_playground, GetContentContext(), impeller::Playground::OpenPlaygroundHere(), impeller::Entity::Render(), and impeller::Playground::switches_.

◆ OpenPlaygroundHere() [2/2]

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

Definition at line 51 of file entity_playground.cc.

51  {
53  return true;
54  }
55 
56  ContentContext content_context(GetContext(), typographer_context_);
57  if (!content_context.IsValid()) {
58  return false;
59  }
60  SinglePassCallback pass_callback = [&](RenderPass& pass) -> bool {
61  content_context.GetRenderTargetCache()->Start();
62  bool result = callback(content_context, pass);
63  content_context.GetRenderTargetCache()->End();
64  content_context.GetTransientsBuffer().Reset();
65  return result;
66  };
67  return Playground::OpenPlaygroundHere(pass_callback);
68 }

References impeller::PlaygroundSwitches::enable_playground, impeller::Playground::GetContext(), impeller::ContentContext::GetRenderTargetCache(), impeller::ContentContext::GetTransientsBuffer(), impeller::ContentContext::IsValid(), impeller::Playground::OpenPlaygroundHere(), impeller::HostBuffer::Reset(), 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: