From 0027354c70386a56a3e3ac620de48c56a80bf174 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Tue, 11 Feb 2014 14:09:19 +0000 Subject: [PATCH] #410 support video regions client side: video data that is not necessarily at 0,0 * add "encoding.video_subregion" capability * remove check in window backing base * use offset in gl code (and remove pointless checks) git-svn-id: https://xpra.org/svn/Xpra/trunk@5429 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/gl/gl_window_backing.py | 21 ++++----------------- src/xpra/client/ui_client_base.py | 1 + src/xpra/client/window_backing_base.py | 1 - 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/xpra/client/gl/gl_window_backing.py b/src/xpra/client/gl/gl_window_backing.py index dc36540644..be4d31bb50 100644 --- a/src/xpra/client/gl/gl_window_backing.py +++ b/src/xpra/client/gl/gl_window_backing.py @@ -512,7 +512,6 @@ def gl_paint_planar(self, img, x, y, enc_width, enc_height, width, height, callb fire_paint_callbacks(callbacks, False) def update_planar_textures(self, x, y, width, height, img, pixel_format, scaling=False): - assert x==0 and y==0 assert self.textures is not None, "no OpenGL textures!" log("%s.update_planar_textures%s", self, (x, y, width, height, img, pixel_format)) @@ -539,12 +538,9 @@ def update_planar_textures(self, x, y, width, height, img, pixel_format, scaling self.gl_marker("updating planar textures: %sx%s %s" % (width, height, pixel_format)) - U_width = 0 - U_height = 0 rowstrides = img.get_rowstride() img_data = img.get_pixels() - assert len(rowstrides)==3 - assert len(img_data)==3 + assert len(rowstrides)==3 and len(img_data)==3 for texture, index in ((GL_TEXTURE0, 0), (GL_TEXTURE1, 1), (GL_TEXTURE2, 2)): (div_w, div_h) = divs[index] glActiveTexture(texture) @@ -552,22 +548,13 @@ def update_planar_textures(self, x, y, width, height, img, pixel_format, scaling glPixelStorei(GL_UNPACK_ROW_LENGTH, rowstrides[index]) pixel_data = img_data[index] log("texture %s: div=%s, rowstride=%s, %sx%s, data=%s bytes", index, divs[index], rowstrides[index], width/div_w, height/div_h, len(pixel_data)) - glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, x, y, width/div_w, height/div_h, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixel_data) - if index == 1: - U_width = width/div_w - U_height = height/div_h - elif index == 2: - if width/div_w != U_width: - log.error("Width of V plane is %d, differs from width of corresponding U plane (%d), pixel_format is %d", width/div_w, U_width, pixel_format) - if height/div_h != U_height: - log.error("Height of V plane is %d, differs from height of corresponding U plane (%d), pixel_format is %d", height/div_h, U_height, pixel_format) + glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width/div_w, height/div_h, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixel_data) def render_planar_update(self, rx, ry, rw, rh, x_scale=1, y_scale=1): log("%s.render_planar_update%s pixel_format=%s", self, (rx, ry, rw, rh, x_scale, y_scale), self.pixel_format) if self.pixel_format not in ("YUV420P", "YUV422P", "YUV444P", "GBRP"): #not ready to render yet return - assert rx==0 and ry==0 if self.pixel_format == "GBRP": self.set_rgbP_paint_state() self.gl_marker("painting planar update, format %s" % self.pixel_format) @@ -580,13 +567,13 @@ def render_planar_update(self, rx, ry, rw, rh, x_scale=1, y_scale=1): tw, th = self.texture_size log("%s.render_planar_update(..) texture_size=%s, size=%s", self, self.texture_size, self.size) glBegin(GL_QUADS) - for x,y in ((rx, ry), (rx, ry+rh), (rx+rw, ry+rh), (rx+rw, ry)): + for x,y in ((0, 0), (0, rh), (rw, rh), (rw, 0)): ax = min(tw, x) ay = min(th, y) for texture, index in ((GL_TEXTURE0, 0), (GL_TEXTURE1, 1), (GL_TEXTURE2, 2)): (div_w, div_h) = divs[index] glMultiTexCoord2i(texture, ax/div_w, ay/div_h) - glVertex2i(int(ax*x_scale), int(ay*y_scale)) + glVertex2i(int(rx+ax*x_scale), int(ry+ay*y_scale)) glEnd() if self.pixel_format == "GBRP": self.unset_rgbP_paint_state() diff --git a/src/xpra/client/ui_client_base.py b/src/xpra/client/ui_client_base.py index 64df8e3ca4..170d2168e1 100644 --- a/src/xpra/client/ui_client_base.py +++ b/src/xpra/client/ui_client_base.py @@ -683,6 +683,7 @@ def make_hello(self): "encoding_client_options" : True, "encoding.csc_atoms" : True, #TODO: check for csc support (swscale only?) + "encoding.video_subregion" : True, "encoding.video_reinit" : True, "encoding.video_scaling" : True, "encoding.rgb_lz4" : use_lz4 and self.compression_level==1, diff --git a/src/xpra/client/window_backing_base.py b/src/xpra/client/window_backing_base.py index b9e71b40ac..b22b9b3177 100644 --- a/src/xpra/client/window_backing_base.py +++ b/src/xpra/client/window_backing_base.py @@ -292,7 +292,6 @@ def make_csc(self, src_width, src_height, src_format, raise Exception("no csc module found for %s(%sx%s) to %s(%sx%s) in %s" % (src_format, src_width, src_height, " or ".join(dst_format_options), dst_width, dst_height, CSC_OPTIONS)) def paint_with_video_decoder(self, decoder_name, coding, img_data, x, y, width, height, options, callbacks): - assert x==0 and y==0 decoder_module = get_codec(decoder_name) assert decoder_module, "decoder module not found for %s" % decoder_name assert hasattr(decoder_module, "Decoder"), "decoder module %s does not have 'Decoder' factory function!" % decoder_module