7 #include <CoreImage/CoreImage.h>
10 #define GLFW_INCLUDE_NONE
11 #include "third_party/glfw/include/GLFW/glfw3.h"
17 FML_CHECK(::glfwInit() == GLFW_TRUE);
28 scale_content ? playground_->GetContentScale() :
Vector2{1, 1};
29 std::shared_ptr<Image> image = picture.
ToImage(
32 std::shared_ptr<Texture> texture = image->GetTexture();
33 id<MTLTexture> metal_texture =
34 std::static_pointer_cast<TextureMTL>(texture)->GetMTLTexture();
36 if (metal_texture.pixelFormat != MTLPixelFormatBGRA8Unorm) {
40 CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
41 CIImage* ciImage = [[CIImage alloc]
42 initWithMTLTexture:metal_texture
43 options:@{kCIImageColorSpace : (__bridge id)color_space}];
44 CGColorSpaceRelease(color_space);
47 std::shared_ptr<Context> context = playground_->GetContext();
48 std::shared_ptr<ContextMTL> context_mtl =
49 std::static_pointer_cast<ContextMTL>(context);
50 CIContext* cicontext =
51 [CIContext contextWithMTLDevice:context_mtl->GetMTLDevice()];
54 CIImage* flipped = [ciImage
55 imageByApplyingOrientation:kCGImagePropertyOrientationDownMirrored];
57 CGImageRef cgImage = [cicontext createCGImage:flipped
58 fromRect:[ciImage extent]];