5#include "flutter/impeller/golden_tests/vulkan_screenshotter.h"
7#include "flutter/fml/synchronization/waitable_event.h"
8#include "flutter/impeller/golden_tests/metal_screenshot.h"
9#define GLFW_INCLUDE_NONE
10#include "third_party/glfw/include/GLFW/glfw3.h"
18 decltype(&CGContextRelease)>;
20 decltype(&CGImageRelease)>;
21using CGColorSpacePtr =
23 decltype(&CGColorSpaceRelease)>;
25std::unique_ptr<Screenshot> ReadTexture(
26 const std::shared_ptr<Context>& surface_context,
27 const std::shared_ptr<Texture>&
texture) {
28 DeviceBufferDescriptor buffer_desc;
31 texture->GetTextureDescriptor().GetByteSizeOfBaseMipLevel();
32 buffer_desc.readback =
true;
33 std::shared_ptr<DeviceBuffer> device_buffer =
34 surface_context->GetResourceAllocator()->CreateBuffer(buffer_desc);
37 auto command_buffer = surface_context->CreateCommandBuffer();
38 auto blit_pass = command_buffer->CreateBlitPass();
39 bool success = blit_pass->AddCopy(
texture, device_buffer);
42 success = blit_pass->EncodeCommands(surface_context->GetResourceAllocator());
47 surface_context->GetCommandQueue()
48 ->Submit({command_buffer},
56 device_buffer->Invalidate();
61 CGColorSpacePtr color_space(CGColorSpaceCreateDeviceRGB(),
62 &CGColorSpaceRelease);
63 CGBitmapInfo bitmap_info =
65 ? kCGImageAlphaPremultipliedFirst | 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);
81 if (
texture->GetYCoordScale() == -1) {
82 CGContextPtr flipped_context(
83 CGBitmapContextCreate(
86 0, color_space.get(), bitmap_info),
88 CGContextTranslateCTM(flipped_context.get(), 0,
texture->GetSize().height);
89 CGContextScaleCTM(flipped_context.get(), 1.0, -1.0);
91 flipped_context.get(),
92 CGRectMake(0, 0,
texture->GetSize().width,
texture->GetSize().height),
94 CGImagePtr flipped_image(CGBitmapContextCreateImage(flipped_context.get()),
99 return std::make_unique<MetalScreenshot>(
image.
release());
104 const std::unique_ptr<PlaygroundImpl>& playground)
105 : playground_(playground) {
113 bool scale_content) {
115 scale_content ? playground_->GetContentScale() :
Vector2{1, 1};
static bool ok(int result)
std::shared_ptr< Context > GetContext() const
VulkanScreenshotter(const std::unique_ptr< PlaygroundImpl > &playground)
std::unique_ptr< Screenshot > MakeScreenshot(AiksContext &aiks_context, const Picture &picture, const ISize &size={300, 300}, bool scale_content=true) override
void swap(sk_sp< T > &that)
#define FML_CHECK(condition)
sk_sp< const SkImage > image
sk_sp< const SkPicture > picture
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size