! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Blurring shadow on text of icons.
Status:
RESOLVED: FIXED
Product:
Xfdesktop
Component:
General

Comments

Description Matias De lellis 2014-10-10 18:28:23 CEST
Created attachment 5679 
Comparation before and after applying the patch using Greybird theme

Hi All,
I have another proposal to xfdesktop: Blur the shadow of the text icons.

I made the first test, and now attach the results:

No improves the text visibility as I expected, but really going more beautiful.. 

What do you think?.

Well, after many turns (Cairo does not implement it natively, and there are thousands of example of how to do it, each one with different results), I'm using Gtk+-3 code to do this:
# https://git.gnome.org/browse/gtk+/tree/gtk/gtkcairoblur.c

And adapt the necessary functions from here:
# https://git.gnome.org/browse/gtk+/tree/gtk/gtkcssshadowvalue.c

Well, obviously, this means more CPU usage, but is supposed that is optimized.. And the patch keeps doing this optional, adding a new property called "shadow-blur-radius" on gtkrc file.

If the "shadow-blur-radius" does not exist or is zero, it is shaded as before. If greater than 1, applies blur. =)

All comments are welcome. ;)

Regards,
Matias.
Comment 1 Matias De lellis 2014-10-10 18:39:14 CEST
Created attachment 5680 
[Patch] Implement optional blur to shadow on icons text
Comment 2 Matias De lellis 2014-10-11 03:53:03 CEST
Hi Again,

Small update, is disgustingly slow..
I said that would consume more CPU.. but I never thought it would be so slow. :(

With a 2-pixel blur takes more than two seconds to change the desktop image.

Now I was investigating change the Gaussian bluring by one exponential, and decreases the time a lot but still seems slow..

I'm seeing how can be optimized...

Regards.
Comment 3 Matias De lellis 2014-10-14 18:11:49 CEST
Tiny update.

I just discovered why is so slow..
In short, I am applying to blur the entire screen... Once for each icon painting..

The xfdesktop code is very inefficient is this.. Each time you draw an icon, a text, or a shadow, does it on a region that occupies the entire screen wasting CPU and memory.. rather than changing only the region involved and then apply a mask.

All current drawings do not require large amounts of CPU (virtually nothing), so maybe it's exaggerated, but adding any effects, it is completely a waste.. :S

However, I must admit that Cairo's new to me. I have to continue investigating.

Regards.
Comment 4 Eric Koegel editbugs 2014-10-14 18:18:37 CEST
Oh, interesting idea! About speeding it up, Xfdesktop gets a series of rectangles in xfdesktop_icon_view_expose and should just repaint the clipbox. I never looked to see if that ends up being the entire desktop... Perhaps we can improve that.

gdk_region_get_rectangles(evt->region, &rects, &n_rects);
gdk_region_get_clipbox(evt->region, &clipbox);

http://git.xfce.org/xfce/xfdesktop/tree/src/xfdesktop-icon-view.c#n2062
Comment 5 Matias De lellis 2014-10-14 19:47:01 CEST
Ok.
I have no idea how this clipbox work but will investigate.. :S

However observe that always finishes running the function  "xfdesktop_icon_view_paint_icon()"

On this function create a cairo_t, using the screen region.
> cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget))); // Note that widget = GTK_WIDGET(icon_view);
* http://git.xfce.org/xfce/xfdesktop/tree/src/xfdesktop-icon-view.c#n2994

..and this is used to build the shadow:
http://git.xfce.org/xfce/xfdesktop/tree/src/xfdesktop-icon-view.c#n3065

The rest of the drawings seems that is better controlled, and is made by drawing regions, but not here that uses the entire region.

In my tests apply the blur to this cairo_t.. :S
Comment 6 Matias De lellis 2014-10-14 23:04:33 CEST
Created attachment 5692 
[Patch] Implement optional blur to shadow on icons text

Changes since first patch:
* Crop bluring area, fixing the performance problem.
* Move all gtk+-3 code to the same file, and add a note on their origin.
* Only blur when radius > 1
Comment 7 Matias De lellis 2014-10-14 23:21:27 CEST
Hi Eric,
Now works correctly except that the shadow is a little trimmed on right.
Would have to extend the GdkRectangle text_extents to be a bit bigger and fit all the shade. I tried, but it moves the text. :(

Ahh.. to test you must add:

XfdesktopIconView::shadow-blur-radius = 2

to xfdesktop-icon-view style of your gtk2 favorite theme. =)
Comment 8 Matias De lellis 2014-10-14 23:49:26 CEST
Created attachment 5693 
[Patch] Implement optional blur to shadow on icons text

Fixes the cut on shadow.
Comment 9 Eric Koegel editbugs 2014-10-15 18:36:35 CEST
Thanks! Pushed to master in:
http://git.xfce.org/xfce/xfdesktop/commit/?id=7e8e8669606e662d1ee1e85815000f068f48acd9

Minor note, in the future you may want to make the git commit header look a little nicer (I know I'm not a great example). Naturally I can't find a good tutorial right away but something like:

Add optional blurring on shadow on text of icons. 

In general backported gtk+-3 code to implement it.. Add a new property called "shadow-blur-radius" on gtkrc file. If the "shadow-blur-radius" does not exist or is zero, it is shaded as before. If greater than 1, applies blur.

So it looks more like: 
http://git.xfce.org/xfce/thunar/commit/?id=6a63d7bd8ff0d937cb30f112c3fd080a5a107053
instead of:
http://git.xfce.org/xfce/xfdesktop/commit/?id=7e8e8669606e662d1ee1e85815000f068f48acd9

But it's obviously not a big deal, thanks again for your work!
Comment 10 Matias De lellis 2014-10-15 23:26:55 CEST
Thank you for even considering my changes!. ;)
The next step that I want to do is center the text on icons.

About the commits descriptions, I have to improve. I usually write mere titles, and in this case I wanted to add an explanation of the new property, but I forget to cut it correctly and also is nice add the number of bug involved.

MM.. Maybe also we should add this to the README

One detail that I just saw on the commit.
http://git.xfce.org/xfce/xfdesktop/tree/src/xfdesktop-icon-view.c#n2994

This cairo_save(cr) should be made before cut the cairo on line:

http://git.xfce.org/xfce/xfdesktop/tree/src/xfdesktop-icon-view.c#n2989

It not affect in anything, due it is the last use of cairo_t, but is a good detail save the state before modifying.. ;S

If you want I can make another patch, but it is fast, and I can not do it until a few hours. :s

Regards.
Comment 11 Matias De lellis 2014-10-16 17:44:46 CEST
Created attachment 5694 
Add description on Readme and a minor fix to previus path.

* Add a description of the property shadow-blur-radius on README file
* Ensure that shadow_blur_radius > 1 before call to paint the shadow.
* Save the cairo_t before change it, and so can be recovered correctly.

About the description, please review it. Talk About the use of cpu, and maybe something alarmist. haha.. ;)
Comment 12 Eric Koegel editbugs 2014-10-16 18:08:33 CEST
Description looks good. I was just about to reply when this came in, great timing! Pushed to master.

Thanks again for writing the patches! The next dev release might be all your work at this rate :)
Comment 13 Matias De lellis 2015-02-12 01:01:28 CET
Created attachment 5930 
Add 1px to widen the text shadow and improve contrast.

Hi Eric,
I hope you get this!.

You notice that the shadow are very clear and become invisible when use blur?.

This patch only adds a pixel around the letters to widen it a bit, and when applying the bluring, the shadow is much stronger improving the visibility of text.

Now also upload a screenshot so you can see the difference.
Comment 14 Matias De lellis 2015-02-12 01:03:22 CET
Created attachment 5931 
Before and after the new patch

Before and after the new patch.. Both with a 2-pixel blur and 1px offset.
Comment 15 Eric Koegel editbugs 2015-02-13 20:19:54 CET
Looks good, pushed to master in:
commit 9ac6329aa6451f261fc366901492eb002de8d62c
Author: Matias De lellis <mati86dl@gmail.com>
Date:   Wed Feb 11 20:14:00 2015 -0300

    Add 1px to widen the text shadow and improve contrast.

http://git.xfce.org/xfce/xfdesktop/commit/?id=9ac6329aa6451f261fc366901492eb002de8d62c

Bug #11228

Reported by:
Matias De lellis
Reported on: 2014-10-10
Last modified on: 2015-02-13

People

Assignee:
Eric Koegel
CC List:
1 user

Version

Version:
Unspecified

Attachments

Additional information