5#include "flutter/shell/common/shell_test_platform_view_metal.h"
11#include "flutter/fml/platform/darwin/scoped_nsobject.h"
12#include "flutter/shell/gpu/gpu_surface_metal_impeller.h"
13#include "flutter/shell/gpu/gpu_surface_metal_skia.h"
14#include "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h"
15#include "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h"
22 [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
26 descriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
36 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch)
42 impeller ? [impeller_context_ context]->GetMTLDevice() : [context_
device])) {}
47 return impeller_context_;
72 std::shared_ptr<ShellTestVsyncClock> vsync_clock,
74 std::shared_ptr<ShellTestExternalViewEmbedder> shell_test_external_view_embedder,
75 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch)
79 is_gpu_disabled_sync_switch)),
80 create_vsync_waiter_(
std::move(create_vsync_waiter)),
81 vsync_clock_(
std::move(vsync_clock)),
82 shell_test_external_view_embedder_(
std::move(shell_test_external_view_embedder)) {
84 FML_CHECK([metal_context_->impeller_context() context] != nil);
86 FML_CHECK([metal_context_->context() mainContext] != nil);
92std::unique_ptr<VsyncWaiter> ShellTestPlatformViewMetal::CreateVSyncWaiter() {
93 return create_vsync_waiter_();
98 vsync_clock_->SimulateVSync();
102std::shared_ptr<ExternalViewEmbedder> ShellTestPlatformViewMetal::CreateExternalViewEmbedder() {
103 return shell_test_external_view_embedder_;
109 return std::make_unique<SmoothPointerDataDispatcher>(delegate);
114std::unique_ptr<Surface> ShellTestPlatformViewMetal::CreateRenderingSurface() {
116 return std::make_unique<GPUSurfaceMetalImpeller>(
this,
117 [metal_context_->impeller_context() context]);
119 return std::make_unique<GPUSurfaceMetalSkia>(
this, [metal_context_->context() mainContext]);
123std::shared_ptr<impeller::Context> ShellTestPlatformViewMetal::GetImpellerContext()
const {
124 return [metal_context_->impeller_context() context];
129 FML_CHECK(
false) <<
"A Metal Delegate configured with MTLRenderTargetType::kMTLTexture was asked "
130 "to acquire a layer.";
135bool ShellTestPlatformViewMetal::PresentDrawable(
GrMTLHandle drawable)
const {
136 FML_CHECK(
false) <<
"A Metal Delegate configured with MTLRenderTargetType::kMTLTexture was asked "
137 "to present a layer drawable.";
142GPUMTLTextureInfo ShellTestPlatformViewMetal::GetMTLTexture(
const SkISize& frame_info)
const {
143 return metal_context_->offscreen_texture_info();
147bool ShellTestPlatformViewMetal::PresentTexture(GPUMTLTextureInfo
texture)
const {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
The interface for Engine to implement.
#define FML_CHECK(condition)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
static fml::scoped_nsprotocol< id< MTLTexture > > CreateOffscreenTexture(id< MTLDevice > device)
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter
std::function< std::unique_ptr< PointerDataDispatcher >(PointerDataDispatcher::Delegate &)> PointerDataDispatcherMaker
Signature for constructing PointerDataDispatcher.
void * GPUCAMetalLayerHandle
const void * GPUMTLTextureHandle