Skip to content

Commit

Permalink
#2052 part 1: tell the server about the client's render-size so the s…
Browse files Browse the repository at this point in the history
…erver can use the same size for video scaling

git-svn-id: https://xpra.org/svn/Xpra/trunk@26652 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 9, 2020
1 parent 9d68c24 commit 2beaa24
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/xpra/client/client_widget_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def make_new_backing(self, backing_class, ww, wh, bw, bh):
backing = bc(self._id, self._window_alpha, self.pixel_depth)
if self._client.mmap_enabled:
backing.enable_mmap(self._client.mmap)
obs = backing.render_size
if obs!=(ww, wh):
#tell the server about the window rendering geometry:
#(so it can downscale to the desired coordinates)
self._client_properties["encoding.render-size"] = (ww, wh)
backing.init(ww, wh, bw, bh)
return backing

Expand Down
1 change: 1 addition & 0 deletions src/xpra/client/window_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def get_encoding_properties(self):
"encoding.transparency" : self._alpha_enabled,
"encoding.full_csc_modes" : self._get_full_csc_modes(self.RGB_MODES),
"encoding.send-window-size" : True,
"encoding.render-size" : self.render_size,
}

def _get_full_csc_modes(self, rgb_modes):
Expand Down
5 changes: 5 additions & 0 deletions src/xpra/server/window/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def __init__(self,
self.rgb_zlib = compression.use_zlib and encoding_options.boolget("rgb_zlib", True) #server and client support zlib pixel compression
self.rgb_lz4 = compression.use_lz4 and encoding_options.boolget("rgb_lz4", False) #server and client support lz4 pixel compression
self.rgb_lzo = compression.use_lzo and encoding_options.boolget("rgb_lzo", False) #server and client support lzo pixel compression
self.client_render_size = encoding_options.get("render-size")
self.client_bit_depth = encoding_options.intget("bit-depth", 24)
self.supports_transparency = HAS_ALPHA and encoding_options.boolget("transparency")
self.full_frames_only = self.is_tray or encoding_options.boolget("full_frames_only")
Expand Down Expand Up @@ -517,6 +518,9 @@ def get_info(self) -> dict:
ma = self.mapped_at
if ma:
info["mapped-at"] = ma
crs = self.client_render_size
if crs:
info["render-size"] = crs
info["damage.fps"] = int(self.get_damage_fps())
if self.pixel_format:
info["pixel-format"] = self.pixel_format
Expand Down Expand Up @@ -672,6 +676,7 @@ def set_client_properties(self, properties):

def do_set_client_properties(self, properties):
self.maximized = properties.boolget("maximized", False)
self.client_render_size = properties.intpair("encoding.render-size")
self.client_bit_depth = properties.intget("bit-depth", self.client_bit_depth)
self.client_refresh_encodings = properties.strtupleget("encoding.auto_refresh_encodings", self.client_refresh_encodings)
self.full_frames_only = self.is_tray or properties.boolget("encoding.full_frames_only", self.full_frames_only)
Expand Down
9 changes: 9 additions & 0 deletions src/xpra/server/window/window_video_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,15 @@ def calculate_scaling(self, width, height, max_w=4096, max_h=4096):
s = self._current_speed
now = monotonic_time()
def get_min_required_scaling(default_value=(1, 1)):
crs = self.client_render_size
if crs:
#if the client is going to downscale things anyway,
#then there is no need to send at a higher resolution than that:
crsw, crsh = crs
if crsw<max_w:
max_w = crsw
if crsh<max_h:
max_h = crsh
if width<=max_w and height<=max_h:
return default_value #no problem
#most encoders can't deal with that!
Expand Down

0 comments on commit 2beaa24

Please sign in to comment.