Skip to content

Commit

Permalink
prepare for YUV422P10 support
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@26904 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 6, 2020
1 parent 755c685 commit 7b1d22a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/xpra/client/gl/gl_window_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
GL_PROJECTION, GL_MODELVIEW,
GL_UNPACK_ROW_LENGTH, GL_UNPACK_ALIGNMENT,
GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_NEAREST,
GL_UNSIGNED_BYTE, GL_LUMINANCE, GL_LINEAR,
GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT,
GL_LUMINANCE, GL_LINEAR,
GL_TEXTURE0, GL_TEXTURE1, GL_TEXTURE2, GL_QUADS, 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,
Expand Down Expand Up @@ -118,6 +119,9 @@
"BGRX" : GL_UNSIGNED_BYTE,
"RGBA" : GL_UNSIGNED_BYTE,
"RGBX" : GL_UNSIGNED_BYTE,
"YUV420P" : GL_UNSIGNED_BYTE,
"YUV422P" : GL_UNSIGNED_BYTE,
"YUV444P" : GL_UNSIGNED_BYTE,
}
CONSTANT_TO_PIXEL_FORMAT = {
GL_BGR : "BGR",
Expand Down Expand Up @@ -1115,7 +1119,7 @@ def gl_paint_planar(self, shader, flush, encoding, img,
x, y = self.gravity_adjust(x, y, options)
try:
pixel_format = img.get_pixel_format()
assert pixel_format in ("YUV420P", "YUV422P", "YUV444P", "GBRP"), \
assert pixel_format in ("YUV420P", "YUV422P", "YUV444P", "GBRP", ), \
"sorry the GL backing does not handle pixel format '%s' yet!" % (pixel_format)

context = self.gl_context()
Expand Down Expand Up @@ -1156,6 +1160,7 @@ def update_planar_textures(self, width : int, height : int, img, pixel_format, s
assert self.textures is not None, "no OpenGL textures!"
log("%s.update_planar_textures%s", self, (width, height, img, pixel_format))

upload_format = PIXEL_FORMAT_TO_DATATYPE[pixel_format]
divs = get_subsampling_divs(pixel_format)
if self.pixel_format is None or self.pixel_format!=pixel_format or self.texture_size!=(width, height):
self.gl_marker("Creating new planar textures, pixel format %s (was %s), texture size %s (was %s)",
Expand All @@ -1173,17 +1178,18 @@ def update_planar_textures(self, width : int, height : int, img, pixel_format, s
mag_filter = GL_LINEAR
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, mag_filter)
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexImage2D(target, 0, GL_LUMINANCE, width//div_w, height//div_h, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, None)
glTexImage2D(target, 0, GL_LUMINANCE, width//div_w, height//div_h, 0, GL_LUMINANCE, upload_format, None)
#glBindTexture(target, 0) #redundant: we rebind below:

self.gl_marker("updating planar textures: %sx%s %s", width, height, pixel_format)
rowstrides = img.get_rowstride()
img_data = img.get_pixels()
BPP = 1
assert len(rowstrides)==3 and len(img_data)==3
for texture, index, tex_name in (
(GL_TEXTURE0, TEX_Y, "Y"),
(GL_TEXTURE1, TEX_U, "U"),
(GL_TEXTURE2, TEX_V, "V"),
(GL_TEXTURE0, TEX_Y, "Y"*BPP),
(GL_TEXTURE1, TEX_U, "U"*BPP),
(GL_TEXTURE2, TEX_V, "V"*BPP),
):
div_w, div_h = divs[index]
w = width//div_w
Expand All @@ -1205,7 +1211,7 @@ def update_planar_textures(self, width : int, height : int, img, pixel_format, s
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, 0)
except Exception:
pass
glTexSubImage2D(target, 0, 0, 0, w, h, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixel_data)
glTexSubImage2D(target, 0, 0, 0, w, h, GL_LUMINANCE, upload_format, pixel_data)
glBindTexture(target, 0)
#glActiveTexture(GL_TEXTURE0) #redundant, we always call render_planar_update afterwards

Expand Down

0 comments on commit 7b1d22a

Please sign in to comment.