diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.mm b/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.mm index 9457437918629..1f78745585533 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.mm +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.mm @@ -8,6 +8,9 @@ #include "flutter/fml/logging.h" #include "flutter/shell/common/context_options.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" +#include "third_party/skia/include/gpu/ganesh/mtl/GrMtlBackendContext.h" +#include "third_party/skia/include/gpu/ganesh/mtl/GrMtlDirectContext.h" FLUTTER_ASSERT_ARC @@ -79,10 +82,12 @@ - (instancetype)initWithMTLDevice:(id)device commandQueue:(id)commandQueue { const auto contextOptions = flutter::MakeDefaultContextOptions(flutter::ContextType::kRender, GrBackendApi::kMetal); + GrMtlBackendContext backendContext = {}; // Skia expect arguments to `MakeMetal` transfer ownership of the reference in for release later // when the GrDirectContext is collected. - return GrDirectContext::MakeMetal((__bridge_retained void*)device, - (__bridge_retained void*)commandQueue, contextOptions); + backendContext.fDevice.reset((__bridge_retained void*)device); + backendContext.fQueue.reset((__bridge_retained void*)commandQueue); + return GrDirectContexts::MakeMetal(backendContext, contextOptions); } - (void)dealloc {