Flutter Engine
The Flutter Engine
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 onTrimMemory (int level)
 
void onResume ()
 
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 ()
 
View getPlatformViewById (int viewId)
 
boolean usesVirtualDisplay (int id)
 
void attachAccessibilityBridge (@NonNull AccessibilityBridge accessibilityBridge)
 
void detachAccessibilityBridge ()
 

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 51 of file PlatformViewsController.java.

Constructor & Destructor Documentation

◆ PlatformViewsController()

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

Definition at line 736 of file PlatformViewsController.java.

736 {
737 registry = new PlatformViewRegistryImpl();
738 vdControllers = new HashMap<>();
739 accessibilityEventsDelegate = new AccessibilityEventsDelegate();
740 contextToEmbeddedView = new HashMap<>();
741 overlayLayerViews = new SparseArray<>();
742 currentFrameUsedOverlayLayerIds = new HashSet<>();
743 currentFrameUsedPlatformViewIds = new HashSet<>();
744 viewWrappers = new SparseArray<>();
745 platformViews = new SparseArray<>();
746 platformViewParent = new SparseArray<>();
747
748 motionEventTracker = MotionEventTracker.getInstance();
749 }
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 760 of file PlatformViewsController.java.

763 {
764 if (this.context != null) {
765 throw new AssertionError(
766 "A PlatformViewsController can only be attached to a single output target.\n"
767 + "attach was called while the PlatformViewsController was already attached.");
768 }
769 this.context = context;
770 this.textureRegistry = textureRegistry;
771 platformViewsChannel = new PlatformViewsChannel(dartExecutor);
772 platformViewsChannel.setPlatformViewsHandler(channelHandler);
773 }
void setPlatformViewsHandler(@Nullable PlatformViewsHandler handler)

◆ 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 876 of file PlatformViewsController.java.

876 {
877 accessibilityEventsDelegate.setAccessibilityBridge(accessibilityBridge);
878 }
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 894 of file PlatformViewsController.java.

894 {
895 this.textInputPlugin = textInputPlugin;
896 }

◆ attachToFlutterRenderer()

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

Definition at line 1165 of file PlatformViewsController.java.

1165 {
1166 androidTouchProcessor = new AndroidTouchProcessor(flutterRenderer, /*trackMotionEvents=*/ true);
1167 }

◆ 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 816 of file PlatformViewsController.java.

816 {
817 flutterView = newFlutterView;
818 // Add wrapper for platform views that use GL texture.
819 for (int index = 0; index < viewWrappers.size(); index++) {
820 final PlatformViewWrapper view = viewWrappers.valueAt(index);
821 flutterView.addView(view);
822 }
823 // Add wrapper for platform views that are composed at the view hierarchy level.
824 for (int index = 0; index < platformViewParent.size(); index++) {
825 final FlutterMutatorView view = platformViewParent.valueAt(index);
826 flutterView.addView(view);
827 }
828 // Notify platform views that they are now attached to a FlutterView.
829 for (int index = 0; index < platformViews.size(); index++) {
830 final PlatformView view = platformViews.valueAt(index);
831 view.onFlutterViewAttached(flutterView);
832 }
833 }

◆ 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 910 of file PlatformViewsController.java.

910 {
911 // View can be null on some devices
912 // See: https://github.com/flutter/flutter/issues/36517
913 if (view == null) {
914 return false;
915 }
916 if (!contextToEmbeddedView.containsKey(view.getContext())) {
917 return false;
918 }
919 View platformView = contextToEmbeddedView.get(view.getContext());
920 if (platformView == view) {
921 return true;
922 }
923 return platformView.checkInputConnectionProxy(view);
924 }

◆ configureForTextureLayerComposition()

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

Definition at line 598 of file PlatformViewsController.java.

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

◆ 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 1344 of file PlatformViewsController.java.

1344 {
1345 // Overlay surfaces have the same size as the background surface.
1346 //
1347 // This allows to reuse these surfaces in consecutive frames even
1348 // if the drawings they contain have a different tight bound.
1349 //
1350 // The final view size is determined when its frame is set.
1351 return createOverlaySurface(
1352 new PlatformOverlayView(
1353 flutterView.getContext(),
1354 flutterView.getWidth(),
1355 flutterView.getHeight(),
1356 accessibilityEventsDelegate));
1357 }

◆ 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 1330 of file PlatformViewsController.java.

1330 {
1331 final int id = nextOverlayLayerId++;
1332 overlayLayerViews.put(id, imageView);
1333 return new FlutterOverlaySurface(id, imageView.getSurface());
1334 }

◆ createPlatformView()

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

Definition at line 505 of file PlatformViewsController.java.

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

◆ 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 1364 of file PlatformViewsController.java.

1364 {
1365 for (int viewId = 0; viewId < overlayLayerViews.size(); viewId++) {
1366 final PlatformOverlayView overlayView = overlayLayerViews.valueAt(viewId);
1367 overlayView.detachFromRenderer();
1368 overlayView.closeImageReader();
1369 // Don't remove overlayView from the view hierarchy since this method can
1370 // be called while the Android framework is iterating over the array of views.
1371 // See ViewGroup#dispatchDetachedFromWindow(), and
1372 // https://github.com/flutter/flutter/issues/97679.
1373 }
1374 }

◆ 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 800 of file PlatformViewsController.java.

800 {
801 if (platformViewsChannel != null) {
802 platformViewsChannel.setPlatformViewsHandler(null);
803 }
805 platformViewsChannel = null;
806 context = null;
807 textureRegistry = null;
808 }

◆ 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 881 of file PlatformViewsController.java.

881 {
882 accessibilityEventsDelegate.setAccessibilityBridge(null);
883 }

◆ 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 842 of file PlatformViewsController.java.

842 {
843 // Remove wrapper for platform views that use GL texture.
844 for (int index = 0; index < viewWrappers.size(); index++) {
845 final PlatformViewWrapper view = viewWrappers.valueAt(index);
846 flutterView.removeView(view);
847 }
848 // Remove wrapper for platform views that are composed at the view hierarchy level.
849 for (int index = 0; index < platformViewParent.size(); index++) {
850 final FlutterMutatorView view = platformViewParent.valueAt(index);
851 flutterView.removeView(view);
852 }
853
855 removeOverlaySurfaces();
856 flutterView = null;
857 flutterViewConvertedToImageView = false;
858
859 // Notify that the platform view have been detached from FlutterView.
860 for (int index = 0; index < platformViews.size(); index++) {
861 final PlatformView view = platformViews.valueAt(index);
862 view.onFlutterViewDetached();
863 }
864 }

◆ detachTextInputPlugin()

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

Detaches this controller from the currently attached text input plugin.

Definition at line 899 of file PlatformViewsController.java.

899 {
900 textInputPlugin = null;
901 }

◆ disposePlatformView()

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

Disposes a single

Parameters
viewIdthe PlatformView ID.

Definition at line 1100 of file PlatformViewsController.java.

1100 {
1101 channelHandler.dispose(viewId);
1102 }

◆ getOverlayLayerViews()

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

Definition at line 1388 of file PlatformViewsController.java.

1388 {
1389 return overlayLayerViews;
1390 }

◆ 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 952 of file PlatformViewsController.java.

952 {
953 if (usesVirtualDisplay(viewId)) {
954 final VirtualDisplayController controller = vdControllers.get(viewId);
955 return controller.getView();
956 }
957
958 final PlatformView platformView = platformViews.get(viewId);
959 if (platformView == null) {
960 return null;
961 }
962 return platformView.getView();
963 }

◆ getRegistry()

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

Definition at line 926 of file PlatformViewsController.java.

926 {
927 return registry;
928 }

◆ 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 1118 of file PlatformViewsController.java.

1118 {
1119 final PlatformView platformView = platformViews.get(viewId);
1120 if (platformView == null) {
1121 throw new IllegalStateException(
1122 "Platform view hasn't been initialized from the platform view channel.");
1123 }
1124 if (platformViewParent.get(viewId) != null) {
1125 return;
1126 }
1127 final View embeddedView = platformView.getView();
1128 if (embeddedView == null) {
1129 throw new IllegalStateException(
1130 "PlatformView#getView() returned null, but an Android view reference was expected.");
1131 }
1132 if (embeddedView.getParent() != null) {
1133 throw new IllegalStateException(
1134 "The Android view returned from PlatformView#getView() was already added to a parent"
1135 + " view.");
1136 }
1137 final FlutterMutatorView parentView =
1139 context, context.getResources().getDisplayMetrics().density, androidTouchProcessor);
1140
1142 (view, hasFocus) -> {
1143 if (hasFocus) {
1144 platformViewsChannel.invokeViewFocused(viewId);
1145 } else if (textInputPlugin != null) {
1146 textInputPlugin.clearPlatformViewClient(viewId);
1147 }
1148 });
1149
1150 platformViewParent.put(viewId, parentView);
1151
1152 // Accessibility in the embedded view is initially disabled because if a Flutter app disabled
1153 // accessibility in the first frame, the embedding won't receive an update to disable
1154 // accessibility since the embedding never received an update to enable it.
1155 // The AccessibilityBridge keeps track of the accessibility nodes, and handles the deltas when
1156 // the framework sends a new a11y tree to the embedding.
1157 // To prevent races, the framework populate the SemanticsNode after the platform view has been
1158 // created.
1159 embeddedView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
1160
1161 parentView.addView(embeddedView);
1162 flutterView.addView(parentView);
1163 }
void setOnDescendantFocusChangeListener(@NonNull OnFocusChangeListener userFocusListener)

◆ 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 934 of file PlatformViewsController.java.

934 {
935 // Currently no action needs to be taken after JNI attachment.
936 }

◆ onBeginFrame()

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

Definition at line 1239 of file PlatformViewsController.java.

1239 {
1240 currentFrameUsedOverlayLayerIds.clear();
1241 currentFrameUsedPlatformViewIds.clear();
1242 }

◆ 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 942 of file PlatformViewsController.java.

942 {
943 diposeAllViews();
944 }

◆ 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 1219 of file PlatformViewsController.java.

1219 {
1220 if (overlayLayerViews.get(id) == null) {
1221 throw new IllegalStateException("The overlay surface (id:" + id + ") doesn't exist");
1222 }
1223 initializeRootImageViewIfNeeded();
1224
1225 final PlatformOverlayView overlayView = overlayLayerViews.get(id);
1226 if (overlayView.getParent() == null) {
1227 flutterView.addView(overlayView);
1228 }
1229
1230 FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams((int) width, (int) height);
1231 layoutParams.leftMargin = (int) x;
1232 layoutParams.topMargin = (int) y;
1233 overlayView.setLayoutParams(layoutParams);
1234 overlayView.setVisibility(View.VISIBLE);
1235 overlayView.bringToFront();
1236 currentFrameUsedOverlayLayerIds.add(id);
1237 }
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 1182 of file PlatformViewsController.java.

1190 {
1191 initializeRootImageViewIfNeeded();
1193
1194 final FlutterMutatorView parentView = platformViewParent.get(viewId);
1195 parentView.readyToDisplay(mutatorsStack, x, y, width, height);
1196 parentView.setVisibility(View.VISIBLE);
1197 parentView.bringToFront();
1198
1199 final FrameLayout.LayoutParams layoutParams =
1200 new FrameLayout.LayoutParams(viewWidth, viewHeight);
1201 final View view = platformViews.get(viewId).getView();
1202 if (view != null) {
1203 view.setLayoutParams(layoutParams);
1204 view.bringToFront();
1205 }
1206 currentFrameUsedPlatformViewIds.add(viewId);
1207 }
void readyToDisplay( @NonNull FlutterMutatorsStack mutatorsStack, int left, int top, int width, int height)

◆ 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 1249 of file PlatformViewsController.java.

1249 {
1250 // If there are no platform views in the current frame,
1251 // then revert the image view surface and use the previous surface.
1252 //
1253 // Otherwise, acquire the latest image.
1254 if (flutterViewConvertedToImageView && currentFrameUsedPlatformViewIds.isEmpty()) {
1255 flutterViewConvertedToImageView = false;
1256 flutterView.revertImageView(
1257 () -> {
1258 // Destroy overlay surfaces once the surface reversion is completed.
1259 finishFrame(false);
1260 });
1261 return;
1262 }
1263 // Whether the current frame was rendered using ImageReaders.
1264 //
1265 // Since the image readers may not have images available at this point,
1266 // this becomes true if all the required surfaces have images available.
1267 //
1268 // This is used to decide if the platform views can be rendered in the current frame.
1269 // If one of the surfaces doesn't have an image, the frame may be incomplete and must be
1270 // dropped.
1271 // For example, a toolbar widget painted by Flutter may not be rendered.
1272 final boolean isFrameRenderedUsingImageReaders =
1273 flutterViewConvertedToImageView && flutterView.acquireLatestImageViewFrame();
1274 finishFrame(isFrameRenderedUsingImageReaders);
1275 }
void revertImageView(@NonNull Runnable onDone)

◆ onPreEngineRestart()

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

Definition at line 946 of file PlatformViewsController.java.

946 {
947 diposeAllViews();
948 }

◆ onResume()

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

Definition at line 1088 of file PlatformViewsController.java.

1088 {
1089 for (VirtualDisplayController vdc : vdControllers.values()) {
1090 vdc.resetSurface();
1091 }
1092 }

◆ onTrimMemory()

void io.flutter.plugin.platform.PlatformViewsController.onTrimMemory ( int  level)
inline

Definition at line 1077 of file PlatformViewsController.java.

1077 {
1078 if (level < ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) {
1079 return;
1080 }
1081 for (VirtualDisplayController vdc : vdControllers.values()) {
1082 vdc.clearSurface();
1083 }
1084 }

◆ 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 787 of file PlatformViewsController.java.

787 {
788 usesSoftwareRendering = useSoftwareRendering;
789 }

◆ toMotionEvent()

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

Definition at line 689 of file PlatformViewsController.java.

690 {
691 MotionEventTracker.MotionEventId motionEventId =
692 MotionEventTracker.MotionEventId.from(touch.motionEventId);
693 MotionEvent trackedEvent = motionEventTracker.pop(motionEventId);
694
695 // Pointer coordinates in the tracked events are global to FlutterView
696 // The framework converts them to be local to a widget, given that
697 // motion events operate on local coords, we need to replace these in the tracked
698 // event with their local counterparts.
699 // Compute this early so it can be used as input to translateNonVirtualDisplayMotionEvent.
700 PointerCoords[] pointerCoords =
701 parsePointerCoordsList(touch.rawPointerCoords, density)
702 .toArray(new PointerCoords[touch.pointerCount]);
703
704 if (!usingVirtualDiplay && trackedEvent != null) {
705 // We have the original event, deliver it after offsetting as it will pass the verifiable
706 // input check.
707 translateMotionEvent(trackedEvent, pointerCoords);
708 return trackedEvent;
709 }
710 // We are in virtual display mode or don't have a reference to the original MotionEvent.
711 // In this case we manually recreate a MotionEvent to be delivered. This MotionEvent
712 // will fail the verifiable input check.
713 PointerProperties[] pointerProperties =
714 parsePointerPropertiesList(touch.rawPointerPropertiesList)
715 .toArray(new PointerProperties[touch.pointerCount]);
716
717 // TODO (kaushikiska) : warn that we are potentially using an untracked
718 // event in the platform views.
719 return MotionEvent.obtain(
720 touch.downTime.longValue(),
721 touch.eventTime.longValue(),
722 touch.action,
723 touch.pointerCount,
724 pointerProperties,
725 pointerCoords,
726 touch.metaState,
727 touch.buttonState,
728 touch.xPrecision,
729 touch.yPrecision,
730 touch.deviceId,
731 touch.edgeFlags,
732 touch.source,
733 touch.flags);
734 }
MotionEvent pop(@NonNull MotionEventId eventId)

◆ 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 966 of file PlatformViewsController.java.

966 {
967 return vdControllers.containsKey(id);
968 }

Member Data Documentation

◆ contextToEmbeddedView

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

Definition at line 98 of file PlatformViewsController.java.

◆ vdControllers

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

Definition at line 92 of file PlatformViewsController.java.


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