| Flutter Impeller |

Classes | Public Member Functions | List of all members
impeller::PlaygroundImplMTL Class Referencefinal

`#include <playground_impl_mtl.h>`

Inheritance diagram for impeller::PlaygroundImplMTL:

## Classes
struct | Data

## Public Member Functions
| PlaygroundImplMTL (PlaygroundSwitches switches)
| ~PlaygroundImplMTL ()
fml::Status | SetCapabilities (const std::shared_ptr< Capabilities > &capabilities) override
Public Member Functions inherited from impeller::PlaygroundImpl
virtual | ~PlaygroundImpl ()
Vector2 | GetContentScale () const
virtual Playground::GLProcAddressResolver | CreateGLProcAddressResolver () const
virtual Playground::VKProcAddressResolver | CreateVKProcAddressResolver () const

## Additional Inherited Members
Public Types inherited from impeller::PlaygroundImpl
using | WindowHandle = void *
Static Public Member Functions inherited from impeller::PlaygroundImpl
static std::unique_ptr< PlaygroundImpl > | Create (PlaygroundBackend backend, PlaygroundSwitches switches)
Protected Member Functions inherited from impeller::PlaygroundImpl
| PlaygroundImpl (PlaygroundSwitches switches)
Protected Attributes inherited from impeller::PlaygroundImpl
const PlaygroundSwitches | switches_

## Detailed Description

Definition at line 20 of file playground_impl_mtl.h.

## Constructor & Destructor Documentation

## ◆ PlaygroundImplMTL()

impeller::PlaygroundImplMTL::PlaygroundImplMTL | ( | PlaygroundSwitches | switches | ) |
| explicit

Definition at line 65 of file playground_impl_mtl.mm.

66 : PlaygroundImpl(switches),
67 handle_(nullptr, &DestroyWindowHandle),
68 data_(std::make_unique<Data>()),
69 concurrent_loop_(fml::ConcurrentMessageLoop::Create()),
70 is_gpu_disabled_sync_switch_(new fml::SyncSwitch(false)) {
71 ::glfwDefaultWindowHints();
72 ::glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
73 ::glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
74 auto window = ::glfwCreateWindow(1, 1, "Test", nullptr, nullptr);
75 if (!window) {
76 return;
77 }
78
79 std::optional<PixelFormat> wide_gamut_format = std::nullopt;
80 if (switches.enable_wide_gamut) {
81 wide_gamut_format = PixelFormat::kB10G10R10A10XR;
82 }
83 auto context = ContextMTL::Create(
84 switches.flags, ShaderLibraryMappingsForPlayground(),
85 is_gpu_disabled_sync_switch_, "Playground Library", wide_gamut_format);
86 if (!context) {
87 return;
88 }
89 NSWindow* cocoa_window = ::glfwGetCocoaWindow(window);
90 if (cocoa_window == nil) {
91 return;
92 }
93 data_->metal_layer = [CAMetalLayer layer];
94 data_->metal_layer.device = ContextMTL::Cast(*context).GetMTLDevice();
95 data_->metal_layer.pixelFormat =
96 ToMTLPixelFormat(context->GetCapabilities()->GetDefaultColorFormat());
97 data_->metal_layer.framebufferOnly = NO;
98 cocoa_window.contentView.layer = data_->metal_layer;
99 cocoa_window.contentView.wantsLayer = YES;
100
101 handle_.reset(window);
102 context_ = std::move(context);
103 swapchain_transients_ = std::make_shared<SwapchainTransientsMTL>(
104 context_->GetResourceAllocator());
105 }
impeller::BackendCast< ContextMTL, Context >::Cast
static ContextMTL & Cast(Context &base)
Definition: backend_cast.h:13
impeller::ContextMTL::Create
static std::shared_ptr< ContextMTL > Create(const Flags &flags, const std::vector< std::string > &shader_library_paths, std::shared_ptr< const fml::SyncSwitch > is_gpu_disabled_sync_switch)
Definition: context_mtl.mm:232
impeller::ContextMTL::GetMTLDevice
id< MTLDevice > GetMTLDevice() const
Definition: context_mtl.mm:364
impeller::PlaygroundImpl::PlaygroundImpl
PlaygroundImpl(PlaygroundSwitches switches)
Definition: playground_impl.cc:55
impeller::interop::Create
ScopedObject< Object > Create(CtorArgs &&... args)
Definition: object.h:161
impeller::PixelFormat::kB10G10R10A10XR
@ kB10G10R10A10XR
impeller::ShaderLibraryMappingsForPlayground
static std::vector< std::shared_ptr< fml::Mapping > > ShaderLibraryMappingsForPlayground()
Definition: playground_impl_gles.cc:114
impeller::ToMTLPixelFormat
constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format)
Definition: formats_mtl.h:76

References impeller::BackendCast< ContextMTL, Context >::Cast(), impeller::ContextMTL::Create(), impeller::PlaygroundSwitches::enable_wide_gamut, impeller::PlaygroundSwitches::flags, impeller::ContextMTL::GetMTLDevice(), impeller::kB10G10R10A10XR, impeller::ShaderLibraryMappingsForPlayground(), and impeller::ToMTLPixelFormat().

## ◆ ~PlaygroundImplMTL()

impeller::PlaygroundImplMTL::~PlaygroundImplMTL | ( |  | ) |
| default

## Member Function Documentation

## ◆ SetCapabilities()

fml::Status impeller::PlaygroundImplMTL::SetCapabilities | ( | const std::shared_ptr< Capabilities > & | capabilities | ) |
| override virtual

Implements impeller::PlaygroundImpl.

Definition at line 136 of file playground_impl_mtl.mm.

137 {
138 context_->SetCapabilities(capabilities);
139 return fml::Status();
140 }

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

- impeller/playground/backend/metal/playground_impl_mtl.h
- impeller/playground/backend/metal/playground_impl_mtl.mm