Flutter Impeller
impeller::PlaygroundImplMTL Class Referencefinal

#include <playground_impl_mtl.h>

Inheritance diagram for impeller::PlaygroundImplMTL:
impeller::PlaygroundImpl

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
 

Additional Inherited Members

- Public Types inherited from impeller::PlaygroundImpl
using WindowHandle = void *
 
- Static Public Member Functions inherited from impeller::PlaygroundImpl
static std::unique_ptr< PlaygroundImplCreate (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 19 of file playground_impl_mtl.h.

Constructor & Destructor Documentation

◆ PlaygroundImplMTL()

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

Definition at line 64 of file playground_impl_mtl.mm.

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

◆ ~PlaygroundImplMTL()

impeller::PlaygroundImplMTL::~PlaygroundImplMTL ( )
default

Member Function Documentation

◆ SetCapabilities()

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

Implements impeller::PlaygroundImpl.

Definition at line 131 of file playground_impl_mtl.mm.

132  {
133  context_->SetCapabilities(capabilities);
134  return fml::Status();
135 }

The documentation for this class was generated from the following files:
impeller::PixelFormat::kB10G10R10A10XR
@ kB10G10R10A10XR
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:225
impeller::ShaderLibraryMappingsForPlayground
static std::vector< std::shared_ptr< fml::Mapping > > ShaderLibraryMappingsForPlayground()
Definition: playground_impl_gles.cc:106
impeller::ToMTLPixelFormat
constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format)
Definition: formats_mtl.h:76
impeller::ContextMTL::GetMTLDevice
id< MTLDevice > GetMTLDevice() const
Definition: context_mtl.mm:354
impeller::BackendCast< ContextMTL, Context >::Cast
static ContextMTL & Cast(Context &base)
Definition: backend_cast.h:13
impeller::interop::Create
ScopedObject< Object > Create(CtorArgs &&... args)
Definition: object.h:160
impeller::PlaygroundImpl::PlaygroundImpl
PlaygroundImpl(PlaygroundSwitches switches)
Definition: playground_impl.cc:55