9#define GLFW_INCLUDE_NONE
16using CGContextPtr = std::unique_ptr<std::remove_pointer<CGContextRef>::type,
17 decltype(&CGContextRelease)>;
18using CGImagePtr = std::unique_ptr<std::remove_pointer<CGImageRef>::type,
19 decltype(&CGImageRelease)>;
20using CGColorSpacePtr =
21 std::unique_ptr<std::remove_pointer<CGColorSpaceRef>::type,
22 decltype(&CGColorSpaceRelease)>;
24std::unique_ptr<Screenshot> ReadTexture(
25 const std::shared_ptr<Context>& surface_context,
26 const std::shared_ptr<Texture>&
texture) {
27 DeviceBufferDescriptor buffer_desc;
30 texture->GetTextureDescriptor().GetByteSizeOfBaseMipLevel();
31 buffer_desc.readback =
true;
32 std::shared_ptr<DeviceBuffer> device_buffer =
33 surface_context->GetResourceAllocator()->CreateBuffer(buffer_desc);
38 bool success = blit_pass->AddCopy(
texture, device_buffer);
41 success = blit_pass->EncodeCommands();
46 surface_context->GetCommandQueue()
55 device_buffer->Invalidate();
60 CGColorSpacePtr color_space(CGColorSpaceCreateDeviceRGB(),
61 &CGColorSpaceRelease);
62 CGBitmapInfo bitmap_info =
64 ?
static_cast<uint32_t
>(kCGImageAlphaPremultipliedFirst) |
65 static_cast<uint32_t
>(kCGBitmapByteOrder32Little)
66 : kCGImageAlphaPremultipliedLast;
68 CGBitmapContextCreate(
69 device_buffer->OnGetContents(),
texture->GetSize().width,
72 texture->GetTextureDescriptor().GetBytesPerRow(),
73 color_space.get(), bitmap_info),
76 CGImagePtr
image(CGBitmapContextCreateImage(
context.get()), &CGImageRelease);
79 return std::make_unique<MetalScreenshot>(
image.release());
86 const std::shared_ptr<Context>&
context,
87 const std::shared_ptr<Texture>&
texture) {
91std::unique_ptr<Screenshot> Screenshotter::MakeOpenGLScreenshot(
92 std::shared_ptr<Context>&
context,
93 const std::shared_ptr<Texture>&
texture) {
97std::unique_ptr<Screenshot> Screenshotter::MakeVulkanScreenshot(
98 std::shared_ptr<Context>&
context,
99 const std::shared_ptr<Texture>&
texture) {
105 const std::shared_ptr<Texture>&
texture) {
std::shared_ptr< Context > GetContext() const
static std::unique_ptr< Screenshot > MakeScreenshot(const std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)
FlutterVulkanImage * image
#define FML_CHECK(condition)
std::shared_ptr< ContextGLES > context
std::shared_ptr< CommandBuffer > command_buffer