Remove more references to dart:ui.window (#120994)
* Remove more references to dart:ui.window * two more doc referenes * revert icon_color_test.dart
This commit is contained in:
committed by
GitHub
parent
f99f472807
commit
2b4c960885
@@ -32,17 +32,17 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
|
||||
double wobbleCounter = 0;
|
||||
|
||||
late List<Picture> _pictures;
|
||||
late Size windowSize;
|
||||
late Size viewSize;
|
||||
late Size cellSize;
|
||||
late Size rectSize;
|
||||
|
||||
@override
|
||||
Future<void> setUpAll() async {
|
||||
_pictures = <Picture>[];
|
||||
windowSize = window.physicalSize;
|
||||
viewSize = view.physicalSize;
|
||||
cellSize = Size(
|
||||
windowSize.width / kColumns,
|
||||
windowSize.height / kRows,
|
||||
viewSize.width / kColumns,
|
||||
viewSize.height / kRows,
|
||||
);
|
||||
rectSize = cellSize * 0.8;
|
||||
|
||||
|
||||
@@ -41,10 +41,10 @@ class BenchClippedOutPictures extends SceneBuilderRecorder {
|
||||
|
||||
@override
|
||||
void onDrawFrame(SceneBuilder sceneBuilder) {
|
||||
final Size screenSize = window.physicalSize / window.devicePixelRatio;
|
||||
final Size viewSize = view.physicalSize / view.devicePixelRatio;
|
||||
final Size pictureSize = Size(
|
||||
screenSize.width / kColumns,
|
||||
screenSize.height / kRows,
|
||||
viewSize.width / kColumns,
|
||||
viewSize.height / kRows,
|
||||
);
|
||||
|
||||
// Fills a single cell with random text.
|
||||
@@ -71,8 +71,8 @@ class BenchClippedOutPictures extends SceneBuilderRecorder {
|
||||
|
||||
// Starting with the top-left cell, fill every cell.
|
||||
sceneBuilder.pushClipRect(Rect.fromCircle(
|
||||
center: Offset(screenSize.width / 2, screenSize.height / 2),
|
||||
radius: math.min(screenSize.width, screenSize.height) / 6,
|
||||
center: Offset(viewSize.width / 2, viewSize.height / 2),
|
||||
radius: math.min(viewSize.width, viewSize.height) / 6,
|
||||
));
|
||||
sceneBuilder.pushOffset(
|
||||
5.0 * math.cos(angle),
|
||||
|
||||
@@ -67,11 +67,11 @@ class BenchDrawRect extends SceneBuilderRecorder {
|
||||
void onDrawFrame(SceneBuilder sceneBuilder) {
|
||||
final PictureRecorder pictureRecorder = PictureRecorder();
|
||||
final Canvas canvas = Canvas(pictureRecorder);
|
||||
final Size windowSize = window.physicalSize;
|
||||
final Size viewSize = view.physicalSize;
|
||||
|
||||
final Size cellSize = Size(
|
||||
windowSize.width / kColumns,
|
||||
windowSize.height / kRows,
|
||||
viewSize.width / kColumns,
|
||||
viewSize.height / kRows,
|
||||
);
|
||||
final Size rectSize = cellSize * 0.8;
|
||||
|
||||
|
||||
@@ -51,12 +51,12 @@ class BenchDynamicClipOnStaticPicture extends SceneBuilderRecorder {
|
||||
const Color black = Color.fromARGB(255, 0, 0, 0);
|
||||
final PictureRecorder pictureRecorder = PictureRecorder();
|
||||
final Canvas canvas = Canvas(pictureRecorder);
|
||||
screenSize = window.physicalSize / window.devicePixelRatio;
|
||||
viewSize = view.physicalSize / view.devicePixelRatio;
|
||||
clipSize = Size(
|
||||
screenSize.width / 2,
|
||||
screenSize.height / 5,
|
||||
viewSize.width / 2,
|
||||
viewSize.height / 5,
|
||||
);
|
||||
final double cellWidth = screenSize.width / kColumns;
|
||||
final double cellWidth = viewSize.width / kColumns;
|
||||
|
||||
final List<Paragraph> paragraphs = generateLaidOutParagraphs(
|
||||
paragraphCount: 500,
|
||||
@@ -93,7 +93,7 @@ class BenchDynamicClipOnStaticPicture extends SceneBuilderRecorder {
|
||||
|
||||
static const String benchmarkName = 'dynamic_clip_on_static_picture';
|
||||
|
||||
late Size screenSize;
|
||||
late Size viewSize;
|
||||
late Size clipSize;
|
||||
late Picture picture;
|
||||
double pictureVerticalOffset = 0.0;
|
||||
|
||||
@@ -37,14 +37,14 @@ class BenchTextOutOfPictureBounds extends SceneBuilderRecorder {
|
||||
paragraphCount: 500,
|
||||
minWordCountPerParagraph: 2,
|
||||
maxWordCountPerParagraph: 4,
|
||||
widthConstraint: window.physicalSize.width / 2,
|
||||
widthConstraint: view.physicalSize.width / 2,
|
||||
color: red,
|
||||
);
|
||||
multiLineParagraphs = generateLaidOutParagraphs(
|
||||
paragraphCount: 50,
|
||||
minWordCountPerParagraph: 30,
|
||||
maxWordCountPerParagraph: 49,
|
||||
widthConstraint: window.physicalSize.width / 2,
|
||||
widthConstraint: view.physicalSize.width / 2,
|
||||
color: green,
|
||||
);
|
||||
}
|
||||
@@ -61,19 +61,19 @@ class BenchTextOutOfPictureBounds extends SceneBuilderRecorder {
|
||||
void onDrawFrame(SceneBuilder sceneBuilder) {
|
||||
final PictureRecorder pictureRecorder = PictureRecorder();
|
||||
final Canvas canvas = Canvas(pictureRecorder);
|
||||
final Size screenSize = window.physicalSize;
|
||||
final Size viewSize = view.physicalSize;
|
||||
const double padding = 10.0;
|
||||
|
||||
// Fills a single cell with random text.
|
||||
void fillCellWithText(List<Paragraph> textSource) {
|
||||
canvas.save();
|
||||
double topOffset = 0;
|
||||
while (topOffset < screenSize.height) {
|
||||
while (topOffset < viewSize.height) {
|
||||
final Paragraph paragraph =
|
||||
textSource[_random.nextInt(textSource.length)];
|
||||
|
||||
// Give it enough space to make sure it ends up being a single-line paragraph.
|
||||
paragraph.layout(ParagraphConstraints(width: screenSize.width / 2));
|
||||
paragraph.layout(ParagraphConstraints(width: viewSize.width / 2));
|
||||
|
||||
canvas.drawParagraph(paragraph, Offset.zero);
|
||||
canvas.translate(0, paragraph.height + padding);
|
||||
@@ -83,12 +83,12 @@ class BenchTextOutOfPictureBounds extends SceneBuilderRecorder {
|
||||
}
|
||||
|
||||
// Starting with the top-left cell, fill every cell with text.
|
||||
canvas.translate(-screenSize.width, -screenSize.height);
|
||||
canvas.translate(-viewSize.width, -viewSize.height);
|
||||
for (int row = 0; row < 3; row++) {
|
||||
canvas.save();
|
||||
for (int col = 0; col < 3; col++) {
|
||||
canvas.drawRect(
|
||||
Offset.zero & screenSize,
|
||||
Offset.zero & viewSize,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 2.0,
|
||||
@@ -98,19 +98,19 @@ class BenchTextOutOfPictureBounds extends SceneBuilderRecorder {
|
||||
|
||||
// Fill multi-line text.
|
||||
canvas.save();
|
||||
canvas.translate(screenSize.width / 2, 0);
|
||||
canvas.translate(viewSize.width / 2, 0);
|
||||
fillCellWithText(multiLineParagraphs);
|
||||
canvas.restore();
|
||||
|
||||
// Shift to next column.
|
||||
canvas.translate(screenSize.width, 0);
|
||||
canvas.translate(viewSize.width, 0);
|
||||
}
|
||||
|
||||
// Undo horizontal shift.
|
||||
canvas.restore();
|
||||
|
||||
// Shift to next row.
|
||||
canvas.translate(0, screenSize.height);
|
||||
canvas.translate(0, viewSize.height);
|
||||
}
|
||||
|
||||
final Picture picture = pictureRecorder.endRecording();
|
||||
|
||||
@@ -279,7 +279,7 @@ abstract class SceneBuilderRecorder extends Recorder {
|
||||
_profile!.record('sceneBuildDuration', () {
|
||||
final Scene scene = sceneBuilder.build();
|
||||
_profile!.record('windowRenderDuration', () {
|
||||
window.render(scene);
|
||||
view.render(scene);
|
||||
}, reported: false);
|
||||
}, reported: false);
|
||||
}, reported: true);
|
||||
@@ -298,6 +298,11 @@ abstract class SceneBuilderRecorder extends Recorder {
|
||||
PlatformDispatcher.instance.scheduleFrame();
|
||||
return profileCompleter.future;
|
||||
}
|
||||
|
||||
FlutterView get view {
|
||||
assert(PlatformDispatcher.instance.implicitView != null, 'This benchmark requires the embedder to provide an implicit view.');
|
||||
return PlatformDispatcher.instance.implicitView!;
|
||||
}
|
||||
}
|
||||
|
||||
/// A recorder for benchmarking interactions with the framework by creating
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:flutter_driver/driver_extension.dart';
|
||||
|
||||
import 'windows.dart';
|
||||
|
||||
void drawHelloWorld() {
|
||||
void drawHelloWorld(ui.FlutterView view) {
|
||||
final ui.ParagraphStyle style = ui.ParagraphStyle();
|
||||
final ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder(style)
|
||||
..addText('Hello world');
|
||||
@@ -28,10 +28,14 @@ void drawHelloWorld() {
|
||||
..addPicture(ui.Offset.zero, picture)
|
||||
..pop();
|
||||
|
||||
ui.window.render(sceneBuilder.build());
|
||||
view.render(sceneBuilder.build());
|
||||
}
|
||||
|
||||
void main() async {
|
||||
// TODO(goderbauer): Create a window if embedder doesn't provide an implicit view to draw into.
|
||||
assert(ui.PlatformDispatcher.instance.implicitView != null);
|
||||
final ui.FlutterView view = ui.PlatformDispatcher.instance.implicitView!;
|
||||
|
||||
// Create a completer to send the window visibility result back to the
|
||||
// integration test.
|
||||
final Completer<String> visibilityCompleter = Completer<String>();
|
||||
@@ -81,7 +85,7 @@ void main() async {
|
||||
|
||||
// Draw something to trigger the first frame callback that displays the
|
||||
// window.
|
||||
drawHelloWorld();
|
||||
drawHelloWorld(view);
|
||||
firstFrame = false;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user