Skip to content

Commit

Permalink
client tells the server if it handles transparency so we can save 1/4…
Browse files Browse the repository at this point in the history
… of pixel data (only done for png for now)

git-svn-id: https://xpra.org/svn/Xpra/trunk@3772 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 5, 2013
1 parent 46ffdf9 commit 1edba9b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/xpra/client/gtk2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def get_core_encodings(self):
encodings.append(x)
return encodings

def has_transparency(self):
return gdk.screen_get_default().get_rgba_visual() is not None


def _startup_complete(self, *args):
GTKXpraClient._startup_complete(self, *args)
gtk.gdk.notify_startup_complete()
Expand Down
4 changes: 4 additions & 0 deletions src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ def make_hello(self, challenge_response=None):
capabilities["encoding.csc_atoms"] = True
#TODO: check for csc support (swscale only?)
capabilities["encoding.video_scaling"] = True
capabilities["encoding.transparency"] = self.has_transparency()
#TODO: check for csc support (swscale only?)
capabilities["encoding.csc_modes"] = ("YUV420P", "YUV422P", "YUV444P", "BGRA")
capabilities["rgb24zlib"] = True
Expand Down Expand Up @@ -515,6 +516,9 @@ def make_hello(self, challenge_response=None):
log("batch props=%s", [("%s=%s" % (k,v)) for k,v in capabilities.items() if k.startswith("batch.")])
return capabilities

def has_transparency(self):
return False


def server_ok(self):
return self._server_ok
Expand Down
8 changes: 6 additions & 2 deletions src/xpra/server/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def __init__(self, idle_add, timeout_add, source_remove,
#does the client support encoding options?
self.supports_rgb24zlib = encoding_options.get("rgb24zlib", False)
#supports rgb24 compression outside network layer (unwrapped)
self.supports_transparency = encoding_options.get("transparency", False)
self.supports_delta = []
if xor_str is not None and not window.is_tray():
self.supports_delta = [x for x in encoding_options.get("supports_delta", []) if x in ("png", "rgb24", "rgb32")]
Expand Down Expand Up @@ -504,7 +505,7 @@ def switch_to_lossless(reason):
coding = self.find_common_lossless_encoder(has_alpha, current_encoding, ww*wh)
debug("do_get_best_encoding(..) temporarily switching to %s encoder for %s pixels: %s", coding, pixel_count, reason)
return coding
if has_alpha:
if has_alpha and self.supports_transparency:
if current_encoding in ("png", "rgb32", "webp"):
return current_encoding
if current_encoding=="rgb":
Expand Down Expand Up @@ -563,7 +564,7 @@ def get_core_encoding(self, has_alpha, current_encoding):
return current_encoding

def find_common_lossless_encoder(self, has_alpha, fallback, pixel_count):
if has_alpha:
if has_alpha and self.supports_transparency:
rgb_fmt = "rgb32"
else:
rgb_fmt = "rgb24"
Expand Down Expand Up @@ -907,6 +908,9 @@ def PIL_encode(self, coding, image, options):
"RGBA" : "RGBA",
"BGRA" : "RGBA",
}.get(pixel_format, pixel_format)
#remove transparency if not handled by the client:
if coding.startswith("png") and not self.supports_transparency and rgb=="RGBA":
rgb = "RGB"
try:
#it is safe to use frombuffer() here since the convert()
#calls below will not convert and modify the data in place
Expand Down

0 comments on commit 1edba9b

Please sign in to comment.