Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement PlatformViewsController. #5722

Merged
merged 6 commits into from
Jul 13, 2018
Merged

Conversation

amirh
Copy link
Contributor

@amirh amirh commented Jul 11, 2018

Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:

  • Forward touch events to the platform views.
  • Support accessibility for platform views.

flutter/flutter#19030

@amirh
Copy link
Contributor Author

amirh commented Jul 11, 2018

Framework side and plugin side CLs are in progress.
I'm totally ok if you prefer to wait for the other CLs before reviewing this.

@amirh
Copy link
Contributor Author

amirh commented Jul 12, 2018

Framework code is available in: flutter/flutter#19325

@amirh
Copy link
Contributor Author

amirh commented Jul 12, 2018

Sample plugin implementation is available here: flutter/plugins#657

@amirh
Copy link
Contributor Author

amirh commented Jul 12, 2018

@jason-simmons @Hixie
For the convenience of reviewing this PR I uploaded 2 in-progress PRs showing how this will be used: flutter/flutter#19325 flutter/plugins#657

This PR is now ready for review.

Copy link
Member

@jason-simmons jason-simmons left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -51,48 +63,145 @@ public PlatformViewRegistry getRegistry() {
}

public void onFlutterViewDestroyed() {
// TODO(amirh): tear down all vd resources.
for (int id : vdControllers.keySet()) {
Copy link
Member

Choose a reason for hiding this comment

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

can iterate over vdControllers.values() here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

switch (call.method) {
case "create":
createPlatformView(call);
break;
mFlutterView.post(new Runnable() {
Copy link
Member

Choose a reason for hiding this comment

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

These messages should be received on the platform thread. Does something fail if you call createPlatformView directly here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thanks

amirh added 6 commits July 13, 2018 11:22
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030
@amirh amirh force-pushed the platform_views_2 branch from 3ad65a0 to b26c3ef Compare July 13, 2018 18:24
@amirh amirh merged commit 80a85e4 into flutter:master Jul 13, 2018
@amirh amirh deleted the platform_views_2 branch July 13, 2018 21:08
jonahwilliams added a commit that referenced this pull request Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants