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 ()
 
std::unique_ptr< ScreenshotMakeScreenshot (const AiksContext &aiks_context, const std::shared_ptr< Texture > &texture) override
 
- Public Member Functions inherited from impeller::testing::Screenshotter
virtual ~Screenshotter ()=default
 

Static Public Member Functions

static std::unique_ptr< ScreenshotMakeScreenshot (const std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)
 
- Static Public Member Functions inherited from impeller::testing::Screenshotter
static std::unique_ptr< ScreenshotMakeScreenshot (std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)
 

Detailed Description

Converts Pictures and DisplayLists to MetalScreenshots with the playground backend.

Definition at line 16 of file metal_screenshotter.h.

Constructor & Destructor Documentation

◆ MetalScreenshotter()

impeller::testing::MetalScreenshotter::MetalScreenshotter ( )
explicit

Definition at line 17 of file metal_screenshotter.mm.

17{}

Member Function Documentation

◆ MakeScreenshot() [1/2]

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 19 of file metal_screenshotter.mm.

21 {
22 return MakeScreenshot(aiks_context.GetContext(), texture);
23}
static std::unique_ptr< Screenshot > MakeScreenshot(const std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)
FlTexture * texture

References impeller::AiksContext::GetContext(), MakeScreenshot(), and texture.

◆ MakeScreenshot() [2/2]

std::unique_ptr< Screenshot > impeller::testing::MetalScreenshotter::MakeScreenshot ( const std::shared_ptr< Context > &  context,
const std::shared_ptr< Texture > &  texture 
)
static

Definition at line 31 of file metal_screenshotter.mm.

33 {
34 @autoreleasepool {
36 if (auto cmd_buffer = context->CreateCommandBuffer()) {
37 if (context->GetCommandQueue()
38 ->Submit({cmd_buffer},
39 [&latch](CommandBuffer::Status status) {
40 FML_CHECK(status == CommandBuffer::Status::kCompleted);
41 latch.Signal();
42 })
43 .ok()) {
44 latch.Wait();
45 }
46 }
47
48 id<MTLTexture> metal_texture =
49 std::static_pointer_cast<TextureMTL>(texture)->GetMTLTexture();
50
51 CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
52 CIImage* ciImage = [[CIImage alloc]
53 initWithMTLTexture:metal_texture
54 options:@{kCIImageColorSpace : (__bridge id)color_space}];
55 CGColorSpaceRelease(color_space);
56 FML_CHECK(ciImage);
57
58 std::shared_ptr<ContextMTL> context_mtl =
59 std::static_pointer_cast<ContextMTL>(context);
60 CIContext* cicontext =
61 [CIContext contextWithMTLDevice:context_mtl->GetMTLDevice()];
63
64 CIImage* flipped = [ciImage
65 imageByApplyingOrientation:kCGImagePropertyOrientationDownMirrored];
66
67 CGImageRef cgImage = [cicontext createCGImage:flipped
68 fromRect:[flipped extent]];
69
70 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
71 return std::unique_ptr<MetalScreenshot>(new MetalScreenshot(cgImage));
72 }
73}
#define FML_CHECK(condition)
Definition logging.h:104
std::shared_ptr< ContextGLES > context
const uintptr_t id

References context, FML_CHECK, id, texture, and fml::AutoResetWaitableEvent::Wait().

Referenced by impeller::testing::MetalGoldenScreenshotter::MakeScreenshot(), and MakeScreenshot().


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