Congrats! Looks good. But there are some problems. In particular, you don't
handle multiple animated gifs properly. (In fact, there will be a timeout leak
in such a case!) You need to have each separate animated gif have its own
timeout, which you store as a field in the image instance, and the timeout's
argument should be the image instance, not a device. This allows for animated
gifs with different time delays (is this not a property of the gif itself? You
hardcode it at 100ms) and would also allow each gif to be stopped independently
of the others. You also really need to implement this stop ability, or people
will go crazy. You should do this using a weak list or hashtable of all the
animated gifs, which you map over. You might also think about providing a lisp
interface to retrieve this list, and possibly other similar lists of extant
image instances. (Somebody, probably whose last name is Perry, is going to want
this.)
Also, why do you have a separate IMAGE_WIDGET_MASK and IMAGE_LAYOUT_MASK?
These are really one and the same.
ben
Andy Piper wrote:
This patch implements animated gifs, but also as a consequence
optimizes
the redisplay handling of glyphs and subwindows somewhat which I hope to
use in optimizing layout handling.
I have only tested this with one animated glyph so I'm guessing there may
be some bizarre formats that are not handled correctly. I'm hoping I
haven't broken gutter display in the process, the way I'm doing things now
is more correct but also slightly different and therefore has the potential
for new bugs.
This patch was almost entirely coded on the train.
andy
1999-10-05 Andy Piper <andy(a)xemacs.org>
* redisplay.c: new state flags, subwindows_state_changed and
subwindows_state_changed set.
(redisplay_window): use them.
(redisplay_device): ditto.
(redisplay_without_hooks): ditto.
(redisplay_frame): ditto. Reset subwindow cachels if
subwindows_changed is set.
(redisplay_window): call mark_glyph_cachels_as_clean after
redisplaying.
* redisplay-x.c (x_output_x_pixmap): select correct
pixmap image for display depending on the currently selected
slice.
* redisplay-output.c (compare_runes): check dirtiness when
checking RUNE_DGLYPH runes.
(compare_display_blocks): relax invalidation of display blocks
since we can now detect whether individual glyphs have changed or
not.
* redisplay-msw.c (mswindows_output_dibitmap): select correct
bitmap image for display depending on the currently selected
slice.
* glyphs.h (struct Lisp_Image_Instance): add a dirty flag.
(IMAGE_INSTANCE_DIRTYP): new macro.
(XIMAGE_INSTANCE_DIRTYP): ditto.
(MARK_IMAGE_INSTANCE_CHANGED): ditto.
(GLYPH_DIRTYP): ditto.
(XGLYPH_DIRTYP): ditto.
(MARK_GLYPH_CHANGED): ditto.
(GLYPH_CACHEL_DIRTYP): ditto.
(struct glyph_cachel): add a dirty flag.
* glyphs.c (update_frame_subwindows): Don't update on
glyphs_changed.
(glyph_animated_timeout_mapper): new function. Map over the
instance cache lookinng for animated images to update.
(Fglyph_animated_timeout_handler): new function. Lisp callback for
handling animated image timeout events.
(disable_glyph_animated_timeout): new function. Add the animated
image timeout.
(disable_glyph_animated_timeout): new function. Remove the
animated image timeout.
(syms_of_glyphs): initialize Qglyph_animated_timeout_handler and
friends.
(vars_of_glyphs): initialize Vglyph_animated_ticker.
(image_instance_equal): add the currently displayed slice.
(image_instance_hash): ditto.
(allocate_glyph): initialize dirty flag.
(glyph_width): rename glyph -> glyph_or_image.
(glyph_height_internal): ditto.
(glyph_dirty_p): new function. Determine whether the image
instance in the domain and/or glyph is dirty.
(set_glyph_dirty_p): set the dirtiness.
(update_glyph_cachel_data): take dirtiness into account. Pass the
image instance we are interested in to glyph_width and friends.
(get_glyph_cachel_index): make non-static. Always call
update_glyph_cachel_data.
(mark_glyph_cachels_as_not_updated): meaningless formatting
change.
(mark_glyph_cachels_as_clean): new function. Clean dirtiness from
glyph cachels.
* glyphs-x.h (struct x_image_instance_data): change
pixmap to a list of pixmaps.
(IMAGE_INSTANCE_X_PIXMAP_SLICE): new macro.
(IMAGE_INSTANCE_X_PIXMAP_SLICES): ditto.
(XIMAGE_INSTANCE_X_PIXMAP_SLICE): ditto.
(XIMAGE_INSTANCE_X_PIXMAP_SLICES): ditto.
* glyphs-x.c (x_finalize_image_instance): make sure multi pixmap
images get deleted properly.
(init_image_instance_from_x_image): add slices paramater and use
it to initialize x_image_instance_data correctly.
(image_instance_add_x_image): new function. Add new pixmaps to our
set of instantiated pixmaps for an image. Used by animated images.
(x_init_image_instance_from_eimage): add a slices
parameter. Instantiate all images from the eimage.
(x_xpm_instantiate): update use of
init_image_instance_from_x_image.
(init_image_instance_from_xbm_inline): ditto.
(x_initialize_pixmap_image_instance): add slices paramater and use
it to allocate x_image_instance_data correctly.
* glyphs-msw.h (struct mswindows_image_instance_data): change
bitmap to a list of bitmaps.
(IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE): new macro.
(IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES): ditto.
(XIMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE): ditto.
(XIMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES): ditto.
* glyphs-msw.c (init_image_instance_from_dibitmap): add slices
paramater and use it to initialize mswindows_image_instance_data
correctly.
(image_instance_add_dibitmap): new function. Add new bitmaps to
our set of instantiated bitmaps for an image. Used by animated
images.
(mswindows_init_image_instance_from_eimage): add a slices
parameter. Instantiate all images from the eimage.
(mswindows_xpm_instantiate): update use of
init_image_instance_from_dibitmap.
(bmp_instantiate): ditto.
(init_image_instance_from_xbm_inline): ditto.
(mswindows_finalize_image_instance): make sure all the bitmap
slices get deleted.
(mswindows_initialize_dibitmap_image_instance): add slices
paramater and use it to allocate mswindows_image_instance_data
correctly.
* glyphs-eimage.c (jpeg_instantiate): give extra paramter to
init_image_instance_from_eimage.
(png_instantiate): ditto.
(tiff_instantiate): ditto.
(gif_instantiate): allocate bitmaps for all gif slices not just
the first one.
* device.h (struct device): add subwindows_state_changed flag.
(MARK_DEVICE_SUBWINDOWS_STATE_CHANGED): new macro.
(MARK_DEVICE_FRAMES_GLYPHS_CHANGED): ditto.
* console.h (struct console_methods): add a slice parameter to
init_image_instance_from_eimage_method.
* redisplay.c (create_string_text_block): Allow buffer to be nil
without crashing.
------------------------------------------------------------------------
Name: anim.patch
anim.patch Type: Plain Text (text/plain)
Encoding: quoted-printable
------------------------------------------------------------------------
--------------------------------------------------------------
Dr Andy Piper
Senior Consultant Architect, BEA Systems Ltd