| Flutter Impeller |

Public Types | Public Member Functions | List of all members
impeller::interop::testing::PlaygroundTest Class Reference

`#include <playground_test.h>`

Inheritance diagram for impeller::interop::testing::PlaygroundTest:

## Public Types
using | InteropPlaygroundCallback = std::function< bool(const ScopedObject< Context > &context, const ScopedObject< Surface > &surface)>
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
| PlaygroundTest ()
| ~PlaygroundTest () override
| PlaygroundTest (const PlaygroundTest &)=delete
PlaygroundTest & | operator= (const PlaygroundTest &)=delete
void | SetUp () override
void | TearDown () override
ScopedObject< Context > | CreateContext () const
ScopedObject< Context > | GetInteropContext ()
bool | OpenPlaygroundHere (InteropPlaygroundCallback callback)
Public Member Functions inherited from impeller::PlaygroundTest
| 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< Context > | GetContext () const
std::shared_ptr< Context > | MakeContext () 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

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

## Detailed Description

Definition at line 16 of file playground_test.h.

## Member Typedef Documentation

## ◆ InteropPlaygroundCallback

using impeller::interop::testing::PlaygroundTest::InteropPlaygroundCallback = std::function<bool(const ScopedObject<Context>& context, const ScopedObject<Surface>& surface)>

Definition at line 39 of file playground_test.h.

## Constructor & Destructor Documentation

## ◆ PlaygroundTest() [1/2]

impeller::interop::testing::PlaygroundTest::PlaygroundTest | ( |  | ) |

Definition at line 15 of file playground_test.cc.

15 {
16 static std::once_flag sOnceFlag;
17 std::call_once(sOnceFlag, []() {
18 std::map<std::string, void*> proc_map;
19 #define IMPELLER_HPP_PROC(name) \
20 proc_map[#name] = reinterpret_cast<void*>(&name);
21 IMPELLER_HPP_EACH_PROC(IMPELLER_HPP_PROC)
22 #undef IMPELLER_HPP_PROC
23 hpp::gGlobalProcTable.Initialize(
24 [&](auto name) { return proc_map.at(name); });
25 });
26 }

References IMPELLER_HPP_NAMESPACE::gGlobalProcTable, IMPELLER_HPP_EACH_PROC, IMPELLER_HPP_PROC, and IMPELLER_HPP_NAMESPACE::ProcTable::Initialize().

## ◆ ~PlaygroundTest()

impeller::interop::testing::PlaygroundTest::~PlaygroundTest | ( |  | ) |
| override virtual default

Reimplemented from impeller::PlaygroundTest.

## ◆ PlaygroundTest() [2/2]

impeller::interop::testing::PlaygroundTest::PlaygroundTest | ( | const PlaygroundTest & |  | ) |
| delete

## Member Function Documentation

## ◆ CreateContext()

ScopedObject< Context > impeller::interop::testing::PlaygroundTest::CreateContext | ( |  | ) | const

Definition at line 40 of file playground_test.cc.

40 {
41 switch (GetBackend()) {
42 case PlaygroundBackend::kMetal:
43 FML_CHECK(false) << "Metal not yet implemented.";
44 return nullptr;
45 case PlaygroundBackend::kOpenGLES: {
46 Playground::GLProcAddressResolver playground_gl_proc_address_callback =
47 CreateGLProcAddressResolver();
48 ImpellerProcAddressCallback gl_proc_address_callback =
49 [](const char* proc_name, void* user_data) -> void* {
50 return (*reinterpret_cast<Playground::GLProcAddressResolver*>(
51 user_data))(proc_name);
52 };
53 return Adopt<Context>(ImpellerContextCreateOpenGLESNew(
54 ImpellerGetVersion(), gl_proc_address_callback,
55 &playground_gl_proc_address_callback));
56 }
57 case PlaygroundBackend::kVulkan:
58 FML_CHECK(false) << "Vulkan not yet implemented.";
59 return nullptr;
60 }
61 FML_UNREACHABLE();
62 }

References impeller::Playground::CreateGLProcAddressResolver(), impeller::PlaygroundTest::GetBackend(), impeller::interop::ImpellerContextCreateOpenGLESNew(), impeller::interop::ImpellerGetVersion(), impeller::kMetal, impeller::kOpenGLES, and impeller::kVulkan.

## ◆ GetInteropContext()

ScopedObject< Context > impeller::interop::testing::PlaygroundTest::GetInteropContext | ( |  | ) |

Definition at line 79 of file playground_test.cc.

79 {
80 if (interop_context_) {
81 return interop_context_;
82 }
83 auto context = Create<Context>(GetContext(), nullptr);
84 if (!context) {
85 return nullptr;
86 }
87 interop_context_ = std::move(context);
88 return interop_context_;
89 }

References impeller::Playground::GetContext().

Referenced by OpenPlaygroundHere().

## ◆ OpenPlaygroundHere()

bool impeller::interop::testing::PlaygroundTest::OpenPlaygroundHere | ( | InteropPlaygroundCallback | callback | ) |

Definition at line 64 of file playground_test.cc.

64 {
65 auto context = GetInteropContext();
66 if (!context) {
67 return false;
68 }
69 return Playground::OpenPlaygroundHere([&](RenderTarget& target) -> bool {
70 auto impeller_surface = std::make_shared<impeller::Surface>(target);
71 auto surface = Create<Surface>(*context.Get(), impeller_surface);
72 if (!surface) {
73 return false;
74 }
75 return callback(context, surface);
76 });
77 }

References GetInteropContext(), and impeller::Playground::OpenPlaygroundHere().

## ◆ operator=()

PlaygroundTest& impeller::interop::testing::PlaygroundTest::operator= | ( | const PlaygroundTest & |  | ) |
| delete

## ◆ SetUp()

void impeller::interop::testing::PlaygroundTest::SetUp | ( |  | ) |
| override

Definition at line 31 of file playground_test.cc.

31 {
32 ::impeller::PlaygroundTest::SetUp();
33 }

References impeller::PlaygroundTest::SetUp().

## ◆ TearDown()

void impeller::interop::testing::PlaygroundTest::TearDown | ( |  | ) |
| override

Definition at line 36 of file playground_test.cc.

36 {
37 ::impeller::PlaygroundTest::TearDown();
38 }

References impeller::PlaygroundTest::TearDown().

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

- impeller/toolkit/interop/playground_test.h
- impeller/toolkit/interop/playground_test.cc

IMPELLER_HPP_NAMESPACE::ProcTable::Initialize
bool Initialize(const std::function< void *(const char *function_name)> &resolver)
Definition: impeller.hpp:183
impeller::PlaygroundBackend::kVulkan
@ kVulkan
IMPELLER_HPP_NAMESPACE::gGlobalProcTable
ProcTable gGlobalProcTable
Definition: playground_test.cc:10
impeller::interop::ImpellerContextCreateOpenGLESNew
IMPELLER_EXTERN_C ImpellerContext ImpellerContextCreateOpenGLESNew(uint32_t version, ImpellerProcAddressCallback gl_proc_address_callback, void *gl_proc_address_callback_user_data)
Definition: impeller.cc:73
impeller::interop::testing::PlaygroundTest::GetInteropContext
ScopedObject< Context > GetInteropContext()
Definition: playground_test.cc:79
impeller::PlaygroundBackend::kMetal
@ kMetal
impeller::interop::ImpellerGetVersion
IMPELLER_EXTERN_C uint32_t ImpellerGetVersion()
Get the version of Impeller standalone API. This is the API that will be accepted for validity checks...
Definition: impeller.cc:68
IMPELLER_HPP_EACH_PROC
#define IMPELLER_HPP_EACH_PROC(PROC)
Definition: impeller.hpp:47
impeller::PlaygroundTest::SetUp
void SetUp() override
Definition: playground_test.cc:45
IMPELLER_HPP_PROC
#define IMPELLER_HPP_PROC(name)
impeller::Playground::OpenPlaygroundHere
bool OpenPlaygroundHere(const RenderCallback &render_callback)
Definition: playground.cc:201
impeller::PlaygroundTest::TearDown
void TearDown() override
Definition: playground_test.cc:76
impeller::Playground::CreateGLProcAddressResolver
GLProcAddressResolver CreateGLProcAddressResolver() const
Definition: playground.cc:519
impeller::PlaygroundBackend::kOpenGLES
@ kOpenGLES
impeller::Playground::GetContext
std::shared_ptr< Context > GetContext() const
Definition: playground.cc:91
ImpellerProcAddressCallback
void *IMPELLER_NULLABLE(* ImpellerProcAddressCallback)(const char *IMPELLER_NONNULL proc_name, void *IMPELLER_NULLABLE user_data)
Definition: impeller.h:310
impeller::Playground::GLProcAddressResolver
std::function< void *(const char *proc_name)> GLProcAddressResolver
Definition: playground.h:118
impeller::PlaygroundTest::GetBackend
PlaygroundBackend GetBackend() const
Definition: playground_test.cc:72