浏览代码

Merge branch 'kgdev' into 'master'

update Timer.runInMain to Window.runInMain.

See merge request upm-packages/ui-widgets/com.unity.uiwidgets!13
/main
Fan Zhang 6 年前
当前提交
e083fe17
共有 9 个文件被更改,包括 65 次插入30 次删除
  1. 4
      Runtime/async/coroutine.cs
  2. 68
      Runtime/async/timer.cs
  3. 4
      Runtime/editor/editor_window.cs
  4. 6
      Runtime/foundation/node.mixin.gen.cs
  5. 3
      Runtime/foundation/node.mixin.njk
  6. 3
      Runtime/rendering/box.mixin.gen.cs
  7. 3
      Runtime/rendering/box.mixin.njk
  8. 2
      Runtime/ui/painting/codec_gif.cs
  9. 2
      Runtime/ui/window.cs

4
Runtime/async/coroutine.cs


this.isDone = true;
this.lastResult = null;
if (this._isBackground) {
Timer.runInMain(() => { this._window.run(() => { this._promise.Reject(lastError); }); });
this._window.runInMain(() => { this._promise.Reject(lastError); });
} else {
this._promise.Reject(lastError);
}

this.isDone = true;
D.assert(this.lastError == null);
if (this._isBackground) {
Timer.runInMain(() => { this._window.run(() => { this._promise.Resolve(this.lastResult); }); });
this._window.runInMain(() => { this._promise.Resolve(this.lastResult); });
} else {
this._promise.Resolve(this.lastResult);
}

68
Runtime/async/timer.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;

static LinkedList<Action> _callbacks = new LinkedList<Action>();
internal static void runInMainFromFinalizer(Action callback) {
lock (_syncObj) {
_callbacks.AddLast(callback);
}
}
public static void runInMain(Action callback) {
public static void runInMainFromFinalizer(Action callback) {
lock (_syncObj) {
_callbacks.AddLast(callback);
}

LinkedList<Action> callbacks;
lock (_syncObj) {
if (_callbacks.isEmpty()) {
return;
}
callbacks = _callbacks;
_callbacks = new LinkedList<Action>();
}

this._queue = new PriorityQueue<TimerImpl>();
}
public Timer runInMain(Action callback) {
var timer = new TimerImpl(callback);
lock (this._queue) {
this._queue.enqueue(timer);
}
return timer;
}
this._queue.enqueue(timer);
lock (this._queue) {
this._queue.enqueue(timer);
}
return timer;
}

this._queue.enqueue(timer);
lock (this._queue) {
this._queue.enqueue(timer);
}
return timer;
}

List<TimerImpl> timers = null;
List<TimerImpl> appendList = null;
while (this._queue.count > 0 && this._queue.peek().deadline <= now) {
var timer = this._queue.dequeue();
if (timers == null) {
timers = new List<TimerImpl>();
}
lock (this._queue) {
while (this._queue.count > 0 && this._queue.peek().deadline <= now) {
var timer = this._queue.dequeue();
if (timers == null) {
timers = new List<TimerImpl>();
}
timers.Add(timer);
timers.Add(timer);
}
}
if (timers != null) {

}
if (appendList != null) {
foreach (var timer in appendList) {
this._queue.enqueue(timer);
lock (this._queue) {
foreach (var timer in appendList) {
this._queue.enqueue(timer);
}
public readonly bool periodic;
public readonly TimeSpan internval;
public readonly bool periodic;
readonly TimeSpan _interval;
this.periodic = periodic;
this.periodic = periodic;
this.internval = duration;
this._interval = duration;
}
public TimerImpl(Action callback) {
this._deadline = 0;
this._callback = callback;
this._done = false;
}
public double deadline {

}
if (this.periodic) {
this._deadline = now + this.internval.TotalSeconds;
this._deadline = now + this._interval.TotalSeconds;
}
}

4
Runtime/editor/editor_window.cs


: this._timerProvider.run(duration, callback);
}
public override Timer runInMain(Action callback) {
return this._timerProvider.runInMain(callback);
}
public void attachRootRenderBox(RenderBox root) {
using (this.getScope()) {
this._binding.renderView.child = root;

6
Runtime/foundation/node.mixin.gen.cs


D.assert(child._parent == null);
D.assert(() => {
var node = this;
while (node.parent != null)
while (node.parent != null) {
}
D.assert(node != child); // indicates we are about to create a cycle
return true;
});

D.assert(child._parent == null);
D.assert(() => {
var node = this;
while (node.parent != null)
while (node.parent != null) {
}
D.assert(node != child); // indicates we are about to create a cycle
return true;
});

3
Runtime/foundation/node.mixin.njk


D.assert(child._parent == null);
D.assert(() => {
var node = this;
while (node.parent != null)
while (node.parent != null) {
}
D.assert(node != child); // indicates we are about to create a cycle
return true;
});

3
Runtime/rendering/box.mixin.gen.cs


while (child != null)
{
ParentDataType childParentData = (ParentDataType) child.parentData;
if (child.hitTest(result, position: position - childParentData.offset))
if (child.hitTest(result, position: position - childParentData.offset)) {
}
child = childParentData.previousSibling;
}
return false;

3
Runtime/rendering/box.mixin.njk


while (child != null)
{
ParentDataType childParentData = (ParentDataType) child.parentData;
if (child.hitTest(result, position: position - childParentData.offset))
if (child.hitTest(result, position: position - childParentData.offset)) {
}
child = childParentData.previousSibling;
}
return false;

2
Runtime/ui/painting/codec_gif.cs


frame = this._frames[i];
}
Timer.runInMain(() => { window.run(() => { frame.Resolve(frameData); }); });
window.runInMain(() => { frame.Resolve(frameData); });
i++;
}

2
Runtime/ui/window.cs


return this.run(TimeSpan.Zero, callback);
}
public abstract Timer runInMain(Action callback);
public abstract TextInput textInput { get; }
public abstract IDisposable getScope();
正在加载...
取消
保存