Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Package Functions | Package Attributes | List of all members
io.flutter.plugin.platform.PlatformViewsController Class Reference
Inheritance diagram for io.flutter.plugin.platform.PlatformViewsController:
io.flutter.plugin.platform.PlatformViewsAccessibilityDelegate

Public Member Functions

PlatformView createPlatformView ( @NonNull PlatformViewsChannel.PlatformViewCreationRequest request, boolean wrapContext)
 
long configureForTextureLayerComposition ( @NonNull PlatformView platformView, @NonNull PlatformViewsChannel.PlatformViewCreationRequest request)
 
MotionEvent toMotionEvent (float density, PlatformViewsChannel.PlatformViewTouch touch, boolean usingVirtualDiplay)
 
 PlatformViewsController ()
 
void attach ( @Nullable Context context, @NonNull TextureRegistry textureRegistry, @NonNull DartExecutor dartExecutor)
 
void setSoftwareRendering (boolean useSoftwareRendering)
 
void detach ()
 
void attachToView (@NonNull FlutterView newFlutterView)
 
void detachFromView ()
 
void attachAccessibilityBridge (@NonNull AccessibilityBridge accessibilityBridge)
 
void detachAccessibilityBridge ()
 
void attachTextInputPlugin (@NonNull TextInputPlugin textInputPlugin)
 
void detachTextInputPlugin ()
 
boolean checkInputConnectionProxy (@Nullable View view)
 
PlatformViewRegistry getRegistry ()
 
void onAttachedToJNI ()
 
void onDetachedFromJNI ()
 
void onPreEngineRestart ()
 
View getPlatformViewById (int viewId)
 
boolean usesVirtualDisplay (int id)
 
void disposePlatformView (int viewId)
 
void attachToFlutterRenderer (@NonNull FlutterRenderer flutterRenderer)
 
void onDisplayPlatformView (int viewId, int x, int y, int width, int height, int viewWidth, int viewHeight, @NonNull FlutterMutatorsStack mutatorsStack)
 
void onDisplayOverlaySurface (int id, int x, int y, int width, int height)
 
void onBeginFrame ()
 
void onEndFrame ()
 
FlutterOverlaySurface createOverlaySurface (@NonNull PlatformOverlayView imageView)
 
FlutterOverlaySurface createOverlaySurface ()
 
void destroyOverlaySurfaces ()
 
SparseArray< PlatformOverlayViewgetOverlayLayerViews ()
 

Package Functions

void initializePlatformViewIfNeeded (int viewId)
 

Package Attributes

final HashMap< Integer, VirtualDisplayControllervdControllers
 
final HashMap< Context, View > contextToEmbeddedView
 

Detailed Description

Manages platform views.

Each io.flutter.embedding.engine.FlutterEngine or io.flutter.app.FlutterPluginRegistry has a single platform views controller. A platform views controller can be attached to at most one Flutter view.

Definition at line 52 of file PlatformViewsController.java.

Constructor & Destructor Documentation

◆ PlatformViewsController()

io.flutter.plugin.platform.PlatformViewsController.PlatformViewsController ( )
inline

Definition at line 716 of file PlatformViewsController.java.

716 {
717 registry = new PlatformViewRegistryImpl();
718 vdControllers = new HashMap<>();
719 accessibilityEventsDelegate = new AccessibilityEventsDelegate();
720 contextToEmbeddedView = new HashMap<>();
721 overlayLayerViews = new SparseArray<>();
722 currentFrameUsedOverlayLayerIds = new HashSet<>();
723 currentFrameUsedPlatformViewIds = new HashSet<>();
724 viewWrappers = new SparseArray<>();
725 platformViews = new SparseArray<>();
726 platformViewParent = new SparseArray<>();
727
728 motionEventTracker = MotionEventTracker.getInstance();
729 }
final HashMap< Integer, VirtualDisplayController > vdControllers

Member Function Documentation

◆ attach()

void io.flutter.plugin.platform.PlatformViewsController.attach ( @Nullable Context  context,
@NonNull TextureRegistry  textureRegistry,
@NonNull DartExecutor  dartExecutor 
)
inline

Attaches this platform views controller to its input and output channels.

Parameters
contextThe base context that will be passed to embedded views created by this controller. This should be the context of the Activity hosting the Flutter application.
textureRegistryThe texture registry which provides the output textures into which the embedded views will be rendered.
dartExecutorThe dart execution context, which is used to set up a system channel.

Definition at line 740 of file PlatformViewsController.java.

743 {
744 if (this.context != null) {
745 throw new AssertionError(
746 "A PlatformViewsController can only be attached to a single output target.\n"
747 + "attach was called while the PlatformViewsController was already attached.");
748 }
749 this.context = context;
750 this.textureRegistry = textureRegistry;
751 platformViewsChannel = new PlatformViewsChannel(dartExecutor);
752 platformViewsChannel.setPlatformViewsHandler(channelHandler);
753 }

◆ attachAccessibilityBridge()

void io.flutter.plugin.platform.PlatformViewsController.attachAccessibilityBridge ( @NonNull AccessibilityBridge  accessibilityBridge)
inline

Attaches an accessibility bridge for this platform views accessibility delegate.

Accessibility events originating in platform views belonging to this delegate will be delegated to this accessibility bridge.

Implements io.flutter.plugin.platform.PlatformViewsAccessibilityDelegate.

Definition at line 856 of file PlatformViewsController.java.

856 {
857 accessibilityEventsDelegate.setAccessibilityBridge(accessibilityBridge);
858 }
void setAccessibilityBridge(@Nullable AccessibilityBridge accessibilityBridge)

◆ attachTextInputPlugin()

void io.flutter.plugin.platform.PlatformViewsController.attachTextInputPlugin ( @NonNull TextInputPlugin  textInputPlugin)
inline

Attaches this controller to a text input plugin.

While a text input plugin is available, the platform views controller interacts with it to facilitate delegation of text input connections to platform views.

A platform views controller should be attached to a text input plugin whenever it is possible for the Flutter framework to receive text input.

Definition at line 874 of file PlatformViewsController.java.

874 {
875 this.textInputPlugin = textInputPlugin;
876 }

◆ attachToFlutterRenderer()

void io.flutter.plugin.platform.PlatformViewsController.attachToFlutterRenderer ( @NonNull FlutterRenderer  flutterRenderer)
inline

Definition at line 1127 of file PlatformViewsController.java.

1127 {
1128 androidTouchProcessor = new AndroidTouchProcessor(flutterRenderer, /*trackMotionEvents=*/ true);
1129 }

◆ attachToView()

void io.flutter.plugin.platform.PlatformViewsController.attachToView ( @NonNull FlutterView  newFlutterView)
inline

Attaches the controller to a FlutterView.

When io.flutter.embedding.android.FlutterFragment is used, this method is called after the device rotates since the FlutterView is recreated after a rotation.

Definition at line 796 of file PlatformViewsController.java.

796 {
797 flutterView = newFlutterView;
798 // Add wrapper for platform views that use GL texture.
799 for (int index = 0; index < viewWrappers.size(); index++) {
800 final PlatformViewWrapper view = viewWrappers.valueAt(index);
801 flutterView.addView(view);
802 }
803 // Add wrapper for platform views that are composed at the view hierarchy level.
804 for (int index = 0; index < platformViewParent.size(); index++) {
805 final FlutterMutatorView view = platformViewParent.valueAt(index);
806 flutterView.addView(view);
807 }
808 // Notify platform views that they are now attached to a FlutterView.
809 for (int index = 0; index < platformViews.size(); index++) {
810 final PlatformView view = platformViews.valueAt(index);
811 view.onFlutterViewAttached(flutterView);
812 }
813 }

◆ checkInputConnectionProxy()

boolean io.flutter.plugin.platform.PlatformViewsController.checkInputConnectionProxy ( @Nullable View  view)
inline

Returns true if Flutter should perform input connection proxying for the view.

If the view is a platform view managed by this platform views controller returns true. Else if the view was created in a platform view's VD, delegates the decision to the platform view's View#checkInputConnectionProxy(View) method. Else returns false.

Definition at line 890 of file PlatformViewsController.java.

890 {
891 // View can be null on some devices
892 // See: https://github.com/flutter/flutter/issues/36517
893 if (view == null) {
894 return false;
895 }
896 if (!contextToEmbeddedView.containsKey(view.getContext())) {
897 return false;
898 }
899 View platformView = contextToEmbeddedView.get(view.getContext());
900 if (platformView == view) {
901 return true;
902 }
903 return platformView.checkInputConnectionProxy(view);
904 }

◆ configureForTextureLayerComposition()

long io.flutter.plugin.platform.PlatformViewsController.configureForTextureLayerComposition ( @NonNull PlatformView  platformView,
@NonNull PlatformViewsChannel.PlatformViewCreationRequest  request 
)
inline

Definition at line 599 of file PlatformViewsController.java.

601 {
602 // This mode attaches the view to the Android view hierarchy and record its drawing
603 // operations, so they can be forwarded to a GL texture that is composed by the
604 // Flutter engine.
605
606 // API level 23 is required to use Surface#lockHardwareCanvas().
607 enforceMinimumAndroidApiVersion(23);
608 Log.i(TAG, "Hosting view in view hierarchy for platform view: " + request.viewId);
609
610 final int physicalWidth = toPhysicalPixels(request.logicalWidth);
611 final int physicalHeight = toPhysicalPixels(request.logicalHeight);
612 PlatformViewWrapper viewWrapper;
613 long textureId;
614 if (usesSoftwareRendering) {
615 viewWrapper = new PlatformViewWrapper(context);
616 textureId = -1;
617 } else {
618 final PlatformViewRenderTarget renderTarget = makePlatformViewRenderTarget(textureRegistry);
619 viewWrapper = new PlatformViewWrapper(context, renderTarget);
620 textureId = renderTarget.getId();
621 }
622 viewWrapper.setTouchProcessor(androidTouchProcessor);
623 viewWrapper.resizeRenderTarget(physicalWidth, physicalHeight);
624
625 final FrameLayout.LayoutParams viewWrapperLayoutParams =
626 new FrameLayout.LayoutParams(physicalWidth, physicalHeight);
627
628 // Size and position the view wrapper.
629 final int physicalTop = toPhysicalPixels(request.logicalTop);
630 final int physicalLeft = toPhysicalPixels(request.logicalLeft);
631 viewWrapperLayoutParams.topMargin = physicalTop;
632 viewWrapperLayoutParams.leftMargin = physicalLeft;
633 viewWrapper.setLayoutParams(viewWrapperLayoutParams);
634
635 // Size the embedded view.
636 final View embeddedView = platformView.getView();
637 embeddedView.setLayoutParams(new FrameLayout.LayoutParams(physicalWidth, physicalHeight));
638
639 // Accessibility in the embedded view is initially disabled because if a Flutter app
640 // disabled accessibility in the first frame, the embedding won't receive an update to
641 // disable accessibility since the embedding never received an update to enable it.
642 // The AccessibilityBridge keeps track of the accessibility nodes, and handles the deltas
643 // when the framework sends a new a11y tree to the embedding.
644 // To prevent races, the framework populate the SemanticsNode after the platform view has
645 // been created.
646 embeddedView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
647
648 // Add the embedded view to the wrapper.
649 viewWrapper.addView(embeddedView);
650
651 // Listen for focus changed in any subview, so the framework is notified when the platform
652 // view is focused.
653 viewWrapper.setOnDescendantFocusChangeListener(
654 (v, hasFocus) -> {
655 if (hasFocus) {
656 platformViewsChannel.invokeViewFocused(request.viewId);
657 } else if (textInputPlugin != null) {
658 textInputPlugin.clearPlatformViewClient(request.viewId);
659 }
660 });
661
662 flutterView.addView(viewWrapper);
663 viewWrappers.append(request.viewId, viewWrapper);
664
665 maybeInvokeOnFlutterViewAttached(platformView);
666
667 return textureId;
668 }
void Log(const char *format,...) SK_PRINTF_LIKE(1

◆ createOverlaySurface() [1/2]

FlutterOverlaySurface io.flutter.plugin.platform.PlatformViewsController.createOverlaySurface ( )
inline

Creates an overlay surface while the Flutter view is rendered by PlatformOverlayView.

This method is invoked by FlutterJNI only.

This member is not intended for public use, and is only visible for testing.

Definition at line 1306 of file PlatformViewsController.java.

1306 {
1307 // Overlay surfaces have the same size as the background surface.
1308 //
1309 // This allows to reuse these surfaces in consecutive frames even
1310 // if the drawings they contain have a different tight bound.
1311 //
1312 // The final view size is determined when its frame is set.
1313 return createOverlaySurface(
1314 new PlatformOverlayView(
1315 flutterView.getContext(),
1316 flutterView.getWidth(),
1317 flutterView.getHeight(),
1318 accessibilityEventsDelegate));
1319 }

◆ createOverlaySurface() [2/2]

FlutterOverlaySurface io.flutter.plugin.platform.PlatformViewsController.createOverlaySurface ( @NonNull PlatformOverlayView  imageView)
inline

Creates and tracks the overlay surface.

Parameters
imageViewThe surface that displays the overlay.
Returns
Wrapper object that provides the layer id and the surface. This member is not intended for public use, and is only visible for testing.

Definition at line 1292 of file PlatformViewsController.java.

1292 {
1293 final int id = nextOverlayLayerId++;
1294 overlayLayerViews.put(id, imageView);
1295 return new FlutterOverlaySurface(id, imageView.getSurface());
1296 }

◆ createPlatformView()

PlatformView io.flutter.plugin.platform.PlatformViewsController.createPlatformView ( @NonNull PlatformViewsChannel.PlatformViewCreationRequest  request,
boolean  wrapContext 
)
inline

Definition at line 506 of file PlatformViewsController.java.

507 {
508 final PlatformViewFactory viewFactory = registry.getFactory(request.viewType);
509 if (viewFactory == null) {
510 throw new IllegalStateException(
511 "Trying to create a platform view of unregistered type: " + request.viewType);
512 }
513
514 Object createParams = null;
515 if (request.params != null) {
516 createParams = viewFactory.getCreateArgsCodec().decodeMessage(request.params);
517 }
518
519 // In some display modes, the context needs to be modified during display.
520 // TODO(stuartmorgan): Make this wrapping unconditional if possible; for context see
521 // https://github.com/flutter/flutter/issues/113449
522 final Context mutableContext = wrapContext ? new MutableContextWrapper(context) : context;
523 final PlatformView platformView =
524 viewFactory.create(mutableContext, request.viewId, createParams);
525
526 // Configure the view to match the requested layout direction.
527 final View embeddedView = platformView.getView();
528 if (embeddedView == null) {
529 throw new IllegalStateException(
530 "PlatformView#getView() returned null, but an Android view reference was expected.");
531 }
532 embeddedView.setLayoutDirection(request.direction);
533 platformViews.put(request.viewId, platformView);
534 maybeInvokeOnFlutterViewAttached(platformView);
535 return platformView;
536 }

◆ destroyOverlaySurfaces()

void io.flutter.plugin.platform.PlatformViewsController.destroyOverlaySurfaces ( )
inline

Destroys the overlay surfaces and removes them from the view hierarchy.

This method is used only internally by FlutterJNI.

Definition at line 1326 of file PlatformViewsController.java.

1326 {
1327 for (int viewId = 0; viewId < overlayLayerViews.size(); viewId++) {
1328 final PlatformOverlayView overlayView = overlayLayerViews.valueAt(viewId);
1329 overlayView.detachFromRenderer();
1330 overlayView.closeImageReader();
1331 // Don't remove overlayView from the view hierarchy since this method can
1332 // be called while the Android framework is iterating over the array of views.
1333 // See ViewGroup#dispatchDetachedFromWindow(), and
1334 // https://github.com/flutter/flutter/issues/97679.
1335 }
1336 }

◆ detach()

void io.flutter.plugin.platform.PlatformViewsController.detach ( )
inline

Detaches this platform views controller.

This is typically called when a Flutter applications moves to run in the background, or is destroyed. After calling this the platform views controller will no longer listen to it's previous messenger, and will not maintain references to the texture registry, context, and messenger passed to the previous attach call.

Definition at line 780 of file PlatformViewsController.java.

780 {
781 if (platformViewsChannel != null) {
782 platformViewsChannel.setPlatformViewsHandler(null);
783 }
785 platformViewsChannel = null;
786 context = null;
787 textureRegistry = null;
788 }

◆ detachAccessibilityBridge()

void io.flutter.plugin.platform.PlatformViewsController.detachAccessibilityBridge ( )
inline

Detaches the current accessibility bridge.

Any accessibility events sent by platform views belonging to this delegate will be ignored until a new accessibility bridge is attached.

Implements io.flutter.plugin.platform.PlatformViewsAccessibilityDelegate.

Definition at line 861 of file PlatformViewsController.java.

861 {
862 accessibilityEventsDelegate.setAccessibilityBridge(null);
863 }

◆ detachFromView()

void io.flutter.plugin.platform.PlatformViewsController.detachFromView ( )
inline

Detaches the controller from FlutterView.

When io.flutter.embedding.android.FlutterFragment is used, this method is called when the device rotates since the FlutterView is detached from the fragment. The next time the fragment needs to be displayed, a new Flutter view is created, so attachToView is called again.

Definition at line 822 of file PlatformViewsController.java.

822 {
823 // Remove wrapper for platform views that use GL texture.
824 for (int index = 0; index < viewWrappers.size(); index++) {
825 final PlatformViewWrapper view = viewWrappers.valueAt(index);
826 flutterView.removeView(view);
827 }
828 // Remove wrapper for platform views that are composed at the view hierarchy level.
829 for (int index = 0; index < platformViewParent.size(); index++) {
830 final FlutterMutatorView view = platformViewParent.valueAt(index);
831 flutterView.removeView(view);
832 }
833
835 removeOverlaySurfaces();
836 flutterView = null;
837 flutterViewConvertedToImageView = false;
838
839 // Notify that the platform view have been detached from FlutterView.
840 for (int index = 0; index < platformViews.size(); index++) {
841 final PlatformView view = platformViews.valueAt(index);
842 view.onFlutterViewDetached();
843 }
844 }

◆ detachTextInputPlugin()

void io.flutter.plugin.platform.PlatformViewsController.detachTextInputPlugin ( )
inline

Detaches this controller from the currently attached text input plugin.

Definition at line 879 of file PlatformViewsController.java.

879 {
880 textInputPlugin = null;
881 }

◆ disposePlatformView()

void io.flutter.plugin.platform.PlatformViewsController.disposePlatformView ( int  viewId)
inline

Disposes a single

Parameters
viewIdthe PlatformView ID.

Definition at line 1062 of file PlatformViewsController.java.

1062 {
1063 channelHandler.dispose(viewId);
1064 }

◆ getOverlayLayerViews()

SparseArray< PlatformOverlayView > io.flutter.plugin.platform.PlatformViewsController.getOverlayLayerViews ( )
inline

Definition at line 1350 of file PlatformViewsController.java.

1350 {
1351 return overlayLayerViews;
1352 }

◆ getPlatformViewById()

View io.flutter.plugin.platform.PlatformViewsController.getPlatformViewById ( int  viewId)
inline

Returns the root of the view hierarchy for the platform view with the requested id, or null if there is no corresponding view.

Implements io.flutter.plugin.platform.PlatformViewsAccessibilityDelegate.

Definition at line 932 of file PlatformViewsController.java.

932 {
933 if (usesVirtualDisplay(viewId)) {
934 final VirtualDisplayController controller = vdControllers.get(viewId);
935 return controller.getView();
936 }
937
938 final PlatformView platformView = platformViews.get(viewId);
939 if (platformView == null) {
940 return null;
941 }
942 return platformView.getView();
943 }

◆ getRegistry()

PlatformViewRegistry io.flutter.plugin.platform.PlatformViewsController.getRegistry ( )
inline

Definition at line 906 of file PlatformViewsController.java.

906 {
907 return registry;
908 }

◆ initializePlatformViewIfNeeded()

void io.flutter.plugin.platform.PlatformViewsController.initializePlatformViewIfNeeded ( int  viewId)
inlinepackage

Initializes a platform view and adds it to the view hierarchy.

Parameters
viewIdThe view ID. This member is not intended for public use, and is only visible for testing.

Definition at line 1080 of file PlatformViewsController.java.

1080 {
1081 final PlatformView platformView = platformViews.get(viewId);
1082 if (platformView == null) {
1083 throw new IllegalStateException(
1084 "Platform view hasn't been initialized from the platform view channel.");
1085 }
1086 if (platformViewParent.get(viewId) != null) {
1087 return;
1088 }
1089 final View embeddedView = platformView.getView();
1090 if (embeddedView == null) {
1091 throw new IllegalStateException(
1092 "PlatformView#getView() returned null, but an Android view reference was expected.");
1093 }
1094 if (embeddedView.getParent() != null) {
1095 throw new IllegalStateException(
1096 "The Android view returned from PlatformView#getView() was already added to a parent"
1097 + " view.");
1098 }
1099 final FlutterMutatorView parentView =
1101 context, context.getResources().getDisplayMetrics().density, androidTouchProcessor);
1102
1103 parentView.setOnDescendantFocusChangeListener(
1104 (view, hasFocus) -> {
1105 if (hasFocus) {
1106 platformViewsChannel.invokeViewFocused(viewId);
1107 } else if (textInputPlugin != null) {
1108 textInputPlugin.clearPlatformViewClient(viewId);
1109 }
1110 });
1111
1112 platformViewParent.put(viewId, parentView);
1113
1114 // Accessibility in the embedded view is initially disabled because if a Flutter app disabled
1115 // accessibility in the first frame, the embedding won't receive an update to disable
1116 // accessibility since the embedding never received an update to enable it.
1117 // The AccessibilityBridge keeps track of the accessibility nodes, and handles the deltas when
1118 // the framework sends a new a11y tree to the embedding.
1119 // To prevent races, the framework populate the SemanticsNode after the platform view has been
1120 // created.
1121 embeddedView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
1122
1123 parentView.addView(embeddedView);
1124 flutterView.addView(parentView);
1125 }

◆ onAttachedToJNI()

void io.flutter.plugin.platform.PlatformViewsController.onAttachedToJNI ( )
inline

Invoked when the io.flutter.embedding.engine.FlutterEngine that owns this PlatformViewsController attaches to JNI.

Definition at line 914 of file PlatformViewsController.java.

914 {
915 // Currently no action needs to be taken after JNI attachment.
916 }

◆ onBeginFrame()

void io.flutter.plugin.platform.PlatformViewsController.onBeginFrame ( )
inline

Definition at line 1201 of file PlatformViewsController.java.

1201 {
1202 currentFrameUsedOverlayLayerIds.clear();
1203 currentFrameUsedPlatformViewIds.clear();
1204 }

◆ onDetachedFromJNI()

void io.flutter.plugin.platform.PlatformViewsController.onDetachedFromJNI ( )
inline

Invoked when the io.flutter.embedding.engine.FlutterEngine that owns this PlatformViewsController detaches from JNI.

Definition at line 922 of file PlatformViewsController.java.

922 {
923 diposeAllViews();
924 }

◆ onDisplayOverlaySurface()

void io.flutter.plugin.platform.PlatformViewsController.onDisplayOverlaySurface ( int  id,
int  x,
int  y,
int  width,
int  height 
)
inline

Called when an overlay surface is displayed in the current frame.

Parameters
idThe ID of the surface.
xThe left position relative to FlutterView.
yThe top position relative to FlutterView.
widthThe width of the surface.
heightThe height of the surface. This member is not intended for public use, and is only visible for testing.

Definition at line 1181 of file PlatformViewsController.java.

1181 {
1182 if (overlayLayerViews.get(id) == null) {
1183 throw new IllegalStateException("The overlay surface (id:" + id + ") doesn't exist");
1184 }
1185 initializeRootImageViewIfNeeded();
1186
1187 final PlatformOverlayView overlayView = overlayLayerViews.get(id);
1188 if (overlayView.getParent() == null) {
1189 flutterView.addView(overlayView);
1190 }
1191
1192 FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams((int) width, (int) height);
1193 layoutParams.leftMargin = (int) x;
1194 layoutParams.topMargin = (int) y;
1195 overlayView.setLayoutParams(layoutParams);
1196 overlayView.setVisibility(View.VISIBLE);
1197 overlayView.bringToFront();
1198 currentFrameUsedOverlayLayerIds.add(id);
1199 }
Type::kYUV Type::kRGBA() int(0.7 *637)
double y
double x
int32_t height
int32_t width

◆ onDisplayPlatformView()

void io.flutter.plugin.platform.PlatformViewsController.onDisplayPlatformView ( int  viewId,
int  x,
int  y,
int  width,
int  height,
int  viewWidth,
int  viewHeight,
@NonNull FlutterMutatorsStack  mutatorsStack 
)
inline

Called when a platform view id displayed in the current frame.

Parameters
viewIdThe ID of the platform view.
xThe left position relative to FlutterView.
yThe top position relative to FlutterView.
widthThe width of the platform view.
heightThe height of the platform view.
viewWidthThe original width of the platform view before applying the mutator stack.
viewHeightThe original height of the platform view before applying the mutator stack.
mutatorsStackThe mutator stack. This member is not intended for public use, and is only visible for testing.

Definition at line 1144 of file PlatformViewsController.java.

1152 {
1153 initializeRootImageViewIfNeeded();
1155
1156 final FlutterMutatorView parentView = platformViewParent.get(viewId);
1157 parentView.readyToDisplay(mutatorsStack, x, y, width, height);
1158 parentView.setVisibility(View.VISIBLE);
1159 parentView.bringToFront();
1160
1161 final FrameLayout.LayoutParams layoutParams =
1162 new FrameLayout.LayoutParams(viewWidth, viewHeight);
1163 final View view = platformViews.get(viewId).getView();
1164 if (view != null) {
1165 view.setLayoutParams(layoutParams);
1166 view.bringToFront();
1167 }
1168 currentFrameUsedPlatformViewIds.add(viewId);
1169 }

◆ onEndFrame()

void io.flutter.plugin.platform.PlatformViewsController.onEndFrame ( )
inline

Called by FlutterJNI when the Flutter frame was submitted.

This member is not intended for public use, and is only visible for testing.

Definition at line 1211 of file PlatformViewsController.java.

1211 {
1212 // If there are no platform views in the current frame,
1213 // then revert the image view surface and use the previous surface.
1214 //
1215 // Otherwise, acquire the latest image.
1216 if (flutterViewConvertedToImageView && currentFrameUsedPlatformViewIds.isEmpty()) {
1217 flutterViewConvertedToImageView = false;
1218 flutterView.revertImageView(
1219 () -> {
1220 // Destroy overlay surfaces once the surface reversion is completed.
1221 finishFrame(false);
1222 });
1223 return;
1224 }
1225 // Whether the current frame was rendered using ImageReaders.
1226 //
1227 // Since the image readers may not have images available at this point,
1228 // this becomes true if all the required surfaces have images available.
1229 //
1230 // This is used to decide if the platform views can be rendered in the current frame.
1231 // If one of the surfaces doesn't have an image, the frame may be incomplete and must be
1232 // dropped.
1233 // For example, a toolbar widget painted by Flutter may not be rendered.
1234 final boolean isFrameRenderedUsingImageReaders =
1235 flutterViewConvertedToImageView && flutterView.acquireLatestImageViewFrame();
1236 finishFrame(isFrameRenderedUsingImageReaders);
1237 }

◆ onPreEngineRestart()

void io.flutter.plugin.platform.PlatformViewsController.onPreEngineRestart ( )
inline

Definition at line 926 of file PlatformViewsController.java.

926 {
927 diposeAllViews();
928 }

◆ setSoftwareRendering()

void io.flutter.plugin.platform.PlatformViewsController.setSoftwareRendering ( boolean  useSoftwareRendering)
inline

Sets whether Flutter uses software rendering.

When software rendering is used, no GL context is available on the raster thread. When this is set to true, there's no Flutter composition of Android views and Flutter widgets since GL textures cannot be used.

Software rendering is only used for testing in emulators, and it should never be set to true in a production environment.

Parameters
useSoftwareRenderingWhether software rendering is used.

Definition at line 767 of file PlatformViewsController.java.

767 {
768 usesSoftwareRendering = useSoftwareRendering;
769 }

◆ toMotionEvent()

MotionEvent io.flutter.plugin.platform.PlatformViewsController.toMotionEvent ( float  density,
PlatformViewsChannel.PlatformViewTouch  touch,
boolean  usingVirtualDiplay 
)
inline

Definition at line 671 of file PlatformViewsController.java.

672 {
673 MotionEventTracker.MotionEventId motionEventId =
674 MotionEventTracker.MotionEventId.from(touch.motionEventId);
675 MotionEvent trackedEvent = motionEventTracker.pop(motionEventId);
676
677 if (!usingVirtualDiplay && trackedEvent != null) {
678 // We have the original event, deliver it as it will pass the verifiable
679 // input check.
680 return trackedEvent;
681 }
682 // We are in virtual display mode or don't have a reference to the original MotionEvent.
683 // In this case we manually recreate a MotionEvent to be delivered. This MotionEvent
684 // will fail the verifiable input check.
685
686 // Pointer coordinates in the tracked events are global to FlutterView
687 // framework converts them to be local to a widget, given that
688 // motion events operate on local coords, we need to replace these in the tracked
689 // event with their local counterparts.
690 PointerProperties[] pointerProperties =
691 parsePointerPropertiesList(touch.rawPointerPropertiesList)
692 .toArray(new PointerProperties[touch.pointerCount]);
693 PointerCoords[] pointerCoords =
694 parsePointerCoordsList(touch.rawPointerCoords, density)
695 .toArray(new PointerCoords[touch.pointerCount]);
696
697 // TODO (kaushikiska) : warn that we are potentially using an untracked
698 // event in the platform views.
699 return MotionEvent.obtain(
700 touch.downTime.longValue(),
701 touch.eventTime.longValue(),
702 touch.action,
703 touch.pointerCount,
704 pointerProperties,
705 pointerCoords,
706 touch.metaState,
707 touch.buttonState,
708 touch.xPrecision,
709 touch.yPrecision,
710 touch.deviceId,
711 touch.edgeFlags,
712 touch.source,
713 touch.flags);
714 }

◆ usesVirtualDisplay()

boolean io.flutter.plugin.platform.PlatformViewsController.usesVirtualDisplay ( int  id)
inline

Returns true if the platform view uses virtual displays.

Implements io.flutter.plugin.platform.PlatformViewsAccessibilityDelegate.

Definition at line 946 of file PlatformViewsController.java.

946 {
947 return vdControllers.containsKey(id);
948 }

Member Data Documentation

◆ contextToEmbeddedView

final HashMap<Context, View> io.flutter.plugin.platform.PlatformViewsController.contextToEmbeddedView
package

Definition at line 99 of file PlatformViewsController.java.

◆ vdControllers

final HashMap<Integer, VirtualDisplayController> io.flutter.plugin.platform.PlatformViewsController.vdControllers
package

Definition at line 93 of file PlatformViewsController.java.


The documentation for this class was generated from the following file: