Reland "Branch out android platform view perf testing (#60238)" (#61554)

This commit is contained in:
Chris Yang
2020-07-16 11:23:52 -07:00
committed by GitHub
parent c78578417d
commit 63ceeb8f15
48 changed files with 1277 additions and 30 deletions

View File

@@ -1,49 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
class AndroidPlatformView extends StatelessWidget {
/// Creates a platform view for Android, which is rendered as a
/// native view.
/// `viewType` identifies the type of Android view to create.
const AndroidPlatformView({
Key key,
@required this.viewType,
}) : assert(viewType != null),
super(key: key);
/// The unique identifier for the view type to be embedded by this widget.
///
/// A PlatformViewFactory for this type must have been registered.
final String viewType;
@override
Widget build(BuildContext context) {
return PlatformViewLink(
viewType: viewType,
surfaceFactory:
(BuildContext context, PlatformViewController controller) {
return AndroidViewSurface(
controller: controller as AndroidViewController,
gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
);
},
onCreatePlatformView: (PlatformViewCreationParams params) {
return PlatformViewsService.initAndroidView(
id: params.id,
viewType: params.viewType,
layoutDirection: TextDirection.ltr,
)
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
..create();
},
);
}
}

View File

@@ -7,8 +7,6 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
import 'android_platform_view.dart';
void main() {
runApp(
const PlatformViewApp()
@@ -17,13 +15,9 @@ void main() {
class PlatformViewApp extends StatefulWidget {
const PlatformViewApp({
Key key,
this.enableHybridCompositionOnAndroid = false,
Key key
}) : super(key: key);
/// Whether to use render the Android view as a platform view or a texture.
final bool enableHybridCompositionOnAndroid;
@override
PlatformViewAppState createState() => PlatformViewAppState();
@@ -89,17 +83,9 @@ class DummyPlatformView extends StatelessWidget {
viewType: viewType,
);
} else if (Platform.isAndroid) {
final PlatformViewApp app = PlatformViewApp.of(context).widget;
assert(app != null);
if (app.enableHybridCompositionOnAndroid) {
nativeView = const AndroidPlatformView(
viewType: viewType,
);
} else {
nativeView = const AndroidView(
viewType: viewType,
);
}
nativeView = const AndroidView(
viewType: viewType,
);
} else {
assert(false, 'Invalid platform');
}

View File

@@ -1,17 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/widgets.dart';
import 'package:flutter_driver/driver_extension.dart';
import 'package:platform_views_layout/main.dart' as app;
void main() {
enableFlutterDriverExtension();
runApp(
const app.PlatformViewApp(
enableHybridCompositionOnAndroid: false,
)
);
}

View File

@@ -10,8 +10,6 @@ import 'package:platform_views_layout/main.dart' as app;
void main() {
enableFlutterDriverExtension();
runApp(
const app.PlatformViewApp(
enableHybridCompositionOnAndroid: true,
)
const app.PlatformViewApp()
);
}