您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
48 行
1.3 KiB
48 行
1.3 KiB
using Unity.UIWidgets.foundation;
|
|
using Unity.UIWidgets.ui;
|
|
|
|
namespace Unity.UIWidgets.flow {
|
|
public class ClipRRectLayer : ContainerLayer {
|
|
RRect _clipRRect;
|
|
|
|
public RRect clipRRect {
|
|
set { _clipRRect = value; }
|
|
}
|
|
|
|
public override void preroll(PrerollContext context, Matrix3 matrix) {
|
|
var previousCullRect = context.cullRect;
|
|
|
|
var clipPathBounds = _clipRRect.outerRect;
|
|
context.cullRect = context.cullRect.intersect(clipPathBounds);
|
|
|
|
paintBounds = Rect.zero;
|
|
if (!context.cullRect.isEmpty) {
|
|
var childPaintBounds = Rect.zero;
|
|
prerollChildren(context, matrix, ref childPaintBounds);
|
|
childPaintBounds = childPaintBounds.intersect(clipPathBounds);
|
|
|
|
if (!childPaintBounds.isEmpty) {
|
|
paintBounds = childPaintBounds;
|
|
}
|
|
}
|
|
|
|
context.cullRect = previousCullRect;
|
|
}
|
|
|
|
public override void paint(PaintContext context) {
|
|
D.assert(needsPainting);
|
|
|
|
var canvas = context.canvas;
|
|
|
|
canvas.save();
|
|
canvas.clipRRect(_clipRRect);
|
|
|
|
try {
|
|
paintChildren(context);
|
|
}
|
|
finally {
|
|
canvas.restore();
|
|
}
|
|
}
|
|
}
|
|
}
|