Slow user interface FPS on EMX

We currently use the EMX module and have consistently seen slow screen refreshes on our 4.3" 480 x 272 display.

This led us to build up a quick app with a significantly less complex interface in order to benchmark the graphics performance and try to determine what could be causing things to run so slow. To our surprise the benchmark app maxes out at a meager 4 FPS. We are stumped as to what we could be doing wrong here and it doesn’t make sense that the EMX plus such a simple graphics routine is so ridiculously slow.

Anyone have any idea why this could be happening?

The test app is built to draw a couple text boxes, a rectangle that moves on every render and a quick FPS calculation. It is set to render this on a 1ms timer. Code below:

  • Brian
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;

namespace GraphicsDebugger
{
	public class BaselineWindow : Window
	{
		public long tickStart, frames;
		public int x, xd;
		public Pen Pen;
		public Brush Brush;
		public DispatcherTimer Timer;

		public BaselineWindow()
		{
			Pen = new Pen(Colors.Black);
			Brush = new SolidColorBrush(Colors.Orange);
			Timer = new DispatcherTimer();
			Timer.Tick += Timer_Tick;
			Timer.Interval = new TimeSpan(0, 0, 0, 0, 1);
			Timer.Start();
			xd = 20;
			tickStart = DateTime.Now.Ticks;
		}

		void Timer_Tick(object sender, EventArgs e)
		{
			Invalidate();
		}

		public override void OnRender(Microsoft.SPOT.Presentation.Media.DrawingContext dc)
		{
			base.OnRender(dc);

			frames++;
			dc.DrawText("Frames: " + frames.ToString(), Resources.GetFont(Resources.FontResources.arial36), Color.Black, 10, 10);
			long seconds = (DateTime.Now.Ticks-tickStart) / (10*1000*1000);	// ticks are in 100 nanoseconds
			dc.DrawText("Seconds: " + seconds, Resources.GetFont(Resources.FontResources.arial36), Color.Black, 10, 50);

			if (seconds > 0)
			{
				long fps = frames / seconds;
				dc.DrawText("FPS: " + fps, Resources.GetFont(Resources.FontResources.arial36), Color.Black, 10, 170);
			}

			if (x >= 480 - 100)
			{
				xd = -20;
			}
			if (x <= 0)
			{
				xd = 20;
			}
			x += xd;
			dc.DrawRectangle(Brush, Pen, x, 120, 100, 50);
		}
	}
}

I never use WPF because of how slow it is. Glide will make things much faster.

The micro framework implementation of WPF is very sloooooow.

A better test of FPS rate would be to use the Bitmap class to write to the display.

Glide and Skewworks products are better choices for GUI frameworks.

That was exactly what we were thinking. We did see quite a few posts online indicating that some threading and timer interactions can cause these types of problems when using the dispatcher. Unfortunately, most of the info on this was not very detailed and we wanted to validate that there wasn’t simply a different way to do this type of drawing when using WPF.

Looks like we are going to move forward with some testing using GLIDE and Skewworks to see how it performs.

-Brian