Skip to content

Commit

Permalink
#650: honour the client's list of allowed rgb pixel formats, and conv…
Browse files Browse the repository at this point in the history
…ert to a new format if necessary

git-svn-id: https://xpra.org/svn/Xpra/trunk@7405 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 22, 2014
1 parent a38147c commit 1a8505c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/xpra/server/picture_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ def warn_encoding_once(key, message):
encoding_warnings.add(key)


def webp_encode(coding, image, supports_transparency, quality, speed, options):
def webp_encode(coding, image, rgb_formats, supports_transparency, quality, speed, options):
pixel_format = image.get_pixel_format()
#log("rgb_encode%s pixel_format=%s, rgb_formats=%s", (coding, image, rgb_formats, supports_transparency, speed, rgb_zlib, rgb_lz4), pixel_format, rgb_formats)
if pixel_format not in rgb_formats:
if not rgb_reformat(image, rgb_formats, supports_transparency):
raise Exception("cannot find compatible rgb format to use for %s! (supported: %s)" % (pixel_format, rgb_formats))
#get the new format:
pixel_format = image.get_pixel_format()
stride = image.get_rowstride()
enc_webp = get_codec("enc_webp")
if enc_webp and stride>0 and stride%4==0 and image.get_pixel_format() in ("BGRA", "BGRX"):
if enc_webp and stride>0 and stride%4==0 and image.get_pixel_format() in ("BGRA", "BGRX", "RGBA", "RGBX"):
#prefer Cython module:
alpha = supports_transparency and image.get_pixel_format().find("A")>=0
w = image.get_width()
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ def make_data_packet(self, damage_time, process_damage_time, wid, image, coding,
def webp_encode(self, coding, image, options):
q = options.get("quality") or self.get_quality(coding)
s = options.get("speed") or self.get_speed(coding)
return webp_encode(coding, image, self.supports_transparency, q, s, options)
return webp_encode(coding, image, self.rgb_formats, self.supports_transparency, q, s, options)

def rgb_encode(self, coding, image, options):
s = options.get("speed") or self._current_speed
Expand Down

0 comments on commit 1a8505c

Please sign in to comment.