using CommonLang.Concurrent; using System; using System.Collections.Generic; namespace CommonUI.Display { // ------------------------------------------------------------------------------------------ // -by zhangyifei // ------------------------------------------------------------------------------------------ public abstract class Image : IDisposable { private static AtomicLong s_RefCount = new AtomicLong(0); private static AtomicLong s_AliveCount = new AtomicLong(0); public static long RefCount { get { return s_RefCount.Value; } } public static long AliveCount { get { return s_AliveCount.Value; } } private bool m_disposed = false; protected Image() { s_RefCount++; s_AliveCount++; } ~Image() { s_RefCount--; } public void Dispose() { if (m_disposed) { return; } Disposing(); m_disposed = true; s_AliveCount--; } public virtual void ReleaseTexture() { } protected abstract void Disposing(); public string name = "Image"; public virtual int Width { get { return 0; } } public virtual int Height { get { return 0; } } public virtual float MaxU { get { return 0; } } public virtual float MaxV { get { return 0; } } /// /// 从原图片复制像素到当前图片 /// /// /// /// /// /// /// /// public abstract void CopyPixels(Image srci, int sx, int sy, int sw, int sh, int dx, int dy); /// /// 复制完像素后刷新缓冲区 /// public abstract void Flush(); // #region Count // private static List mReferenceList = new List(); // public static string DumpImageList() // { // string sout = string.Empty; // // for(int i = mReferenceList.Count - 1; i >= 0; --i) // { // sout += ((Image)mReferenceList[i]).name; // sout += "\r\n"; // } // // return sout; // } // #endregion } public struct TImageRegion { public Image image; public float sx, sy, sw, sh; } }