32 const std::shared_ptr<Context>&
context,
33 const std::shared_ptr<Texture>&
texture) {
36 if (
auto cmd_buffer =
context->CreateCommandBuffer()) {
38 ->Submit({cmd_buffer},
40 FML_CHECK(status == CommandBuffer::Status::kCompleted);
48 id<MTLTexture> metal_texture =
49 std::static_pointer_cast<TextureMTL>(
texture)->GetMTLTexture();
51 CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
52 CIImage* ciImage = [[CIImage alloc]
53 initWithMTLTexture:metal_texture
54 options:@{kCIImageColorSpace : (__bridge
id)color_space}];
55 CGColorSpaceRelease(color_space);
58 std::shared_ptr<ContextMTL> context_mtl =
59 std::static_pointer_cast<ContextMTL>(
context);
60 CIContext* cicontext =
61 [CIContext contextWithMTLDevice:context_mtl->GetMTLDevice()];
64 CIImage* flipped = [ciImage
65 imageByApplyingOrientation:kCGImagePropertyOrientationDownMirrored];
67 CGImageRef cgImage = [cicontext createCGImage:flipped
68 fromRect:[flipped extent]];
std::shared_ptr< Context > GetContext() const