Subject: Re: bug#38109: Updated Emacs to HEAD, consistently not scaling now

From: Alan Third <[email-masked]>
Date: Fri, 8 Nov 2019 23:03:45 +0000

On Fri, Nov 08, 2019 at 10:03:17PM +0100, Adam Sjøgren wrote:
> I apparently haven't got Cairo enabled in my build, maybe that's a
> problem?

No, this should all work without Cairo.

>   asjo@tullinup:/usr/src/emacs$ grep CAIRO src/config.h
>   /* #undef USE_CAIRO */
> 
> An observation: when displaying the colormapped .png,
> image_create_x_image_and_pixmap_1() is called twice, the first time
> depth is <= 0, and the second time it isn't.

Does the RGB png call that function twice? The second time through is
for setting the mask, or transparency, and it looks like it sets depth
to ‘1’, which image_create_x_image_and_pixmap_1 doesn’t like with
xrender. Although your patch should have fixed that.

But in addition you might need this:

modified   src/image.c
@@ -2244,6 +2244,13 @@ image_set_transform (struct frame *f, struct image *img)
       XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->picture, FilterBest,
 			       0, 0);
       XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->picture, &tmat);
+
+      if (img->mask_picture)
+        {
+          XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->mask_picture, FilterBest,
+                                   0, 0);
+          XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->mask_picture, &tmat);
+        }
     }
 # elif defined HAVE_NTGUI
   /* Store the transform matrix for application at draw time.  */

As I don’t think we were setting the transform for the mask to match
the image. Although I don’t really know for sure if it’s needed.

It really wouldn’t surprise me too much if this was all related to
masks, I never managed to get a satisfactory test going.

OTOH, if XPMs don’t even use these functions then that would certainly
cause scaling to fail. I’ll have to have a look at the XPM code to
find out what they’re doing instead.
-- 
Alan Third