using System; using System.IO; using CommonUI.Gemo; namespace CommonUI.Display { // ------------------------------------------------------------------------------------------ // -by zhangyifei // ------------------------------------------------------------------------------------------ public abstract class Driver { //------------------------------------------------------------------ private static Driver s_instance = null; public static Driver Instance { get { return s_instance; } } protected Driver() { s_instance = this; } //------------------------------------------------------------------ #region _Graphics_ abstract public Image createImage(String resource); abstract public void ReloadImage(Image img); abstract public Image createImage(Stream stream); abstract public Image createImage(byte[] imageData, int imageOffset, int imageLength); abstract public Image createRGBImage(uint[] rgba, int width, int height); virtual public Image createRGBImage(int width, int height) { uint[] rgba = new uint[width * height]; return this.createRGBImage(rgba, width, height); } abstract public TextLayer createTextLayer(string text, float size, FontStyle style); /// /// 测试文本是否换行 /// /// /// /// /// /// 测试宽度 /// [out]实际宽度 /// [out]实际高度 /// abstract public bool testTextLineBreak(string text, float size, FontStyle style, int borderTime, float testWidth, out float realWidth, out float realHeight); /// /// 创建定点缓冲区 /// /// /// abstract public VertexBuffer createVertexBuffer(int capacity); abstract public void Assert(bool cond, string msg); /// /// 检测是否为表情符号 /// /// /// /// 表情符号所占长度 /// public virtual bool IsEmoji(string text, int i, out int len) { if (i + 1 < text.Length) { int c0 = text[i]; int c1 = text[i + 1]; if (c0 >= 0xD800 && c0 <= 0xDBFF) { len = 2; return true; } } len = 1; return false; } #endregion //------------------------------------------------------------------ } }