Skip to content

Commit

Permalink
inline OnPresentationChanged (#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkast authored May 22, 2024
1 parent 492bac9 commit d6c6f9b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 31 deletions.
5 changes: 4 additions & 1 deletion MonoGame.Framework/.Blazor/ConcreteGraphicsDeviceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ public override void CreateDevice()
gameWindow.EnterFullScreen(pp);

if (!pp.HardwareModeSwitch)
((IPlatformGraphicsDevice)this.GraphicsDevice).Strategy.ToConcrete<ConcreteGraphicsDevice>().OnPresentationChanged();
{
ConcreteGraphicsDevice cgd = ((IPlatformGraphicsDevice)this.GraphicsDevice).Strategy.ToConcrete<ConcreteGraphicsDevice>();
((IPlatformGraphicsContext)cgd.MainContext).Strategy.ApplyRenderTargets(null);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ public override void CreateDevice()
gameWindow.EnterFullScreen(pp);

if (!pp.HardwareModeSwitch)
((IPlatformGraphicsDevice)this.GraphicsDevice).Strategy.ToConcrete<ConcreteGraphicsDevice>().OnPresentationChanged();
{
ConcreteGraphicsDevice cgd = ((IPlatformGraphicsDevice)this.GraphicsDevice).Strategy.ToConcrete<ConcreteGraphicsDevice>();
cgd.Internal_CreateSizeDependentResources();
((IPlatformGraphicsContext)cgd.MainContext).Strategy.ApplyRenderTargets(null);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public override void Reset(PresentationParameters presentationParameters)

public override void Reset()
{
// Update the back buffer.
this.OnPresentationChanged();
((IPlatformGraphicsContext)_mainContext).Strategy.ApplyRenderTargets(null);
}

public override void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle, IntPtr overrideWindowHandle)
Expand Down Expand Up @@ -175,11 +174,6 @@ public override System.Reflection.Assembly ConcreteAssembly
get { return ReflectionHelpers.GetAssembly(typeof(ConcreteGraphicsDevice)); }
}

internal void OnPresentationChanged()
{
((IPlatformGraphicsContext)_mainContext).Strategy.ApplyRenderTargets(null);
}


protected override void Dispose(bool disposing)
{
Expand Down
14 changes: 6 additions & 8 deletions MonoGame.Framework/Graphics/.DX11/ConcreteGraphicsDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public override void Reset()
if (PresentationParameters.DeviceWindowHandle == IntPtr.Zero)
throw new ArgumentException("PresentationParameters.DeviceWindowHandle must not be null.");

// Update the back buffer.
this.OnPresentationChanged();
CreateSizeDependentResources();
((IPlatformGraphicsContext)_mainContext).Strategy.ApplyRenderTargets(null);
}

public override void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle, IntPtr overrideWindowHandle)
Expand Down Expand Up @@ -529,6 +529,10 @@ internal void SetMultiSamplingToMaximum(PresentationParameters presentationParam
}
#endif

internal void Internal_CreateSizeDependentResources()
{
this.CreateSizeDependentResources();
}

private void CreateSizeDependentResources()
{
Expand Down Expand Up @@ -946,12 +950,6 @@ public override System.Reflection.Assembly ConcreteAssembly
get { return ReflectionHelpers.GetAssembly(typeof(ConcreteGraphicsDevice)); }
}

internal void OnPresentationChanged()
{
CreateSizeDependentResources();
((IPlatformGraphicsContext)_mainContext).Strategy.ApplyRenderTargets(null);
}


protected override void Dispose(bool disposing)
{
Expand Down
21 changes: 7 additions & 14 deletions MonoGame.Framework/Graphics/.GL/ConcreteGraphicsDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ public override void Reset(PresentationParameters presentationParameters)

public override void Reset()
{
// Update the back buffer.
this.OnPresentationChanged();
#if DESKTOPGL
((IPlatformGraphicsContext)_mainContext).Strategy.ToConcrete<ConcreteGraphicsContext>().MakeCurrent(this.PresentationParameters.DeviceWindowHandle);
int swapInterval = ConcreteGraphicsContext.ToGLSwapInterval(this.PresentationParameters.PresentationInterval);
Sdl.Current.OpenGL.SetSwapInterval(swapInterval);
#endif

((IPlatformGraphicsContext)_mainContext).Strategy.ApplyRenderTargets(null);
}

public override void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle, IntPtr overrideWindowHandle)
Expand Down Expand Up @@ -145,18 +150,6 @@ internal int GetMaxMultiSampleCount(SurfaceFormat surfaceFormat)
return maxMultiSampleCount;
}

internal void OnPresentationChanged()
{
#if DESKTOPGL
((IPlatformGraphicsContext)_mainContext).Strategy.ToConcrete<ConcreteGraphicsContext>().MakeCurrent(this.PresentationParameters.DeviceWindowHandle);
int swapInterval = ConcreteGraphicsContext.ToGLSwapInterval(this.PresentationParameters.PresentationInterval);
Sdl.Current.OpenGL.SetSwapInterval(swapInterval);
#endif

((IPlatformGraphicsContext)_mainContext).Strategy.ApplyRenderTargets(null);
}


protected override void Dispose(bool disposing)
{
if (disposing)
Expand Down

0 comments on commit d6c6f9b

Please sign in to comment.