diff --git a/experimental/minimal_ios_mtl_skia_app/main.mm b/experimental/minimal_ios_mtl_skia_app/main.mm index 3d4b18c753..2a125a9c35 100644 --- a/experimental/minimal_ios_mtl_skia_app/main.mm +++ b/experimental/minimal_ios_mtl_skia_app/main.mm @@ -44,7 +44,6 @@ static void draw_example(SkSurface* surface, const SkPaint& paint, double rotati @interface AppViewDelegate : NSObject @property (assign, nonatomic) GrContext* grContext; // non-owning pointer. -@property (assign, nonatomic) id metalQueue; @end @implementation AppViewDelegate { @@ -71,10 +70,7 @@ static void draw_example(SkSurface* surface, const SkPaint& paint, double rotati // Must flush *and* present for this to work! surface->flush(); surface = nullptr; - - id commandBuffer = [[self metalQueue] commandBuffer]; - [commandBuffer presentDrawable:[view currentDrawable]]; - [commandBuffer commit]; + [[view currentDrawable] present]; } - (void)mtkView:(nonnull MTKView *)view drawableSizeWillChange:(CGSize)size { @@ -86,7 +82,6 @@ static void draw_example(SkSurface* surface, const SkPaint& paint, double rotati @interface AppViewController : UIViewController @property (strong, nonatomic) id metalDevice; -@property (strong, nonatomic) id metalQueue; @end @implementation AppViewController { @@ -101,9 +96,8 @@ static void draw_example(SkSurface* surface, const SkPaint& paint, double rotati [super viewDidLoad]; if (!fGrContext) { [self setMetalDevice:MTLCreateSystemDefaultDevice()]; - [self setMetalQueue:[[self metalDevice] newCommandQueue]]; GrContextOptions grContextOptions; // set different options here. - fGrContext = SkMetalDeviceToGrContext([self metalDevice], [self metalQueue], grContextOptions); + fGrContext = SkMetalDeviceToGrContext([self metalDevice], grContextOptions); } if (![self view] || ![self metalDevice]) { NSLog(@"Metal is not supported on this device"); @@ -116,7 +110,6 @@ static void draw_example(SkSurface* surface, const SkPaint& paint, double rotati SkMtkViewConfigForSkia(mtkView); AppViewDelegate* viewDelegate = [[AppViewDelegate alloc] init]; [viewDelegate setGrContext:fGrContext.get()]; - [viewDelegate setMetalQueue:[self metalQueue]]; [viewDelegate mtkView:mtkView drawableSizeWillChange:[mtkView bounds].size]; [mtkView setDelegate:viewDelegate]; } diff --git a/experimental/skottie_ios/SkMetalViewBridge.h b/experimental/skottie_ios/SkMetalViewBridge.h index f5fa57feb3..9fb88a4d24 100644 --- a/experimental/skottie_ios/SkMetalViewBridge.h +++ b/experimental/skottie_ios/SkMetalViewBridge.h @@ -12,7 +12,7 @@ template class sk_sp; sk_sp SkMtkViewToSurface(MTKView*, GrContext*); -sk_sp SkMetalDeviceToGrContext(id, id, const GrContextOptions&); +sk_sp SkMetalDeviceToGrContext(id, const GrContextOptions&); void SkMtkViewConfigForSkia(MTKView*); diff --git a/experimental/skottie_ios/SkMetalViewBridge.mm b/experimental/skottie_ios/SkMetalViewBridge.mm index a48a19713c..aabf2ff43f 100644 --- a/experimental/skottie_ios/SkMetalViewBridge.mm +++ b/experimental/skottie_ios/SkMetalViewBridge.mm @@ -41,8 +41,9 @@ sk_sp SkMtkViewToSurface(MTKView* mtkView, GrContext* grContext) { } } -sk_sp SkMetalDeviceToGrContext(id device, id queue, const GrContextOptions& opts) { - return GrContext::MakeMetal((void*)device, (void*)queue, opts); +sk_sp SkMetalDeviceToGrContext(id device, const GrContextOptions& opts) { + return GrContext::MakeMetal((void*)device, + (void*)[device newCommandQueue], opts); } void SkMtkViewConfigForSkia(MTKView* mtkView) {