pyglet CSS improvements
2007-01-05 13:01:07
This week has mostly been rewriting/refactoring the layout code. Mostly this
was due to me not correctly understanding CSS when I started implementing it, and
some of it was because I got better ideas on how to do things. As a result of
having the code match the specification more closely in terms of structure, it
became far simpler to work with, and several new CSS features (borders,
backgrounds) were added quite quickly and easily.
Today I finished this refactoring of existing code by moving the Font/Glyph
interaction with layout from Box into Frame. This will make properties like
:first-line possible, and much of the layout calculation becomes simplified. I
also suspect that this will simplify incremental changes to documents (though no
work has started on that yet).
As expected, layout is now 2-5 times slower (though box creation is faster, but
that's not very interesting), but drawing is 1.5-2 times faster (due to the
reduced depth of the document tree). While I like fast layout, in reality I
think it's a low priority for a games-oriented toolkit.
pyglet gets CSS
2006-12-27 00:02:11
Some of it, anyway. r322 gives classes for parsing XML/XHTML + CSS 2.1 and
rendering, including backgrounds and borders. Only the bare minimum is
implemented so far: block and inline display elements; but dare I say the hard
bit's done? I'll finish off the text attributes (line-height, text-indent,
font-weight, font-style, ...) in the next couple of days, then look into float,
absolute and relative displays.
Parsing CSS feels slow (haven't measured it), could be improved with a
hand-crafted scanner (I'm using
Plex at the moment). Many parts of the grammar
could be inlined to reduce function-call (of which there will be many) overhead.
Layout (reflowing after resizing) is pretty quick on my desktop, and perfectly
acceptable on my iBook. There's not much that can be done to speed it up. For
pyglet, this will really only need to be done during content updates (I don't
imagine many people using resizable windows), and incremental updates could be
implemented.
Display is very fast... between 35 and 75 FPS for the Frog King text (1400
words) without any optimisations. I plan to improve on this a lot, by flattening
the render structure and partitioning it for view culling.
pyglet.org goes live
2006-12-18 16:01:22
The rumours are true, here's the link:
pyglet.org. Thanks to Richard for
providing the hosting and drawing the buttons and the cube.
pyglet: Mesa and image regressions
2006-12-09 12:44:47
Mesa rendering works now. The problem was to do with not setting a colormap on
the window--indirect rendering needs to have a compatible colormap with the GLX
visual. I would never have worked this out myself... extensive Googling found a
thread with a similar problem on another program,
Clutter, which ended with the
maintainer posting "there's a fix in the trunk now". A carefully
crafted svn diff on that date found exactly the patch I needed to apply to pyglet
:-)
A nice Gentooism that helped debug is:
eselect opengl set xorg-x11
which swaps in the Mesa software rendering driver. Later I can
eselect opengl set nvidia
to return to the proprietary driver, all without rebooting.
Test cases can now save images of themselves which are stored in a regressions
directory; the next time the test runs instead of having to ask the user if it
looks correct, they simply match the on-screen image with the regression image.
Some tests (image.*) can use the same regression images across platforms, while
others (text.*) will have to be kept separate due to inherent (desirable)
rendering differences.
Laptop: addition
2006-12-07 21:33:45
The flicker, interferency, frozen, supernova problem is apparently the same old
logic board problem that plagues all iBooks of my vintage (I remember checking
serial numbers some time ago and falling outside the range, which has evidently
been updated since). The replacement program is over now, but Apple have given
me the part for free ($1500 value!) because they feel sorry for my having to have
the same part replaced only 4.5 months ago (as far as I know, that never actually
happened).
So, what is old will be new again ;-)