+ type = encode_image_instance_type (IMAGE_INSTANCE_TYPE (ii));
+ meths = decode_device_ii_format (Qnil, type, ERROR_ME_NOT);
+
+ MAYBE_IIFORMAT_METH (meths, layout,
+ (image_instance, width, height, xoffset, yoffset,
+ domain));
+ /* Do not clear the dirty flag here - redisplay will do this for
+ us at the end. */
+ IMAGE_INSTANCE_LAYOUT_CHANGED (ii) = 0;
+}
+
+/* Update an image instance from its changed instantiator. */
+static void
+update_image_instance (Lisp_Object image_instance,
+ Lisp_Object instantiator)
+{
+ struct image_instantiator_methods* meths;
+ Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+
+ ERROR_CHECK_IMAGE_INSTANCE (image_instance);
+
+ if (NOTHING_IMAGE_INSTANCEP (image_instance))
+ return;
+
+ assert (!internal_equal (IMAGE_INSTANCE_INSTANTIATOR (ii), instantiator, 0)
+ || (internal_equal (IMAGE_INSTANCE_INSTANTIATOR (ii), instantiator, 0)
+ && internal_equal (IMAGE_INSTANCE_INSTANTIATOR (ii), instantiator, -10)));
+
+ /* If the instantiator is identical then do nothing. We must use
+ equal here because the specifier code copies the instantiator. */
+ if (!internal_equal (IMAGE_INSTANCE_INSTANTIATOR (ii), instantiator, 0))
+ {
+ /* Extract the changed properties so that device / format
+ methods only have to cope with these. We assume that
+ normalization has already been done. */
+ Lisp_Object diffs = find_instantiator_differences
+ (instantiator,
+ IMAGE_INSTANCE_INSTANTIATOR (ii));
+ Lisp_Object type = encode_image_instance_type
+ (IMAGE_INSTANCE_TYPE (ii));
+ struct gcpro gcpro1;
+ GCPRO1 (diffs);
+
+ /* try device specific methods first ... */
+ meths = decode_device_ii_format (image_instance_device (image_instance),
+ type, ERROR_ME_NOT);
+ MAYBE_IIFORMAT_METH (meths, update, (image_instance, diffs));
+ /* ... then format specific methods ... */
+ meths = decode_device_ii_format (Qnil, type, ERROR_ME_NOT);
+ MAYBE_IIFORMAT_METH (meths, update, (image_instance, diffs));
+
+ /* Instance and therefore glyph has changed so mark as dirty.
+ If we don't do this output optimizations will assume the
+ glyph is unchanged. */
+ set_image_instance_dirty_p (image_instance, 1);
+ /* Structure has changed. */
+ IMAGE_INSTANCE_LAYOUT_CHANGED (ii) = 1;
+
+ UNGCPRO;
+ }
+ /* We should now have a consistent instantiator so keep a record of
+ it. It is important that we don't actually update the window
+ system widgets here - we must do that when redisplay tells us
+ to.
+
+ #### should we delay doing this until the display is up-to-date
+ also? */
+ IMAGE_INSTANCE_INSTANTIATOR (ii) = instantiator;