Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::DlPlayground Class Reference

#include <dl_playground.h>

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

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::ScreenshotMakeScreenshot (const sk_sp< flutter::DisplayList > &list)
 
SkFont CreateTestFontOfSize (Scalar scalar)
 
SkFont CreateTestFont ()
 
sk_sp< flutter::DlImageCreateDlImageForFixture (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::MappingOpenAssetAsMapping (std::string asset_name) const override
 
absl::StatusOr< RuntimeStage::MapOpenAssetAsRuntimeStage (const char *asset_name) const
 
std::string GetWindowTitle () const override
 
testing::GoldenDigestManagerGetGoldenDigestManager () 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.
 
std::shared_ptr< ContextGetContext () const
 
std::shared_ptr< ContextMakeContext () const
 
ContentContextGetContentContext () const
 
std::shared_ptr< TypographerContextGetTypographerContext () const
 
bool ShouldWriteGoldenImage ()
 Whether this instance will write a golden image of the output from |OpenPlaygroundHere|.
 
void SetEnableWriteGolden (bool write_golden)
 Sets a particular test to either write a golden or not, false by default.
 
bool OpenPlaygroundHere (const RenderCallback &render_callback)
 
bool OpenPlaygroundHere (const 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)
 
GLProcAddressResolver CreateGLProcAddressResolver () const
 
VKProcAddressResolver CreateVKProcAddressResolver () const
 
void SetGPUDisabled (bool disabled) const
 Mark the GPU as unavilable.
 
RuntimeStageBackend GetRuntimeStageBackend () const
 
bool InitializePipelineDescriptorForRendering (PipelineDescriptor &desc) const
 Initializes the provided |PipelineDescriptor| with appropriate default values to match the conditions under which a pipeline will be rendered.
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::PlaygroundTest
static void SetupTestEnvironment ()
 
- Static Public Member Functions inherited from impeller::Playground
static void OnTearDownTestEnvironment ()
 
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::PlaygroundTest
virtual bool IsGoldenTestSuite () const
 This method is overridden on a test suite basis and establishes whether a given set of tests is intended to generate goldens.
 
- 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.
 
bool PlatformSupportsWideGamutTests () const
 Returns true if the platform can support wide gamuts.
 
bool RenderingSupportsMSAA () const
 Returns true if the rendering path supports MSAA rendering.
 
SampleCount GetDefaultSampleCount () const
 Returns the default sample count of the rendering path.
 
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.
 
const PlaygroundSwitchesGetSwitches () 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.
 
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

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

79 {
80 std::shared_ptr<fml::Mapping> mapping =
82 std::shared_ptr<Texture> texture = Playground::CreateTextureForMapping(
83 GetContext(), mapping, enable_mipmapping);
84 if (texture) {
85 texture->SetLabel(fixture_name);
86 }
88}
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
std::shared_ptr< Context > GetContext() const
static std::shared_ptr< Texture > CreateTextureForMapping(const std::shared_ptr< Context > &context, std::shared_ptr< fml::Mapping > mapping, bool enable_mipmapping=false)
FlTexture * texture
std::unique_ptr< fml::Mapping > OpenFixtureAsMapping(const std::string &fixture_name)
Opens a fixture of the given file name and returns a mapping to its contents.
Definition testing.cc:58

References impeller::Playground::CreateTextureForMapping(), impeller::Playground::GetContext(), impeller::DlImageImpeller::Make(), flutter::testing::OpenFixtureAsMapping(), and texture.

◆ CreateTestFont()

SkFont impeller::DlPlayground::CreateTestFont ( )

Definition at line 73 of file dl_playground.cc.

73 {
74 return CreateTestFontOfSize(50);
75}
SkFont CreateTestFontOfSize(Scalar scalar)

References CreateTestFontOfSize().

◆ CreateTestFontOfSize()

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

Definition at line 65 of file dl_playground.cc.

65 {
66 static constexpr const char* kTestFontFixture = "Roboto-Regular.ttf";
67 auto mapping = flutter::testing::OpenFixtureAsSkData(kTestFontFixture);
68 FML_CHECK(mapping);
69 sk_sp<SkFontMgr> font_mgr = txt::GetDefaultFontManager();
70 return SkFont{font_mgr->makeFromData(mapping), scalar};
71}
#define FML_CHECK(condition)
Definition logging.h:104
sk_sp< SkData > OpenFixtureAsSkData(const std::string &fixture_name)
Opens a fixture of the given file name and returns a Skia SkData holding its contents.
Definition testing.cc:63
sk_sp< SkFontMgr > GetDefaultFontManager(uint32_t font_initialization_data)
Definition platform.cc:17

References FML_CHECK, txt::GetDefaultFontManager(), and flutter::testing::OpenFixtureAsSkData().

Referenced by CreateTestFont().

◆ MakeScreenshot()

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

Definition at line 52 of file dl_playground.cc.

53 {
54 std::shared_ptr<Context> context = GetContext();
55 AiksContext renderer(context, GetTypographerContext());
56 Point content_scale = GetContentScale();
57
58 ISize physical_window_size(
59 std::round(GetWindowSize().width * content_scale.x),
60 std::round(GetWindowSize().height * content_scale.y));
62 context, DisplayListToTexture(list, physical_window_size, renderer));
63}
ISize GetWindowSize() const
std::shared_ptr< TypographerContext > GetTypographerContext() const
Point GetContentScale() const
static std::unique_ptr< Screenshot > MakeScreenshot(std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)
std::shared_ptr< Texture > DisplayListToTexture(const sk_sp< flutter::DisplayList > &display_list, ISize size, AiksContext &context, bool reset_host_buffer, bool generate_mips, std::optional< PixelFormat > target_pixel_format)
Render the provided display list to a texture with the given size.
TPoint< Scalar > Point
Definition point.h:426
ISize64 ISize
Definition size.h:162
std::shared_ptr< ContextGLES > context
int32_t height
int32_t width

References context, impeller::DisplayListToTexture(), impeller::Playground::GetContentScale(), impeller::Playground::GetContext(), impeller::Playground::GetTypographerContext(), impeller::Playground::GetWindowSize(), height, impeller::testing::Screenshotter::MakeScreenshot(), width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ OpenPlaygroundHere() [1/3]

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

Definition at line 33 of file dl_playground.cc.

33 {
35 if (!context.IsValid()) {
36 return false;
37 }
39 [&context, &callback](RenderTarget& render_target) -> bool {
40 return RenderToTarget(
41 context.GetContentContext(), //
42 render_target, //
43 callback(), //
44 Rect::MakeWH(render_target.GetRenderTargetSize().width,
45 render_target.GetRenderTargetSize().height), //
46 /*reset_host_buffer=*/true, //
47 /*is_onscreen=*/false //
48 );
49 });
50}
bool OpenPlaygroundHere(const RenderCallback &render_callback)
static std::shared_ptr< TypographerContext > Make()
FlutterDesktopBinaryReply callback
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.
static constexpr TRect MakeWH(Type width, Type height)
Definition rect.h:140

References callback, context, impeller::Playground::GetContext(), impeller::RenderTarget::GetRenderTargetSize(), impeller::TSize< T >::height, 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 25 of file dl_playground.cc.

25 {
26 return OpenPlaygroundHere(builder.Build());
27}
sk_sp< DisplayList > Build()
bool OpenPlaygroundHere(flutter::DisplayListBuilder &builder)

References flutter::DisplayListBuilder::Build(), and OpenPlaygroundHere().

Referenced by OpenPlaygroundHere(), and OpenPlaygroundHere().

◆ OpenPlaygroundHere() [3/3]

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

Definition at line 29 of file dl_playground.cc.

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

References OpenPlaygroundHere().


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