Skip to content

Commit

Permalink
swap Reset(...) (#1594)
Browse files Browse the repository at this point in the history
* inline GraphicsDeviceStrategy.Reset()

* use GraphicsDeviceStrategy.Reset(PresentationParameters)

* inline GraphicsDeviceStrategy.Reset()

* use GraphicsDevice.Reset(PresentationParameters)

* refactor Reset(PresentationParameters)
  • Loading branch information
nkast authored May 22, 2024
1 parent d6c6f9b commit b1644f6
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ internal ConcreteGraphicsDevice(GraphicsDevice device, GraphicsAdapter adapter,

public override void Reset(PresentationParameters presentationParameters)
{
PresentationParameters = presentationParameters;
Reset();
}
this.PresentationParameters = presentationParameters;

public override void Reset()
{
((IPlatformGraphicsContext)_mainContext).Strategy.ApplyRenderTargets(null);
}

Expand Down
8 changes: 2 additions & 6 deletions MonoGame.Framework/Graphics/.DX11/ConcreteGraphicsDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,13 @@ internal ConcreteGraphicsDevice(GraphicsDevice device, GraphicsAdapter adapter,

public override void Reset(PresentationParameters presentationParameters)
{
PresentationParameters = presentationParameters;
Reset();
}
this.PresentationParameters = presentationParameters;

public override void Reset()
{
#if WINDOWSDX
CorrectBackBufferSize();
#endif

if (PresentationParameters.DeviceWindowHandle == IntPtr.Zero)
if (this.PresentationParameters.DeviceWindowHandle == IntPtr.Zero)
throw new ArgumentException("PresentationParameters.DeviceWindowHandle must not be null.");

CreateSizeDependentResources();
Expand Down
6 changes: 1 addition & 5 deletions MonoGame.Framework/Graphics/.GL/ConcreteGraphicsDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ internal ConcreteGraphicsDeviceGL(GraphicsDevice device, GraphicsAdapter adapter

public override void Reset(PresentationParameters presentationParameters)
{
PresentationParameters = presentationParameters;
Reset();
}
this.PresentationParameters = presentationParameters;

public override void Reset()
{
#if DESKTOPGL
((IPlatformGraphicsContext)_mainContext).Strategy.ToConcrete<ConcreteGraphicsContext>().MakeCurrent(this.PresentationParameters.DeviceWindowHandle);
int swapInterval = ConcreteGraphicsContext.ToGLSwapInterval(this.PresentationParameters.PresentationInterval);
Expand Down
5 changes: 0 additions & 5 deletions MonoGame.Framework/Graphics/.Ref/ConcreteGraphicsDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ public override void Reset(PresentationParameters presentationParameters)
throw new PlatformNotSupportedException();
}

public override void Reset()
{
throw new PlatformNotSupportedException();
}

public override void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle, IntPtr overrideWindowHandle)
{
throw new PlatformNotSupportedException();
Expand Down
10 changes: 2 additions & 8 deletions src/Xna.Framework.Graphics/Graphics/GraphicsDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,7 @@ private void OnDeviceReset(EventArgs e)

public void Reset()
{
_strategy.OnDeviceResetting(EventArgs.Empty);

_strategy.Reset();

_strategy.OnPresentationChanged(new PresentationEventArgs(PresentationParameters));

_strategy.OnDeviceReset(EventArgs.Empty);
Reset(this.PresentationParameters);
}

public void Reset(PresentationParameters presentationParameters)
Expand All @@ -354,7 +348,7 @@ public void Reset(PresentationParameters presentationParameters)

_strategy.Reset(presentationParameters);

_strategy.OnPresentationChanged(new PresentationEventArgs(PresentationParameters));
_strategy.OnPresentationChanged(new PresentationEventArgs(this.PresentationParameters));

_strategy.OnDeviceReset(EventArgs.Empty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ protected internal void OnDeviceReset(EventArgs e)
}


public abstract void Reset();
public abstract void Reset(PresentationParameters presentationParameters);
public abstract void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle, IntPtr overrideWindowHandle);
public virtual void Present()
Expand Down

0 comments on commit b1644f6

Please sign in to comment.