From 4620733d5c4b100fae10861eaae6d6e97003c282 Mon Sep 17 00:00:00 2001 From: John McCutchan Date: Wed, 16 Aug 2023 10:30:32 -0700 Subject: [PATCH] Conditionally enable HardwareBuffer backed platform views (flutter/engine#44744) On Android >= 29 we can use a more efficient platform view render target --- .../io/flutter/plugin/platform/PlatformViewsController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index f9500cdf00..0df81363ca 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -968,11 +968,12 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega private static PlatformViewRenderTarget makePlatformViewRenderTarget( TextureRegistry textureRegistry) { - // TODO(johnmccutchan): Enable ImageReaderPlatformViewRenderTarget for public use. - if (false) { + if (Build.VERSION.SDK_INT >= 29) { + // Prefer ImageReader-based backend on versions >= 29. final TextureRegistry.ImageTextureEntry textureEntry = textureRegistry.createImageTexture(); return new ImageReaderPlatformViewRenderTarget(textureEntry); } + // Fallback to SurfaceTexture support on old phones. final TextureRegistry.SurfaceTextureEntry textureEntry = textureRegistry.createSurfaceTexture(); return new SurfaceTexturePlatformViewRenderTarget(textureEntry); }