浏览代码

refine texture

/zxw-3d
xingweizhu 3 年前
当前提交
6be57ac2
共有 2 个文件被更改,包括 54 次插入5 次删除
  1. 40
      com.unity.uiwidgets/Runtime/rendering/texture.cs
  2. 19
      com.unity.uiwidgets/Runtime/widgets/texture.cs

40
com.unity.uiwidgets/Runtime/rendering/texture.cs


using System;
using Unity.UIWidgets.async;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;

public TextureBox(int textureId) {
public TextureBox(int? textureId, Texture texture) {
_texture = texture;
Texture _texture;
public int? textureId {
get { return _textureId; }

}
int? _textureId;
Timer _timer;
bool _frameCallbackScheduled;
protected override bool sizedByParent {
get { return true; }

return true;
}
void _scheduleAppFrame() {
if (_frameCallbackScheduled || textureId == null) {
return;
}
_frameCallbackScheduled = true;
SchedulerBinding.instance.scheduleFrameCallback(_handleAppFrame);
}
void _handleAppFrame(TimeSpan timestamp) {
_frameCallbackScheduled = false;
if (textureId == null) {
return;
}
TimeSpan delay = TimeSpan.Zero;
delay = new TimeSpan((long) (delay.Ticks * scheduler_.timeDilation));
_timer = Timer.create(delay, () => _scheduleAppFrame());
}
if (_texture != null) {
markNeedsLayout();
SchedulerBinding.instance.scheduleFrameCallback(_handleAppFrame);
if (_texture.GetNativeTexturePtr() != IntPtr.Zero) {
_textureId = UIWidgetsPanelWrapper.current.registerTexture(_texture);
}
}
_scheduleAppFrame();
context.addLayer(new TextureLayer(
rect: Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height),
textureId: _textureId.Value

19
com.unity.uiwidgets/Runtime/widgets/texture.cs


using System;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;

public Texture(
Key key = null,
UnityEngine.Texture texture = null,
D.assert(textureId != null);
this.textureId = textureId.Value;
this.textureId = textureId;
this.texture = texture;
if (texture != null && texture.GetNativeTexturePtr() != IntPtr.Zero) {
this.textureId = UIWidgetsPanelWrapper.current.registerTexture(texture);
}
public readonly int textureId;
public readonly int? textureId;
public readonly UnityEngine.Texture texture;
return new TextureBox(textureId: textureId);
return new TextureBox(textureId: textureId, texture: texture);
}
public override bool Equals(object obj) {
return false;
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {

正在加载...
取消
保存