xpra icon
Bug tracker and wiki

Ticket #981: sync-paint-with-video-v6.patch

File sync-paint-with-video-v6.patch, 6.8 KB (added by Antoine Martin, 4 years ago)

adds the ability to toggle flush using an env var

  • xpra/client/ui_client_base.py

     
    29082908                decode_time = int(end*1000*1000-start*1000*1000)
    29092909                self.pixel_counter.append((start, end, width*height))
    29102910                dms = "%sms" % (int(decode_time/100)/10.0)
    2911                 paintlog("record_decode_time(%s, %s) wid=%s, %s: %sx%s, %s", success, message, wid, coding, width, height, dms)
     2911                paintlog.info("record_decode_time(%s, %s) wid=%s, %s: %sx%s, %s", success, message, wid, coding, width, height, dms)
    29122912            elif success==0:
    29132913                decode_time = -1
    29142914                paintlog("record_decode_time(%s, %s) decoding error on wid=%s, %s: %sx%s", success, message, wid, coding, width, height)
  • xpra/server/window/window_source.py

     
    12141214        if not self.is_cancelled():
    12151215            self.do_send_delayed_regions(damage_time, window, regions, coding, options)
    12161216
    1217     def do_send_delayed_regions(self, damage_time, window, regions, coding, options, exclude_region=None, get_best_encoding=None):
     1217    def do_send_delayed_regions(self, damage_time, window, regions, coding, options, exclude_region=None, get_best_encoding=None, flush_offset=0):
    12181218        ww,wh = window.get_dimensions()
    12191219        speed = options.get("speed") or self._current_speed
    12201220        quality = options.get("quality") or self._current_quality
     
    12821282                log("send_delayed_regions: %s regions with %s pixels (encoding=%s, actual=%s)", len(regions), pixel_count, coding, actual_encoding)
    12831283                if pixel_count>=ww*wh or self.must_encode_full_frame(window, actual_encoding):
    12841284                    #use full screen dimensions:
    1285                     self.process_damage_region(damage_time, window, 0, 0, ww, wh, actual_encoding, options)
     1285                    self.process_damage_region(damage_time, window, 0, 0, ww, wh, actual_encoding, options, flush=flush_offset)
    12861286                    return
    12871287
    12881288        #we're processing a number of regions separately,
     
    13021302                self.process_damage_region(damage_time, window, 0, 0, ww, wh, actual_encoding, options)
    13031303                #we can stop here (full screen update will include the other regions)
    13041304                return
    1305             i_reg_enc.append((i, region, actual_encoding))
     1305            i_reg_enc.append((flush_offset+i, region, actual_encoding))
    13061306
    13071307        #reversed so that i=0 is last for flushing
    13081308        for i, region, actual_encoding in reversed(i_reg_enc):
  • xpra/server/window/window_video_source.py

     
    4343SCALING_HARDCODED = parse_scaling_value(os.environ.get("XPRA_SCALING_HARDCODED", ""))
    4444
    4545VIDEO_SUBREGION = os.environ.get("XPRA_VIDEO_SUBREGION", "1")=="1"
     46FLUSH_WITH_VIDEO = os.environ.get("XPRA_FLUSH_WITH_VIDEO", "1")=="1"
    4647
    4748
    4849class WindowVideoSource(WindowSource):
     
    449450    def must_batch(self, delay):
    450451        #force batching when using video region
    451452        #because the video region code is in the send_delayed path
     453        #and because we want to flush all the paints with the video
    452454        return self.video_subregion.rectangle is not None or WindowSource.must_batch(self, delay)
    453455
    454456
     
    534536        """
    535537        #overrides the default method for finding the encoding of a region
    536538        #so we can ensure we don't use the video encoder when we don't want to:
    537         def send_nonvideo(regions=regions, encoding=coding, exclude_region=None, get_best_encoding=self.get_best_nonvideo_encoding):
    538             WindowSource.do_send_delayed_regions(self, damage_time, window, regions, encoding, options, exclude_region=exclude_region, get_best_encoding=get_best_encoding)
     539        def send_nonvideo(regions=regions, encoding=coding, exclude_region=None, get_best_encoding=self.get_best_nonvideo_encoding, flush_offset=0):
     540            WindowSource.do_send_delayed_regions(self, damage_time, window, regions, encoding, options, exclude_region=exclude_region, get_best_encoding=get_best_encoding, flush_offset=flush_offset)
    539541
    540542        if self.is_tray:
    541543            sublog("BUG? video for tray - don't use video region!")
     
    589591                    if len(same_c)==1:
    590592                        actual_vr = same_c[0]
    591593
    592         if actual_vr is None:
    593             sublog("send_delayed_regions: video region %s not found in: %s", vr, regions)
    594         else:
    595             #found the video region:
     594        def send_vr():
     595            if not actual_vr:
     596                return
    596597            #send this using the video encoder:
    597598            video_options = options.copy()
    598599            video_options["av-sync"] = True
    599600            self.process_damage_region(damage_time, window, actual_vr.x, actual_vr.y, actual_vr.width, actual_vr.height, coding, video_options, 0)
    600601
    601             #now substract this region from the rest:
     602        if actual_vr is None:
     603            sublog("send_delayed_regions: video region %s not found in: %s", vr, regions)
     604        else:
     605            #found the video region, substract it from the rest:
    602606            trimmed = []
    603607            for r in regions:
    604608                trimmed += r.substract_rect(actual_vr)
     609            sublog("send_delayed_regions: substracted %s from %s gives us %s", actual_vr, regions, trimmed)
    605610            if not trimmed:
    606                 sublog("send_delayed_regions: nothing left after removing video region %s", actual_vr)
     611                #nothing else to send:
     612                send_vr()
    607613                return
    608             sublog("send_delayed_regions: substracted %s from %s gives us %s", actual_vr, regions, trimmed)
    609614            regions = trimmed
     615            if not FLUSH_WITH_VIDEO:
     616                send_vr()
     617                actual_vr = None
    610618
    611619        #merge existing damage delayed region if there is one:
    612620        #(this codepath can fire from a video region refresh callback)
     
    627635            delay = max(self.batch_config.delay*4, 50)
    628636            delay = min(delay, self.video_subregion.non_max_wait-elapsed)
    629637        if delay<=25:
    630             send_nonvideo(regions=regions, encoding=None)
     638            send_nonvideo(regions=regions, encoding=None, flush_offset=int(actual_vr is not None))
     639            send_vr()
    631640        else:
    632641            self._damage_delayed = damage_time, window, regions, coding, options or {}
    633642            sublog("send_delayed_regions: delaying non video regions %s some more by %ims", regions, delay)