Unverified Commit 899548c4 authored by wangying's avatar wangying Committed by GitHub

Assign debugCreator for more layers (#101899)

parent f6feb8f8
...@@ -899,6 +899,10 @@ class RenderOpacity extends RenderProxyBox { ...@@ -899,6 +899,10 @@ class RenderOpacity extends RenderProxyBox {
} }
assert(needsCompositing); assert(needsCompositing);
layer = context.pushOpacity(offset, _alpha, super.paint, oldLayer: layer as OpacityLayer?); layer = context.pushOpacity(offset, _alpha, super.paint, oldLayer: layer as OpacityLayer?);
assert(() {
layer!.debugCreator = debugCreator;
return true;
}());
} }
} }
...@@ -1006,6 +1010,10 @@ mixin RenderAnimatedOpacityMixin<T extends RenderObject> on RenderObjectWithChil ...@@ -1006,6 +1010,10 @@ mixin RenderAnimatedOpacityMixin<T extends RenderObject> on RenderObjectWithChil
} }
assert(needsCompositing); assert(needsCompositing);
layer = context.pushOpacity(offset, _alpha!, super.paint, oldLayer: layer as OpacityLayer?); layer = context.pushOpacity(offset, _alpha!, super.paint, oldLayer: layer as OpacityLayer?);
assert(() {
layer!.debugCreator = debugCreator;
return true;
}());
} }
} }
...@@ -1115,6 +1123,10 @@ class RenderShaderMask extends RenderProxyBox { ...@@ -1115,6 +1123,10 @@ class RenderShaderMask extends RenderProxyBox {
..maskRect = offset & size ..maskRect = offset & size
..blendMode = _blendMode; ..blendMode = _blendMode;
context.pushLayer(layer!, super.paint, offset); context.pushLayer(layer!, super.paint, offset);
assert(() {
layer!.debugCreator = debugCreator;
return true;
}());
} else { } else {
layer = null; layer = null;
} }
...@@ -1181,6 +1193,10 @@ class RenderBackdropFilter extends RenderProxyBox { ...@@ -1181,6 +1193,10 @@ class RenderBackdropFilter extends RenderProxyBox {
layer!.filter = _filter; layer!.filter = _filter;
layer!.blendMode = _blendMode; layer!.blendMode = _blendMode;
context.pushLayer(layer!, super.paint, offset); context.pushLayer(layer!, super.paint, offset);
assert(() {
layer!.debugCreator = debugCreator;
return true;
}());
} else { } else {
layer = null; layer = null;
} }
...@@ -2426,6 +2442,10 @@ class RenderTransform extends RenderProxyBox { ...@@ -2426,6 +2442,10 @@ class RenderTransform extends RenderProxyBox {
layer = ImageFilterLayer(imageFilter: filter); layer = ImageFilterLayer(imageFilter: filter);
} }
context.pushLayer(layer!, super.paint, offset); context.pushLayer(layer!, super.paint, offset);
assert(() {
layer!.debugCreator = debugCreator;
return true;
}());
} }
} }
} }
...@@ -5212,7 +5232,10 @@ class RenderLeaderLayer extends RenderProxyBox { ...@@ -5212,7 +5232,10 @@ class RenderLeaderLayer extends RenderProxyBox {
..offset = offset; ..offset = offset;
} }
context.pushLayer(layer!, super.paint, Offset.zero); context.pushLayer(layer!, super.paint, Offset.zero);
assert(layer != null); assert(() {
layer!.debugCreator = debugCreator;
return true;
}());
} }
@override @override
...@@ -5424,6 +5447,10 @@ class RenderFollowerLayer extends RenderProxyBox { ...@@ -5424,6 +5447,10 @@ class RenderFollowerLayer extends RenderProxyBox {
double.infinity, double.infinity,
), ),
); );
assert(() {
layer!.debugCreator = debugCreator;
return true;
}());
} }
@override @override
......
...@@ -173,6 +173,10 @@ class RenderSliverOpacity extends RenderProxySliver { ...@@ -173,6 +173,10 @@ class RenderSliverOpacity extends RenderProxySliver {
super.paint, super.paint,
oldLayer: layer as OpacityLayer?, oldLayer: layer as OpacityLayer?,
); );
assert(() {
layer!.debugCreator = debugCreator;
return true;
}());
} }
} }
......
...@@ -74,5 +74,9 @@ class _ColorFilterRenderObject extends RenderProxyBox { ...@@ -74,5 +74,9 @@ class _ColorFilterRenderObject extends RenderProxyBox {
@override @override
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
layer = context.pushColorFilter(offset, colorFilter, super.paint, oldLayer: layer as ColorFilterLayer?); layer = context.pushColorFilter(offset, colorFilter, super.paint, oldLayer: layer as ColorFilterLayer?);
assert(() {
layer!.debugCreator = debugCreator;
return true;
}());
} }
} }
...@@ -73,6 +73,9 @@ class _ImageFilterRenderObject extends RenderProxyBox { ...@@ -73,6 +73,9 @@ class _ImageFilterRenderObject extends RenderProxyBox {
filterLayer.imageFilter = imageFilter; filterLayer.imageFilter = imageFilter;
} }
context.pushLayer(layer!, super.paint, offset); context.pushLayer(layer!, super.paint, offset);
assert(layer != null); assert(() {
layer!.debugCreator = debugCreator;
return true;
}());
} }
} }
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
...@@ -269,4 +271,74 @@ void main() { ...@@ -269,4 +271,74 @@ void main() {
} }
debugHighlightDeprecatedWidgets = false; debugHighlightDeprecatedWidgets = false;
}); });
testWidgets('debugCreator of layers should not be null', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: Stack(
children: <Widget>[
const ColorFiltered(
colorFilter: ColorFilter.mode(Color(0xFFFF0000), BlendMode.color),
child: Placeholder(),
),
const Opacity(
opacity: 1.0,
child: Placeholder(),
),
ImageFiltered(
imageFilter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
child: const Placeholder(),
),
BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
child: const Placeholder(),
),
ShaderMask(
shaderCallback: (Rect bounds) => const RadialGradient(
radius: 0.05,
colors: <Color>[Color(0xFFFF0000), Color(0xFF00FF00)],
tileMode: TileMode.mirror,
).createShader(bounds),
child: const Placeholder(),
),
RangeSlider(
values: const RangeValues(0.3, 0.7),
onChanged: (RangeValues newValues) {},
),
CompositedTransformFollower(
link: LayerLink(),
),
],
),
),
),
),
);
RenderObject renderObject;
renderObject = tester.firstRenderObject(find.byType(Opacity));
expect(renderObject.debugLayer?.debugCreator, isNotNull);
renderObject = tester.firstRenderObject(find.byType(ColorFiltered));
expect(renderObject.debugLayer?.debugCreator, isNotNull);
renderObject = tester.firstRenderObject(find.byType(ImageFiltered));
expect(renderObject.debugLayer?.debugCreator, isNotNull);
renderObject = tester.firstRenderObject(find.byType(BackdropFilter));
expect(renderObject.debugLayer?.debugCreator, isNotNull);
renderObject = tester.firstRenderObject(find.byType(ShaderMask));
expect(renderObject.debugLayer?.debugCreator, isNotNull);
renderObject = tester.firstRenderObject(find.byType(RangeSlider));
expect(renderObject.debugLayer?.debugCreator, isNotNull);
renderObject = tester.firstRenderObject(find.byType(CompositedTransformFollower));
expect(renderObject.debugLayer?.debugCreator, isNotNull);
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment