do not send frames when nothing changes
This commit is contained in:
parent
89494ef495
commit
de3d298475
1 changed files with 54 additions and 13 deletions
|
|
@ -2,7 +2,7 @@ using System.Diagnostics;
|
|||
|
||||
namespace DisplayCommands;
|
||||
|
||||
public sealed class PixelGrid(ushort width, ushort height)
|
||||
public sealed class PixelGrid(ushort width, ushort height) : IEquatable<PixelGrid>
|
||||
{
|
||||
private readonly ByteGrid _byteGrid = new((ushort)(width / 8u), height);
|
||||
|
||||
|
|
@ -34,6 +34,18 @@ public sealed class PixelGrid(ushort width, ushort height)
|
|||
|
||||
public void Clear() => _byteGrid.Clear();
|
||||
|
||||
public bool Equals(PixelGrid? other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return Width == other.Width && Height == other.Height && _byteGrid.Equals(other._byteGrid);
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj) => ReferenceEquals(this, obj) || (obj is PixelGrid other && Equals(other));
|
||||
public override int GetHashCode() => HashCode.Combine(_byteGrid, Width, Height);
|
||||
public static bool operator ==(PixelGrid? left, PixelGrid? right) => Equals(left, right);
|
||||
public static bool operator !=(PixelGrid? left, PixelGrid? right) => !Equals(left, right);
|
||||
|
||||
private (ushort byteIndex, byte bitInByteMask) GetIndexes(int x)
|
||||
{
|
||||
Debug.Assert(x < Width);
|
||||
|
|
|
|||
Reference in a new issue