GrContextOptions grContextOptions;
_skContext = GrDirectContext::MakeMetal((__bridge void*)_device,
(__bridge void*)_commandQueue,
grContextOptions);
if (_skContext == nullptr) {
NSAssert(NO, @"Error.");
}
}
// Lock Mutex to block the runLoop from overwriting the _texture
// std::lock_guard lockGuard(_textureMutex);
id<MTLTexture> texture = _renderTargetTexture;
GrMtlTextureInfo fbInfo;
fbInfo.fTexture.retain((__bridge void*)texture);
GrBackendRenderTarget backendRT((int)texture.width,
(int)texture.height,
fbInfo);
const GrSurfaceOrigin origin = kTopLeft_GrSurfaceOrigin;
const SkColorType colorType = kBGRA_8888_SkColorType;
sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeSRGB();
SkSurfaceProps surfaceProps(0, kRGB_H_SkPixelGeometry);
sk_sp<SkSurface> skSurface(SkSurface::MakeFromBackendRenderTarget(_skContext.get(), backendRT, origin, colorType, nullptr, &surfaceProps));
if (skSurface == nullptr) {
NSLog(@"skSurface is null.");
return;
}
SkCanvas* canvas = skSurface->getCanvas();
SkSurface* surface = canvas->getSurface();
skSurface is alway null, any help is appreciate!
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/da82f7f4-ac3a-4d24-9eb1-e91e2005202fn%40googlegroups.com.