Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@bparrishMines
Copy link
Contributor

@bparrishMines bparrishMines commented Jun 19, 2020

Description

Creates an image RenderMode that paints a Flutter UI provided by an ImageReader onto a Canvas. This is needed for hybrid platform views on Android.

Since this adds a new RenderMode, this slightly changes the behavior in a deprecated constructor that defaulted to RenderMode.texture if RenderMode.surface was not selected.

Related Issues

flutter/flutter#58289

Tests

I added the following tests:

This PR only creates a new RenderMode, but doesn't actually set it up to be used. This is part of a larger project to support hybrid views: https://github.com/flutter/flutter/projects/138

I added a trivial test to verify that a call to FlutterImageView.acquireLatestImage calls ImageReader.acquireLatestImage() and invalidate().

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the contributor guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the C++, Objective-C, Java style guides for the engine.
  • I read the tree hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change.

@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@auto-assign auto-assign bot requested a review from gaaclarke June 19, 2020 01:40
@Nullable private Image nextImage;
private Image currentImage;

public FlutterImageView(Context context, ImageReader imageReader) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: @NonNull annotation in both arguments

this.imageReader = imageReader;
}

@RequiresApi(api = Build.VERSION_CODES.KITKAT)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It looks like this entire class requires KITKAT due to the dependency on ImageReader.

return;
}

currentImage.close();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is nullable

}

@RequiresApi(api = Build.VERSION_CODES.P)
private void drawImageBuffer(Canvas canvas) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below Canvas arguments need @NonNull

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

class FlutterImageView extends View implements RenderSurface {
Copy link

@blasten blasten Jun 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs some javadoc.

@blasten
Copy link

blasten commented Jun 19, 2020

Direction looks 👍

invalidate();
}

@RequiresApi(api = Build.VERSION_CODES.P)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Only a codepath in onDraw requires this API.

drawImageBuffer(canvas);
} else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
drawImagePlane(canvas);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else: throw unsupported Android version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since, I moved the @RequiresApi(api = Build.VERSION_CODES.KITKAT) to the top of the class due to your other comment. I don't think it needs that anymore, right?

@bparrishMines bparrishMines changed the title New type of flutterview Create a new kind of FlutterView that takes an ImageReader Jun 19, 2020
@bparrishMines bparrishMines changed the title Create a new kind of FlutterView that takes an ImageReader Creates a new RenderMode for FlutterView Jun 19, 2020
@bparrishMines bparrishMines merged commit 1913040 into flutter:master Jun 22, 2020
@bparrishMines bparrishMines deleted the flutter_image_view branch June 22, 2020 21:40
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2020
renderSurface = flutterTextureView;
} else {
throw new IllegalArgumentException(
String.format("RenderMode not supported with this constructor: ", renderMode));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, the missing format arguments break Google test (here and below line 268). If we have not yet, can we fix this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zhongwuzw pushed a commit to zhongwuzw/engine that referenced this pull request Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants