浏览代码

fix : makeTrans(Vector) --> makeTrans(Offset); use Matrix3.invert directly

/main
xingwei.zhu 6 年前
当前提交
07f123c4
共有 9 个文件被更改,包括 34 次插入42 次删除
  1. 11
      Runtime/rendering/box.cs
  2. 2
      Runtime/rendering/layer.cs
  3. 13
      Runtime/rendering/object.cs
  4. 15
      Runtime/rendering/proxy_box.cs
  5. 6
      Runtime/rendering/sliver.cs
  6. 2
      Runtime/rendering/viewport.cs
  7. 19
      Runtime/ui/matrix.cs
  8. 2
      Runtime/widgets/basic.cs
  9. 6
      Runtime/widgets/widget_inspector.cs

11
Runtime/rendering/box.cs


var childParentData = (BoxParentData) child.parentData;
var offset = childParentData.offset;
transform = Matrix3.makeTrans(offset.toVector()) * transform;
transform = Matrix3.makeTrans(offset) * transform;
if (!transform.invertable()) {
return Offset.zero;
}
var inverse = Matrix3.I();
var invertible = transform.invert(inverse);
return invertible ? inverse.mapPoint(point) : Offset.zero;
transform = transform.inverse();
return transform.mapPoint(point);
}
public Offset localToGlobal(Offset point, RenderObject ancestor = null) {

2
Runtime/rendering/layer.cs


var totalOffset = this.offset + layerOffset;
if (totalOffset != Offset.zero) {
this._lastEffectiveTransform =
Matrix3.makeTrans(totalOffset.toVector()) * this._lastEffectiveTransform;
Matrix3.makeTrans(totalOffset) * this._lastEffectiveTransform;
}
builder.pushTransform(this._lastEffectiveTransform);

13
Runtime/rendering/object.cs


public void pushTransform(bool needsCompositing, Offset offset, Matrix3 transform,
PaintingContextCallback painter) {
var effectiveTransform = Matrix3.makeTrans(offset.toVector())
* transform * Matrix3.makeTrans(-offset.toVector());
var effectiveTransform = Matrix3.makeTrans(offset)
* transform * Matrix3.makeTrans(-offset);
if (needsCompositing) {
if (needsCompositing)
{
var inverse = Matrix3.I();
var invertible = effectiveTransform.invert(inverse);
D.assert(invertible);
childPaintBounds: effectiveTransform.inverse().mapRect(this.estimatedBounds)
childPaintBounds: inverse.mapRect(this.estimatedBounds)
);
} else {
this.canvas.save();

15
Runtime/rendering/proxy_box.cs


var result = Matrix3.I();
if (this._origin != null) {
result = Matrix3.makeTrans(new Vector2((float) this._origin.dx, (float) this._origin.dy)) *
result = Matrix3.makeTrans((float) this._origin.dx, (float) this._origin.dy) *
result;
}

result = Matrix3.makeTrans(new Vector2((float) translation.dx, (float) translation.dy)) * result;
result = Matrix3.makeTrans((float) translation.dx, (float) translation.dy) * result;
result = Matrix3.makeTrans(new Vector2((float) -translation.dx, (float) -translation.dy)) *
result = Matrix3.makeTrans((float) -translation.dx, (float) -translation.dy) *
result = Matrix3.makeTrans(new Vector2((float) -this._origin.dx, (float) -this._origin.dy)) *
result = Matrix3.makeTrans((float) -this._origin.dx, (float) -this._origin.dy) *
result;
}

protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
if (this.transformHitTests) {
var transform = this._effectiveTransform;
if (!transform.invertable()) {
var inverse = Matrix3.I();
var invertible = transform.invert(inverse);
if (!invertible) {
position = transform.inverse().mapPoint(position);
position = inverse.mapPoint(position);
}
return base.hitTestChildren(result, position: position);

6
Runtime/rendering/sliver.cs


public Offset paintOffset = Offset.zero;
public void applyPaintTransform(ref Matrix3 transform) {
transform = Matrix3.makeTrans(this.paintOffset.toVector()) * transform;
transform = Matrix3.makeTrans(this.paintOffset) * transform;
}
public override string ToString() {

delta = it.geometry.paintExtent - child.size.width - delta;
}
transform = Matrix3.makeTrans(new Vector2((float) delta, (float) crossAxisDelta)) * transform;
transform = Matrix3.makeTrans((float) delta, (float) crossAxisDelta) * transform;
break;
case Axis.vertical:
if (!rightWayUp) {

transform = Matrix3.makeTrans(new Vector2((float) crossAxisDelta, (float) delta)) * transform;
transform = Matrix3.makeTrans((float) crossAxisDelta, (float) delta) * transform;
break;
}
}

2
Runtime/rendering/viewport.cs


D.assert(child != null);
Offset offset = this.paintOffsetOf((RenderSliver) child);
transform = Matrix3.makeTrans(offset.toVector()) * transform;
transform = Matrix3.makeTrans(offset) * transform;
}
protected override double computeChildMainAxisPosition(RenderSliver child, double parentMainAxisPosition) {

19
Runtime/ui/matrix.cs


return m;
}
public static Matrix3 makeTrans(Vector2 vector)
public static Matrix3 makeTrans(Offset offset)
m.setTranslate(vector.x, vector.y);
m.setTranslate((float)offset.dx, (float)offset.dy);
return m;
}

{
return "Matrix3(" + string.Join(",", Array.ConvertAll(fMat, i => i.ToString())) + ")";
}
public bool invertable()
{
var mask = this.getType();
var isPersp = (int) (mask & TypeMask.kPerspective_Mask);
var invDet = ScalarUtils.inv_determinant(fMat, isPersp);
return invDet != 0;
}
public Matrix3 inverse()
{
var m = new Matrix3();
var invertable = this.invert(m);
D.assert(invertable);
return m;
}
public Offset mapPoint(Offset point)
{

2
Runtime/widgets/basic.cs


Widget child = null
) : base(key: key, child: child) {
D.assert(offset != null);
this.transform = Matrix3.makeTrans(new Vector2((float) offset.dx, (float) offset.dy));
this.transform = Matrix3.makeTrans((float) offset.dx, (float) offset.dy);
this.origin = null;
this.alignment = null;
this.transformHitTests = transformHitTests;

6
Runtime/widgets/widget_inspector.cs


) {
var hit = false;
if (!transform.invertable())
var inverse = Matrix3.I();
var invertible = transform.invert(inverse);
if (!invertible)
Matrix3 inverse = transform.inverse();
var localPosition = inverse.mapPoint(position);
List<DiagnosticsNode> children = renderObject.debugDescribeChildren();

正在加载...
取消
保存