guanghuispark
4 年前
当前提交
9927d791
共有 2 个文件被更改,包括 110 次插入 和 10 次删除
-
52com.unity.uiwidgets/Runtime/rendering/layer.cs
-
68com.unity.uiwidgets/Runtime/widgets/image_filter.cs
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
public class ImageFiltered : SingleChildRenderObjectWidget { |
|||
|
|||
protected ImageFiltered( |
|||
Key key, |
|||
ImageFilter imageFilter, |
|||
Widget child |
|||
) : |
|||
base(key: key, child: child) { |
|||
D.assert(imageFilter != null); |
|||
} |
|||
|
|||
public readonly ImageFilter imageFilter; |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) => new _ImageFilterRenderObject(imageFilter); |
|||
|
|||
public override void updateRenderObject(BuildContext context, RenderObject renderObject) { |
|||
((_ImageFilterRenderObject) renderObject).imageFilter = imageFilter; |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new DiagnosticsProperty<ImageFilter>("imageFilter", imageFilter)); |
|||
} |
|||
} |
|||
|
|||
public class _ImageFilterRenderObject : RenderProxyBox { |
|||
public _ImageFilterRenderObject(ImageFilter _imageFilter) { |
|||
this._imageFilter = _imageFilter; |
|||
} |
|||
|
|||
public ImageFilter imageFilter { |
|||
get { |
|||
return _imageFilter; |
|||
} |
|||
set { |
|||
D.assert(value != null); |
|||
if (value != _imageFilter) { |
|||
_imageFilter = value; |
|||
markNeedsPaint(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
ImageFilter _imageFilter; |
|||
|
|||
protected override bool alwaysNeedsCompositing { |
|||
get { return child != null; } |
|||
} |
|||
|
|||
public override void paint(PaintingContext context, Offset offset) { |
|||
D.assert(imageFilter != null); |
|||
if (layer == null) { |
|||
layer = new ImageFilterLayer(imageFilter: imageFilter); |
|||
} else { |
|||
ImageFilterLayer filterLayer = layer as ImageFilterLayer; |
|||
filterLayer.imageFilter = imageFilter; |
|||
} |
|||
context.pushLayer(layer, base.paint, offset); |
|||
D.assert(layer != null); |
|||
} |
|||
} |
|||
|
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue