7 #include "flutter/impeller/renderer/backend/metal/formats_mtl.h"
8 #include "flutter/impeller/renderer/context.h"
9 #include "flutter/shell/gpu/gpu_surface_metal_impeller.h"
10 #include "impeller/display_list/aiks_context.h"
11 #include "impeller/typographer/backends/skia/typographer_context_skia.h"
12 #include "impeller/typographer/typographer_context.h"
19 const std::shared_ptr<IOSContext>& context)
21 GPUSurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer),
23 impeller_context_(context ? context->GetImpellerContext() : nullptr),
24 aiks_context_(context ? context->GetAiksContext() : nullptr) {
25 if (!impeller_context_ || !aiks_context_) {
35 bool IOSSurfaceMetalImpeller::IsValid()
const {
40 void IOSSurfaceMetalImpeller::UpdateStorageSizeIfNecessary() {
45 std::unique_ptr<Surface> IOSSurfaceMetalImpeller::CreateGPUSurface(GrDirectContext*) {
46 impeller_context_->UpdateOffscreenLayerPixelFormat(
47 impeller::FromMTLPixelFormat(layer_.get().pixelFormat));
48 return std::make_unique<GPUSurfaceMetalImpeller>(
this,
54 GPUCAMetalLayerHandle IOSSurfaceMetalImpeller::GetCAMetalLayer(
const SkISize& frame_info)
const {
55 CAMetalLayer* layer = layer_.get();
56 const auto drawable_size = CGSizeMake(frame_info.width(), frame_info.height());
57 if (!CGSizeEqualToSize(drawable_size, layer.drawableSize)) {
58 layer.drawableSize = drawable_size;
63 layer.framebufferOnly = NO;
65 return (__bridge GPUCAMetalLayerHandle)layer;
69 bool IOSSurfaceMetalImpeller::PresentDrawable(GrMTLHandle drawable)
const {
75 GPUMTLTextureInfo IOSSurfaceMetalImpeller::GetMTLTexture(
const SkISize& frame_info)
const {
77 return GPUMTLTextureInfo{
84 bool IOSSurfaceMetalImpeller::PresentTexture(GPUMTLTextureInfo texture)
const {
90 bool IOSSurfaceMetalImpeller::AllowsDrawingWhenGpuDisabled()
const {