11#import <Metal/Metal.h>
12#import <UIKit/UIKit.h>
23 return [CAMetalLayer class];
33 ~GraphiteMetalWindowContext_ios()
override;
35 bool onInitializeContext()
override;
36 void onDestroyContext()
override;
38 void resize(
int w,
int h)
override;
42 UIViewController* fViewController;
46GraphiteMetalWindowContext_ios::GraphiteMetalWindowContext_ios(
const IOSWindowInfo&
info,
49 , fWindow(
info.fWindow)
50 , fViewController(
info.fViewController) {
54 this->initializeContext();
57GraphiteMetalWindowContext_ios::~GraphiteMetalWindowContext_ios() {
58 this->destroyContext();
59 [fMetalView removeFromSuperview];
63bool GraphiteMetalWindowContext_ios::onInitializeContext() {
67 CGRect frameRect = [fViewController.view frame];
68 fMetalView = [[[
GraphiteMetalView alloc] initWithFrame:frameRect] initWithWindow:fWindow];
69 [fViewController.view addSubview:fMetalView];
71 fMetalLayer = (CAMetalLayer*)fMetalView.layer;
72 fMetalLayer.device = fDevice.get();
73 fMetalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm;
74 fMetalLayer.drawableSize = frameRect.size;
75 fMetalLayer.frame = frameRect;
76 fMetalLayer.framebufferOnly =
false;
78 fMetalLayer.contentsGravity = kCAGravityTopLeft;
80 fWidth = frameRect.size.width;
81 fHeight = frameRect.size.height;
86void GraphiteMetalWindowContext_ios::onDestroyContext() {}
88void GraphiteMetalWindowContext_ios::resize(
int w,
int h) {
89 fMetalLayer.drawableSize = fMetalView.frame.size;
90 fMetalLayer.frame = fMetalView.frame;
101 std::unique_ptr<WindowContext> ctx(
new GraphiteMetalWindowContext_ios(
info,
params));
102 if (!ctx->isValid()) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
const EmbeddedViewParams * params
std::unique_ptr< WindowContext > MakeGraphiteMetalForIOS(const IOSWindowInfo &info, const DisplayParams ¶ms)