mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Provide oldLayer where possible (#67320)
This commit is contained in:
parent
cba84d5127
commit
24abe59f38
@ -524,11 +524,13 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
|
||||
thumbCenterY + CupertinoThumbPainter.radius,
|
||||
);
|
||||
|
||||
context.pushClipRRect(needsCompositing, Offset.zero, thumbBounds, trackRRect, (PaintingContext innerContext, Offset offset) {
|
||||
_clipRRectLayer = context.pushClipRRect(needsCompositing, Offset.zero, thumbBounds, trackRRect, (PaintingContext innerContext, Offset offset) {
|
||||
const CupertinoThumbPainter.switchThumb().paint(innerContext.canvas, thumbBounds);
|
||||
});
|
||||
}, oldLayer: _clipRRectLayer);
|
||||
}
|
||||
|
||||
ClipRRectLayer? _clipRRectLayer;
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder description) {
|
||||
super.debugFillProperties(description);
|
||||
|
||||
@ -371,15 +371,17 @@ class _ToolbarRenderBox extends RenderShiftedBox {
|
||||
}
|
||||
|
||||
final _ToolbarParentData childParentData = child!.parentData! as _ToolbarParentData;
|
||||
context.pushClipPath(
|
||||
_clipPathLayer = context.pushClipPath(
|
||||
needsCompositing,
|
||||
offset + childParentData.offset,
|
||||
Offset.zero & child!.size,
|
||||
_clipPath(),
|
||||
(PaintingContext innerContext, Offset innerOffset) => innerContext.paintChild(child!, innerOffset),
|
||||
oldLayer: _clipPathLayer
|
||||
);
|
||||
}
|
||||
|
||||
ClipPathLayer? _clipPathLayer;
|
||||
Paint? _debugPaint;
|
||||
|
||||
@override
|
||||
|
||||
@ -1474,7 +1474,10 @@ class _RenderDecoration extends RenderBox {
|
||||
_labelTransform = Matrix4.identity()
|
||||
..translate(dx, labelOffset.dy + dy)
|
||||
..scale(scale);
|
||||
context.pushTransform(needsCompositing, offset, _labelTransform!, _paintLabel);
|
||||
_transformLayer = context.pushTransform(needsCompositing, offset, _labelTransform!, _paintLabel,
|
||||
oldLayer: _transformLayer);
|
||||
} else {
|
||||
_transformLayer = null;
|
||||
}
|
||||
|
||||
doPaint(icon);
|
||||
@ -1488,6 +1491,8 @@ class _RenderDecoration extends RenderBox {
|
||||
doPaint(counter);
|
||||
}
|
||||
|
||||
TransformLayer? _transformLayer;
|
||||
|
||||
@override
|
||||
bool hitTestSelf(Offset position) => true;
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
|
||||
import 'box.dart';
|
||||
import 'layer.dart';
|
||||
import 'object.dart';
|
||||
import 'shifted_box.dart';
|
||||
|
||||
@ -294,9 +295,13 @@ class RenderAnimatedSize extends RenderAligningShiftedBox {
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
if (child != null && _hasVisualOverflow && clipBehavior != Clip.none) {
|
||||
final Rect rect = Offset.zero & size;
|
||||
context.pushClipRect(needsCompositing, offset, rect, super.paint, clipBehavior: clipBehavior);
|
||||
_clipRectLayer = context.pushClipRect(needsCompositing, offset, rect, super.paint,
|
||||
clipBehavior: clipBehavior, oldLayer: _clipRectLayer);
|
||||
} else {
|
||||
_clipRectLayer = null;
|
||||
super.paint(context, offset);
|
||||
}
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
}
|
||||
|
||||
@ -2287,13 +2287,18 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
||||
@override
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
_layoutText(minWidth: constraints.minWidth, maxWidth: constraints.maxWidth);
|
||||
if (_hasVisualOverflow && clipBehavior != Clip.none)
|
||||
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintContents, clipBehavior: clipBehavior);
|
||||
else
|
||||
if (_hasVisualOverflow && clipBehavior != Clip.none) {
|
||||
_clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintContents,
|
||||
clipBehavior: clipBehavior, oldLayer: _clipRectLayer);
|
||||
} else {
|
||||
_clipRectLayer = null;
|
||||
_paintContents(context, offset);
|
||||
}
|
||||
_paintHandleLayers(context, getEndpointsForSelection(selection!));
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
@override
|
||||
Rect? describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Offset.zero & size : null;
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'box.dart';
|
||||
import 'debug_overflow_indicator.dart';
|
||||
import 'layer.dart';
|
||||
import 'object.dart';
|
||||
|
||||
/// How the child is inscribed into the available space.
|
||||
@ -977,10 +978,12 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
||||
return;
|
||||
|
||||
if (clipBehavior == Clip.none) {
|
||||
_clipRectLayer = null;
|
||||
defaultPaint(context, offset);
|
||||
} else {
|
||||
// We have overflow and the clipBehavior isn't none. Clip it.
|
||||
context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint, clipBehavior: clipBehavior);
|
||||
_clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint,
|
||||
clipBehavior: clipBehavior, oldLayer: _clipRectLayer);
|
||||
}
|
||||
|
||||
assert(() {
|
||||
@ -1026,6 +1029,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
||||
}());
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
@override
|
||||
Rect? describeApproximatePaintClip(RenderObject child) => _hasOverflow ? Offset.zero & size : null;
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
import 'box.dart';
|
||||
import 'layer.dart';
|
||||
import 'object.dart';
|
||||
|
||||
/// A context in which a [FlowDelegate] paints.
|
||||
@ -383,12 +384,16 @@ class RenderFlow extends RenderBox
|
||||
@override
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
if (clipBehavior == Clip.none) {
|
||||
_clipRectLayer = null;
|
||||
_paintWithDelegate(context, offset);
|
||||
} else {
|
||||
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintWithDelegate, clipBehavior: clipBehavior);
|
||||
_clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintWithDelegate,
|
||||
clipBehavior: clipBehavior, oldLayer: _clipRectLayer);
|
||||
}
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
@override
|
||||
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
|
||||
final List<RenderBox> children = getChildrenAsList();
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:flutter/animation.dart';
|
||||
import 'package:vector_math/vector_math_64.dart' show Matrix4;
|
||||
|
||||
import 'box.dart';
|
||||
import 'layer.dart';
|
||||
import 'object.dart';
|
||||
import 'viewport.dart';
|
||||
import 'viewport_offset.dart';
|
||||
@ -784,19 +785,23 @@ class RenderListWheelViewport
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
if (childCount > 0) {
|
||||
if (_shouldClipAtCurrentOffset() && clipBehavior != Clip.none) {
|
||||
context.pushClipRect(
|
||||
_clipRectLayer = context.pushClipRect(
|
||||
needsCompositing,
|
||||
offset,
|
||||
Offset.zero & size,
|
||||
_paintVisibleChildren,
|
||||
clipBehavior: clipBehavior,
|
||||
oldLayer: _clipRectLayer,
|
||||
);
|
||||
} else {
|
||||
_clipRectLayer = null;
|
||||
_paintVisibleChildren(context, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
/// Paints all children visible in the current viewport.
|
||||
void _paintVisibleChildren(PaintingContext context, Offset offset) {
|
||||
RenderBox? childToPaint = firstChild;
|
||||
|
||||
@ -206,13 +206,16 @@ class RenderAndroidView extends RenderBox with _PlatformViewGestureMixin {
|
||||
// Clip the texture if it's going to paint out of the bounds of the renter box
|
||||
// (see comment in _paintTexture for an explanation of when this happens).
|
||||
if ((size.width < _currentAndroidViewSize.width || size.height < _currentAndroidViewSize.height) && clipBehavior != Clip.none) {
|
||||
context.pushClipRect(true, offset, offset & size, _paintTexture, clipBehavior: clipBehavior);
|
||||
_clipRectLayer = context.pushClipRect(true, offset, offset & size, _paintTexture, clipBehavior: clipBehavior,
|
||||
oldLayer: _clipRectLayer);
|
||||
return;
|
||||
}
|
||||
|
||||
_clipRectLayer = null;
|
||||
_paintTexture(context, offset);
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
void _paintTexture(PaintingContext context, Offset offset) {
|
||||
// As resizing the Android view happens asynchronously we don't know exactly when is a
|
||||
// texture frame with the new size is ready for consumption.
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:flutter/painting.dart';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
import 'box.dart';
|
||||
import 'layer.dart';
|
||||
import 'object.dart';
|
||||
|
||||
const double _kQuarterTurnsInRadians = math.pi / 2.0;
|
||||
@ -108,10 +109,16 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB
|
||||
|
||||
@override
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
if (child != null)
|
||||
context.pushTransform(needsCompositing, offset, _paintTransform!, _paintChild);
|
||||
if (child != null) {
|
||||
_transformLayer = context.pushTransform(needsCompositing, offset, _paintTransform!, _paintChild,
|
||||
oldLayer: _transformLayer);
|
||||
} else {
|
||||
_transformLayer = null;
|
||||
}
|
||||
}
|
||||
|
||||
TransformLayer? _transformLayer;
|
||||
|
||||
@override
|
||||
void applyPaintTransform(RenderBox child, Matrix4 transform) {
|
||||
if (_paintTransform != null)
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'box.dart';
|
||||
import 'debug.dart';
|
||||
import 'debug_overflow_indicator.dart';
|
||||
import 'layer.dart';
|
||||
import 'object.dart';
|
||||
import 'stack.dart' show RelativeRect;
|
||||
|
||||
@ -712,10 +713,12 @@ class RenderUnconstrainedBox extends RenderAligningShiftedBox with DebugOverflow
|
||||
}
|
||||
|
||||
if (clipBehavior == Clip.none) {
|
||||
_clipRectLayer = null;
|
||||
super.paint(context, offset);
|
||||
} else {
|
||||
// We have overflow and the clipBehavior isn't none. Clip it.
|
||||
context.pushClipRect(needsCompositing, offset, Offset.zero & size, super.paint, clipBehavior: clipBehavior);
|
||||
_clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, super.paint,
|
||||
clipBehavior: clipBehavior, oldLayer:_clipRectLayer);
|
||||
}
|
||||
|
||||
// Display the overflow indicator.
|
||||
@ -725,6 +728,8 @@ class RenderUnconstrainedBox extends RenderAligningShiftedBox with DebugOverflow
|
||||
}());
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
@override
|
||||
Rect? describeApproximatePaintClip(RenderObject child) {
|
||||
return _isOverflowing ? Offset.zero & size : null;
|
||||
|
||||
@ -8,6 +8,7 @@ import 'dart:ui' show lerpDouble, hashValues;
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'box.dart';
|
||||
import 'layer.dart';
|
||||
import 'object.dart';
|
||||
|
||||
/// An immutable 2D, axis-aligned, floating-point rectangle whose coordinates
|
||||
@ -613,12 +614,16 @@ class RenderStack extends RenderBox
|
||||
@override
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
if (clipBehavior != Clip.none && _hasVisualOverflow) {
|
||||
context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintStack, clipBehavior: clipBehavior);
|
||||
_clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintStack,
|
||||
clipBehavior: clipBehavior, oldLayer: _clipRectLayer);
|
||||
} else {
|
||||
_clipRectLayer = null;
|
||||
paintStack(context, offset);
|
||||
}
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
@override
|
||||
Rect? describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Offset.zero & size : null;
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ import 'package:flutter/semantics.dart';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
import 'box.dart';
|
||||
import 'layer.dart';
|
||||
import 'object.dart';
|
||||
import 'sliver.dart';
|
||||
import 'viewport_offset.dart';
|
||||
@ -629,12 +630,16 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
|
||||
if (firstChild == null)
|
||||
return;
|
||||
if (hasVisualOverflow && clipBehavior != Clip.none) {
|
||||
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintContents, clipBehavior: clipBehavior);
|
||||
_clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintContents,
|
||||
clipBehavior: clipBehavior, oldLayer: _clipRectLayer);
|
||||
} else {
|
||||
_clipRectLayer = null;
|
||||
_paintContents(context, offset);
|
||||
}
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
void _paintContents(PaintingContext context, Offset offset) {
|
||||
for (final RenderSliver child in childrenInPaintOrder) {
|
||||
if (child.geometry!.visible)
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'box.dart';
|
||||
import 'layer.dart';
|
||||
import 'object.dart';
|
||||
|
||||
/// How [Wrap] should align objects.
|
||||
@ -763,12 +764,17 @@ class RenderWrap extends RenderBox
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
// TODO(ianh): move the debug flex overflow paint logic somewhere common so
|
||||
// it can be reused here
|
||||
if (_hasVisualOverflow && clipBehavior != Clip.none)
|
||||
context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint, clipBehavior: clipBehavior);
|
||||
else
|
||||
if (_hasVisualOverflow && clipBehavior != Clip.none) {
|
||||
_clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint,
|
||||
clipBehavior: clipBehavior, oldLayer: _clipRectLayer);
|
||||
} else {
|
||||
_clipRectLayer = null;
|
||||
defaultPaint(context, offset);
|
||||
}
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
|
||||
@ -756,12 +756,16 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
|
||||
@override
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
if (_hasVisualOverflow && clipBehavior != Clip.none) {
|
||||
context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintStack, clipBehavior: clipBehavior);
|
||||
_clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintStack,
|
||||
clipBehavior: clipBehavior, oldLayer: _clipRectLayer);
|
||||
} else {
|
||||
_clipRectLayer = null;
|
||||
paintStack(context, offset);
|
||||
}
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
@override
|
||||
void visitChildrenForSemantics(RenderObjectVisitor visitor) {
|
||||
RenderBox? child = _firstOnstageChild;
|
||||
|
||||
@ -583,13 +583,17 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix
|
||||
}
|
||||
|
||||
if (_shouldClipAtPaintOffset(paintOffset) && clipBehavior != Clip.none) {
|
||||
context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintContents, clipBehavior: clipBehavior);
|
||||
_clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintContents,
|
||||
clipBehavior: clipBehavior, oldLayer: _clipRectLayer);
|
||||
} else {
|
||||
_clipRectLayer = null;
|
||||
paintContents(context, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClipRectLayer? _clipRectLayer;
|
||||
|
||||
@override
|
||||
void applyPaintTransform(RenderBox child, Matrix4 transform) {
|
||||
final Offset paintOffset = _paintOffset;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user