kg
6 年前
当前提交
79c3c83d
共有 40 个文件被更改,包括 871 次插入 和 57 次删除
-
1Assets/UIWidgets/foundation/callback.cs
-
1Assets/UIWidgets/foundation/change_notifier.cs
-
2Assets/UIWidgets/painting/box_border.cs
-
14Assets/UIWidgets/painting/box_decoration.cs
-
8Assets/UIWidgets/rendering/layer.cs
-
13Assets/UIWidgets/rendering/object.cs
-
6Assets/UIWidgets/rendering/object.mixin.njk
-
5Assets/UIWidgets/rendering/proxy_box.cs
-
11Assets/UIWidgets/rendering/viewpoint.cs
-
35Assets/UIWidgets/ui/compositing.cs
-
31Assets/UIWidgets/ui/geometry.cs
-
72Assets/UIWidgets/ui/painting.cs
-
1Assets/UIWidgets/widgets/framework.cs
-
3Assets/UIWidgets/editor.meta
-
3Assets/UIWidgets/flow.meta
-
2Assets/UIWidgets/foundation/binding.cs
-
3Assets/UIWidgets/foundation/binding.cs.meta
-
68Assets/UIWidgets/rendering/binding.cs
-
3Assets/UIWidgets/rendering/binding.cs.meta
-
11Assets/UIWidgets/rendering/binding.gen.cs.meta
-
3Assets/UIWidgets/rendering/binding.njk
-
3Assets/UIWidgets/rendering/binding.njk.meta
-
113Assets/UIWidgets/rendering/view.cs
-
3Assets/UIWidgets/rendering/view.cs.meta
-
3Assets/UIWidgets/scheduler.meta
-
50Assets/UIWidgets/ui/window.cs
-
3Assets/UIWidgets/ui/window.cs.meta
-
100Assets/UIWidgets/editor/editor_window.cs
-
3Assets/UIWidgets/editor/editor_window.cs.meta
-
39Assets/UIWidgets/flow/container_layer.cs
-
3Assets/UIWidgets/flow/container_layer.cs.meta
-
35Assets/UIWidgets/flow/layer.cs
-
3Assets/UIWidgets/flow/layer.cs.meta
-
60Assets/UIWidgets/flow/layer_builder.cs
-
3Assets/UIWidgets/flow/layer_builder.cs.meta
-
208Assets/UIWidgets/scheduler/binding.cs
-
3Assets/UIWidgets/scheduler/binding.cs.meta
|
|||
namespace UIWidgets.foundation { |
|||
public delegate void VoidCallback(); |
|||
} |
|
|||
namespace UIWidgets.ui { |
|||
using System; |
|||
using UIWidgets.flow; |
|||
using UnityEngine; |
|||
|
|||
namespace UIWidgets.ui { |
|||
private readonly LayerBuilder _layerBuilder = new LayerBuilder(); |
|||
|
|||
public void pushTransform(Matrix4x4 matrix) { |
|||
this._layerBuilder.pushTransform(matrix); |
|||
} |
|||
|
|||
this._layerBuilder.pushClipRect(rect); |
|||
this._layerBuilder.pushOpacity(alpha); |
|||
this._layerBuilder.pop(); |
|||
this._layerBuilder.pushPicture(offset, picture); |
|||
} |
|||
|
|||
public Scene build() { |
|||
return new Scene(this._layerBuilder.takeLayer()); |
|||
} |
|||
} |
|||
|
|||
public class Scene : IDisposable { |
|||
public Scene(Layer rootLayer) { |
|||
this._rootLayer = rootLayer; |
|||
} |
|||
|
|||
private readonly Layer _rootLayer; |
|||
|
|||
public Layer takeLayer() { |
|||
return this._rootLayer; |
|||
} |
|||
|
|||
public void Dispose() { |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 531a69a207e64172959ffbed66131560 |
|||
timeCreated: 1534308241 |
|
|||
fileFormatVersion: 2 |
|||
guid: e1056a6e2b8247cbaf7db24691b913ec |
|||
timeCreated: 1534389920 |
|
|||
namespace UIWidgets.foundation { |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5d042465a280442e8c71335670cabc3a |
|||
timeCreated: 1534222421 |
|
|||
using System; |
|||
using UIWidgets.scheduler; |
|||
using UIWidgets.ui; |
|||
|
|||
namespace UIWidgets.rendering { |
|||
public abstract class RendererBinding : SchedulerBinding { |
|||
public RendererBinding(Window window) : base(window) { |
|||
this._pipelineOwner = new PipelineOwner( |
|||
binding: this, |
|||
onNeedVisualUpdate: this.ensureVisualUpdate |
|||
); |
|||
|
|||
window._onMetricsChanged = this.handleMetricsChanged; |
|||
this.initRenderView(); |
|||
this.addPersistentFrameCallback(this._handlePersistentFrameCallback); |
|||
} |
|||
|
|||
public void initRenderView() { |
|||
this.renderView = new RenderView(configuration: this.createViewConfiguration()); |
|||
this.renderView.scheduleInitialFrame(); |
|||
} |
|||
|
|||
public PipelineOwner pipelineOwner { |
|||
get { return this._pipelineOwner; } |
|||
} |
|||
|
|||
public PipelineOwner _pipelineOwner; |
|||
|
|||
public RenderView renderView { |
|||
get { return (RenderView) this._pipelineOwner.rootNode; } |
|||
set { this._pipelineOwner.rootNode = value; } |
|||
} |
|||
|
|||
public void handleMetricsChanged() { |
|||
this.renderView.configuration = this.createViewConfiguration(); |
|||
this.scheduleForcedFrame(); |
|||
} |
|||
|
|||
public ViewConfiguration createViewConfiguration() { |
|||
var devicePixelRatio = this._window.devicePixelRatio; |
|||
return new ViewConfiguration( |
|||
size: this._window.physicalSize / devicePixelRatio, |
|||
devicePixelRatio: devicePixelRatio |
|||
); |
|||
} |
|||
|
|||
public void _handlePersistentFrameCallback(TimeSpan timeStamp) { |
|||
this.drawFrame(); |
|||
} |
|||
|
|||
public void drawFrame() { |
|||
this.pipelineOwner.flushLayout(); |
|||
this.pipelineOwner.flushCompositingBits(); |
|||
this.pipelineOwner.flushPaint(); |
|||
this.renderView.compositeFrame(); |
|||
} |
|||
|
|||
public void render(Scene scene) { |
|||
this._window.render(scene); |
|||
} |
|||
} |
|||
|
|||
public class RendererBindingImpl : RendererBinding { |
|||
public RendererBindingImpl(Window window, RenderBox root) : base(window) { |
|||
this.renderView.child = root; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7c20610b6dd54a58a6735fadc317cb90 |
|||
timeCreated: 1534222643 |
|
|||
fileFormatVersion: 2 |
|||
guid: b8e36c63511f04dbf8d5ed86f144274d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UIWidgets.rendering { |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3c1a210c4c4b4354bba182d6903742cd |
|||
timeCreated: 1534222730 |
|
|||
using System; |
|||
using UIWidgets.ui; |
|||
using UnityEngine; |
|||
using Rect = UIWidgets.ui.Rect; |
|||
|
|||
namespace UIWidgets.rendering { |
|||
public class ViewConfiguration { |
|||
public ViewConfiguration( |
|||
Size size = null, |
|||
double devicePixelRatio = 1.0 |
|||
) { |
|||
this.size = size ?? Size.zero; |
|||
this.devicePixelRatio = devicePixelRatio; |
|||
} |
|||
|
|||
public readonly Size size; |
|||
|
|||
public readonly double devicePixelRatio; |
|||
|
|||
public Matrix4x4 toMatrix() { |
|||
return Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3( |
|||
(float) this.devicePixelRatio, (float) this.devicePixelRatio, 1)); |
|||
} |
|||
|
|||
public override string ToString() { |
|||
return string.Format("${0} at ${1}x", this.size, this.devicePixelRatio); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class RenderView : RenderObjectWithChildMixinRenderObject<RenderBox> { |
|||
public RenderView( |
|||
RenderBox child = null, |
|||
ViewConfiguration configuration = null) { |
|||
this.child = child; |
|||
this._configuration = configuration; |
|||
} |
|||
|
|||
public Size size { |
|||
get { return this._size; } |
|||
} |
|||
|
|||
public Size _size = Size.zero; |
|||
|
|||
public ViewConfiguration configuration { |
|||
get { return this._configuration; } |
|||
set { |
|||
if (value == this._configuration) { |
|||
return; |
|||
} |
|||
|
|||
this._configuration = value; |
|||
this.replaceRootLayer((OffsetLayer) this._updateMatricesAndCreateNewRootLayer()); |
|||
this.markNeedsLayout(); |
|||
} |
|||
} |
|||
|
|||
public ViewConfiguration _configuration; |
|||
|
|||
public void scheduleInitialFrame() { |
|||
this.scheduleInitialLayout(); |
|||
this.scheduleInitialPaint((OffsetLayer) this._updateMatricesAndCreateNewRootLayer()); |
|||
this.owner.requestVisualUpdate(); |
|||
} |
|||
|
|||
public Matrix4x4 _rootTransform; |
|||
|
|||
public Layer _updateMatricesAndCreateNewRootLayer() { |
|||
this._rootTransform = this.configuration.toMatrix(); |
|||
ContainerLayer rootLayer = new TransformLayer(transform: this._rootTransform); |
|||
rootLayer.attach(this); |
|||
return rootLayer; |
|||
} |
|||
|
|||
public override void performResize() { |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public override void performLayout() { |
|||
this._size = this.configuration.size; |
|||
if (this.child != null) { |
|||
this.child.layout(BoxConstraints.tight(this._size)); |
|||
} |
|||
} |
|||
|
|||
public override bool isRepaintBoundary { |
|||
get { return true; } |
|||
} |
|||
|
|||
public override void paint(PaintingContext context, Offset offset) { |
|||
if (this.child != null) { |
|||
context.paintChild(this.child, offset); |
|||
} |
|||
} |
|||
|
|||
public void applyPaintTransform(RenderBox child, Matrix4x4 transform) { |
|||
transform *= this._rootTransform; |
|||
base.applyPaintTransform(child, transform); |
|||
} |
|||
|
|||
public void compositeFrame() { |
|||
var builder = new SceneBuilder(); |
|||
this.layer.addToScene(builder, Offset.zero); |
|||
using (var scene = builder.build()) { |
|||
this.owner.binding.render(scene); |
|||
} |
|||
} |
|||
|
|||
public override Rect paintBounds { |
|||
get { return Offset.zero & (this.size * this.configuration.devicePixelRatio); } |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 92d5facf02ac421dbe319205bf049557 |
|||
timeCreated: 1534220758 |
|
|||
fileFormatVersion: 2 |
|||
guid: d1ea4ed01afa43fb82a5f5f549595271 |
|||
timeCreated: 1534227201 |
|
|||
using System; |
|||
using UIWidgets.rendering; |
|||
using UIWidgets.widgets; |
|||
|
|||
namespace UIWidgets.ui { |
|||
public delegate void VoidCallback(); |
|||
|
|||
public delegate void FrameCallback(TimeSpan duration); |
|||
|
|||
public abstract class Window { |
|||
public double devicePixelRatio { |
|||
get { return this._devicePixelRatio; } |
|||
} |
|||
|
|||
public double _devicePixelRatio = 1.0; |
|||
|
|||
public Size physicalSize { |
|||
get { return this._physicalSize; } |
|||
} |
|||
|
|||
public Size _physicalSize = Size.zero; |
|||
|
|||
public VoidCallback onMetricsChanged { |
|||
get { return this._onMetricsChanged; } |
|||
set { this._onMetricsChanged = value; } |
|||
} |
|||
|
|||
public VoidCallback _onMetricsChanged; |
|||
|
|||
public FrameCallback onBeginFrame { |
|||
get { return this._onBeginFrame; } |
|||
set { this._onBeginFrame = value; } |
|||
} |
|||
|
|||
public FrameCallback _onBeginFrame; |
|||
|
|||
public VoidCallback onDrawFrame { |
|||
get { return this._onDrawFrame; } |
|||
set { this._onDrawFrame = value; } |
|||
} |
|||
|
|||
public VoidCallback _onDrawFrame; |
|||
|
|||
public abstract void scheduleFrame(); |
|||
|
|||
public abstract void render(Scene scene); |
|||
} |
|||
|
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 81bd1754231e433bb8db2424e0a0debd |
|||
timeCreated: 1534300726 |
|
|||
using System; |
|||
using UIWidgets.flow; |
|||
using UIWidgets.rendering; |
|||
using UIWidgets.ui; |
|||
using UIWidgets.widgets; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using Rect = UnityEngine.Rect; |
|||
|
|||
namespace UIWidgets.editor { |
|||
public class WindowAdapter : Window { |
|||
public WindowAdapter(EditorWindow editorWindow) { |
|||
this.editorWindow = editorWindow; |
|||
this._devicePixelRatio = EditorGUIUtility.pixelsPerPoint; |
|||
this._lastPosition = editorWindow.position; |
|||
this._physicalSize = new Size(this._lastPosition.width, this._lastPosition.height); |
|||
} |
|||
|
|||
public EditorWindow editorWindow; |
|||
public Rect _lastPosition; |
|||
public readonly DateTime _epoch = DateTime.Now; |
|||
|
|||
public void OnGUI() { |
|||
if (this.onBeginFrame != null) { |
|||
this.onBeginFrame(DateTime.Now - this._epoch); |
|||
} |
|||
|
|||
if (this.onDrawFrame != null) { |
|||
this.onDrawFrame(); |
|||
} |
|||
} |
|||
|
|||
public void Update() { |
|||
bool dirty = false; |
|||
if (this._devicePixelRatio != EditorGUIUtility.pixelsPerPoint) { |
|||
this._devicePixelRatio = EditorGUIUtility.pixelsPerPoint; |
|||
dirty = true; |
|||
} |
|||
|
|||
if (this._lastPosition != this.editorWindow.position) { |
|||
this._lastPosition = this.editorWindow.position; |
|||
this._physicalSize = new Size(this._lastPosition.width, this._lastPosition.height); |
|||
dirty = true; |
|||
} |
|||
|
|||
if (dirty) { |
|||
if (this._onMetricsChanged != null) { |
|||
this._onMetricsChanged(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override void scheduleFrame() { |
|||
if (this.editorWindow != null) { |
|||
this.editorWindow.Repaint(); |
|||
} |
|||
} |
|||
|
|||
public override void render(Scene scene) { |
|||
var layer = scene.takeLayer(); |
|||
|
|||
var prerollContext = new PrerollContext(); |
|||
layer.preroll(prerollContext, Matrix4x4.identity); |
|||
|
|||
var paintContext = new PaintContext(); |
|||
layer.paint(paintContext); |
|||
} |
|||
} |
|||
|
|||
public class EditorWindow : UnityEditor.EditorWindow { |
|||
protected virtual void OnGUI() { |
|||
if (this.windowAdapter != null) { |
|||
this.windowAdapter.OnGUI(); |
|||
} |
|||
} |
|||
|
|||
protected virtual void Update() { |
|||
if (this.windowAdapter != null) { |
|||
this.windowAdapter.Update(); |
|||
} |
|||
} |
|||
|
|||
protected virtual void Awake() { |
|||
this.windowAdapter = new WindowAdapter(this); |
|||
} |
|||
|
|||
protected void OnDestroy() { |
|||
this.windowAdapter = null; |
|||
} |
|||
|
|||
public WindowAdapter windowAdapter; |
|||
|
|||
public void runWidget(Widget root) { |
|||
} |
|||
|
|||
public void runRenderBox(RenderBox root) { |
|||
new RendererBindingImpl(this.windowAdapter, root); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e8cf046da18d4f6d97d5de766aea64e0 |
|||
timeCreated: 1534308250 |
|
|||
using System.Collections.Generic; |
|||
using UIWidgets.ui; |
|||
using Matrix4x4 = UnityEngine.Matrix4x4; |
|||
|
|||
namespace UIWidgets.flow { |
|||
public abstract class ContainerLayer : Layer { |
|||
private readonly List<Layer> _layers = new List<Layer>(); |
|||
|
|||
public List<Layer> layers { |
|||
get { return this._layers; } |
|||
} |
|||
|
|||
public void add(Layer layer) { |
|||
layer.parent = this; |
|||
this._layers.Add(layer); |
|||
} |
|||
|
|||
public override void preroll(PrerollContext context, Matrix4x4 matrix) { |
|||
Rect childPaintBounds = Rect.zero; |
|||
this.prerollChildren(context, matrix, childPaintBounds); |
|||
this.paintBounds = childPaintBounds; |
|||
} |
|||
|
|||
protected void prerollChildren(PrerollContext context, Matrix4x4 childMatrix, Rect childPaintBounds) { |
|||
foreach (var layer in this._layers) { |
|||
layer.preroll(context, childMatrix); |
|||
childPaintBounds.expandToInclude(layer.paintBounds); |
|||
} |
|||
} |
|||
|
|||
protected void paintChildren(PaintContext context) { |
|||
foreach (var layer in this._layers) { |
|||
if (layer.needsPainting) { |
|||
layer.paint(context); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 54b9aa9fb9694d2a80843b7c14f4de09 |
|||
timeCreated: 1534390038 |
|
|||
using UnityEngine; |
|||
using Rect = UIWidgets.ui.Rect; |
|||
|
|||
namespace UIWidgets.flow { |
|||
public class PrerollContext { |
|||
} |
|||
|
|||
public class PaintContext { |
|||
} |
|||
|
|||
public abstract class Layer { |
|||
private ContainerLayer _parent; |
|||
|
|||
public ContainerLayer parent { |
|||
get { return this._parent; } |
|||
set { this._parent = value; } |
|||
} |
|||
|
|||
private Rect _paintBounds; |
|||
|
|||
public Rect paintBounds { |
|||
get { return this._paintBounds; } |
|||
set { this._paintBounds = value; } |
|||
} |
|||
|
|||
public bool needsPainting { |
|||
get { return !this._paintBounds.isEmpty; } |
|||
} |
|||
|
|||
public virtual void preroll(PrerollContext context, Matrix4x4 matrix) { |
|||
} |
|||
|
|||
public abstract void paint(PaintContext context); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 523b29e94d694060871b6531d0a4f482 |
|||
timeCreated: 1534389944 |
|
|||
using System.Collections.Generic; |
|||
using UIWidgets.ui; |
|||
using Matrix4x4 = UnityEngine.Matrix4x4; |
|||
|
|||
namespace UIWidgets.flow { |
|||
public class LayerBuilder { |
|||
private ContainerLayer _rootLayer; |
|||
private ContainerLayer _currentLayer; |
|||
|
|||
private readonly Stack<Rect> _cullRects = new Stack<Rect>(); |
|||
|
|||
public LayerBuilder() { |
|||
this._cullRects.Push(Rect.largest); |
|||
} |
|||
|
|||
private void pushLayer(ContainerLayer layer, Rect cullRect) { |
|||
this._cullRects.Push(cullRect); |
|||
|
|||
if (this._rootLayer == null) { |
|||
this._rootLayer = layer; |
|||
this._currentLayer = layer; |
|||
return; |
|||
} |
|||
|
|||
if (this._currentLayer == null) { |
|||
return; |
|||
} |
|||
|
|||
this._currentLayer.add(layer); |
|||
this._currentLayer = layer; |
|||
} |
|||
|
|||
public Layer takeLayer() { |
|||
return this._rootLayer; |
|||
} |
|||
|
|||
public void pop() { |
|||
if (this._currentLayer == null) { |
|||
return; |
|||
} |
|||
|
|||
this._cullRects.Pop(); |
|||
this._currentLayer = this._currentLayer.parent; |
|||
} |
|||
|
|||
public void pushTransform(Matrix4x4 matrix) { |
|||
} |
|||
|
|||
public void pushClipRect(Rect clipRect) { |
|||
|
|||
} |
|||
|
|||
public void pushOpacity(int alpha) { |
|||
} |
|||
|
|||
public void pushPicture(Offset offset, Picture picture) { |
|||
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f7ca7d815141405a85b3a2de247eb1dc |
|||
timeCreated: 1534391496 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UIWidgets.ui; |
|||
using UnityEngine; |
|||
|
|||
namespace UIWidgets.scheduler { |
|||
public enum SchedulerPhase { |
|||
idle, |
|||
transientCallbacks, |
|||
midFrameMicrotasks, |
|||
persistentCallbacks, |
|||
postFrameCallbacks, |
|||
} |
|||
|
|||
public class _FrameCallbackEntry { |
|||
public _FrameCallbackEntry(FrameCallback callback, bool rescheduling = false) { |
|||
this.callback = callback; |
|||
} |
|||
|
|||
public readonly FrameCallback callback; |
|||
} |
|||
|
|||
public abstract class SchedulerBinding { |
|||
public SchedulerBinding(Window window) { |
|||
this._window = window; |
|||
|
|||
window.onBeginFrame = this._handleBeginFrame; |
|||
window.onDrawFrame = this._handleDrawFrame; |
|||
} |
|||
|
|||
public readonly Window _window; |
|||
|
|||
public double timeDilation { |
|||
get { return this._timeDilation; } |
|||
set { |
|||
if (this._timeDilation == value) { |
|||
return; |
|||
} |
|||
|
|||
this.resetEpoch(); |
|||
this._timeDilation = value; |
|||
} |
|||
} |
|||
|
|||
public double _timeDilation = 1.0; |
|||
|
|||
|
|||
public int _nextFrameCallbackId = 0; |
|||
public Dictionary<int, _FrameCallbackEntry> _transientCallbacks = new Dictionary<int, _FrameCallbackEntry>(); |
|||
public HashSet<int> _removedIds = new HashSet<int>(); |
|||
|
|||
public int transientCallbackCount { |
|||
get { return this._transientCallbacks.Count; } |
|||
} |
|||
|
|||
public int scheduleFrameCallback(FrameCallback callback, bool rescheduling = false) { |
|||
this.scheduleFrame(); |
|||
this._nextFrameCallbackId += 1; |
|||
this._transientCallbacks[this._nextFrameCallbackId] = |
|||
new _FrameCallbackEntry(callback, rescheduling: rescheduling); |
|||
return this._nextFrameCallbackId; |
|||
} |
|||
|
|||
public void cancelFrameCallbackWithId(int id) { |
|||
this._transientCallbacks.Remove(id); |
|||
this._removedIds.Add(id); |
|||
} |
|||
|
|||
public readonly List<FrameCallback> _persistentCallbacks = new List<FrameCallback>(); |
|||
|
|||
public void addPersistentFrameCallback(FrameCallback callback) { |
|||
this._persistentCallbacks.Add(callback); |
|||
} |
|||
|
|||
public readonly List<FrameCallback> _postFrameCallbacks = new List<FrameCallback>(); |
|||
|
|||
public void addPostFrameCallback(FrameCallback callback) { |
|||
this._postFrameCallbacks.Add(callback); |
|||
} |
|||
|
|||
public bool hasScheduledFrame { |
|||
get { return this._hasScheduledFrame; } |
|||
} |
|||
|
|||
public bool _hasScheduledFrame = false; |
|||
|
|||
public SchedulerPhase schedulerPhase { |
|||
get { return this._schedulerPhase; } |
|||
} |
|||
|
|||
public SchedulerPhase _schedulerPhase = SchedulerPhase.idle; |
|||
|
|||
public void ensureVisualUpdate() { |
|||
switch (this.schedulerPhase) { |
|||
case SchedulerPhase.idle: |
|||
case SchedulerPhase.postFrameCallbacks: |
|||
this.scheduleFrame(); |
|||
return; |
|||
case SchedulerPhase.transientCallbacks: |
|||
case SchedulerPhase.midFrameMicrotasks: |
|||
case SchedulerPhase.persistentCallbacks: |
|||
return; |
|||
} |
|||
} |
|||
|
|||
public void scheduleFrame() { |
|||
if (this._hasScheduledFrame) { |
|||
return; |
|||
} |
|||
|
|||
this._window.scheduleFrame(); |
|||
this._hasScheduledFrame = true; |
|||
} |
|||
|
|||
public void scheduleForcedFrame() { |
|||
this.scheduleFrame(); |
|||
} |
|||
|
|||
public TimeSpan? _firstRawTimeStampInEpoch; |
|||
public TimeSpan _epochStart = TimeSpan.Zero; |
|||
public TimeSpan _lastRawTimeStamp = TimeSpan.Zero; |
|||
|
|||
public void resetEpoch() { |
|||
this._epochStart = this._adjustForEpoch(this._lastRawTimeStamp); |
|||
this._firstRawTimeStampInEpoch = null; |
|||
} |
|||
|
|||
public TimeSpan _adjustForEpoch(TimeSpan rawTimeStamp) { |
|||
var rawDurationSinceEpoch = this._firstRawTimeStampInEpoch == null |
|||
? TimeSpan.Zero |
|||
: rawTimeStamp - this._firstRawTimeStampInEpoch.Value; |
|||
return new TimeSpan((long) (rawDurationSinceEpoch.Ticks / this.timeDilation) + this._epochStart.Ticks); |
|||
} |
|||
|
|||
public TimeSpan currentFrameTimeStamp { |
|||
get { return this._currentFrameTimeStamp.Value; } |
|||
} |
|||
|
|||
public TimeSpan? _currentFrameTimeStamp; |
|||
|
|||
public void _handleBeginFrame(TimeSpan rawTimeStamp) { |
|||
this.handleBeginFrame(rawTimeStamp); |
|||
} |
|||
|
|||
public void _handleDrawFrame() { |
|||
this.handleDrawFrame(); |
|||
} |
|||
|
|||
public void handleBeginFrame(TimeSpan? rawTimeStamp) { |
|||
if (this._firstRawTimeStampInEpoch == null) { |
|||
this._firstRawTimeStampInEpoch = rawTimeStamp; |
|||
} |
|||
|
|||
this._currentFrameTimeStamp = this._adjustForEpoch(rawTimeStamp ?? this._lastRawTimeStamp); |
|||
|
|||
if (rawTimeStamp != null) { |
|||
this._lastRawTimeStamp = rawTimeStamp.Value; |
|||
} |
|||
|
|||
this._hasScheduledFrame = false; |
|||
|
|||
try { |
|||
this._schedulerPhase = SchedulerPhase.transientCallbacks; |
|||
var callbacks = this._transientCallbacks; |
|||
this._transientCallbacks = new Dictionary<int, _FrameCallbackEntry>(); |
|||
foreach (var entry in callbacks) { |
|||
if (!this._removedIds.Contains(entry.Key)) { |
|||
this._invokeFrameCallback(entry.Value.callback, this._currentFrameTimeStamp.Value); |
|||
} |
|||
} |
|||
|
|||
this._removedIds.Clear(); |
|||
} |
|||
finally { |
|||
this._schedulerPhase = SchedulerPhase.midFrameMicrotasks; |
|||
} |
|||
} |
|||
|
|||
public void _invokeFrameCallback(FrameCallback callback, TimeSpan timeStamp) { |
|||
try { |
|||
callback(timeStamp); |
|||
} |
|||
catch (Exception ex) { |
|||
Debug.LogError("error in frame callback: " + ex); |
|||
} |
|||
} |
|||
|
|||
public void handleDrawFrame() { |
|||
try { |
|||
this._schedulerPhase = SchedulerPhase.persistentCallbacks; |
|||
foreach (FrameCallback callback in this._persistentCallbacks) { |
|||
this._invokeFrameCallback(callback, this._currentFrameTimeStamp.Value); |
|||
} |
|||
|
|||
this._schedulerPhase = SchedulerPhase.postFrameCallbacks; |
|||
var localPostFrameCallbacks = new List<FrameCallback>(this._postFrameCallbacks); |
|||
this._postFrameCallbacks.Clear(); |
|||
foreach (FrameCallback callback in localPostFrameCallbacks) { |
|||
this._invokeFrameCallback(callback, this._currentFrameTimeStamp.Value); |
|||
} |
|||
} |
|||
finally { |
|||
this._schedulerPhase = SchedulerPhase.idle; |
|||
this._currentFrameTimeStamp = null; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6b74179dadff469cb8ee1f7b2ff51ae7 |
|||
timeCreated: 1534227207 |
撰写
预览
正在加载...
取消
保存
Reference in new issue