public Texture2d Get(DisplaySurface ds) { using (var bb = new BitmapBuffer(ds.PeekBitmap(), new BitmapLoadOptions())) { return(Get(bb)); } }
public Texture2d Get(DisplaySurface ds) { using (var bb = new BitmapBuffer(ds.PeekBitmap(), new BitmapLoadOptions())) { return Get(bb); } }
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) { } } }
public void DrawFinish() { if (_GUISurface != null) { GlobalWin.DisplayManager.UnlockLuaSurface(_GUISurface); } _GUISurface = null; }
/// <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; } }
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); }
/// <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; } }
public void DrawNew(string name, bool clear) { try { DrawFinish(); _GUISurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear); } catch (InvalidOperationException ex) { LogCallback(ex.ToString()); } }
public void DrawNew(string name, bool?clear = true) { try { DrawFinish(); _GUISurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear ?? true); } catch (InvalidOperationException ex) { Console.WriteLine(ex.ToString()); } }
/// <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; }
/// <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); }
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); }
/// <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); }
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) { } } }
/// <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; }
public void ReleaseSurface(DisplaySurface surface) { lock (this) ReleasedSurfaces.Enqueue(surface); }
public void ReleaseSurface(DisplaySurface surface) { lock (this) _releasedSurfaces.Enqueue(surface); }
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; }
public void SetLuaSurfaceNativePreOSD(DisplaySurface surface) { luaNativeSurfaceSet.SetPending(surface); }
public void DrawFinish() { if(_luaSurface != null) GlobalWin.DisplayManager.UnlockLuaSurface(_luaSurface); _luaSurface = null; }
/// <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); }
public void SetLuaSurfaceNativePreOSD(DisplaySurface surface) { luaNativeSurfaceSet.SetPending(surface); }
public void DrawNew(string name) { try { DrawFinish(); _luaSurface = GlobalWin.DisplayManager.LockLuaSurface(name); } catch (InvalidOperationException ex) { Log(ex.ToString()); } }