浏览代码
Merge pull request #15 from Unity-Technologies/siyaoH/skiaPainting
Merge pull request #15 from Unity-Technologies/siyaoH/skiaPainting
fix painting compile error/siyaoH-1.17-PlatformMessage
GitHub
4 年前
当前提交
97fa588b
共有 17 个文件被更改,包括 712 次插入 和 338 次删除
-
71com.unity.uiwidgets/Runtime/painting/alignment.cs
-
1com.unity.uiwidgets/Runtime/painting/binding.cs
-
19com.unity.uiwidgets/Runtime/painting/box_decoration.cs
-
2com.unity.uiwidgets/Runtime/painting/colors.cs
-
6com.unity.uiwidgets/Runtime/painting/decoration_image.cs
-
59com.unity.uiwidgets/Runtime/painting/gradient.cs
-
136com.unity.uiwidgets/Runtime/painting/image_provider.cs
-
6com.unity.uiwidgets/Runtime/painting/image_resolution.cs
-
28com.unity.uiwidgets/Runtime/painting/image_stream.cs
-
36com.unity.uiwidgets/Runtime/painting/matrix_utils.cs
-
7com.unity.uiwidgets/Runtime/painting/shader_warmup.cs
-
2com.unity.uiwidgets/Runtime/painting/strut_style.cs
-
239com.unity.uiwidgets/Runtime/painting/text_painter.cs
-
190com.unity.uiwidgets/Runtime/painting/text_span.cs
-
40com.unity.uiwidgets/Runtime/painting/text_style.cs
-
2com.unity.uiwidgets/Runtime/ui2/painting.cs
-
206com.unity.uiwidgets/Runtime/painting/inline_span.cs
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.painting { |
|||
public class Accumulator { |
|||
public Accumulator(int _value = 0) { |
|||
this._value = _value; |
|||
} |
|||
|
|||
public int value { |
|||
get { return _value; } |
|||
} |
|||
|
|||
int _value; |
|||
|
|||
public void increment(int addend) { |
|||
D.assert(addend >= 0); |
|||
_value += addend; |
|||
} |
|||
} |
|||
|
|||
public delegate bool InlineSpanVisitor(InlineSpan span); |
|||
|
|||
public delegate bool TextSpanVisitor(TextSpan span); |
|||
|
|||
public class InlineSpanSemanticsInformation : IEquatable<InlineSpanSemanticsInformation> { |
|||
public InlineSpanSemanticsInformation( |
|||
string text, |
|||
bool isPlaceholder = false, |
|||
string semanticsLabel = null, |
|||
GestureRecognizer recognizer = null |
|||
) { |
|||
D.assert(text != null); |
|||
D.assert(isPlaceholder != null); |
|||
D.assert(isPlaceholder == false || (text == "\uFFFC" && semanticsLabel == null && recognizer == null)); |
|||
requiresOwnNode = isPlaceholder || recognizer != null; |
|||
} |
|||
|
|||
public static readonly InlineSpanSemanticsInformation placeholder = |
|||
new InlineSpanSemanticsInformation("\uFFFC", isPlaceholder: true); |
|||
|
|||
public readonly string text; |
|||
|
|||
public readonly string semanticsLabel; |
|||
|
|||
public readonly GestureRecognizer recognizer; |
|||
|
|||
public readonly bool isPlaceholder; |
|||
|
|||
public readonly bool requiresOwnNode; |
|||
|
|||
|
|||
public override string ToString() => |
|||
$"{foundation_.objectRuntimeType(this, "InlineSpanSemanticsInformation")}" + |
|||
$"{text: $text, semanticsLabel: $semanticsLabel, recognizer: $recognizer}"; |
|||
|
|||
public bool Equals(InlineSpanSemanticsInformation other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return text == other.text && semanticsLabel == other.semanticsLabel && |
|||
Equals(recognizer, other.recognizer) && isPlaceholder == other.isPlaceholder; |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((InlineSpanSemanticsInformation) obj); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = (text != null ? text.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (semanticsLabel != null ? semanticsLabel.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (recognizer != null ? recognizer.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ isPlaceholder.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public abstract class InlineSpan : DiagnosticableTree, IEquatable<InlineSpan> { |
|||
public InlineSpan( |
|||
TextStyle style = null |
|||
) { |
|||
this.style = style; |
|||
} |
|||
|
|||
public readonly TextStyle style; |
|||
|
|||
public abstract void build(ParagraphBuilder builder, |
|||
float textScaleFactor = 1, List<PlaceholderDimensions> dimensions = null |
|||
); |
|||
|
|||
public abstract bool visitChildren(InlineSpanVisitor visitor); |
|||
|
|||
public InlineSpan getSpanForPosition(TextPosition position) { |
|||
D.assert(debugAssertIsValid()); |
|||
Accumulator offset = new Accumulator(); |
|||
InlineSpan result = null; |
|||
visitChildren((InlineSpan span) => { |
|||
result = span.getSpanForPositionVisitor(position, offset); |
|||
return result == null; |
|||
}); |
|||
return result; |
|||
} |
|||
|
|||
protected abstract InlineSpan getSpanForPositionVisitor(TextPosition position, Accumulator offset); |
|||
|
|||
public string toPlainText( |
|||
bool includeSemanticsLabels = true, bool includePlaceholders = true) { |
|||
StringBuilder buffer = new StringBuilder(); |
|||
computeToPlainText(buffer, includeSemanticsLabels: includeSemanticsLabels, |
|||
includePlaceholders: includePlaceholders); |
|||
return buffer.ToString(); |
|||
} |
|||
|
|||
List<InlineSpanSemanticsInformation> getSemanticsInformation() { |
|||
List<InlineSpanSemanticsInformation> collector = new List<InlineSpanSemanticsInformation>(); |
|||
|
|||
computeSemanticsInformation(collector); |
|||
return collector; |
|||
} |
|||
|
|||
public abstract void computeSemanticsInformation(List<InlineSpanSemanticsInformation> collector); |
|||
|
|||
public abstract void computeToPlainText(StringBuilder buffer, |
|||
bool includeSemanticsLabels = true, bool includePlaceholders = true); |
|||
|
|||
public int? codeUnitAt(int index) { |
|||
if (index < 0) |
|||
return null; |
|||
Accumulator offset = new Accumulator(); |
|||
int? result = null; |
|||
visitChildren((InlineSpan span) => { |
|||
result = span.codeUnitAtVisitor(index, offset); |
|||
return result == null; |
|||
}); |
|||
return result; |
|||
} |
|||
|
|||
protected abstract int? codeUnitAtVisitor(int index, Accumulator offset); |
|||
|
|||
public bool debugAssertIsValid() => true; |
|||
public abstract RenderComparison compareTo(InlineSpan other); |
|||
|
|||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.whitespace; |
|||
if (style != null) { |
|||
style.debugFillProperties(properties); |
|||
} |
|||
} |
|||
|
|||
public bool Equals(InlineSpan other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return Equals(style, other.style); |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((InlineSpan) obj); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
return (style != null ? style.GetHashCode() : 0); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue