rendering only certain areas



Hello,
I want to show much text but the text is not displayed completely at once. Just imagine a textbox or similar widget where the user can scroll around.

I think rendering the layout completely to an offscreen buffer is no good idea. It would use too much memory. So only those parts are rendered which are also displayed.

If I always completely rerender the text shown in the widget everytime the user scrolls around it would cost too much CPU time and slows down the rest (benchmarked 800x600px area with text rendering => 40ms).

If the user scrolls a bit down, some of the text that was visible before is now displayed at another screen position, some text becomes invisible and some new text is displayed. I think I can use that for improvement. If some new area of the text is shown due to scrolling, the invisible areas of the text can now be used to store the new text (some modulo operations determine rendering position to offscreen buffer).

Example, the text has got 10 parts but only 4 parts displayed at once:

1. part of text
2. part of text
3. part of text
4. part of text

scrolling down one line =>
5. part of text
2. part of text
3. part of text
4. part of text
Part 5 is stored at position 5 mod 4

scrolling down one part =>
5. part of text
6. part of text
3. part of text
4. part of text
Part 5 is stored at position 6 mod 4

and so on...

So whats my problem? I want to render parts of the text. I found


     pango_layout_get_line_readonly ();


     pango_cairo_show_layout_line ();

with which I can render single lines. This is nice, but what if the user uses a pango layout with different font sizes or the lines have a height of let's say 20px and the user only scrolls 10 px down. It will become a bit tricky to manage all that. Does pango provide a function to render any part of a layout? And not "only" lines? I searched the documentation but found nothing.

Thanks in advance.
Regards,
Ulrich




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]