|
|
|
|
|
|
using Unity.UIWidgets.painting; |
|
|
|
using Unity.UIWidgets.ui; |
|
|
|
using UnityEngine; |
|
|
|
using Canvas = Unity.UIWidgets.ui.Canvas; |
|
|
|
using Color = Unity.UIWidgets.ui.Color; |
|
|
|
using Rect = Unity.UIWidgets.ui.Rect; |
|
|
|
|
|
|
|
|
|
|
get { return (ContainerLayer) base.parent; } |
|
|
|
} |
|
|
|
|
|
|
|
bool _needsAddToScene = true; |
|
|
|
public bool _needsAddToScene = true; |
|
|
|
if (_needsAddToScene) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
_needsAddToScene = true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal bool _subtreeNeedsAddToScene; |
|
|
|
|
|
|
|
flow.Layer _engineLayer; |
|
|
|
|
|
|
|
protected EngineLayer engineLayer { |
|
|
|
get { return _engineLayer; } |
|
|
|
set { |
|
|
|
_engineLayer = value; |
|
|
|
if (!alwaysNeedsAddToScene) { |
|
|
|
if (parent != null && !parent.alwaysNeedsAddToScene) { |
|
|
|
parent.markNeedsAddToScene(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
EngineLayer _engineLayer; |
|
|
|
_subtreeNeedsAddToScene = _needsAddToScene || alwaysNeedsAddToScene; |
|
|
|
_needsAddToScene = _needsAddToScene || alwaysNeedsAddToScene; |
|
|
|
} |
|
|
|
|
|
|
|
public Layer nextSibling { |
|
|
|
|
|
|
internal Layer _previousSibling; |
|
|
|
|
|
|
|
protected override void dropChild(AbstractNodeMixinDiagnosticableTree child) { |
|
|
|
markNeedsAddToScene(); |
|
|
|
if (!alwaysNeedsAddToScene) { |
|
|
|
markNeedsAddToScene(); |
|
|
|
} |
|
|
|
|
|
|
|
markNeedsAddToScene(); |
|
|
|
if (!alwaysNeedsAddToScene) { |
|
|
|
markNeedsAddToScene(); |
|
|
|
} |
|
|
|
|
|
|
|
base.adoptChild(child); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal abstract S find<S>(Offset regionOffset) where S : class; |
|
|
|
|
|
|
|
internal abstract flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null); |
|
|
|
internal abstract void addToScene(SceneBuilder builder, Offset layerOffset = null); |
|
|
|
if (!_subtreeNeedsAddToScene && _engineLayer != null) { |
|
|
|
if (!_needsAddToScene && _engineLayer != null) { |
|
|
|
_engineLayer = addToScene(builder); |
|
|
|
addToScene(builder); |
|
|
|
_needsAddToScene = false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|
|
|
|
|
|
public class TextureLayer : Layer { |
|
|
|
public TextureLayer( |
|
|
|
Rect rect, |
|
|
|
Texture texture, |
|
|
|
int textureId, |
|
|
|
D.assert(texture != null); |
|
|
|
this.texture = texture; |
|
|
|
this.textureId = textureId; |
|
|
|
public readonly Texture texture; |
|
|
|
public readonly int textureId; |
|
|
|
|
|
|
|
public readonly bool freeze; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
texture, |
|
|
|
textureId, |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PictureLayer _highlightConflictingLayer(PhysicalModelLayer child) { |
|
|
|
PictureRecorder recorder = new PictureRecorder(); |
|
|
|
var canvas = new RecorderCanvas(recorder); |
|
|
|
var canvas = new Canvas(recorder); |
|
|
|
canvas.drawPath(child.clipPath, new Paint() { |
|
|
|
color = new Color(0xFFAA0000), |
|
|
|
style = PaintingStyle.stroke, |
|
|
|
|
|
|
Layer child = firstChild; |
|
|
|
while (child != null) { |
|
|
|
child.updateSubtreeNeedsAddToScene(); |
|
|
|
_subtreeNeedsAddToScene = _subtreeNeedsAddToScene || child._subtreeNeedsAddToScene; |
|
|
|
_needsAddToScene = _needsAddToScene || child._needsAddToScene; |
|
|
|
child = child.nextSibling; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
_lastChild = null; |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public void addChildrenToScene(SceneBuilder builder, Offset childOffset = null) { |
|
|
|
|
|
|
return scene; |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
var engineLayer = builder.pushOffset( |
|
|
|
engineLayer = builder.pushOffset( |
|
|
|
(float) (layerOffset.dy + offset.dy)); |
|
|
|
(float) (layerOffset.dy + offset.dy), |
|
|
|
oldLayer: engineLayer as OffsetEngineLayer); |
|
|
|
return engineLayer; |
|
|
|
} |
|
|
|
|
|
|
|
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|
|
|
|
|
|
return base.find<S>(regionOffset); |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
|
|
|
|
bool enabled = true; |
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (enabled) { |
|
|
|
builder.pushClipRect(clipRect.shift(layerOffset)); |
|
|
|
var shiftedClipRect = layerOffset == Offset.zero ? clipRect : clipRect.shift(layerOffset); |
|
|
|
engineLayer = builder.pushClipRect( |
|
|
|
rect: shiftedClipRect, |
|
|
|
clipBehavior: clipBehavior, |
|
|
|
oldLayer: engineLayer as ClipRectEngineLayer); |
|
|
|
} |
|
|
|
else { |
|
|
|
engineLayer = null; |
|
|
|
} |
|
|
|
|
|
|
|
addChildrenToScene(builder, layerOffset); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|
|
|
|
|
|
return base.find<S>(regionOffset); |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
|
|
|
|
bool enabled = true; |
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (enabled) { |
|
|
|
builder.pushClipRRect(clipRRect.shift(layerOffset)); |
|
|
|
var shiftedClipRRect = layerOffset == Offset.zero ? clipRRect : clipRRect.shift(layerOffset); |
|
|
|
engineLayer = builder.pushClipRRect( |
|
|
|
shiftedClipRRect, |
|
|
|
clipBehavior: clipBehavior, |
|
|
|
oldLayer: engineLayer as ClipRRectEngineLayer |
|
|
|
); |
|
|
|
} |
|
|
|
else { |
|
|
|
engineLayer = null; |
|
|
|
} |
|
|
|
|
|
|
|
addChildrenToScene(builder, layerOffset); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|
|
|
|
|
|
return base.find<S>(regionOffset); |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
|
|
|
|
bool enabled = true; |
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (enabled) { |
|
|
|
builder.pushClipPath(clipPath.shift(layerOffset)); |
|
|
|
var shiftedPath = layerOffset == Offset.zero ? clipPath : clipPath.shift(layerOffset); |
|
|
|
engineLayer = builder.pushClipPath( |
|
|
|
shiftedPath, |
|
|
|
clipBehavior: clipBehavior, |
|
|
|
oldLayer: engineLayer as ClipPathEngineLayer); |
|
|
|
} |
|
|
|
else { |
|
|
|
engineLayer = null; |
|
|
|
} |
|
|
|
|
|
|
|
addChildrenToScene(builder, layerOffset); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
return base.find<S>(new Offset(result[0], result[1])); |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
|
|
|
|
_lastEffectiveTransform = _transform; |
|
|
|
|
|
|
_lastEffectiveTransform.multiply(transform); |
|
|
|
} |
|
|
|
|
|
|
|
builder.pushTransform(_lastEffectiveTransform.toMatrix3()); |
|
|
|
engineLayer = builder.pushTransform( |
|
|
|
_lastEffectiveTransform._m4storage, |
|
|
|
oldLayer: engineLayer as TransformEngineLayer); |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public override void applyTransform(Layer child, Matrix4 transform) { |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
|
|
|
|
bool enabled = true; |
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
builder.pushOpacity(alpha, offset: offset + layerOffset); |
|
|
|
engineLayer = builder.pushOpacity( |
|
|
|
alpha, |
|
|
|
offset: offset + layerOffset, |
|
|
|
oldLayer: engineLayer as OpacityEngineLayer); |
|
|
|
} |
|
|
|
else { |
|
|
|
engineLayer = null; |
|
|
|
} |
|
|
|
|
|
|
|
addChildrenToScene(builder, layerOffset); |
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
builder.pushBackdropFilter(filter); |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
D.assert(filter != null); |
|
|
|
engineLayer = builder.pushBackdropFilter( |
|
|
|
filter: filter, |
|
|
|
oldLayer: engineLayer as BackdropFilterEngineLayer); |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
return base.find<S>(regionOffset - offset); |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
builder.pushTransform(new Matrix4() |
|
|
|
engineLayer = builder.pushTransform( |
|
|
|
new Matrix4() |
|
|
|
.toMatrix3()); |
|
|
|
._m4storage, |
|
|
|
oldLayer: engineLayer as TransformEngineLayer); |
|
|
|
} |
|
|
|
|
|
|
|
addChildrenToScene(builder, Offset.zero); |
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public override void applyTransform(Layer child, Matrix4 transform) { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
|
|
|
|
D.assert(link != null); |
|
|
|
|
|
|
_inverseDirty = true; |
|
|
|
return null; |
|
|
|
engineLayer = null; |
|
|
|
builder.pushTransform(_lastTransform.toMatrix3()); |
|
|
|
engineLayer = builder.pushTransform( |
|
|
|
_lastTransform._m4storage, |
|
|
|
oldLayer: engineLayer as TransformEngineLayer); |
|
|
|
addChildrenToScene(builder); |
|
|
|
builder.pop(); |
|
|
|
_lastOffset = unlinkedOffset + layerOffset; |
|
|
|
|
|
|
var matrix = new Matrix4().translationValues(unlinkedOffset.dx, unlinkedOffset.dy, 0); |
|
|
|
builder.pushTransform(matrix.toMatrix3()); |
|
|
|
engineLayer = builder.pushTransform( |
|
|
|
matrix._m4storage, |
|
|
|
oldLayer: engineLayer as TransformEngineLayer); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public override void applyTransform(Layer child, Matrix4 transform) { |
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
D.assert(optionsMask != null); |
|
|
|
builder.addPerformanceOverlay(optionsMask, overlayRect.shift(layerOffset)); |
|
|
|
return null; |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
|
|
|
|
var shiftedOverlayRect = layerOffset == Offset.zero ? overlayRect : overlayRect.shift(layerOffset); |
|
|
|
builder.addPerformanceOverlay(optionsMask, shiftedOverlayRect); |
|
|
|
//TODO: add implementations
|
|
|
|
//builder.setRasterizerTracingThreshold(rasterizerThreshold);
|
|
|
|
//builder.setCheckerboardRasterCacheImages(checkerboardRasterCacheImages);
|
|
|
|
//builder.setCheckerboardOffscreenLayers(checkerboardOffscreenLayers);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
ancestor = ancestor.parent; |
|
|
|
} |
|
|
|
|
|
|
|
return clipPath.transform(matrix.toMatrix3()); |
|
|
|
return clipPath.transform(matrix._m4storage); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
return base.find<S>(regionOffset); |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
|
|
|
|
D.assert(clipPath != null); |
|
|
|
D.assert(color != null); |
|
|
|
D.assert(shadowColor != null); |
|
|
|
builder.pushPhysicalShape( |
|
|
|
path: clipPath.shift(layerOffset), |
|
|
|
elevation: elevation, |
|
|
|
color: color, |
|
|
|
shadowColor: shadowColor, |
|
|
|
clipBehavior: clipBehavior); |
|
|
|
bool enabled = true; |
|
|
|
D.assert(() => { |
|
|
|
enabled = !D.debugDisablePhysicalShapeLayers; |
|
|
|
return true; |
|
|
|
}); |
|
|
|
if (enabled) { |
|
|
|
engineLayer = builder.pushPhysicalShape( |
|
|
|
path: layerOffset == Offset.zero ? clipPath : clipPath.shift(layerOffset), |
|
|
|
elevation: elevation, |
|
|
|
color: color, |
|
|
|
shadowColor: shadowColor, |
|
|
|
clipBehavior: clipBehavior, |
|
|
|
oldLayer: engineLayer as PhysicalShapeEngineLayer); |
|
|
|
} |
|
|
|
else { |
|
|
|
engineLayer = null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
builder.pop(); |
|
|
|
return null; |
|
|
|
if (enabled) { |
|
|
|
builder.pop(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|