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)>
 
using VKProcAddressResolver = std::function< void *(void *instance, 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::Screenshot > MakeScreenshot (const sk_sp< flutter::DisplayList > &list)
 
SkFont CreateTestFontOfSize (Scalar 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
 
absl::StatusOr< RuntimeStage::Map > OpenAssetAsRuntimeStage (const char *asset_name) const
 
std::string GetWindowTitle () const override
 
- Public Member Functions inherited from impeller::Playground
 Playground (PlaygroundBackend backend, const PlaygroundSwitches &switches)
 
virtual ~Playground ()
 
bool IsPlaygroundEnabled () const
 
Point GetCursorPosition () const
 
ISize GetWindowSize () const
 
IRect GetWindowBounds () 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< Context > GetContext () const
 
std::shared_ptr< Context > MakeContext () const
 
ContentContext & GetContentContext () const
 
std::shared_ptr< TypographerContext > GetTypographerContext () const
 
bool OpenPlaygroundHere (const RenderCallback &render_callback)
 
bool OpenPlaygroundHere (SinglePassCallback pass_callback)
 
std::shared_ptr< Texture > CreateTextureForFixture (const char *fixture_name, bool enable_mipmapping=false) const
 
std::shared_ptr< Texture > CreateTextureCubeForFixture (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...
 
RuntimeStageBackend GetRuntimeStageBackend () const
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::Playground
static bool ShouldOpenNewPlaygrounds ()
 
static std::shared_ptr< CompressedImage > LoadFixtureImageCompressed (std::shared_ptr< fml::Mapping > mapping)
 
static std::optional< DecompressedImage > DecodeImageRGBA (const std::shared_ptr< CompressedImage > &compressed)
 
static std::shared_ptr< Texture > CreateTextureForMapping (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 TearDownContextData ()
 
virtual void EnsureContextIsUnique ()
 Make sure that when the context is later created that it will not be shared with any other playgrounds. More...
 
bool PlatformSupportsWideGamutTests () const
 Returns true if the platform can support wide gamuts. More...
 
virtual bool EnsureContextSupportsWideGamut ()
 Make sure that when the context is later created that it will support wide gamuts if the platform supports it. Returns whether the platform supports wide gamut. More...
 
virtual void EnsureContextSupportsAntialiasLines ()
 Make sure that when the context is later created that it will support the experimental AA lines flag. More...
 
const PlaygroundSwitches & GetSwitches () const
 Return an unmodifiable reference to the current switches. The switches might change at the start of a test as it has a brief opportunity to call any of the Ensure* methods that define the environment it expects, but should be stable by the time any subsequent methods that might perform work are called. More...
 
void SetTypographerContext (std::shared_ptr< TypographerContext > typographer_context)
 
void SetWindowSize (ISize size)
 

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 18 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 72 of file dl_playground.cc.

74  {
75  std::shared_ptr<fml::Mapping> mapping =
76  flutter::testing::OpenFixtureAsMapping(fixture_name);
77  std::shared_ptr<Texture> texture = Playground::CreateTextureForMapping(
78  GetContext(), mapping, enable_mipmapping);
79  if (texture) {
80  texture->SetLabel(fixture_name);
81  }
82  return DlImageImpeller::Make(texture);
83 }
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:126
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:522

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

◆ CreateTestFont()

SkFont impeller::DlPlayground::CreateTestFont ( )

Definition at line 68 of file dl_playground.cc.

68  {
69  return CreateTestFontOfSize(50);
70 }
SkFont CreateTestFontOfSize(Scalar scalar)

References CreateTestFontOfSize().

◆ CreateTestFontOfSize()

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

Definition at line 60 of file dl_playground.cc.

60  {
61  static constexpr const char* kTestFontFixture = "Roboto-Regular.ttf";
62  auto mapping = flutter::testing::OpenFixtureAsSkData(kTestFontFixture);
63  FML_CHECK(mapping);
64  sk_sp<SkFontMgr> font_mgr = txt::GetDefaultFontManager();
65  return SkFont{font_mgr->makeFromData(mapping), scalar};
66 }

Referenced by CreateTestFont().

◆ MakeScreenshot()

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

Definition at line 55 of file dl_playground.cc.

56  {
57  return nullptr;
58 }

◆ OpenPlaygroundHere() [1/3]

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

Definition at line 32 of file dl_playground.cc.

32  {
33  if (!IsPlaygroundEnabled()) {
34  return true;
35  }
36 
38  if (!context.IsValid()) {
39  return false;
40  }
42  [&context, &callback](RenderTarget& render_target) -> bool {
43  return RenderToTarget(
44  context.GetContentContext(), //
45  render_target, //
46  callback(), //
47  Rect::MakeWH(render_target.GetRenderTargetSize().width,
48  render_target.GetRenderTargetSize().height), //
49  /*reset_host_buffer=*/true, //
50  /*is_onscreen=*/false //
51  );
52  });
53 }
bool OpenPlaygroundHere(const RenderCallback &render_callback)
Definition: playground.cc:287
bool IsPlaygroundEnabled() const
Definition: playground.cc:224
static std::shared_ptr< TypographerContext > Make()
bool RenderToTarget(ContentContext &context, RenderTarget render_target, const sk_sp< flutter::DisplayList > &display_list, Rect cull_rect, bool reset_host_buffer, bool is_onscreen)
Render the provided display list to the render target.
std::shared_ptr< ContextGLES > context
constexpr static TRect MakeWH(Type width, Type height)
Definition: rect.h:140

References context, impeller::Playground::GetContext(), impeller::RenderTarget::GetRenderTargetSize(), impeller::TSize< T >::height, impeller::Playground::IsPlaygroundEnabled(), impeller::TypographerContextSkia::Make(), impeller::TRect< Scalar >::MakeWH(), impeller::Playground::OpenPlaygroundHere(), impeller::RenderToTarget(), and impeller::TSize< T >::width.

◆ 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 }
bool OpenPlaygroundHere(flutter::DisplayListBuilder &builder)

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: