- glyph_index gindex = get_glyph_cachel_index (w, drb->object.dglyph.glyph);
- /* Although doing the cachel lookup for every comparison is
- very expensive.we have to do it to make sure the cache is
- up-to-date. */
- if (GLYPH_CACHEL_DIRTYP (w, gindex))
+ /* We need some way of telling redisplay_output_layout () that the
+ only reason we are outputting it is because something has
+ changed internally. That way we can optimize whether we need
+ to clear the layout first and also only output the components
+ that have changed. The image_instance dirty flag and
+ display_hash are no good to us because these will invariably
+ have been set anyway if the layout has changed. So it looks
+ like we need yet another change flag that we can set here and
+ then clear in redisplay_output_layout (). */
+ Lisp_Object window, image;
+ Lisp_Image_Instance* ii;
+ XSETWINDOW (window, w);
+ image = glyph_image_instance (crb->object.dglyph.glyph,
+ window, ERROR_ME_NOT, 1);
+
+ if (!IMAGE_INSTANCEP (image))
+ return 0;
+ ii = XIMAGE_INSTANCE (image);
+
+ if (TEXT_IMAGE_INSTANCEP (image) &&
+ (crb->findex != drb->findex ||
+ WINDOW_FACE_CACHEL_DIRTY (w, drb->findex)))