Teach render objects to reuse engine layers (#36402)

Teach Layer and its implementations, RenderObject and its implementations, and PaintingContext to reuse engine layers. The idea is that a concrete RenderObject creates a Layer and holds on to it as long as it needs it (i.e. when it is composited, and the layer type does not change). In return, each Layer object holds on to an EngineLayer and reports it to the engine via addRetained and oldLayer. This allows the Web engine to reuse DOM elements across frames. Without it, each frame drops all previously rendered HTML and regenerates it from scratch.
This commit is contained in:
Yegor
2019-08-16 15:27:12 -07:00
committed by GitHub
parent 1a5e4a5d7f
commit 34c692659e
22 changed files with 1212 additions and 357 deletions

View File

@@ -196,7 +196,7 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
Future<Evaluation> evaluate(WidgetTester tester) async {
final SemanticsNode root = tester.binding.pipelineOwner.semanticsOwner.rootSemanticsNode;
final RenderView renderView = tester.binding.renderView;
final OffsetLayer layer = renderView.layer;
final OffsetLayer layer = renderView.debugLayer;
ui.Image image;
final ByteData byteData = await tester.binding.runAsync<ByteData>(() async {
// Needs to be the same pixel ratio otherwise our dimensions won't match the

View File

@@ -231,7 +231,7 @@ abstract class WidgetController {
}
/// Returns a list of all the [Layer] objects in the rendering.
List<Layer> get layers => _walkLayers(binding.renderView.layer).toList();
List<Layer> get layers => _walkLayers(binding.renderView.debugLayer).toList();
Iterable<Layer> _walkLayers(Layer layer) sync* {
TestAsyncUtils.guardSync();
yield layer;

View File

@@ -1620,7 +1620,7 @@ Future<ui.Image> _captureImage(Element element) {
assert(renderObject != null);
}
assert(!renderObject.debugNeedsPaint);
final OffsetLayer layer = renderObject.layer;
final OffsetLayer layer = renderObject.debugLayer;
return layer.toImage(renderObject.paintBounds);
}