| 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

## 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 63 of file playground_impl_mtl.mm.

64 : PlaygroundImpl(switches),
65 handle_(nullptr, &DestroyWindowHandle),
66 data_(std::make_unique<Data>()),
67 concurrent_loop_(fml::ConcurrentMessageLoop::Create()),
68 is_gpu_disabled_sync_switch_(new fml::SyncSwitch(false)) {
69 ::glfwDefaultWindowHints();
70 ::glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
71 ::glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
72 auto window = ::glfwCreateWindow(1, 1, "Test", nullptr, nullptr);
73 if (!window) {
74 return;
75 }
76 auto context =
77 ContextMTL::Create(ShaderLibraryMappingsForPlayground(),
78 is_gpu_disabled_sync_switch_, "Playground Library");
79 if (!context) {
80 return;
81 }
82 NSWindow* cocoa_window = ::glfwGetCocoaWindow(window);
83 if (cocoa_window == nil) {
84 return;
85 }
86 data_->metal_layer = [CAMetalLayer layer];
87 data_->metal_layer.device = ContextMTL::Cast(*context).GetMTLDevice();
88 data_->metal_layer.pixelFormat =
89 ToMTLPixelFormat(context->GetCapabilities()->GetDefaultColorFormat());
90 data_->metal_layer.framebufferOnly = NO;
91 cocoa_window.contentView.layer = data_->metal_layer;
92 cocoa_window.contentView.wantsLayer = YES;
93
94 handle_.reset(window);
95 context_ = std::move(context);
96 }

References impeller::BackendCast< ContextMTL, Context >::Cast(), impeller::ContextMTL::Create(), impeller::ContextMTL::GetMTLDevice(), 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 126 of file playground_impl_mtl.mm.

127 {
128 context_->SetCapabilities(capabilities);
129 return fml::Status();
130 }

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

impeller::ContextMTL::Create
static std::shared_ptr< ContextMTL > Create(const std::vector< std::string > &shader_library_paths, std::shared_ptr< const fml::SyncSwitch > is_gpu_disabled_sync_switch)
Definition: context_mtl.mm:236
impeller::ShaderLibraryMappingsForPlayground
static std::vector< std::shared_ptr< fml::Mapping > > ShaderLibraryMappingsForPlayground()
Definition: playground_impl_gles.cc:91
impeller::ToMTLPixelFormat
constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format)
Definition: formats_mtl.h:77
impeller::ContextMTL::GetMTLDevice
id< MTLDevice > GetMTLDevice() const
Definition: context_mtl.mm:371
impeller::BackendCast< ContextMTL, Context >::Cast
static ContextMTL & Cast(Context &base)
Definition: backend_cast.h:15
impeller::PlaygroundImpl::PlaygroundImpl
PlaygroundImpl(PlaygroundSwitches switches)
Definition: playground_impl.cc:48