Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::testing::MetalScreenshotter Class Reference

#include <metal_screenshotter.h>

Inheritance diagram for impeller::testing::MetalScreenshotter:
impeller::testing::Screenshotter

Public Member Functions

 MetalScreenshotter (const PlaygroundSwitches &switches)
 
std::unique_ptr< ScreenshotMakeScreenshot (const AiksContext &aiks_context, const std::shared_ptr< Texture > texture) override
 
PlaygroundImplGetPlayground () override
 
- Public Member Functions inherited from impeller::testing::Screenshotter
virtual ~Screenshotter ()=default
 

Detailed Description

Converts Pictures and DisplayLists to MetalScreenshots with the playground backend.

Definition at line 18 of file metal_screenshotter.h.

Constructor & Destructor Documentation

◆ MetalScreenshotter()

impeller::testing::MetalScreenshotter::MetalScreenshotter ( const PlaygroundSwitches switches)
explicit

Definition at line 17 of file metal_screenshotter.mm.

17 {
18 FML_CHECK(::glfwInit() == GLFW_TRUE);
20}
static std::unique_ptr< PlaygroundImpl > Create(PlaygroundBackend backend, PlaygroundSwitches switches)
#define GLFW_TRUE
#define FML_CHECK(condition)
Definition logging.h:104

References impeller::PlaygroundImpl::Create(), FML_CHECK, GLFW_TRUE, and impeller::kMetal.

Member Function Documentation

◆ GetPlayground()

PlaygroundImpl & impeller::testing::MetalScreenshotter::GetPlayground ( )
inlineoverridevirtual

Implements impeller::testing::Screenshotter.

Definition at line 26 of file metal_screenshotter.h.

26{ return *playground_; }

◆ MakeScreenshot()

std::unique_ptr< Screenshot > impeller::testing::MetalScreenshotter::MakeScreenshot ( const AiksContext aiks_context,
const std::shared_ptr< Texture texture 
)
overridevirtual

Implements impeller::testing::Screenshotter.

Definition at line 22 of file metal_screenshotter.mm.

24 {
25 @autoreleasepool {
26 std::shared_ptr<Context> context = aiks_context.GetContext();
28 if (auto cmd_buffer = context->CreateCommandBuffer()) {
29 if (context->GetCommandQueue()
30 ->Submit({cmd_buffer},
31 [&latch](CommandBuffer::Status status) {
32 FML_CHECK(status == CommandBuffer::Status::kCompleted);
33 latch.Signal();
34 })
35 .ok()) {
36 latch.Wait();
37 }
38 }
39
40 id<MTLTexture> metal_texture =
41 std::static_pointer_cast<TextureMTL>(texture)->GetMTLTexture();
42
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);
48 FML_CHECK(ciImage);
49
50 std::shared_ptr<ContextMTL> context_mtl =
51 std::static_pointer_cast<ContextMTL>(context);
52 CIContext* cicontext =
53 [CIContext contextWithMTLDevice:context_mtl->GetMTLDevice()];
54 FML_CHECK(context);
55
56 CIImage* flipped = [ciImage
57 imageByApplyingOrientation:kCGImagePropertyOrientationDownMirrored];
58
59 CGImageRef cgImage = [cicontext createCGImage:flipped
60 fromRect:[flipped extent]];
61
62 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
63 return std::unique_ptr<MetalScreenshot>(new MetalScreenshot(cgImage));
64 }
65}
FlTexture * texture
const uintptr_t id

References FML_CHECK, impeller::AiksContext::GetContext(), id, texture, and fml::AutoResetWaitableEvent::Wait().

Referenced by flutter::testing::DlSurfaceInstanceImpeller::SnapshotToPixelData().


The documentation for this class was generated from the following files: