7 #include <CoreImage/CoreImage.h>
10 #define GLFW_INCLUDE_NONE
11 #include "flutter/fml/synchronization/waitable_event.h"
12 #include "third_party/glfw/include/GLFW/glfw3.h"
18 FML_CHECK(::glfwInit() == GLFW_TRUE);
24 const std::shared_ptr<Texture> texture) {
26 std::shared_ptr<Context> context = aiks_context.
GetContext();
27 fml::AutoResetWaitableEvent latch;
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
static std::unique_ptr< PlaygroundImpl > Create(PlaygroundBackend backend, PlaygroundSwitches switches)