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"
16 const std::shared_ptr<IOSContext>& context)
18 GPUSurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer),
20 impeller_context_(context ? context->GetImpellerContext() : nullptr) {
21 if (!impeller_context_) {
31 bool IOSSurfaceMetalImpeller::IsValid()
const {
36 void IOSSurfaceMetalImpeller::UpdateStorageSizeIfNecessary() {
41 std::unique_ptr<Surface> IOSSurfaceMetalImpeller::CreateGPUSurface(GrDirectContext*) {
42 impeller_context_->UpdateOffscreenLayerPixelFormat(
43 impeller::FromMTLPixelFormat(layer_.get().pixelFormat));
44 return std::make_unique<GPUSurfaceMetalImpeller>(
this,
50 GPUCAMetalLayerHandle IOSSurfaceMetalImpeller::GetCAMetalLayer(
const SkISize& frame_info)
const {
51 CAMetalLayer* layer = layer_.get();
52 const auto drawable_size = CGSizeMake(frame_info.width(), frame_info.height());
53 if (!CGSizeEqualToSize(drawable_size, layer.drawableSize)) {
54 layer.drawableSize = drawable_size;
59 layer.framebufferOnly = NO;
67 layer.presentsWithTransaction = [[NSThread currentThread] isMainThread];
69 return (__bridge GPUCAMetalLayerHandle)layer;
73 bool IOSSurfaceMetalImpeller::PresentDrawable(GrMTLHandle drawable)
const {
79 GPUMTLTextureInfo IOSSurfaceMetalImpeller::GetMTLTexture(
const SkISize& frame_info)
const {
81 return GPUMTLTextureInfo{
88 bool IOSSurfaceMetalImpeller::PresentTexture(GPUMTLTextureInfo texture)
const {
94 bool IOSSurfaceMetalImpeller::AllowsDrawingWhenGpuDisabled()
const {