Skip to content

Commit

Permalink
window scaling for gl clients
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@3906 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 20, 2013
1 parent 1febab9 commit 3d0c97e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/xpra/client/gl/gl_client_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def __init__(self, client, group_leader, wid, x, y, w, h, metadata, override_red
ClientWindow.__init__(self, client, group_leader, wid, x, y, w, h, metadata, override_redirect, client_properties, auto_refresh_delay)
#tell the server that we don't want RGB data by specifying only YUV modes:
self._client_properties["encoding.csc_modes"] = ("YUV420P", "YUV422P", "YUV444P")
self._client_properties["encoding.video_scaling"] = False
self.set_reallocate_redraws(True)
self.add(self._backing.glarea)

Expand Down
17 changes: 8 additions & 9 deletions src/xpra/client/gl/gl_window_backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,12 @@ def _do_paint_rgb24(self, img_data, x, y, width, height, rowstride, options, cal

def do_video_paint(self, img, x, y, enc_width, enc_height, width, height, options, callbacks):
#we need to run in UI thread from here on!
#debug("paint_yuv(..) will call via idle_add")
assert enc_width==width and enc_height==height, "scaling not implemented for OpenGL!"
#ideally, the decoder would manage buffers properly...
#instead of relying on us making a copy before leaving the decoding thread
img.clone_pixel_data()
gobject.idle_add(self.gl_paint_yuv, img, x, y, width, height, callbacks)
gobject.idle_add(self.gl_paint_yuv, img, x, y, enc_width, enc_height, width, height, callbacks)

def gl_paint_yuv(self, img, x, y, w, h, callbacks):
def gl_paint_yuv(self, img, x, y, enc_width, enc_height, width, height, callbacks):
#this function runs in the UI thread, no video_decoder lock held
pixel_format = img.get_pixel_format()
assert pixel_format in ("YUV420P", "YUV422P", "YUV444P"), "sorry the GL backing does not handle pixel format %s yet!" % (pixel_format)
Expand All @@ -350,10 +348,10 @@ def gl_paint_yuv(self, img, x, y, w, h, callbacks):
return
try:
try:
self.update_texture_yuv(x, y, w, h, img, pixel_format)
self.update_texture_yuv(x, y, enc_width, enc_height, img, pixel_format)
if self.paint_screen:
# Update FBO texture
self.render_yuv_update(x, y, x+w, y+h)
self.render_yuv_update(x, y, enc_width, enc_height, x_scale=width/enc_width, y_scale=height/enc_height)
# Present it on screen
self.present_fbo(drawable)
fire_paint_callbacks(callbacks, True)
Expand Down Expand Up @@ -428,11 +426,12 @@ def update_texture_yuv(self, x, y, width, height, img, 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)

def render_yuv_update(self, rx, ry, rw, rh):
debug("render_yuv_update %sx%s at %sx%s pixel_format=%s", rw, rh, rx, ry, self.pixel_format)
def render_yuv_update(self, rx, ry, rw, rh, x_scale=1, y_scale=1):
log("render_yuv_update%s pixel_format=%s", (rx, ry, rw, rh, x_scale, y_scale), self.pixel_format)
if self.pixel_format not in ("YUV420P", "YUV422P", "YUV444P"):
#not ready to render yet
return
assert rx==0 and ry==0
self.gl_marker("Painting YUV update")
divs = get_subsampling_divs(self.pixel_format)
glEnable(GL_FRAGMENT_PROGRAM_ARB)
Expand All @@ -450,5 +449,5 @@ def render_yuv_update(self, rx, ry, rw, rh):
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(ax, ay)
glVertex2i(int(ax*x_scale), int(ay*y_scale))
glEnd()

0 comments on commit 3d0c97e

Please sign in to comment.