|
|
|
|
|
|
using UnityEngine; |
|
|
|
using Canvas = Unity.UIWidgets.ui.Canvas; |
|
|
|
using Color = Unity.UIWidgets.ui.Color; |
|
|
|
using Object = System.Object; |
|
|
|
using Rect = Unity.UIWidgets.ui.Rect; |
|
|
|
using Shader = Unity.UIWidgets.ui.Shader; |
|
|
|
namespace Unity.UIWidgets.rendering { |
|
|
|
|
|
|
protected void markNeedsAddToScene() { |
|
|
|
D.assert( |
|
|
|
!alwaysNeedsAddToScene,()=> |
|
|
|
GetType().ToString() +" with alwaysNeedsAddToScene set called markNeedsAddToScene.\n" + |
|
|
|
GetType() +" with alwaysNeedsAddToScene set called markNeedsAddToScene.\n" + |
|
|
|
"The layer's alwaysNeedsAddToScene is set to true, and therefore it should not call markNeedsAddToScene." |
|
|
|
); |
|
|
|
if (_needsAddToScene) { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public virtual void remove() { |
|
|
|
if (parent != null) { |
|
|
|
parent._removeChild(this); |
|
|
|
} |
|
|
|
parent?._removeChild(this); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual bool findAnnotations<S>( |
|
|
|
|
|
|
S find<S>(Offset localPosition) { |
|
|
|
AnnotationResult<S> result = new AnnotationResult<S>(); |
|
|
|
findAnnotations<S>(result, localPosition, onlyFirst: true); |
|
|
|
return result.entries.Count() == 0 ? default : result.entries.First().annotation; |
|
|
|
return !result.entries.Any() ? default : result.entries.First().annotation; |
|
|
|
} |
|
|
|
|
|
|
|
AnnotationResult<S> findAllAnnotations<S>(Offset localPosition) { |
|
|
|
|
|
|
defaultValue: foundation_.kNullDefaultValue)); |
|
|
|
properties.add(new DiagnosticsProperty<object>("creator", debugCreator, |
|
|
|
defaultValue: foundation_.kNullDefaultValue, level: DiagnosticLevel.debug)); |
|
|
|
properties.add(new DiagnosticsProperty<string>("engine layer", foundation_.describeIdentity(_engineLayer))); |
|
|
|
} |
|
|
|
public void replaceWith(Layer newLayer) { |
|
|
|
D.assert(parent != null); |
|
|
|
|
|
|
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|
|
|
base.debugFillProperties(properties); |
|
|
|
properties.add(new DiagnosticsProperty<Rect>("paint bounds", canvasBounds)); |
|
|
|
properties.add(new DiagnosticsProperty<string>("picture", _picture.GetType().ToString)); |
|
|
|
properties.add(new DiagnosticsProperty<string>("picture", foundation_.describeIdentity(_picture))); |
|
|
|
"isComplex =" + isComplexHint + "willChange ="+ willChangeHint) |
|
|
|
$"isComplex = {isComplexHint} willChange = {willChangeHint}") |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
public override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
|
|
|
|
Rect shiftedRect = rect.shift(layerOffset); |
|
|
|
Rect shiftedRect = layerOffset == Offset.zero ? rect : rect.shift(layerOffset); |
|
|
|
builder.addTexture( |
|
|
|
textureId, |
|
|
|
offset: shiftedRect.topLeft, |
|
|
|
|
|
|
|
|
|
|
UIWidgetsError.reportError(new UIWidgetsErrorDetails( |
|
|
|
exception: new UIWidgetsError("Painting order is out of order with respect to elevation.\n" + |
|
|
|
"See https://api.flutter.dev/flutter/rendering/debugCheckElevations.html " + |
|
|
|
"See https://api.flutter.dev/flutter/rendering/debugCheckElevationsEnabled.html " + |
|
|
|
"for more details."), |
|
|
|
library: "rendering library", |
|
|
|
context: new ErrorDescription("during compositing"), |
|
|
|
|
|
|
bool isAbsorbed = child.findAnnotations<S>(result, localPosition, onlyFirst: onlyFirst); |
|
|
|
if (isAbsorbed) |
|
|
|
return true; |
|
|
|
if (onlyFirst && result.entries.Count() != 0) |
|
|
|
if (onlyFirst && result.entries.Any()) |
|
|
|
return isAbsorbed; |
|
|
|
} |
|
|
|
return false; |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
addChildrenToScene(builder, layerOffset); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
properties.add(new DiagnosticsProperty<Offset>("offset", offset)); |
|
|
|
} |
|
|
|
|
|
|
|
public Scene buildScene(SceneBuilder builder) { |
|
|
|
/*public Scene buildScene(SceneBuilder builder) { |
|
|
|
List<PictureLayer> temporaryLayers = null; |
|
|
|
D.assert(() => { |
|
|
|
if (RenderingDebugUtils.debugCheckElevationsEnabled) { |
|
|
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
return scene; |
|
|
|
} |
|
|
|
}*/ |
|
|
|
D.assert(pixelRatio != null); |
|
|
|
ui.SceneBuilder builder = new SceneBuilder(); |
|
|
|
Matrix4 transform = Matrix4.translationValues( |
|
|
|
(-bounds.left - offset.dx) * pixelRatio, |
|
|
|
|
|
|
public override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
D.assert(clipRect != null); |
|
|
|
D.assert(clipBehavior != null); |
|
|
|
|
|
|
|
bool enabled = true; |
|
|
|
D.assert(() => { |
|
|
|
|
|
|
public class ClipRRectLayer : ContainerLayer { |
|
|
|
public ClipRRectLayer( |
|
|
|
RRect clipRRect = null, |
|
|
|
Clip clipBehavior = Clip.hardEdge |
|
|
|
Clip clipBehavior = Clip.antiAlias |
|
|
|
) { |
|
|
|
D.assert(clipRRect != null); |
|
|
|
D.assert(clipBehavior != Clip.none); |
|
|
|
|
|
|
public override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
D.assert(clipRRect != null); |
|
|
|
D.assert(clipBehavior != null); |
|
|
|
bool enabled = true; |
|
|
|
D.assert(() => { |
|
|
|
enabled = !D.debugDisableClipLayers; |
|
|
|
|
|
|
public class ClipPathLayer : ContainerLayer { |
|
|
|
public ClipPathLayer( |
|
|
|
Path clipPath = null, |
|
|
|
Clip clipBehavior = Clip.hardEdge |
|
|
|
Clip clipBehavior = Clip.antiAlias |
|
|
|
) { |
|
|
|
D.assert(clipPath != null); |
|
|
|
D.assert(clipBehavior != Clip.none); |
|
|
|
|
|
|
public override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
D.assert(clipPath != null); |
|
|
|
D.assert(clipBehavior != null); |
|
|
|
|
|
|
|
bool enabled = true; |
|
|
|
D.assert(() => { |
|
|
|
|
|
|
get { return _transform; } |
|
|
|
set { |
|
|
|
D.assert(value != null); |
|
|
|
//D.assert(value.storage.Each((float component) => ));
|
|
|
|
bool componentIsFinite = true; |
|
|
|
foreach (var component in value.storage) { |
|
|
|
if (!component.isFinite()) { |
|
|
|
componentIsFinite = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
D.assert(componentIsFinite); |
|
|
|
if (value == _transform) |
|
|
|
return; |
|
|
|
_transform = value; |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
engineLayer = builder.pushTransform( |
|
|
|
_lastEffectiveTransform._m4storage, |
|
|
|
_lastEffectiveTransform.storage, |
|
|
|
oldLayer: engineLayer as TransformEngineLayer); |
|
|
|
|
|
|
|
addChildrenToScene(builder); |
|
|
|
|
|
|
public int alpha { |
|
|
|
get { return _alpha; } |
|
|
|
set { |
|
|
|
D.assert(value != null); |
|
|
|
if (value != _alpha) { |
|
|
|
_alpha = value; |
|
|
|
markNeedsAddToScene(); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
D.assert(filter != null); |
|
|
|
engineLayer = builder.pushBackdropFilter( |
|
|
|
filter: filter, |
|
|
|
|
|
|
D.assert(value != null); |
|
|
|
_link = value; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
LayerLink _link; |
|
|
|
|
|
|
|
|
|
|
public override void addToScene(SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
D.assert(link != null); |
|
|
|
D.assert(showWhenUnlinked != null); |
|
|
|
D.assert(link != null); |
|
|
|
if (link.leader == null && !showWhenUnlinked) { |
|
|
|
_lastTransform = null; |
|
|
|
|
|
|
defaultValue: foundation_.kNullDefaultValue)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*public class PlatformViewLayer : Layer { |
|
|
|
/// Creates a platform view layer.
|
|
|
|
///
|
|
|
|
/// The `rect` and `viewId` parameters must not be null.
|
|
|
|
public PlatformViewLayer( |
|
|
|
Rect rect = null, |
|
|
|
int viewId = default, |
|
|
|
MouseTrackerAnnotation hoverAnnotation = null |
|
|
|
) { |
|
|
|
D.assert(rect != null); |
|
|
|
} |
|
|
|
|
|
|
|
public readonly Rect rect; |
|
|
|
|
|
|
|
|
|
|
|
public readonly int viewId; |
|
|
|
|
|
|
|
public readonly MouseTrackerAnnotation hoverAnnotation; |
|
|
|
|
|
|
|
|
|
|
|
public override void addToScene(ui.SceneBuilder builder, Offset layerOffset = null) { |
|
|
|
Rect shiftedRect = layerOffset == Offset.zero ? rect : rect.shift(layerOffset); |
|
|
|
builder.addPlatformView( |
|
|
|
viewId, |
|
|
|
offset: shiftedRect.topLeft, |
|
|
|
width: shiftedRect.width, |
|
|
|
height: shiftedRect.height |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override bool findAnnotations<S>(AnnotationResult<S> result, Offset localPosition, bool onlyFirst ) { |
|
|
|
if (hoverAnnotation == null || !rect.contains(localPosition)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
if (typeof(S) == typeof(MouseTrackerAnnotation)) { |
|
|
|
Object untypedValue = hoverAnnotation; |
|
|
|
S typedValue = (S)untypedValue; |
|
|
|
result.add(new AnnotationEntry<S>( |
|
|
|
annotation: typedValue, |
|
|
|
localPosition: localPosition |
|
|
|
)); |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
}*/ |
|
|
|
int? optionsMask = null, |
|
|
|
int? rasterizerThreshold = null, |
|
|
|
bool? checkerboardRasterCacheImages = null, |
|
|
|
bool? checkerboardOffscreenLayers = null |
|
|
|
int optionsMask = default, |
|
|
|
int rasterizerThreshold = default, |
|
|
|
bool checkerboardRasterCacheImages = default, |
|
|
|
bool checkerboardOffscreenLayers = default |
|
|
|
|
|
|
|
) { |
|
|
|
_overlayRect = overlayRect; |
|
|
|
|
|
|
} |
|
|
|
Rect _overlayRect; |
|
|
|
|
|
|
|
public readonly int? optionsMask; |
|
|
|
public readonly int? rasterizerThreshold; |
|
|
|
public readonly bool? checkerboardRasterCacheImages; |
|
|
|
public readonly bool? checkerboardOffscreenLayers; |
|
|
|
public readonly int optionsMask; |
|
|
|
public readonly int rasterizerThreshold; |
|
|
|
public readonly bool checkerboardRasterCacheImages; |
|
|
|
public readonly bool checkerboardOffscreenLayers; |
|
|
|
|
|
|
|
public override bool findAnnotations<S>(AnnotationResult<S> result, Offset localPosition, bool onlyFirst ) { |
|
|
|
return false; |
|
|
|
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
|
|
|
|
var shiftedOverlayRect = layerOffset == Offset.zero ? overlayRect : overlayRect.shift(layerOffset); |
|
|
|
builder.addPerformanceOverlay((int)optionsMask, shiftedOverlayRect); |
|
|
|
builder.addPerformanceOverlay(optionsMask, shiftedOverlayRect); |
|
|
|
//TODO: add implementations
|
|
|
|
//builder.setRasterizerTracingThreshold(rasterizerThreshold);
|
|
|
|
//builder.setCheckerboardRasterCacheImages(checkerboardRasterCacheImages);
|
|
|
|
|
|
|
) { |
|
|
|
offset = offset ?? Offset.zero; |
|
|
|
D.assert(value != null); |
|
|
|
D.assert(opaque != null); |
|
|
|
this.value = value; |
|
|
|
this.size = size; |
|
|
|
this.offset = offset; |
|
|
|
|
|
|
|
|
|
|
public override bool findAnnotations<S>(AnnotationResult<S> result, Offset localPosition, bool onlyFirst ) { |
|
|
|
bool isAbsorbed = base.findAnnotations(result, localPosition, onlyFirst: onlyFirst); |
|
|
|
if (result.entries.Count() != 0 && onlyFirst) |
|
|
|
if (result.entries.Any() && onlyFirst) |
|
|
|
return isAbsorbed; |
|
|
|
if (size != null && !(offset & size).contains(localPosition)) { |
|
|
|
return isAbsorbed; |
|
|
|
|
|
|
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|
|
|
base.debugFillProperties(properties); |
|
|
|
properties.add(new FloatProperty("elevation", elevation)); |
|
|
|
properties.add(new DiagnosticsProperty<Color>("color", color)); |
|
|
|
properties.add(new ColorProperty("color", color)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |