Commits

ant...@3bb7dfac-3a0b-4e04-842a-767bc560f471  committed 601d543

client tells the server if it handles transparency so we can save 1/4 of pixel data (only done for png for now)

  • Participants
  • Parent commits 87a02c1

Comments (0)

Files changed (3)

File src/xpra/client/gtk2/client.py

                 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()

File src/xpra/client/ui_client_base.py

         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
         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

File src/xpra/server/window_source.py

                                                         #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")]
             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":
         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"
                "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