void RmImg(RmImgCmd cmd) { #if FDB if (cmd.id >= 0) { Should.True("nodeIdxDict.ContainsKey(cmd.id)", PtrIntDict.Contains(nodeDict, cmd.id)); } #endif if (cmd.id < 0) { nodeTouchHandlerDict.Clear(); PtrIntDict.Clear(nodeDict); PtrLst.Clear(spritePtrLst); Pool.Clear(spritePool); } else { if (nodeTouchHandlerDict.ContainsKey(cmd.id)) { nodeTouchHandlerDict.Remove(cmd.id); } void *node = PtrIntDict.Remove(nodeDict, cmd.id); PtrLst.Remove(spritePtrLst, node); Pool.Free(spritePool, node); } }
void AddImg(AddImgCmd cmd) { #if FDB Should.False("nodeIdxDict.ContainsKey(cmd.id)", PtrIntDict.Contains(nodeDict, cmd.id)); Should.True("Res.HasSpriteMeta(cmd.imgId)", Res.HasSpriteMeta(cmd.imgId)); #endif var node = (TpSprite *)Pool.Alloc(spritePool, sizeof(TpSprite)); TpSprite.Init(node, Res.GetSpriteMeta(cmd.imgId)); node->id = cmd.id; if (spritePool->shift != 0) { PtrLst.ShiftBase(spritePtrLst, spritePool->shift); PtrIntDict.ShiftBase(nodeDict, spritePool->shift); foreach (var esJob in esJobList) { if (esJob is EsImgJob) { var esTpSpriteJob = (EsImgJob)esJob; esTpSpriteJob.node = (TpSprite *)((byte *)esTpSpriteJob.node + spritePool->shift); } } needDepthSort = true; spritePool->shift = 0; } PtrLst.Push(spritePtrLst, node); PtrIntDict.Set(nodeDict, cmd.id, node); }
public void Dispose() { cmdQueue.Clear(); esJobList.Clear(); PtrIntDict.Decon(nodeDict); Mem.Free(nodeDict); nodeDict = null; Pool.Decon(spritePool); Mem.Free(spritePool); spritePool = null; PtrLst.Decon(spritePtrLst); Mem.Free(spritePtrLst); spritePtrLst = null; DrawCtx.Dispose(); Debug.Log("Clean up GPC"); }
public static void LoadAtlases(params int[] ids) { for (int i = 0, len = ids.Length; i < len; i += 1) { int id = ids[i]; var atlasMeta = TpAtlasMeta.New(Resources.Load <TextAsset>(id.ToString()).text); PtrLst.Push(atlasMetaLst, atlasMeta); for (int j = 0, jlen = atlasMeta->spriteCount; j < jlen; j += 1) { var spriteMeta = atlasMeta->sprites + j; PtrIntDict.Set(spriteMetaDict, spriteMeta->name, spriteMeta); // spriteMetaLstIdxDict[spriteMeta->name] = spriteMetaLst->count; // PtrLst.Push(spriteMetaLst, spriteMeta); } } }
public static void Test() { #if UNITY_EDITOR System.Reflection.Assembly .GetAssembly(typeof(UnityEditor.SceneView)) .GetType("UnityEditor.LogEntries") .GetMethod("Clear") .Invoke(new object(), null); #endif var sw = new System.Diagnostics.Stopwatch(); sw.Stop(); sw.Reset(); sw.Start(); Mem.Test(); Log("Mem test: {0:N0}", sw.ElapsedTicks); sw.Reset(); sw.Start(); Algo.Test(); Log("Algo test: {0:N0}", sw.ElapsedTicks); sw.Reset(); sw.Start(); Pool.Test(); Log("Pool2 test: {0:N0}", sw.ElapsedTicks); sw.Reset(); sw.Start(); PtrLst.Test(); Log("PtrLst2 test: {0:N0}", sw.ElapsedTicks); sw.Reset(); sw.Start(); PtrIntDict.Test(); Log("NumDict test: {0:N0}", sw.ElapsedTicks); sw.Reset(); sw.Start(); }
public static void ReleaseAtlases(params int[] ids) { for (int i = 0, len = ids.Length; i < len; i += 1) { int id = ids[i]; var atlasMeta = (TpAtlasMeta *)atlasMetaLst->arr[i]; if (atlasMeta->name == id) { ReleaseTexture(id); for (int j = 0, jlen = atlasMeta->spriteCount; j < jlen; j += 1) { var spriteMeta = atlasMeta->sprites + j; PtrIntDict.Remove(spriteMetaDict, spriteMeta->name); } TpAtlasMeta.Decon(atlasMeta); Mem.Free(atlasMeta); PtrLst.RemoveAt(atlasMetaLst, i); i -= 1; } } }