public BitmapCacheItem this[Fragment f] { get { if (IsCached(f)) { return fragmentsWithCache[f]; } else { return null; } } }
public void ExtendRoot() { Fragment newRoot = new Fragment(root.Depth - 1); newRoot.MakeChilds(); newRoot.ChildLT.ChildRB = Root.ChildLT; newRoot.ChildRT.ChildLB = Root.ChildRT; newRoot.ChildLB.ChildRT = Root.ChildLB; newRoot.ChildRB.ChildLT = Root.ChildRB; root = newRoot; size *= 2; }
public BitmapCacheItem AllocateCache(Fragment f) { if (IsCached(f)) { return fragmentsWithCache[f]; } else { // Take item from head and put it at tail BitmapCacheItem item = caches.First.Value; caches.RemoveFirst(); caches.AddLast(item); // Allocate the item to freagment if (item.Owner != null) { ReleaseCache(item.Owner); } item.Owner = f; fragmentsWithCache[f] = item; return item; } }
BitmapCacheItem UpdateBitmap(Fragment f) { if (bitmapCache.IsCached(f)) { return bitmapCache[f]; } else { BitmapCacheItem c = bitmapCache.AllocateCache(f); UpdateTexture(c.Texture, c.X, c.Y, f.MakeImage(fractal.ColorMap)); return c; } }
public void MakeChilds() { if (!HasAllChilds) { childLT = new Fragment(depth + 1); childRT = new Fragment(depth + 1); childLB = new Fragment(depth + 1); childRB = new Fragment(depth + 1); } }
public void ReleaseCache(Fragment f) { if (IsCached(f)) { fragmentsWithCache[f].Owner = null; fragmentsWithCache.Remove(f); } }
public bool IsCached(Fragment f) { return fragmentsWithCache.ContainsKey(f); }