Re: gtk_widget_queue_draw_area much slower in gtk3 than gtk3



hi Emmanuele, everybody else,

First of all, let me thank your giving us a hand with this.

On Mon, Mar 30, 2015 at 5:22 AM, Emmanuele Bassi <ebassi gmail com> wrote:
So far the functionality is there, but we have been hit by a major
problem in both apps: gtk3 is much slower rendering to the canvas than
gtk2.

I'm very sceptical about this conclusion…

I have tried to track this problem down, and my experiments suggest
that it is the call to

gtk_widget_queue_draw_area

We draw a segment of a line  using cairo, but it does not get drawn
to the screen until gtk_widget_queue_draw_area is called. Which is
fine. But under gtk3
it really slows down sampling of the stylus.

… Because you're talking about events.

Motion events are compressed in GTK+; they get collected and pushed to
the application code once per frame, because you cannot obviously
paint any faster than what your display can show, and because the vast
majority of applications do not draw content in response to fine event
delivery.

Please see this: https://github.com/xournalpp/xournalpp/issues/109
it exemplifies the problem we have from gtk2 to gtk3.

I did a small test. I tried to draw a curve during 1 second. And the
results seem to support this as the reason.

 in the motion notify event our logic is the following:

1- We gather the coordinates of the new point
2- Using cairo we draw the new line segment directly onto the canvas
3- We then compute the area that the new segment occupies
4- We call gtk_widget_queue_draw_area synchronously

When 4 is removed, sampling increases significantly and we no longer
have the problem but now the screen is not refreshed immediately. It
is random when the refresh is.

gdk_window_set_event_compression to false does not seem to make any
difference on this (I am using gtk3 version 3.12 Ubuntu 14.10)

It seems to me that the problem is the that we call
gtk_widget_queue_draw_area every time we have a segment.

The refresh rate of rendering seems to imply that we can only call
gtk_widget_queue_draw once every 1/60s. (or whatever refresh rate the
computer has)
but what would be the best way to do this? If the user is drawing at a
rate of one point in less than 1/60s then do not use
gtk_widget_queue_draw.
otherwise use it.


thanks again for all your valuable help,

--dmg


You have two options:

 * use the event history for the devices you're interested in
 * disable motion event compression on the GdkWindow that you're using
to detect events, and build up the positions you will then draw

Other painting applications opted for the latter solution, so you
should likely explore it first; see the API reference:

  https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#gdk-window-set-event-compression

Ciao,
 Emmanuele.




-- 
--dmg

---
Daniel M. German
http://turingmachine.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]