浏览代码

Merge branch 'siyaoH/skiaBase' into shiyun/skia

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
e7cbeabb
共有 67 个文件被更改,包括 3913 次插入538 次删除
  1. 142
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
  2. 84
      com.unity.uiwidgets/Runtime/foundation/assertions.cs
  3. 71
      com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
  4. 7
      com.unity.uiwidgets/Runtime/gestures/mouse_tracking.cs
  5. 35
      com.unity.uiwidgets/Runtime/painting/binding.cs
  6. 2
      com.unity.uiwidgets/Runtime/painting/border_radius.cs
  7. 9
      com.unity.uiwidgets/Runtime/painting/box_border.cs
  8. 40
      com.unity.uiwidgets/Runtime/painting/box_decoration.cs
  9. 2
      com.unity.uiwidgets/Runtime/painting/decoration.cs
  10. 16
      com.unity.uiwidgets/Runtime/painting/edge_insets.cs
  11. 25
      com.unity.uiwidgets/Runtime/painting/gradient.cs
  12. 215
      com.unity.uiwidgets/Runtime/painting/image_provider.cs
  13. 20
      com.unity.uiwidgets/Runtime/painting/inline_span.cs
  14. 4
      com.unity.uiwidgets/Runtime/painting/shape_decoration.cs
  15. 74
      com.unity.uiwidgets/Runtime/painting/text_painter.cs
  16. 145
      com.unity.uiwidgets/Runtime/painting/text_span.cs
  17. 42
      com.unity.uiwidgets/Runtime/painting/text_style.cs
  18. 24
      com.unity.uiwidgets/Runtime/rendering/binding.cs
  19. 2
      com.unity.uiwidgets/Runtime/rendering/box.cs
  20. 96
      com.unity.uiwidgets/Runtime/rendering/error.cs
  21. 19
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  22. 2
      com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs
  23. 4
      com.unity.uiwidgets/Runtime/rendering/object.cs
  24. 16
      com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
  25. 2
      com.unity.uiwidgets/Runtime/rendering/rotated_box.cs
  26. 2
      com.unity.uiwidgets/Runtime/rendering/sliver.cs
  27. 17
      com.unity.uiwidgets/Runtime/rendering/view.cs
  28. 2
      com.unity.uiwidgets/Runtime/rendering/viewport.cs
  29. 886
      com.unity.uiwidgets/Runtime/ui2/Matrix4.cs
  30. 2
      com.unity.uiwidgets/Runtime/ui2/isolate.cs
  31. 99
      com.unity.uiwidgets/Runtime/ui2/painting.cs
  32. 10
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  33. 35
      com.unity.uiwidgets/Runtime/widgets/binding.cs
  34. 1
      com.unity.uiwidgets/Runtime/widgets/dismissible.cs
  35. 2
      com.unity.uiwidgets/Runtime/widgets/editable_text.cs
  36. 708
      com.unity.uiwidgets/Runtime/widgets/framework.cs
  37. 2
      com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs
  38. 2
      com.unity.uiwidgets/Runtime/widgets/layout_builder.cs
  39. 2
      com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs
  40. 2
      com.unity.uiwidgets/Runtime/widgets/selectable_text.cs
  41. 2
      com.unity.uiwidgets/Runtime/widgets/sliver.cs
  42. 2
      com.unity.uiwidgets/Runtime/widgets/sliver_persistent_header.cs
  43. 2
      com.unity.uiwidgets/Runtime/widgets/table.cs
  44. 2
      com.unity.uiwidgets/Runtime/widgets/text.cs
  45. 4
      com.unity.uiwidgets/Runtime/widgets/transitions.cs
  46. 6
      com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
  47. 2
      engine/Build.bee.cs
  48. 1
      engine/README.md
  49. 6
      engine/src/lib/ui/painting/path.h
  50. 52
      engine/src/lib/ui/painting/path_measure.cc
  51. 3
      engine/src/lib/ui/painting/path_measure.h
  52. 8
      engine/src/shell/platform/unity/unity_surface_manager.cc
  53. 7
      Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/confetti.json.meta
  54. 1001
      Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/test.gif
  55. 7
      Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/test.gif.meta
  56. 1
      Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/wine.json
  57. 7
      Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/wine.json.meta
  58. 44
      com.unity.uiwidgets/Runtime/painting/placeholder_span.cs
  59. 3
      com.unity.uiwidgets/Runtime/painting/placeholder_span.cs.meta
  60. 132
      com.unity.uiwidgets/Runtime/rendering/lottie.cs
  61. 3
      com.unity.uiwidgets/Runtime/rendering/lottie.cs.meta
  62. 104
      com.unity.uiwidgets/Runtime/widgets/LottiePainter.cs
  63. 3
      com.unity.uiwidgets/Runtime/widgets/LottiePainter.cs.meta
  64. 109
      com.unity.uiwidgets/Runtime/widgets/widget_span.cs
  65. 3
      com.unity.uiwidgets/Runtime/widgets/widget_span.cs.meta
  66. 41
      engine/src/lib/ui/painting/skottie.cc
  67. 26
      engine/src/lib/ui/painting/skottie.h

142
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;

using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Image = Unity.UIWidgets.widgets.Image;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
using Unity.UIWidgets.cupertino;

{
public bool switchValue = false;
private float frame = 0;
var widgets = new List<Widget>();
widgets.Add(new Expanded(child: new Text("a switch")));
widgets.Add(new CupertinoSwitch(
value: switchValue,
onChanged: value => { setState(() => switchValue = value); }
));
var rowWidgtes = new List<Widget>();
var row = new Row(children: widgets);
//rowWidgtes.Add(row);
return new Container(
color: Colors.green,
child: new Column(
children: new List<Widget>
{
AnimatedLottie.file("wine.json", frame: frame, curve: Curves.linear),
new Container(
width: 100,
height: 100,
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Image.file("test.gif", gaplessPlayback: true)
),
new Container(
width: 200,
height: 100,
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Image.network(
"https://unity-cn-cms-prd-1254078910.cos.ap-shanghai.myqcloud.com/assetstore-cms-media/img-7dfe215f-0075-4f9c-9b5a-be5ee88b866b",
gaplessPlayback: true)
),
new Text("Counter: " + counter,
style: new TextStyle(fontSize: 18, fontWeight: FontWeight.w100)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "racher", fontSize: 18, fontWeight: FontWeight.w100)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w200)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w300)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w400)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w500)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w600)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w700)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w800)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w900)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w900,
fontStyle: FontStyle.italic)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w100)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "roboto", fontSize: 18, fontWeight: FontWeight.w900)),
new Text("-----"),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "robotox", fontSize: 18, fontWeight: FontWeight.w200)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "robotox", fontSize: 18, fontWeight: FontWeight.w300)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "robotox", fontSize: 18, fontWeight: FontWeight.w400)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "robotox", fontSize: 18, fontWeight: FontWeight.w500)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "robotox", fontSize: 18, fontWeight: FontWeight.w600)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "robotox", fontSize: 18, fontWeight: FontWeight.w700)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "robotox", fontSize: 18, fontWeight: FontWeight.w800)),
new Text("Counter: " + counter,
style: new TextStyle(fontFamily: "robotox", fontSize: 18, fontWeight: FontWeight.w900)),
new Text("Counter: " + counter + (char) 0xf472 + (char) 0xf442 + (char) 0xf43b,
style: new TextStyle(fontFamily: "robotox", fontSize: 18, fontWeight: FontWeight.w900,
fontStyle: FontStyle.italic)),
new Text("Counter: " + counter + (char) 0xf472 + (char) 0xf442 + (char) 0xf43b,
style: new TextStyle(fontFamily: "CupertinoIcons", fontSize: 18)),
var cupBtn = new CupertinoButton(
child: new Text("launch action sheet"),
onPressed: () =>
{
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
builder: (context1) =>
{
return new CupertinoActionSheet(
title: new Text("some choices"),
actions: new List<Widget>()
new GestureDetector(
onTap: () =>
{
setState(() =>
new CupertinoActionSheetAction(
child: new Text("one"),
onPressed: () => { Navigator.pop(context1, 1); },
isDefaultAction: true
),
new CupertinoActionSheetAction(
child: new Text("two"),
onPressed: () => { Navigator.pop(context1, 2); }
),
new CupertinoActionSheetAction(
child: new Text("three"),
onPressed: () => { Navigator.pop(context1, 3); }
)
}
);
}
);
}
);
rowWidgtes.Add(cupBtn);
return new CupertinoPageScaffold(
child: new Center(
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: rowWidgtes
)
counter++;
frame += 1;
});
},
child: new Container(
padding: EdgeInsets.symmetric(20, 20),
color: counter % 2 == 0 ? Colors.blue : Colors.red,
child: new Text("Click Me",
style: new TextStyle(fontFamily: "racher", fontWeight: FontWeight.w100))
)
)
}
)
/*,
navigationBar: new CupertinoNavigationBar(

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


}
}
}
internal abstract class _ErrorDiagnostic : DiagnosticsProperty<List<object>> {
/// This constructor provides a reliable hook for a kernel transformer to find
/// error messages that need to be rewritten to include object references for
/// interactive display of errors.
internal _ErrorDiagnostic(
String message,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse, // DiagnosticsTreeStyle.flat
DiagnosticLevel level = DiagnosticLevel.info
) : base(
name: null,
value: new List<object>() {message},
showName: false,
showSeparator: false,
defaultValue: null,
style: style,
level: level) {
D.assert(message != null);
}
/// In debug builds, a kernel transformer rewrites calls to the default
/// constructors for [ErrorSummary], [ErrorDetails], and [ErrorHint] to use
/// this constructor.
//
// ```dart
// _ErrorDiagnostic('Element $element must be $color')
// ```
// Desugars to:
// ```dart
// _ErrorDiagnostic.fromParts(<Object>['Element ', element, ' must be ', color])
// ```
//
// Slightly more complex case:
// ```dart
// _ErrorDiagnostic('Element ${element.runtimeType} must be $color')
// ```
// Desugars to:
//```dart
// _ErrorDiagnostic.fromParts(<Object>[
// 'Element ',
// DiagnosticsProperty(null, element, description: element.runtimeType?.toString()),
// ' must be ',
// color,
// ])
// ```
internal _ErrorDiagnostic(
List<object> messageParts,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse,
DiagnosticLevel level = DiagnosticLevel.info
) : base(
name: null,
value: messageParts,
showName: false,
showSeparator: false,
defaultValue: null,
style: style,
level: level) {
D.assert(messageParts != null);
}
protected override string valueToString(TextTreeConfiguration parentConfiguration = null) {
return String.Join("", value);
}
}
internal class ErrorDescription : _ErrorDiagnostic {
/// A lint enforces that this constructor can only be called with a string
/// literal to match the limitations of the Dart Kernel transformer that
/// optionally extracts out objects referenced using string interpolation in
/// the message passed in.
///
/// The message will display with the same text regardless of whether the
/// 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) {
}
/// Calls to the default constructor may be rewritten to use this constructor
/// in debug mode using a kernel transformer.
// ignore: unused_element
public ErrorDescription(List<object> messageParts) : base(messageParts, level: DiagnosticLevel.info) {
}
}
}

71
com.unity.uiwidgets/Runtime/foundation/diagnostics.cs


prefixOtherLinesRootNode: ""
);
}
class _PrefixedStringBuilder {
internal _PrefixedStringBuilder(string prefixLineOne, string prefixOtherLines) {
this.prefixLineOne = prefixLineOne;

internal _NoDefaultValue() {
}
}
class _NullDefaultValue {
internal _NullDefaultValue() {
}

public static readonly object kNoDefaultValue = new _NoDefaultValue();
public static readonly object kNullDefaultValue = new _NullDefaultValue();

protected DiagnosticsNode(
string name = null,
DiagnosticsTreeStyle? style = null,
String linePrefix = null,
bool showName = true,
bool showSeparator = true
) {

_style = style;
_showName = showName;
this.showSeparator = showSeparator;
this.linePrefix = linePrefix;
}
public static DiagnosticsNode message(

get { return null; }
}
readonly string linePrefix;
public abstract object valueObject { get; }
public virtual DiagnosticsTreeStyle? style {

readonly DiagnosticsTreeStyle? _style;
public bool allowWrap {
get { return false; }
}
public bool allowNameWrap {
get { return false; }
}
public bool allowTruncate {
get { return false; }
}
public abstract List<DiagnosticsNode> getProperties();

return builder.ToString();
}
}
public class DiagnosticsBlock : DiagnosticsNode {
public DiagnosticsBlock(
string name,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.whitespace,
bool showName = true,
bool showSeparator = true,
string linePrefix = null,
object value = null,
string description = null,
DiagnosticLevel level = DiagnosticLevel.info,
bool allowTruncate = false,
List<DiagnosticsNode> children = null,
List<DiagnosticsNode> properties = null
) : base(
name: name,
style: style,
showName: showName && name != null,
showSeparator: showSeparator,
linePrefix: linePrefix
) {
_description = description;
_children = children ?? new List<DiagnosticsNode>();
_properties = properties ?? new List<DiagnosticsNode>();
this.level = level;
valueObject = value;
this.allowTruncate = allowTruncate;
}
readonly List<DiagnosticsNode> _children;
readonly List<DiagnosticsNode> _properties;
public override DiagnosticLevel level {
get;
}
readonly string _description;
public override object valueObject { get; }
public readonly bool allowTruncate;
public override List<DiagnosticsNode> getChildren() => _children;
public override List<DiagnosticsNode> getProperties() => _properties;
public override string toDescription(TextTreeConfiguration parentConfiguration = null) => _description;
}
public class MessageProperty : DiagnosticsProperty<object> {

return new List<DiagnosticsNode>();
}
}
public static partial class foundation_ {
public static string shortHash(object o) {
return (o.GetHashCode() & 0xFFFFF).ToString("X").PadLeft(5, '0');

7
com.unity.uiwidgets/Runtime/gestures/mouse_tracking.cs


MouseDetectorAnnotationFinder annotationFinder,
bool inEditorWindow = false
) {
_router = router;
~MouseTracker() {
_router.removeGlobalRoute(_handleEvent);
}
readonly PointerRouter _router;
readonly bool inEditorWindow;

35
com.unity.uiwidgets/Runtime/painting/binding.cs


using System;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;

namespace Unity.UIWidgets.painting {
public class PaintingBinding : GestureBinding {
protected override void initInstances() {
base.initInstances();
instance = this;
_imageCache = createImageCache();
if (shaderWarmUp != null) {
shaderWarmUp.execute();
}
}
protected override void initInstances() {
base.initInstances();
instance = this;
_imageCache = createImageCache();
if (shaderWarmUp != null) {
shaderWarmUp.execute();
}
}
public new static PaintingBinding instance {
get { return (PaintingBinding) GestureBinding.instance; }

protected virtual ImageCache createImageCache() {
return new ImageCache();
}
//
// public Future<Codec> instantiateImageCodec(byte[] bytes,
// int? cacheWidth = null,
// int? cacheHeight = null) {
// D.assert(cacheWidth == null || cacheWidth > 0);
// D.assert(cacheHeight == null || cacheHeight > 0);
//
// Future<object> f = instantiateImageCodec(null).then<object>(c => {
// return FutureOr.null_;
// }).to<Codec>().asOf<object>();
// return ui.instantiateImageCodec(
// bytes,
// targetWidth: cacheWidth,
// targetHeight: cacheHeight
// );
// }
}
public static partial class painting_ {

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;

215
com.unity.uiwidgets/Runtime/painting/image_provider.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;

using Window = Unity.UIWidgets.ui.Window;
namespace Unity.UIWidgets.painting {
public static partial class painting_ {
internal delegate void _KeyAndErrorHandlerCallback<T>(T key, Action<Exception> handleError);
internal delegate Future _AsyncKeyErrorHandler<T>(T key, Exception exception);
}
public class ImageConfiguration : IEquatable<ImageConfiguration> {
public ImageConfiguration(
AssetBundle bundle = null,

}
}
public delegate Future<ui.Codec> DecoderCallback(byte[] bytes, int cacheWidth = 0, int cacheHeight = 0);
public delegate Future<ui.Codec> DecoderCallback(byte[] bytes, int? cacheWidth = 0, int? cacheHeight = 0);
public static bool operator ==(ImageProvider left, ImageProvider right) {
return Equals(left, right);
}
public static bool operator !=(ImageProvider left, ImageProvider right) {
return !Equals(left, right);
}
}
public abstract class ImageProvider<T> : ImageProvider {

ImageStream stream = new ImageStream();
T obtainedKey = default;
_createErrorHandlerAndKey(
configuration,
(T successKey, Action<Exception> errorHandler) => {
resolveStreamForKey(configuration, stream, successKey, (Exception e) => errorHandler(e));
},
(T key, Exception exception) => {
// await null; // wait an event turn in case a listener has been added to the image stream.
_ErrorImageCompleter imageCompleter = new _ErrorImageCompleter();
stream.setCompleter(imageCompleter);
InformationCollector collector = null;
D.assert(() => {
collector = (sb) => {
sb.Append(new DiagnosticsProperty<ImageProvider>("Image provider", this));
sb.Append(new DiagnosticsProperty<ImageConfiguration>("Image configuration",
configuration));
sb.Append(new DiagnosticsProperty<T>("Image key", key, defaultValue: null));
};
return true;
});
imageCompleter.setError(
exception: exception,
stack: exception.StackTrace,
context: new ErrorDescription("while resolving an image"),
silent: true, // could be a network error or whatnot
informationCollector: collector
);
return Future.value();
}
);
obtainKey(configuration).then_((T key) => {
obtainedKey = key;
// TODO : how to load
// stream.setCompleter(PaintingBinding.instance.imageCache.putIfAbsent(key, () => load(key)));
D.assert(false, () => "load image from ImageStream is not implemented yet");
}).catchError(ex => {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: ex,
library: "services library",
context: "while resolving an image",
silent: true,
informationCollector: information => {
information.AppendLine($"Image provider: {this}");
information.AppendLine($"Image configuration: {configuration}");
if (obtainedKey != null) {
information.AppendLine($"Image key: {obtainedKey}");
}
}
));
});
return stream;
}
void resolveStreamForKey(ImageConfiguration configuration, ImageStream stream, T key,
ImageErrorListener handleError) {
// This is an unusual edge case where someone has told us that they found
// the image we want before getting to this method. We should avoid calling
// load again, but still update the image cache with LRU information.
if (stream.completer != null) {
ImageStreamCompleter completerEdge = PaintingBinding.instance.imageCache.putIfAbsent(
key,
() => stream.completer,
onError: handleError
);
D.assert(Equals(completerEdge, stream.completer));
return;
}
return stream;
ImageStreamCompleter completer = PaintingBinding.instance.imageCache.putIfAbsent(
key,
() => load(key, ui_.instantiateImageCodec),
onError: handleError
);
if (completer != null) {
stream.setCompleter(completer);
}
}
public Future<bool> evict(ImageCache cache = null, ImageConfiguration configuration = null) {

protected abstract ImageStreamCompleter load(T assetBundleImageKey, DecoderCallback decode);
protected abstract Future<T> obtainKey(ImageConfiguration configuration);
private void _createErrorHandlerAndKey(
ImageConfiguration configuration,
painting_._KeyAndErrorHandlerCallback<T> successCallback,
painting_._AsyncKeyErrorHandler<T> errorCallback
) {
T obtainedKey = default;
bool didError = false;
Action<Exception> handleError = (Exception exception) => {
if (didError) {
return;
}
if (!didError) {
errorCallback(obtainedKey, exception);
}
didError = true;
};
// If an error is added to a synchronous completer before a listener has been
// added, it can throw an error both into the zone and up the stack. Thus, it
// looks like the error has been caught, but it is in fact also bubbling to the
// zone. Since we cannot prevent all usage of Completer.sync here, or rather
// that changing them would be too breaking, we instead hook into the same
// zone mechanism to intercept the uncaught error and deliver it to the
// image stream's error handler. Note that these errors may be duplicated,
// hence the need for the `didError` flag.
Zone dangerZone = Zone.current.fork(
specification: new ZoneSpecification(
handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone, Exception error) => {
handleError(error);
}
)
);
dangerZone.runGuarded(() => {
Future<T> key;
try {
key = obtainKey(configuration);
}
catch (Exception error) {
handleError(error);
return null;
}
key.then_((T reusltKey) => {
obtainedKey = reusltKey;
try {
successCallback(reusltKey, handleError);
}
catch (Exception error) {
handleError(error);
}
}).catchError(handleError);
return null;
});
}
}
public class AssetBundleImageKey : IEquatable<AssetBundleImageKey> {

}
Future<Codec> _loadAsync(NetworkImage key, DecoderCallback decode) {
var loaded = _loadBytes(key);
if (loaded.Current is byte[] bytes) {
return decode(bytes);
}
var completer = Completer.create();
var isolate = Isolate.current;
var panel = UIWidgetsPanel.current;
panel.StartCoroutine(_loadCoroutine(key.url, completer, isolate));
return completer.future.to<byte[]>().then_<byte[]>(data => {
if (data != null && data.Length > 0) {
return decode(data);
}
throw new Exception("not loaded");
}).to<Codec>();
}
IEnumerator _loadCoroutine(string key, Completer completer, Isolate isolate) {
var url = new Uri(key);
using (var www = UnityWebRequest.Get(url)) {
if (headers != null) {
foreach (var header in headers) {
www.SetRequestHeader(header.Key, header.Value);
}
}
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError) {
completer.completeError(new Exception($"Failed to load from url \"{url}\": {www.error}"));
yield break;
}
throw new Exception("not loaded");
var data = www.downloadHandler.data;
using (Isolate.getScope(isolate)) {
completer.complete(data);
}
}
}
IEnumerator _loadBytes(NetworkImage key) {

}
Future<Codec> _loadAsync(FileImage key, DecoderCallback decode) {
var loaded = _loadBytes(key);
if (loaded.Current is byte[] bytes) {
byte[] bytes = File.ReadAllBytes("Assets/StreamingAssets/" + key.file);
if (bytes != null && bytes.Length > 0 ) {
return decode(bytes);
}
throw new Exception("not loaded");

public override string ToString() {
return $"{GetType()}(name: \"{assetName}\", scale: {scale}, bundle: {bundle})";
}
}
internal class _ErrorImageCompleter : ImageStreamCompleter {
internal _ErrorImageCompleter() {
}
public void setError(
DiagnosticsNode context,
Exception exception,
string stack,
InformationCollector informationCollector,
bool silent = false
) {
reportError(
context: context.toDescription(),
exception: exception,
informationCollector: informationCollector,
silent: silent
);
}
}
}

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;
}
}

24
com.unity.uiwidgets/Runtime/rendering/binding.cs


set { PaintingBinding.instance = value; }
}
public RendererBinding(bool inEditorWindow = false) {
protected override void initInstances() {
base.initInstances();
instance = this;
// onSemanticsOwnerCreated: _handleSemanticsOwnerCreated,
// onSemanticsOwnerDisposed: _handleSemanticsOwnerDisposed,
// ..onSemanticsEnabledChanged = _handleSemanticsEnabledChanged
// ..onSemanticsAction = _handleSemanticsAction;
// _handleSemanticsEnabledChanged();
this.inEditorWindow = inEditorWindow;
_mouseTracker = _createMouseTracker();
initMouseTracker();
public void initRenderView() {
D.assert(renderView == null);
renderView = new RenderView(configuration: createViewConfiguration());

get { return _pipelineOwner; }
}
readonly PipelineOwner _pipelineOwner;
PipelineOwner _pipelineOwner;
public RenderView renderView {
get { return (RenderView) _pipelineOwner.rootNode; }

size: Window.instance.physicalSize / devicePixelRatio,
devicePixelRatio: devicePixelRatio
);
}
public void initMouseTracker(MouseTracker tracker = null) {
// _mouseTracker?.dispose();
_mouseTracker = tracker ?? new MouseTracker(pointerRouter, renderView.hitTestMouseTrackers);
}
void _handlePersistentFrameCallback(TimeSpan timeStamp) {

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
);

96
com.unity.uiwidgets/Runtime/rendering/error.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
public static partial class rendering_ {
public static float _kMaxWidth = 100000.0f;
public static float _kMaxHeight = 100000.0f;
}
public class RenderErrorBox : RenderBox {
const string _kLine = "\n\n────────────────────\n\n";

string message;
Paragraph _paragraph;
static TextStyle textStyle = new TextStyle(
color: new Color(0xFFFFFF66),
fontFamily: "monospace",
fontSize: 14.0f,
fontWeight: FontWeight.w700
);
protected override float computeMaxIntrinsicWidth(float height) {
return rendering_._kMaxWidth;
}
static ParagraphStyle paragraphStyle = new ParagraphStyle(
height: 1.0f
protected internal override float computeMaxIntrinsicHeight(float width) {
return rendering_._kMaxHeight;
}
protected override bool sizedByParent {
get => true;
}
protected override bool hitTestSelf(Offset position) => true;
protected override void performResize() {
size = constraints.constrain(new Size(rendering_._kMaxWidth, rendering_._kMaxHeight));
}
public static EdgeInsets padding = EdgeInsets.fromLTRB(64, 96, 64, 12);
public static float minimumWidth = 200;
public static Color backgroundColor = _initBackgroundColor();
public static Color _initBackgroundColor() {
Color result = new Color(0xF0C0C0C0);
D.assert(() => {
result = new Color(0xF0900000);
return true;
});
return result;
}
public static ui.TextStyle textStyle = _initTextStyle();
public static ui.TextStyle _initTextStyle() {
ui.TextStyle result = new ui.TextStyle(
color: new Color(0xFF303030),
fontFamily: "sans-serif",
fontSize: 18.0f
);
D.assert(() => {
result = new ui.TextStyle(
color: new Color(0xFFFFFF66),
fontFamily: "monospace",
fontSize: 14.0f,
fontWeight: FontWeight.bold
);
return true;
});
return result;
}
public static ParagraphStyle paragraphStyle = new ParagraphStyle(
textDirection: TextDirection.ltr,
textAlign: TextAlign.left
public override void paint(PaintingContext context, Offset offset) {
try {
context.canvas.drawRect(offset & size, new Paint() {color = backgroundColor});
if (_paragraph != null) {
float width = size.width;
float left = 0.0f;
float top = 0.0f;
if (width > padding.left + minimumWidth + padding.right) {
width -= padding.left + padding.right;
left += padding.left;
}
_paragraph.layout(new ui.ParagraphConstraints(width: width));
if (size.height > padding.top + _paragraph.height() + padding.bottom) {
top += padding.top;
}
context.canvas.drawParagraph(_paragraph, offset + new Offset(left, top));
}
}
catch (Exception e) {
// Intentionally left empty.
}
}
}
}

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,

17
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();
}

return true;
}
public MouseTrackerAnnotation hitTestMouseTrackers(Offset position) {
// Layer hit testing is done using device pixels, so we have to convert
// the logical coordinates of the event location back to device pixels
// here.
return layer.find<MouseTrackerAnnotation>(
position * configuration.devicePixelRatio
);
}
public override bool isRepaintBoundary {
get { return true; }
}

D.assert(() => {
if (D.debugRepaintRainbowEnabled || D.debugRepaintTextRainbowEnabled) {
D.debugCurrentRepaintColor = D.debugCurrentRepaintColor.withHue((D.debugCurrentRepaintColor.hue + 2.0f) % 360.0f);
D.debugCurrentRepaintColor =
D.debugCurrentRepaintColor.withHue((D.debugCurrentRepaintColor.hue + 2.0f) % 360.0f);
}
return true;

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
文件差异内容过多而无法显示
查看文件

2
com.unity.uiwidgets/Runtime/ui2/isolate.cs


internal void addNativeWrapper(NativeWrapper wrapper) {
lock (_nativeWrappers) {
_nativeWrappers.Add(wrapper._ptr, new WeakReference<NativeWrapper>(wrapper));
_nativeWrappers.putIfAbsent(wrapper._ptr, ()=>new WeakReference<NativeWrapper>(wrapper));
}
}

99
com.unity.uiwidgets/Runtime/ui2/painting.cs


}
public static partial class ui_ {
const int _kDoNotResizeDimension = -1;
internal const int _kDoNotResizeDimension = -1;
}
public class Paint {

public Path() : base(Path_constructor()) {
}
private Path(IntPtr ptr) : base(ptr) {
public Path(IntPtr ptr) : base(ptr) {
}
protected override void DisposePtr(IntPtr ptr) {

}
}
public class Tangent {
public Tangent(Offset position, Offset vector) {
D.assert(position != null);
D.assert(vector != null);
this.position = position;
this.vector = vector;
}
public static Tangent fromAngle(Offset position, float angle) {
return new Tangent(position, new Offset(Mathf.Cos(angle), Mathf.Sin(angle)));
}
public readonly Offset position;
public readonly Offset vector;
public float angle => -Mathf.Atan2(vector.dy, vector.dx);
}
public class PathMetric {
public PathMetric(_PathMeasure measure) {
D.assert(measure != null);

public readonly int contourIndex;
readonly _PathMeasure _measure;
public Tangent getTangentForOffset(float distance) {
return _measure.getTangentForOffset(contourIndex, distance);
}
public Path extractPath(float start, float end, bool startWithMoveTo = true) {
return _measure.extractPath(contourIndex, start, end, startWithMoveTo);
}
public override string ToString() {
return $"{GetType()}: length: {length}, isClosed: {isClosed}, contourIndex: {contourIndex}";
}
}

return PathMeasure_length(contourIndex);
}
public unsafe Tangent getTangentForOffset(int contourIndex, float distance) {
D.assert(contourIndex <= currentContourIndex, () => $"Iterator must be advanced before index {contourIndex} can be used.");
float[] posTan = new float[5];
fixed (float* posTanPtr = posTan) {
PathMeasure_getPosTan(contourIndex, distance, posTanPtr);
}
if (posTan[0] == 0.0f) {
return null;
}
else {
return new Tangent(
new Offset(posTan[1], posTan[2]),
new Offset(posTan[3], posTan[4])
);
}
}
public Path extractPath(int contourIndex, float start, float end, bool startWithMoveTo = true) {
D.assert(contourIndex <= currentContourIndex,
() => $"Iterator must be advanced before index {contourIndex} can be used.");
IntPtr pathPtr = PathMeasure_getSegment(contourIndex, start, end, startWithMoveTo);
return new Path(pathPtr);
}
public bool isClosed(int contourIndex) {
D.assert(contourIndex <= currentContourIndex, () => $"Iterator must be advanced before index {contourIndex} can be used.");
return PathMeasure_isClosed(contourIndex);

[DllImport(NativeBindings.dllName)]
static extern float PathMeasure_length(int contourIndex);
[DllImport(NativeBindings.dllName)]
static extern unsafe void PathMeasure_getPosTan(int contourIndex, float distance, float* posTan);
[DllImport(NativeBindings.dllName)]
static extern IntPtr PathMeasure_getSegment(int contourIndex, float start, float end,
bool startWithMoveTo);
[DllImport(NativeBindings.dllName)]

return hashCode;
}
}
}
public class Skottie : NativeWrapper {
public Skottie(string path) {
_setPtr(Skottie_Construct(path));
}
protected override void DisposePtr(IntPtr ptr) {
Skottie_Dispose(ptr);
}
public void paint(Canvas canvas, Offset offset, float width, float height, float frame) {
Skottie_Paint(_ptr, canvas._ptr, offset.dx, offset.dy, width, height, frame);
}
public float duration() {
return Skottie_Duration(_ptr);
}
[DllImport(NativeBindings.dllName)]
static extern IntPtr Skottie_Construct(string path);
[DllImport(NativeBindings.dllName)]
static extern void Skottie_Dispose(IntPtr skottie);
[DllImport(NativeBindings.dllName)]
static extern void Skottie_Paint(IntPtr skottie, IntPtr canvas, float x, float y, float width, float height,
float frame);
[DllImport(NativeBindings.dllName)]
static extern float Skottie_Duration(IntPtr skottie);
}
delegate void _Callback<T>(T result);

10
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;

this.repeat = repeat;
this.centerSlice = centerSlice;
this.invertColors = invertColors;
this.filterMode = filterMode;
this.filterQuality = filterQuality;
}

public readonly float scale;
public readonly Color color;
public readonly FilterMode filterMode;
public readonly BlendMode colorBlendMode;
public readonly BoxFit? fit;
public readonly Alignment alignment;

properties.add(new DiagnosticsProperty<Rect>("centerSlice", centerSlice,
defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<bool>("invertColors", invertColors));
properties.add(new EnumProperty<FilterMode>("filterMode", filterMode));
properties.add(new EnumProperty<FilterQuality>("filterMode", filterQuality));
}
}

35
com.unity.uiwidgets/Runtime/widgets/binding.cs


}
public static void runApp(Widget app) {
var instance = WidgetsFlutterBinding.ensureInitialized();
var instance = UiWidgetsBinding.ensureInitialized();
instance.scheduleAttachRootWidget(app);
instance.scheduleWarmUpFrame();
}

set { RendererBinding.instance = value; }
}
public WidgetsBinding(bool inEditorWindow = false) : base(inEditorWindow) {
protected override void initInstances() {
base.initInstances();
instance = this;
// D.assert(() => {
// _debugAddStackFilters();
// return true;
// }());
_buildOwner = new BuildOwner();
Window.instance.onLocaleChanged += handleLocaleChanged;
window.onLocaleChanged += handleLocaleChanged;
// addPersistentFrameCallback((duration) => {
// TextBlobMesh.tickNextFrame();
// TessellationGenerator.tickNextFrame();
// uiTessellationGenerator.tickNextFrame();
// uiPathCacheManager.tickNextFrame();
// });
// window.onAccessibilityFeaturesChanged = handleAccessibilityFeaturesChanged;
// SystemChannels.navigation.setMethodCallHandler(_handleNavigationInvocation);
// FlutterErrorDetails.propertiesTransformers.add(transformDebugCreator);
}
public BuildOwner buildOwner {

readonly BuildOwner _buildOwner = new BuildOwner();
BuildOwner _buildOwner = new BuildOwner();
public FocusManager focusManager {
get { return _buildOwner.focusManager; }

_handlePopRouteSub(false);
}
public readonly WidgetInspectorService widgetInspectorService;
public WidgetInspectorService widgetInspectorService;
protected override void handleMetricsChanged() {
base.handleMetricsChanged();

}
}
protected override void forgetChild(Element child) {
internal override void forgetChild(Element child) {
D.assert(child == _child);
_child = null;
}

}
}
public class WidgetsFlutterBinding : WidgetsBinding {
public class UiWidgetsBinding : WidgetsBinding {
new WidgetsFlutterBinding();
new UiWidgetsBinding();
return WidgetsBinding.instance;
}
}

1
com.unity.uiwidgets/Runtime/widgets/dismissible.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {

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,

708
com.unity.uiwidgets/Runtime/widgets/framework.cs
文件差异内容过多而无法显示
查看文件

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/layout_builder.cs


}
}
protected override void forgetChild(Element child) {
internal override void forgetChild(Element child) {
D.assert(child == _child);
_child = null;
}

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


}
}
protected override void forgetChild(Element child) {
internal override void forgetChild(Element child) {
_childElements.Remove((int) (child.slot));
}
}

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/sliver.cs


return newChild;
}
protected override void forgetChild(Element child) {
internal override void forgetChild(Element child) {
D.assert(child != null);
D.assert(child.slot != null);
D.assert(_childElements.ContainsKey((int) child.slot));

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


});
}
protected override void forgetChild(Element child) {
internal override void forgetChild(Element child) {
D.assert(child == this.child);
this.child = null;
}

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


}
}
protected override void forgetChild(Element child) {
internal override void forgetChild(Element child) {
_forgottenChildren.Add(child);
}
}

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,

6
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;
}

set {
if (_current != value) {
_current = value;
_DebugCreator creator = value.debugCreator as _DebugCreator;
DebugCreator creator = value.debugCreator as DebugCreator;
_currentElement = creator.element;
}
}

void _computeCurrent() {
if (_index < candidates.Count) {
_current = candidates[index];
_currentElement = ((_DebugCreator) _current.debugCreator).element;
_currentElement = ((DebugCreator) _current.debugCreator).element;
}
else {
_current = null;

2
engine/Build.bee.cs


"src/lib/ui/painting/shader.h",
"src/lib/ui/painting/single_frame_codec.cc",
"src/lib/ui/painting/single_frame_codec.h",
"src/lib/ui/painting/skottie.cc",
"src/lib/ui/painting/skottie.h",
"src/lib/ui/painting/vertices.cc",
"src/lib/ui/painting/vertices.h",

1
engine/README.md


Update out/Debug/args.gn with the following content:
```
clang_win = "C:\Program Files\LLVM"
win_vc = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"
cc = "clang"
cxx = "clang++"
is_debug = true

6
engine/src/lib/ui/painting/path.h


return fml::MakeRefCounted<CanvasPath>();
}
static fml::RefPtr<CanvasPath> CreateFrom(const SkPath& src) {
fml::RefPtr<CanvasPath> path = CanvasPath::CreateNew();
path->path_ = src;
return path;
}
int getFillType();
void setFillType(int fill_type);

52
engine/src/lib/ui/painting/path_measure.cc


return -1;
}
void CanvasPathMeasure::getPosTan(int contour_index, float distance, float* posTan) {
posTan[0] = 0;
if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
contour_index) >= measures_.size()) {
return;
}
SkPoint pos;
SkVector tan;
bool success = measures_[contour_index]->getPosTan(distance, &pos, &tan);
if (success) {
posTan[0] = 1; // dart code will check for this for success
posTan[1] = pos.x();
posTan[2] = pos.y();
posTan[3] = tan.x();
posTan[4] = tan.y();
}
}
fml::RefPtr<CanvasPath> CanvasPathMeasure::getSegment(int contour_index,
float start_d, float stop_d,
bool start_with_move_to) {
if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
contour_index) >= measures_.size()) {
return CanvasPath::CreateNew();
}
SkPath dst;
bool success = measures_[contour_index]->getSegment(start_d, stop_d, &dst,
start_with_move_to);
if (!success) {
return CanvasPath::CreateNew();
} else {
return CanvasPath::CreateFrom(dst);
}
}
bool CanvasPathMeasure::isClosed(int contour_index) {
if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
contour_index) < measures_.size()) {

UIWIDGETS_API(float) PathMeasure_length(PathMeasure* ptr, int contourIndex) {
return ptr->getLength(contourIndex);
}
UIWIDGETS_API(void)
PathMeasure_getPosTan(PathMeasure* ptr, int contour_index, float distance,
float* posTan) {
ptr->getPosTan(contour_index, distance, posTan);
}
UIWIDGETS_API(CanvasPath*)
PathMeasure_getSegment(PathMeasure* ptr, int contour_index, float start_d,
float stop_d,
bool start_with_move_to) {
const auto path = ptr->getSegment(contour_index, start_d, stop_d, start_with_move_to);
path->AddRef();
return path.get();
}
UIWIDGETS_API(bool) PathMeasure_isClosed(PathMeasure* ptr, int contourIndex) {

3
engine/src/lib/ui/painting/path_measure.h


void setPath(const CanvasPath* path, bool isClosed);
float getLength(int contour_index);
void getPosTan(int contour_index, float distance, float* posTan);
fml::RefPtr<CanvasPath> getSegment(int contour_index, float start_d,
float stop_d, bool start_with_move_to);
bool isClosed(int contour_index);
bool nextContour();

8
engine/src/shell/platform/unity/unity_surface_manager.cc


image_texture->Release();
GLint old_texture_binding_2d;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_texture_binding_2d);
FML_DCHECK(fbo_texture_ == 0);
glGenTextures(1, &fbo_texture_);
glBindTexture(GL_TEXTURE_2D, fbo_texture_);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, fbo_egl_image_);
glBindTexture(GL_TEXTURE_2D, old_texture_binding_2d);
GLint old_framebuffer_binding;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_framebuffer_binding);
FML_DCHECK(fbo_ == 0);
glGenFramebuffers(1, &fbo_);

FML_CHECK(glCheckFramebufferStatus(GL_FRAMEBUFFER) ==
GL_FRAMEBUFFER_COMPLETE);
glBindFramebuffer(GL_FRAMEBUFFER, old_framebuffer_binding);
return fbo_;
}

7
Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/confetti.json.meta


fileFormatVersion: 2
guid: ac26747b511ae1e42b7ee598ca4fc76d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/test.gif
文件差异内容过多而无法显示
查看文件

7
Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/test.gif.meta


fileFormatVersion: 2
guid: d0c98e9a4446a81498786934f0bb4268
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1
Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/wine.json
文件差异内容过多而无法显示
查看文件

7
Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/wine.json.meta


fileFormatVersion: 2
guid: e6c5720c879142e49a96f1d129c9a492
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

132
com.unity.uiwidgets/Runtime/rendering/lottie.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.rendering {
public class RenderLottie : RenderBox {
public RenderLottie(
Skottie skottie,
float? width = null,
float? height = null,
float scale = 1.0f,
float frame = 0
) {
_width = width;
_height = height;
_scale = scale;
_skottie = skottie;
_frame = frame;
_duration = skottie.duration();
}
Skottie _skottie;
float _frame = 0;
float _duration = 0;
public float frame {
get { return _frame; }
set {
while (value > _duration) {
value -= _duration;
}
if (value == _frame) {
return;
}
_frame = value;
markNeedsLayout();
}
}
float? _width;
public float? width {
get { return _width; }
set {
if (value == _width) {
return;
}
_width = value;
markNeedsLayout();
}
}
float? _height;
public float? height {
get { return _height; }
set {
if (value == _height) {
return;
}
_height = value;
markNeedsLayout();
}
}
float _scale;
public float scale {
get { return _scale; }
set {
if (value == _scale) {
return;
}
_scale = value;
markNeedsLayout();
}
}
Size _sizeForConstraints(BoxConstraints constraints) {
constraints = BoxConstraints.tightFor(
_width,
_height
).enforce(constraints);
return constraints.smallest;
}
protected override float computeMinIntrinsicWidth(float height) {
D.assert(height >= 0.0);
if (_width == null && _height == null) {
return 0.0f;
}
return _sizeForConstraints(BoxConstraints.tightForFinite(height: height)).width;
}
protected override float computeMaxIntrinsicWidth(float height) {
D.assert(height >= 0.0);
return _sizeForConstraints(BoxConstraints.tightForFinite(height: height)).width;
}
protected override float computeMinIntrinsicHeight(float width) {
D.assert(width >= 0.0);
if (_width == null && _height == null) {
return 0.0f;
}
return _sizeForConstraints(BoxConstraints.tightForFinite(width: width)).height;
}
protected internal override float computeMaxIntrinsicHeight(float width) {
D.assert(width >= 0.0);
return _sizeForConstraints(BoxConstraints.tightForFinite(width: width)).height;
}
protected override bool hitTestSelf(Offset position) {
return true;
}
protected override void performLayout() {
size = _sizeForConstraints(constraints);
}
public override void paint(PaintingContext context, Offset offset) {
_skottie.paint(context.canvas, offset, _width ?? 0, _height ?? 0, _frame);
}
}
}

3
com.unity.uiwidgets/Runtime/rendering/lottie.cs.meta


fileFormatVersion: 2
guid: d638e264913843d89da562fca3c33484
timeCreated: 1605844378

104
com.unity.uiwidgets/Runtime/widgets/LottiePainter.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
using Path = System.IO.Path;
namespace Unity.UIWidgets.widgets {
public class Lottie : StatefulWidget {
public Skottie _skottie = null;
public float _frame = 0;
public Lottie(string path, float frame) {
D.assert(path != null);
_skottie = new Skottie(Path.Combine(Application.streamingAssetsPath, path));
_frame = frame;
}
public override State createState() {
return new LottieState();
}
}
public class LottieState : State<Lottie> {
public override Widget build(BuildContext context) {
return new LottieRenderObjectWidget(widget._skottie, widget._frame);
}
}
public class LottieRenderObjectWidget : LeafRenderObjectWidget {
Skottie _anime;
float _frame;
float _duration;
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
base.updateRenderObject(context, renderObject);
var a = (RenderLottie) renderObject;
a.frame = _frame*_duration;
}
public LottieRenderObjectWidget(Skottie anime, float frame) {
_anime = anime;
_frame = frame;
_duration = anime.duration();
}
public override RenderObject createRenderObject(BuildContext context) {
return new RenderLottie(_anime, 100, 100, frame: _frame);
}
}
public class AnimatedLottie : ImplicitlyAnimatedWidget {
public Skottie _skottie = null;
public float _frame = 0;
public AnimatedLottie(
string path,
Key key = null,
Curve curve = null,
TimeSpan? duration = null,
float frame = 0
) :base(key: key, curve: curve, duration: duration){
_skottie = new Skottie(Path.Combine(Application.streamingAssetsPath, path));
_frame = frame;
}
AnimatedLottie(
Skottie skottie,
Key key = null,
Curve curve = null,
TimeSpan? duration = null,
float frame = 0
) :base(key: key, curve: curve, duration: duration){
_skottie = skottie;
_frame = frame;
}
public static AnimatedLottie file(string path, Key key = null, Curve curve = null, TimeSpan? duration = null,
float frame = 0) {
var skottie = new Skottie(Path.Combine(Application.streamingAssetsPath, path));
duration = duration ?? TimeSpan.FromSeconds(skottie.duration());
return new AnimatedLottie(skottie, key, curve, duration, frame);
}
public override State createState() {
return new _AnimatedLottieState();
}
}
class _AnimatedLottieState : AnimatedWidgetBaseState<AnimatedLottie> {
FloatTween frame;
protected override void forEachTween(TweenVisitor visitor) {
frame = (FloatTween) visitor.visit(this, frame, widget._frame,
(value) => new FloatTween(begin: value, value));
}
public override Widget build(BuildContext context) {
return new LottieRenderObjectWidget(widget._skottie, frame.lerp(animation.value));
}
}
}

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


fileFormatVersion: 2
guid: 719affe0aa514bbca2666a67eedd57a0
timeCreated: 1605658320

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

41
engine/src/lib/ui/painting/skottie.cc


#include "skottie.h"
#include "lib/ui/ui_mono_state.h"
namespace uiwidgets {
fml::RefPtr<Skottie> Skottie::Create(char* path) {
sk_sp<skottie::Animation> animation_ = skottie::Animation::MakeFromFile(path);
return fml::MakeRefCounted<Skottie>(animation_);
}
Skottie::Skottie(sk_sp<skottie::Animation> animation) {
animation_ = animation;
}
void Skottie::paint(Canvas* canvas, float x, float y, float width, float height,
float frame) {
animation_->seekFrameTime(frame);
SkRect rect = SkRect::MakeXYWH(x, y, width, height);
animation_->render(canvas->canvas(), &rect);
}
float Skottie::duration() { return animation_->duration(); }
UIWIDGETS_API(Skottie*)
Skottie_Construct(char* path) {
fml::RefPtr<Skottie> skottie = Skottie::Create(path);
skottie->AddRef();
return skottie.get();
}
UIWIDGETS_API(void)
Skottie_Dispose(Skottie* ptr) { ptr->Release(); }
UIWIDGETS_API(void)
Skottie_Paint(Skottie* ptr, Canvas* canvas, float x, float y, float width,
float height, float frame) {
ptr->paint(canvas, x, y, width, height, frame);
}
UIWIDGETS_API(float)
Skottie_Duration(Skottie* ptr) { return ptr->duration(); }
} // namespace uiwidgets

26
engine/src/lib/ui/painting/skottie.h


#pragma once
#include "flutter/fml/memory/ref_counted.h"
#include "lib/ui/painting/canvas.h"
#include "modules/skottie/include/Skottie.h"
namespace uiwidgets {
class Skottie : public fml::RefCountedThreadSafe<Skottie> {
FML_FRIEND_MAKE_REF_COUNTED(Skottie);
public:
static fml::RefPtr<Skottie> Create(char* path);
void paint(Canvas* canvas, float x, float y, float width, float height,
float frame);
float duration();
private:
explicit Skottie(sk_sp<skottie::Animation> animation);
sk_sp<skottie::Animation> animation_;
bool is_null;
};
} // namespace uiwidgets
正在加载...
取消
保存