Re: gnome-photos: Support undo after clicking "done" (GNOME #763096)

Debarshi Ray <[email protected]>
Newsgroups gmane.comp.gnome.documentation,gmane.comp.gnome.internationalization.general
Message-ID <[email protected]>
Hey,

On Tue, Mar 08, 2016 at 07:34:49PM -0500, Matthias Clasen wrote:
> Shouldn't the view redraw as needed, when its
> model changes ?

Ideally, yes.

TLDR: Doing the right thing would require more intrusive changes, and
I am not comfortable making them at the eleventh hour. In comparison,
this is a quick and dirty way to achieve the same thing.

Longer explanation follows ...

The PhotosImageView widget originated as a fork of the toy gegl-gtk
widget. Due to not having any real life users, gegl-gtk is not
perfect, and even though we have evolved the code a bit, there are
still some hacks to plaster over the cracks.

PhotosImageView draws the result of a graph (source at one end and
then some operations). The result of the graph can change if:
 (a) the connectivity of the nodes change
 (b) the properties of the nodes change
 (c) we process the graph after (a) or (b) has happened to generate
     new pixels

The widget can implicitly handle (a) or (b). eg., it can reposition
and resize the image if you apply a crop.

However, it needs some help with (c). GEGL processes the graph in
smaller bits. If you have 1000x1000 image, it might process it in
100x100 chunks. This is nice because we can use an idle handler and
turn the processing into an asynchronous operation to avoid freezing
the UI. (Even if this is purely CPU intensive and no I/O is done, it
can occupy the CPU for a second or two.)  PhotosImageDraw gets
notified when each chunk is finished, but it doesn't know when all of
them are processed. Queueing a redraw after each chunk is problematic
because it leads to a checkerboard effect because you can see the
chunks being updated.

The application hacked around this by queueing a redraw from the
photos_base_item_process_async callback. We only needed to do it from
the container holding PhotosImageView, so it was quick and easy.

Except, now, we have to do it from a different part of the code - the
notification. So it was quick (and safe) to just turn the redraw into a
GAction that can be activated from elsewhere and is implemented by the
widget's container.

The correct thing to do would be to teach PhotosImageView to keep
track of the chunks. I tried to do it [1] during my attempt to animate
changes to the graph - cross fade between filters, rubber band effect
when cropping. That exposed some bugs in GEGL's processing - it
emitted too many (and sometimes with bogus values) notifications. I
fixed some. Some I punted, because I was not sufficiently happy with
the larger animation code anyway.

So, something that can be targetted for GNOME 3.22, but not going to
be safe for 3.20.

Thanks for taking a look at the code!

Cheers,
Rishi

[1] https://git.gnome.org/browse/gnome-photos/log/?h=wip/rishi/imageview

_______________________________________________
gnome-doc-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gnome-doc-list
signature.asc (application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJW3+qbAAoJEEMnBfrN1AMlCKoP/2UQMhceJJxnNnex1Px79IAr
ZfsWJs1gfZEU+yGWhuS6Ye5O9zDWulMmBvvv5DYpVY1VcxU+SKpGuhl4B5Q57GS/
XqwcQ30jr0RcVdtaV8DGVYLrDtcazaVZYyqFM3UKYjmlsMQVOdBSG0B4IIKIlwtQ
bcHmAlj5hnBtwn5v0HC0ex5eJrjku0Tkn4QMv5OsF9qgKR1Sjscbu/8ZugKKQ0sB
JZyxNPJi2zpOKKtDZW+hKHe8xOHfek3jWP/VKBUFOBFkbhTu0TQkpgXoDwU8NuPj
s4bAu0J7YwYVe3cfTK0apX8sP+WEO9ULa3PqOP1JcUXGimug3HcYSegx9PVjvwYp
A0L+R0xOH8kWTynkFEFzy55t/BCNs/sxF+Vkbmh9VY2i2ASIX7sgRiN6cAJXd5PB
z8EPTY66CW9q+wCb0XA7Ro/phkleansjDUn/rOysRCMsxm6VwDF3f3urDSYGXzIP
KhLM7ypCnbXOfcE4csNBZBGtkckHxm4W2Tcj5gSVTdt9PybrSEuRHJ+VNMxa+5SU
xCCBlLMDNT2p2ZJ1UBZmhA/Ng6iN0fA83iaB6zc5NBuIe0N3UZIrtAJTY/lXnUtF
YnAm70J0EpZUtG2cd00x9FUC/DiMnOQIhLIpNn904UGCRiQ1iE1Z1LnK9QCarPuZ
5DC0npX/DWcCAHq7D09x
=SzoY
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.