Skip to content

Commit

Permalink
CGS update (part 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymekk44 committed May 10, 2024
1 parent 0066ac9 commit ef04aeb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 34 deletions.
17 changes: 1 addition & 16 deletions source/Cosmos.HAL2/Drivers/Video/SVGAII/VMWareSVGAII.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Cosmos.Core;
using Cosmos.HAL.BlockDevice.Registers;

namespace Cosmos.HAL.Drivers.Video.SVGAII
{
Expand Down Expand Up @@ -157,27 +156,13 @@ public void Update(uint x, uint y, uint width, uint height)

/// <summary>
/// Update video memory.
/// </summary>S
/// </summary>
public void DoubleBufferUpdate()
{
videoMemory.MoveDown(FrameOffset, FrameSize, FrameSize);
Update(0, 0, width, height);
}

public void PartUpdate(uint x, uint y, uint UpdateWidth, uint UpdateHeight)
{
uint Offset = y * width + x;
for (uint i = 0; i < UpdateHeight; i++)
{
videoMemory.MoveDown(FrameOffset + Offset, FrameSize + Offset, UpdateWidth);
Offset += UpdateHeight;

}

Update(x, y, UpdateWidth*2, UpdateHeight);
}


/// <summary>
/// Set pixel.
/// </summary>
Expand Down
4 changes: 0 additions & 4 deletions source/Cosmos.System2/Graphics/Canvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,6 @@ public virtual void DrawImage(Image image, int x, int y, int w, int h)
}
}
}
public virtual void UpdatePart(uint x, uint y, uint width, uint height)
{

}

/// <summary>
/// Draws an image with alpha blending.
Expand Down
15 changes: 4 additions & 11 deletions source/Cosmos.System2/Graphics/SVGAIICanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ public override void DrawFilledRectangle(Color color, int xStart, int yStart, in
{
var argb = color.ToArgb();
var frameSize = (int)driver.FrameSize;

width = Math.Min(width, (int)mode.Width - xStart);
height = Math.Min(height, (int)mode.Height - yStart);
// For now write directly into video memory, once _xSVGADriver.Fill will be faster it will have to be changed
for (int i = yStart; i < yStart + height; i++)
{
driver.videoMemory.Fill(GetPointOffset(xStart, i) + (int)frameSize, width, argb);
driver.videoMemory.Fill(GetPointOffset(xStart, i) + frameSize, width, argb);
}
}

Expand Down Expand Up @@ -310,14 +311,6 @@ public override Color GetPointColor(int x, int y)
return Color.FromArgb((int)driver.GetPixel((uint)x, (uint)y));
}

public override void UpdatePart(uint x, uint y, uint width, uint height)
{
driver.PartUpdate(x, y, width, height);
}




public override void Display()
{
driver.DoubleBufferUpdate();
Expand Down Expand Up @@ -362,7 +355,7 @@ public override void DrawImage(Image image, int x, int y)
var maxHeight = Math.Min(height, (int)mode.Height - y);
var frameSize = (int)driver.FrameSize;
var data = image.RawData;

for (int i = 0; i < maxHeight; i++)
{
driver.videoMemory.Copy(GetPointOffset(x, y + i) + frameSize, data, i * width, maxWidth);
Expand Down
6 changes: 3 additions & 3 deletions source/Cosmos.System2/Graphics/VBECanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,14 @@ public override void DrawImage(Image aImage, int aX, int aY)
var xHeight = (int)aImage.Height;
var maxWidth = Math.Min(xWidth, (int)mode.Width - aX);
var maxHeight = Math.Min(xHeight, (int)mode.Height - aY);
int xOffset = aY*(int)Mode.Width + aX;
int xOffset = aY * (int)Mode.Width + aX;
for (int i = 0; i < maxHeight; i++)
{
driver.CopyVRAM((i * (int)Mode.Width) + xOffset, xBitmap, i * xWidth, maxWidth);
driver.CopyVRAM((i * (int)Mode.Width) + xOffset, xBitmap, i * xWidth, maxWidth);
}

}

#endregion

public override void Display()
Expand Down

0 comments on commit ef04aeb

Please sign in to comment.