Flutter Impeller
impeller::DlPlayground Class Reference

#include <dl_playground.h>

Inheritance diagram for impeller::DlPlayground:
impeller::PlaygroundTest impeller::Playground

Public Types

using DisplayListPlaygroundCallback = std::function< sk_sp< flutter::DisplayList >()>
 
- 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)>
 

Public Member Functions

 DlPlayground ()
 
 ~DlPlayground ()
 
bool OpenPlaygroundHere (flutter::DisplayListBuilder &builder)
 
bool OpenPlaygroundHere (sk_sp< flutter::DisplayList > list)
 
bool OpenPlaygroundHere (DisplayListPlaygroundCallback callback)
 
std::unique_ptr< testing::ScreenshotMakeScreenshot (const sk_sp< flutter::DisplayList > &list)
 
SkFont CreateTestFontOfSize (SkScalar scalar)
 
SkFont CreateTestFont ()
 
sk_sp< flutter::DlImage > CreateDlImageForFixture (const char *fixture_name, bool enable_mipmapping=false) 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
 

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 dl_playground.h.

Member Typedef Documentation

◆ DisplayListPlaygroundCallback

using impeller::DlPlayground::DisplayListPlaygroundCallback = std::function<sk_sp<flutter::DisplayList>()>

Definition at line 19 of file dl_playground.h.

Constructor & Destructor Documentation

◆ DlPlayground()

impeller::DlPlayground::DlPlayground ( )
default

◆ ~DlPlayground()

impeller::DlPlayground::~DlPlayground ( )
default

Member Function Documentation

◆ CreateDlImageForFixture()

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

Definition at line 83 of file dl_playground.cc.

85  {
86  std::shared_ptr<fml::Mapping> mapping =
87  flutter::testing::OpenFixtureAsMapping(fixture_name);
88  std::shared_ptr<Texture> texture = Playground::CreateTextureForMapping(
89  GetContext(), mapping, enable_mipmapping);
90  if (texture) {
91  texture->SetLabel(fixture_name);
92  }
93  return DlImageImpeller::Make(texture);
94 }

References impeller::Playground::CreateTextureForMapping(), impeller::Playground::GetContext(), and impeller::DlImageImpeller::Make().

◆ CreateTestFont()

SkFont impeller::DlPlayground::CreateTestFont ( )

Definition at line 79 of file dl_playground.cc.

79  {
80  return CreateTestFontOfSize(50);
81 }

References CreateTestFontOfSize().

◆ CreateTestFontOfSize()

SkFont impeller::DlPlayground::CreateTestFontOfSize ( SkScalar  scalar)

Definition at line 71 of file dl_playground.cc.

71  {
72  static constexpr const char* kTestFontFixture = "Roboto-Regular.ttf";
73  auto mapping = flutter::testing::OpenFixtureAsSkData(kTestFontFixture);
74  FML_CHECK(mapping);
75  sk_sp<SkFontMgr> font_mgr = txt::GetDefaultFontManager();
76  return SkFont{font_mgr->makeFromData(mapping), scalar};
77 }

Referenced by CreateTestFont().

◆ MakeScreenshot()

std::unique_ptr< testing::Screenshot > impeller::DlPlayground::MakeScreenshot ( const sk_sp< flutter::DisplayList > &  list)

Definition at line 66 of file dl_playground.cc.

67  {
68  return nullptr;
69 }

◆ OpenPlaygroundHere() [1/3]

bool impeller::DlPlayground::OpenPlaygroundHere ( DisplayListPlaygroundCallback  callback)

Definition at line 32 of file dl_playground.cc.

32  {
34  return true;
35  }
36 
37  AiksContext context(GetContext(), TypographerContextSkia::Make());
38  if (!context.IsValid()) {
39  return false;
40  }
42  [&context, &callback](RenderTarget& render_target) -> bool {
43  static bool wireframe = false;
44  if (ImGui::IsKeyPressed(ImGuiKey_Z)) {
45  wireframe = !wireframe;
46  context.GetContentContext().SetWireframe(wireframe);
47  }
48 
49  auto list = callback();
50  TextFrameDispatcher collector(context.GetContentContext(), Matrix(),
52  list->Dispatch(collector);
53 
54  CanvasDlDispatcher impeller_dispatcher(
55  context.GetContentContext(), render_target,
56  list->root_has_backdrop_filter(), list->max_root_blend_mode(),
58  list->Dispatch(impeller_dispatcher);
59  impeller_dispatcher.FinishRecording();
60  context.GetContentContext().GetTransientsBuffer().Reset();
61  context.GetContentContext().GetLazyGlyphAtlas()->ResetTextFrames();
62  return true;
63  });
64 }

References impeller::PlaygroundSwitches::enable_playground, impeller::CanvasDlDispatcher::FinishRecording(), impeller::AiksContext::GetContentContext(), impeller::Playground::GetContext(), impeller::ContentContext::GetLazyGlyphAtlas(), impeller::ContentContext::GetTransientsBuffer(), impeller::AiksContext::IsValid(), impeller::TypographerContextSkia::Make(), impeller::TRect< Scalar >::MakeMaximum(), impeller::TRect< T >::MakeMaximum(), impeller::Playground::OpenPlaygroundHere(), impeller::HostBuffer::Reset(), and impeller::Playground::switches_.

◆ OpenPlaygroundHere() [2/3]

bool impeller::DlPlayground::OpenPlaygroundHere ( flutter::DisplayListBuilder &  builder)

Definition at line 24 of file dl_playground.cc.

24  {
25  return OpenPlaygroundHere(builder.Build());
26 }

References OpenPlaygroundHere().

Referenced by OpenPlaygroundHere().

◆ OpenPlaygroundHere() [3/3]

bool impeller::DlPlayground::OpenPlaygroundHere ( sk_sp< flutter::DisplayList >  list)

Definition at line 28 of file dl_playground.cc.

28  {
29  return OpenPlaygroundHere([&list]() { return list; });
30 }

References OpenPlaygroundHere().


The documentation for this class was generated from the following files:
impeller::DlPlayground::OpenPlaygroundHere
bool OpenPlaygroundHere(flutter::DisplayListBuilder &builder)
Definition: dl_playground.cc:24
impeller::DlImageImpeller::Make
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
Definition: dl_image_impeller.cc:23
impeller::Playground::OpenPlaygroundHere
bool OpenPlaygroundHere(const RenderCallback &render_callback)
Definition: playground.cc:197
impeller::DlPlayground::CreateTestFontOfSize
SkFont CreateTestFontOfSize(SkScalar scalar)
Definition: dl_playground.cc:71
impeller::Playground::switches_
const PlaygroundSwitches switches_
Definition: playground.h:121
impeller::Playground::CreateTextureForMapping
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:429
impeller::TRect< Scalar >::MakeMaximum
constexpr static TRect MakeMaximum()
Definition: rect.h:178
impeller::Playground::GetContext
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:90
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:75