| Flutter Impeller |

Public Member Functions | List of all members
impeller::testing::MetalScreenshotter Class Reference

`#include <metal_screenshotter.h>`

Inheritance diagram for impeller::testing::MetalScreenshotter:

## Public Member Functions
| MetalScreenshotter (bool enable_wide_gamut)
std::unique_ptr< Screenshot > | MakeScreenshot (AiksContext &aiks_context, const std::shared_ptr< Texture > texture) override
PlaygroundImpl & | GetPlayground () override
Public Member Functions inherited from impeller::testing::Screenshotter
virtual | ~Screenshotter ()=default

## Detailed Description

Converts `Picture`s and `DisplayList`s to `MetalScreenshot`s with the playground backend.

Definition at line 18 of file metal_screenshotter.h.

## Constructor & Destructor Documentation

## ◆ MetalScreenshotter()

impeller::testing::MetalScreenshotter::MetalScreenshotter | ( | bool | enable_wide_gamut | ) |
| explicit

Definition at line 16 of file metal_screenshotter.mm.

16 {
17 FML_CHECK(::glfwInit() == GLFW_TRUE);
18 PlaygroundSwitches switches;
19 switches.enable_wide_gamut = enable_wide_gamut;
20 playground_ = PlaygroundImpl::Create(PlaygroundBackend::kMetal, switches);
21 }
impeller::PlaygroundImpl::Create
static std::unique_ptr< PlaygroundImpl > Create(PlaygroundBackend backend, PlaygroundSwitches switches)
Definition: playground_impl.cc:25
impeller::PlaygroundBackend::kMetal
@ kMetal

References impeller::PlaygroundImpl::Create(), impeller::PlaygroundSwitches::enable_wide_gamut, and impeller::kMetal.

## Member Function Documentation

## ◆ GetPlayground()

PlaygroundImpl& impeller::testing::MetalScreenshotter::GetPlayground | ( |  | ) |
| inline override virtual

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 | ( | AiksContext & | aiks_context,
|  | const std::shared_ptr< Texture > | texture
| ) |  |
| override virtual

Implements impeller::testing::Screenshotter.

Definition at line 23 of file metal_screenshotter.mm.

25 {
26 @autoreleasepool {
27 id<MTLTexture> metal_texture =
28 std::static_pointer_cast<TextureMTL>(texture)->GetMTLTexture();
29
30 CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
31 CIImage* ciImage = [[CIImage alloc]
32 initWithMTLTexture:metal_texture
33 options:@{kCIImageColorSpace : (__bridge id)color_space}];
34 CGColorSpaceRelease(color_space);
35 FML_CHECK(ciImage);
36
37 std::shared_ptr<Context> context = playground_->GetContext();
38 std::shared_ptr<ContextMTL> context_mtl =
39 std::static_pointer_cast<ContextMTL>(context);
40 CIContext* cicontext =
41 [CIContext contextWithMTLDevice:context_mtl->GetMTLDevice()];
42 FML_CHECK(context);
43
44 CIImage* flipped = [ciImage
45 imageByApplyingOrientation:kCGImagePropertyOrientationDownMirrored];
46
47 CGImageRef cgImage = [cicontext createCGImage:flipped
48 fromRect:[ciImage extent]];
49
50 return std::unique_ptr<MetalScreenshot>(new MetalScreenshot(cgImage));
51 }
52 }

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

- impeller/golden_tests/metal_screenshotter.h
- impeller/golden_tests/metal_screenshotter.mm