浏览代码

clipRRect + fix clipRRectLayer

/main
xingwei.zhu 6 年前
当前提交
f2fe14fe
共有 3 个文件被更改,包括 124 次插入8 次删除
  1. 26
      Runtime/rendering/layer.cs
  2. 67
      Runtime/rendering/proxy_box.cs
  3. 39
      Runtime/widgets/basic.cs

26
Runtime/rendering/layer.cs


if (child._previousSibling == null) {
D.assert(this.firstChild == child);
this._firstChild = child.nextSibling;
} else {
}
else {
child._previousSibling._nextSibling = child.nextSibling;
}

} else {
}
else {
child._nextSibling._previousSibling = child.previousSibling;
}

while (child != null) {
if (childOffset == null || childOffset == Offset.zero) {
child._addToSceneWithRetainedRendering(builder);
} else {
}
else {
child = child.nextSibling;
}
}

internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
bool enabled = true;
D.assert(() => {
enabled = !D.debugDisableClipLayers;

}
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
bool enabled = true;
D.assert(() => {
enabled = !D.debugDisableClipLayers;

}
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
bool enabled = true;
D.assert(() => {
enabled = !D.debugDisableClipLayers;

internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
this._lastEffectiveTransform = this._transform;
var totalOffset = this.offset + layerOffset;

this.addChildrenToScene(builder);
builder.pop();
this._lastOffset = this.unlinkedOffset + layerOffset;
} else {
}
else {
this._lastOffset = null;
var matrix = Matrix3.makeTrans(this.unlinkedOffset.dx, this.unlinkedOffset.dy);
builder.pushTransform(matrix);

D.assert(transform != null);
if (this._lastTransform != null) {
transform.preConcat(this._lastTransform);
} else {
}
else {
transform.preConcat(Matrix3.makeTrans(this.unlinkedOffset.dx, this.unlinkedOffset.dy));
}
}

defaultValue: Diagnostics.kNullDefaultValue));
}
}
}
}

67
Runtime/rendering/proxy_box.cs


}
public class RenderClipRRect : _RenderCustomClip<RRect> {
public RenderClipRRect(
RenderBox child = null,
BorderRadius borderRadius = null,
CustomClipper<RRect> clipper = null,
Clip clipBehavior = Clip.antiAlias
) : base(child: child, clipper: clipper, clipBehavior: clipBehavior) {
D.assert(clipBehavior != Clip.none);
this._borderRadius = borderRadius ?? BorderRadius.zero;
D.assert(this._borderRadius != null || clipper != null);
}
public BorderRadius borderRadius {
get { return this._borderRadius; }
set {
D.assert(value != null);
if (this._borderRadius == value) {
return;
}
this._borderRadius = value;
this._markNeedsClip();
}
}
BorderRadius _borderRadius;
protected override RRect _defaultClip {
get { return this._borderRadius.toRRect(Offset.zero & this.size); }
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);
if (!this._clip.contains(position)) {
return false;
}
}
return base.hitTest(result, position: position);
}
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();
context.pushClipRRect(this.needsCompositing, offset, this._clip.outerRect, this._clip,
base.paint, clipBehavior: this.clipBehavior);
}
}
protected override void debugPaintSize(PaintingContext context, Offset offset) {
D.assert(() => {
if (this.child != null) {
base.debugPaintSize(context, offset);
context.canvas.drawRRect(this._clip.shift(offset), this._debugPaint);
this._debugText.paint(context.canvas,
offset + new Offset(this._clip.tlRadiusX,
-(this._debugText.text.style.fontSize ?? 0.0f) * 1.1f));
}
return true;
});
}
}
public class RenderClipPath : _RenderCustomClip<Path> {
public RenderClipPath(
RenderBox child = null,

39
Runtime/widgets/basic.cs


}
}
public class ClipRRect : SingleChildRenderObjectWidget {
public ClipRRect(
Key key = null,
BorderRadius borderRadius = null,
CustomClipper<RRect> clipper = null,
Clip clipBehavior = Clip.antiAlias,
Widget child = null
) : base(key: key, child: child) {
D.assert(borderRadius != null || clipper != null);
this.borderRadius = borderRadius;
this.clipper = clipper;
this.clipBehavior = clipBehavior;
}
public readonly BorderRadius borderRadius;
public readonly CustomClipper<RRect> clipper;
public readonly Clip clipBehavior;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderClipRRect(borderRadius: this.borderRadius, clipper: this.clipper,
clipBehavior: this.clipBehavior);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
RenderClipRRect _renderObject = (RenderClipRRect) renderObject;
_renderObject.borderRadius = this.borderRadius;
_renderObject.clipper = this.clipper;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<BorderRadius>("borderRadius", this.borderRadius, showName: false,
defaultValue: null));
properties.add(new DiagnosticsProperty<CustomClipper<RRect>>("clipper", this.clipper, defaultValue: null));
}
}
public class ClipPath : SingleChildRenderObjectWidget {
public ClipPath(
Key key = null,

正在加载...
取消
保存