Implement blending enable/disable for IGL_GDIPlus (more just moving it away from GDIPlusGuiRenderer)

Fix GDI+ used for display method (got broken in some cleanup commits ago)
Remove some things meant to be removed in the last commit (fixes debug build)
This commit is contained in:
CasualPokePlayer 2023-08-22 17:16:48 -07:00
parent 8c1d996b80
commit 53563657fe
5 changed files with 27 additions and 40 deletions

View File

@ -1,6 +0,0 @@
namespace BizHawk.Bizware.BizwareGL
{
public interface IBlendState
{
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Numerics;
@ -39,12 +40,16 @@ namespace BizHawk.Bizware.Graphics
public void EnableBlending()
{
// TODO for real
var g = GetCurrentGraphics();
g.CompositingMode = CompositingMode.SourceOver;
g.CompositingQuality = CompositingQuality.Default;
}
public void DisableBlending()
{
// TODO for real
var g = GetCurrentGraphics();
g.CompositingMode = CompositingMode.SourceCopy;
g.CompositingQuality = CompositingQuality.HighSpeed;
}
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required, string memo)

View File

@ -95,13 +95,15 @@ namespace BizHawk.Bizware.Graphics
CurrentImageAttributes.SetColorMatrix(colorMatrix,ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
}
private bool _enableBlending;
public void EnableBlending()
=> _enableBlending = true;
{
Owner.EnableBlending();
}
public void DisableBlending()
=> _enableBlending = false;
{
Owner.DisableBlending();
}
private MatrixStack _Projection, _Modelview;
@ -133,7 +135,7 @@ namespace BizHawk.Bizware.Graphics
public void Begin(int width, int height)
{
Begin();
Projection = Owner.CreateGuiProjectionMatrix(width, height);
Modelview = Owner.CreateGuiViewMatrix(width, height);
}
@ -142,11 +144,12 @@ namespace BizHawk.Bizware.Graphics
{
// uhhmmm I want to throw an exception if its already active, but its annoying.
IsActive = true;
_enableBlending = false;
Owner.DisableBlending();
CurrentImageAttributes?.Dispose();
CurrentImageAttributes = new();
Modelview.Clear();
Projection.Clear();
Modelview?.Clear();
Projection?.Clear();
}
public void Flush()
@ -187,8 +190,8 @@ namespace BizHawk.Bizware.Graphics
PointF[] destPoints =
{
new(x, y),
new(x+w, y),
new(x, y+h),
new(x + w, y),
new(x, y + h),
};
g.DrawImage(gtex.SDBitmap, destPoints, new(x0, y0, x1 - x0, y1 - y0), GraphicsUnit.Pixel, CurrentImageAttributes);
@ -208,7 +211,7 @@ namespace BizHawk.Bizware.Graphics
DrawInternal(art, x, y, width, height);
}
private void PrepDraw(SDGraphics g, Texture2d tex)
private static void PrepDraw(SDGraphics g, Texture2d tex)
{
var tw = (GDIPlusTexture)tex.Opaque;
@ -224,21 +227,6 @@ namespace BizHawk.Bizware.Graphics
TextureMagFilter.Nearest => InterpolationMode.NearestNeighbor,
_ => g.InterpolationMode
};
if (_enableBlending)
{
g.CompositingMode = CompositingMode.SourceOver;
g.CompositingQuality = CompositingQuality.Default; // ?
}
else
{
g.CompositingMode = CompositingMode.SourceCopy;
g.CompositingQuality = CompositingQuality.HighSpeed;
// WARNING : DO NOT USE COLOR MATRIX TO WIPE THE ALPHA
// ITS SOOOOOOOOOOOOOOOOOOOOOOOOOOOO SLOW
// instead, we added kind of hacky support for 24bpp images
}
}
private void SetupMatrix(SDGraphics g)

View File

@ -361,9 +361,6 @@ namespace BizHawk.Bizware.Graphics
pData[31] = CornerColors[3].W;
Owner.Draw(new(pData), 4);
#if DEBUG
Debug.Assert(BlendStateSet);
#endif
}
private void DrawSubrectInternal(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1)
@ -381,9 +378,6 @@ namespace BizHawk.Bizware.Graphics
// state cache
private Texture2d sTexture;
#if DEBUG
private bool BlendStateSet;
#endif
// shaders are hand-coded for each platform to make sure they stay as fast as possible

View File

@ -45,6 +45,12 @@ namespace BizHawk.Client.Common.Filters
Passes = preset.Passes.ToArray();
Errors = string.Empty;
if (owner.API is not ("OPENGL" or "D3D9"))
{
Errors = $"Unsupported API {owner.API}";
return;
}
// load up the shaders
var shaders = new RetroShader[preset.Passes.Count];
for (var i = 0; i < preset.Passes.Count; i++)