Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
impeller::testing::MetalScreenshotter Class Reference

#include <metal_screenshotter.h>

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

Public Member Functions

 MetalScreenshotter (bool enable_wide_gamut)
 
std::unique_ptr< ScreenshotMakeScreenshot (AiksContext &aiks_context, const Picture &picture, const ISize &size={300, 300}, bool scale_content=true) 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 19 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;
21}
static std::unique_ptr< PlaygroundImpl > Create(PlaygroundBackend backend, PlaygroundSwitches switches)
#define GLFW_TRUE
#define FML_CHECK(condition)
Definition logging.h:85

Member Function Documentation

◆ GetPlayground()

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

Implements impeller::testing::Screenshotter.

Definition at line 29 of file metal_screenshotter.h.

29{ return *playground_; }

◆ MakeScreenshot()

std::unique_ptr< Screenshot > impeller::testing::MetalScreenshotter::MakeScreenshot ( AiksContext aiks_context,
const Picture picture,
const ISize size = {300, 300},
bool  scale_content = true 
)
overridevirtual

Implements impeller::testing::Screenshotter.

Definition at line 23 of file metal_screenshotter.mm.

27 {
28 Vector2 content_scale =
29 scale_content ? playground_->GetContentScale() : Vector2{1, 1};
30 std::shared_ptr<Image> image = picture.ToImage(
31 aiks_context,
32 ISize(size.width * content_scale.x, size.height * content_scale.y));
33 std::shared_ptr<Texture> texture = image->GetTexture();
34 id<MTLTexture> metal_texture =
35 std::static_pointer_cast<TextureMTL>(texture)->GetMTLTexture();
36
37 CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
38 CIImage* ciImage = [[CIImage alloc]
39 initWithMTLTexture:metal_texture
40 options:@{kCIImageColorSpace : (__bridge id)color_space}];
41 CGColorSpaceRelease(color_space);
42 FML_CHECK(ciImage);
43
44 std::shared_ptr<Context> context = playground_->GetContext();
45 std::shared_ptr<ContextMTL> context_mtl =
46 std::static_pointer_cast<ContextMTL>(context);
47 CIContext* cicontext =
48 [CIContext contextWithMTLDevice:context_mtl->GetMTLDevice()];
49 FML_CHECK(context);
50
51 CIImage* flipped = [ciImage
52 imageByApplyingOrientation:kCGImagePropertyOrientationDownMirrored];
53
54 CGImageRef cgImage = [cicontext createCGImage:flipped
55 fromRect:[ciImage extent]];
56
57 return std::unique_ptr<MetalScreenshot>(new MetalScreenshot(cgImage));
58}
const char * options
sk_sp< SkImage > image
Definition examples.cpp:29
FlTexture * texture
sk_sp< const SkPicture > picture
Definition SkRecords.h:299
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
Definition switches.h:259
Point Vector2
Definition point.h:320
TSize< int64_t > ISize
Definition size.h:138
const uintptr_t id

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