浏览代码

composite context => using ui-version objects (more)

/main
xingwei.zhu 5 年前
当前提交
8b30a2e4
共有 6 个文件被更改,包括 39 次插入30 次删除
  1. 2
      Runtime/ui/utils/renderer/allocUtils/pool_items.cs
  2. 1
      Runtime/ui/utils/renderer/cmdbufferCanvas/command_buffer_canvas.cs
  3. 8
      Runtime/ui/utils/renderer/cmdbufferCanvas/rendering/canvas_impl.cs
  4. 45
      Runtime/ui/utils/renderer/common/picture.cs
  5. 5
      Runtime/ui/utils/renderer/geometry/path/path.cs
  6. 8
      Runtime/flow.meta

2
Runtime/ui/utils/renderer/allocUtils/pool_items.cs


static readonly Dictionary<Type, List<PoolItem>> poolDict = new Dictionary<Type, List<PoolItem>>();
static readonly Dictionary<Type, ItemDebugInfo> debugInfo = new Dictionary<Type, ItemDebugInfo>();
const bool _debugFlag = false;
const bool _debugFlag = true;
static int _allocTick = 0;

1
Runtime/ui/utils/renderer/cmdbufferCanvas/command_buffer_canvas.cs


var picture = this._recorder.endRecording();
this._flusher.flush(picture);
this._recorder.reset();
picture.dispose();
}
public void dispose() {

8
Runtime/ui/utils/renderer/cmdbufferCanvas/rendering/canvas_impl.cs


var path = uiPath.create();
path.addRect(uiRectHelper.fromRect(rect));
this._clipPath(path);
path.dispose();
}
void _clipUIRect(uiRect rect) {

path.dispose();
}
void _clipRRect(RRect rrect) {

path.dispose();
}
void _clipPath(uiPath path) {

path.dispose();
}
void _tryAddScissor(RenderLayer layer, uiRect? scissor) {

if (paint.style == PaintingStyle.fill) {
var state = this._currentLayer.currentState;
var cache = path.flatten(state.scale * this._devicePixelRatio);
path.dispose();
bool convex;
var fillMesh = cache.getFillMesh(out convex);

}
var cache = path.flatten(state.scale * this._devicePixelRatio);
path.dispose();
var strokenMesh = cache.getStrokeMesh(
strokeWidth / state.scale * 0.5f,

case DrawClipPath cmd: {
var uipath = uiPath.fromPath(cmd.path);
this._clipPath(uipath);
uipath.dispose();
uipath.dispose();
break;
}
case DrawImage cmd: {

45
Runtime/ui/utils/renderer/common/picture.cs


namespace Unity.UIWidgets.ui {
public class uiPicture {
public uiPicture(List<uiDrawCmd> drawCmds, uiRect paintBounds) {
this.drawCmds = drawCmds;
this.paintBounds = paintBounds;
public class uiPicture : PoolItem {
public uiPicture() {
}
public static uiPicture create(List<uiDrawCmd> drawCmds, uiRect paintBounds) {
var picture = ItemPoolManager.alloc<uiPicture>();
picture.drawCmds = drawCmds;
picture.paintBounds = paintBounds;
return picture;
public readonly List<uiDrawCmd> drawCmds;
public readonly uiRect paintBounds;
public List<uiDrawCmd> drawCmds;
public uiRect paintBounds;
public override void clear() {
//the recorder will dispose the draw commands
this.drawCmds = null;
}
readonly List<uiDrawCmd> _drawCmds = new List<uiDrawCmd>();
readonly List<uiDrawCmd> _drawCmds = new List<uiDrawCmd>(128);
readonly List<uiCanvasState> _states = new List<uiCanvasState>();
readonly List<uiCanvasState> _states = new List<uiCanvasState>(32);
public uiPictureRecorder() {
this.reset();

}
public void reset() {
foreach (var drawCmd in this._drawCmds) {
drawCmd.dispose();
}
this._drawCmds.Clear();
this._states.Clear();
this._states.Add(new uiCanvasState {

}
var state = this._getState();
return new uiPicture(this._drawCmds, state.paintBounds);
return uiPicture.create(this._drawCmds, state.paintBounds);
}
public void addDrawCmd(uiDrawCmd drawCmd) {

uiMeshMesh mesh;
if (paint.style == PaintingStyle.fill) {
var cache = path.flatten(scale * devicePixelRatio);
mesh = cache.getFillMesh(out _).transform(state.xform);
var fillMesh = cache.getFillMesh(out _);
mesh = fillMesh.transform(state.xform);
fillMesh.dispose();
cache.dispose();
} else {
float strokeWidth = (paint.strokeWidth * scale).clamp(0, 200.0f);

} else {
this._addPaintBounds(mesh.bounds);
}
mesh.dispose();
break;
}
case uiDrawImage cmd: {

}
}
class uiCanvasState {
struct uiCanvasState {
public uiMatrix3 xform;
public uiRect? scissor;
public bool saveLayer;

public uiCanvasState copy() {
return new uiCanvasState {
return new uiCanvasState{
paintBounds = this.paintBounds,
paintBounds = this.paintBounds
};
}
}

5
Runtime/ui/utils/renderer/geometry/path/path.cs


using System;
using System.Collections.Generic;
using System.Text;
using Vector2 = UnityEngine.Vector2;
using Vector3 = UnityEngine.Vector3;
namespace Unity.UIWidgets.ui {
public class uiPath : PoolItem {

8
Runtime/flow.meta


fileFormatVersion: 2
guid: e1056a6e2b8247cbaf7db24691b913ec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存