浏览代码

fix minor bugs

adjust folder structure (move renderer out of utils)
/main
xingwei.zhu 5 年前
当前提交
2ef8478c
共有 6 个文件被更改,包括 21 次插入14 次删除
  1. 3
      Runtime/ui/painting/txt/mesh_generator.cs
  2. 14
      Runtime/ui/renderer/allocator/pool_object.cs
  3. 18
      Runtime/ui/renderer/allocator/debug.cs
  4. 0
      /Runtime/ui/renderer
  5. 0
      /Runtime/ui/renderer/allocator

3
Runtime/ui/painting/txt/mesh_generator.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using UnityEngine;

ObjectPool<uiList<Vector3>>.release(vertices);
ObjectPool<uiList<Vector2>>.release(uv);
ObjectPool<uiList<int>>.release(triangles);
ObjectPool<MeshKey>.release(key);
return null;
}

14
Runtime/ui/renderer/allocator/pool_object.cs


public static class ObjectPool<TObject> where TObject :PoolObject, new() {
static readonly Stack<TObject> pool = new Stack<TObject>();
static int allocatedCount = 0;
public static TObject alloc() {
if (pool.Count == 0) {

}
allocatedCount += 128;
}
var ret = pool.Pop();

AllocDebugger.onAlloc(debugKey, debugName);
AllocDebugger.onAlloc(debugKey, debugName, allocatedCount);
ret.activated_flag = true;
}

}
obj.activated_flag = false;
AllocDebugger.onRelease(debugKey, debugName);
AllocDebugger.onRelease(debugKey, debugName, allocatedCount);
obj.clear();
allocatedCount--;
obj.clear();
pool.Push(obj);
}

18
Runtime/ui/renderer/allocator/debug.cs


public int watermark;
public int prev_watermark;
public int borrowed;
public int allocated;
public void onAlloc() {
public void onAlloc(int allocatedCount) {
this.allocated = allocatedCount;
public void onRelease() {
public void onRelease(int allocatedCount) {
this.allocated = allocatedCount;
}
}

}
}
public static void onAlloc(int objKey, string objName) {
public static void onAlloc(int objKey, string objName, int allocatedCount) {
borrowed = 0
borrowed = 0,
allocated = 0
debugInfos[objKey].onAlloc();
debugInfos[objKey].onAlloc(allocatedCount);
public static void onRelease(int objKey, string objName) {
public static void onRelease(int objKey, string objName, int allocatedCount) {
debugInfos[objKey].onRelease();
debugInfos[objKey].onRelease(allocatedCount);
}
}
}

/Runtime/ui/utils/renderer → /Runtime/ui/renderer

/Runtime/ui/renderer/allocUtils → /Runtime/ui/renderer/allocator

正在加载...
取消
保存