24 const std::shared_ptr<Texture>
texture) {
26 std::shared_ptr<Context> context = aiks_context.
GetContext();
28 if (
auto cmd_buffer = context->CreateCommandBuffer()) {
29 if (context->GetCommandQueue()
30 ->Submit({cmd_buffer},
32 FML_CHECK(status == CommandBuffer::Status::kCompleted);
40 id<MTLTexture> metal_texture =
41 std::static_pointer_cast<TextureMTL>(
texture)->GetMTLTexture();
43 CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
44 CIImage* ciImage = [[CIImage alloc]
45 initWithMTLTexture:metal_texture
46 options:@{kCIImageColorSpace : (__bridge
id)color_space}];
47 CGColorSpaceRelease(color_space);
50 std::shared_ptr<ContextMTL> context_mtl =
51 std::static_pointer_cast<ContextMTL>(context);
52 CIContext* cicontext =
53 [CIContext contextWithMTLDevice:context_mtl->GetMTLDevice()];
56 CIImage* flipped = [ciImage
57 imageByApplyingOrientation:kCGImagePropertyOrientationDownMirrored];
59 CGImageRef cgImage = [cicontext createCGImage:flipped
60 fromRect:[flipped extent]];
std::shared_ptr< Context > GetContext() const