Jump to content

Full screen background image slow rendering


csteaderman

Recommended Posts

My target hardware is an Atmel SAMA5D2 with built in display controller and an 800x480 pixel display. I have chosen the Framebuffer model for the display driver. The hardware controller supports up to 4 layers, but I am only using one right now. When I integrate Pixmap support, I will take advantage of the multiple layers. At this time I have implemented the sample benchmark program and am getting a little more than 10M pixels per second drawing random size/color boxes. I am now trying to render a full screen bitmap as the background. The problem is that I can see the image rendered row by row. Is there a configuration setting to change the buffer size that is decoded and written to the display so that more of the bitmap is rendered per call? Is there an event/callback that I can hook in order to know that uGFX is done rendering the bitmap so that I can buffer the smaller writes and then quickly switch the DMA buffer? Any pointers would be appreciated.

 

Thanks,

Charlie

Link to comment
Share on other sites

Where are you loading the image from and what type of image is it?

As ugfx decodes inline as it displays, a slow storage can mean slow image displaying. There are three sutions to the problem...

1. Put your image in fast storage eg using ROMFS.

2. Use gdispImageCache() to cache your image decode in memory (if you have enough RAM)

3. Create a pixmap, draw the image to the pixmap and then bitblit the pixmap to the screen whenever you want to draw the image (again this requires you have enough RAM to store the de oded image in RAM)

Link to comment
Share on other sites

Hello @csteaderman,

gdispImageCache() will already improve the drawing speed for the very first draw.
One of the nice things of gdispImageCache() is that  your image will still be drawn, even if caching it failed (due to lack of memory). However, you will always be aware of this as the return value of gdispImageCache() gives you information of whether the caching was successful.

 

Link to comment
Share on other sites

Thanks for the pointers, PIXMAP is just what I was looking for. Do PIXMAPs natively support alpha blending? Right now I am using one PIXMAP to draw (blit) a background image and another PIXMAP to blit a PNG with transparent background on top of the background. Unfortunately, the background color of the top PIXMAP is rendered as black.

Link to comment
Share on other sites

Sorry for the late reply...

It turns out that what my friend did isn't exactly what you need. All he did was hacking an alpha channel into the existing pixmap. This won't help when blitting two pixmaps together which is what you want.

LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
	unsigned	pos;
	color_t 	color;

	#if GDISP_NEED_CONTROL
		switch(g->g.Orientation) {
		case GDISP_ROTATE_0:
		default:
			pos = g->p.y * g->g.Width + g->p.x;
			break;
		case GDISP_ROTATE_90:
			pos = (g->g.Width-g->p.x-1) * g->g.Height + g->p.y;
			break;
		case GDISP_ROTATE_180:
			pos = (g->g.Height-g->p.y-1) * g->g.Width + g->g.Width-g->p.x-1;
			break;
		case GDISP_ROTATE_270:
			pos = g->p.x * g->g.Height + g->g.Height-g->p.y-1;
			break;
		}
	#else
		pos = g->p.y * g->g.Width + g->p.x;
	#endif

	if(g->p.color & 0xFF000000){
		color = gdispBlendColor(((pixmap *)(g)->priv)->pixels[pos], g->p.color & 0x00FFFFFF, ((g->p.color & 0xFF000000) >> 24));
	} else {
		color = g->p.color;
	}

	((pixmap *)(g)->priv)->pixels[pos] = color;
}

Note that this is really a hack as the underlying GDISP module doesn't offer a color format that implements an alpha channel. The code above needs to be adjusted in case of the used color format is not RGB888.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...