Skip to content

Commit

Permalink
gl: add untested GBRP painting support
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@3923 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
Arthur Huillet committed Jul 21, 2013
1 parent f33fd2b commit 9bb000f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
57 changes: 56 additions & 1 deletion src/xpra/client/gl/gl_colorspace_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,61 @@
END
# 10 instructions, 2 R-regs
"""
# The following fragprog is a derived work of the above.
# Source Cg is :
#
#struct pixel_in {
# float2 texcoord1 : TEXCOORD0;
# float2 texcoord2 : TEXCOORD1;
# float2 texcoord3 : TEXCOORD2;
# uniform samplerRECT texture1 : TEXUNIT0;
# uniform samplerRECT texture2 : TEXUNIT1;
# uniform samplerRECT texture3 : TEXUNIT2;
# float4 color : COLOR0;
#};
#
#struct pixel_out {
# float4 color : COLOR0;
#};
#
#pixel_out
#main (pixel_in IN)
#{
# pixel_out OUT;
#
# OUT.color.r = texRECT(IN.texture1, IN.texcoord1).r;
# OUT.color.g = texRECT(IN.texture2, IN.texcoord2).r;
# OUT.color.b = texRECT(IN.texture3, IN.texcoord3).r;
# OUT.color.a = IN.color.a;
#
# return OUT;
#}

RGBP2RGB_shader = """
RGBP2RGB_shader = """!!ARBfp1.0
# cgc version 3.1.0013, build date Apr 24 2012
# command line args: -profile arbfp1
# source file: a.cg
#vendor NVIDIA Corporation
#version 3.1.0.13
#profile arbfp1
#program main
#semantic main.IN
#var float2 IN.texcoord1 : $vin.TEXCOORD0 : TEX0 : 0 : 1
#var float2 IN.texcoord2 : $vin.TEXCOORD1 : TEX1 : 0 : 1
#var float2 IN.texcoord3 : $vin.TEXCOORD2 : TEX2 : 0 : 1
#var samplerRECT IN.texture1 : TEXUNIT0 : texunit 0 : 0 : 1
#var samplerRECT IN.texture2 : TEXUNIT1 : texunit 1 : 0 : 1
#var samplerRECT IN.texture3 : TEXUNIT2 : texunit 2 : 0 : 1
#var float4 IN.color : $vin.COLOR0 : COL0 : 0 : 1
#var float4 main.color : $vout.COLOR0 : COL : -1 : 1
TEMP R0;
TEMP R1;
TEX R0.x, fragment.texcoord[2], texture[2], RECT;
TEX R1.x, fragment.texcoord[1], texture[1], RECT;
MOV result.color.w, fragment.color.primary;
MOV result.color.z, R0.x;
MOV result.color.y, R1.x;
TEX result.color.x, fragment.texcoord[0], texture[0], RECT;
END
# 6 instructions, 2 R-regs
"""
16 changes: 15 additions & 1 deletion src/xpra/client/gl/gl_window_backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def gl_init(self):

# Default state is good for YUV painting:
# - fragment program enabled
# - YUV fragment program bound
# - YUV fragment program bound
# - render to offscreen FBO
glEnable(GL_FRAGMENT_PROGRAM_ARB)
if self.textures is None:
Expand Down Expand Up @@ -250,6 +250,16 @@ def unset_rgb24_paint_state(self):
self.gl_marker("Switching back to YUV paint state")
glEnable(GL_FRAGMENT_PROGRAM_ARB)

def set_rgbP_paint_state(self):
# Set GL state for planar RGB:
# change fragment program
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, self.shaders[1])

def unset_rgbP_paint_state(self):
# Reset state to our default (YUV painting):
# change fragment program
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, self.shaders[0])

def present_fbo(self, drawable):
debug("present_fbo() drawable=%s", drawable)
self.gl_marker("Presenting FBO on screen")
Expand Down Expand Up @@ -438,6 +448,8 @@ def render_planar_update(self, rx, ry, rw, rh, x_scale=1, y_scale=1):
#not ready to render yet
return
assert rx==0 and ry==0
if self.pixel_format == "BGRP":
self.set_rgbP_paint_state()
self.gl_marker("Painting planar update, format %s" % (self.pixel_format))
divs = get_subsampling_divs(self.pixel_format)
glEnable(GL_FRAGMENT_PROGRAM_ARB)
Expand All @@ -456,3 +468,5 @@ def render_planar_update(self, rx, ry, rw, rh, x_scale=1, y_scale=1):
glMultiTexCoord2i(texture, ax/div_w, ay/div_h)
glVertex2i(int(ax*x_scale), int(ay*y_scale))
glEnd()
if self.pixel_format == "BGRP":
self.unset_rgbP_paint_state()

0 comments on commit 9bb000f

Please sign in to comment.