浏览代码

matrix4 & painting

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
bffd7872
共有 34 个文件被更改,包括 1301 次插入287 次删除
  1. 2
      com.unity.uiwidgets/Runtime/foundation/assertions.cs
  2. 2
      com.unity.uiwidgets/Runtime/painting/border_radius.cs
  3. 9
      com.unity.uiwidgets/Runtime/painting/box_border.cs
  4. 40
      com.unity.uiwidgets/Runtime/painting/box_decoration.cs
  5. 2
      com.unity.uiwidgets/Runtime/painting/decoration.cs
  6. 16
      com.unity.uiwidgets/Runtime/painting/edge_insets.cs
  7. 25
      com.unity.uiwidgets/Runtime/painting/gradient.cs
  8. 20
      com.unity.uiwidgets/Runtime/painting/inline_span.cs
  9. 4
      com.unity.uiwidgets/Runtime/painting/shape_decoration.cs
  10. 74
      com.unity.uiwidgets/Runtime/painting/text_painter.cs
  11. 145
      com.unity.uiwidgets/Runtime/painting/text_span.cs
  12. 42
      com.unity.uiwidgets/Runtime/painting/text_style.cs
  13. 2
      com.unity.uiwidgets/Runtime/rendering/box.cs
  14. 19
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  15. 2
      com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs
  16. 4
      com.unity.uiwidgets/Runtime/rendering/object.cs
  17. 16
      com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
  18. 2
      com.unity.uiwidgets/Runtime/rendering/rotated_box.cs
  19. 2
      com.unity.uiwidgets/Runtime/rendering/sliver.cs
  20. 2
      com.unity.uiwidgets/Runtime/rendering/view.cs
  21. 2
      com.unity.uiwidgets/Runtime/rendering/viewport.cs
  22. 886
      com.unity.uiwidgets/Runtime/ui2/Matrix4.cs
  23. 6
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  24. 2
      com.unity.uiwidgets/Runtime/widgets/editable_text.cs
  25. 91
      com.unity.uiwidgets/Runtime/widgets/framework.cs
  26. 2
      com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs
  27. 2
      com.unity.uiwidgets/Runtime/widgets/selectable_text.cs
  28. 2
      com.unity.uiwidgets/Runtime/widgets/text.cs
  29. 4
      com.unity.uiwidgets/Runtime/widgets/transitions.cs
  30. 2
      com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
  31. 44
      com.unity.uiwidgets/Runtime/painting/placeholder_span.cs
  32. 3
      com.unity.uiwidgets/Runtime/painting/placeholder_span.cs.meta
  33. 109
      com.unity.uiwidgets/Runtime/widgets/widget_span.cs
  34. 3
      com.unity.uiwidgets/Runtime/widgets/widget_span.cs.meta

2
com.unity.uiwidgets/Runtime/foundation/assertions.cs


/// kernel transformer is used. The kernel transformer is required so that
/// debugging tools can provide interactive displays of objects described by
/// the error.
public ErrorDescription(String message) : base(message, level: DiagnosticLevel.info) {
public ErrorDescription(string message) : base(message, level: DiagnosticLevel.info) {
}
/// Calls to the default constructor may be rewritten to use this constructor

2
com.unity.uiwidgets/Runtime/painting/border_radius.cs


public static bool operator !=(BorderRadius a, BorderRadius b) {
return !Equals(a, b);
}
public BorderRadius resolve(TextDirection direction) => this;
public override string ToString() {
string visual = null;

9
com.unity.uiwidgets/Runtime/painting/box_border.cs


return new Border(top: side, right: side, bottom: side, left: side);
}
public static Border symmetric(
BorderSide vertical = null,
BorderSide horizontal = null
) {
vertical = vertical ?? BorderSide.none;
horizontal = horizontal ?? BorderSide.none;
return new Border(top: vertical, left: horizontal, right: horizontal, bottom: vertical);
}
public static Border all(
Color color = null,
float width = 1.0f,

40
com.unity.uiwidgets/Runtime/painting/box_decoration.cs


this.shape = shape;
}
public BoxDecoration copyWith(
Color color,
DecorationImage image,
Border border,
BorderRadius borderRadius,
List<BoxShadow> boxShadow,
Gradient gradient,
BlendMode? backgroundBlendMode,
BoxShape? shape
) {
return new BoxDecoration(
color: color ?? this.color,
image: image ?? this.image,
border: border ?? this.border,
borderRadius: borderRadius ?? this.borderRadius,
boxShadow: boxShadow ?? this.boxShadow,
gradient: gradient ?? this.gradient,
backgroundBlendMode: backgroundBlendMode ?? this.backgroundBlendMode,
shape: shape ?? this.shape
);
}
public override bool debugAssertIsValid() {
D.assert(shape != BoxShape.circle || borderRadius == null);
return base.debugAssertIsValid();

public override EdgeInsets padding {
get { return border?.dimensions; }
}
public override Path getClipPath(Rect rect, TextDirection textDirection) {
Path clipPath = null;
switch (shape) {
case BoxShape.circle:
clipPath = new Path();
clipPath.addOval(rect);
break;
case BoxShape.rectangle:
if (borderRadius != null) {
clipPath = new Path();
clipPath.addRRect(borderRadius.resolve(textDirection).toRRect(rect));
}
break;
}
return clipPath;
}
public BoxDecoration scale(float factor) {

2
com.unity.uiwidgets/Runtime/painting/decoration.cs


}
public abstract BoxPainter createBoxPainter(VoidCallback onChanged = null);
public virtual Path getClipPath(Rect rect, TextDirection textDirection) => null;
}
public abstract class BoxPainter : IDisposable {

16
com.unity.uiwidgets/Runtime/painting/edge_insets.cs


public readonly float top;
public readonly float bottom;
public static EdgeInsets infinity = fromLTRB(
float.PositiveInfinity,
float.PositiveInfinity,
float.PositiveInfinity,
float.PositiveInfinity
);
public bool isNonNegative {
get {
return left >= 0.0

);
}
public EdgeInsets clamp(EdgeInsets min, EdgeInsets max) {
return fromLTRB(
left.clamp(min.left, min.left),
top.clamp(min.top, min.top),
right.clamp(min.right, min.right),
bottom.clamp(min.bottom, min.bottom)
);
}
public static EdgeInsets operator -(EdgeInsets a, EdgeInsets b) {
return fromLTRB(
a.left - b.left,

25
com.unity.uiwidgets/Runtime/painting/gradient.cs


Offset center = bounds.center;
float originX = sinRadians * center.dy + oneMinusCosRadians * center.dx;
float originY = -sinRadians * center.dx + oneMinusCosRadians * center.dy;
var result = new Matrix4().identity();
var result = Matrix4.identity();
result.translate(originX, originY);
result.rotateZ(radians);
return result;

public abstract class Gradient {
public Gradient(
List<Color> colors = null,
List<float> stops = null
List<float> stops = null,
GradientTransform transform = null
this.transform = transform;
public readonly List<float> stops;
public readonly GradientTransform transform;

}
protected float[] _resolveTransform(Rect bounds, TextDirection? textDirection) {
return transform?.transform(bounds, textDirection: textDirection)?._m4storage;
return transform?.transform(bounds, textDirection: textDirection)?.storage;
}
}

Alignment end = null,
List<Color> colors = null,
List<float> stops = null,
TileMode tileMode = TileMode.clamp
) : base(colors: colors, stops: stops) {
TileMode tileMode = TileMode.clamp,
GradientTransform transform = null
) : base(colors: colors, stops: stops, transform: transform) {
this.begin = begin ?? Alignment.centerLeft;
this.end = end ?? Alignment.centerRight;
this.tileMode = tileMode;

float radius = 0.5f,
List<Color> colors = null,
List<float> stops = null,
TileMode tileMode = TileMode.clamp
) : base(colors: colors, stops: stops) {
TileMode tileMode = TileMode.clamp,
GradientTransform transform = null
) : base(colors: colors, stops: stops, transform: transform) {
this.center = center ?? Alignment.center;
this.radius = radius;
this.tileMode = tileMode;

float endAngle = Mathf.PI * 2,
List<Color> colors = null,
List<float> stops = null,
TileMode tileMode = TileMode.clamp
) : base(colors: colors, stops: stops) {
TileMode tileMode = TileMode.clamp,
GradientTransform transform = null
) : base(colors: colors, stops: stops, transform: transform) {
this.center = center ?? Alignment.center;
this.startAngle = startAngle;
this.endAngle = endAngle;

20
com.unity.uiwidgets/Runtime/painting/inline_span.cs


public abstract class InlineSpan : DiagnosticableTree, IEquatable<InlineSpan> {
public InlineSpan(
TextStyle style = null
TextStyle style , HoverRecognizer hoverRecognizer
this.hoverRecognizer = hoverRecognizer;
}
public readonly HoverRecognizer hoverRecognizer;
public bool hasHoverRecognizer {
get {
bool need = false;
visitChildren((text) => {
if (text.hoverRecognizer != null) {
need = true;
return false;
}
return true;
});
return need;
}
}
public readonly TextStyle style;

4
com.unity.uiwidgets/Runtime/painting/shape_decoration.cs


);
}
public override Path getClipPath(Rect rect, TextDirection textDirection) {
return shape.getOuterPath(rect);
}
public override EdgeInsets padding {
get { return shape.dimensions; }
}

74
com.unity.uiwidgets/Runtime/painting/text_painter.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;

}
}
List<TextBox> _inlinePlaceholderBoxes;
List<float> inlinePlaceholderScales {
get { return _inlinePlaceholderScales; }
}
List<float> _inlinePlaceholderScales;
public float minIntrinsicWidth {
get {
Debug.Assert(!_needsLayout);

void setPlaceholderDimensions(List<PlaceholderDimensions> value) {
if (value == null || value.isEmpty() || value.SequenceEqual(_placeholderDimensions)) {
return;
}
D.assert(() => {
int placeholderCount = 0;
text.visitChildren((InlineSpan span) => {
if (span is PlaceholderSpan) {
placeholderCount += 1;
}
return true;
});
return placeholderCount == value.Count;
});
_placeholderDimensions = value;
markNeedsLayout();
}
List<PlaceholderDimensions> _placeholderDimensions;
public float maxIntrinsicWidth {
get {
Debug.Assert(!_needsLayout);

public float width {
get {
Debug.Assert(!_needsLayout);
return _applyFloatingPointHack(_paragraph.width());
return _applyFloatingPointHack(textWidthBasis == TextWidthBasis.longestLine
? _paragraph.longestLine()
: _paragraph.width());
}
}

_needsLayout = false;
if (_paragraph == null) {
var builder = new ParagraphBuilder(_createParagraphStyle());
_text.build(builder, textScaleFactor);
_text.build(builder, textScaleFactor: textScaleFactor,
dimensions: _placeholderDimensions);
_inlinePlaceholderScales = builder.placeholderScales;
_paragraph = builder.build();
}

_paragraph.layout(new ParagraphConstraints(newWidth));
}
}
_inlinePlaceholderBoxes = _paragraph.getBoxesForPlaceholders();
}
public void paint(Canvas canvas, Offset offset) {

_previousCaretPrototype = caretPrototype;
}
public List<TextBox> getBoxesForSelection(TextSelection selection,
public List<TextBox> getBoxesForSelection(
TextSelection selection,
ui.BoxHeightStyle boxHeightStyle = ui.BoxHeightStyle.tight,
ui.BoxWidthStyle boxWidthStyle = ui.BoxWidthStyle.tight) {
D.assert(!_needsLayout);

D.assert(!_needsLayout);
return _paragraph.getWordBoundary(position);
}
TextRange getLineBoundary(TextPosition position) {
D.assert(!_needsLayout);
return _paragraph.getLineBoundary(position);

D.assert(textAlign != null);
D.assert(textDirection != null, () => "TextPainter.textDirection must be set to a non-null value before using the TextPainter.");
D.assert(textDirection != null,
() => "TextPainter.textDirection must be set to a non-null value before using the TextPainter.");
return _text.style?.getParagraphStyle(
textAlign: textAlign,
textDirection: textDirection ?? defaultTextDirection,

ellipsis: _ellipsis
// locale: _locale,
// strutStyle: _strutStyle,
) ?? new ui.ParagraphStyle(
) ?? new ParagraphStyle(
textAlign: textAlign,
textDirection: textDirection ?? defaultTextDirection,
maxLines: maxLines,

const int _zwjUtf16 = 0x200d;
Rect _getRectFromUpstream(int offset, Rect caretPrototype) {
string flattenedText = _text.toPlainText();
string flattenedText = _text.toPlainText(includePlaceholders: false);
bool needsSearch = _isUtf16Surrogate(prevCodeUnit.Value) || _text.codeUnitAt(offset) == _zwjUtf16;
bool needsSearch = _isUtf16Surrogate(prevCodeUnit.Value) || _text.codeUnitAt(offset) == _zwjUtf16 ||
_isUnicodeDirectionality(prevCodeUnit);
boxes = _paragraph.getBoxesForRange(prevRuneOffset, offset);
boxes = _paragraph.getBoxesForRange(prevRuneOffset, offset, boxHeightStyle: ui.BoxHeightStyle.strut);
if (boxes.isEmpty()) {
if (!needsSearch) {
break;

float caretEnd = box.end;
float dx = box.direction == TextDirection.rtl ? caretEnd - caretPrototype.width : caretEnd;
return Rect.fromLTRB(Mathf.Min(dx, width), box.top,
Mathf.Min(dx, width), box.bottom);
return Rect.fromLTRB(Mathf.Min(dx, _paragraph.width()), box.top,
Mathf.Min(dx, _paragraph.width()), box.bottom);
}
return null;

string flattenedText = _text.toPlainText();
string flattenedText = _text.toPlainText(includePlaceholders: false);
var nextCodeUnit =
_text.codeUnitAt(Mathf.Min(offset, flattenedText == null ? 0 : flattenedText.Length - 1));
if (nextCodeUnit == null) {

List<TextBox> boxes = null;
while ((boxes == null || boxes.isEmpty()) && flattenedText != null) {
int nextRuneOffset = offset + graphemeClusterLength;
boxes = _paragraph.getBoxesForRange(offset, nextRuneOffset);
boxes = _paragraph.getBoxesForRange(offset, nextRuneOffset, boxHeightStyle: ui.BoxHeightStyle.strut);
if (boxes.isEmpty()) {
if (!needsSearch) {
break;

TextBox box = boxes[boxes.Count - 1];
float caretStart = box.start;
float dx = box.direction == TextDirection.rtl ? caretStart - caretPrototype.width : caretStart;
return Rect.fromLTRB(Mathf.Min(dx, width), box.top,
Mathf.Min(dx, width), box.bottom);
return Rect.fromLTRB(Mathf.Min(dx, _paragraph.width()), box.top,
Mathf.Min(dx, _paragraph.width()), box.bottom);
}
return null;

static bool _isUtf16Surrogate(int value) {
return (value & 0xF800) == 0xD800;
}
bool _isUnicodeDirectionality(int? value) {
return value == 0x200F || value == 0x200E;
}
}
}

145
com.unity.uiwidgets/Runtime/painting/text_span.cs


public class TextSpan : InlineSpan, IEquatable<TextSpan> {
public delegate bool Visitor(TextSpan span);
public readonly TextStyle style;
public readonly List<TextSpan> children;
public readonly List<InlineSpan> children;
public readonly HoverRecognizer hoverRecognizer;
List<TextSpan> children = null,
List<InlineSpan> children = null,
string semanticsLabel = null) : base(style) {
string semanticsLabel = null) : base(style: style, hoverRecognizer: hoverRecognizer) {
this.style = style;
this.hoverRecognizer = hoverRecognizer;
this.semanticsLabel = semanticsLabel;
}

return null;
}
public bool hasHoverRecognizer {
get {
bool need = false;
visitTextSpan((text) => {
if (text.hoverRecognizer != null) {
need = true;
return false;
}
return true;
});
return need;
}
}
bool visitTextSpan(Visitor visitor) {
if (!string.IsNullOrEmpty(text)) {
if (!visitor.Invoke(this)) {
return false;
}
}
if (children != null) {
foreach (var child in children) {
if (!child.visitTextSpan(visitor)) {
return false;
}
}
}
return true;
}
public TextSpan getSpanForPosition(TextPosition position) {
D.assert(debugAssertIsValid());
var offset = 0;
var targetOffset = position.offset;
var affinity = position.affinity;
TextSpan result = null;
visitTextSpan((span) => {
var endOffset = offset + span.text.Length;
if ((targetOffset == offset && affinity == TextAffinity.downstream) ||
(targetOffset > offset && targetOffset < endOffset) ||
(targetOffset == endOffset && affinity == TextAffinity.upstream)) {
result = span;
return false;
}
offset = endOffset;
return true;
});
return result;
}
public int? codeUnitAt(int index) {
if (index < 0) {
return null;
}
var offset = 0;
int? result = null;
visitTextSpan(span => {
if (index - offset < span.text.Length) {
result = span.text[index - offset];
return false;
}
offset += span.text.Length;
return true;
});
return result;
}
if (!visitTextSpan(span => {
if (span.children != null) {
foreach (TextSpan child in span.children) {
if (child == null) {
return false;
}
if (children != null) {
foreach (InlineSpan child in children) {
if (child == null) {
throw new UIWidgetsError(
"A TextSpan object with a non-null child list should not have any nulls in its child list.\n" +
"The full text in question was:\n" +
toStringDeep(prefixLineOne: " "));
}
return true;
})) {
throw new UIWidgetsError(
"A TextSpan object with a non-null child list should not have any nulls in its child list.\n" +
"The full text in question was:\n" +
toStringDeep(prefixLineOne: " "));
D.assert(child.debugAssertIsValid());
}
return true;
return base.debugAssertIsValid();
if (other.GetType()!= GetType())
if (other.GetType() != GetType())
return RenderComparison.layout;
TextSpan textSpan = other as TextSpan;
if (textSpan.text != text ||

RenderComparison result = recognizer == textSpan.recognizer ?
RenderComparison.identical :
RenderComparison.metadata;
RenderComparison result = recognizer == textSpan.recognizer
? RenderComparison.identical
: RenderComparison.metadata;
if (style != null) {
RenderComparison candidate = style.compareTo(textSpan.style);
if (candidate > result)

}
if (children != null) {
for (int index = 0; index < children.Count; index += 1) {
RenderComparison candidate = children[index].compareTo(textSpan.children[index]);

return result;
}
}
return result;
}

public override int GetHashCode() {
unchecked {
var hashCode = (style != null ? style.GetHashCode() : 0);
var hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (children != null ? children.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (childHash());
hashCode = (hashCode * 397) ^ (semanticsLabel != null ? semanticsLabel.GetHashCode() : 0);
public bool Equals(TextSpan other) {
if (ReferenceEquals(null, other)) {
public bool Equals(InlineSpan otherInline) {
if (ReferenceEquals(null, otherInline)) {
if (ReferenceEquals(this, other)) {
if (ReferenceEquals(this, otherInline)) {
TextSpan other = otherInline as TextSpan;
return Equals(style, other.style) && string.Equals(text, other.text) &&
childEquals(children, other.children) && recognizer == other.recognizer;

}
}
static bool childEquals(List<TextSpan> left, List<TextSpan> right) {
static bool childEquals(List<InlineSpan> left, List<InlineSpan> right) {
if (ReferenceEquals(left, right)) {
return true;
}

return DiagnosticsNode.message("<null child>");
}
}).ToList();
}
public bool Equals(TextSpan other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return base.Equals(other) && text == other.text && Equals(children, other.children) &&
Equals(recognizer, other.recognizer) && semanticsLabel == other.semanticsLabel;
}
}
}

42
com.unity.uiwidgets/Runtime/painting/text_style.cs


public readonly Paint background;
public readonly string fontFamily;
public readonly List<BoxShadow> shadows;
public readonly List<ui.FontFeature> fontFeatures;
public List<string> fontFamilyFallback {
get { return _fontFamilyFallback; }

string fontFamily = null,
List<string> fontFamilyFallback = null,
List<BoxShadow> shadows = null,
List<ui.FontFeature> fontFeatures = null,
string debugLabel = null) {
D.assert(color == null || foreground == null, () => _kColorForegroundWarning);
D.assert(backgroundColor == null || background == null, () => _kColorBackgroundWarning);

this.foreground = foreground;
this.background = background;
this.shadows = shadows;
this.fontFeatures = fontFeatures;
}
public RenderComparison compareTo(TextStyle other) {

wordSpacing != other.wordSpacing || textBaseline != other.textBaseline ||
height != other.height || background != other.background ||
shadows.equalsList(other.shadows)) {
shadows.equalsList(other.shadows) || fontFeatures.equalsList(other.fontFeatures)) {
return RenderComparison.layout;
}

}
public ParagraphStyle getParagraphStyle(TextAlign textAlign,
TextDirection textDirection, string ellipsis, int? maxLines, float textScaleFactor = 1.0f) {
TextDirection textDirection, string ellipsis, int? maxLines,
ui.TextHeightBehavior textHeightBehavior = null,
float textScaleFactor = 1.0f) {
textAlign: textAlign, textDirection: textDirection, fontWeight: fontWeight, fontStyle: fontStyle,
maxLines: maxLines, fontSize: (fontSize ?? _defaultFontSize) * textScaleFactor, fontFamily: fontFamily,
textAlign: textAlign,
textDirection: textDirection,
fontWeight: fontWeight,
fontStyle: fontStyle,
maxLines: maxLines,
fontSize: (fontSize ?? _defaultFontSize) * textScaleFactor,
fontFamily: fontFamily,
textHeightBehavior: textHeightBehavior,
ellipsis: ellipsis
);
}

decorationThickness: decorationThickness == null
? null
: decorationThickness * decorationThicknessFactor + decorationThicknessDelta,
shadows: shadows ?? this.shadows,
shadows: shadows ?? this.shadows,
fontFeatures: fontFeatures,
debugLabel: modifiedDebugLabel
);
}

decorationStyle: other.decorationStyle,
decorationThickness: other.decorationThickness,
shadows: other.shadows,
fontFeatures: other.fontFeatures,
debugLabel: mergedDebugLabel
);
}

TextDecorationStyle? decorationStyle = null,
float? decorationThickness = null,
List<BoxShadow> shadows = null,
List<ui.FontFeature> fontFeatures = null,
string debugLabel = null) {
D.assert(color == null || foreground == null, () => _kColorForegroundWarning);
D.assert(backgroundColor == null || background == null, () => _kColorBackgroundWarning);

foreground: foreground ?? this.foreground,
background: background ?? this.background,
shadows: shadows ?? this.shadows,
fontFeatures: fontFeatures ?? this.fontFeatures,
debugLabel: newDebugLabel
);
}

decorationStyle: t < 0.5f ? null : b.decorationStyle,
decorationThickness: t < 0.5f ? null : b.decorationThickness,
shadows: t < 0.5f ? null : b.shadows,
fontFeatures: t < 0.5 ? null : b.fontFeatures,
debugLabel: lerpDebugLabel
);
}

decorationStyle: t < 0.5f ? a.decorationStyle : null,
decorationThickness: t < 0.5f ? a.decorationThickness : null,
shadows: t < 0.5f ? a.shadows : null,
fontFeatures: t < 0.5 ? a.fontFeatures : null,
debugLabel: lerpDebugLabel
);
}

a.decorationThickness ?? b.decorationThickness ?? 0.0f,
b.decorationThickness ?? a.decorationThickness ?? 0.0f, t),
shadows: t < 0.5f ? a.shadows : b.shadows,
fontFeatures: t < 0.5 ? a.fontFeatures : b.fontFeatures,
public ui.TextStyle getTextStyle(float textScaleFactor = 1.0f ) {
public ui.TextStyle getTextStyle(float textScaleFactor = 1.0f) {
return new ui.TextStyle(
color: color,
decoration: decoration,

// locale: locale,
foreground: foreground,
background: background ?? (backgroundColor != null
? backgroundPaint : null
? backgroundPaint
: null
shadows: shadows?.Cast<Shadow>().ToList()
// fontFeatures: fontFeatures,
shadows: shadows?.Cast<Shadow>().ToList(),
fontFeatures: fontFeatures
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);

Equals(background, other.background) &&
fontFamilyFallback.equalsList(other.fontFamilyFallback) &&
shadows.equalsList(other.shadows) &&
fontFeatures.equalsList(other.fontFeatures) &&
string.Equals(fontFamily, other.fontFamily);
}

hashCode = (hashCode * 397) ^
(fontFamilyFallback != null ? fontFamilyFallback.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (shadows != null ? shadows.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (fontFeatures != null ? fontFeatures.GetHashCode() : 0);
return hashCode;
}
}

2
com.unity.uiwidgets/Runtime/rendering/box.cs


) {
D.assert(hitTest != null);
return addWithRawTransform(
transform: offset != null ? new Matrix4().translationValues(-offset.dx, -offset.dy, 0) : null,
transform: offset != null ? Matrix4.translationValues(-offset.dx, -offset.dy, 0) : null,
position: position,
hitTest: hitTest
);

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


public class TransformLayer : OffsetLayer {
public TransformLayer(Matrix4 transform = null, Offset offset = null) : base(offset) {
_transform = transform ?? new Matrix4().identity();
_transform = transform ?? Matrix4.identity();
}
public Matrix4 transform {

var totalOffset = offset + layerOffset;
if (totalOffset != Offset.zero) {
_lastEffectiveTransform = new Matrix4().translationValues(totalOffset.dx, totalOffset.dy, 0);
_lastEffectiveTransform = Matrix4.translationValues(totalOffset.dx, totalOffset.dy, 0);
_lastEffectiveTransform.multiply(transform);
}

_lastOffset = offset + layerOffset;
if (_lastOffset != Offset.zero) {
engineLayer = builder.pushTransform(
new Matrix4()
.translationValues(_lastOffset.dx, _lastOffset.dy,0)
Matrix4.translationValues(_lastOffset.dx, _lastOffset.dy,0)
._m4storage,
oldLayer: engineLayer as TransformEngineLayer);
}

Offset _lastOffset;
Matrix4 _lastTransform;
Matrix4 _invertedTransform = new Matrix4().identity();
Matrix4 _invertedTransform = Matrix4.identity();
bool _inverseDirty = true;
internal override S find<S>(Offset regionOffset) {

return null;
}
Matrix4 result = new Matrix4().translationValues(-_lastOffset.dx, -_lastOffset.dy,0 );
Matrix4 result = Matrix4.translationValues(-_lastOffset.dx, -_lastOffset.dy,0 );
Matrix4 result = new Matrix4().identity();
Matrix4 result = Matrix4.identity();
for (int index = layers.Count - 1; index > 0; index -= 1) {
layers[index].applyTransform(layers[index - 1], result);
}

}
else {
_lastOffset = null;
var matrix = new Matrix4().translationValues(unlinkedOffset.dx, unlinkedOffset.dy, 0);
var matrix = Matrix4.translationValues(unlinkedOffset.dx, unlinkedOffset.dy, 0);
engineLayer = builder.pushTransform(
matrix._m4storage,
oldLayer: engineLayer as TransformEngineLayer);

transform.multiply(_lastTransform);
}
else {
transform.multiply(new Matrix4().translationValues(unlinkedOffset.dx, unlinkedOffset.dy, 0));
transform.multiply(Matrix4.translationValues(unlinkedOffset.dx, unlinkedOffset.dy, 0));
}
}

internal Path _debugTransformedClipPath {
get {
ContainerLayer ancestor = parent;
Matrix4 matrix = new Matrix4().identity();
Matrix4 matrix = Matrix4.identity();
while (ancestor != null && ancestor.parent != null) {
ancestor.applyTransform(this, matrix);
ancestor = ancestor.parent;

2
com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs


var radius = size.height * _diameterRatio / 2.0f;
var deltaY = radius * Mathf.Sin(angle);
Matrix4 transform = new Matrix4().identity();
Matrix4 transform = Matrix4.identity();
// Matrix4x4 transform2 = MatrixUtils.createCylindricalProjectionTransform(
// radius: this.size.height * this._diameterRatio / 2.0f,
// angle: angle,

4
com.unity.uiwidgets/Runtime/rendering/object.cs


effectiveTransform = transform;
}
else {
effectiveTransform = new Matrix4().translationValues(offset.dx, offset.dy, 0);
effectiveTransform = Matrix4.translationValues(offset.dx, offset.dy, 0);
effectiveTransform.multiply(transform);
effectiveTransform.translate(-offset.dx, -offset.dy);
}

renderers.Add(renderer);
}
var transform = new Matrix4().identity();
var transform = Matrix4.identity();
for (int index = renderers.Count - 1; index > 0; index -= 1) {
renderers[index].applyPaintTransform(renderers[index - 1], transform);
}

16
com.unity.uiwidgets/Runtime/rendering/proxy_box.cs


Matrix4 _transform;
public void setIdentity() {
_transform = new Matrix4().identity();
_transform = Matrix4.identity();
_transform.rotateX(degrees);
markNeedsPaint();
_transform.rotateY(degrees);
markNeedsPaint();
//2D, do nothing
}

}
public void translate(float x, float y = 0.0f, float z = 0.0f) {
_transform.translationValues(x, y, 0);
_transform.translate(x, y, z);
markNeedsPaint();
}

return _transform;
}
var result = new Matrix4().identity();
var result = Matrix4.identity();
if (_origin != null) {
result.translate(_origin.dx, _origin.dy);
}

if (child == null) {
_hasVisualOverflow = false;
_transform = new Matrix4().identity();
_transform = Matrix4.identity();
}
else {
_resolve();

Rect sourceRect = _resolvedAlignment.inscribe(sizes.source, Offset.zero & childSize);
Rect destinationRect = _resolvedAlignment.inscribe(sizes.destination, Offset.zero & size);
_hasVisualOverflow = sourceRect.width < childSize.width || sourceRect.height < childSize.height;
_transform = new Matrix4().translationValues(destinationRect.left, destinationRect.top, 0);
_transform = Matrix4.translationValues(destinationRect.left, destinationRect.top, 0);
_transform.scale(scaleX, scaleY, 1);
_transform.translate(-sourceRect.left, -sourceRect.top);
}

new FollowerLayer _layer;
Matrix4 getCurrentTransform() {
return _layer?.getLastTransform() ?? new Matrix4().identity();
return _layer?.getLastTransform() ?? Matrix4.identity();
}
public override bool hitTest(BoxHitTestResult result, Offset position) {

2
com.unity.uiwidgets/Runtime/rendering/rotated_box.cs


size = _isVertical
? new Size(child.size.height, child.size.width)
: child.size;
_paintTransform = new Matrix4().identity();
_paintTransform = Matrix4.identity();
_paintTransform.translate(size.width / 2.0f, size.height / 2.0f);
_paintTransform.rotateZ(RotatedBoxUtils._kQuarterTurnsInRadians * (quarterTurns % 4));
_paintTransform.translate(-child.size.width / 2.0f, -child.size.height / 2.0f);

2
com.unity.uiwidgets/Runtime/rendering/sliver.cs


D.assert(crossAxisPosition != null);
D.assert(hitTest != null);
if (paintOffset != null) {
pushTransform(new Matrix4().translationValues(-paintOffset.dx, -paintOffset.dy, 0));
pushTransform(Matrix4.translationValues(-paintOffset.dx, -paintOffset.dy, 0));
}
bool isHit = hitTest(
this,

2
com.unity.uiwidgets/Runtime/rendering/view.cs


public readonly float devicePixelRatio;
public Matrix4 toMatrix() {
return new Matrix4().diagonal3Values(devicePixelRatio, devicePixelRatio, 0);
return Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 0);
//return new Matrix4().identity();
}

2
com.unity.uiwidgets/Runtime/rendering/viewport.cs


if (!child.geometry.visible) {
continue;
}
Matrix4 transform = new Matrix4().identity();
Matrix4 transform = Matrix4.identity();
applyPaintTransform(child, transform);
bool isHit = result.addWithPaintTransform(
transform: transform,

886
com.unity.uiwidgets/Runtime/ui2/Matrix4.cs
文件差异内容过多而无法显示
查看文件

6
com.unity.uiwidgets/Runtime/widgets/basic.cs


Widget child = null,
float degree = 0.0f
) : base(key: key, child: child) {
transform = new Matrix4().rotationZ(degree);
transform = Matrix4.rotationZ(degree);
this.origin = origin;
this.alignment = alignment;
this.transformHitTests = transformHitTests;

Widget child = null
) : base(key: key, child: child) {
D.assert(offset != null);
transform = new Matrix4().translationValues(offset.dx, offset.dy, 0);
transform = Matrix4.translationValues(offset.dx, offset.dy, 0);
origin = null;
alignment = null;
this.transformHitTests = transformHitTests;

bool transformHitTests = true,
Widget child = null
) : base(key: key, child: child) {
transform = new Matrix4().translationValues(scale, scale, scale);
transform = Matrix4.translationValues(scale, scale, scale);
this.origin = origin;
this.alignment = alignment;
this.transformHitTests = transformHitTests;

2
com.unity.uiwidgets/Runtime/widgets/editable_text.cs


return new TextSpan(
style: widget.style,
children: new List<TextSpan> {
children: new List<InlineSpan> {
new TextSpan(text: _value.composing.textBefore(_value.text)),
new TextSpan(
style: composingStyle,

91
com.unity.uiwidgets/Runtime/widgets/framework.cs


: base(key: key, child: child) {
}
public abstract bool debugIsValidAncestor(RenderObjectWidget ancestor);
public abstract bool debugIsValidRenderObject(RenderObject renderObject);
string ownershipChain = null,
DiagnosticsNode ownershipChain = null,
bool foundValidAncestor = false,
IEnumerable<Widget> badAncestors = null
);

return new ParentDataElement(this);
}
public override bool debugIsValidAncestor(RenderObjectWidget ancestor) {
public override bool debugIsValidRenderObject(RenderObject renderObject) {
return ancestor is T;
return renderObject is T;
string ownershipChain = null,
DiagnosticsNode ownershipChain = null,
bool foundValidAncestor = false,
IEnumerable<Widget> badAncestors = null
) {

properties.add(new FlagProperty("dirty", value: dirty, ifTrue: "dirty"));
if (_dependencies != null && _dependencies.isNotEmpty()) {
List<DiagnosticsNode> diagnosticsDependencies = _dependencies
.Select((InheritedElement element) => element.widget.toDiagnosticsNode(style: DiagnosticsTreeStyle.sparse))
.Select((InheritedElement element) =>
element.widget.toDiagnosticsNode(style: DiagnosticsTreeStyle.sparse))
.ToList();
properties.add(new DiagnosticsProperty<List<DiagnosticsNode>>("dependencies", diagnosticsDependencies));
}

public delegate Widget IndexedWidgetBuilder(BuildContext context, int index);
public delegate Widget TransitionBuilder(BuildContext context, Widget child);
public delegate Widget ControlsWidgetBuilder(BuildContext context, VoidCallback onStepContinue = null, VoidCallback onStepCancel = null);
public delegate Widget ControlsWidgetBuilder(BuildContext context, VoidCallback onStepContinue = null,
VoidCallback onStepCancel = null);
public abstract class ComponentElement : Element {
protected ComponentElement(Widget widget) : base(widget) {

public new ParentDataWidget widget {
get { return (ParentDataWidget) base.widget; }
}
public override void mount(Element parent, object newSlot) {
D.assert(() => {
var badAncestors = new List<Widget>();
Element ancestor = parent;
while (ancestor != null) {
if (ancestor is ParentDataElement) {
badAncestors.Add(ancestor.widget);
}
else if (ancestor is RenderObjectElement) {
if (widget.debugIsValidAncestor(((RenderObjectElement) ancestor).widget)) {
break;
}
badAncestors.Add(ancestor.widget);
}
ancestor = ancestor._parent;
}
if (ancestor != null && badAncestors.isEmpty()) {
return true;
}
throw new UIWidgetsError(
"Incorrect use of ParentDataWidget.\n" +
widget.debugDescribeInvalidAncestorChain(
description: ToString(),
ownershipChain: parent.debugGetCreatorChain(10),
foundValidAncestor: ancestor != null,
badAncestors: badAncestors
)
);
});
base.mount(parent, newSlot);
}
void _applyParentData(ParentDataWidget widget) {
ElementVisitor applyParentDataToChild = null;
applyParentDataToChild = child => {

}
protected override void notifyClients(ProxyWidget oldWidget) {
_applyParentData(widget);
_applyParentData((ParentDataWidget) widget);
}
}

base.deactivate();
D.assert(!renderObject.attached,
() => "A RenderObject was still attached when attempting to deactivate its " +
"RenderObjectElement: " + renderObject);
"RenderObjectElement: " + renderObject);
}
public override void unmount() {

"RenderObjectElement: " + renderObject);
"RenderObjectElement: " + renderObject);
internal void _updateParentData(ParentDataWidget parentData) {
parentData.applyParentData(renderObject);
internal void _updateParentData(ParentDataWidget parentDataWidget) {
bool applyParentData = true;
D.assert(() => {
try {
if (!parentDataWidget.debugIsValidRenderObject(renderObject)) {
applyParentData = false;
throw new UIWidgetsError(
"Incorrect use of ParentDataWidget.\n" +
parentDataWidget.debugDescribeInvalidAncestorChain(
description: ToString(),
ownershipChain: new ErrorDescription(debugGetCreatorChain(10)),
foundValidAncestor: _ancestorRenderObjectElement.widget != null
// badAncestors: badAncestors
)
);
}
}
catch (UIWidgetsError e) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
context: "while apply parent data",
exception: e
));
}
return true;
});
if (applyParentData)
parentDataWidget.applyParentData(renderObject);
}
internal override void _updateSlot(object newSlot) {

2
com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs


.scaled(1.0f - t)
.add(endRotation.scaled(t)).normalized;
Vector3 lerpScale = beginScale * (1.0f - t) + endScale * t;
return new Matrix4().compose(lerpTranslation, lerpRotation, lerpScale);
return Matrix4.compose(lerpTranslation, lerpRotation, lerpScale);
}
}

2
com.unity.uiwidgets/Runtime/widgets/selectable_text.cs


text: new TextSpan(
style: effectiveTextStyle,
text: widget.data,
children: widget.textSpan != null ? new List<TextSpan> {widget.textSpan} : null
children: widget.textSpan != null ? new List<InlineSpan> {widget.textSpan} : null
),
onSelectionChanged: () => {
if (_hasFocus) {

2
com.unity.uiwidgets/Runtime/widgets/text.cs


text: new TextSpan(
style: effectiveTextStyle,
text: data,
children: textSpan != null ? new List<TextSpan> {textSpan} : null
children: textSpan != null ? new List<InlineSpan> {textSpan} : null
)
);
}

4
com.unity.uiwidgets/Runtime/widgets/transitions.cs


protected internal override Widget build(BuildContext context) {
float scaleValue = scale.value;
Matrix4 transform = new Matrix4().diagonal3Values(scaleValue, scaleValue, 1);
Matrix4 transform = Matrix4.diagonal3Values(scaleValue, scaleValue, 1);
return new Transform(
transform: transform,
alignment: alignment,

protected internal override Widget build(BuildContext context) {
float turnsValue = turns.value;
Matrix4 transform = new Matrix4().rotationZ((turnsValue * Mathf.PI * 2.0f));
Matrix4 transform = Matrix4.rotationZ((turnsValue * Mathf.PI * 2.0f));
return new Transform(
transform: transform,
alignment: alignment,

2
com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs


var hit = false;
var inverse = new Matrix4().inverted(transform);
var inverse = Matrix4.inverted(transform);
if (inverse == null) {
return false;
}

44
com.unity.uiwidgets/Runtime/painting/placeholder_span.cs


using System.Collections.Generic;
using System.Text;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.painting {
abstract class PlaceholderSpan : InlineSpan {
public PlaceholderSpan(
TextBaseline baseline,
TextStyle style,
PlaceholderAlignment alignment = PlaceholderAlignment.bottom,
HoverRecognizer hoverRecognizer = null
) : base(style: style, hoverRecognizer: hoverRecognizer) {
this.baseline = baseline;
this.alignment = alignment;
}
public PlaceholderAlignment alignment;
public TextBaseline baseline;
public override void computeToPlainText(
StringBuilder buffer,
bool includeSemanticsLabels = true,
bool includePlaceholders = true
) {
if (includePlaceholders) {
buffer.Append('\uFFFC');
}
}
public override void computeSemanticsInformation(List<InlineSpanSemanticsInformation> collector) {
collector.Add(InlineSpanSemanticsInformation.placeholder);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<PlaceholderAlignment>("alignment", alignment, defaultValue: null));
properties.add(new EnumProperty<TextBaseline>("baseline", baseline, defaultValue: null));
}
}
}

3
com.unity.uiwidgets/Runtime/painting/placeholder_span.cs.meta


fileFormatVersion: 2
guid: c1dc25aeb48f4abbb683062b2a1d4582
timeCreated: 1606291325

109
com.unity.uiwidgets/Runtime/widgets/widget_span.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.widgets {
class WidgetSpan : PlaceholderSpan {
public WidgetSpan(
Widget child,
TextBaseline baseline,
TextStyle style,
PlaceholderAlignment alignment = PlaceholderAlignment.bottom
) : base(
alignment: alignment,
baseline: baseline,
style: style
) {
D.assert(child != null);
D.assert(!(
(alignment == PlaceholderAlignment.aboveBaseline) ||
(alignment == PlaceholderAlignment.belowBaseline) ||
(alignment == PlaceholderAlignment.baseline)
));
this.child = child;
}
Widget child;
public override void build(
ParagraphBuilder builder,
float textScaleFactor = 1.0f,
List<PlaceholderDimensions> dimensions = null) {
D.assert(DebugAssertIsValid());
D.assert(dimensions != null);
bool hasStyle = style != null;
if (hasStyle) {
builder.pushStyle(style.getTextStyle(textScaleFactor: textScaleFactor));
}
D.assert(builder.placeholderCount < dimensions.Count);
PlaceholderDimensions currentDimensions = dimensions[builder.placeholderCount];
builder.addPlaceholder(
currentDimensions.size.width,
currentDimensions.size.height,
alignment,
scale: textScaleFactor,
baseline: currentDimensions.baseline,
baselineOffset: currentDimensions.baselineOffset
);
if (hasStyle) {
builder.pop();
}
}
public override bool visitChildren(InlineSpanVisitor visitor) {
return visitor(this);
}
protected override InlineSpan getSpanForPositionVisitor(TextPosition position, Accumulator offset) {
if (position.offset == offset.value) {
return this;
}
offset.increment(1);
return null;
}
protected override int? codeUnitAtVisitor(int index, Accumulator offset) {
return null;
}
public override RenderComparison compareTo(InlineSpan other) {
if (this == other)
return RenderComparison.identical;
if ((style == null) != (other.style == null))
return RenderComparison.layout;
WidgetSpan typedOther = other as WidgetSpan;
if (child.Equals(typedOther.child) || alignment != typedOther.alignment) {
return RenderComparison.layout;
}
RenderComparison result = RenderComparison.identical;
if (style != null) {
RenderComparison candidate = style.compareTo(other.style);
if ((int) candidate > (int) result)
result = candidate;
if (result == RenderComparison.layout)
return result;
}
return result;
}
public override int GetHashCode() {
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (child.GetHashCode());
hashCode = (hashCode * 397) ^ (alignment.GetHashCode());
hashCode = (hashCode * 397) ^ (baseline.GetHashCode());
return hashCode;
}
public bool DebugAssertIsValid() {
return true;
}
}
}

3
com.unity.uiwidgets/Runtime/widgets/widget_span.cs.meta


fileFormatVersion: 2
guid: 5d48514e70d8418195ae5d7352f15a0e
timeCreated: 1606303521
正在加载...
取消
保存