[Q] how to cache a drawn morph

Ned Konz ned at squeakland.org
Wed Mar 2 21:52:04 UTC 2005


On Wednesday 02 March 2005 1:28 pm, Baveco, Hans wrote:
> In the hierarchy of drawing morphs, this is probably not the right place to
> create/update the cache?

No, because you're making other morphs draw themselves too.

> How do I obtain a Form with only the drawings of 
> my morph's submorphs on it? Is there a standard way to achieve this caching
> (there is a CachingMorph somewhere, but I don't understand how it is
> supposed to work)..

The standard way to cache a morph's drawing is to call a private drawOn: to 
render the morph's *own* image to a Form, and then use that instead of the 
expensive drawing later. Then in your drawOn: method you'd just bitBlt the 
form instead of doing the drawing (of course, you throw away and redraw the 
form when the morph's image changes (perhaps in your #changed method)).

However, you really want to get the submorphs' images too. So in addition to 
(or maybe instead of) overriding drawOn: you'd want to override 
drawSubmorphsOn: to use a form instead.

-- 
Ned Konz
http://bike-nomad.com/squeak/



More information about the Squeak-dev mailing list