unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Testing native image scaling
Date: Sun, 20 Jan 2019 19:26:31 +0000	[thread overview]
Message-ID: <20190120192631.GA40845@breton.holly.idiocy.org> (raw)
In-Reply-To: <834la3b9hd.fsf@gnu.org>

On Sun, Jan 20, 2019 at 06:05:18PM +0200, Eli Zaretskii wrote:
> > Date: Sat, 19 Jan 2019 21:45:43 +0000
> > From: Alan Third <alan@idiocy.org>
> > Cc: emacs-devel@gnu.org
> > 
> > x_set_image_size calculates the new sizes, does the conversion, and
> > writes those new sizes back into struct image, over‐writing the
> > original sizes.
> > 
> > For NS it also asks the NSImage back‐end to scale the image using
> > ns_image_set_size, which in effect does the actual scaling.
> > 
> > For XRender it sets up an affine transformation matrix, and applies it
> > to img->picture, which also in effect does the actual scaling.
> > 
> > The compositing functions in nsterm.m and xterm.c don’t need to know
> > the original image size, just the new size, and NSImage/XRender
> > handles the rest.
> 
> Well, on w32, the implementation actually resizes when it draws.
> Maybe that's sub-optimal, but I know next to nothing about w32 image
> display, so what I got looks definitely fine for my ignorance.

I believe that with XRender, and possibly with NS, the actual resizing
is done at draw time, it’s just that the drawing functions don’t need
to know about it because it’s already built into the image types.

> So we now have native resizing on all major platforms.

Excellent! Thanks!

> > We could use XRender to rotate images if we really wanted to, and the
> > NS port already supports it.
> 
> Where's the NS support for that?  AFAICT, :rotate is only handled in
> ImageMagick specific portions of the code, what did I miss?

It’s buried in nsimage.m, ns_load_image gets both :rotation and
:index, then processes the image as appropriate.

If we were to add XRender rotation support, I’d be tempted to do both
rotation and scaling using affine transformation matrices in both
XRender and NS, as they would then both use the same code to calculate
the transforms. I believe Windows supports transformation matrices
through D2D, but I assume Emacs doesn’t use D2D currently, so it may
not be straight forward to add.

If we were to go that far, it may be worth actually exposing the
matrices to lisp and handle the calculations there, but that would
potentially be a big change to the API.
-- 
Alan Third



  reply	other threads:[~2019-01-20 19:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-19  9:31 Testing native image scaling Eli Zaretskii
2019-01-19 21:45 ` Alan Third
2019-01-20 16:05   ` Eli Zaretskii
2019-01-20 19:26     ` Alan Third [this message]
2019-01-20 19:41       ` Eli Zaretskii
2019-01-20 20:19         ` Alan Third
2019-03-27  2:35     ` YAMAMOTO Mitsuharu
2019-03-27 17:09       ` Eli Zaretskii
2019-03-27 18:35         ` Andy Moreton
2019-03-27 18:42           ` Eli Zaretskii
2019-03-27 19:06             ` Andy Moreton
2019-03-27 19:34               ` Andy Moreton
2019-03-28  2:26           ` YAMAMOTO Mitsuharu
2019-03-28 16:02             ` Eli Zaretskii
2019-03-28 18:06               ` Andy Moreton
2019-03-28 18:19                 ` Eli Zaretskii
2019-03-28 19:29                   ` Andy Moreton
2019-03-28 20:09                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190120192631.GA40845@breton.holly.idiocy.org \
    --to=alan@idiocy.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).