diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h index 5236d95d9a..9db228a70c 100644 --- a/include/core/SkSurface.h +++ b/include/core/SkSurface.h @@ -307,7 +307,7 @@ public: instantiated; may not be nullptr @return created SkSurface, or nullptr */ - static sk_sp MakeFromCAMetalLayer(GrContext* context, + static sk_sp MakeFromCAMetalLayer(GrRecordingContext* context, GrMTLHandle layer, GrSurfaceOrigin origin, int sampleCnt, @@ -334,7 +334,7 @@ public: fonts; may be nullptr @return created SkSurface, or nullptr */ - static sk_sp MakeFromMTKView(GrContext* context, + static sk_sp MakeFromMTKView(GrRecordingContext* context, GrMTLHandle mtkView, GrSurfaceOrigin origin, int sampleCnt, diff --git a/src/image/SkSurface_GpuMtl.mm b/src/image/SkSurface_GpuMtl.mm index deab4fe440..b41e2f3ff9 100644 --- a/src/image/SkSurface_GpuMtl.mm +++ b/src/image/SkSurface_GpuMtl.mm @@ -9,8 +9,8 @@ #include "include/core/SkSurface.h" #include "include/gpu/GrBackendSurface.h" #include "include/gpu/mtl/GrMtlTypes.h" -#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrProxyProvider.h" +#include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/GrRenderTargetContext.h" #include "src/gpu/GrResourceProvider.h" #include "src/gpu/GrResourceProviderPriv.h" @@ -26,7 +26,7 @@ #import #import -sk_sp SkSurface::MakeFromCAMetalLayer(GrContext* context, +sk_sp SkSurface::MakeFromCAMetalLayer(GrRecordingContext* rContext, GrMTLHandle layer, GrSurfaceOrigin origin, int sampleCnt, @@ -34,8 +34,8 @@ sk_sp SkSurface::MakeFromCAMetalLayer(GrContext* context, sk_sp colorSpace, const SkSurfaceProps* surfaceProps, GrMTLHandle* drawable) { - GrProxyProvider* proxyProvider = context->priv().proxyProvider(); - const GrCaps* caps = context->priv().caps(); + GrProxyProvider* proxyProvider = rContext->priv().proxyProvider(); + const GrCaps* caps = rContext->priv().caps(); CAMetalLayer* metalLayer = (__bridge CAMetalLayer*)layer; GrBackendFormat backendFormat = GrBackendFormat::MakeMtl(metalLayer.pixelFormat); @@ -90,23 +90,23 @@ sk_sp SkSurface::MakeFromCAMetalLayer(GrContext* context, GrSurfaceProxyView readView(proxy, origin, readSwizzle); GrSurfaceProxyView writeView(std::move(proxy), origin, writeSwizzle); - auto rtc = std::make_unique(context, std::move(readView), + auto rtc = std::make_unique(rContext, std::move(readView), std::move(writeView), grColorType, colorSpace, surfaceProps); - sk_sp surface = SkSurface_Gpu::MakeWrappedRenderTarget(context, std::move(rtc)); + sk_sp surface = SkSurface_Gpu::MakeWrappedRenderTarget(rContext, std::move(rtc)); return surface; } -sk_sp SkSurface::MakeFromMTKView(GrContext* context, +sk_sp SkSurface::MakeFromMTKView(GrRecordingContext* rContext, GrMTLHandle view, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp colorSpace, const SkSurfaceProps* surfaceProps) { - GrProxyProvider* proxyProvider = context->priv().proxyProvider(); - const GrCaps* caps = context->priv().caps(); + GrProxyProvider* proxyProvider = rContext->priv().proxyProvider(); + const GrCaps* caps = rContext->priv().caps(); MTKView* mtkView = (__bridge MTKView*)view; GrBackendFormat backendFormat = GrBackendFormat::MakeMtl(mtkView.colorPixelFormat); @@ -160,11 +160,11 @@ sk_sp SkSurface::MakeFromMTKView(GrContext* context, GrSurfaceProxyView readView(proxy, origin, readSwizzle); GrSurfaceProxyView writeView(std::move(proxy), origin, writeSwizzle); - auto rtc = std::make_unique(context, std::move(readView), + auto rtc = std::make_unique(rContext, std::move(readView), std::move(writeView), grColorType, colorSpace, surfaceProps); - sk_sp surface = SkSurface_Gpu::MakeWrappedRenderTarget(context, std::move(rtc)); + sk_sp surface = SkSurface_Gpu::MakeWrappedRenderTarget(rContext, std::move(rtc)); return surface; } diff --git a/tools/skottie_ios_app/GrContextHolder.h b/tools/skottie_ios_app/GrContextHolder.h index eed4d9df8a..0f77db0878 100644 --- a/tools/skottie_ios_app/GrContextHolder.h +++ b/tools/skottie_ios_app/GrContextHolder.h @@ -5,12 +5,13 @@ #include -class GrContext; +class GrDirectContext; -// A struct to take ownership of a GrContext. -struct GrContextRelease { void operator()(GrContext*); }; -using GrContextHolder = std::unique_ptr; +// A struct to take ownership of a GrDirectContext. +struct GrDirectContextRelease { void operator()(GrDirectContext*); }; +using GrContextHolder = std::unique_ptr; -// Wrapper around GrContext::MakeGL +// Wrapper around GrDirectContext::MakeGL GrContextHolder SkMakeGLContext(); + #endif // GrContextHolder_DEFINED diff --git a/tools/skottie_ios_app/SkMetalViewBridge.h b/tools/skottie_ios_app/SkMetalViewBridge.h index 1c2c2f03ab..4f82d73f5c 100644 --- a/tools/skottie_ios_app/SkMetalViewBridge.h +++ b/tools/skottie_ios_app/SkMetalViewBridge.h @@ -12,7 +12,7 @@ class SkSurface; template class sk_sp; -sk_sp SkMtkViewToSurface(MTKView*, GrContext*); +sk_sp SkMtkViewToSurface(MTKView*, GrRecordingContext*); GrContextHolder SkMetalDeviceToGrContext(id, id); diff --git a/tools/skottie_ios_app/SkMetalViewBridge.mm b/tools/skottie_ios_app/SkMetalViewBridge.mm index 6fa51177b3..dd5de64696 100644 --- a/tools/skottie_ios_app/SkMetalViewBridge.mm +++ b/tools/skottie_ios_app/SkMetalViewBridge.mm @@ -12,8 +12,8 @@ #import #import -sk_sp SkMtkViewToSurface(MTKView* mtkView, GrContext* grContext) { - if (!grContext || +sk_sp SkMtkViewToSurface(MTKView* mtkView, GrRecordingContext* rContext) { + if (!rContext || MTLPixelFormatDepth32Float_Stencil8 != [mtkView depthStencilPixelFormat] || MTLPixelFormatBGRA8Unorm != [mtkView colorPixelFormat]) { return nullptr; @@ -25,15 +25,15 @@ sk_sp SkMtkViewToSurface(MTKView* mtkView, GrContext* grContext) { const SkSurfaceProps surfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); int sampleCount = (int)[mtkView sampleCount]; - return SkSurface::MakeFromMTKView(grContext, (__bridge GrMTLHandle)mtkView, origin, sampleCount, + return SkSurface::MakeFromMTKView(rContext, (__bridge GrMTLHandle)mtkView, origin, sampleCount, colorType, colorSpace, &surfaceProps); } GrContextHolder SkMetalDeviceToGrContext(id device, id queue) { GrContextOptions grContextOptions; // set different options here. - return GrContextHolder(GrContext::MakeMetal((__bridge void*)device, - (__bridge void*)queue, - grContextOptions).release()); + return GrContextHolder(GrDirectContext::MakeMetal((__bridge void*)device, + (__bridge void*)queue, + grContextOptions).release()); } void SkMtkViewConfigForSkia(MTKView* mtkView) {