23 const std::shared_ptr<Texture>
texture) {
25 id<MTLTexture> metal_texture =
26 std::static_pointer_cast<TextureMTL>(
texture)->GetMTLTexture();
28 CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
29 CIImage* ciImage = [[CIImage alloc]
30 initWithMTLTexture:metal_texture
31 options:@{kCIImageColorSpace : (__bridge
id)color_space}];
32 CGColorSpaceRelease(color_space);
35 std::shared_ptr<Context> context = playground_->GetContext();
36 std::shared_ptr<ContextMTL> context_mtl =
37 std::static_pointer_cast<ContextMTL>(context);
38 CIContext* cicontext =
39 [CIContext contextWithMTLDevice:context_mtl->GetMTLDevice()];
42 CIImage* flipped = [ciImage
43 imageByApplyingOrientation:kCGImagePropertyOrientationDownMirrored];
45 CGImageRef cgImage = [cicontext createCGImage:flipped
46 fromRect:[flipped extent]];