Skip to content

Commit

Permalink
#640 OpenGL for gtk3:
Browse files Browse the repository at this point in the history
* move gl init to generic gtk client class
* move most gl backing code to generic superclass and only keep version specific code in new gtk2 / gtk3 submodules
* use context manager instead of try + finally to ensure we close the gl context

Note: the gtk3 code does not actually close the context.. because that crashes!

git-svn-id: https://xpra.org/svn/Xpra/trunk@7599 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 14, 2014
1 parent 6290aea commit 451a545
Show file tree
Hide file tree
Showing 14 changed files with 428 additions and 259 deletions.
8 changes: 7 additions & 1 deletion src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1615,8 +1615,14 @@ def cython_add(*args, **kwargs):
toggle_packages(client_ENABLED and gtk3_ENABLED, "xpra.client.gtk3", "gi")
toggle_packages(client_ENABLED and qt4_ENABLED, "xpra.client.qt4", "PyQt4")
toggle_packages(client_ENABLED and (gtk2_ENABLED or gtk3_ENABLED), "xpra.client.gtk_base")
toggle_packages(client_ENABLED and opengl_ENABLED and gtk2_ENABLED, "xpra.client.gl.gtk2")
toggle_packages(client_ENABLED and opengl_ENABLED and gtk3_ENABLED, "xpra.client.gl.gtk3")
#we can't just include "xpra.client.gl" because cx_freeze and py2exe then do the wrong thing
#and try to include both gtk3 and gtk2, and fail hard..
for x in ("gl_check", "gl_colorspace_conversions", "gl_window_backing_base", "gtk_compat"):
toggle_packages(client_ENABLED and opengl_ENABLED, "xpra.client.gl.%s" % x)

toggle_packages(sound_ENABLED, "xpra.sound")
toggle_packages(client_ENABLED and opengl_ENABLED, "xpra.client.gl")

toggle_packages(clipboard_ENABLED, "xpra.clipboard")
if clipboard_ENABLED:
Expand Down
34 changes: 13 additions & 21 deletions src/xpra/client/gl/gl_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
BLACKLIST["vendor"].append("Intel Inc.")
WHITELIST["renderer"] = ["Intel HD Graphics 4000 OpenGL Engine"]


DEFAULT_ALPHA = not sys.platform.startswith("win") and not sys.platform.startswith("darwin")
#alpha requires gtk3 or *nix only for gtk2:
DEFAULT_ALPHA = sys.version>'3' or (not sys.platform.startswith("win") and not sys.platform.startswith("darwin"))
GL_ALPHA_SUPPORTED = os.environ.get("XPRA_ALPHA", DEFAULT_ALPHA) in (True, "1")
DEFAULT_DOUBLE_BUFFERED = 0
if sys.platform.startswith("win"):
#needed on win32?
DEFAULT_DOUBLE_BUFFERED = 1
#not working with gtk3 yet?
CAN_DOUBLE_BUFFER = True
#needed on win32?:
DEFAULT_DOUBLE_BUFFERED = sys.platform.startswith("win") and CAN_DOUBLE_BUFFER
DOUBLE_BUFFERED = os.environ.get("XPRA_OPENGL_DOUBLE_BUFFERED", str(DEFAULT_DOUBLE_BUFFERED))=="1"


Expand Down Expand Up @@ -116,16 +117,9 @@ def check_functions(*functions):

#sanity checks: OpenGL version and fragment program support:
def check_GL_support(widget, min_texture_size=0, force_enable=False):
from xpra.client.gl.gtk_compat import begin_gl, end_gl
try:
if not begin_gl(widget):
raise ImportError("failed to get an opengl context")
except Exception as e:
raise ImportError("error getting an opengl context: %s" % e)
try:
from xpra.client.gl.gtk_compat import GLContextManager
with GLContextManager(widget):
return do_check_GL_support(min_texture_size, force_enable)
finally:
end_gl(widget)

def do_check_GL_support(min_texture_size, force_enable):
props = {}
Expand Down Expand Up @@ -369,16 +363,16 @@ def check_support(min_texture_size=0, force_enable=False, check_colormap=False):

props = {}
#this will import gtk.gtkgl / gdkgl or gi.repository.GtkGLExt / GdkGLExt:
from xpra.client.gl.gtk_compat import get_info, gtkgl, gdkgl, Config_new_by_mode, MODE_DOUBLE, RGBA_TYPE
from xpra.client.gl.gtk_compat import get_info, gdkgl, Config_new_by_mode, MODE_DOUBLE, GLDrawingArea
props.update(get_info())
display_mode = get_DISPLAY_MODE()
glconfig = Config_new_by_mode(display_mode)
if glconfig is None:
if glconfig is None and CAN_DOUBLE_BUFFER:
log("trying to toggle double-buffering")
display_mode &= ~MODE_DOUBLE
glconfig = Config_new_by_mode(display_mode)
if not glconfig:
raise Exception("cannot setup an OpenGL context")
if not glconfig:
raise Exception("cannot setup an OpenGL context")
props["display_mode"] = get_MODE_names(display_mode)
props["glconfig"] = glconfig
props["has_alpha"] = glconfig.has_alpha()
Expand All @@ -400,9 +394,7 @@ def check_support(min_texture_size=0, force_enable=False, check_colormap=False):
w = gtk.Window()
w.set_decorated(False)
vbox = gtk.VBox()
glarea = gtk.DrawingArea()
# Set OpenGL-capability to the widget
gtkgl.widget_set_gl_capability(glarea, glconfig, None, True, RGBA_TYPE)
glarea = GLDrawingArea(glconfig)
glarea.set_size_request(32, 32)
vbox.add(glarea)
vbox.show_all()
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/client/gl/gl_colorspace_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# * Michael Dominic K. <mdk@mdk.am>
#http://www.mdk.org.pl/2007/11/17/gl-colorspace-conversions

YUV2RGB_shader = """!!ARBfp1.0
YUV2RGB_shader = b"""!!ARBfp1.0
# cgc version 3.1.0010, build date Feb 10 2012
# command line args: -profile arbfp1
# source file: yuv.cg
Expand Down Expand Up @@ -71,7 +71,7 @@
# return OUT;
#}

RGBP2RGB_shader = """!!ARBfp1.0
RGBP2RGB_shader = b"""!!ARBfp1.0
# cgc version 3.1.0013, build date Apr 24 2012
# command line args: -profile arbfp1
# source file: a.cg
Expand Down
Loading

0 comments on commit 451a545

Please sign in to comment.