Skip to content

Commit

Permalink
#2481 now that we always do a refresh, make sure that it is efficient…
Browse files Browse the repository at this point in the history
…: accumulate the areas and use a single idle_add call to process all of them, don't call present_fbo from the paint code - only from the refresh timer

git-svn-id: https://xpra.org/svn/Xpra/trunk@24434 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Nov 17, 2019
1 parent 08cd23a commit e10483e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
44 changes: 26 additions & 18 deletions src/xpra/client/client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
alphalog = Logger("alpha")


REPAINT_ALL = os.environ.get("XPRA_REPAINT_ALL", "")
REPAINT_ALL = envbool("XPRA_REPAINT_ALL", False)
SIMULATE_MOUSE_DOWN = envbool("XPRA_SIMULATE_MOUSE_DOWN", True)
PROPERTIES_DEBUG = [x.strip() for x in os.environ.get("XPRA_WINDOW_PROPERTIES_DEBUG", "").split(",")]
AWT_DIALOG_WORKAROUND = envbool("XPRA_AWT_DIALOG_WORKAROUND", WIN32)
Expand Down Expand Up @@ -76,6 +76,7 @@ def __init__(self, client, group_leader, watcher_pid, wid,
self.button_state = {}
self.pixel_depth = pixel_depth #0 for default
self.window_offset = None #actual vs reported coordinates
self.pending_refresh = []

self.init_window(metadata)
self.setup_window(bw, bh)
Expand Down Expand Up @@ -646,27 +647,34 @@ def draw_region(self, x, y, width, height, coding, img_data, rowstride, _packet_
from xpra.client.window_backing_base import fire_paint_callbacks
fire_paint_callbacks(callbacks, -1, "no backing")
return
def after_draw_refresh(success, message=""):
plog("after_draw_refresh(%s, %s) %sx%s at %sx%s encoding=%s, options=%s",
success, message, width, height, x, y, coding, options)
if success<=0:
return
backing = self._backing
if backing and (backing.draw_needs_refresh or REPAINT_ALL):
if REPAINT_ALL=="1" or self._client.xscale!=1 or self._client.yscale!=1 or is_Wayland():
rw, rh = self.get_size()
rx, ry = 0, 0
else:
rx, ry, rw, rh = self._client.srect(x, y, width, height)
#if self.window_offset:
# rx -= self.window_offset[0]
# ry -= self.window_offset[1]
self.idle_add(self.queue_draw_area, rx, ry, rw, rh)
#only register this callback if we actually need it:
if backing.draw_needs_refresh:
callbacks.append(after_draw_refresh)
if not REPAINT_ALL:
self.pending_refresh.append((x, y, width, height))
if options.intget("flush", 0)==0:
callbacks.append(self.after_draw_refresh)
backing.draw_region(x, y, width, height, coding, img_data, rowstride, options, callbacks)

def after_draw_refresh(self, success, message=""):
plog("after_draw_refresh(%s, %s) pending_refresh=%s",
success, message, self.pending_refresh)
backing = self._backing
if not backing:
return
if REPAINT_ALL or self._client.xscale!=1 or self._client.yscale!=1 or is_Wayland():
#easy: just repaint the whole window:
rw, rh = self.get_size()
self.idle_add(self.queue_draw_area, 0, 0, rw, rh)
return
pr = self.pending_refresh
self.pending_refresh = []
for x, y, w, h in pr:
rx, ry, rw, rh = self._client.srect(x, y, w, h)
#if self.window_offset:
# rx -= self.window_offset[0]
# ry -= self.window_offset[1]
self.idle_add(self.queue_draw_area, rx, ry, rw, rh)

def eos(self):
""" Note: this runs from the draw thread (not UI thread) """
backing = self._backing
Expand Down
9 changes: 6 additions & 3 deletions src/xpra/client/gl/gl_window_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ def fail(msg):
glBindTexture(target, 0)
glDisable(target)
fire_paint_callbacks(callbacks, True)
self.present_fbo(0, 0, bw, bh, flush)
if not self.draw_needs_refresh:
self.present_fbo(0, 0, bw, bh, flush)

def copy_fbo(self, w, h, sx=0, sy=0, dx=0, dy=0):
#copy from offscreen to tmp:
Expand Down Expand Up @@ -1041,7 +1042,8 @@ def do_paint_rgb(self, rgb_format, img_data, x, y, width, height, rowstride, opt
glDisable(target)
self.paint_box(options.strget("encoding"), options.intget("delta", -1)>=0, x, y, width, height)
# Present update to screen
self.present_fbo(x, y, width, height, options.intget("flush", 0))
if not self.draw_needs_refresh:
self.present_fbo(x, y, width, height, options.intget("flush", 0))
# present_fbo has reset state already
fire_paint_callbacks(callbacks)
return
Expand Down Expand Up @@ -1095,7 +1097,8 @@ def gl_paint_planar(self, shader, flush, encoding, img,
self.paint_box(encoding, False, x, y, width, height)
fire_paint_callbacks(callbacks, True)
# Present it on screen
self.present_fbo(x, y, width, height, flush)
if not self.draw_needs_refresh:
self.present_fbo(x, y, width, height, flush)
img.free()
return
except GLError as e:
Expand Down

0 comments on commit e10483e

Please sign in to comment.