Guard metal rendering behind SHELL_ENABLE_METAL (flutter/engine#24727)

This commit is contained in:
Kaushik Iska
2021-03-04 11:04:01 -06:00
committed by GitHub
parent 6ee73bc8fc
commit abc42cde56
2 changed files with 6 additions and 5 deletions

View File

@@ -10,12 +10,13 @@
@implementation FlutterRenderingBackend
+ (BOOL)renderUsingMetal {
#ifdef SHELL_ENABLE_METAL
if (@available(macOS 10.14, *)) {
BOOL systemSupportsMetal = MTLCreateSystemDefaultDevice() != nil;
return systemSupportsMetal;
} else {
return NO;
}
#endif
return NO;
}
+ (Class)layerClass {

View File

@@ -66,7 +66,7 @@ sk_sp<SkImage> EmbedderExternalTextureMetal::ResolveTexture(int64_t texture_id,
switch (texture->pixel_format) {
case FlutterMetalExternalTexturePixelFormat::kRGBA: {
if (ValidNumTextures(1, texture->num_textures)) {
id<MTLTexture> rgbaTex = reinterpret_cast<id<MTLTexture>>(texture->textures[0]);
id<MTLTexture> rgbaTex = (__bridge id<MTLTexture>)texture->textures[0];
image = [FlutterDarwinExternalTextureSkImageWrapper wrapRGBATexture:rgbaTex
grContext:context
width:size.width()
@@ -76,8 +76,8 @@ sk_sp<SkImage> EmbedderExternalTextureMetal::ResolveTexture(int64_t texture_id,
}
case FlutterMetalExternalTexturePixelFormat::kYUVA: {
if (ValidNumTextures(2, texture->num_textures)) {
id<MTLTexture> yTex = reinterpret_cast<id<MTLTexture>>(texture->textures[0]);
id<MTLTexture> uvTex = reinterpret_cast<id<MTLTexture>>(texture->textures[1]);
id<MTLTexture> yTex = (__bridge id<MTLTexture>)texture->textures[0];
id<MTLTexture> uvTex = (__bridge id<MTLTexture>)texture->textures[1];
image = [FlutterDarwinExternalTextureSkImageWrapper wrapYUVATexture:yTex
UVTex:uvTex
grContext:context