[RFC] Off-by-one in linkmap cairo drawing ?

View: New views
6 Messages — Rating Filter:   Alert me  

[RFC] Off-by-one in linkmap cairo drawing ?

by Vincent Legoll :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

could someone please comment on the validity of:

Attachment #133349: maybe this one is more complete
for bug #580311

The screenshots were taken with the first (obsoleted) patch

What are all those magical 0.5 values for anyways ?

--
Vincent Legoll

[fix-cairo-linkmap-drawing2.patch]

diff --git a/filediff.py b/filediff.py
index ac5063c..cf2979f 100644
--- a/filediff.py
+++ b/filediff.py
@@ -1116,8 +1116,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             return [self._pixel_to_line(idx, pix_start[idx]), self._pixel_to_line(idx, pix_start[idx]+htotal)]
         visible = [None] + bounds(which) + bounds(which+1)
 
+        adjust = 0
+
         # For bezier control points
-        x_steps = [-0.5, (1. / 3) * wtotal, (2. / 3) * wtotal, wtotal + 0.5]
+        x_steps = [-adjust, (1. / 3) * wtotal, (2. / 3) * wtotal, wtotal + adjust]
 
         def paint_pixbuf_at(pixbuf, x, y):
             context.translate(x, y)
@@ -1148,14 +1150,14 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             if t0 == t1:
                 t0 -= 1
 
-            context.move_to(x_steps[0], f0 - 0.5)
-            context.curve_to(x_steps[1], f0 - 0.5,
-                             x_steps[2], t0 - 0.5,
-                             x_steps[3], t0 - 0.5)
-            context.line_to(x_steps[3], t1 + 0.5)
-            context.curve_to(x_steps[2], t1 + 0.5,
-                             x_steps[1], f1 + 0.5,
-                             x_steps[0], f1 + 0.5)
+            context.move_to(x_steps[0], f0 - adjust)
+            context.curve_to(x_steps[1], f0 - adjust,
+                             x_steps[2], t0 - adjust,
+                             x_steps[3], t0 - adjust)
+            context.line_to(x_steps[3], t1 + adjust)
+            context.curve_to(x_steps[2], t1 + adjust,
+                             x_steps[1], f1 + adjust,
+                             x_steps[0], f1 + adjust)
             context.close_path()
 
             context.set_source_rgb(*self.fill_colors[c[0]])
@@ -1171,8 +1173,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
                 paint_pixbuf_at(pix0, 0, f0)
 
         # allow for scrollbar at end of textview
-        mid = int(0.5 * self.textview[0].allocation.height) + 0.5
-        context.set_source_rgba(0., 0., 0., 0.5)
+        mid = int(adjust * self.textview[0].allocation.height) + adjust
+        context.set_source_rgba(0., 0., 0., adjust)
         context.move_to(.35 * wtotal, mid)
         context.line_to(.65 * wtotal, mid)
         context.stroke()


_______________________________________________
meld-list mailing list
meld-list@...
http://mail.gnome.org/mailman/listinfo/meld-list

Re: [RFC] Off-by-one in linkmap cairo drawing ?

by Stephen Kennedy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think they may have been due to some strangeness in the way
cairo did antialiasing. See the original commit
http://git.gnome.org/cgit/meld/commit/?id=ca289a59a7e3a4dc690ecf7aa7606700dc246835
I didn't track down where 0.2 became 0.5

That was quite tedious to find using cgit and gitk. Does anybody
know is it not possible with git to jump directly to the diff which
corresponds to a given line of a given revision? e.g. like:
http://svn.gnome.org/viewvc/meld/trunk/filediff.py?annotate=1331&pathrev=1333

Stephen.

On Sun, Apr 26, 2009 at 6:22 PM, Vincent Legoll
<vincent.legoll@...> wrote:

> Hello,
>
> could someone please comment on the validity of:
>
> Attachment #133349: maybe this one is more complete
> for bug #580311
>
> The screenshots were taken with the first (obsoleted) patch
>
> What are all those magical 0.5 values for anyways ?
>
> --
> Vincent Legoll
>
> _______________________________________________
> meld-list mailing list
> meld-list@...
> http://mail.gnome.org/mailman/listinfo/meld-list
>
_______________________________________________
meld-list mailing list
meld-list@...
http://mail.gnome.org/mailman/listinfo/meld-list

Parent Message unknown Re: [RFC] Off-by-one in linkmap cairo drawing ?

by Kristi-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Using the command line, "git blame" will annotate the file for you.
Too bad cgit doesn't have an interface for this.
~Kristi

> Date: Tue, 28 Apr 2009 09:15:32 +0100
> From: Stephen Kennedy <stevek@...>
> Subject: Re: [RFC] Off-by-one in linkmap cairo drawing ?
> To: Vincent Legoll <vincent.legoll@...>
> Cc: meld-list <meld-list@...>
> Message-ID:
>        <ff6c57a20904280115v40987617n3663e87763707fa@...>
> Content-Type: text/plain; charset=UTF-8
>
> I think they may have been due to some strangeness in the way
> cairo did antialiasing. See the original commit
> http://git.gnome.org/cgit/meld/commit/?id=ca289a59a7e3a4dc690ecf7aa7606700dc246835
> I didn't track down where 0.2 became 0.5
>
> That was quite tedious to find using cgit and gitk. Does anybody
> know is it not possible with git to jump directly to the diff which
> corresponds to a given line of a given revision? e.g. like:
> http://svn.gnome.org/viewvc/meld/trunk/filediff.py?annotate=1331&pathrev=1333
>
> Stephen.
>
> On Sun, Apr 26, 2009 at 6:22 PM, Vincent Legoll
> <vincent.legoll@...> wrote:
>> Hello,
>>
>> could someone please comment on the validity of:
>>
>> Attachment #133349: maybe this one is more complete
>> for bug #580311
>>
>> The screenshots were taken with the first (obsoleted) patch
>>
>> What are all those magical 0.5 values for anyways ?
>>
>> --
>> Vincent Legoll
>>
>> _______________________________________________
>> meld-list mailing list
>> meld-list@...
>> http://mail.gnome.org/mailman/listinfo/meld-list
>>
_______________________________________________
meld-list mailing list
meld-list@...
http://mail.gnome.org/mailman/listinfo/meld-list

Re: [RFC] Off-by-one in linkmap cairo drawing ?

by Kai Willadsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/4/27 Vincent Legoll <vincent.legoll@...>:
> Hello,
>
> could someone please comment on the validity of:
>
> Attachment #133349: maybe this one is more complete
> for bug #580311
>
> The screenshots were taken with the first (obsoleted) patch

The horizontal line in your after-screenshots is blurred, which is
what the 0.5 adjustment fixes.

> What are all those magical 0.5 values for anyways ?

Rough answer: integer coordinates in Cairo fall between pixels, not on pixels
Longer answer: http://cairographics.org/FAQ/#sharp_lines

I changed the 0.2 to 0.5 a while back since the 0.2 was only there to
fix blurry rendering of straight lines, and for that purpose 0.5 is
what should actually be used.

As for the bug, the 'missing pixel' was the intended result at the
time. The idea is to indicate the insertion point of the diff, while
maintaining nice sharp straight lines where appropriate. I agree that
our rendering of these lines could be nicer... but if you play around
with different cases it quickly becomes non-trivial to get it right.
We should really decide how the lines *should* be placed, and then
figure out the rendering.

Kai
_______________________________________________
meld-list mailing list
meld-list@...
http://mail.gnome.org/mailman/listinfo/meld-list

history digging with git (was: [RFC] Off-by-one in linkmap cairo drawing ?)

by Martin Renold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi Stephen,

On Tue, Apr 28, 2009 at 09:15:32AM +0100, Stephen Kennedy wrote:
> That was quite tedious to find using cgit and gitk. Does anybody
> know is it not possible with git to jump directly to the diff which
> corresponds to a given line of a given revision? e.g. like:
> http://svn.gnome.org/viewvc/meld/trunk/filediff.py?annotate=1331&pathrev=1333

I was looking for the same thing for some time now, and I have not found a
single program that does it.  But I discovered something even better!

Git allows you to grep through all diffs. In your example, I saw the comment
"bezier" above the code of interest, and, using this as an "anchor keyword",

git log -p -Sbezier

finds just the change you were looking for. It shows both commit message and
patch, and is quite fast.  This command opens a tiny new paradise for
history digging.  I'm finally starting to enjoy git...

bye,
Martin
_______________________________________________
meld-list mailing list
meld-list@...
http://mail.gnome.org/mailman/listinfo/meld-list

Re: history digging with git (was: [RFC] Off-by-one in linkmap cairo drawing ?)

by Stephen Kennedy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, May 13, 2009 at 9:49 PM, Martin Renold <martinxyz@...> wrote:

> On Tue, Apr 28, 2009 at 09:15:32AM +0100, Stephen Kennedy wrote:
>> That was quite tedious to find using cgit and gitk. Does anybody
>> know is it not possible with git to jump directly to the diff which
>> corresponds to a given line of a given revision? e.g. like:
>> http://svn.gnome.org/viewvc/meld/trunk/filediff.py?annotate=1331&pathrev=1333
>
> I was looking for the same thing for some time now, and I have not found a
> single program that does it.  But I discovered something even better!
>
> Git allows you to grep through all diffs. In your example, I saw the comment
> "bezier" above the code of interest, and, using this as an "anchor keyword",
>
> git log -p -Sbezier

Thanks Martin, that's a good trick to know. I recently found that qgit can do
a reasonable job. Turn on the tree view (T), then you get an annotated file
history by double clicking a file. Double clicking a line goes to the commit
which introduced that line and you can view it with (Ctrl+P).

Stephen.
_______________________________________________
meld-list mailing list
meld-list@...
http://mail.gnome.org/mailman/listinfo/meld-list