From 9988cbd50a2189b8d5de66a4eda2d8f68424d380 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Thu, 2 May 2024 14:05:52 +0700 Subject: [PATCH] use cairo scaling if none of the csc modules can handle it limited backport of 65bb2fd632f381077fc5b11bae6a67cd3336ff8d --- xpra/client/gui/window_backing_base.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xpra/client/gui/window_backing_base.py b/xpra/client/gui/window_backing_base.py index 0d8db47c56..1cbd40ac60 100644 --- a/xpra/client/gui/window_backing_base.py +++ b/xpra/client/gui/window_backing_base.py @@ -691,10 +691,14 @@ def make_csc(self, src_width: int, src_height: int, src_format: str, if not specs: continue for spec in specs: + score = - (spec.quality + spec.speed + spec.score_boost) + if not spec.can_scale and (src_width != dst_width or src_height != dst_height): + # prefer csc scaling to cairo's own scaling + score += 100 v = self.validate_csc_size(spec, src_width, src_height, dst_width, dst_height) if v: + # not suitable continue - score = - (spec.quality + spec.speed + spec.score_boost) csc_scores.setdefault(score, []).append((dst_format, spec)) videolog(f"csc scores: {csc_scores}") @@ -712,8 +716,10 @@ def make_csc(self, src_width: int, src_height: int, src_format: str, for dst_format, spec in csc_scores.get(score): try: csc = spec.codec_class() + width = dst_width if spec.can_scale else src_width + height = dst_height if spec.can_scale else src_height csc.init_context(src_width, src_height, src_format, - dst_width, dst_height, dst_format, options) + width, height, dst_format, options) return csc except Exception as e: videolog("make_csc%s", @@ -744,8 +750,6 @@ def make_csc(self, src_width: int, src_height: int, src_format: str, @staticmethod def validate_csc_size(spec, src_width: int, src_height: int, dst_width: int, dst_height: int): - if not spec.can_scale and (src_width != dst_width or src_height != dst_height): - return "scaling not supported" if src_width < spec.min_w: return "source width %i is out of range: minimum is %i", src_width, spec.min_w if src_height < spec.min_h: @@ -889,10 +893,12 @@ def do_video_paint(self, img, x: int, y: int, enc_width: int, enc_height: int, w def paint(): data = rgb.get_pixels() + rgb_width = rgb.get_width() + rgb_height = rgb.get_height() rowstride = rgb.get_rowstride() try: self.do_paint_rgb(rgb_format, data, - x, y, width, height, width, height, rowstride, paint_options, callbacks) + x, y, rgb_width, rgb_height, width, height, rowstride, paint_options, callbacks) finally: rgb.free()