Add onDisplayOverlaySurface JNI (flutter/engine#18859)

This commit is contained in:
cg021
2020-06-09 19:07:53 -05:00
committed by GitHub
parent 86e7ef2334
commit 06a0d3ac93
5 changed files with 39 additions and 4 deletions

View File

@@ -103,10 +103,6 @@ public class FlutterEngine {
platformViewsController.onPreEngineRestart();
}
public void onDisplayPlatformView(int viewId, int x, int y, int width, int height) {
platformViewsController.onDisplayPlatformView(viewId, x, y, width, height);
}
};
/**

View File

@@ -788,6 +788,17 @@ public class FlutterJNI {
listener.onPreEngineRestart();
}
}
@SuppressWarnings("unused")
@UiThread
public void onDisplayOverlaySurface(int id, int x, int y, int width, int height) {
ensureRunningOnMainThread();
if (platformViewsController == null) {
throw new RuntimeException(
"platformViewsController must be set before attempting to position an overlay surface");
}
platformViewsController.onDisplayOverlaySurface(id, x, y, width, height);
}
// ----- End Engine Lifecycle Support ----
// @SuppressWarnings("unused")

View File

@@ -537,4 +537,8 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
public void onDisplayPlatformView(int viewId, int x, int y, int width, int height) {
// TODO: Implement this method. https://github.com/flutter/flutter/issues/58288
}
public void onDisplayOverlaySurface(int id, int x, int y, int width, int height) {
// TODO: Implement this method. https://github.com/flutter/flutter/issues/58288
}
}

View File

@@ -44,6 +44,14 @@ void FlutterViewOnDisplayPlatformView(JNIEnv* env,
jint width,
jint height);
void FlutterViewDisplayOverlaySurface(JNIEnv* env,
jobject obj,
jint id,
jint x,
jint y,
jint width,
jint height);
void SurfaceTextureAttachToGLContext(JNIEnv* env, jobject obj, jint textureId);
void SurfaceTextureUpdateTexImage(JNIEnv* env, jobject obj);

View File

@@ -65,4 +65,20 @@ public class FlutterJNITest {
.onDisplayPlatformView(
/*viewId=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200);
}
@Test
public void onDisplayOverlaySurface__callsPlatformViewsController() {
PlatformViewsController platformViewsController = mock(PlatformViewsController.class);
FlutterJNI flutterJNI = new FlutterJNI();
flutterJNI.setPlatformViewsController(platformViewsController);
// --- Execute Test ---
flutterJNI.onDisplayOverlaySurface(
/*id=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200);
// --- Verify Results ---
verify(platformViewsController, times(1))
.onDisplayOverlaySurface(/*id=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200);
}
}