|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
internal virtual void updateSubtreeNeedsAddToScene() { |
|
|
|
_subtreeNeedsAddToScene = _needsAddToScene || alwaysNeedsAddToScene; |
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
internal void _addToSceneWithRetainedRendering(SceneBuilder builder) { |
|
|
|
if (!_subtreeNeedsAddToScene && _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, |
|
|
|
|
|
|
_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; |
|
|
|
|
|
|
builder.pushTransform(_lastEffectiveTransform.toMatrix3()); |
|
|
|
addChildrenToScene(builder); |
|
|
|
builder.pop(); |
|
|
|
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; |
|
|
|
|
|
|
}); |
|
|
|
if (enabled) { |
|
|
|
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) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
|
|
|
|
D.assert(offset != null); |
|
|
|
|
|
|
if (_lastOffset != Offset.zero) { |
|
|
|
builder.pop(); |
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
_establishTransform(); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_inverseDirty = true; |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public override void applyTransform(Layer child, Matrix4 transform) { |
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
internal override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
D.assert(optionsMask != null); |
|
|
|
|
|
|
|
|
|
|
|
builder.addPerformanceOverlay(optionsMask, overlayRect.shift(layerOffset)); |
|
|
|
return null; |
|
|
|
|
|
|
|
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);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|