浏览代码

add image_filter.cs

/siyaoH-1.17-PlatformMessage
guanghuispark 4 年前
当前提交
9927d791
共有 2 个文件被更改,包括 110 次插入10 次删除
  1. 52
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  2. 68
      com.unity.uiwidgets/Runtime/widgets/image_filter.cs

52
com.unity.uiwidgets/Runtime/rendering/layer.cs


properties.add(new DiagnosticsProperty<Clip>("clipBehavior", clipBehavior));
}
}
/// A composite layer that applies a [ColorFilter] to its children.
/// Creates a layer that applies a [ColorFilter] to its children.
///
/// The [colorFilter] property must be non-null before the compositing phase
/// of the pipeline.
/// The color filter to apply to children.
///
/// The scene must be explicitly recomposited after this property is changed
/// (as described at [Layer]).
public ColorFilter colorFilter {
get {
return _colorFilter;

}
}
public class ImageFilterLayer : ContainerLayer {
public ImageFilterLayer(
ui.ImageFilter imageFilter
) {
_imageFilter = imageFilter;
}
public ui.ImageFilter imageFilter {
get {
return _imageFilter;
}
set {
D.assert(value != null);
if (value != _imageFilter) {
_imageFilter = value;
markNeedsAddToScene();
}
}
}
ui.ImageFilter _imageFilter;
//[!!!] builder.pushImageFilter?
/*public override void addToScene(ui.SceneBuilder builder, Offset layerOffset = null) {
D.assert(imageFilter != null);
engineLayer = builder.pushImageFilter(
imageFilter,
oldLayer: _engineLayer as ui.ImageFilterEngineLayer
);
addChildrenToScene(builder, layerOffset);
builder.pop();
}*/
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ui.ImageFilter>("imageFilter", imageFilter));
}
}
public class TransformLayer : OffsetLayer {
public TransformLayer(Matrix4 transform = null, Offset offset = null) : base(offset) {

68
com.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);
}
}
}
正在加载...
取消
保存