XFlush will just flush the buffers, while XSync will also get a reply
from server, besides flushing the buffers. XSync would cause a "round
trip", and be slower over network. We use XSync before recycling Scratch
images, so that we could be sure that all drawing operations on the shared
XImage/Pixmap were finished. Is that right? --Jianjun > -----邮件原件----- > 发件人: Owen Taylor [mailto:otaylor redhat com] > 发送时间: > 收件人: jianjun.yang > 抄送: > 主题: Re: why not empty the scratch image when flush_all_displays > > On Mon, > > Hi All, > > > > > > > > When gdk_window_process_all_updates, flush_all_displays is invoked. > > Then all the drawing commands are sent to server. Meanwhile, I think > > the contents of the scratch image corresponding current display are no > > longer useful, and should be thrown away. Otherwise, it may increase > > the frequency of invoking to gdk_flush while alloc_scratch_image. So I > > add the gdk_scratch_image_reset to gdk_window_process_all_updates. > > gdk_display_flush() [what flush_all_displays() does] actually calls > XFlush(), unlike gdk_flush(), which for weird historical reasons > calls XSync. > > Scratch images can only be recycled after XSync(), not after XFlush(). > > (To reduce the calls to XSync() used with the scratch image cache you > *could* watch for XShmCompletionEvent, though I don't think the > improvement would be that big.) > > - Owen |