Page 2 of 7

Re: text rendering

Posted: Thu Jun 21, 2012 5:48 pm
by Badger
Abhishek wrote:Alternatively, I was also thinking, I should remove all wrapping and else functionality from the lcdDrawChar function

yes, I think it would be best. Other code can be written on top of lcdDrawChar that handles the wrapping. keep it as a low level function, and keep it simple.

if these little bits can be sorted out it will make implementing the 'virtual console' much easier!

Re: text rendering

Posted: Thu Jun 21, 2012 5:52 pm
by Abhishek
... And after that, word wrapping, console, BaseSequentialStream and other functionality could be made a part of a higher level text renderkng driver. That'll be the best solution I guess.

Let's come up with a blueprint of changes.

Re: text rendering

Posted: Thu Jun 21, 2012 5:56 pm
by Badger
Have a look at my branch on github, it has some work-in-progress changes with the new file console.c.

The basic idea is you define a portion of the screen and create a GLCDConsole object. This object implements BaseSyncrounousStream. So in theory you could have several!

Re: text rendering

Posted: Thu Jun 21, 2012 7:23 pm
by Tectu
@Abishek, if you are interested in keep hacking at the font stuff, you might take a look to Badgers library from a while ago, which inspired me: https://github.com/trsaunders/Chibios-LCD-Driver

It's very simple and very very clean. You might just copy the font files and change the font stuff inside glcd.c

I'd be very very thankful to whoever fixes font rendering.


~ Tectu

Re: text rendering

Posted: Thu Jun 21, 2012 7:29 pm
by Badger
Abishek, are your fonts monospaced? it would make things easier if we used monospaced fonts. and it would cut down on the memory usage for the fonts as it wouldn't need to save the width for each character.

Re: text rendering

Posted: Sat Jun 23, 2012 11:03 pm
by Badger
Having a big screen of text takes quite a long time to draw (maybe half a second on F1 over FSMC). This is for several reasons:
  • variable width characters requires quite a bit of arithmetic to look up width
  • drawing font pixel by pixel is slow; it involves setting the pixel x/y location and then writing the colour

So what we need to do firstly is to improve the pixel write. At a minimum, we define the write area (the size of the character) and send all of the pixel data as one long write, rather than sending coordinates individually for each pixel. This has disadvantages, it makes transparent more difficult (we would probably have to read the pixel data in the character 'box' before writing and re-write the same background pixels).

As for the monospaced vs variable width, Abishek seems quite keen for variable width, personally I don't need the added complexity. So I vote for simple fonts, less memory usage. We could support both via some macros. But then things get complicated ;)

either way we need to improve the character drawing first!

Re: text rendering

Posted: Sun Jun 24, 2012 10:51 am
by Badger
using a bulk write speeds things up by a factor of 500%!

Re: text rendering

Posted: Sun Jun 24, 2012 10:57 am
by Abhishek
@Badger, Could you please explain things a little?

EDIT: I suppose you are using lcdSetWindow and lcdWrite. But entry mode has to be set correctly to increment Y first and then X in order to use this system.

Re: text rendering

Posted: Sun Jun 24, 2012 11:01 am
by Tectu
I implemented lcdWriteStream() to do that job. I am not sure if this is quite a good solution in this case or not. The idea is to pass a pointer to a uint16_t array and the amount of elements of course. Feel free to suggest any other streaming solution.
Setting the drawing area using lcdSetWindow() is neccessary of course.

I guess it's for sure that we need a faster text rendering when we want to do fancy stuff like the terminal thing.

Since the transparency is only needed when drawing on top of images, I guess we can "drop" that and do what Badger said - read out the pixels and write them back if neccessary
I think this will increase the performance heavily. The routine I used in my first implemention of the library was very easy and bare, but fast as hell.

To the monospace thing: When we decide to overwork the whole font rendering now, I might be usefull to do it monospace this time. I guess we can use some #ifdef to do variable length in the future without any big prolems, right?


~ Tectu

Re: text rendering

Posted: Sun Jun 24, 2012 11:06 am
by Abhishek
Unfortunately Tectu, I don't have my hardware right now, so I cannot take a fresh benchmark. But half a second for long text (and that on FSMC!)... even I hadn't thought of that.

As I posted earlier, I think we should let Badger tell us about it in detail.