浏览代码

Update rendering.

/main
Yuncong Zhang 5 年前
当前提交
3ca5ca69
共有 6 个文件被更改,包括 48 次插入27 次删除
  1. 3
      Runtime/rendering/binding.cs
  2. 6
      Runtime/rendering/sliver.cs
  3. 2
      Runtime/rendering/sliver_multi_box_adaptor.cs
  4. 10
      Runtime/rendering/sliver_persistent_header.cs
  5. 3
      Runtime/rendering/table.cs
  6. 51
      Runtime/rendering/viewport.cs

3
Runtime/rendering/binding.cs


protected virtual void handleTextScaleFactorChanged() {
}
protected virtual void handlePlatformBrightnessChanged() {
}
protected virtual ViewConfiguration createViewConfiguration() {
var devicePixelRatio = Window.instance.devicePixelRatio;
return new ViewConfiguration(

6
Runtime/rendering/sliver.cs


GrowthDirection growthDirection,
ScrollDirection userScrollDirection,
float scrollOffset,
float precedingScrollExtent,
float overlap,
float remainingPaintExtent,
float crossAxisExtent,

this.growthDirection = growthDirection;
this.userScrollDirection = userScrollDirection;
this.scrollOffset = scrollOffset;
this.precedingScrollExtent = precedingScrollExtent;
this.overlap = overlap;
this.remainingPaintExtent = remainingPaintExtent;
this.crossAxisExtent = crossAxisExtent;

GrowthDirection? growthDirection = null,
ScrollDirection? userScrollDirection = null,
float? scrollOffset = null,
float? precedingScrollExtent = null,
float? overlap = null,
float? remainingPaintExtent = null,
float? crossAxisExtent = null,

growthDirection: growthDirection ?? this.growthDirection,
userScrollDirection: userScrollDirection ?? this.userScrollDirection,
scrollOffset: scrollOffset ?? this.scrollOffset,
precedingScrollExtent: precedingScrollExtent ?? this.precedingScrollExtent,
overlap: overlap ?? this.overlap,
remainingPaintExtent: remainingPaintExtent ?? this.remainingPaintExtent,
crossAxisExtent: crossAxisExtent ?? this.crossAxisExtent,

public readonly ScrollDirection userScrollDirection;
public readonly float scrollOffset;
public readonly float precedingScrollExtent;
public readonly float overlap;

2
Runtime/rendering/sliver_multi_box_adaptor.cs


foreach (int index in indices) {
children.Add(this._keepAliveBucket[index].toDiagnosticsNode(
name: "child with index " + index + " (kept alive offstage)",
name: "child with index " + index + " (kept alive but not laid out)",
style: DiagnosticsTreeStyle.offstage
));
}

10
Runtime/rendering/sliver_persistent_header.cs


if (value == null) {
this._controller?.dispose();
this._controller = null;
}
else {
if (this._snapConfiguration != null && value.vsync != this._snapConfiguration.vsync) {

protected override float updateGeometry() {
float? minExtent = this.minExtent;
float? minAllowedExtent = this.constraints.remainingPaintExtent > minExtent
? minExtent
: this.constraints.remainingPaintExtent;
float? clampedPaintExtent =
paintExtent?.clamp(minAllowedExtent ?? 0.0f, this.constraints.remainingPaintExtent);
paintExtent: paintExtent?.clamp(minExtent ?? 0.0f, this.constraints.remainingPaintExtent) ?? 0.0f,
layoutExtent: layoutExtent?.clamp(0.0f, this.constraints.remainingPaintExtent - minExtent ?? 0.0f),
paintExtent: clampedPaintExtent ?? 0.0f,
layoutExtent: layoutExtent?.clamp(0.0f, clampedPaintExtent ?? 0.0f),
maxPaintExtent: maxExtent ?? 0.0f,
maxScrollObstructionExtent: maxExtent ?? 0.0f,
hasVisualOverflow: true

3
Runtime/rendering/table.cs


float deficit = tableWidth - maxWidthConstraint;
int availableColumns = this.columns;
while (deficit > 0.0f && totalFlex > 0.0f) {
float minimumDeficit = 0.00000001f;
while (deficit > 0.0f && totalFlex > minimumDeficit) {
float newTotalFlex = 0.0f;
for (int x = 0; x < this.columns; x++) {
if (flexes[x] != null) {

51
Runtime/rendering/viewport.cs


GrowthDirectionUtils.applyGrowthDirectionToScrollDirection(
this.offset.userScrollDirection, growthDirection);
float maxPaintOffset = layoutOffset + overlap;
float precedingScrollExtent = 0.0f;
while (child != null) {
float sliverScrollOffset = scrollOffset <= 0.0 ? 0.0f : scrollOffset;

growthDirection: growthDirection,
userScrollDirection: adjustedUserScrollDirection,
scrollOffset: sliverScrollOffset,
precedingScrollExtent: precedingScrollExtent,
overlap: maxPaintOffset - layoutOffset,
remainingPaintExtent: Mathf.Max(0.0f,
remainingPaintExtent - layoutOffset + initialLayoutOffset),

maxPaintOffset = Mathf.Max(effectiveLayoutOffset + childLayoutGeometry.paintExtent,
maxPaintOffset);
scrollOffset -= childLayoutGeometry.scrollExtent;
precedingScrollExtent += childLayoutGeometry.scrollExtent;
layoutOffset += childLayoutGeometry.layoutExtent;
if (childLayoutGeometry.cacheExtent != 0.0) {

public RevealedOffset getOffsetToReveal(RenderObject target, float alignment, Rect rect = null) {
float leadingScrollOffset = 0.0f;
float targetMainAxisExtent = 0.0f;
RenderObject descendant;
if (target is RenderBox) {
RenderBox targetBox = (RenderBox) target;
RenderObject child = target;
RenderBox pivot = null;
bool onlySlivers = target is RenderSliver;
while (child.parent != this) {
D.assert(child.parent != null, $"target must be a descendant of ${this}");
if (child is RenderBox) {
pivot = (RenderBox) child;
}
RenderBox pivot = targetBox;
while (pivot.parent is RenderBox) {
pivot = (RenderBox) pivot.parent;
if (child.parent is RenderSliver) {
RenderSliver parent = (RenderSliver) child.parent;
leadingScrollOffset += parent.childScrollOffset(child);
else {
onlySlivers = false;
leadingScrollOffset = 0.0f;
}
child = (RenderObject) child.parent;
}
if (pivot != null) {
D.assert(pivot.parent != null);
D.assert(pivot.parent != this);
D.assert(pivot != this);

transform = targetBox.getTransformTo(pivot);
transform = target.getTransformTo(pivot);
Rect bounds = transform.mapRect(rect);
float offset = 0.0f;

break;
}
leadingScrollOffset = pivot.size.height - offset;
leadingScrollOffset += pivot.size.height - offset;
leadingScrollOffset = bounds.left;
leadingScrollOffset += bounds.left;
leadingScrollOffset = bounds.top;
leadingScrollOffset += bounds.top;
targetMainAxisExtent = bounds.height;
break;
case AxisDirection.left:

break;
}
leadingScrollOffset = pivot.size.width - offset;
leadingScrollOffset += pivot.size.width - offset;
descendant = pivot;
else if (target is RenderSliver) {
else if (onlySlivers) {
leadingScrollOffset = 0.0f;
descendant = targetSliver;
}
RenderObject child = descendant;
while (child.parent is RenderSliver) {
var parent = (RenderSliver) child.parent;
leadingScrollOffset += parent.childScrollOffset(child);
child = parent;
}
D.assert(child.parent == this);

正在加载...
取消
保存