Skip to content

Commit

Permalink
accept 16 bit display-depth and use RGB565 (no alpha) or RGB5_A1 (1 b…
Browse files Browse the repository at this point in the history
…it alpha)

git-svn-id: https://xpra.org/svn/Xpra/trunk@16326 3bb7dfac-3a0b-4e04-842a-767bc560f471
totaam committed Jul 13, 2017
1 parent 515344a commit d33cd25
Showing 2 changed files with 27 additions and 7 deletions.
32 changes: 26 additions & 6 deletions src/xpra/client/gl/gl_window_backing_base.py
Original file line number Diff line number Diff line change
@@ -52,8 +52,8 @@
GL_TEXTURE0, GL_TEXTURE1, GL_TEXTURE2, GL_QUADS, GL_POLYGON, GL_LINE_LOOP, GL_LINES, GL_COLOR_BUFFER_BIT, \
GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER, \
GL_DONT_CARE, GL_TRUE, GL_DEPTH_TEST, GL_SCISSOR_TEST, GL_LIGHTING, GL_DITHER, \
GL_RGB, GL_RGBA, GL_BGR, GL_BGRA, GL_RGBA8, GL_RGB8, \
GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_10_10_10_2, GL_RGB10_A2, \
GL_RGB, GL_RGBA, GL_BGR, GL_BGRA, GL_RGBA8, GL_RGB8, GL_RGB10_A2, GL_RGB565, GL_RGB5_A1, \
GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_SHORT_5_6_5, \
GL_BLEND, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, \
GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_BASE_LEVEL, \
GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST, \
@@ -89,10 +89,14 @@
"BGRX" : GL_BGRA,
"RGBA" : GL_RGBA,
"RGBX" : GL_RGBA,
"BGR565": GL_BGR,
"RGB565": GL_RGB,
}
PIXEL_FORMAT_TO_DATATYPE = {
"r210" : GL_UNSIGNED_INT_2_10_10_10_REV,
"R210" : GL_UNSIGNED_INT_10_10_10_2,
"RGB565": GL_UNSIGNED_SHORT_5_6_5,
"BGR565": GL_UNSIGNED_SHORT_5_6_5,
"BGR" : GL_UNSIGNED_BYTE,
"RGB" : GL_UNSIGNED_BYTE,
"BGRA" : GL_UNSIGNED_BYTE,
@@ -110,11 +114,14 @@
GL_RGB10_A2 : "RGB10_A2",
GL_RGBA8 : "RGBA8",
GL_RGB8 : "RGB8",
GL_RGB565 : "RGB565",
GL_RGB5_A1 : "RGB5_A1",
}
DATATYPE_TO_STR = {
GL_UNSIGNED_INT_2_10_10_10_REV : "UNSIGNED_INT_2_10_10_10_REV",
GL_UNSIGNED_INT_10_10_10_2 : "UNSIGNED_INT_10_10_10_2",
GL_UNSIGNED_BYTE : "UNSIGNED_BYTE",
GL_UNSIGNED_SHORT_5_6_5 : "UNSIGNED_SHORT_5_6_5",
}

#debugging variables:
@@ -230,18 +237,31 @@ def __init__(self, wid, window_alpha, pixel_depth=0):
self.init_backing()
self.bit_depth = self.get_bit_depth(pixel_depth)
if self.bit_depth==30:
self.texture_pixel_format = GL_RGBA
self.internal_format = GL_RGB10_A2
if "r210" not in GLWindowBackingBase.RGB_MODES:
GLWindowBackingBase.RGB_MODES.append("r210")
if self.bit_depth==16:
#GL_UNSIGNED_SHORT_4_4_4_4
#GL_UNSIGNED_SHORT_5_5_5_1
if self._alpha_enabled:
self.internal_format = GL_RGB5_A1
else:
self.internal_format = GL_RGB565
if "BGR565" not in GLWindowBackingBase.RGB_MODES:
GLWindowBackingBase.RGB_MODES.append("BGR565")
if "RGB565" not in GLWindowBackingBase.RGB_MODES:
GLWindowBackingBase.RGB_MODES.append("RGB565")
else:
#(pixels are always stored in 32bpp - but this makes it clearer when we do/don't support alpha)
#assume 24:
if self._alpha_enabled:
self.internal_format = GL_RGBA8
self.texture_pixel_format = GL_RGBA
else:
self.internal_format = GL_RGB8
self.texture_pixel_format = GL_RGB
#(pixels are always stored in 32bpp - but this makes it clearer when we do/don't support alpha)
if self._alpha_enabled:
self.texture_pixel_format = GL_RGBA
else:
self.texture_pixel_format = GL_RGB
self.draw_needs_refresh = False
self._backing.show()

2 changes: 1 addition & 1 deletion src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
@@ -341,7 +341,7 @@ def init(self, opts):
self.xscale, self.yscale = self.initial_scaling

self.pixel_depth = int(opts.pixel_depth)
if self.pixel_depth<0 or (self.pixel_depth>0 and self.pixel_depth<24) or (self.pixel_depth>24 and self.pixel_depth<30):
if self.pixel_depth not in (0, 16, 24, 30) and self.pixel_depth<32:
log.warn("Warning: invalid pixel depth %i", self.pixel_depth)
self.pixel_depth = 0
self.dpi = int(opts.dpi)

0 comments on commit d33cd25

Please sign in to comment.