After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 567249 - gsd-media-keys-window.c: cairo drawings are misaligned
gsd-media-keys-window.c: cairo drawings are misaligned
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: plugins
2.25.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2009-01-10 12:40 UTC by Andrea Cimitan
Modified: 2009-10-27 20:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
This patch fixes the problem. (787 bytes, patch)
2009-02-15 17:25 UTC, Leo Iannacone
committed Details | Review
zoomed screenshot (2.65 KB, image/png)
2009-09-09 17:31 UTC, Andrea Cimitan
  Details
Fix bluriness in level bar, and popup (2.67 KB, patch)
2009-10-26 14:58 UTC, Bastien Nocera
none Details | Review
Fix bluriness in level bar, and popup (3.06 KB, patch)
2009-10-26 15:21 UTC, Bastien Nocera
accepted-commit_now Details | Review
Fix bluriness in level bar, and popup (2.90 KB, patch)
2009-10-26 23:42 UTC, Bastien Nocera
none Details | Review
Fix bluriness in level bar, and popup (2.48 KB, patch)
2009-10-27 14:34 UTC, Bastien Nocera
committed Details | Review

Description Andrea Cimitan 2009-01-10 12:40:17 UTC
The cairo drawings are misaligned when the screen is composited.
See the borders of the window, see the volume bar: the edges are not pixel-aligned.
First of all I'm not sure you should use doubles, because double precision is not needed since we're drawing pixels (int).

To fix, for example the window's borders, try to draw x+0.5, y+.5, width-1, height-1, (height-1)/10. You'll see how the borders will be aligned
Comment 1 Jens Granseuer 2009-01-11 10:44:28 UTC
I don't actually see anything... because I cannot use compositing. Now, since guessing what you mean probably isn't the best way to go about this, and since yu already seem to have an idea of how to fix it, how about a screenshot and a patch instead? Thanks.
Comment 2 Leo Iannacone 2009-02-15 17:25:27 UTC
Created attachment 128783 [details] [review]
This patch fixes the problem.

Cimi is right, following his suggestion I wrote the patch.

Now curved_rectangle is fine.
Comment 3 Jens Granseuer 2009-02-15 18:17:54 UTC
Thanks for the patch. Since, as I mentioned before, I cannot actually test the patch, I'm going to take your word for it.

2009-02-15  Jens Granseuer  <...>

        Patch by: Leo Iannacone <...>

        * plugins/media-keys/gsd-media-keys-window.c: (on_expose_event): fix
        alignment of the composited media window (bug #567249)
Comment 4 Andrea Cimitan 2009-02-15 18:27:31 UTC
I guess the volume bar is not fixed yet... Leo, could you fix it too? The approach is similar: you should align the drawings to the cairo grid.
Comment 5 Bastien Nocera 2009-09-09 16:28:53 UTC
Andrea, I can't see the misalignment I'm afraid.

Can you take a screenshot and show us where the bug is?
To take a screenie, in gnome-settings-daemon/plugin/media-keys:
- in gsd-media-keys-window.c, remove the code that sets fade_timeout_id:
+//                window->priv->fade_timeout_id = g_timeout_add (FADE_TIMEOUT,
+//                                                               (GSourceFunc) fade_timeout,
+//                                                               window);
- in test-media-window.c, remove the g_timeout_add() code
- and change the call to gsd_media_keys_window_set_volume_level() to set the level you know shows the problem (say, 50?)
- launch test-media-window and take a screenshot
Comment 6 Andrea Cimitan 2009-09-09 17:31:35 UTC
Created attachment 142813 [details]
zoomed screenshot

As you can see, the borders of the progressbar have 1px of "transparent" border, that's because it is not aligned to the cairo pixel grid. (0.5 px is drawn outside, and 0.5 on the border)
Comment 7 Bastien Nocera 2009-10-26 14:58:45 UTC
Created attachment 146271 [details] [review]
Fix bluriness in level bar, and popup

By shifting the top-left coordinates by half a pixel, to match
the cairo grid.

This makes the outter border of the popup, as well as the
level bar's borders much sharper.
Comment 8 Bastien Nocera 2009-10-26 15:21:51 UTC
Created attachment 146272 [details] [review]
Fix bluriness in level bar, and popup

By shifting the top-left coordinates by half a pixel, to match
the cairo grid.

This makes the outter border of the popup, as well as the
level bar's borders much sharper.
Comment 9 Bastien Nocera 2009-10-26 18:18:22 UTC
Waiting on Andrea, or Martin (on fedora-desktop-list) to confirm that the fix works for them.
Comment 10 Martin Sourada 2009-10-26 20:05:45 UTC
(In reply to comment #8)
> Created an attachment (id=146272) [details] [review]
> Fix bluriness in level bar, and popup
> 
> By shifting the top-left coordinates by half a pixel, to match
> the cairo grid.
> 
> This makes the outter border of the popup, as well as the
> level bar's borders much sharper.
On quick look:
-        x1 = x0 + width;
-        y1 = y0 + height;
-
         if (!width || !height) {
                 return;
         }
 
+        x1 = x0 + width;
+        y1 = y0 + height;
+
^^^ this is irrelevant change

The round () should work for the level bar, not sure if you're using the sizes for anything else (why are you rounding the icon_box_*  as well?).

-                           volume_box_x0,
-                           volume_box_y0,
+                           volume_box_x0 + 0.5,
+                           volume_box_y0 + 0.5,
^^^ I'd prefer adjusting this in draw_volume_boxes() as you need to also adjust the value indication fill (that does not have border so it needs to be drawn on integer coordinates and with 0.5 smaller roundness). Don't forget to also width/height - 1 for the main rect and width/height - 2 for the value fill.

-        curved_rectangle (cr, 0.5, 0.5, width-1, height-1, height / 10);
+        curved_rectangle (cr, 0.5, 0.5, width-0.5, height-0.5, round (height / 10));
^^^ this would break the previous patch. Width and heights are relative, not coordinates of the opposite corner, so you should be actually doing width/height - 2*0.5 (once from top/left and once from bottom/right). There's no need to round the radius -- non-integer radius does not make things blurry.
Comment 11 Bastien Nocera 2009-10-26 23:42:07 UTC
Created attachment 146305 [details] [review]
Fix bluriness in level bar, and popup

By shifting the top-left coordinates by half a pixel, to match
the cairo grid.

This makes the outter border of the popup, as well as the
level bar's borders much sharper.
Comment 12 Bastien Nocera 2009-10-26 23:43:19 UTC
Had to make the width smaller as it would overflow onto the border otherwise.

Looked at all that under a magnifying glass and it looks OK to me. Comments?
Comment 13 Martin Sourada 2009-10-27 00:10:50 UTC
(In reply to comment #11)
> Created an attachment (id=146305) [details] [review]
> Fix bluriness in level bar, and popup
> 
+        height = round (height);
^^^ aren't you forgetting to round width as well? IMHO, both should be further decreased by one (the drawing function adds half of the border on each side making it effectively 1px larger)

+        x1 = round (width * percentage - 1.5);
+        x1 = (x1 >= 0 ? x1 : 0);
^^^ IMHO, should be just
+        x1 = round ((width - 1)*percentage); 
you should first correctly get available width (which is width - 1) and then derive the percentage.

-        curved_rectangle (cr, 0.5, 0.5, width-1, height-1, height / 10);
+        curved_rectangle (cr, 0.5, 0.5, width-1, height-1, round (height / 10));
^^^ As I said in my previous comment, the rounding here isn't needed (it's corner radius setting which does not need to be integer)
Comment 14 Bastien Nocera 2009-10-27 14:34:12 UTC
Created attachment 146338 [details] [review]
Fix bluriness in level bar, and popup

By shifting the top-left coordinates by half a pixel, to match
the cairo grid.

This makes the outter border of the popup, as well as the
level bar's borders much sharper.
Comment 15 Bastien Nocera 2009-10-27 14:34:51 UTC
(In reply to comment #13)
> (In reply to comment #11)
> > Created an attachment (id=146305) [details] [review] [details] [review]
> > Fix bluriness in level bar, and popup
> > 
> +        height = round (height);
> ^^^ aren't you forgetting to round width as well?

No, the width is icon_box_width, which is already rounded. I'll round it to avoid this sort of confusion.

> IMHO, both should be further
> decreased by one (the drawing function adds half of the border on each side
> making it effectively 1px larger)

Done.

> +        x1 = round (width * percentage - 1.5);
> +        x1 = (x1 >= 0 ? x1 : 0);
> ^^^ IMHO, should be just
> +        x1 = round ((width - 1)*percentage); 
> you should first correctly get available width (which is width - 1) and then
> derive the percentage.

Done.

> -        curved_rectangle (cr, 0.5, 0.5, width-1, height-1, height / 10);
> +        curved_rectangle (cr, 0.5, 0.5, width-1, height-1, round (height /
> 10));
> ^^^ As I said in my previous comment, the rounding here isn't needed (it's
> corner radius setting which does not need to be integer)

Done.
Comment 16 Martin Sourada 2009-10-27 20:14:53 UTC
Looks OK now, I don't have any further comments.
Comment 17 Bastien Nocera 2009-10-27 20:35:44 UTC
Attachment 146338 [details] pushed as fadc8f8 - Fix bluriness in level bar, and popup