8#include "flutter/shell/platform/embedder/embedder_surface_metal_impeller.h"
10#include "flutter/fml/logging.h"
11#include "flutter/fml/synchronization/sync_switch.h"
12#include "flutter/shell/gpu/gpu_surface_metal_delegate.h"
13#include "flutter/shell/gpu/gpu_surface_metal_impeller.h"
14#import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h"
15#include "impeller/entity/mtl/entity_shaders.h"
16#include "impeller/entity/mtl/framebuffer_blend_shaders.h"
17#include "impeller/entity/mtl/modern_shaders.h"
21#include "impeller/scene/shaders/mtl/scene_shaders.h"
32 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder)
34 metal_dispatch_table_(
std::move(metal_dispatch_table)),
35 external_view_embedder_(
std::move(external_view_embedder)) {
36 std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
37 std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
38 impeller_entity_shaders_length),
40 std::make_shared<fml::NonOwnedMapping>(impeller_scene_shaders_data,
41 impeller_scene_shaders_length),
43 std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_data,
44 impeller_modern_shaders_length),
45 std::make_shared<fml::NonOwnedMapping>(impeller_framebuffer_blend_shaders_data,
46 impeller_framebuffer_blend_shaders_length),
50 (id<MTLCommandQueue>)command_queue,
52 std::make_shared<fml::SyncSwitch>(
false),
55 FML_LOG(IMPORTANT) <<
"Using the Impeller rendering backend (Metal).";
62bool EmbedderSurfaceMetalImpeller::IsValid()
const {
66std::unique_ptr<Surface> EmbedderSurfaceMetalImpeller::CreateGPUSurface()
72 const bool render_to_surface = !external_view_embedder_;
73 auto surface = std::make_unique<GPUSurfaceMetalImpeller>(
this, context_, render_to_surface);
82std::shared_ptr<impeller::Context> EmbedderSurfaceMetalImpeller::CreateImpellerContext()
const {
87 const SkISize& frame_info)
const {
88 FML_CHECK(
false) <<
"Only rendering to MTLTexture is supported.";
92bool EmbedderSurfaceMetalImpeller::PresentDrawable(
GrMTLHandle drawable)
const {
93 FML_CHECK(
false) <<
"Only rendering to MTLTexture is supported.";
97GPUMTLTextureInfo EmbedderSurfaceMetalImpeller::GetMTLTexture(
const SkISize& frame_info)
const {
98 return metal_dispatch_table_.
get_texture(frame_info);
101bool EmbedderSurfaceMetalImpeller::PresentTexture(GPUMTLTextureInfo
texture)
const {
#define FLUTTER_ASSERT_NOT_ARC
static std::shared_ptr< ContextMTL > Create(const std::vector< std::string > &shader_library_paths, std::shared_ptr< const fml::SyncSwitch > is_gpu_disabled_sync_switch)
#define IMPELLER_CA_METAL_LAYER_AVAILABLE
#define FML_LOG(severity)
#define FML_CHECK(condition)
void * GPUMTLDeviceHandle
void * GPUCAMetalLayerHandle
void * GPUMTLCommandQueueHandle