Exemplo n.º 1
0
 public Texture2d Get(DisplaySurface ds)
 {
     using (var bb = new BitmapBuffer(ds.PeekBitmap(), new BitmapLoadOptions()))
     {
         return(Get(bb));
     }
 }
Exemplo n.º 2
0
		public Texture2d Get(DisplaySurface ds)
		{
			using (var bb = new BitmapBuffer(ds.PeekBitmap(), new BitmapLoadOptions()))
			{
				return Get(bb);
			}
		}
Exemplo n.º 3
0
 public void ClearLuaSurfaces()
 {
     foreach (var kvp in LuaSurfaceSets)
     {
         try
         {
             var            surf       = PeekLockedLuaSurface(kvp.Key);
             DisplaySurface surfLocked = null;
             if (surf == null)
             {
                 surf = surfLocked = LockLuaSurface(kvp.Key, true);
             }
             //zero 21-apr-2016 - we shouldnt need this
             //surf.Clear();
             if (surfLocked != null)
             {
                 UnlockLuaSurface(surfLocked);
             }
             LuaSurfaceSets[kvp.Key].SetPending(null);
         }
         catch (InvalidOperationException)
         {
         }
     }
 }
Exemplo n.º 4
0
 public void DrawFinish()
 {
     if (_GUISurface != null)
     {
         GlobalWin.DisplayManager.UnlockLuaSurface(_GUISurface);
     }
     _GUISurface = null;
 }
Exemplo n.º 5
0
		/// <summary>
		/// sets the provided buffer as pending. takes control of the supplied buffer
		/// </summary>
		public void SetPending(DisplaySurface newPending)
		{
			lock (this)
			{
				if (Pending != null) ReleasedSurfaces.Enqueue(Pending);
				Pending = newPending;
				IsPending = true;
			}
		}
Exemplo n.º 6
0
        public static DisplaySurface DisplaySurfaceWrappingBitmap(Bitmap bmp)
        {
            DisplaySurface ret = new DisplaySurface();

            ret.Width    = bmp.Width;
            ret.Height   = bmp.Height;
            ret.bmp      = bmp;
            ret.isBitmap = true;
            return(ret);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Unlocks this DisplaySurface which had better have been locked as a lua surface
        /// </summary>
        public void UnlockLuaSurface(DisplaySurface surface)
        {
            if (!MapLuaSurfaceToName.ContainsKey(surface))
            {
                throw new InvalidOperationException("Surface was not locked as a lua surface");
            }
            string name = MapLuaSurfaceToName[surface];

            MapLuaSurfaceToName.Remove(surface);
            MapNameToLuaSurface.Remove(name);
            LuaSurfaceSets[name].SetPending(surface);
        }
 /// <summary>
 /// sets the provided buffer as pending. takes control of the supplied buffer
 /// </summary>
 public void SetPending(DisplaySurface newPending)
 {
     lock (this)
     {
         if (_pending != null)
         {
             _releasedSurfaces.Enqueue(_pending);
         }
         _pending   = newPending;
         _isPending = true;
     }
 }
 /// <summary>
 /// sets the provided buffer as pending. takes control of the supplied buffer
 /// </summary>
 public void SetPending(DisplaySurface newPending)
 {
     lock (this)
     {
         if (Pending != null)
         {
             ReleasedSurfaces.Enqueue(Pending);
         }
         Pending   = newPending;
         IsPending = true;
     }
 }
Exemplo n.º 10
0
 public void DrawNew(string name, bool clear)
 {
     try
     {
         DrawFinish();
         _GUISurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear);
     }
     catch (InvalidOperationException ex)
     {
         LogCallback(ex.ToString());
     }
 }
Exemplo n.º 11
0
 public void DrawNew(string name, bool?clear = true)
 {
     try
     {
         DrawFinish();
         _GUISurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear ?? true);
     }
     catch (InvalidOperationException ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Exemplo n.º 12
0
		/// <summary>
		/// returns the current buffer, making the most recent pending buffer (if there is such) as the new current first.
		/// </summary>
		public DisplaySurface GetCurrent()
		{
			lock (this)
			{
				if (IsPending)
				{
					if (Current != null) ReleasedSurfaces.Enqueue(Current);
					Current = Pending;
					Pending = null;
					IsPending = false;
				}
			}
			return Current;
		}
Exemplo n.º 13
0
        /// <summary>
        /// Locks the requested lua surface name
        /// </summary>
        public DisplaySurface LockLuaSurface(string name, bool clear = true)
        {
            if (MapNameToLuaSurface.ContainsKey(name))
            {
                throw new InvalidOperationException($"Lua surface is already locked: {name}");
            }

            SwappableDisplaySurfaceSet sdss;

            if (!LuaSurfaceSets.TryGetValue(name, out sdss))
            {
                sdss = new SwappableDisplaySurfaceSet();
                LuaSurfaceSets.Add(name, sdss);
            }

            //placeholder logic for more abstracted surface definitions from filter chain
            int currNativeWidth  = presentationPanel.NativeSize.Width;
            int currNativeHeight = presentationPanel.NativeSize.Height;

            currNativeWidth  += ClientExtraPadding.Horizontal;
            currNativeHeight += ClientExtraPadding.Vertical;

            int width, height;

            if (name == "emu")
            {
                width   = currEmuWidth;
                height  = currEmuHeight;
                width  += GameExtraPadding.Horizontal;
                height += GameExtraPadding.Vertical;
            }
            else if (name == "native")
            {
                width = currNativeWidth; height = currNativeHeight;
            }
            else
            {
                throw new InvalidOperationException($"Unknown lua surface name: {name}");
            }

            DisplaySurface ret = sdss.AllocateSurface(width, height, clear);

            MapNameToLuaSurface[name] = ret;
            MapLuaSurfaceToName[ret]  = name;
            return(ret);
        }
 /// <summary>
 /// returns the current buffer, making the most recent pending buffer (if there is such) as the new current first.
 /// </summary>
 public DisplaySurface GetCurrent()
 {
     lock (this)
     {
         if (IsPending)
         {
             if (Current != null)
             {
                 ReleasedSurfaces.Enqueue(Current);
             }
             Current   = Pending;
             Pending   = null;
             IsPending = false;
         }
     }
     return(Current);
 }
Exemplo n.º 15
0
 public void ClearLuaSurfaces()
 {
     foreach (var kvp in LuaSurfaceSets)
     {
         var            surf       = PeekLockedLuaSurface(kvp.Key);
         DisplaySurface surfLocked = null;
         if (surf == null)
         {
             surf = surfLocked = LockLuaSurface(kvp.Key);
         }
         surf.Clear();
         if (surfLocked != null)
         {
             UnlockLuaSurface(surfLocked);
         }
         LuaSurfaceSets[kvp.Key].SetPending(null);
     }
 }
        /// <summary>
        /// returns the current buffer, making the most recent pending buffer (if there is such) as the new current first.
        /// </summary>
        public DisplaySurface GetCurrent()
        {
            lock (this)
            {
                if (_isPending)
                {
                    if (_current != null)
                    {
                        _releasedSurfaces.Enqueue(_current);
                    }
                    _current   = _pending;
                    _pending   = null;
                    _isPending = false;
                }
            }

            return(_current);
        }
Exemplo n.º 17
0
        /// <summary>
        /// returns a new surface
        /// </summary>
        /// <param name="xpad"></param>
        /// <param name="ypad"></param>
        /// <returns></returns>
        public DisplaySurface ToPaddedSurface(int xpad0, int ypad0, int xpad1, int ypad1)
        {
            int            new_width  = Width + xpad0 + xpad1;
            int            new_height = Height + ypad0 + ypad1;
            DisplaySurface ret        = new DisplaySurface(new_width, new_height);
            int *          dptr       = ret.PixelPtr;
            int *          sptr       = PixelPtr;
            int            dstride    = ret.Stride / 4;
            int            sstride    = Stride / 4;

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    dptr[(y + ypad0) * dstride + x + xpad0] = sptr[y * sstride + x];
                }
            }
            return(ret);
        }
Exemplo n.º 18
0
 public void ClearLuaSurfaces()
 {
     foreach (var kvp in LuaSurfaceSets)
     {
         try
         {
             var            surf       = PeekLockedLuaSurface(kvp.Key);
             DisplaySurface surfLocked = null;
             if (surf == null)
             {
                 surf = surfLocked = LockLuaSurface(kvp.Key);
             }
             surf.Clear();
             if (surfLocked != null)
             {
                 UnlockLuaSurface(surfLocked);
             }
             LuaSurfaceSets[kvp.Key].SetPending(null);
         }
         catch (InvalidOperationException)
         {
         }
     }
 }
Exemplo n.º 19
0
		/// <summary>
		/// returns a new surface 
		/// </summary>
		/// <param name="xpad"></param>
		/// <param name="ypad"></param>
		/// <returns></returns>
		public DisplaySurface ToPaddedSurface(int xpad0, int ypad0, int xpad1, int ypad1)
		{
			int new_width = Width + xpad0 + xpad1;
			int new_height = Height + ypad0 + ypad1;
			DisplaySurface ret = new DisplaySurface(new_width, new_height);
			int* dptr = ret.PixelPtr;
			int* sptr = PixelPtr;
			int dstride = ret.Stride / 4;
			int sstride = Stride / 4;
			for (int y = 0; y < Height; y++)
				for (int x = 0; x < Width; x++)
				{
					dptr[(y + ypad0) * dstride + x + xpad0] = sptr[y * sstride + x];
				}
			return ret;

		}
Exemplo n.º 20
0
		public void ReleaseSurface(DisplaySurface surface)
		{
			lock (this) ReleasedSurfaces.Enqueue(surface);
		}
 public void ReleaseSurface(DisplaySurface surface)
 {
     lock (this) _releasedSurfaces.Enqueue(surface);
 }
Exemplo n.º 22
0
		public static DisplaySurface DisplaySurfaceWrappingBitmap(Bitmap bmp)
		{
			DisplaySurface ret = new DisplaySurface();
			ret.Width = bmp.Width;
			ret.Height = bmp.Height;
			ret.bmp = bmp;
			ret.isBitmap = true;
			return ret;
		}
Exemplo n.º 23
0
 public void SetLuaSurfaceNativePreOSD(DisplaySurface surface)
 {
     luaNativeSurfaceSet.SetPending(surface);
 }
Exemplo n.º 24
0
 public void DrawFinish()
 {
     if(_luaSurface != null)
         GlobalWin.DisplayManager.UnlockLuaSurface(_luaSurface);
     _luaSurface = null;
 }
Exemplo n.º 25
0
		/// <summary>
		/// Unlocks this DisplaySurface which had better have been locked as a lua surface
		/// </summary>
		public void UnlockLuaSurface(DisplaySurface surface)
		{
			if (!MapLuaSurfaceToName.ContainsKey(surface))
				throw new InvalidOperationException("Surface was not locked as a lua surface");
			string name = MapLuaSurfaceToName[surface];
			MapLuaSurfaceToName.Remove(surface);
			MapNameToLuaSurface.Remove(name);
			LuaSurfaceSets[name].SetPending(surface);
		}
Exemplo n.º 26
0
		public void SetLuaSurfaceNativePreOSD(DisplaySurface surface) { luaNativeSurfaceSet.SetPending(surface); }
Exemplo n.º 27
0
 public void DrawNew(string name)
 {
     try
     {
         DrawFinish();
         _luaSurface = GlobalWin.DisplayManager.LockLuaSurface(name);
     }
     catch (InvalidOperationException ex)
     {
         Log(ex.ToString());
     }
 }