Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphics display corrupted when using partial flush #655

Closed
AdrianSoundy opened this issue Oct 23, 2020 · 1 comment · Fixed by nanoframework/nf-interpreter#1788
Closed

Comments

@AdrianSoundy
Copy link
Member

AdrianSoundy commented Oct 23, 2020

Description

This happens on all existing targets/display controller Otm8009a , ILL9341 and ST7789V

ILL9341 and ST7789V use same code.

Noticed when testing Tetris application. As soon as start play half the display is Corrupted

Latest graphics firmware versions.

This looks like a problem with the BitBlt() method not working with start positions and widths that are not a full screen

To show problem I created a test program(See below) that draws a rectangle on 4 corners of display. Then flushes each out individually

Expected behaviour

All rectangles should be shown correctly when each flushed

Screenshot

After full screen flush -OK
Goog_fullscreenflush

After just flushing first rectangle, top left
AfterFirstFlush

using System;
using System.Threading;
using nanoFramework.UI;
using nanoFramework.Presentation.Media;


namespace TestFlush
{
    public class Program
    {
		static int height;
		static int width;

		static int qw;
		static int qh;

		static int px1;
		static int px2;
		static int py1;
		static int py2;


		public static void Main()
        {
            DisplayControl dc = new DisplayControl();

			// Init positions
			height = dc.ShorterSide;
            width = dc.LongerSide;

			// Rectangle size
			qw = width / 4;
			qh = height / 4;

			// Start Positions
			px1 = 5;
			px2 = width - qw - 5;
			py1 = 5;
			py2 = height -qh - 5;

			try
            {
                Bitmap fullScreenBitmap = new Bitmap(width, height); 

				while (true)
				{
					// Clear display
					ClearDisplay(fullScreenBitmap);

					// Show rectangles as full screen
					DrawRectangles(fullScreenBitmap);
					fullScreenBitmap.Flush();   // OK

					Thread.Sleep(4000);

					ClearDisplay(fullScreenBitmap);

					// Draw all rectangles on full screen
					DrawRectangles(fullScreenBitmap);

					// Flush each rectangle separately ( partial flush) 
					// top left
					fullScreenBitmap.Flush(px1, py1, qw, qh);
					Thread.Sleep(1000);

					// Top right
					fullScreenBitmap.Flush(px2, py1, qw, qh);
					Thread.Sleep(1000);

					// bottom left
					fullScreenBitmap.Flush(px1, py2, qw, qh);
					Thread.Sleep(1000);

					// bottom right
					fullScreenBitmap.Flush(px2, py2, qw, qh);
					Thread.Sleep(5000);
				}

			}
			catch (Exception) { }


            Thread.Sleep(Timeout.Infinite);

        }

		static void ClearDisplay(Bitmap fullScreenBitmap)
		{
			fullScreenBitmap.Clear();
			fullScreenBitmap.Flush();
		}

		static void DrawRectangles( Bitmap fullScreenBitmap)
		{

			// top left
			fullScreenBitmap.DrawRectangle(Color.Red, 1, px1, py1, qw, qh, 1, 1,
				Color.Black, 0, 0, Color.Black, 0, 0, 0);

			// Top right
			fullScreenBitmap.DrawRectangle(Color.Blue, 1, px2, py1, qw, qh, 1, 1,
				Color.Black, 0, 0, Color.Black, 0, 0, 0);

			// Bottom left
			fullScreenBitmap.DrawRectangle(Color.Green, 1, px1, py2, qw, qh, 1, 1,
				Color.Black, 0, 0, Color.Black, 0, 0, 0);

			// Bottom right
			fullScreenBitmap.DrawRectangle(Color.HotPink, 1, px2, py2, qw, qh, 1, 1,
				Color.Black, 0, 0, Color.Black, 0, 0, 0);

		}
	}
}

@AdrianSoundy
Copy link
Member Author

This is a problem with the bitBlt code not taking into account of partial windows to display

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants