Skip to content

Commit

Permalink
Re-enable HardwareBuffer backed Platform Views on Android >= 29
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmccutchan committed Sep 21, 2023
1 parent 78c1ad2 commit 8ce8181
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class ImageReaderPlatformViewRenderTarget implements PlatformViewRenderTa
private int bufferWidth = 0;
private int bufferHeight = 0;
private static final String TAG = "ImageReaderPlatformViewRenderTarget";
private static final int MAX_IMAGES = 3;

private void closeReader() {
if (this.reader != null) {
Expand All @@ -39,7 +40,7 @@ public void onImageAvailable(ImageReader reader) {
try {
image = reader.acquireLatestImage();
} catch (IllegalStateException e) {
Log.e(TAG, "New image available that could not be acquired: " + e.toString());
Log.e(TAG, "New image available but it could not be acquired: " + e.toString());
}
if (image == null) {
return;
Expand All @@ -52,7 +53,7 @@ public void onImageAvailable(ImageReader reader) {
protected ImageReader createImageReader33() {
final ImageReader.Builder builder = new ImageReader.Builder(bufferWidth, bufferHeight);
// Allow for double buffering.
builder.setMaxImages(3);
builder.setMaxImages(MAX_IMAGES);
// Use PRIVATE image format so that we can support video decoding.
// TODO(johnmccutchan): Should we always use PRIVATE here? It may impact our
// ability to read back texture data. If we don't always want to use it, how do
Expand All @@ -78,7 +79,7 @@ protected ImageReader createImageReader29() {
bufferWidth,
bufferHeight,
ImageFormat.PRIVATE,
3,
MAX_IMAGES,
HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE);
reader.setOnImageAvailableListener(this.onImageAvailableListener, onImageAvailableHandler);
return reader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
// Whether software rendering is used.
private boolean usesSoftwareRendering = false;

private static boolean enableHardwareBufferRenderingTarget = false;
private static boolean enableHardwareBufferRenderingTarget = true;

private final PlatformViewsChannel.PlatformViewsHandler channelHandler =
new PlatformViewsChannel.PlatformViewsHandler() {
Expand Down

0 comments on commit 8ce8181

Please sign in to comment.